blob: fdc2331263136c4a75bf431ec4d5d5b9224c60b7 [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"
83
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>
Jeff Johnson295189b2012-06-20 16:38:30 -070091
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;
165
166 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
167 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdActiveList)))
168 {
169 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdPendingList)))
170 {
171 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdFreeList)))
172 {
173 status = palAllocateMemory(pMac->hHdd, (void **)&pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
174 if(HAL_STATUS_SUCCESS(status))
175 {
176 tANI_U32 c;
177
178 palZeroMemory(pMac->hHdd, pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
179 pMac->sme.pSmeCmdBufAddr = pCmd;
180 for(c = 0; c < pMac->sme.totalSmeCmd; c++)
181 {
182 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd[c].Link, LL_ACCESS_LOCK);
183 }
184 }
185 }
186 }
187 }
188
189 return (status);
190}
191
192
193void smeReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCmd)
194{
195 pCmd->command = eSmeNoCommand;
196 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd->Link, LL_ACCESS_LOCK);
197}
198
199
200
201static void smeReleaseCmdList(tpAniSirGlobal pMac, tDblLinkList *pList)
202{
203 tListElem *pEntry;
204 tSmeCmd *pCommand;
205
206 while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_LOCK)) != NULL)
207 {
208 //TODO: base on command type to call release functions
209 //reinitialize different command types so they can be reused
210 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
211 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
212 }
213}
214
215static void purgeSmeCmdList(tpAniSirGlobal pMac)
216{
217 //release any out standing commands back to free command list
218 smeReleaseCmdList(pMac, &pMac->sme.smeCmdPendingList);
219 smeReleaseCmdList(pMac, &pMac->sme.smeCmdActiveList);
220}
221
222void purgeSmeSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
223{
224 //release any out standing commands back to free command list
225 tListElem *pEntry, *pNext;
226 tSmeCmd *pCommand;
227 tDblLinkList *pList = &pMac->sme.smeCmdPendingList;
228 tDblLinkList localList;
229
230 vos_mem_zero(&localList, sizeof(tDblLinkList));
231 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
232 {
233 smsLog(pMac, LOGE, FL(" failed to open list"));
234 return;
235 }
236
237 csrLLLock(pList);
238 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
239 while(pEntry != NULL)
240 {
241 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
242 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
243 if(pCommand->sessionId == sessionId)
244 {
245 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
246 {
247 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
248 }
249 }
250 pEntry = pNext;
251 }
252 csrLLUnlock(pList);
253
254 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
255 {
256 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
257 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
258 }
259 csrLLClose(&localList);
260
261}
262
263
264static eHalStatus freeSmeCmdList(tpAniSirGlobal pMac)
265{
266 eHalStatus status = eHAL_STATUS_SUCCESS;
267
268 purgeSmeCmdList(pMac);
269 csrLLClose(&pMac->sme.smeCmdPendingList);
270 csrLLClose(&pMac->sme.smeCmdActiveList);
271 csrLLClose(&pMac->sme.smeCmdFreeList);
272
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800273 status = vos_lock_acquire(&pMac->sme.lkSmeGlobalLock);
274 if(status != eHAL_STATUS_SUCCESS)
275 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800276 smsLog(pMac, LOGE,
277 FL("Failed to acquire the lock status = %d"), status);
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800278 goto done;
279 }
280
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 if(NULL != pMac->sme.pSmeCmdBufAddr)
282 {
283 status = palFreeMemory(pMac->hHdd, pMac->sme.pSmeCmdBufAddr);
284 pMac->sme.pSmeCmdBufAddr = NULL;
285 }
286
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800287 status = vos_lock_release(&pMac->sme.lkSmeGlobalLock);
288 if(status != eHAL_STATUS_SUCCESS)
289 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800290 smsLog(pMac, LOGE,
291 FL("Failed to release the lock status = %d"), status);
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800292 }
293done:
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 return (status);
295}
296
297
298void dumpCsrCommandInfo(tpAniSirGlobal pMac, tSmeCmd *pCmd)
299{
300#ifdef WLAN_DEBUG
301 switch( pCmd->command )
302 {
303 case eSmeCommandScan:
304 smsLog( pMac, LOGE, " scan command reason is %d", pCmd->u.scanCmd.reason );
305 break;
306
307 case eSmeCommandRoam:
308 smsLog( pMac, LOGE, " roam command reason is %d", pCmd->u.roamCmd.roamReason );
309 break;
310
311 case eSmeCommandWmStatusChange:
312 smsLog( pMac, LOGE, " WMStatusChange command type is %d", pCmd->u.wmStatusChangeCmd.Type );
313 break;
314
315 case eSmeCommandSetKey:
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800316 smsLog( pMac, LOGE, " setKey command auth(%d) enc(%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700317 pCmd->u.setKeyCmd.authType, pCmd->u.setKeyCmd.encType );
318 break;
319
320 case eSmeCommandRemoveKey:
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800321 smsLog( pMac, LOGE, " removeKey command auth(%d) enc(%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 pCmd->u.removeKeyCmd.authType, pCmd->u.removeKeyCmd.encType );
323 break;
324
325 default:
326 break;
327 }
328#endif //#ifdef WLAN_DEBUG
329}
330
331tSmeCmd *smeGetCommandBuffer( tpAniSirGlobal pMac )
332{
333 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
334 tListElem *pEntry;
335
336 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK );
337
338 // If we can get another MS Msg buffer, then we are ok. Just link
339 // the entry onto the linked list. (We are using the linked list
340 // to keep track of tfhe message buffers).
341 if ( pEntry )
342 {
343 pRetCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
344 }
345 else {
346 int idx = 1;
347
348 //Cannot change pRetCmd here since it needs to return later.
349 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
350 if( pEntry )
351 {
352 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
353 }
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800354 smsLog( pMac, LOGE, "Out of command buffer.... command (0x%X) stuck",
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
356 if(pTempCmd)
357 {
358 if( eSmeCsrCommandMask & pTempCmd->command )
359 {
360 //CSR command is stuck. See what the reason code is for that command
361 dumpCsrCommandInfo(pMac, pTempCmd);
362 }
363 } //if(pTempCmd)
364
365 //dump what is in the pending queue
366 csrLLLock(&pMac->sme.smeCmdPendingList);
367 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
368 while(pEntry)
369 {
370 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800371 smsLog( pMac, LOGE, "Out of command buffer.... SME pending command #%d (0x%X)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 idx++, pTempCmd->command );
373 if( eSmeCsrCommandMask & pTempCmd->command )
374 {
375 //CSR command is stuck. See what the reason code is for that command
376 dumpCsrCommandInfo(pMac, pTempCmd);
377 }
378 pEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
379 }
380 csrLLUnlock(&pMac->sme.smeCmdPendingList);
381
382 //There may be some more command in CSR's own pending queue
383 csrLLLock(&pMac->roam.roamCmdPendingList);
384 pEntry = csrLLPeekHead( &pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK );
385 while(pEntry)
386 {
387 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800388 smsLog( pMac, LOGE, "Out of command buffer.... CSR pending command #%d (0x%X)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 idx++, pTempCmd->command );
390 dumpCsrCommandInfo(pMac, pTempCmd);
391 pEntry = csrLLNext( &pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
392 }
393 csrLLUnlock(&pMac->roam.roamCmdPendingList);
394 }
395
396 return( pRetCmd );
397}
398
399
400void smePushCommand( tpAniSirGlobal pMac, tSmeCmd *pCmd, tANI_BOOLEAN fHighPriority )
401{
402 if ( fHighPriority )
403 {
404 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
405 }
406 else
407 {
408 csrLLInsertTail( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
409 }
410
411 // process the command queue...
412 smeProcessPendingQueue( pMac );
413
414 return;
415}
416
417
418static eSmeCommandType smeIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand )
419{
420 eSmeCommandType pmcCommand = eSmeNoCommand;
421 tANI_BOOLEAN fFullPowerNeeded = eANI_BOOLEAN_FALSE;
422 tPmcState pmcState;
423 eHalStatus status;
424
425 do
426 {
427 pmcState = pmcGetPmcState(pMac);
428
429 status = csrIsFullPowerNeeded( pMac, pCommand, NULL, &fFullPowerNeeded );
430 if( !HAL_STATUS_SUCCESS(status) )
431 {
432 //PMC state is not right for the command, drop it
433 return ( eSmeDropCommand );
434 }
435 if( fFullPowerNeeded ) break;
436 fFullPowerNeeded = ( ( eSmeCommandAddTs == pCommand->command ) ||
437 ( eSmeCommandDelTs == pCommand->command ) );
438 if( fFullPowerNeeded ) break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700439#ifdef FEATURE_OEM_DATA_SUPPORT
440 fFullPowerNeeded = (pmcState == IMPS &&
441 eSmeCommandOemDataReq == pCommand->command);
442 if(fFullPowerNeeded) break;
443#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 fFullPowerNeeded = (pmcState == IMPS &&
445 eSmeCommandRemainOnChannel == pCommand->command);
446 if(fFullPowerNeeded) break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 } while(0);
448
449 if( fFullPowerNeeded )
450 {
451 switch( pmcState )
452 {
453 case IMPS:
454 case STANDBY:
455 pmcCommand = eSmeCommandExitImps;
456 break;
457
458 case BMPS:
459 pmcCommand = eSmeCommandExitBmps;
460 break;
461
462 case UAPSD:
463 pmcCommand = eSmeCommandExitUapsd;
464 break;
465
466 case WOWL:
467 pmcCommand = eSmeCommandExitWowl;
468 break;
469
470 default:
471 break;
472 }
473 }
474
475 return ( pmcCommand );
476}
477
478
479//For commands that need to do extra cleanup.
480static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
481{
482 if( eSmePmcCommandMask & pCommand->command )
483 {
484 pmcAbortCommand( pMac, pCommand, fStopping );
485 }
486 else if ( eSmeCsrCommandMask & pCommand->command )
487 {
488 csrAbortCommand( pMac, pCommand, fStopping );
489 }
490 else
491 {
492 switch( pCommand->command )
493 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 case eSmeCommandRemainOnChannel:
495 if (NULL != pCommand->u.remainChlCmd.callback)
496 {
497 remainOnChanCallback callback =
498 pCommand->u.remainChlCmd.callback;
499 /* process the msg */
500 if( callback )
501 {
502 callback(pMac, pCommand->u.remainChlCmd.callbackCtx,
503 eCSR_SCAN_ABORT );
504 }
505 }
506 smeReleaseCommand( pMac, pCommand );
507 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 default:
509 smeReleaseCommand( pMac, pCommand );
510 break;
511 }
512 }
513}
514
515
516
517tANI_BOOLEAN smeProcessCommand( tpAniSirGlobal pMac )
518{
519 tANI_BOOLEAN fContinue = eANI_BOOLEAN_FALSE;
520 eHalStatus status = eHAL_STATUS_SUCCESS;
521 tListElem *pEntry;
522 tSmeCmd *pCommand;
523 eSmeCommandType pmcCommand = eSmeNoCommand;
524
525 // if the ActiveList is empty, then nothing is active so we can process a
526 // pending command...
527 //alwasy lock active list before locking pending list
528 csrLLLock( &pMac->sme.smeCmdActiveList );
529 if ( csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) )
530 {
531 if(!csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK))
532 {
533 //Peek the command
534 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK );
535 if( pEntry )
536 {
537 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
538 //We cannot execute any command in wait-for-key state until setKey is through.
539 if( CSR_IS_WAIT_FOR_KEY( pMac, pCommand->sessionId ) )
540 {
541 if( !CSR_IS_SET_KEY_COMMAND( pCommand ) )
542 {
543 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800544 smsLog(pMac, LOGE, " Cannot process command(%d) while waiting for key", pCommand->command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 return ( eANI_BOOLEAN_FALSE );
546 }
547 }
548 pmcCommand = smeIsFullPowerNeeded( pMac, pCommand );
549 if( eSmeDropCommand == pmcCommand )
550 {
551 //This command is not ok for current PMC state
552 if( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
553 {
554 smeAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE );
555 }
556 csrLLUnlock( &pMac->sme.smeCmdActiveList );
557 //tell caller to continue
558 return (eANI_BOOLEAN_TRUE);
559 }
560 else if( eSmeNoCommand != pmcCommand )
561 {
562 tExitBmpsInfo exitBmpsInfo;
563 void *pv = NULL;
564 tANI_U32 size = 0;
565 tSmeCmd *pPmcCmd = NULL;
566
567 if( eSmeCommandExitBmps == pmcCommand )
568 {
569 exitBmpsInfo.exitBmpsReason = eSME_REASON_OTHER;
570 pv = (void *)&exitBmpsInfo;
571 size = sizeof(tExitBmpsInfo);
572 }
573 //pmcCommand has to be one of the exit power save command
574 status = pmcPrepareCommand( pMac, pmcCommand, pv, size, &pPmcCmd );
575 if( HAL_STATUS_SUCCESS( status ) && pPmcCmd )
576 {
577 //Force this command to wake up the chip
578 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK );
579 csrLLUnlock( &pMac->sme.smeCmdActiveList );
580 fContinue = pmcProcessCommand( pMac, pPmcCmd );
581 if( fContinue )
582 {
583 //The command failed, remove it
584 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK ) )
585 {
586 pmcReleaseCommand( pMac, pPmcCmd );
587 }
588 }
589 }
590 else
591 {
592 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800593 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 -0700594 //Let it retry
595 fContinue = eANI_BOOLEAN_TRUE;
596 }
597 return fContinue;
598 }
599 if ( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
600 {
601 // we can reuse the pCommand
602
603 // Insert the command onto the ActiveList...
604 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pCommand->Link, LL_ACCESS_NOLOCK );
605
606 // .... and process the command.
607
608 switch ( pCommand->command )
609 {
610
611 case eSmeCommandScan:
612 csrLLUnlock( &pMac->sme.smeCmdActiveList );
613 status = csrProcessScanCommand( pMac, pCommand );
614 break;
615
616 case eSmeCommandRoam:
617 csrLLUnlock( &pMac->sme.smeCmdActiveList );
618 status = csrRoamProcessCommand( pMac, pCommand );
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800619 if(!HAL_STATUS_SUCCESS(status))
620 {
621 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
622 &pCommand->Link, LL_ACCESS_LOCK ) )
623 {
624 csrReleaseCommandRoam( pMac, pCommand );
625 }
626 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 break;
628
629 case eSmeCommandWmStatusChange:
630 csrLLUnlock( &pMac->sme.smeCmdActiveList );
631 csrRoamProcessWmStatusChangeCommand(pMac, pCommand);
632 break;
633
634 case eSmeCommandSetKey:
635 csrLLUnlock( &pMac->sme.smeCmdActiveList );
636 status = csrRoamProcessSetKeyCommand( pMac, pCommand );
637 if(!HAL_STATUS_SUCCESS(status))
638 {
639 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
640 &pCommand->Link, LL_ACCESS_LOCK ) )
641 {
642 csrReleaseCommandSetKey( pMac, pCommand );
643 }
644 }
645 break;
646
647 case eSmeCommandRemoveKey:
648 csrLLUnlock( &pMac->sme.smeCmdActiveList );
649 status = csrRoamProcessRemoveKeyCommand( pMac, pCommand );
650 if(!HAL_STATUS_SUCCESS(status))
651 {
652 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
653 &pCommand->Link, LL_ACCESS_LOCK ) )
654 {
655 csrReleaseCommandRemoveKey( pMac, pCommand );
656 }
657 }
658 break;
659
660 case eSmeCommandAddStaSession:
661 csrLLUnlock( &pMac->sme.smeCmdActiveList );
662 csrProcessAddStaSessionCommand( pMac, pCommand );
663 break;
664 case eSmeCommandDelStaSession:
665 csrLLUnlock( &pMac->sme.smeCmdActiveList );
666 csrProcessDelStaSessionCommand( pMac, pCommand );
667 break;
668
Jeff Johnsone7245742012-09-05 17:12:55 -0700669#ifdef FEATURE_OEM_DATA_SUPPORT
670 case eSmeCommandOemDataReq:
671 csrLLUnlock(&pMac->sme.smeCmdActiveList);
672 oemData_ProcessOemDataReqCommand(pMac, pCommand);
673 break;
674#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 case eSmeCommandRemainOnChannel:
676 csrLLUnlock(&pMac->sme.smeCmdActiveList);
677 p2pProcessRemainOnChannelCmd(pMac, pCommand);
678 break;
679 case eSmeCommandNoAUpdate:
680 csrLLUnlock( &pMac->sme.smeCmdActiveList );
681 p2pProcessNoAReq(pMac,pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 case eSmeCommandEnterImps:
683 case eSmeCommandExitImps:
684 case eSmeCommandEnterBmps:
685 case eSmeCommandExitBmps:
686 case eSmeCommandEnterUapsd:
687 case eSmeCommandExitUapsd:
688 case eSmeCommandEnterWowl:
689 case eSmeCommandExitWowl:
690 csrLLUnlock( &pMac->sme.smeCmdActiveList );
691 fContinue = pmcProcessCommand( pMac, pCommand );
692 if( fContinue )
693 {
694 //The command failed, remove it
695 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
696 &pCommand->Link, LL_ACCESS_LOCK ) )
697 {
698 pmcReleaseCommand( pMac, pCommand );
699 }
700 }
701 break;
702
703 //Treat standby differently here because caller may not be able to handle
704 //the failure so we do our best here
705 case eSmeCommandEnterStandby:
706 if( csrIsConnStateDisconnected( pMac, pCommand->sessionId ) )
707 {
708 //It can continue
709 csrLLUnlock( &pMac->sme.smeCmdActiveList );
710 fContinue = pmcProcessCommand( pMac, pCommand );
711 if( fContinue )
712 {
713 //The command failed, remove it
714 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
715 &pCommand->Link, LL_ACCESS_LOCK ) )
716 {
717 pmcReleaseCommand( pMac, pCommand );
718 }
719 }
720 }
721 else
722 {
723 //Need to issue a disconnect first before processing this command
724 tSmeCmd *pNewCmd;
725
726 //We need to re-run the command
727 fContinue = eANI_BOOLEAN_TRUE;
728 //Pull off the standby command first
729 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
730 &pCommand->Link, LL_ACCESS_NOLOCK ) )
731 {
732 csrLLUnlock( &pMac->sme.smeCmdActiveList );
733 //Need to call CSR function here because the disconnect command
734 //is handled by CSR
735 pNewCmd = csrGetCommandBuffer( pMac );
736 if( NULL != pNewCmd )
737 {
738 //Put the standby command to the head of the pending list first
739 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCommand->Link,
740 LL_ACCESS_LOCK );
741 pNewCmd->command = eSmeCommandRoam;
742 pNewCmd->u.roamCmd.roamReason = eCsrForcedDisassoc;
743 //Put the disassoc command before the standby command
744 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pNewCmd->Link,
745 LL_ACCESS_LOCK );
746 }
747 else
748 {
749 //Continue the command here
750 fContinue = pmcProcessCommand( pMac, pCommand );
751 if( fContinue )
752 {
753 //The command failed, remove it
754 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
755 &pCommand->Link, LL_ACCESS_LOCK ) )
756 {
757 pmcReleaseCommand( pMac, pCommand );
758 }
759 }
760 }
761 }
762 else
763 {
764 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800765 smsLog( pMac, LOGE, FL(" failed to remove standby command") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700766 VOS_ASSERT(0);
767 }
768 }
769 break;
770
771 case eSmeCommandAddTs:
772 case eSmeCommandDelTs:
773 csrLLUnlock( &pMac->sme.smeCmdActiveList );
774#ifndef WLAN_MDM_CODE_REDUCTION_OPT
775 fContinue = qosProcessCommand( pMac, pCommand );
776 if( fContinue )
777 {
778 //The command failed, remove it
779 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
780 &pCommand->Link, LL_ACCESS_NOLOCK ) )
781 {
782//#ifndef WLAN_MDM_CODE_REDUCTION_OPT
783 qosReleaseCommand( pMac, pCommand );
784//#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
785 }
786 }
787#endif
788 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800789#ifdef FEATURE_WLAN_TDLS
790 case eSmeCommandTdlsSendMgmt:
791 case eSmeCommandTdlsAddPeer:
792 case eSmeCommandTdlsDelPeer:
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530793 case eSmeCommandTdlsLinkEstablish:
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800794#ifdef FEATURE_WLAN_TDLS_INTERNAL
795 case eSmeCommandTdlsDiscovery:
796 case eSmeCommandTdlsLinkSetup:
797 case eSmeCommandTdlsLinkTear:
798 case eSmeCommandTdlsEnterUapsd:
799 case eSmeCommandTdlsExitUapsd:
800#endif
801 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800802 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800803 "sending TDLS Command 0x%x to PE", pCommand->command);
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800804
805 csrLLUnlock( &pMac->sme.smeCmdActiveList );
806 status = csrTdlsProcessCmd( pMac, pCommand );
807 }
808 break ;
809#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700810
811 default:
812 //something is wrong
813 //remove it from the active list
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800814 smsLog(pMac, LOGE, " csrProcessCommand processes an unknown command %d", pCommand->command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK );
816 csrLLUnlock( &pMac->sme.smeCmdActiveList );
817 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
818 smeReleaseCommand( pMac, pCommand );
819 status = eHAL_STATUS_FAILURE;
820 break;
821 }
822 if(!HAL_STATUS_SUCCESS(status))
823 {
824 fContinue = eANI_BOOLEAN_TRUE;
825 }
826 }//if(pEntry)
827 else
828 {
829 //This is odd. Some one else pull off the command.
830 csrLLUnlock( &pMac->sme.smeCmdActiveList );
831 }
832 }
833 else
834 {
835 csrLLUnlock( &pMac->sme.smeCmdActiveList );
836 }
837 }
838 else
839 {
840 //No command waiting
841 csrLLUnlock( &pMac->sme.smeCmdActiveList );
842 //This is only used to restart an idle mode scan, it means at least one other idle scan has finished.
843 if(pMac->scan.fRestartIdleScan && eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
844 {
845 tANI_U32 nTime = 0;
846
847 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
848 if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime)))
849 {
850 csrScanStartIdleScanTimer(pMac, nTime);
851 }
852 }
853 }
854 }
855 else {
856 csrLLUnlock( &pMac->sme.smeCmdActiveList );
857 }
858
859 return ( fContinue );
860}
861
862void smeProcessPendingQueue( tpAniSirGlobal pMac )
863{
864 while( smeProcessCommand( pMac ) );
865}
866
867
868tANI_BOOLEAN smeCommandPending(tpAniSirGlobal pMac)
869{
870 return ( !csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) ||
871 !csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK) );
872}
873
874
875
876//Global APIs
877
878/*--------------------------------------------------------------------------
879
880 \brief sme_Open() - Initialze all SME modules and put them at idle state
881
882 The function initializes each module inside SME, PMC, CCM, CSR, etc. . Upon
883 successfully return, all modules are at idle state ready to start.
884
885 smeOpen must be called before any other SME APIs can be involved.
886 smeOpen must be called after macOpen.
Srinivas Girigowdade697412013-02-14 16:31:48 -0800887 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 \param hHal - The handle returned by macOpen.
889
890 \return eHAL_STATUS_SUCCESS - SME is successfully initialized.
891
892 Other status means SME is failed to be initialized
893 \sa
894
895 --------------------------------------------------------------------------*/
896eHalStatus sme_Open(tHalHandle hHal)
897{
898 eHalStatus status = eHAL_STATUS_FAILURE;
899 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
900
901 do {
902 pMac->sme.state = SME_STATE_STOP;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -0700903 pMac->sme.currDeviceMode = VOS_STA_MODE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->sme.lkSmeGlobalLock ) ) )
905 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800906 smsLog( pMac, LOGE, "sme_Open failed init lock" );
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 status = eHAL_STATUS_FAILURE;
908 break;
909 }
910
911 status = ccmOpen(hHal);
912 if ( ! HAL_STATUS_SUCCESS( status ) ) {
913 smsLog( pMac, LOGE,
914 "ccmOpen failed during initialization with status=%d", status );
915 break;
916 }
917
918 status = csrOpen(pMac);
919 if ( ! HAL_STATUS_SUCCESS( status ) ) {
920 smsLog( pMac, LOGE,
921 "csrOpen failed during initialization with status=%d", status );
922 break;
923 }
924
925 status = pmcOpen(hHal);
926 if ( ! HAL_STATUS_SUCCESS( status ) ) {
927 smsLog( pMac, LOGE,
928 "pmcOpen failed during initialization with status=%d", status );
929 break;
930 }
931
Gopichand Nakkala34d1b062013-03-19 15:28:33 -0700932#ifdef FEATURE_WLAN_TDLS
933 pMac->isTdlsPowerSaveProhibited = 0;
934#endif
935
Jeff Johnson295189b2012-06-20 16:38:30 -0700936#ifndef WLAN_MDM_CODE_REDUCTION_OPT
937 status = sme_QosOpen(pMac);
938 if ( ! HAL_STATUS_SUCCESS( status ) ) {
939 smsLog( pMac, LOGE,
940 "Qos open failed during initialization with status=%d", status );
941 break;
942 }
943
944 status = btcOpen(pMac);
945 if ( ! HAL_STATUS_SUCCESS( status ) ) {
946 smsLog( pMac, LOGE,
947 "btcOpen open failed during initialization with status=%d", status );
948 break;
949 }
950#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700951#ifdef FEATURE_OEM_DATA_SUPPORT
952 status = oemData_OemDataReqOpen(pMac);
953 if ( ! HAL_STATUS_SUCCESS( status ) ) {
954 smsLog(pMac, LOGE,
955 "oemData_OemDataReqOpen failed during initialization with status=%d", status );
956 break;
957 }
958#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700959
960 if(!HAL_STATUS_SUCCESS((status = initSmeCmdList(pMac))))
961 break;
962
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 {
964 v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SAP, NULL);
965 if ( NULL == pvosGCtx ){
966 smsLog( pMac, LOGE, "WLANSAP_Open open failed during initialization");
967 status = eHAL_STATUS_FAILURE;
968 break;
969 }
970
971 status = WLANSAP_Open( pvosGCtx );
972 if ( ! HAL_STATUS_SUCCESS( status ) ) {
973 smsLog( pMac, LOGE,
974 "WLANSAP_Open open failed during initialization with status=%d", status );
975 break;
976 }
977 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700978#if defined WLAN_FEATURE_VOWIFI
979 status = rrmOpen(pMac);
980 if ( ! HAL_STATUS_SUCCESS( status ) ) {
981 smsLog( pMac, LOGE,
982 "rrmOpen open failed during initialization with status=%d", status );
983 break;
984 }
985#endif
986
987#if defined WLAN_FEATURE_VOWIFI_11R
988 sme_FTOpen(pMac);
989#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 sme_p2pOpen(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700991
992 }while (0);
993
994 return status;
995}
996
Jeff Johnson295189b2012-06-20 16:38:30 -0700997/*--------------------------------------------------------------------------
998
999 \brief sme_set11dinfo() - Set the 11d information about valid channels
1000 and there power using information from nvRAM
1001 This function is called only for AP.
1002
Srinivas Girigowdade697412013-02-14 16:31:48 -08001003 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001004
1005 \param hHal - The handle returned by macOpen.
1006 \Param pSmeConfigParams - a pointer to a caller allocated object of
1007 typedef struct _smeConfigParams.
1008
1009 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1010
1011 Other status means SME is failed to update the config parameters.
1012 \sa
1013--------------------------------------------------------------------------*/
1014
1015eHalStatus sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1016{
1017 eHalStatus status = eHAL_STATUS_FAILURE;
1018 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1019
1020 if (NULL == pSmeConfigParams ) {
1021 smsLog( pMac, LOGE,
1022 "Empty config param structure for SME, nothing to update");
1023 return status;
1024 }
1025
1026 status = csrSetChannels(hHal, &pSmeConfigParams->csrConfig );
1027 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001028 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 status );
1030 }
1031 return status;
1032}
1033
1034/*--------------------------------------------------------------------------
1035
1036 \brief sme_getSoftApDomain() - Get the current regulatory domain of softAp.
1037
Srinivas Girigowdade697412013-02-14 16:31:48 -08001038 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001039
1040 \param hHal - The handle returned by HostapdAdapter.
1041 \Param v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
1042
1043 \return eHAL_STATUS_SUCCESS - SME successfully completed the request.
1044
1045 Other status means, failed to get the current regulatory domain.
1046 \sa
1047--------------------------------------------------------------------------*/
1048
1049eHalStatus sme_getSoftApDomain(tHalHandle hHal, v_REGDOMAIN_t *domainIdSoftAp)
1050{
1051 eHalStatus status = eHAL_STATUS_FAILURE;
1052 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1053
1054 if (NULL == domainIdSoftAp ) {
1055 smsLog( pMac, LOGE, "Uninitialized domain Id");
1056 return status;
1057 }
1058
1059 *domainIdSoftAp = pMac->scan.domainIdCurrent;
1060 status = eHAL_STATUS_SUCCESS;
1061
1062 return status;
1063}
1064
1065
1066eHalStatus sme_setRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
1067{
1068 eHalStatus status = eHAL_STATUS_FAILURE;
1069 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1070
1071 if (NULL == apCntryCode ) {
1072 smsLog( pMac, LOGE, "Empty Country Code, nothing to update");
1073 return status;
1074 }
1075
1076 status = csrSetRegInfo(hHal, apCntryCode );
1077 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001078 smsLog( pMac, LOGE, "csrSetRegInfo failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 status );
1080 }
1081 return status;
1082}
1083
Jeff Johnson295189b2012-06-20 16:38:30 -07001084#ifdef FEATURE_WLAN_SCAN_PNO
1085/*--------------------------------------------------------------------------
1086
1087 \brief sme_UpdateChannelConfig() - Update channel configuration in RIVA.
1088
1089 It is used at driver start up to inform RIVA of the default channel
1090 configuration.
1091
Srinivas Girigowdade697412013-02-14 16:31:48 -08001092 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001093
1094 \param hHal - The handle returned by macOpen.
1095
1096 \return eHAL_STATUS_SUCCESS - SME update the channel config successfully.
1097
1098 Other status means SME is failed to update the channel config.
1099 \sa
1100
1101 --------------------------------------------------------------------------*/
1102eHalStatus sme_UpdateChannelConfig(tHalHandle hHal)
1103{
1104 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1105
1106 pmcUpdateScanParams( pMac, &(pMac->roam.configParam),
1107 &pMac->scan.base20MHzChannels, FALSE);
1108 return eHAL_STATUS_SUCCESS;
1109}
1110#endif // FEATURE_WLAN_SCAN_PNLO
1111
1112/*--------------------------------------------------------------------------
1113
1114 \brief sme_UpdateConfig() - Change configurations for all SME moduels
1115
1116 The function updates some configuration for modules in SME, CCM, CSR, etc
1117 during SMEs close open sequence.
1118
1119 Modules inside SME apply the new configuration at the next transaction.
1120
Srinivas Girigowdade697412013-02-14 16:31:48 -08001121 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001122
1123 \param hHal - The handle returned by macOpen.
1124 \Param pSmeConfigParams - a pointer to a caller allocated object of
1125 typedef struct _smeConfigParams.
1126
1127 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1128
1129 Other status means SME is failed to update the config parameters.
1130 \sa
1131
1132 --------------------------------------------------------------------------*/
1133eHalStatus sme_UpdateConfig(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1134{
1135 eHalStatus status = eHAL_STATUS_FAILURE;
1136 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1137
1138 if (NULL == pSmeConfigParams ) {
1139 smsLog( pMac, LOGE,
1140 "Empty config param structure for SME, nothing to update");
1141 return status;
1142 }
1143
1144 status = csrChangeDefaultConfigParam(pMac, &pSmeConfigParams->csrConfig);
1145
1146 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001147 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 status );
1149 }
1150#if defined WLAN_FEATURE_P2P_INTERNAL
1151 status = p2pChangeDefaultConfigParam(pMac, &pSmeConfigParams->p2pConfig);
1152
1153 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001154 smsLog( pMac, LOGE, "p2pChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 status );
1156 }
1157#endif
1158#if defined WLAN_FEATURE_VOWIFI
1159 status = rrmChangeDefaultConfigParam(hHal, &pSmeConfigParams->rrmConfig);
1160
1161 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001162 smsLog( pMac, LOGE, "rrmChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 status );
1164 }
1165#endif
1166 //For SOC, CFG is set before start
1167 //We don't want to apply global CFG in connect state because that may cause some side affect
1168 if(
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 csrIsAllSessionDisconnected( pMac) )
1170 {
1171 csrSetGlobalCfgs(pMac);
1172 }
1173
Gopichand Nakkala86e42662013-06-11 17:44:11 +05301174 /* update the directed scan offload setting */
1175 pMac->fScanOffload = pSmeConfigParams->fScanOffload;
1176
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 return status;
1178}
1179
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301180#ifdef WLAN_FEATURE_GTK_OFFLOAD
1181void sme_ProcessGetGtkInfoRsp( tHalHandle hHal,
1182 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
1183{
1184 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1185
1186 if (NULL == pMac)
1187 {
1188 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1189 "%s: pMac is null", __func__);
1190 return ;
1191 }
1192 if (pMac->pmc.GtkOffloadGetInfoCB == NULL)
1193 {
1194 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1195 "%s: HDD callback is null", __func__);
1196 return ;
1197 }
1198 pMac->pmc.GtkOffloadGetInfoCB(pMac->pmc.GtkOffloadGetInfoCBContext,
1199 pGtkOffloadGetInfoRsp);
1200}
1201#endif
1202
Jeff Johnson295189b2012-06-20 16:38:30 -07001203/* ---------------------------------------------------------------------------
1204 \fn sme_ChangeConfigParams
1205 \brief The SME API exposed for HDD to provide config params to SME during
1206 SMEs stop -> start sequence.
1207
1208 If HDD changed the domain that will cause a reset. This function will
1209 provide the new set of 11d information for the new domain. Currrently this
1210 API provides info regarding 11d only at reset but we can extend this for
1211 other params (PMC, QoS) which needs to be initialized again at reset.
1212
Srinivas Girigowdade697412013-02-14 16:31:48 -08001213 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001214
1215 \param hHal - The handle returned by macOpen.
1216
1217 \Param
1218 pUpdateConfigParam - a pointer to a structure (tCsrUpdateConfigParam) that
1219 currently provides 11d related information like Country code,
1220 Regulatory domain, valid channel list, Tx power per channel, a
1221 list with active/passive scan allowed per valid channel.
1222
1223 \return eHalStatus
1224 ---------------------------------------------------------------------------*/
1225eHalStatus sme_ChangeConfigParams(tHalHandle hHal,
1226 tCsrUpdateConfigParam *pUpdateConfigParam)
1227{
1228 eHalStatus status = eHAL_STATUS_FAILURE;
1229 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1230
1231 if (NULL == pUpdateConfigParam ) {
1232 smsLog( pMac, LOGE,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001233 "Empty config param structure for SME, nothing to reset");
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 return status;
1235 }
1236
1237 status = csrChangeConfigParams(pMac, pUpdateConfigParam);
1238
1239 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001240 smsLog( pMac, LOGE, "csrUpdateConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 status );
1242 }
1243
1244 return status;
1245
1246}
1247
1248/*--------------------------------------------------------------------------
1249
1250 \brief sme_HDDReadyInd() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1251 that the NIC is ready tio run.
1252
1253 The function is called by HDD at the end of initialization stage so PE/HAL can
1254 enable the NIC to running state.
1255
Srinivas Girigowdade697412013-02-14 16:31:48 -08001256 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 \param hHal - The handle returned by macOpen.
1258
1259 \return eHAL_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1260 successfully.
1261
1262 Other status means SME failed to send the message to PE.
1263 \sa
1264
1265 --------------------------------------------------------------------------*/
1266eHalStatus sme_HDDReadyInd(tHalHandle hHal)
1267{
1268 tSirSmeReadyReq Msg;
1269 eHalStatus status = eHAL_STATUS_FAILURE;
1270 tPmcPowerState powerState;
1271 tPmcSwitchState hwWlanSwitchState;
1272 tPmcSwitchState swWlanSwitchState;
1273 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1274
1275 do
1276 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001277
1278 Msg.messageType = eWNI_SME_SYS_READY_IND;
1279 Msg.length = sizeof( tSirSmeReadyReq );
1280
1281 if (eSIR_FAILURE != uMacPostCtrlMsg( hHal, (tSirMbMsg*)&Msg ))
1282 {
1283 status = eHAL_STATUS_SUCCESS;
1284 }
1285 else
1286 {
1287 smsLog( pMac, LOGE,
1288 "uMacPostCtrlMsg failed to send eWNI_SME_SYS_READY_IND");
1289 break;
1290 }
1291
1292 status = pmcQueryPowerState( hHal, &powerState,
1293 &hwWlanSwitchState, &swWlanSwitchState );
1294 if ( ! HAL_STATUS_SUCCESS( status ) )
1295 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001296 smsLog( pMac, LOGE, "pmcQueryPowerState failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 status );
1298 break;
1299 }
1300
1301 if ( (ePMC_SWITCH_OFF != hwWlanSwitchState) &&
1302 (ePMC_SWITCH_OFF != swWlanSwitchState) )
1303 {
1304 status = csrReady(pMac);
1305 if ( ! HAL_STATUS_SUCCESS( status ) )
1306 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001307 smsLog( pMac, LOGE, "csrReady failed with status=%d", status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 break;
1309 }
1310 status = pmcReady(hHal);
1311 if ( ! HAL_STATUS_SUCCESS( status ) )
1312 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001313 smsLog( pMac, LOGE, "pmcReady failed with status=%d", status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 break;
1315 }
1316#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1317 if(VOS_STATUS_SUCCESS != btcReady(hHal))
1318 {
1319 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001320 smsLog( pMac, LOGE, "btcReady failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 break;
1322 }
1323#endif
1324
1325#if defined WLAN_FEATURE_VOWIFI
1326 if(VOS_STATUS_SUCCESS != rrmReady(hHal))
1327 {
1328 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001329 smsLog( pMac, LOGE, "rrmReady failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 break;
1331 }
1332#endif
1333 }
1334 pMac->sme.state = SME_STATE_READY;
1335 } while( 0 );
1336
1337 return status;
1338}
1339
1340/*--------------------------------------------------------------------------
1341
1342 \brief sme_Start() - Put all SME modules at ready state.
1343
1344 The function starts each module in SME, PMC, CCM, CSR, etc. . Upon
1345 successfully return, all modules are ready to run.
Srinivas Girigowdade697412013-02-14 16:31:48 -08001346 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 \param hHal - The handle returned by macOpen.
1348
1349 \return eHAL_STATUS_SUCCESS - SME is ready.
1350
1351 Other status means SME is failed to start
1352 \sa
1353
1354 --------------------------------------------------------------------------*/
1355eHalStatus sme_Start(tHalHandle hHal)
1356{
1357 eHalStatus status = eHAL_STATUS_FAILURE;
1358 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1359
1360 do
1361 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 status = csrStart(pMac);
1363 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001364 smsLog( pMac, LOGE, "csrStart failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001365 status );
1366 break;
1367 }
1368
1369 status = pmcStart(hHal);
1370 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001371 smsLog( pMac, LOGE, "pmcStart failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 status );
1373 break;
1374 }
1375
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 status = WLANSAP_Start(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1377 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001378 smsLog( pMac, LOGE, "WLANSAP_Start failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 status );
1380 break;
1381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 pMac->sme.state = SME_STATE_START;
1383 }while (0);
1384
1385 return status;
1386}
1387
1388
1389#ifdef WLAN_FEATURE_PACKET_FILTERING
1390/******************************************************************************
1391*
1392* Name: sme_PCFilterMatchCountResponseHandler
1393*
1394* Description:
1395* Invoke Packet Coalescing Filter Match Count callback routine
1396*
1397* Parameters:
1398* hHal - HAL handle for device
1399* pMsg - Pointer to tRcvFltPktMatchRsp structure
1400*
1401* Returns: eHalStatus
1402*
1403******************************************************************************/
1404eHalStatus sme_PCFilterMatchCountResponseHandler(tHalHandle hHal, void* pMsg)
1405{
1406 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1407 eHalStatus status = eHAL_STATUS_SUCCESS;
1408 tpSirRcvFltPktMatchRsp pRcvFltPktMatchRsp = (tpSirRcvFltPktMatchRsp)pMsg;
1409
1410 if (NULL == pMsg)
1411 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001412 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 status = eHAL_STATUS_FAILURE;
1414 }
1415 else
1416 {
1417 smsLog(pMac, LOG2, "SME: entering "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001418 "sme_FilterMatchCountResponseHandler");
Jeff Johnson295189b2012-06-20 16:38:30 -07001419
1420 /* Call Packet Coalescing Filter Match Count callback routine. */
1421 if (pMac->pmc.FilterMatchCountCB != NULL)
1422 pMac->pmc.FilterMatchCountCB(pMac->pmc.FilterMatchCountCBContext,
1423 pRcvFltPktMatchRsp);
1424
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001425 smsLog(pMac, LOG1, "%s: status=0x%x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 pRcvFltPktMatchRsp->status);
1427
1428 pMac->pmc.FilterMatchCountCB = NULL;
1429 pMac->pmc.FilterMatchCountCBContext = NULL;
1430 }
1431
1432 return(status);
1433}
1434#endif // WLAN_FEATURE_PACKET_FILTERING
1435
1436
Chet Lanctot186b5732013-03-18 10:26:30 -07001437#ifdef WLAN_FEATURE_11W
1438/*------------------------------------------------------------------
1439 *
1440 * Handle the unprotected management frame indication from LIM and
1441 * forward it to HDD.
1442 *
1443 *------------------------------------------------------------------*/
1444
1445eHalStatus sme_UnprotectedMgmtFrmInd( tHalHandle hHal,
1446 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1447{
1448 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1449 eHalStatus status = eHAL_STATUS_SUCCESS;
1450 tCsrRoamInfo pRoamInfo = {0};
1451 tANI_U32 SessionId = pSmeMgmtFrm->sessionId;
1452
1453 pRoamInfo.nFrameLength = pSmeMgmtFrm->frameLen;
1454 pRoamInfo.pbFrames = pSmeMgmtFrm->frameBuf;
1455 pRoamInfo.frameType = pSmeMgmtFrm->frameType;
1456
1457 /* forward the mgmt frame to HDD */
1458 csrRoamCallCallback(pMac, SessionId, &pRoamInfo, 0, eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1459
1460 return status;
1461}
1462#endif
1463
1464
Jeff Johnson295189b2012-06-20 16:38:30 -07001465/*--------------------------------------------------------------------------
1466
1467 \brief sme_ProcessMsg() - The main message processor for SME.
1468
1469 The function is called by a message dispatcher when to process a message
1470 targeted for SME.
1471
Srinivas Girigowdade697412013-02-14 16:31:48 -08001472 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 \param hHal - The handle returned by macOpen.
1474 \param pMsg - A pointer to a caller allocated object of tSirMsgQ.
1475
1476 \return eHAL_STATUS_SUCCESS - SME successfully process the message.
1477
1478 Other status means SME failed to process the message to HAL.
1479 \sa
1480
1481 --------------------------------------------------------------------------*/
1482eHalStatus sme_ProcessMsg(tHalHandle hHal, vos_msg_t* pMsg)
1483{
1484 eHalStatus status = eHAL_STATUS_FAILURE;
1485 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1486
1487 if (pMsg == NULL) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001488 smsLog( pMac, LOGE, "Empty message for SME, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 return status;
1490 }
1491
1492 status = sme_AcquireGlobalLock( &pMac->sme );
1493 if ( HAL_STATUS_SUCCESS( status ) )
1494 {
1495 if( SME_IS_START(pMac) )
1496 {
1497 switch (pMsg->type) { // TODO: Will be modified to do a range check for msgs instead of having cases for each msgs
1498 case eWNI_PMC_ENTER_BMPS_RSP:
1499 case eWNI_PMC_EXIT_BMPS_RSP:
1500 case eWNI_PMC_EXIT_BMPS_IND:
1501 case eWNI_PMC_ENTER_IMPS_RSP:
1502 case eWNI_PMC_EXIT_IMPS_RSP:
1503 case eWNI_PMC_SMPS_STATE_IND:
1504 case eWNI_PMC_ENTER_UAPSD_RSP:
1505 case eWNI_PMC_EXIT_UAPSD_RSP:
1506 case eWNI_PMC_ENTER_WOWL_RSP:
1507 case eWNI_PMC_EXIT_WOWL_RSP:
1508 //PMC
1509 if (pMsg->bodyptr)
1510 {
1511 pmcMessageProcessor(hHal, pMsg->bodyptr);
1512 status = eHAL_STATUS_SUCCESS;
1513 vos_mem_free( pMsg->bodyptr );
1514 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001515 smsLog( pMac, LOGE, "Empty rsp message for PMC, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 }
1517 break;
1518
1519 case WNI_CFG_SET_CNF:
1520 case WNI_CFG_DNLD_CNF:
1521 case WNI_CFG_GET_RSP:
1522 case WNI_CFG_ADD_GRP_ADDR_CNF:
1523 case WNI_CFG_DEL_GRP_ADDR_CNF:
1524 //CCM
1525 if (pMsg->bodyptr)
1526 {
1527 ccmCfgCnfMsgHandler(hHal, pMsg->bodyptr);
1528 status = eHAL_STATUS_SUCCESS;
1529 vos_mem_free( pMsg->bodyptr );
1530 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001531 smsLog( pMac, LOGE, "Empty rsp message for CCM, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 }
1533 break;
1534
1535 case eWNI_SME_ADDTS_RSP:
1536 case eWNI_SME_DELTS_RSP:
1537 case eWNI_SME_DELTS_IND:
1538#ifdef WLAN_FEATURE_VOWIFI_11R
1539 case eWNI_SME_FT_AGGR_QOS_RSP:
1540#endif
1541 //QoS
1542 if (pMsg->bodyptr)
1543 {
1544#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1545 status = sme_QosMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
1546 vos_mem_free( pMsg->bodyptr );
1547#endif
1548 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001549 smsLog( pMac, LOGE, "Empty rsp message for QoS, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 }
1551 break;
1552#if defined WLAN_FEATURE_VOWIFI
1553 case eWNI_SME_NEIGHBOR_REPORT_IND:
1554 case eWNI_SME_BEACON_REPORT_REQ_IND:
1555#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001556 smsLog( pMac, LOGE, "Received RRM message. Message Id = %d", pMsg->type );
Jeff Johnson295189b2012-06-20 16:38:30 -07001557#endif
1558 if ( pMsg->bodyptr )
1559 {
1560 status = sme_RrmMsgProcessor( pMac, pMsg->type, pMsg->bodyptr );
1561 vos_mem_free( pMsg->bodyptr );
1562 }
1563 else
1564 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001565 smsLog( pMac, LOGE, "Empty message for RRM, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 }
1567 break;
1568#endif
1569
Jeff Johnsone7245742012-09-05 17:12:55 -07001570#ifdef FEATURE_OEM_DATA_SUPPORT
1571 //Handle the eWNI_SME_OEM_DATA_RSP:
1572 case eWNI_SME_OEM_DATA_RSP:
1573 if(pMsg->bodyptr)
1574 {
1575 status = sme_HandleOemDataRsp(pMac, pMsg->bodyptr);
1576 vos_mem_free(pMsg->bodyptr);
1577 }
1578 else
1579 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001580 smsLog( pMac, LOGE, "Empty rsp message for oemData_ (eWNI_SME_OEM_DATA_RSP), nothing to process");
Jeff Johnsone7245742012-09-05 17:12:55 -07001581 }
1582 smeProcessPendingQueue( pMac );
1583 break;
1584#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001585
1586 case eWNI_SME_ADD_STA_SELF_RSP:
1587 if(pMsg->bodyptr)
1588 {
1589 status = csrProcessAddStaSessionRsp(pMac, pMsg->bodyptr);
1590 vos_mem_free(pMsg->bodyptr);
1591 }
1592 else
1593 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001594 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ADD_STA_SELF_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 }
1596 break;
1597 case eWNI_SME_DEL_STA_SELF_RSP:
1598 if(pMsg->bodyptr)
1599 {
1600 status = csrProcessDelStaSessionRsp(pMac, pMsg->bodyptr);
1601 vos_mem_free(pMsg->bodyptr);
1602 }
1603 else
1604 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001605 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_DEL_STA_SELF_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 }
1607 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 case eWNI_SME_REMAIN_ON_CHN_RSP:
1609 if(pMsg->bodyptr)
1610 {
1611 status = sme_remainOnChnRsp(pMac, pMsg->bodyptr);
1612 vos_mem_free(pMsg->bodyptr);
1613 }
1614 else
1615 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001616 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 }
1618 break;
1619 case eWNI_SME_REMAIN_ON_CHN_RDY_IND:
1620 if(pMsg->bodyptr)
1621 {
1622 status = sme_remainOnChnReady(pMac, pMsg->bodyptr);
1623 vos_mem_free(pMsg->bodyptr);
1624 }
1625 else
1626 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001627 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 -07001628 }
1629 break;
1630 case eWNI_SME_MGMT_FRM_IND:
1631 if(pMsg->bodyptr)
1632 {
1633 sme_mgmtFrmInd(pMac, pMsg->bodyptr);
1634 vos_mem_free(pMsg->bodyptr);
1635 }
1636 else
1637 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001638 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_MGMT_FRM_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 }
1640 break;
1641 case eWNI_SME_ACTION_FRAME_SEND_CNF:
1642 if(pMsg->bodyptr)
1643 {
1644 status = sme_sendActionCnf(pMac, pMsg->bodyptr);
1645 vos_mem_free(pMsg->bodyptr);
1646 }
1647 else
1648 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001649 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ACTION_FRAME_SEND_CNF), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 }
1651 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 case eWNI_SME_COEX_IND:
1653 if(pMsg->bodyptr)
1654 {
1655 status = btcHandleCoexInd((void *)pMac, pMsg->bodyptr);
1656 vos_mem_free(pMsg->bodyptr);
1657 }
1658 else
1659 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001660 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 }
1662 break;
1663
1664#ifdef FEATURE_WLAN_SCAN_PNO
1665 case eWNI_SME_PREF_NETWORK_FOUND_IND:
1666 if(pMsg->bodyptr)
1667 {
1668 status = sme_PreferredNetworkFoundInd((void *)pMac, pMsg->bodyptr);
1669 vos_mem_free(pMsg->bodyptr);
1670 }
1671 else
1672 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001673 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_PREF_NETWORK_FOUND_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 }
1675 break;
1676#endif // FEATURE_WLAN_SCAN_PNO
1677
1678 case eWNI_SME_TX_PER_HIT_IND:
1679 if (pMac->sme.pTxPerHitCallback)
1680 {
1681 pMac->sme.pTxPerHitCallback(pMac->sme.pTxPerHitCbContext);
1682 }
1683 break;
1684
1685 case eWNI_SME_CHANGE_COUNTRY_CODE:
1686 if(pMsg->bodyptr)
1687 {
1688 status = sme_HandleChangeCountryCode((void *)pMac, pMsg->bodyptr);
1689 vos_mem_free(pMsg->bodyptr);
1690 }
1691 else
1692 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001693 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 }
1695 break;
1696
1697#ifdef WLAN_FEATURE_PACKET_FILTERING
1698 case eWNI_PMC_PACKET_COALESCING_FILTER_MATCH_COUNT_RSP:
1699 if(pMsg->bodyptr)
1700 {
1701 status = sme_PCFilterMatchCountResponseHandler((void *)pMac, pMsg->bodyptr);
1702 vos_mem_free(pMsg->bodyptr);
1703 }
1704 else
1705 {
1706 smsLog(pMac, LOGE, "Empty rsp message for meas "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001707 "(PACKET_COALESCING_FILTER_MATCH_COUNT_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 }
1709 break;
1710#endif // WLAN_FEATURE_PACKET_FILTERING
1711 case eWNI_SME_PRE_SWITCH_CHL_IND:
1712 {
1713 status = sme_HandlePreChannelSwitchInd(pMac);
1714 break;
1715 }
1716
1717 case eWNI_SME_POST_SWITCH_CHL_IND:
1718 {
1719 status = sme_HandlePostChannelSwitchInd(pMac);
1720 break;
1721 }
1722
1723#ifdef WLAN_WAKEUP_EVENTS
1724 case eWNI_SME_WAKE_REASON_IND:
1725 if(pMsg->bodyptr)
1726 {
1727 status = sme_WakeReasonIndCallback((void *)pMac, pMsg->bodyptr);
1728 vos_mem_free(pMsg->bodyptr);
1729 }
1730 else
1731 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001732 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_WAKE_REASON_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 }
1734 break;
1735#endif // WLAN_WAKEUP_EVENTS
1736
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001737#ifdef FEATURE_WLAN_TDLS
1738 /*
1739 * command rescived from PE, SME tdls msg processor shall be called
1740 * to process commands recieved from PE
1741 */
1742 case eWNI_SME_TDLS_SEND_MGMT_RSP:
1743 case eWNI_SME_TDLS_ADD_STA_RSP:
Hoonki Leee6bfe942013-02-05 15:01:19 -08001744 case eWNI_SME_TDLS_DEL_STA_RSP:
1745 case eWNI_SME_TDLS_DEL_STA_IND:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001746 case eWNI_SME_TDLS_DEL_ALL_PEER_IND:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001747 case eWNI_SME_MGMT_FRM_TX_COMPLETION_IND:
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301748 case eWNI_SME_TDLS_LINK_ESTABLISH_RSP:
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05301749#ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP
1750 case eWNI_SME_TDLS_AP_DISAPPEAR_IND:
1751#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001752#ifdef FEATURE_WLAN_TDLS_INTERNAL
1753 case eWNI_SME_TDLS_DISCOVERY_START_RSP:
1754 case eWNI_SME_TDLS_DISCOVERY_START_IND:
1755 case eWNI_SME_TDLS_LINK_START_RSP:
1756 case eWNI_SME_TDLS_LINK_START_IND:
1757 case eWNI_SME_TDLS_TEARDOWN_RSP:
1758 case eWNI_SME_TDLS_TEARDOWN_IND:
1759 case eWNI_SME_ADD_TDLS_PEER_IND:
1760 case eWNI_SME_DELETE_TDLS_PEER_IND:
1761#endif
1762 {
1763 if (pMsg->bodyptr)
1764 {
1765 status = tdlsMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
1766 vos_mem_free( pMsg->bodyptr );
1767 }
1768 else
1769 {
1770 smsLog( pMac, LOGE, "Empty rsp message for TDLS, \
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001771 nothing to process");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001772 }
1773 break;
1774 }
1775#endif
1776
Chet Lanctot186b5732013-03-18 10:26:30 -07001777#ifdef WLAN_FEATURE_11W
1778 case eWNI_SME_UNPROT_MGMT_FRM_IND:
1779 if (pMsg->bodyptr)
1780 {
1781 sme_UnprotectedMgmtFrmInd(pMac, pMsg->bodyptr);
1782 vos_mem_free(pMsg->bodyptr);
1783 }
1784 else
1785 {
1786 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_UNPROT_MGMT_FRM_IND), nothing to process");
1787 }
1788 break;
1789#endif
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001790#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1791 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
1792 status = csrRoamOffloadScanRspHdlr((void *)pMac, pMsg->bodyval);
1793 break;
1794#endif // WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Chet Lanctot186b5732013-03-18 10:26:30 -07001795
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301796#ifdef WLAN_FEATURE_GTK_OFFLOAD
1797 case eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP:
1798 if (pMsg->bodyptr)
1799 {
1800 sme_ProcessGetGtkInfoRsp(pMac, pMsg->bodyptr);
1801 vos_mem_free(pMsg->bodyptr);
1802 }
1803 else
1804 {
1805 smsLog(pMac, LOGE, "Empty rsp message for (eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP), nothing to process");
1806 }
1807 break ;
1808#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 default:
1810
1811 if ( ( pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN )
1812 && ( pMsg->type <= eWNI_SME_MSG_TYPES_END ) )
1813 {
1814 //CSR
1815 if (pMsg->bodyptr)
1816 {
1817 status = csrMsgProcessor(hHal, pMsg->bodyptr);
1818 vos_mem_free( pMsg->bodyptr );
1819 }
1820 else
1821 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001822 smsLog( pMac, LOGE, "Empty rsp message for CSR, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 }
1824 }
1825 else
1826 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001827 smsLog( pMac, LOGW, "Unknown message type %d, nothing to process",
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 pMsg->type);
1829 if (pMsg->bodyptr)
1830 {
1831 vos_mem_free( pMsg->bodyptr );
1832 }
1833 }
1834 }//switch
1835 } //SME_IS_START
1836 else
1837 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001838 smsLog( pMac, LOGW, "message type %d in stop state ignored", pMsg->type);
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 if (pMsg->bodyptr)
1840 {
1841 vos_mem_free( pMsg->bodyptr );
1842 }
1843 }
1844 sme_ReleaseGlobalLock( &pMac->sme );
1845 }
1846 else
1847 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001848 smsLog( pMac, LOGW, "Locking failed, bailing out");
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 if (pMsg->bodyptr)
1850 {
1851 vos_mem_free( pMsg->bodyptr );
1852 }
1853 }
1854
1855 return status;
1856}
1857
1858
1859//No need to hold the global lock here because this function can only be called
1860//after sme_Stop.
1861v_VOID_t sme_FreeMsg( tHalHandle hHal, vos_msg_t* pMsg )
1862{
1863 if( pMsg )
1864 {
1865 if (pMsg->bodyptr)
1866 {
1867 vos_mem_free( pMsg->bodyptr );
1868 }
1869 }
1870
1871}
1872
1873
1874/*--------------------------------------------------------------------------
1875
1876 \brief sme_Stop() - Stop all SME modules and put them at idle state
1877
1878 The function stops each module in SME, PMC, CCM, CSR, etc. . Upon
1879 return, all modules are at idle state ready to start.
1880
Srinivas Girigowdade697412013-02-14 16:31:48 -08001881 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 \param hHal - The handle returned by macOpen
1883
1884 \return eHAL_STATUS_SUCCESS - SME is stopped.
1885
1886 Other status means SME is failed to stop but caller should still
1887 consider SME is stopped.
1888 \sa
1889
1890 --------------------------------------------------------------------------*/
1891eHalStatus sme_Stop(tHalHandle hHal, tANI_BOOLEAN pmcFlag)
1892{
1893 eHalStatus status = eHAL_STATUS_FAILURE;
1894 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
1895 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1896
Jeff Johnson295189b2012-06-20 16:38:30 -07001897 status = WLANSAP_Stop(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1898 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001899 smsLog( pMac, LOGE, "WLANSAP_Stop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 status );
1901 fail_status = status;
1902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001903
1904 p2pStop(hHal);
1905
1906 if(pmcFlag)
1907 {
1908 status = pmcStop(hHal);
1909 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001910 smsLog( pMac, LOGE, "pmcStop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 status );
1912 fail_status = status;
1913 }
1914 }
1915
1916 status = csrStop(pMac);
1917 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001918 smsLog( pMac, LOGE, "csrStop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 status );
1920 fail_status = status;
1921 }
1922
1923 ccmStop(hHal);
1924
1925 purgeSmeCmdList(pMac);
1926
1927 if (!HAL_STATUS_SUCCESS( fail_status )) {
1928 status = fail_status;
1929 }
1930
1931 pMac->sme.state = SME_STATE_STOP;
1932
1933 return status;
1934}
1935
1936/*--------------------------------------------------------------------------
1937
1938 \brief sme_Close() - Release all SME modules and their resources.
1939
1940 The function release each module in SME, PMC, CCM, CSR, etc. . Upon
1941 return, all modules are at closed state.
1942
1943 No SME APIs can be involved after smeClose except smeOpen.
1944 smeClose must be called before macClose.
Srinivas Girigowdade697412013-02-14 16:31:48 -08001945 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 \param hHal - The handle returned by macOpen
1947
1948 \return eHAL_STATUS_SUCCESS - SME is successfully close.
1949
1950 Other status means SME is failed to be closed but caller still cannot
1951 call any other SME functions except smeOpen.
1952 \sa
1953
1954 --------------------------------------------------------------------------*/
1955eHalStatus sme_Close(tHalHandle hHal)
1956{
1957 eHalStatus status = eHAL_STATUS_FAILURE;
1958 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
1959 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1960
1961 status = csrClose(pMac);
1962 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001963 smsLog( pMac, LOGE, "csrClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 status );
1965 fail_status = status;
1966 }
1967
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 status = WLANSAP_Close(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1969 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001970 smsLog( pMac, LOGE, "WLANSAP_close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 status );
1972 fail_status = status;
1973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001974
1975#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1976 status = btcClose(hHal);
1977 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001978 smsLog( pMac, LOGE, "BTC close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001979 status );
1980 fail_status = status;
1981 }
1982
1983 status = sme_QosClose(pMac);
1984 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001985 smsLog( pMac, LOGE, "Qos close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 status );
1987 fail_status = status;
1988 }
1989#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001990#ifdef FEATURE_OEM_DATA_SUPPORT
1991 status = oemData_OemDataReqClose(hHal);
1992 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001993 smsLog( pMac, LOGE, "OEM DATA REQ close failed during sme close with status=%d",
Jeff Johnsone7245742012-09-05 17:12:55 -07001994 status );
1995 fail_status = status;
1996 }
1997#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001998
1999 status = ccmClose(hHal);
2000 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002001 smsLog( pMac, LOGE, "ccmClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 status );
2003 fail_status = status;
2004 }
2005
2006 status = pmcClose(hHal);
2007 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002008 smsLog( pMac, LOGE, "pmcClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 status );
2010 fail_status = status;
2011 }
2012#if defined WLAN_FEATURE_VOWIFI
2013 status = rrmClose(hHal);
2014 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002015 smsLog( pMac, LOGE, "RRM close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 status );
2017 fail_status = status;
2018 }
2019#endif
2020
2021#if defined WLAN_FEATURE_VOWIFI_11R
2022 sme_FTClose(hHal);
2023#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 sme_p2pClose(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002025
2026 freeSmeCmdList(pMac);
2027
2028 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->sme.lkSmeGlobalLock ) ) )
2029 {
2030 fail_status = eHAL_STATUS_FAILURE;
2031 }
2032
2033 if (!HAL_STATUS_SUCCESS( fail_status )) {
2034 status = fail_status;
2035 }
2036
2037 pMac->sme.state = SME_STATE_STOP;
2038
2039 return status;
2040}
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002041#ifdef FEATURE_WLAN_LFR
2042tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac)
2043{
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07002044#if 0
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002045 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
2046 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2047 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
2048 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
2049 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
2050 return eANI_BOOLEAN_FALSE;
2051 default:
2052 return eANI_BOOLEAN_TRUE;
2053 }
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07002054#else
2055 /*
2056 * TODO: always return TRUE for now until
2057 * we figure out why we could be stuck in
2058 * one of the roaming states forever.
2059 */
2060 return eANI_BOOLEAN_TRUE;
2061#endif
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002062}
2063#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002064/* ---------------------------------------------------------------------------
2065 \fn sme_ScanRequest
2066 \brief a wrapper function to Request a 11d or full scan from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002067 This is an asynchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002068 \param pScanRequestID - pointer to an object to get back the request ID
2069 \param callback - a callback function that scan calls upon finish, will not
2070 be called if csrScanRequest returns error
2071 \param pContext - a pointer passed in for the callback
2072 \return eHalStatus
2073 ---------------------------------------------------------------------------*/
2074eHalStatus sme_ScanRequest(tHalHandle hHal, tANI_U8 sessionId, tCsrScanRequest *pscanReq,
2075 tANI_U32 *pScanRequestID,
2076 csrScanCompleteCallback callback, void *pContext)
2077{
2078 eHalStatus status = eHAL_STATUS_FAILURE;
2079 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2080
2081 smsLog(pMac, LOG2, FL("enter"));
2082 do
2083 {
2084 if(pMac->scan.fScanEnable)
2085 {
2086 status = sme_AcquireGlobalLock( &pMac->sme );
2087 if ( HAL_STATUS_SUCCESS( status ) )
2088 {
2089 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002090#ifdef FEATURE_WLAN_LFR
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002091 if(csrIsScanAllowed(pMac))
2092 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002093#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002094 status = csrScanRequest( hHal, sessionId, pscanReq,
2095 pScanRequestID, callback, pContext );
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002096#ifdef FEATURE_WLAN_LFR
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002097 }
2098 else
2099 {
Madan Mohan Koyyalamudiab4ab0d2012-10-24 14:26:50 -07002100 smsLog(pMac, LOGE, FL("Scan denied in state %d (sub-state %d)"),
2101 pMac->roam.neighborRoamInfo.neighborRoamState,
2102 pMac->roam.curSubState[sessionId]);
2103 /*HandOff is in progress. So schedule this scan later*/
2104 status = eHAL_STATUS_RESOURCES;
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002105 }
2106#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 }
2108
2109 sme_ReleaseGlobalLock( &pMac->sme );
2110 } //sme_AcquireGlobalLock success
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002111 else
2112 {
2113 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
2114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 } //if(pMac->scan.fScanEnable)
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002116 else
2117 {
2118 smsLog(pMac, LOGE, FL("fScanEnable FALSE"));
2119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 } while( 0 );
2121
2122 return (status);
2123
2124
2125}
2126
2127/* ---------------------------------------------------------------------------
2128 \fn sme_ScanGetResult
2129 \brief a wrapper function to request scan results from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002130 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 \param pFilter - If pFilter is NULL, all cached results are returned
2132 \param phResult - an object for the result.
2133 \return eHalStatus
2134 ---------------------------------------------------------------------------*/
2135eHalStatus sme_ScanGetResult(tHalHandle hHal, tANI_U8 sessionId, tCsrScanResultFilter *pFilter,
2136 tScanResultHandle *phResult)
2137{
2138 eHalStatus status = eHAL_STATUS_FAILURE;
2139 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2140
2141 smsLog(pMac, LOG2, FL("enter"));
2142 status = sme_AcquireGlobalLock( &pMac->sme );
2143 if ( HAL_STATUS_SUCCESS( status ) )
2144 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07002145 status = csrScanGetResult( hHal, pFilter, phResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 sme_ReleaseGlobalLock( &pMac->sme );
2147 }
2148 smsLog(pMac, LOG2, FL("exit status %d"), status);
2149
2150 return (status);
2151}
2152
2153
2154/* ---------------------------------------------------------------------------
2155 \fn sme_ScanFlushResult
2156 \brief a wrapper function to request CSR to clear scan results.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002157 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 \return eHalStatus
2159 ---------------------------------------------------------------------------*/
2160eHalStatus sme_ScanFlushResult(tHalHandle hHal, tANI_U8 sessionId)
2161{
2162 eHalStatus status = eHAL_STATUS_FAILURE;
2163 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2164
2165 status = sme_AcquireGlobalLock( &pMac->sme );
2166 if ( HAL_STATUS_SUCCESS( status ) )
2167 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07002168 status = csrScanFlushResult( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 sme_ReleaseGlobalLock( &pMac->sme );
2170 }
2171
2172 return (status);
2173}
2174
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002175eHalStatus sme_ScanFlushP2PResult(tHalHandle hHal, tANI_U8 sessionId)
2176{
2177 eHalStatus status = eHAL_STATUS_FAILURE;
2178 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2179
2180 status = sme_AcquireGlobalLock( &pMac->sme );
2181 if ( HAL_STATUS_SUCCESS( status ) )
2182 {
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302183 status = csrScanFlushSelectiveResult( hHal, VOS_TRUE );
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002184 sme_ReleaseGlobalLock( &pMac->sme );
2185 }
2186
2187 return (status);
2188}
Jeff Johnson295189b2012-06-20 16:38:30 -07002189
2190/* ---------------------------------------------------------------------------
2191 \fn sme_ScanResultGetFirst
2192 \brief a wrapper function to request CSR to returns the first element of
2193 scan result.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002194 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 \param hScanResult - returned from csrScanGetResult
2196 \return tCsrScanResultInfo * - NULL if no result
2197 ---------------------------------------------------------------------------*/
2198tCsrScanResultInfo *sme_ScanResultGetFirst(tHalHandle hHal,
2199 tScanResultHandle hScanResult)
2200{
2201 eHalStatus status = eHAL_STATUS_FAILURE;
2202 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2203 tCsrScanResultInfo *pRet = NULL;
2204
2205 status = sme_AcquireGlobalLock( &pMac->sme );
2206 if ( HAL_STATUS_SUCCESS( status ) )
2207 {
2208 pRet = csrScanResultGetFirst( pMac, hScanResult );
2209 sme_ReleaseGlobalLock( &pMac->sme );
2210 }
2211
2212 return (pRet);
2213}
2214
2215
2216/* ---------------------------------------------------------------------------
2217 \fn sme_ScanResultGetNext
2218 \brief a wrapper function to request CSR to returns the next element of
2219 scan result. It can be called without calling csrScanResultGetFirst
2220 first
Srinivas Girigowdade697412013-02-14 16:31:48 -08002221 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 \param hScanResult - returned from csrScanGetResult
2223 \return Null if no result or reach the end
2224 ---------------------------------------------------------------------------*/
2225tCsrScanResultInfo *sme_ScanResultGetNext(tHalHandle hHal,
2226 tScanResultHandle hScanResult)
2227{
2228 eHalStatus status = eHAL_STATUS_FAILURE;
2229 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2230 tCsrScanResultInfo *pRet = NULL;
2231
2232 status = sme_AcquireGlobalLock( &pMac->sme );
2233 if ( HAL_STATUS_SUCCESS( status ) )
2234 {
2235 pRet = csrScanResultGetNext( pMac, hScanResult );
2236 sme_ReleaseGlobalLock( &pMac->sme );
2237 }
2238
2239 return (pRet);
2240}
2241
2242
2243/* ---------------------------------------------------------------------------
2244 \fn sme_ScanSetBGScanparams
2245 \brief a wrapper function to request CSR to set BG scan params in PE
Srinivas Girigowdade697412013-02-14 16:31:48 -08002246 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 \param pScanReq - BG scan request structure
2248 \return eHalStatus
2249 ---------------------------------------------------------------------------*/
2250eHalStatus sme_ScanSetBGScanparams(tHalHandle hHal, tANI_U8 sessionId, tCsrBGScanRequest *pScanReq)
2251{
2252 eHalStatus status = eHAL_STATUS_FAILURE;
2253 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2254
2255 if( NULL != pScanReq )
2256 {
2257 status = sme_AcquireGlobalLock( &pMac->sme );
2258 if ( HAL_STATUS_SUCCESS( status ) )
2259 {
2260 status = csrScanSetBGScanparams( hHal, pScanReq );
2261 sme_ReleaseGlobalLock( &pMac->sme );
2262 }
2263 }
2264
2265 return (status);
2266}
2267
2268
2269/* ---------------------------------------------------------------------------
2270 \fn sme_ScanResultPurge
2271 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
2272 in the list and free memory for each item
Srinivas Girigowdade697412013-02-14 16:31:48 -08002273 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 \param hScanResult - returned from csrScanGetResult. hScanResult is
2275 considered gone by
2276 calling this function and even before this function reutrns.
2277 \return eHalStatus
2278 ---------------------------------------------------------------------------*/
2279eHalStatus sme_ScanResultPurge(tHalHandle hHal, tScanResultHandle hScanResult)
2280{
2281 eHalStatus status = eHAL_STATUS_FAILURE;
2282 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2283
2284 status = sme_AcquireGlobalLock( &pMac->sme );
2285 if ( HAL_STATUS_SUCCESS( status ) )
2286 {
2287 status = csrScanResultPurge( hHal, hScanResult );
2288 sme_ReleaseGlobalLock( &pMac->sme );
2289 }
2290
2291 return (status);
2292}
2293
2294/* ---------------------------------------------------------------------------
2295 \fn sme_ScanGetPMKIDCandidateList
2296 \brief a wrapper function to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08002297 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 \param pPmkidList - caller allocated buffer point to an array of
2299 tPmkidCandidateInfo
2300 \param pNumItems - pointer to a variable that has the number of
2301 tPmkidCandidateInfo allocated when retruning, this is
2302 either the number needed or number of items put into
2303 pPmkidList
2304 \return eHalStatus - when fail, it usually means the buffer allocated is not
2305 big enough and pNumItems
2306 has the number of tPmkidCandidateInfo.
2307 \Note: pNumItems is a number of tPmkidCandidateInfo,
2308 not sizeof(tPmkidCandidateInfo) * something
2309 ---------------------------------------------------------------------------*/
2310eHalStatus sme_ScanGetPMKIDCandidateList(tHalHandle hHal, tANI_U8 sessionId,
2311 tPmkidCandidateInfo *pPmkidList,
2312 tANI_U32 *pNumItems )
2313{
2314 eHalStatus status = eHAL_STATUS_FAILURE;
2315 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2316
2317 status = sme_AcquireGlobalLock( &pMac->sme );
2318 if ( HAL_STATUS_SUCCESS( status ) )
2319 {
2320 status = csrScanGetPMKIDCandidateList( pMac, sessionId, pPmkidList, pNumItems );
2321 sme_ReleaseGlobalLock( &pMac->sme );
2322 }
2323
2324 return (status);
2325}
2326
2327/*----------------------------------------------------------------------------
2328 \fn sme_RoamRegisterLinkQualityIndCallback
2329
2330 \brief
2331 a wrapper function to allow HDD to register a callback handler with CSR for
2332 link quality indications.
2333
2334 Only one callback may be registered at any time.
2335 In order to deregister the callback, a NULL cback may be provided.
2336
2337 Registration happens in the task context of the caller.
2338
2339 \param callback - Call back being registered
2340 \param pContext - user data
2341
2342 DEPENDENCIES: After CSR open
2343
2344 \return eHalStatus
2345-----------------------------------------------------------------------------*/
2346eHalStatus sme_RoamRegisterLinkQualityIndCallback(tHalHandle hHal, tANI_U8 sessionId,
2347 csrRoamLinkQualityIndCallback callback,
2348 void *pContext)
2349{
2350 return(csrRoamRegisterLinkQualityIndCallback((tpAniSirGlobal)hHal, callback, pContext));
2351}
2352
2353/* ---------------------------------------------------------------------------
2354 \fn sme_RoamRegisterCallback
2355 \brief a wrapper function to allow HDD to register a callback with CSR.
2356 Unlike scan, roam has one callback for all the roam requests
2357 \param callback - a callback function that roam calls upon when state changes
2358 \param pContext - a pointer passed in for the callback
2359 \return eHalStatus
2360 ---------------------------------------------------------------------------*/
2361eHalStatus sme_RoamRegisterCallback(tHalHandle hHal,
2362 csrRoamCompleteCallback callback,
2363 void *pContext)
2364{
2365 return(csrRoamRegisterCallback((tpAniSirGlobal)hHal, callback, pContext));
2366}
2367
2368eCsrPhyMode sme_GetPhyMode(tHalHandle hHal)
2369{
2370 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2371 return pMac->roam.configParam.phyMode;
2372}
2373
2374/* ---------------------------------------------------------------------------
2375 \fn sme_RoamConnect
2376 \brief a wrapper function to request CSR to inititiate an association
Srinivas Girigowdade697412013-02-14 16:31:48 -08002377 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002378 \param sessionId - the sessionId returned by sme_OpenSession.
2379 \param pProfile - description of the network to which to connect
2380 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
2381 from csrScanGetResult
2382 \param pRoamId - to get back the request ID
2383 \return eHalStatus
2384 ---------------------------------------------------------------------------*/
2385eHalStatus sme_RoamConnect(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2386 tANI_U32 *pRoamId)
2387{
2388 eHalStatus status = eHAL_STATUS_FAILURE;
2389 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2390
2391 smsLog(pMac, LOG2, FL("enter"));
2392 status = sme_AcquireGlobalLock( &pMac->sme );
2393 if ( HAL_STATUS_SUCCESS( status ) )
2394 {
2395 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2396 {
2397 status = csrRoamConnect( pMac, sessionId, pProfile, NULL, pRoamId );
2398 }
2399 else
2400 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002401 smsLog(pMac, LOGE, FL("invalid sessionID %d"), sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 status = eHAL_STATUS_INVALID_PARAMETER;
2403 }
2404 sme_ReleaseGlobalLock( &pMac->sme );
2405 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002406 else
2407 {
2408 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
2409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002410
2411 return (status);
2412}
2413
2414/* ---------------------------------------------------------------------------
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05302415
2416 \fn sme_SetPhyMode
2417
2418 \brief Changes the PhyMode.
2419
2420 \param hHal - The handle returned by macOpen.
2421
2422 \param phyMode new phyMode which is to set
2423
2424 \return eHalStatus SUCCESS.
2425
2426 -------------------------------------------------------------------------------*/
2427eHalStatus sme_SetPhyMode(tHalHandle hHal, eCsrPhyMode phyMode)
2428{
2429 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2430
2431 if (NULL == pMac)
2432 {
2433 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2434 "%s: invalid context", __func__);
2435 return eHAL_STATUS_FAILURE;
2436 }
2437
2438 pMac->roam.configParam.phyMode = phyMode;
2439 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL,
2440 pMac->roam.configParam.phyMode,
2441 pMac->roam.configParam.ProprietaryRatesEnabled);
2442
2443 return eHAL_STATUS_SUCCESS;
2444}
2445
2446/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 \fn sme_RoamReassoc
2448 \brief a wrapper function to request CSR to inititiate a re-association
2449 \param pProfile - can be NULL to join the currently connected AP. In that
2450 case modProfileFields should carry the modified field(s) which could trigger
2451 reassoc
2452 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
2453 that might need modification dynamically once STA is up & running and this
2454 could trigger a reassoc
2455 \param pRoamId - to get back the request ID
2456 \return eHalStatus
2457 -------------------------------------------------------------------------------*/
2458eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2459 tCsrRoamModifyProfileFields modProfileFields,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002460 tANI_U32 *pRoamId, v_BOOL_t fForce)
Jeff Johnson295189b2012-06-20 16:38:30 -07002461{
2462 eHalStatus status = eHAL_STATUS_FAILURE;
2463 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2464
2465 smsLog(pMac, LOG2, FL("enter"));
2466 status = sme_AcquireGlobalLock( &pMac->sme );
2467 if ( HAL_STATUS_SUCCESS( status ) )
2468 {
2469 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2470 {
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07002471 if((NULL == pProfile) && (fForce == 1))
2472 {
2473 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2474 /* to force the AP initiate fresh 802.1x authentication need to clear
2475 * the PMKID cache for that set the following boolean. this is needed
2476 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
2477 pSession->fIgnorePMKIDCache = TRUE;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002478 status = csrReassoc( pMac, sessionId, &modProfileFields, pRoamId , fForce);
2479 }
2480 else
2481 {
2482 status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
2483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002484 }
2485 else
2486 {
2487 status = eHAL_STATUS_INVALID_PARAMETER;
2488 }
2489 sme_ReleaseGlobalLock( &pMac->sme );
2490 }
2491
2492 return (status);
2493}
2494
2495/* ---------------------------------------------------------------------------
2496 \fn sme_RoamConnectToLastProfile
2497 \brief a wrapper function to request CSR to disconnect and reconnect with
2498 the same profile
Srinivas Girigowdade697412013-02-14 16:31:48 -08002499 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 \return eHalStatus. It returns fail if currently connected
2501 ---------------------------------------------------------------------------*/
2502eHalStatus sme_RoamConnectToLastProfile(tHalHandle hHal, tANI_U8 sessionId)
2503{
2504 eHalStatus status = eHAL_STATUS_FAILURE;
2505 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2506
2507 status = sme_AcquireGlobalLock( &pMac->sme );
2508 if ( HAL_STATUS_SUCCESS( status ) )
2509 {
2510 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2511 {
2512 status = csrRoamConnectToLastProfile( pMac, sessionId );
2513 }
2514 else
2515 {
2516 status = eHAL_STATUS_INVALID_PARAMETER;
2517 }
2518 sme_ReleaseGlobalLock( &pMac->sme );
2519 }
2520
2521 return (status);
2522}
2523
2524/* ---------------------------------------------------------------------------
2525 \fn sme_RoamDisconnect
2526 \brief a wrapper function to request CSR to disconnect from a network
Srinivas Girigowdade697412013-02-14 16:31:48 -08002527 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 \param reason -- To indicate the reason for disconnecting. Currently, only
2529 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
2530 \return eHalStatus
2531 ---------------------------------------------------------------------------*/
2532eHalStatus sme_RoamDisconnect(tHalHandle hHal, tANI_U8 sessionId, eCsrRoamDisconnectReason reason)
2533{
2534 eHalStatus status = eHAL_STATUS_FAILURE;
2535 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2536
2537 smsLog(pMac, LOG2, FL("enter"));
2538 status = sme_AcquireGlobalLock( &pMac->sme );
2539 if ( HAL_STATUS_SUCCESS( status ) )
2540 {
2541 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2542 {
2543 status = csrRoamDisconnect( pMac, sessionId, reason );
2544 }
2545 else
2546 {
2547 status = eHAL_STATUS_INVALID_PARAMETER;
2548 }
2549 sme_ReleaseGlobalLock( &pMac->sme );
2550 }
2551
2552 return (status);
2553}
2554
Jeff Johnson295189b2012-06-20 16:38:30 -07002555/* ---------------------------------------------------------------------------
2556 \fn sme_RoamStopBss
2557 \brief To stop BSS for Soft AP. This is an asynchronous API.
2558 \param hHal - Global structure
2559 \param sessionId - sessionId of SoftAP
2560 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2561 -------------------------------------------------------------------------------*/
2562eHalStatus sme_RoamStopBss(tHalHandle hHal, tANI_U8 sessionId)
2563{
2564 eHalStatus status = eHAL_STATUS_FAILURE;
2565 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2566
2567 smsLog(pMac, LOG2, FL("enter"));
2568 status = sme_AcquireGlobalLock( &pMac->sme );
2569 if ( HAL_STATUS_SUCCESS( status ) )
2570 {
2571 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2572 {
Gopichand Nakkalaf44bdc52013-02-16 00:54:45 +05302573 status = csrRoamIssueStopBssCmd( pMac, sessionId, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 }
2575 else
2576 {
2577 status = eHAL_STATUS_INVALID_PARAMETER;
2578 }
2579 sme_ReleaseGlobalLock( &pMac->sme );
2580 }
2581
2582 return (status);
2583}
2584
2585/* ---------------------------------------------------------------------------
2586 \fn sme_RoamDisconnectSta
2587 \brief To disassociate a station. This is an asynchronous API.
2588 \param hHal - Global structure
2589 \param sessionId - sessionId of SoftAP
2590 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2591 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2592 -------------------------------------------------------------------------------*/
2593eHalStatus sme_RoamDisconnectSta(tHalHandle hHal, tANI_U8 sessionId,
2594 tANI_U8 *pPeerMacAddr)
2595{
2596 eHalStatus status = eHAL_STATUS_FAILURE;
2597 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2598
2599 if ( NULL == pMac )
2600 {
2601 VOS_ASSERT(0);
2602 return status;
2603 }
2604
2605 status = sme_AcquireGlobalLock( &pMac->sme );
2606 if ( HAL_STATUS_SUCCESS( status ) )
2607 {
2608 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2609 {
2610 status = csrRoamIssueDisassociateStaCmd( pMac, sessionId, pPeerMacAddr,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302611 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 }
2613 else
2614 {
2615 status = eHAL_STATUS_INVALID_PARAMETER;
2616 }
2617 sme_ReleaseGlobalLock( &pMac->sme );
2618 }
2619
2620 return (status);
2621}
2622
2623/* ---------------------------------------------------------------------------
2624 \fn sme_RoamDeauthSta
2625 \brief To disassociate a station. This is an asynchronous API.
2626 \param hHal - Global structure
2627 \param sessionId - sessionId of SoftAP
2628 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2629 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2630 -------------------------------------------------------------------------------*/
2631eHalStatus sme_RoamDeauthSta(tHalHandle hHal, tANI_U8 sessionId,
2632 tANI_U8 *pPeerMacAddr)
2633{
2634 eHalStatus status = eHAL_STATUS_FAILURE;
2635 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2636
2637 if ( NULL == pMac )
2638 {
2639 VOS_ASSERT(0);
2640 return status;
2641 }
2642
2643 status = sme_AcquireGlobalLock( &pMac->sme );
2644 if ( HAL_STATUS_SUCCESS( status ) )
2645 {
2646 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2647 {
2648 status = csrRoamIssueDeauthStaCmd( pMac, sessionId, pPeerMacAddr,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302649 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 }
2651 else
2652 {
2653 status = eHAL_STATUS_INVALID_PARAMETER;
2654 }
2655 sme_ReleaseGlobalLock( &pMac->sme );
2656 }
2657
2658 return (status);
2659}
2660
2661/* ---------------------------------------------------------------------------
2662 \fn sme_RoamTKIPCounterMeasures
2663 \brief To start or stop TKIP counter measures. This is an asynchronous API.
2664 \param sessionId - sessionId of SoftAP
2665 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2666 \return eHalStatus
2667 -------------------------------------------------------------------------------*/
2668eHalStatus sme_RoamTKIPCounterMeasures(tHalHandle hHal, tANI_U8 sessionId,
2669 tANI_BOOLEAN bEnable)
2670{
2671 eHalStatus status = eHAL_STATUS_FAILURE;
2672 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2673
2674 if ( NULL == pMac )
2675 {
2676 VOS_ASSERT(0);
2677 return status;
2678 }
2679
2680 status = sme_AcquireGlobalLock( &pMac->sme );
2681 if ( HAL_STATUS_SUCCESS( status ) )
2682 {
2683 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2684 {
2685 status = csrRoamIssueTkipCounterMeasures( pMac, sessionId, bEnable);
2686 }
2687 else
2688 {
2689 status = eHAL_STATUS_INVALID_PARAMETER;
2690 }
2691 sme_ReleaseGlobalLock( &pMac->sme );
2692 }
2693
2694 return (status);
2695}
2696
2697/* ---------------------------------------------------------------------------
2698 \fn sme_RoamGetAssociatedStas
2699 \brief To probe the list of associated stations from various modules of CORE stack.
2700 \This is an asynchronous API.
2701 \param sessionId - sessionId of SoftAP
2702 \param modId - Module from whom list of associtated stations is to be probed.
2703 If an invalid module is passed then by default VOS_MODULE_ID_PE will be probed
2704 \param pUsrContext - Opaque HDD context
2705 \param pfnSapEventCallback - Sap event callback in HDD
2706 \param pAssocBuf - Caller allocated memory to be filled with associatd stations info
2707 \return eHalStatus
2708 -------------------------------------------------------------------------------*/
2709eHalStatus sme_RoamGetAssociatedStas(tHalHandle hHal, tANI_U8 sessionId,
2710 VOS_MODULE_ID modId, void *pUsrContext,
2711 void *pfnSapEventCallback, tANI_U8 *pAssocStasBuf)
2712{
2713 eHalStatus status = eHAL_STATUS_FAILURE;
2714 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2715
2716 if ( NULL == pMac )
2717 {
2718 VOS_ASSERT(0);
2719 return status;
2720 }
2721
2722 status = sme_AcquireGlobalLock( &pMac->sme );
2723 if ( HAL_STATUS_SUCCESS( status ) )
2724 {
2725 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2726 {
2727 status = csrRoamGetAssociatedStas( pMac, sessionId, modId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2728 }
2729 else
2730 {
2731 status = eHAL_STATUS_INVALID_PARAMETER;
2732 }
2733 sme_ReleaseGlobalLock( &pMac->sme );
2734 }
2735
2736 return (status);
2737}
2738
2739/* ---------------------------------------------------------------------------
2740 \fn sme_RoamGetWpsSessionOverlap
2741 \brief To get the WPS PBC session overlap information.
2742 \This is an asynchronous API.
2743 \param sessionId - sessionId of SoftAP
2744 \param pUsrContext - Opaque HDD context
2745 \param pfnSapEventCallback - Sap event callback in HDD
2746 \pRemoveMac - pointer to Mac address which needs to be removed from session
2747 \return eHalStatus
2748 -------------------------------------------------------------------------------*/
2749eHalStatus sme_RoamGetWpsSessionOverlap(tHalHandle hHal, tANI_U8 sessionId,
2750 void *pUsrContext, void
2751 *pfnSapEventCallback, v_MACADDR_t pRemoveMac)
2752{
2753 eHalStatus status = eHAL_STATUS_FAILURE;
2754 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2755
2756 if ( NULL == pMac )
2757 {
2758 VOS_ASSERT(0);
2759 return status;
2760 }
2761
2762 status = sme_AcquireGlobalLock( &pMac->sme );
2763 if ( HAL_STATUS_SUCCESS( status ) )
2764 {
2765 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2766 {
2767 status = csrRoamGetWpsSessionOverlap( pMac, sessionId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2768 }
2769 else
2770 {
2771 status = eHAL_STATUS_INVALID_PARAMETER;
2772 }
2773 sme_ReleaseGlobalLock( &pMac->sme );
2774 }
2775
2776 return (status);
2777}
2778
Jeff Johnson295189b2012-06-20 16:38:30 -07002779
2780/* ---------------------------------------------------------------------------
2781 \fn sme_RoamGetConnectState
2782 \brief a wrapper function to request CSR to return the current connect state
2783 of Roaming
Srinivas Girigowdade697412013-02-14 16:31:48 -08002784 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 \return eHalStatus
2786 ---------------------------------------------------------------------------*/
2787eHalStatus sme_RoamGetConnectState(tHalHandle hHal, tANI_U8 sessionId, eCsrConnectState *pState)
2788{
2789 eHalStatus status = eHAL_STATUS_FAILURE;
2790 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2791
2792 status = sme_AcquireGlobalLock( &pMac->sme );
2793 if ( HAL_STATUS_SUCCESS( status ) )
2794 {
2795 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2796 {
2797 status = csrRoamGetConnectState( pMac, sessionId, pState );
2798 }
2799 else
2800 {
2801 status = eHAL_STATUS_INVALID_PARAMETER;
2802 }
2803 sme_ReleaseGlobalLock( &pMac->sme );
2804 }
2805
2806 return (status);
2807}
2808
2809/* ---------------------------------------------------------------------------
2810 \fn sme_RoamGetConnectProfile
2811 \brief a wrapper function to request CSR to return the current connect
2812 profile. Caller must call csrRoamFreeConnectProfile after it is done
2813 and before reuse for another csrRoamGetConnectProfile call.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002814 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 \param pProfile - pointer to a caller allocated structure
2816 tCsrRoamConnectedProfile
2817 \return eHalStatus. Failure if not connected
2818 ---------------------------------------------------------------------------*/
2819eHalStatus sme_RoamGetConnectProfile(tHalHandle hHal, tANI_U8 sessionId,
2820 tCsrRoamConnectedProfile *pProfile)
2821{
2822 eHalStatus status = eHAL_STATUS_FAILURE;
2823 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2824
2825 status = sme_AcquireGlobalLock( &pMac->sme );
2826 if ( HAL_STATUS_SUCCESS( status ) )
2827 {
2828 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2829 {
2830 status = csrRoamGetConnectProfile( pMac, sessionId, pProfile );
2831 }
2832 else
2833 {
2834 status = eHAL_STATUS_INVALID_PARAMETER;
2835 }
2836 sme_ReleaseGlobalLock( &pMac->sme );
2837 }
2838
2839 return (status);
2840}
2841
2842/* ---------------------------------------------------------------------------
2843 \fn sme_RoamFreeConnectProfile
2844 \brief a wrapper function to request CSR to free and reinitialize the
2845 profile returned previously by csrRoamGetConnectProfile.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002846 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 \param pProfile - pointer to a caller allocated structure
2848 tCsrRoamConnectedProfile
2849 \return eHalStatus.
2850 ---------------------------------------------------------------------------*/
2851eHalStatus sme_RoamFreeConnectProfile(tHalHandle hHal,
2852 tCsrRoamConnectedProfile *pProfile)
2853{
2854 eHalStatus status = eHAL_STATUS_FAILURE;
2855 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2856
2857 status = sme_AcquireGlobalLock( &pMac->sme );
2858 if ( HAL_STATUS_SUCCESS( status ) )
2859 {
2860 status = csrRoamFreeConnectProfile( pMac, pProfile );
2861 sme_ReleaseGlobalLock( &pMac->sme );
2862 }
2863
2864 return (status);
2865}
2866
2867/* ---------------------------------------------------------------------------
2868 \fn sme_RoamSetPMKIDCache
2869 \brief a wrapper function to request CSR to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08002870 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 \param pPMKIDCache - caller allocated buffer point to an array of
2872 tPmkidCacheInfo
2873 \param numItems - a variable that has the number of tPmkidCacheInfo
2874 allocated when retruning, this is either the number needed
2875 or number of items put into pPMKIDCache
2876 \return eHalStatus - when fail, it usually means the buffer allocated is not
2877 big enough and pNumItems has the number of
2878 tPmkidCacheInfo.
2879 \Note: pNumItems is a number of tPmkidCacheInfo,
2880 not sizeof(tPmkidCacheInfo) * something
2881 ---------------------------------------------------------------------------*/
2882eHalStatus sme_RoamSetPMKIDCache( tHalHandle hHal, tANI_U8 sessionId, tPmkidCacheInfo *pPMKIDCache,
2883 tANI_U32 numItems )
2884{
2885 eHalStatus status = eHAL_STATUS_FAILURE;
2886 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2887
2888 status = sme_AcquireGlobalLock( &pMac->sme );
2889 if ( HAL_STATUS_SUCCESS( status ) )
2890 {
2891 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2892 {
2893 status = csrRoamSetPMKIDCache( pMac, sessionId, pPMKIDCache, numItems );
2894 }
2895 else
2896 {
2897 status = eHAL_STATUS_INVALID_PARAMETER;
2898 }
2899 sme_ReleaseGlobalLock( &pMac->sme );
2900 }
2901
2902 return (status);
2903}
2904
2905/* ---------------------------------------------------------------------------
2906 \fn sme_RoamGetSecurityReqIE
2907 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
2908 passes to PE to JOIN request or START_BSS request
Srinivas Girigowdade697412013-02-14 16:31:48 -08002909 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 \param pLen - caller allocated memory that has the length of pBuf as input.
2911 Upon returned, *pLen has the needed or IE length in pBuf.
2912 \param pBuf - Caller allocated memory that contain the IE field, if any,
2913 upon return
2914 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
2915 \return eHalStatus - when fail, it usually means the buffer allocated is not
2916 big enough
2917 ---------------------------------------------------------------------------*/
2918eHalStatus sme_RoamGetSecurityReqIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
2919 tANI_U8 *pBuf, eCsrSecurityType secType)
2920{
2921 eHalStatus status = eHAL_STATUS_FAILURE;
2922 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2923
2924 status = sme_AcquireGlobalLock( &pMac->sme );
2925 if ( HAL_STATUS_SUCCESS( status ) )
2926 {
2927 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2928 {
2929 status = csrRoamGetWpaRsnReqIE( hHal, sessionId, pLen, pBuf );
2930 }
2931 else
2932 {
2933 status = eHAL_STATUS_INVALID_PARAMETER;
2934 }
2935 sme_ReleaseGlobalLock( &pMac->sme );
2936 }
2937
2938 return (status);
2939}
2940
2941/* ---------------------------------------------------------------------------
2942 \fn sme_RoamGetSecurityRspIE
2943 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE from
2944 the beacon or probe rsp if connected
Srinivas Girigowdade697412013-02-14 16:31:48 -08002945 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 \param pLen - caller allocated memory that has the length of pBuf as input.
2947 Upon returned, *pLen has the needed or IE length in pBuf.
2948 \param pBuf - Caller allocated memory that contain the IE field, if any,
2949 upon return
2950 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
2951 \return eHalStatus - when fail, it usually means the buffer allocated is not
2952 big enough
2953 ---------------------------------------------------------------------------*/
2954eHalStatus sme_RoamGetSecurityRspIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
2955 tANI_U8 *pBuf, eCsrSecurityType secType)
2956{
2957 eHalStatus status = eHAL_STATUS_FAILURE;
2958 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2959
2960 status = sme_AcquireGlobalLock( &pMac->sme );
2961 if ( HAL_STATUS_SUCCESS( status ) )
2962 {
2963 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2964 {
2965 status = csrRoamGetWpaRsnRspIE( pMac, sessionId, pLen, pBuf );
2966 }
2967 else
2968 {
2969 status = eHAL_STATUS_INVALID_PARAMETER;
2970 }
2971 sme_ReleaseGlobalLock( &pMac->sme );
2972 }
2973
2974 return (status);
2975
2976}
2977
2978
2979/* ---------------------------------------------------------------------------
2980 \fn sme_RoamGetNumPMKIDCache
2981 \brief a wrapper function to request CSR to return number of PMKID cache
2982 entries
Srinivas Girigowdade697412013-02-14 16:31:48 -08002983 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 \return tANI_U32 - the number of PMKID cache entries
2985 ---------------------------------------------------------------------------*/
2986tANI_U32 sme_RoamGetNumPMKIDCache(tHalHandle hHal, tANI_U8 sessionId)
2987{
2988 eHalStatus status = eHAL_STATUS_FAILURE;
2989 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2990 tANI_U32 numPmkidCache = 0;
2991
2992 status = sme_AcquireGlobalLock( &pMac->sme );
2993 if ( HAL_STATUS_SUCCESS( status ) )
2994 {
2995 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2996 {
2997 numPmkidCache = csrRoamGetNumPMKIDCache( pMac, sessionId );
2998 status = eHAL_STATUS_SUCCESS;
2999 }
3000 else
3001 {
3002 status = eHAL_STATUS_INVALID_PARAMETER;
3003 }
3004 sme_ReleaseGlobalLock( &pMac->sme );
3005 }
3006
3007 return (numPmkidCache);
3008}
3009
3010/* ---------------------------------------------------------------------------
3011 \fn sme_RoamGetPMKIDCache
3012 \brief a wrapper function to request CSR to return PMKID cache from CSR
Srinivas Girigowdade697412013-02-14 16:31:48 -08003013 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 \param pNum - caller allocated memory that has the space of the number of
3015 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3016 needed or actually number in tPmkidCacheInfo.
3017 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
3018 any, upon return
3019 \return eHalStatus - when fail, it usually means the buffer allocated is not
3020 big enough
3021 ---------------------------------------------------------------------------*/
3022eHalStatus sme_RoamGetPMKIDCache(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pNum,
3023 tPmkidCacheInfo *pPmkidCache)
3024{
3025 eHalStatus status = eHAL_STATUS_FAILURE;
3026 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3027
3028 status = sme_AcquireGlobalLock( &pMac->sme );
3029 if ( HAL_STATUS_SUCCESS( status ) )
3030 {
3031 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3032 {
3033 status = csrRoamGetPMKIDCache( pMac, sessionId, pNum, pPmkidCache );
3034 }
3035 else
3036 {
3037 status = eHAL_STATUS_INVALID_PARAMETER;
3038 }
3039 sme_ReleaseGlobalLock( &pMac->sme );
3040 }
3041
3042 return (status);
3043}
3044
3045
3046/* ---------------------------------------------------------------------------
3047 \fn sme_GetConfigParam
3048 \brief a wrapper function that HDD calls to get the global settings
3049 currently maintained by CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003050 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 \param pParam - caller allocated memory
3052 \return eHalStatus
3053 ---------------------------------------------------------------------------*/
3054eHalStatus sme_GetConfigParam(tHalHandle hHal, tSmeConfigParams *pParam)
3055{
3056 eHalStatus status = eHAL_STATUS_FAILURE;
3057 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3058
3059 status = sme_AcquireGlobalLock( &pMac->sme );
3060 if ( HAL_STATUS_SUCCESS( status ) )
3061 {
3062 status = csrGetConfigParam(pMac, &pParam->csrConfig);
3063 if (status != eHAL_STATUS_SUCCESS)
3064 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003065 smsLog( pMac, LOGE, "%s csrGetConfigParam failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 sme_ReleaseGlobalLock( &pMac->sme );
3067 return status;
3068 }
3069#if defined WLAN_FEATURE_P2P_INTERNAL
3070 status = p2pGetConfigParam(pMac, &pParam->p2pConfig);
3071 if (status != eHAL_STATUS_SUCCESS)
3072 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003073 smsLog( pMac, LOGE, "%s p2pGetConfigParam failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 sme_ReleaseGlobalLock( &pMac->sme );
3075 return status;
3076 }
3077#endif
3078 sme_ReleaseGlobalLock( &pMac->sme );
3079 }
3080
3081 return (status);
3082}
3083
3084/* ---------------------------------------------------------------------------
3085 \fn sme_CfgSetInt
3086 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003087 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 \param cfgId - Configuration Parameter ID (type) for STA.
3089 \param ccmValue - The information related to Configuration Parameter ID
3090 which needs to be saved in CFG
3091 \param callback - To be registered by CSR with CCM. Once the CFG done with
3092 saving the information in the database, it notifies CCM &
3093 then the callback will be invoked to notify.
3094 \param toBeSaved - To save the request for future reference
3095 \return eHalStatus
3096 ---------------------------------------------------------------------------*/
3097eHalStatus sme_CfgSetInt(tHalHandle hHal, tANI_U32 cfgId, tANI_U32 ccmValue,
3098 tCcmCfgSetCallback callback, eAniBoolean toBeSaved)
3099{
3100 return(ccmCfgSetInt(hHal, cfgId, ccmValue, callback, toBeSaved));
3101}
3102
3103/* ---------------------------------------------------------------------------
3104 \fn sme_CfgSetStr
3105 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003106 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 \param cfgId - Configuration Parameter ID (type) for STA.
3108 \param pStr - Pointer to the byte array which carries the information needs
3109 to be saved in CFG
3110 \param length - Length of the data to be saved
3111 \param callback - To be registered by CSR with CCM. Once the CFG done with
3112 saving the information in the database, it notifies CCM &
3113 then the callback will be invoked to notify.
3114 \param toBeSaved - To save the request for future reference
3115 \return eHalStatus
3116 ---------------------------------------------------------------------------*/
3117eHalStatus sme_CfgSetStr(tHalHandle hHal, tANI_U32 cfgId, tANI_U8 *pStr,
3118 tANI_U32 length, tCcmCfgSetCallback callback,
3119 eAniBoolean toBeSaved)
3120{
3121 return(ccmCfgSetStr(hHal, cfgId, pStr, length, callback, toBeSaved));
3122}
3123
3124/* ---------------------------------------------------------------------------
3125 \fn sme_GetModifyProfileFields
3126 \brief HDD or SME - QOS calls this function to get the current values of
3127 connected profile fields, changing which can cause reassoc.
3128 This function must be called after CFG is downloaded and STA is in connected
3129 state. Also, make sure to call this function to get the current profile
3130 fields before calling the reassoc. So that pModifyProfileFields will have
3131 all the latest values plus the one(s) has been updated as part of reassoc
3132 request.
3133 \param pModifyProfileFields - pointer to the connected profile fields
3134 changing which can cause reassoc
3135
3136 \return eHalStatus
3137 -------------------------------------------------------------------------------*/
3138eHalStatus sme_GetModifyProfileFields(tHalHandle hHal, tANI_U8 sessionId,
3139 tCsrRoamModifyProfileFields * pModifyProfileFields)
3140{
3141 eHalStatus status = eHAL_STATUS_FAILURE;
3142 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3143
3144 status = sme_AcquireGlobalLock( &pMac->sme );
3145 if ( HAL_STATUS_SUCCESS( status ) )
3146 {
3147 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3148 {
3149 status = csrGetModifyProfileFields(pMac, sessionId, pModifyProfileFields);
3150 }
3151 else
3152 {
3153 status = eHAL_STATUS_INVALID_PARAMETER;
3154 }
3155 sme_ReleaseGlobalLock( &pMac->sme );
3156 }
3157
3158 return (status);
3159}
3160
3161/*--------------------------------------------------------------------------
3162 \fn sme_SetConfigPowerSave
3163 \brief Wrapper fn to change power save configuration in SME (PMC) module.
3164 For BMPS related configuration, this function also updates the CFG
3165 and sends a message to FW to pick up the new values. Note: Calling
3166 this function only updates the configuration and does not enable
3167 the specified power save mode.
3168 \param hHal - The handle returned by macOpen.
3169 \param psMode - Power Saving mode being modified
3170 \param pConfigParams - a pointer to a caller allocated object of type
3171 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
3172 \return eHalStatus
3173 --------------------------------------------------------------------------*/
3174eHalStatus sme_SetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
3175 void *pConfigParams)
3176{
3177 eHalStatus status = eHAL_STATUS_FAILURE;
3178 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3179
3180 if (NULL == pConfigParams ) {
3181 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3182 "nothing to update");
3183 return eHAL_STATUS_FAILURE;
3184 }
3185
3186 status = sme_AcquireGlobalLock( &pMac->sme );
3187 if ( HAL_STATUS_SUCCESS( status ) )
3188 {
3189 status = pmcSetConfigPowerSave(hHal, psMode, pConfigParams);
3190 sme_ReleaseGlobalLock( &pMac->sme );
3191 }
3192
3193 return (status);
3194}
3195
3196/*--------------------------------------------------------------------------
3197 \fn sme_GetConfigPowerSave
3198 \brief Wrapper fn to retrieve power save configuration in SME (PMC) module
3199 \param hHal - The handle returned by macOpen.
3200 \param psMode - Power Saving mode
3201 \param pConfigParams - a pointer to a caller allocated object of type
3202 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
3203 \return eHalStatus
3204 --------------------------------------------------------------------------*/
3205eHalStatus sme_GetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
3206 void *pConfigParams)
3207{
3208 eHalStatus status = eHAL_STATUS_FAILURE;
3209 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3210
3211 if (NULL == pConfigParams ) {
3212 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3213 "nothing to update");
3214 return eHAL_STATUS_FAILURE;
3215 }
3216
3217 status = sme_AcquireGlobalLock( &pMac->sme );
3218 if ( HAL_STATUS_SUCCESS( status ) )
3219 {
3220 status = pmcGetConfigPowerSave(hHal, psMode, pConfigParams);
3221 sme_ReleaseGlobalLock( &pMac->sme );
3222 }
3223
3224 return (status);
3225}
3226
3227/* ---------------------------------------------------------------------------
3228 \fn sme_SignalPowerEvent
3229 \brief Signals to PMC that a power event has occurred. Used for putting
3230 the chip into deep sleep mode.
3231 \param hHal - The handle returned by macOpen.
3232 \param event - the event that has occurred
3233 \return eHalStatus
3234 ---------------------------------------------------------------------------*/
3235eHalStatus sme_SignalPowerEvent (tHalHandle hHal, tPmcPowerEvent event)
3236{
3237 eHalStatus status = eHAL_STATUS_FAILURE;
3238 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3239
3240 status = sme_AcquireGlobalLock( &pMac->sme );
3241 if ( HAL_STATUS_SUCCESS( status ) )
3242 {
3243 status = pmcSignalPowerEvent(hHal, event);
3244 sme_ReleaseGlobalLock( &pMac->sme );
3245 }
3246
3247 return (status);
3248}
3249
3250/* ---------------------------------------------------------------------------
3251 \fn sme_EnablePowerSave
3252 \brief Enables one of the power saving modes.
3253 \param hHal - The handle returned by macOpen.
3254 \param psMode - The power saving mode to enable. If BMPS mode is enabled
3255 while the chip is operating in Full Power, PMC will start
3256 a timer that will try to put the chip in BMPS mode after
3257 expiry.
3258 \return eHalStatus
3259 ---------------------------------------------------------------------------*/
3260eHalStatus sme_EnablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3261{
3262 eHalStatus status = eHAL_STATUS_FAILURE;
3263 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3264
3265 status = sme_AcquireGlobalLock( &pMac->sme );
3266 if ( HAL_STATUS_SUCCESS( status ) )
3267 {
3268 status = pmcEnablePowerSave(hHal, psMode);
3269 sme_ReleaseGlobalLock( &pMac->sme );
3270 }
3271
3272 return (status);
3273}
3274
3275/* ---------------------------------------------------------------------------
3276 \fn sme_DisablePowerSave
3277 \brief Disables one of the power saving modes.
3278 \param hHal - The handle returned by macOpen.
3279 \param psMode - The power saving mode to disable. Disabling does not imply
3280 that device will be brought out of the current PS mode. This
3281 is purely a configuration API.
3282 \return eHalStatus
3283 ---------------------------------------------------------------------------*/
3284eHalStatus sme_DisablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3285{
3286 eHalStatus status = eHAL_STATUS_FAILURE;
3287 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3288
3289 status = sme_AcquireGlobalLock( &pMac->sme );
3290 if ( HAL_STATUS_SUCCESS( status ) )
3291 {
3292 status = pmcDisablePowerSave(hHal, psMode);
3293 sme_ReleaseGlobalLock( &pMac->sme );
3294 }
3295
3296 return (status);
3297 }
3298
3299/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +05303300+ \fn sme_SetHostPowerSave
3301+ \brief Enables BMPS logic to be controlled by User level apps
3302+ \param hHal - The handle returned by macOpen.
3303+ \param psMode - The power saving mode to disable. Disabling does not imply
3304+ that device will be brought out of the current PS mode. This
3305+ is purely a configuration API.
3306+ \return eHalStatus
3307+ ---------------------------------------------------------------------------*/
3308eHalStatus sme_SetHostPowerSave (tHalHandle hHal, v_BOOL_t psMode)
3309{
3310 eHalStatus status = eHAL_STATUS_FAILURE;
3311 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3312
3313 pMac->pmc.isHostPsEn = psMode;
3314
3315 return (status);
3316}
3317
3318/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 \fn sme_StartAutoBmpsTimer
3320 \brief Starts a timer that periodically polls all the registered
3321 module for entry into Bmps mode. This timer is started only if BMPS is
3322 enabled and whenever the device is in full power.
3323 \param hHal - The handle returned by macOpen.
3324 \return eHalStatus
3325 ---------------------------------------------------------------------------*/
3326eHalStatus sme_StartAutoBmpsTimer ( tHalHandle hHal)
3327{
3328 eHalStatus status = eHAL_STATUS_FAILURE;
3329 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3330
3331 status = sme_AcquireGlobalLock( &pMac->sme );
3332 if ( HAL_STATUS_SUCCESS( status ) )
3333 {
3334 status = pmcStartAutoBmpsTimer(hHal);
3335 sme_ReleaseGlobalLock( &pMac->sme );
3336 }
3337
3338 return (status);
3339}
3340/* ---------------------------------------------------------------------------
3341 \fn sme_StopAutoBmpsTimer
3342 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
3343 Stopping the timer does not cause a device state change. Only the timer
3344 is stopped. If "Full Power" is desired, use the sme_RequestFullPower API
3345 \param hHal - The handle returned by macOpen.
3346 \return eHalStatus
3347 ---------------------------------------------------------------------------*/
3348eHalStatus sme_StopAutoBmpsTimer ( tHalHandle hHal)
3349{
3350 eHalStatus status = eHAL_STATUS_FAILURE;
3351 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3352
3353 status = sme_AcquireGlobalLock( &pMac->sme );
3354 if ( HAL_STATUS_SUCCESS( status ) )
3355 {
3356 status = pmcStopAutoBmpsTimer(hHal);
3357 sme_ReleaseGlobalLock( &pMac->sme );
3358 }
3359
3360 return (status);
3361}
3362/* ---------------------------------------------------------------------------
3363 \fn sme_QueryPowerState
3364 \brief Returns the current power state of the device.
3365 \param hHal - The handle returned by macOpen.
3366 \param pPowerState - pointer to location to return power state (LOW or HIGH)
3367 \param pSwWlanSwitchState - ptr to location to return SW WLAN Switch state
3368 \return eHalStatus
3369 ---------------------------------------------------------------------------*/
3370eHalStatus sme_QueryPowerState (
3371 tHalHandle hHal,
3372 tPmcPowerState *pPowerState,
3373 tPmcSwitchState *pSwWlanSwitchState)
3374{
3375 eHalStatus status = eHAL_STATUS_FAILURE;
3376 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3377
3378 status = sme_AcquireGlobalLock( &pMac->sme );
3379 if ( HAL_STATUS_SUCCESS( status ) )
3380 {
3381 status = pmcQueryPowerState (hHal, pPowerState, NULL, pSwWlanSwitchState);
3382 sme_ReleaseGlobalLock( &pMac->sme );
3383 }
3384
3385 return (status);
3386}
3387
3388/* ---------------------------------------------------------------------------
3389 \fn sme_IsPowerSaveEnabled
3390 \brief Checks if the device is able to enter a particular power save mode
3391 This does not imply that the device is in a particular PS mode
3392 \param hHal - The handle returned by macOpen.
3393 \param psMode - the power saving mode
3394 \return eHalStatus
3395 ---------------------------------------------------------------------------*/
3396tANI_BOOLEAN sme_IsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
3397{
3398 eHalStatus status = eHAL_STATUS_FAILURE;
3399 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3400 tANI_BOOLEAN result = false;
3401
3402 status = sme_AcquireGlobalLock( &pMac->sme );
3403 if ( HAL_STATUS_SUCCESS( status ) )
3404 {
3405 result = pmcIsPowerSaveEnabled(hHal, psMode);
3406 sme_ReleaseGlobalLock( &pMac->sme );
3407 return result;
3408 }
3409
3410 return false;
3411}
3412
3413/* ---------------------------------------------------------------------------
3414 \fn sme_RequestFullPower
3415 \brief Request that the device be brought to full power state. When the
3416 device enters Full Power PMC will start a BMPS timer if BMPS PS mode
3417 is enabled. On timer expiry PMC will attempt to put the device in
3418 BMPS mode if following holds true:
3419 - BMPS mode is enabled
3420 - Polling of all modules through the Power Save Check routine passes
3421 - STA is associated to an access point
3422 \param hHal - The handle returned by macOpen.
3423 \param - callbackRoutine Callback routine invoked in case of success/failure
3424 \return eHalStatus - status
3425 eHAL_STATUS_SUCCESS - device brought to full power state
3426 eHAL_STATUS_FAILURE - device cannot be brought to full power state
3427 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
3428 ---------------------------------------------------------------------------*/
3429eHalStatus sme_RequestFullPower (
3430 tHalHandle hHal,
3431 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3432 void *callbackContext,
3433 tRequestFullPowerReason fullPowerReason)
3434{
3435 eHalStatus status = eHAL_STATUS_FAILURE;
3436 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3437
3438 status = sme_AcquireGlobalLock( &pMac->sme );
3439 if ( HAL_STATUS_SUCCESS( status ) )
3440 {
3441 status = pmcRequestFullPower(hHal, callbackRoutine, callbackContext, fullPowerReason);
3442 sme_ReleaseGlobalLock( &pMac->sme );
3443 }
3444
3445 return (status);
3446}
3447
3448/* ---------------------------------------------------------------------------
3449 \fn sme_RequestBmps
3450 \brief Request that the device be put in BMPS state. Request will be
3451 accepted only if BMPS mode is enabled and power save check routine
3452 passes.
3453 \param hHal - The handle returned by macOpen.
3454 \param - callbackRoutine Callback routine invoked in case of success/failure
3455 \return eHalStatus
3456 eHAL_STATUS_SUCCESS - device is in BMPS state
3457 eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
3458 eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state
3459 ---------------------------------------------------------------------------*/
3460eHalStatus sme_RequestBmps (
3461 tHalHandle hHal,
3462 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3463 void *callbackContext)
3464{
3465 eHalStatus status = eHAL_STATUS_FAILURE;
3466 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3467
3468 status = sme_AcquireGlobalLock( &pMac->sme );
3469 if ( HAL_STATUS_SUCCESS( status ) )
3470 {
3471 status = pmcRequestBmps(hHal, callbackRoutine, callbackContext);
3472 sme_ReleaseGlobalLock( &pMac->sme );
3473 }
3474
3475 return (status);
3476}
3477
3478
3479/* ---------------------------------------------------------------------------
3480 \fn sme_SetDHCPTillPowerActiveFlag
3481 \brief Sets/Clears DHCP related flag in PMC to disable/enable auto BMPS
3482 entry by PMC
3483 \param hHal - The handle returned by macOpen.
3484 ---------------------------------------------------------------------------*/
3485void sme_SetDHCPTillPowerActiveFlag(tHalHandle hHal, tANI_U8 flag)
3486{
3487 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3488
3489 // Set/Clear the DHCP flag which will disable/enable auto BMPS entery by PMC
3490 pMac->pmc.remainInPowerActiveTillDHCP = flag;
3491}
3492
3493
3494/* ---------------------------------------------------------------------------
3495 \fn sme_StartUapsd
3496 \brief Request that the device be put in UAPSD state. If the device is in
3497 Full Power it will be put in BMPS mode first and then into UAPSD
3498 mode.
3499 \param hHal - The handle returned by macOpen.
3500 \param - callbackRoutine Callback routine invoked in case of success/failure
3501 eHAL_STATUS_SUCCESS - device is in UAPSD state
3502 eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
3503 eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
3504 eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
3505 \return eHalStatus
3506 ---------------------------------------------------------------------------*/
3507eHalStatus sme_StartUapsd (
3508 tHalHandle hHal,
3509 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3510 void *callbackContext)
3511{
3512 eHalStatus status = eHAL_STATUS_FAILURE;
3513 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3514
3515 status = sme_AcquireGlobalLock( &pMac->sme );
3516 if ( HAL_STATUS_SUCCESS( status ) )
3517 {
3518 status = pmcStartUapsd(hHal, callbackRoutine, callbackContext);
3519 sme_ReleaseGlobalLock( &pMac->sme );
3520 }
3521
3522 return (status);
3523 }
3524
3525/* ---------------------------------------------------------------------------
3526 \fn sme_StopUapsd
3527 \brief Request that the device be put out of UAPSD state. Device will be
3528 put in in BMPS state after stop UAPSD completes.
3529 \param hHal - The handle returned by macOpen.
3530 \return eHalStatus
3531 eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
3532 eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
3533 ---------------------------------------------------------------------------*/
3534eHalStatus sme_StopUapsd (tHalHandle hHal)
3535{
3536 eHalStatus status = eHAL_STATUS_FAILURE;
3537 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3538
3539 status = sme_AcquireGlobalLock( &pMac->sme );
3540 if ( HAL_STATUS_SUCCESS( status ) )
3541 {
3542 status = pmcStopUapsd(hHal);
3543 sme_ReleaseGlobalLock( &pMac->sme );
3544 }
3545
3546 return (status);
3547}
3548
3549/* ---------------------------------------------------------------------------
3550 \fn sme_RequestStandby
3551 \brief Request that the device be put in standby. It is HDD's responsibility
3552 to bring the chip to full power and do a disassoc before calling
3553 this API.
3554 \param hHal - The handle returned by macOpen.
3555 \param - callbackRoutine Callback routine invoked in case of success/failure
3556 \return eHalStatus
3557 eHAL_STATUS_SUCCESS - device is in Standby mode
3558 eHAL_STATUS_FAILURE - device cannot be put in standby mode
3559 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
3560 ---------------------------------------------------------------------------*/
3561eHalStatus sme_RequestStandby (
3562 tHalHandle hHal,
3563 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3564 void *callbackContext)
3565{
3566 eHalStatus status = eHAL_STATUS_FAILURE;
3567 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3568
3569 smsLog( pMac, LOG1, FL("") );
3570 status = sme_AcquireGlobalLock( &pMac->sme );
3571 if ( HAL_STATUS_SUCCESS( status ) )
3572 {
3573 status = pmcRequestStandby(hHal, callbackRoutine, callbackContext);
3574 sme_ReleaseGlobalLock( &pMac->sme );
3575 }
3576
3577 return (status);
3578}
3579
3580/* ---------------------------------------------------------------------------
3581 \fn sme_RegisterPowerSaveCheck
3582 \brief Register a power save check routine that is called whenever
3583 the device is about to enter one of the power save modes.
3584 \param hHal - The handle returned by macOpen.
3585 \param checkRoutine - Power save check routine to be registered
3586 \return eHalStatus
3587 eHAL_STATUS_SUCCESS - successfully registered
3588 eHAL_STATUS_FAILURE - not successfully registered
3589 ---------------------------------------------------------------------------*/
3590eHalStatus sme_RegisterPowerSaveCheck (
3591 tHalHandle hHal,
3592 tANI_BOOLEAN (*checkRoutine) (void *checkContext), void *checkContext)
3593{
3594 eHalStatus status = eHAL_STATUS_FAILURE;
3595 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3596
3597 status = sme_AcquireGlobalLock( &pMac->sme );
3598 if ( HAL_STATUS_SUCCESS( status ) )
3599 {
3600 status = pmcRegisterPowerSaveCheck (hHal, checkRoutine, checkContext);
3601 sme_ReleaseGlobalLock( &pMac->sme );
3602 }
3603
3604 return (status);
3605}
3606
3607/* ---------------------------------------------------------------------------
3608 \fn sme_DeregisterPowerSaveCheck
3609 \brief Deregister a power save check routine
3610 \param hHal - The handle returned by macOpen.
3611 \param checkRoutine - Power save check routine to be deregistered
3612 \return eHalStatus
3613 eHAL_STATUS_SUCCESS - successfully deregistered
3614 eHAL_STATUS_FAILURE - not successfully deregistered
3615 ---------------------------------------------------------------------------*/
3616eHalStatus sme_DeregisterPowerSaveCheck (
3617 tHalHandle hHal,
3618 tANI_BOOLEAN (*checkRoutine) (void *checkContext))
3619{
3620 eHalStatus status = eHAL_STATUS_FAILURE;
3621 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3622
3623 status = sme_AcquireGlobalLock( &pMac->sme );
3624 if ( HAL_STATUS_SUCCESS( status ) )
3625 {
3626 status = pmcDeregisterPowerSaveCheck (hHal, checkRoutine);
3627 sme_ReleaseGlobalLock( &pMac->sme );
3628 }
3629
3630 return (status);
3631}
3632
3633/* ---------------------------------------------------------------------------
3634 \fn sme_RegisterDeviceStateUpdateInd
3635 \brief Register a callback routine that is called whenever
3636 the device enters a new device state (Full Power, BMPS, UAPSD)
3637 \param hHal - The handle returned by macOpen.
3638 \param callbackRoutine - Callback routine to be registered
3639 \param callbackContext - Cookie to be passed back during callback
3640 \return eHalStatus
3641 eHAL_STATUS_SUCCESS - successfully registered
3642 eHAL_STATUS_FAILURE - not successfully registered
3643 ---------------------------------------------------------------------------*/
3644eHalStatus sme_RegisterDeviceStateUpdateInd (
3645 tHalHandle hHal,
3646 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
3647 void *callbackContext)
3648{
3649 eHalStatus status = eHAL_STATUS_FAILURE;
3650 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3651
3652 status = sme_AcquireGlobalLock( &pMac->sme );
3653 if ( HAL_STATUS_SUCCESS( status ) )
3654 {
3655 status = pmcRegisterDeviceStateUpdateInd (hHal, callbackRoutine, callbackContext);
3656 sme_ReleaseGlobalLock( &pMac->sme );
3657 }
3658
3659 return (status);
3660}
3661
3662/* ---------------------------------------------------------------------------
3663 \fn sme_DeregisterDeviceStateUpdateInd
3664 \brief Deregister a routine that was registered for device state changes
3665 \param hHal - The handle returned by macOpen.
3666 \param callbackRoutine - Callback routine to be deregistered
3667 \return eHalStatus
3668 eHAL_STATUS_SUCCESS - successfully deregistered
3669 eHAL_STATUS_FAILURE - not successfully deregistered
3670 ---------------------------------------------------------------------------*/
3671eHalStatus sme_DeregisterDeviceStateUpdateInd (
3672 tHalHandle hHal,
3673 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
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 = pmcDeregisterDeviceStateUpdateInd (hHal, callbackRoutine);
3682 sme_ReleaseGlobalLock( &pMac->sme );
3683 }
3684
3685 return (status);
3686}
3687
3688/* ---------------------------------------------------------------------------
3689 \fn sme_WowlAddBcastPattern
3690 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
3691 do a pattern match on these patterns when Wowl is enabled during BMPS
3692 mode. Note that Firmware performs the pattern matching only on
3693 broadcast frames and while Libra is in BMPS mode.
3694 \param hHal - The handle returned by macOpen.
3695 \param pattern - Pattern to be added
3696 \return eHalStatus
3697 eHAL_STATUS_FAILURE Cannot add pattern
3698 eHAL_STATUS_SUCCESS Request accepted.
3699 ---------------------------------------------------------------------------*/
3700eHalStatus sme_WowlAddBcastPattern (
3701 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003702 tpSirWowlAddBcastPtrn pattern,
3703 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003704{
3705 eHalStatus status = eHAL_STATUS_FAILURE;
3706 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3707 status = sme_AcquireGlobalLock( &pMac->sme );
3708 if ( HAL_STATUS_SUCCESS( status ) )
3709 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003710 status = pmcWowlAddBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 sme_ReleaseGlobalLock( &pMac->sme );
3712 }
3713
3714 return (status);
3715}
3716
3717/* ---------------------------------------------------------------------------
3718 \fn sme_WowlDelBcastPattern
3719 \brief Delete a pattern that was added for Pattern Byte Matching.
3720 \param hHal - The handle returned by macOpen.
3721 \param pattern - Pattern to be deleted
3722 \return eHalStatus
3723 eHAL_STATUS_FAILURE Cannot delete pattern
3724 eHAL_STATUS_SUCCESS Request accepted.
3725 ---------------------------------------------------------------------------*/
3726eHalStatus sme_WowlDelBcastPattern (
3727 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003728 tpSirWowlDelBcastPtrn pattern,
3729 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003730{
3731 eHalStatus status = eHAL_STATUS_FAILURE;
3732 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3733 status = sme_AcquireGlobalLock( &pMac->sme );
3734 if ( HAL_STATUS_SUCCESS( status ) )
3735 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003736 status = pmcWowlDelBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 sme_ReleaseGlobalLock( &pMac->sme );
3738 }
3739
3740 return (status);
3741}
3742
3743/* ---------------------------------------------------------------------------
3744 \fn sme_EnterWowl
3745 \brief This is the SME API exposed to HDD to request enabling of WOWL mode.
3746 WoWLAN works on top of BMPS mode. If the device is not in BMPS mode,
3747 SME will will cache the information that WOWL has been enabled and
3748 attempt to put the device in BMPS. On entry into BMPS, SME will
3749 enable the WOWL mode.
3750 Note 1: If we exit BMPS mode (someone requests full power), we
3751 will NOT resume WOWL when we go back to BMPS again. Request for full
3752 power (while in WOWL mode) means disable WOWL and go to full power.
3753 Note 2: Both UAPSD and WOWL work on top of BMPS. On entry into BMPS, SME
3754 will give priority to UAPSD and enable only UAPSD if both UAPSD and WOWL
3755 are required. Currently there is no requirement or use case to support
3756 UAPSD and WOWL at the same time.
3757
3758 \param hHal - The handle returned by macOpen.
3759 \param enterWowlCallbackRoutine - Callback routine provided by HDD.
3760 Used for success/failure notification by SME
3761 \param enterWowlCallbackContext - A cookie passed by HDD, that is passed back to HDD
3762 at the time of callback.
3763 \param wakeReasonIndCB - Callback routine provided by HDD.
3764 Used for Wake Reason Indication by SME
3765 \param wakeReasonIndCBContext - A cookie passed by HDD, that is passed back to HDD
3766 at the time of callback.
3767 \return eHalStatus
3768 eHAL_STATUS_SUCCESS Device is already in WoWLAN mode
3769 eHAL_STATUS_FAILURE Device cannot enter WoWLAN mode.
3770 eHAL_STATUS_PMC_PENDING Request accepted. SME will enable WOWL after
3771 BMPS mode is entered.
3772 ---------------------------------------------------------------------------*/
3773eHalStatus sme_EnterWowl (
3774 tHalHandle hHal,
3775 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
3776 void *enterWowlCallbackContext,
3777#ifdef WLAN_WAKEUP_EVENTS
3778 void (*wakeIndicationCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
3779 void *wakeIndicationCBContext,
3780#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003781 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003782{
3783 eHalStatus status = eHAL_STATUS_FAILURE;
3784 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3785 status = sme_AcquireGlobalLock( &pMac->sme );
3786 if ( HAL_STATUS_SUCCESS( status ) )
3787 {
3788 status = pmcEnterWowl (hHal, enterWowlCallbackRoutine, enterWowlCallbackContext,
3789#ifdef WLAN_WAKEUP_EVENTS
3790 wakeIndicationCB, wakeIndicationCBContext,
3791#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003792 wowlEnterParams, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 sme_ReleaseGlobalLock( &pMac->sme );
3794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 return (status);
3796}
3797/* ---------------------------------------------------------------------------
3798 \fn sme_ExitWowl
3799 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
3800 SME will initiate exit from WoWLAN mode and device will be put in BMPS
3801 mode.
3802 \param hHal - The handle returned by macOpen.
3803 \return eHalStatus
3804 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
3805 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
3806 ---------------------------------------------------------------------------*/
3807eHalStatus sme_ExitWowl (tHalHandle hHal)
3808{
3809 eHalStatus status = eHAL_STATUS_FAILURE;
3810 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3811 status = sme_AcquireGlobalLock( &pMac->sme );
3812 if ( HAL_STATUS_SUCCESS( status ) )
3813 {
3814 status = pmcExitWowl (hHal);
3815 sme_ReleaseGlobalLock( &pMac->sme );
3816 }
3817
3818 return (status);
3819}
3820
3821/* ---------------------------------------------------------------------------
3822
3823 \fn sme_RoamSetKey
3824
3825 \brief To set encryption key. This function should be called only when connected
3826 This is an asynchronous API.
3827
3828 \param pSetKeyInfo - pointer to a caller allocated object of tCsrSetContextInfo
3829
3830 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3831
3832 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3833
3834 FAILURE or RESOURCES The API finished and failed.
3835
3836 -------------------------------------------------------------------------------*/
3837eHalStatus sme_RoamSetKey(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 *pRoamId)
3838{
3839 eHalStatus status = eHAL_STATUS_FAILURE;
3840 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3841 tANI_U32 roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 tANI_U32 i;
3843 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003844
Jeff Johnsonf89f4b52013-03-27 10:32:44 -07003845 if (pSetKey->keyLength > CSR_MAX_KEY_LEN)
3846 {
3847 smsLog(pMac, LOGE, FL("Invalid key length %d"), pSetKey->keyLength);
3848 return eHAL_STATUS_FAILURE;
3849 }
3850
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 status = sme_AcquireGlobalLock( &pMac->sme );
3852 if ( HAL_STATUS_SUCCESS( status ) )
3853 {
3854 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3855 if(pRoamId)
3856 {
3857 *pRoamId = roamId;
3858 }
3859
Jeff Johnsonf89f4b52013-03-27 10:32:44 -07003860 smsLog(pMac, LOG2, FL("keyLength %d"), pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003861
3862 for(i=0; i<pSetKey->keyLength; i++)
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003863 smsLog(pMac, LOG2, FL("%02x"), pSetKey->Key[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003864
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003865 smsLog(pMac, LOG2, "\n sessionId=%d roamId=%d", sessionId, roamId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003866
3867 pSession = CSR_GET_SESSION(pMac, sessionId);
3868
Jeff Johnson32d95a32012-09-10 13:15:23 -07003869 if(!pSession)
3870 {
3871 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08003872 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003873 return eHAL_STATUS_FAILURE;
3874 }
3875
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
3877 {
3878 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
3879 {
3880 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
3881 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
3882 {
3883 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3884 }
3885 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
3886 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
3887 {
3888 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3889 }
3890 }
3891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003892
3893 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
3894 sme_ReleaseGlobalLock( &pMac->sme );
3895 }
3896
3897 return (status);
3898}
3899
3900
3901/* ---------------------------------------------------------------------------
3902
3903 \fn sme_RoamRemoveKey
3904
3905 \brief To set encryption key. This is an asynchronous API.
3906
3907 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
3908
3909 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3910
3911 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3912
3913 FAILURE or RESOURCES The API finished and failed.
3914
3915 -------------------------------------------------------------------------------*/
3916eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
3917 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
3918{
3919 eHalStatus status = eHAL_STATUS_FAILURE;
3920 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3921 tANI_U32 roamId;
3922
3923 status = sme_AcquireGlobalLock( &pMac->sme );
3924 if ( HAL_STATUS_SUCCESS( status ) )
3925 {
3926 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3927 if(pRoamId)
3928 {
3929 *pRoamId = roamId;
3930 }
3931 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
3932 sme_ReleaseGlobalLock( &pMac->sme );
3933 }
3934
3935 return (status);
3936}
3937
3938/* ---------------------------------------------------------------------------
3939 \fn sme_GetRssi
3940 \brief a wrapper function that client calls to register a callback to get RSSI
3941
3942 \param callback - SME sends back the requested stats using the callback
3943 \param staId - The station ID for which the stats is requested for
3944 \param pContext - user context to be passed back along with the callback
3945 \param pVosContext - vos context
3946 \return eHalStatus
3947 ---------------------------------------------------------------------------*/
3948eHalStatus sme_GetRssi(tHalHandle hHal,
3949 tCsrRssiCallback callback,
3950 tANI_U8 staId, tCsrBssid bssId,
3951 void *pContext, void* pVosContext)
3952{
3953 eHalStatus status = eHAL_STATUS_FAILURE;
3954 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3955
3956 status = sme_AcquireGlobalLock( &pMac->sme );
3957 if ( HAL_STATUS_SUCCESS( status ) )
3958 {
3959 status = csrGetRssi( pMac, callback,
3960 staId, bssId, pContext, pVosContext);
3961 sme_ReleaseGlobalLock( &pMac->sme );
3962 }
3963 return (status);
3964}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08003965#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
3966/* ---------------------------------------------------------------------------
3967 \fn sme_GetRoamRssi
3968 \brief a wrapper function that client calls to register a callback to get Roam RSSI
3969
3970 \param callback - SME sends back the requested stats using the callback
3971 \param staId - The station ID for which the stats is requested for
3972 \param pContext - user context to be passed back along with the callback
3973 \param pVosContext - vos context
3974 \return eHalStatus
3975 ---------------------------------------------------------------------------*/
3976eHalStatus sme_GetRoamRssi(tHalHandle hHal,
3977 tCsrRssiCallback callback,
3978 tANI_U8 staId, tCsrBssid bssId,
3979 void *pContext, void* pVosContext)
3980{
3981 eHalStatus status = eHAL_STATUS_FAILURE;
3982 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3983
3984 status = sme_AcquireGlobalLock( &pMac->sme );
3985 if ( HAL_STATUS_SUCCESS( status ) )
3986 {
3987 status = csrGetRoamRssi( pMac, callback,
3988 staId, bssId, pContext, pVosContext);
3989 sme_ReleaseGlobalLock( &pMac->sme );
3990 }
3991 return (status);
3992}
3993#endif
3994
Jeff Johnson295189b2012-06-20 16:38:30 -07003995
3996/* ---------------------------------------------------------------------------
3997 \fn sme_GetStatistics
3998 \brief a wrapper function that client calls to register a callback to get
3999 different PHY level statistics from CSR.
4000
4001 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
4002 \param statsMask - The different category/categories of stats requester is looking for
4003 \param callback - SME sends back the requested stats using the callback
4004 \param periodicity - If requester needs periodic update in millisec, 0 means
4005 it's an one time request
4006 \param cache - If requester is happy with cached stats
4007 \param staId - The station ID for which the stats is requested for
4008 \param pContext - user context to be passed back along with the callback
4009 \return eHalStatus
4010 ---------------------------------------------------------------------------*/
4011eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
4012 tANI_U32 statsMask,
4013 tCsrStatsCallback callback,
4014 tANI_U32 periodicity, tANI_BOOLEAN cache,
4015 tANI_U8 staId, void *pContext)
4016{
4017 eHalStatus status = eHAL_STATUS_FAILURE;
4018 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4019
4020 status = sme_AcquireGlobalLock( &pMac->sme );
4021 if ( HAL_STATUS_SUCCESS( status ) )
4022 {
4023 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
4024 periodicity, cache, staId, pContext);
4025 sme_ReleaseGlobalLock( &pMac->sme );
4026 }
4027
4028 return (status);
4029
4030}
4031
4032/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304033 \fn smeGetTLSTAState
4034 \helper function to get the TL STA State whenever the function is called.
4035
4036 \param staId - The staID to be passed to the TL
4037 to get the relevant TL STA State
4038 \return the state as tANI_U16
4039 ---------------------------------------------------------------------------*/
4040tANI_U16 smeGetTLSTAState(tHalHandle hHal, tANI_U8 staId)
4041{
4042 tANI_U16 tlSTAState = TL_INIT_STATE;
4043 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4044 eHalStatus status = eHAL_STATUS_FAILURE;
4045
4046 status = sme_AcquireGlobalLock( &pMac->sme );
4047 if ( HAL_STATUS_SUCCESS( status ) )
4048 {
4049 tlSTAState = csrGetTLSTAState( pMac, staId);
4050 sme_ReleaseGlobalLock( &pMac->sme );
4051 }
4052
4053 return tlSTAState;
4054}
4055
4056/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07004057
4058 \fn sme_GetCountryCode
4059
4060 \brief To return the current country code. If no country code is applied, default country code is
4061 used to fill the buffer.
4062 If 11d supported is turned off, an error is return and the last applied/default country code is used.
4063 This is a synchronous API.
4064
4065 \param pBuf - pointer to a caller allocated buffer for returned country code.
4066
4067 \param pbLen For input, this parameter indicates how big is the buffer.
4068 Upon return, this parameter has the number of bytes for country. If pBuf
4069 doesn't have enough space, this function returns
4070 fail status and this parameter contains the number that is needed.
4071
4072 \return eHalStatus SUCCESS.
4073
4074 FAILURE or RESOURCES The API finished and failed.
4075
4076 -------------------------------------------------------------------------------*/
4077eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
4078{
4079 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4080
4081 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
4082}
4083
4084
4085/* ---------------------------------------------------------------------------
4086
4087 \fn sme_SetCountryCode
4088
4089 \brief To change the current/default country code.
4090 If 11d supported is turned off, an error is return.
4091 This is a synchronous API.
4092
4093 \param pCountry - pointer to a caller allocated buffer for the country code.
4094
4095 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
4096 whether a reset is required.
4097
4098 \return eHalStatus SUCCESS.
4099
4100 FAILURE or RESOURCES The API finished and failed.
4101
4102 -------------------------------------------------------------------------------*/
4103eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
4104{
4105 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4106
4107 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
4108}
4109
4110
4111/* ---------------------------------------------------------------------------
4112 \fn sme_ResetCountryCodeInformation
4113 \brief this function is to reset the country code current being used back to EEPROM default
4114 this includes channel list and power setting. This is a synchronous API.
4115 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
4116 a restart is needed to apply the change
4117 \return eHalStatus
4118 -------------------------------------------------------------------------------*/
4119eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
4120{
4121 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4122
4123 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
4124}
4125
4126
4127/* ---------------------------------------------------------------------------
4128 \fn sme_GetSupportedCountryCode
4129 \brief this function is to get a list of the country code current being supported
4130 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
4131 this has the country code list. 3 bytes for each country code. This may be NULL if
4132 caller wants to know the needed byte count.
4133 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
4134 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
4135 \return eHalStatus
4136 -------------------------------------------------------------------------------*/
4137eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
4138{
4139 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4140
4141 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
4142}
4143
4144
4145/* ---------------------------------------------------------------------------
4146 \fn sme_GetCurrentRegulatoryDomain
4147 \brief this function is to get the current regulatory domain. This is a synchronous API.
4148 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4149 SME. The function fails if 11d support is turned off.
4150 \param pDomain - Caller allocated buffer to return the current domain.
4151 \return eHalStatus SUCCESS.
4152
4153 FAILURE or RESOURCES The API finished and failed.
4154 -------------------------------------------------------------------------------*/
4155eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
4156{
4157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4158 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4159
4160 if( pDomain )
4161 {
4162 if( csrIs11dSupported( pMac ) )
4163 {
4164 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
4165 status = eHAL_STATUS_SUCCESS;
4166 }
4167 else
4168 {
4169 status = eHAL_STATUS_FAILURE;
4170 }
4171 }
4172
4173 return ( status );
4174}
4175
4176
4177/* ---------------------------------------------------------------------------
4178 \fn sme_SetRegulatoryDomain
4179 \brief this function is to set the current regulatory domain.
4180 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4181 SME. This is a synchronous API.
4182 \param domainId - indicate the domain (defined in the driver) needs to set to.
4183 See v_REGDOMAIN_t for definition
4184 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
4185 a restart is needed to apply the change
4186 \return eHalStatus
4187 -------------------------------------------------------------------------------*/
4188eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
4189{
4190 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4191
4192 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
4193}
4194
4195
4196/* ---------------------------------------------------------------------------
4197
4198 \fn sme_GetRegulatoryDomainForCountry
4199
4200 \brief To return a regulatory domain base on a country code. This is a synchronous API.
4201
4202 \param pCountry - pointer to a caller allocated buffer for input country code.
4203
4204 \param pDomainId Upon successful return, it is the domain that country belongs to.
4205 If it is NULL, returning success means that the country code is known.
4206
4207 \return eHalStatus SUCCESS.
4208
4209 FAILURE or RESOURCES The API finished and failed.
4210
4211 -------------------------------------------------------------------------------*/
4212eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
4213{
4214 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4215
4216 return ( csrGetRegulatoryDomainForCountry( pMac, pCountry, pDomainId ) );
4217}
4218
4219
4220
4221
4222/* ---------------------------------------------------------------------------
4223
4224 \fn sme_GetSupportedRegulatoryDomains
4225
4226 \brief To return a list of supported regulatory domains. This is a synchronous API.
4227
4228 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
4229
4230 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
4231 Upon return, this parameter has the number for supported domains. If pDomains
4232 doesn't have enough space for all the supported domains, this function returns
4233 fail status and this parameter contains the number that is needed.
4234
4235 \return eHalStatus SUCCESS.
4236
4237 FAILURE or RESOURCES The API finished and failed.
4238
4239 -------------------------------------------------------------------------------*/
4240eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
4241{
4242 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4243
4244 //We support all domains for now
4245 if( pNumDomains )
4246 {
4247 if( NUM_REG_DOMAINS <= *pNumDomains )
4248 {
4249 status = eHAL_STATUS_SUCCESS;
4250 }
4251 *pNumDomains = NUM_REG_DOMAINS;
4252 }
4253 if( HAL_STATUS_SUCCESS( status ) )
4254 {
4255 if( pDomains )
4256 {
4257 pDomains[0] = REGDOMAIN_FCC;
4258 pDomains[1] = REGDOMAIN_ETSI;
4259 pDomains[2] = REGDOMAIN_JAPAN;
4260 pDomains[3] = REGDOMAIN_WORLD;
4261 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
4262 pDomains[5] = REGDOMAIN_APAC;
4263 pDomains[6] = REGDOMAIN_KOREA;
4264 pDomains[7] = REGDOMAIN_HI_5GHZ;
4265 pDomains[8] = REGDOMAIN_NO_5GHZ;
4266 }
4267 else
4268 {
4269 status = eHAL_STATUS_INVALID_PARAMETER;
4270 }
4271 }
4272
4273 return ( status );
4274}
4275
4276
4277//some support functions
4278tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
4279{
4280 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4281
4282 return ( csrIs11dSupported( pMac ) );
4283}
4284
4285
4286tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
4287{
4288 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4289
4290 return ( csrIs11hSupported( pMac ) );
4291}
4292
4293
4294tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
4295{
4296 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4297
4298 return ( csrIsWmmSupported( pMac ) );
4299}
4300
4301//Upper layer to get the list of the base channels to scan for passively 11d info from csr
4302eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
4303{
4304 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4305
4306 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
4307}
4308
4309/* ---------------------------------------------------------------------------
4310
4311 \fn sme_ChangeCountryCode
4312
4313 \brief Change Country code from upperlayer during WLAN driver operation.
4314 This is a synchronous API.
4315
4316 \param hHal - The handle returned by macOpen.
4317
4318 \param pCountry New Country Code String
4319
4320 \return eHalStatus SUCCESS.
4321
4322 FAILURE or RESOURCES The API finished and failed.
4323
4324 -------------------------------------------------------------------------------*/
4325eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
4326 tSmeChangeCountryCallback callback,
4327 tANI_U8 *pCountry,
4328 void *pContext,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304329 void* pVosContext,
4330 tAniBool countryFromUserSpace )
Jeff Johnson295189b2012-06-20 16:38:30 -07004331{
4332 eHalStatus status = eHAL_STATUS_FAILURE;
4333 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4334 vos_msg_t msg;
4335 tAniChangeCountryCodeReq *pMsg;
4336
4337 status = sme_AcquireGlobalLock( &pMac->sme );
4338 if ( HAL_STATUS_SUCCESS( status ) )
4339 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004340 smsLog(pMac, LOG1, FL(" called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniChangeCountryCodeReq));
4342 if ( !HAL_STATUS_SUCCESS(status) )
4343 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004344 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req");
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08004345 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 return status;
4347 }
4348
4349 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
4350 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
4351 palCopyMemory(pMac->hHdd, pMsg->countryCode, pCountry, 3);
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304352 pMsg->countryFromUserSpace = countryFromUserSpace;
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 pMsg->changeCCCallback = callback;
4354 pMsg->pDevContext = pContext;
4355 pMsg->pVosContext = pVosContext;
4356
4357 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4358 msg.bodyptr = pMsg;
4359 msg.reserved = 0;
4360
4361 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
4362 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004363 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -07004364 palFreeMemory(pMac->hHdd, (void *)pMsg);
4365 status = eHAL_STATUS_FAILURE;
4366 }
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004367 smsLog(pMac, LOG1, FL(" returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 sme_ReleaseGlobalLock( &pMac->sme );
4369 }
4370
4371 return (status);
4372}
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05304373/* ---------------------------------------------------------------------------
4374
4375 \fn sme_DHCPStartInd
4376
4377 \brief API to signal the FW about the DHCP Start event.
4378
4379 \param hHal - HAL handle for device.
4380
4381 \param device_mode - mode(AP,SAP etc) of the device.
4382
4383 \param macAddr - MAC address of the device.
4384
4385 \return eHalStatus SUCCESS.
4386
4387 FAILURE or RESOURCES The API finished and failed.
4388 --------------------------------------------------------------------------*/
4389eHalStatus sme_DHCPStartInd( tHalHandle hHal,
4390 tANI_U8 device_mode,
4391 tANI_U8 *macAddr )
4392{
4393 eHalStatus status;
4394 VOS_STATUS vosStatus;
4395 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4396 vos_msg_t vosMessage;
4397 tAniDHCPInd *pMsg;
4398
4399 status = sme_AcquireGlobalLock(&pMac->sme);
4400 if ( eHAL_STATUS_SUCCESS == status)
4401 {
4402 pMsg = (tAniDHCPInd*)vos_mem_malloc(sizeof(tAniDHCPInd));
4403 if (NULL == pMsg)
4404 {
4405 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4406 "%s: Not able to allocate memory for dhcp start", __func__);
4407 sme_ReleaseGlobalLock( &pMac->sme );
4408 return eHAL_STATUS_FAILURE;
4409 }
4410 pMsg->msgType = WDA_DHCP_START_IND;
4411 pMsg->msgLen = (tANI_U16)sizeof(tAniDHCPInd);
4412 pMsg->device_mode = device_mode;
4413 vos_mem_copy( pMsg->macAddr, macAddr, sizeof(tSirMacAddr));
4414
4415 vosMessage.type = WDA_DHCP_START_IND;
4416 vosMessage.bodyptr = pMsg;
4417 vosMessage.reserved = 0;
4418
4419 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
4420 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
4421 {
4422 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4423 "%s: Post DHCP Start MSG fail", __func__);
4424 vos_mem_free(pMsg);
4425 status = eHAL_STATUS_FAILURE;
4426 }
4427 sme_ReleaseGlobalLock( &pMac->sme );
4428 }
4429 return (status);
4430}
4431/* ---------------------------------------------------------------------------
4432 \fn sme_DHCPStopInd
4433
4434 \brief API to signal the FW about the DHCP complete event.
4435
4436 \param hHal - HAL handle for device.
4437
4438 \param device_mode - mode(AP, SAP etc) of the device.
4439
4440 \param macAddr - MAC address of the device.
4441
4442 \return eHalStatus SUCCESS.
4443 FAILURE or RESOURCES The API finished and failed.
4444 --------------------------------------------------------------------------*/
4445eHalStatus sme_DHCPStopInd( tHalHandle hHal,
4446 tANI_U8 device_mode,
4447 tANI_U8 *macAddr )
4448{
4449 eHalStatus status;
4450 VOS_STATUS vosStatus;
4451 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4452 vos_msg_t vosMessage;
4453 tAniDHCPInd *pMsg;
4454
4455 status = sme_AcquireGlobalLock(&pMac->sme);
4456 if ( eHAL_STATUS_SUCCESS == status)
4457 {
4458 pMsg = (tAniDHCPInd*)vos_mem_malloc(sizeof(tAniDHCPInd));
4459 if (NULL == pMsg)
4460 {
4461 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4462 "%s: Not able to allocate memory for dhcp stop", __func__);
4463 sme_ReleaseGlobalLock( &pMac->sme );
4464 return eHAL_STATUS_FAILURE;
4465 }
4466
4467 pMsg->msgType = WDA_DHCP_STOP_IND;
4468 pMsg->msgLen = (tANI_U16)sizeof(tAniDHCPInd);
4469 pMsg->device_mode = device_mode;
4470 vos_mem_copy( pMsg->macAddr, macAddr, sizeof(tSirMacAddr));
4471
4472 vosMessage.type = WDA_DHCP_STOP_IND;
4473 vosMessage.bodyptr = pMsg;
4474 vosMessage.reserved = 0;
4475
4476 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
4477 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
4478 {
4479 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4480 "%s: Post DHCP Stop MSG fail", __func__);
4481 vos_mem_free(pMsg);
4482 status = eHAL_STATUS_FAILURE;
4483 }
4484
4485 sme_ReleaseGlobalLock( &pMac->sme );
4486 }
4487 return (status);
4488}
4489
Jeff Johnson295189b2012-06-20 16:38:30 -07004490
4491/* ---------------------------------------------------------------------------
4492 \fn sme_BtcSignalBtEvent
4493 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
4494 BT event type and the current operating mode of Libra (full power,
4495 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
4496 would be employed.
4497 \param hHal - The handle returned by macOpen.
4498 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
4499 Caller owns the memory and is responsible for freeing it.
4500 \return VOS_STATUS
4501 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
4502 if BTC execution mode is set to BTC_WLAN_ONLY
4503 or BTC_PTA_ONLY.
4504 VOS_STATUS_SUCCESS BT Event passed to HAL
4505 ---------------------------------------------------------------------------*/
4506VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
4507{
4508 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4509#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4510 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4511
4512 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4513 {
4514 status = btcSignalBTEvent (hHal, pBtEvent);
4515 sme_ReleaseGlobalLock( &pMac->sme );
4516 }
4517#endif
4518 return (status);
4519}
4520
4521/* ---------------------------------------------------------------------------
4522 \fn sme_BtcSetConfig
4523 \brief API to change the current Bluetooth Coexistence (BTC) configuration
4524 This function should be invoked only after CFG download has completed.
4525 Calling it after sme_HDDReadyInd is recommended.
4526 \param hHal - The handle returned by macOpen.
4527 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
4528 Caller owns the memory and is responsible for freeing it.
4529 \return VOS_STATUS
4530 VOS_STATUS_E_FAILURE Config not passed to HAL.
4531 VOS_STATUS_SUCCESS Config passed to HAL
4532 ---------------------------------------------------------------------------*/
4533VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4534{
4535 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4536#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4537 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4538 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4539 {
4540 status = btcSetConfig (hHal, pSmeBtcConfig);
4541 sme_ReleaseGlobalLock( &pMac->sme );
4542 }
4543#endif
4544 return (status);
4545}
4546
4547/* ---------------------------------------------------------------------------
4548 \fn sme_BtcGetConfig
4549 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
4550 \param hHal - The handle returned by macOpen.
4551 \param pSmeBtcConfig - Pointer to a caller allocated object of type
4552 tSmeBtcConfig. Caller owns the memory and is responsible
4553 for freeing it.
4554 \return VOS_STATUS
4555 VOS_STATUS_E_FAILURE - failure
4556 VOS_STATUS_SUCCESS success
4557 ---------------------------------------------------------------------------*/
4558VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4559{
4560 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4561#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4562 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4563
4564 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4565 {
4566 status = btcGetConfig (hHal, pSmeBtcConfig);
4567 sme_ReleaseGlobalLock( &pMac->sme );
4568 }
4569#endif
4570 return (status);
4571}
4572/* ---------------------------------------------------------------------------
4573 \fn sme_SetCfgPrivacy
4574 \brief API to set configure privacy parameters
4575 \param hHal - The handle returned by macOpen.
4576 \param pProfile - Pointer CSR Roam profile.
4577 \param fPrivacy - This parameter indicates status of privacy
4578
4579 \return void
4580 ---------------------------------------------------------------------------*/
4581void sme_SetCfgPrivacy( tHalHandle hHal,
4582 tCsrRoamProfile *pProfile,
4583 tANI_BOOLEAN fPrivacy
4584 )
4585{
4586 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4587 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4588 {
4589 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
4590 sme_ReleaseGlobalLock( &pMac->sme );
4591 }
4592}
4593
4594#if defined WLAN_FEATURE_VOWIFI
4595/* ---------------------------------------------------------------------------
4596 \fn sme_NeighborReportRequest
4597 \brief API to request neighbor report.
4598 \param hHal - The handle returned by macOpen.
4599 \param pRrmNeighborReq - Pointer to a caller allocated object of type
4600 tRrmNeighborReq. Caller owns the memory and is responsible
4601 for freeing it.
4602 \return VOS_STATUS
4603 VOS_STATUS_E_FAILURE - failure
4604 VOS_STATUS_SUCCESS success
4605 ---------------------------------------------------------------------------*/
4606VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
4607 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
4608{
4609 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4610 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4611
4612 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4613 {
4614 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
4615 sme_ReleaseGlobalLock( &pMac->sme );
4616 }
4617
4618 return (status);
4619}
4620#endif
4621
4622//The following are debug APIs to support direct read/write register/memory
4623//They are placed in SME because HW cannot be access when in LOW_POWER state
4624//AND not connected. The knowledge and synchronization is done in SME
4625
4626//sme_DbgReadRegister
4627//Caller needs to validate the input values
4628VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
4629{
4630 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4631 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 tPmcPowerState PowerState;
4633 tANI_U32 sessionId = 0;
4634
4635 /* 1) To make Quarky work in FTM mode **************************************/
4636
4637 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4638 {
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08004639 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 {
4641 return VOS_STATUS_SUCCESS;
4642 }
4643 return VOS_STATUS_E_FAILURE;
4644 }
4645
4646 /* 2) NON FTM mode driver *************************************************/
4647
4648 /* Acquire SME global lock */
4649 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4650 {
4651 return VOS_STATUS_E_FAILURE;
4652 }
4653
4654 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4655 {
4656 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4657 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4658 {
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08004659 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 {
4661 status = VOS_STATUS_SUCCESS;
4662 }
4663 else
4664 {
4665 status = VOS_STATUS_E_FAILURE;
4666 }
4667 }
4668 else
4669 {
4670 status = VOS_STATUS_E_FAILURE;
4671 }
4672 }
4673
4674 /* This is a hack for Qualky/pttWniSocket
4675 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4676 if ( VOS_STATUS_SUCCESS != status )
4677 {
4678 *pRegValue = 0xDEADBEEF;
4679 status = VOS_STATUS_SUCCESS;
4680 }
4681
4682 /* Release SME global lock */
4683 sme_ReleaseGlobalLock(&pMac->sme);
4684
4685 return (status);
4686}
4687
4688
4689//sme_DbgWriteRegister
4690//Caller needs to validate the input values
4691VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
4692{
4693 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4694 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 tPmcPowerState PowerState;
4696 tANI_U32 sessionId = 0;
4697
4698 /* 1) To make Quarky work in FTM mode **************************************/
4699
4700 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4701 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 {
4704 return VOS_STATUS_SUCCESS;
4705 }
4706 return VOS_STATUS_E_FAILURE;
4707 }
4708
4709 /* 2) NON FTM mode driver *************************************************/
4710
4711 /* Acquire SME global lock */
4712 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4713 {
4714 return VOS_STATUS_E_FAILURE;
4715 }
4716
4717 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4718 {
4719 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4720 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4721 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 {
4724 status = VOS_STATUS_SUCCESS;
4725 }
4726 else
4727 {
4728 status = VOS_STATUS_E_FAILURE;
4729 }
4730 }
4731 else
4732 {
4733 status = VOS_STATUS_E_FAILURE;
4734 }
4735 }
4736
4737 /* Release SME global lock */
4738 sme_ReleaseGlobalLock(&pMac->sme);
4739
4740 return (status);
4741}
4742
4743
4744
4745//sme_DbgReadMemory
4746//Caller needs to validate the input values
4747//pBuf caller allocated buffer has the length of nLen
4748VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4749{
4750 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4751 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 tPmcPowerState PowerState;
4753 tANI_U32 sessionId = 0;
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004754 tANI_U32 cmd = READ_MEMORY_DUMP_CMD;
4755 tANI_U32 arg1 = memAddr;
4756 tANI_U32 arg2 = nLen/4;
4757 tANI_U32 arg3 = 4;
4758 tANI_U32 arg4 = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 /* 1) To make Quarky work in FTM mode **************************************/
4760
4761 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4762 {
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004763 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8*)pBuf))
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 {
4765 return VOS_STATUS_SUCCESS;
4766 }
4767 return VOS_STATUS_E_FAILURE;
4768 }
4769
4770 /* 2) NON FTM mode driver *************************************************/
4771
4772 /* Acquire SME global lock */
4773 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4774 {
4775 return VOS_STATUS_E_FAILURE;
4776 }
4777
4778 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4779 {
4780 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4781 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4782 {
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004783 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8 *)pBuf))
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 {
4785 status = VOS_STATUS_SUCCESS;
4786 }
4787 else
4788 {
4789 status = VOS_STATUS_E_FAILURE;
4790 }
4791 }
4792 else
4793 {
4794 status = VOS_STATUS_E_FAILURE;
4795 }
4796 }
4797
4798 /* This is a hack for Qualky/pttWniSocket
4799 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4800 if (VOS_STATUS_SUCCESS != status)
4801 {
4802 vos_mem_set(pBuf, nLen, 0xCD);
4803 status = VOS_STATUS_SUCCESS;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004804 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 }
4806
4807 /* Release SME lock */
4808 sme_ReleaseGlobalLock(&pMac->sme);
4809
4810 return (status);
4811}
4812
4813
4814//sme_DbgWriteMemory
4815//Caller needs to validate the input values
4816VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4817{
4818 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4819 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 tPmcPowerState PowerState;
4821 tANI_U32 sessionId = 0;
4822
4823 /* 1) To make Quarky work in FTM mode **************************************/
4824
4825 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4826 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 {
4828 return VOS_STATUS_SUCCESS;
4829 }
4830 return VOS_STATUS_E_FAILURE;
4831 }
4832
4833 /* 2) NON FTM mode driver *************************************************/
4834
4835 /* Acquire SME global lock */
4836 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4837 {
4838 return VOS_STATUS_E_FAILURE;
4839 }
4840
4841 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4842 {
4843 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4844 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4845 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 {
4848 status = VOS_STATUS_SUCCESS;
4849 }
4850 else
4851 {
4852 status = VOS_STATUS_E_FAILURE;
4853 }
4854 }
4855 else
4856 {
4857 status = VOS_STATUS_E_FAILURE;
4858 }
4859 }
4860
4861 /* Release Global lock */
4862 sme_ReleaseGlobalLock(&pMac->sme);
4863
4864 return (status);
4865}
4866
4867
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004868void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
Jeff Johnson295189b2012-06-20 16:38:30 -07004869{
4870#ifdef WLAN_DEBUG
4871 // Verify against current log level
4872 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
4873 return;
4874 else
4875 {
4876 va_list marker;
4877
4878 va_start( marker, pString ); /* Initialize variable arguments. */
4879
4880 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
4881
4882 va_end( marker ); /* Reset variable arguments. */
4883 }
4884#endif
4885}
Jeff Johnson295189b2012-06-20 16:38:30 -07004886
Jeff Johnson295189b2012-06-20 16:38:30 -07004887/* ---------------------------------------------------------------------------
4888 \fn sme_GetWcnssWlanCompiledVersion
4889 \brief This API returns the version of the WCNSS WLAN API with
4890 which the HOST driver was built
4891 \param hHal - The handle returned by macOpen.
4892 \param pVersion - Points to the Version structure to be filled
4893 \return VOS_STATUS
4894 VOS_STATUS_E_INVAL - failure
4895 VOS_STATUS_SUCCESS success
4896 ---------------------------------------------------------------------------*/
4897VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
4898 tSirVersionType *pVersion)
4899{
4900 VOS_STATUS status = VOS_STATUS_SUCCESS;
4901 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4902 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4903
4904 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4905 {
4906 if( pVersion != NULL )
4907 {
4908 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
4909 }
4910 else
4911 {
4912 status = VOS_STATUS_E_INVAL;
4913 }
4914 sme_ReleaseGlobalLock( &pMac->sme );
4915 }
4916
4917 return (status);
4918}
4919
4920
4921/* ---------------------------------------------------------------------------
4922 \fn sme_GetWcnssWlanReportedVersion
4923 \brief This API returns the version of the WCNSS WLAN API with
4924 which the WCNSS driver reports it was built
4925 \param hHal - The handle returned by macOpen.
4926 \param pVersion - Points to the Version structure to be filled
4927 \return VOS_STATUS
4928 VOS_STATUS_E_INVAL - failure
4929 VOS_STATUS_SUCCESS success
4930 ---------------------------------------------------------------------------*/
4931VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
4932 tSirVersionType *pVersion)
4933{
4934 VOS_STATUS status = VOS_STATUS_SUCCESS;
4935 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4936 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4937
4938 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4939 {
4940 if( pVersion != NULL )
4941 {
4942 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
4943 }
4944 else
4945 {
4946 status = VOS_STATUS_E_INVAL;
4947 }
4948 sme_ReleaseGlobalLock( &pMac->sme );
4949 }
4950
4951 return (status);
4952}
4953
4954
4955/* ---------------------------------------------------------------------------
4956 \fn sme_GetWcnssSoftwareVersion
4957 \brief This API returns the version string of the WCNSS driver
4958 \param hHal - The handle returned by macOpen.
4959 \param pVersion - Points to the Version string buffer to be filled
4960 \param versionBufferSize - THe size of the Version string buffer
4961 \return VOS_STATUS
4962 VOS_STATUS_E_INVAL - failure
4963 VOS_STATUS_SUCCESS success
4964 ---------------------------------------------------------------------------*/
4965VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
4966 tANI_U8 *pVersion,
4967 tANI_U32 versionBufferSize)
4968{
4969 VOS_STATUS status = VOS_STATUS_SUCCESS;
4970 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4971 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4972
4973 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4974 {
4975 if( pVersion != NULL )
4976 {
4977 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
4978 versionBufferSize);
4979 }
4980 else
4981 {
4982 status = VOS_STATUS_E_INVAL;
4983 }
4984 sme_ReleaseGlobalLock( &pMac->sme );
4985 }
4986
4987 return (status);
4988}
4989
4990
4991/* ---------------------------------------------------------------------------
4992 \fn sme_GetWcnssHardwareVersion
4993 \brief This API returns the version string of the WCNSS hardware
4994 \param hHal - The handle returned by macOpen.
4995 \param pVersion - Points to the Version string buffer to be filled
4996 \param versionBufferSize - THe size of the Version string buffer
4997 \return VOS_STATUS
4998 VOS_STATUS_E_INVAL - failure
4999 VOS_STATUS_SUCCESS success
5000 ---------------------------------------------------------------------------*/
5001VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
5002 tANI_U8 *pVersion,
5003 tANI_U32 versionBufferSize)
5004{
5005 VOS_STATUS status = VOS_STATUS_SUCCESS;
5006 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5007 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
5008
5009 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5010 {
5011 if( pVersion != NULL )
5012 {
5013 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
5014 versionBufferSize);
5015 }
5016 else
5017 {
5018 status = VOS_STATUS_E_INVAL;
5019 }
5020 sme_ReleaseGlobalLock( &pMac->sme );
5021 }
5022
5023 return (status);
5024}
Jeff Johnson4824d4c2013-02-12 14:23:57 -08005025
Jeff Johnson295189b2012-06-20 16:38:30 -07005026
5027#ifdef FEATURE_WLAN_WAPI
5028/* ---------------------------------------------------------------------------
5029 \fn sme_RoamSetBKIDCache
5030 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
5031 candidate list.
5032 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
5033 it is opened (by calling halOpen).
5034 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
5035 \param numItems - a variable that has the number of tBkidCacheInfo allocated
5036 when retruning, this is the number of items put into pBKIDCache
5037 \return eHalStatus - when fail, it usually means the buffer allocated is not
5038 big enough and pNumItems has the number of tBkidCacheInfo.
5039 ---------------------------------------------------------------------------*/
5040eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
5041 tANI_U32 numItems )
5042{
5043 eHalStatus status = eHAL_STATUS_FAILURE;
5044 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5045
5046 status = sme_AcquireGlobalLock( &pMac->sme );
5047 if ( HAL_STATUS_SUCCESS( status ) )
5048 {
5049 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
5050 sme_ReleaseGlobalLock( &pMac->sme );
5051 }
5052
5053 return (status);
5054}
5055
5056/* ---------------------------------------------------------------------------
5057 \fn sme_RoamGetBKIDCache
5058 \brief The SME API exposed to HDD to allow HDD to request SME to return its
5059 BKID cache.
5060 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
5061 it is opened (by calling halOpen).
5062 \param pNum - caller allocated memory that has the space of the number of
5063 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
5064 in SME cache.
5065 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
5066 upon return
5067 \return eHalStatus - when fail, it usually means the buffer allocated is not
5068 big enough.
5069 ---------------------------------------------------------------------------*/
5070eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
5071 tBkidCacheInfo *pBkidCache)
5072{
5073 eHalStatus status = eHAL_STATUS_FAILURE;
5074 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5075
5076 status = sme_AcquireGlobalLock( &pMac->sme );
5077 if ( HAL_STATUS_SUCCESS( status ) )
5078 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005079 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
5081 sme_ReleaseGlobalLock( &pMac->sme );
5082 }
5083
5084 return (status);
5085}
5086
5087/* ---------------------------------------------------------------------------
5088 \fn sme_RoamGetNumBKIDCache
5089 \brief The SME API exposed to HDD to allow HDD to request SME to return the
5090 number of BKID cache entries.
5091 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
5092 it is opened (by calling halOpen).
5093 \return tANI_U32 - the number of BKID cache entries.
5094 ---------------------------------------------------------------------------*/
5095tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
5096{
5097 eHalStatus status = eHAL_STATUS_FAILURE;
5098 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5099 tANI_U32 numBkidCache = 0;
5100
5101 status = sme_AcquireGlobalLock( &pMac->sme );
5102 if ( HAL_STATUS_SUCCESS( status ) )
5103 {
5104 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
5105 sme_ReleaseGlobalLock( &pMac->sme );
5106 }
5107
5108 return (numBkidCache);
5109}
5110
5111/* ---------------------------------------------------------------------------
5112 \fn sme_ScanGetBKIDCandidateList
5113 \brief a wrapper function to return the BKID candidate list
5114 \param pBkidList - caller allocated buffer point to an array of
5115 tBkidCandidateInfo
5116 \param pNumItems - pointer to a variable that has the number of
5117 tBkidCandidateInfo allocated when retruning, this is
5118 either the number needed or number of items put into
5119 pPmkidList
5120 \return eHalStatus - when fail, it usually means the buffer allocated is not
5121 big enough and pNumItems
5122 has the number of tBkidCandidateInfo.
5123 \Note: pNumItems is a number of tBkidCandidateInfo,
5124 not sizeof(tBkidCandidateInfo) * something
5125 ---------------------------------------------------------------------------*/
5126eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
5127 tBkidCandidateInfo *pBkidList,
5128 tANI_U32 *pNumItems )
5129{
5130 eHalStatus status = eHAL_STATUS_FAILURE;
5131 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5132
5133 status = sme_AcquireGlobalLock( &pMac->sme );
5134 if ( HAL_STATUS_SUCCESS( status ) )
5135 {
5136 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
5137 sme_ReleaseGlobalLock( &pMac->sme );
5138 }
5139
5140 return (status);
5141}
5142#endif /* FEATURE_WLAN_WAPI */
5143
Jeff Johnsone7245742012-09-05 17:12:55 -07005144#ifdef FEATURE_OEM_DATA_SUPPORT
5145
5146/*****************************************************************************
5147 OEM DATA related modifications and function additions
5148 *****************************************************************************/
5149
5150/* ---------------------------------------------------------------------------
5151 \fn sme_getOemDataRsp
5152 \brief a wrapper function to obtain the OEM DATA RSP
5153 \param pOemDataRsp - A pointer to the response object
5154 \param pContext - a pointer passed in for the callback
5155 \return eHalStatus
5156 ---------------------------------------------------------------------------*/
5157eHalStatus sme_getOemDataRsp(tHalHandle hHal,
5158 tOemDataRsp **pOemDataRsp)
5159{
5160 eHalStatus status = eHAL_STATUS_SUCCESS;
5161 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5162
5163 do
5164 {
5165 //acquire the lock for the sme object
5166 status = sme_AcquireGlobalLock(&pMac->sme);
5167
5168 if(!HAL_STATUS_SUCCESS(status))
5169 {
5170 break;
5171 }
5172
5173 if(pMac->oemData.pOemDataRsp != NULL)
5174 {
5175 *pOemDataRsp = pMac->oemData.pOemDataRsp;
5176 }
5177 else
5178 {
5179 status = eHAL_STATUS_FAILURE;
5180 }
5181
5182 //release the lock for the sme object
5183 sme_ReleaseGlobalLock( &pMac->sme );
5184
5185 } while(0);
5186
5187 return status;
5188}
5189
5190/* ---------------------------------------------------------------------------
5191 \fn sme_OemDataReq
5192 \brief a wrapper function for OEM DATA REQ
5193 \param sessionId - session id to be used.
5194 \param pOemDataReqId - pointer to an object to get back the request ID
5195 \param callback - a callback function that is called upon finish
5196 \param pContext - a pointer passed in for the callback
5197 \return eHalStatus
5198 ---------------------------------------------------------------------------*/
5199eHalStatus sme_OemDataReq(tHalHandle hHal,
5200 tANI_U8 sessionId,
5201 tOemDataReqConfig *pOemDataReqConfig,
5202 tANI_U32 *pOemDataReqID,
5203 oemData_OemDataReqCompleteCallback callback,
5204 void *pContext)
5205{
5206 eHalStatus status = eHAL_STATUS_SUCCESS;
5207 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5208
5209 do
5210 {
5211 //acquire the lock for the sme object
5212 status = sme_AcquireGlobalLock(&pMac->sme);
5213 if(HAL_STATUS_SUCCESS(status))
5214 {
5215 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
5216
5217 if(pOemDataReqID)
5218 {
5219 *pOemDataReqID = lOemDataReqId;
5220 }
5221 else
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08005222 {
5223 sme_ReleaseGlobalLock( &pMac->sme );
5224 return eHAL_STATUS_FAILURE;
5225 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005226
5227 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
5228
5229 //release the lock for the sme object
5230 sme_ReleaseGlobalLock( &pMac->sme );
5231 }
5232 } while(0);
5233
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005234 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07005235
5236 return(status);
5237}
5238
5239#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005240
5241/*--------------------------------------------------------------------------
5242
5243 \brief sme_OpenSession() - Open a session for scan/roam operation.
5244
5245 This is a synchronous API.
5246
5247
5248 \param hHal - The handle returned by macOpen.
5249 \param callback - A pointer to the function caller specifies for roam/connect status indication
5250 \param pContext - The context passed with callback
5251 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
5252 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
5253
5254 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
5255
5256 Other status means SME is failed to open the session.
5257 eHAL_STATUS_RESOURCES - no more session available.
5258 \sa
5259
5260 --------------------------------------------------------------------------*/
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005261eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback,
5262 void *pContext, tANI_U8 *pSelfMacAddr,
5263 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005264{
5265 eHalStatus status;
5266 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5267
5268 if( NULL == pbSessionId )
5269 {
5270 status = eHAL_STATUS_INVALID_PARAMETER;
5271 }
5272 else
5273 {
5274 status = sme_AcquireGlobalLock( &pMac->sme );
5275 if ( HAL_STATUS_SUCCESS( status ) )
5276 {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005277 status = csrRoamOpenSession(pMac, callback, pContext,
5278 pSelfMacAddr, pbSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005279
5280 sme_ReleaseGlobalLock( &pMac->sme );
5281 }
5282 }
5283
5284 return ( status );
5285}
5286
5287
5288/*--------------------------------------------------------------------------
5289
5290 \brief sme_CloseSession() - Open a session for scan/roam operation.
5291
5292 This is a synchronous API.
5293
5294
5295 \param hHal - The handle returned by macOpen.
5296
5297 \param sessionId - A previous opened session's ID.
5298
5299 \return eHAL_STATUS_SUCCESS - session is closed.
5300
5301 Other status means SME is failed to open the session.
5302 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
5303 \sa
5304
5305 --------------------------------------------------------------------------*/
5306eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
5307 csrRoamSessionCloseCallback callback, void *pContext)
5308{
5309 eHalStatus status;
5310 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5311
5312 status = sme_AcquireGlobalLock( &pMac->sme );
5313 if ( HAL_STATUS_SUCCESS( status ) )
5314 {
5315 status = csrRoamCloseSession( pMac, sessionId, FALSE,
5316 callback, pContext );
5317
5318 sme_ReleaseGlobalLock( &pMac->sme );
5319 }
5320
5321 return ( status );
5322}
5323
Jeff Johnson295189b2012-06-20 16:38:30 -07005324/* ---------------------------------------------------------------------------
5325
5326 \fn sme_RoamUpdateAPWPSIE
5327
5328 \brief To update AP's WPS IE. This function should be called after SME AP session is created
5329 This is an asynchronous API.
5330
5331 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
5332
5333 \return eHalStatus – SUCCESS –
5334
5335 FAILURE or RESOURCES – The API finished and failed.
5336
5337 -------------------------------------------------------------------------------*/
5338eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
5339{
5340
5341 eHalStatus status = eHAL_STATUS_FAILURE;
5342 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5343
5344 status = sme_AcquireGlobalLock( &pMac->sme );
5345 if ( HAL_STATUS_SUCCESS( status ) )
5346 {
5347
5348 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
5349
5350 sme_ReleaseGlobalLock( &pMac->sme );
5351 }
5352
5353 return (status);
5354}
5355/* ---------------------------------------------------------------------------
5356
5357 \fn sme_RoamUpdateAPWPARSNIEs
5358
5359 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
5360 This is an asynchronous API.
5361
5362 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
5363
5364 \return eHalStatus – SUCCESS –
5365
5366 FAILURE or RESOURCES – The API finished and failed.
5367
5368 -------------------------------------------------------------------------------*/
5369eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
5370{
5371
5372 eHalStatus status = eHAL_STATUS_FAILURE;
5373 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5374
5375 status = sme_AcquireGlobalLock( &pMac->sme );
5376 if ( HAL_STATUS_SUCCESS( status ) )
5377 {
5378
5379 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
5380
5381 sme_ReleaseGlobalLock( &pMac->sme );
5382 }
5383
5384 return (status);
5385}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005386/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07005387
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005388 \fn sme_ChangeMCCBeaconInterval
5389
5390 \brief To update P2P-GO beaconInterval. This function should be called after
5391 disassociating all the station is done
5392 This is an asynchronous API.
5393
5394 \param
5395
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005396 \return eHalStatus SUCCESS
5397 FAILURE or RESOURCES
5398 The API finished and failed.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005399
5400 -------------------------------------------------------------------------------*/
5401eHalStatus sme_ChangeMCCBeaconInterval(tHalHandle hHal, tANI_U8 sessionId)
5402{
5403 eHalStatus status = eHAL_STATUS_FAILURE;
5404 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5405
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005406 smsLog(pMac, LOG1, FL("Update Beacon PARAMS "));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005407 status = sme_AcquireGlobalLock( &pMac->sme );
5408 if ( HAL_STATUS_SUCCESS( status ) )
5409 {
5410 status = csrSendChngMCCBeaconInterval( pMac, sessionId);
5411 sme_ReleaseGlobalLock( &pMac->sme );
5412 }
5413 return (status);
5414}
Jeff Johnson295189b2012-06-20 16:38:30 -07005415
5416/*-------------------------------------------------------------------------------*
5417
5418 \fn sme_sendBTAmpEvent
5419
5420 \brief to receive the coex priorty request from BT-AMP PAL
5421 and send the BT_AMP link state to HAL
5422
5423 \param btAmpEvent - btAmpEvent
5424
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005425 \return eHalStatus: SUCCESS : BTAmp event successfully sent to HAL
Jeff Johnson295189b2012-06-20 16:38:30 -07005426
5427 FAILURE: API failed
5428
5429-------------------------------------------------------------------------------*/
5430
5431eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
5432{
5433 vos_msg_t msg;
5434 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
5435 eHalStatus status = eHAL_STATUS_FAILURE;
5436
5437 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tpSmeBtAmpEvent));
5438 if (NULL == ptrSmeBtAmpEvent)
5439 {
5440 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005441 "Not able to allocate memory for BTAmp event", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 return status;
5443 }
5444
5445 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
5446 msg.type = WDA_SIGNAL_BTAMP_EVENT;
5447 msg.reserved = 0;
5448 msg.bodyptr = ptrSmeBtAmpEvent;
5449
5450 //status = halFW_SendBTAmpEventMesg(pMac, event);
5451
5452 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5453 {
5454 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005455 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005456 vos_mem_free(ptrSmeBtAmpEvent);
5457 return status;
5458 }
5459
5460 return eHAL_STATUS_SUCCESS;
5461
5462}
5463
5464/* ---------------------------------------------------------------------------
5465 \fn sme_SetHostOffload
5466 \brief API to set the host offload feature.
5467 \param hHal - The handle returned by macOpen.
5468 \param pRequest - Pointer to the offload request.
5469 \return eHalStatus
5470 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005471eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
5472 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005473{
5474 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07005475 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005476
5477 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5478 {
5479#ifdef WLAN_NS_OFFLOAD
5480 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
5481 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005482 status = pmcSetNSOffload( hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 }
5484 else
5485#endif //WLAN_NS_OFFLOAD
5486 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005487 status = pmcSetHostOffload (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 }
5489 sme_ReleaseGlobalLock( &pMac->sme );
5490 }
5491
5492 return (status);
5493}
5494
5495#ifdef WLAN_FEATURE_GTK_OFFLOAD
5496/* ---------------------------------------------------------------------------
5497 \fn sme_SetGTKOffload
5498 \brief API to set GTK offload information.
5499 \param hHal - The handle returned by macOpen.
5500 \param pRequest - Pointer to the GTK offload request.
5501 \return eHalStatus
5502 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005503eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest,
5504 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005505{
5506 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5507 eHalStatus status;
5508
5509 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5510 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005511 status = pmcSetGTKOffload( hHal, pRequest, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 sme_ReleaseGlobalLock( &pMac->sme );
5513 }
5514
5515 return (status);
5516}
5517
5518/* ---------------------------------------------------------------------------
5519 \fn sme_GetGTKOffload
5520 \brief API to get GTK offload information.
5521 \param hHal - The handle returned by macOpen.
5522 \param pRequest - Pointer to the GTK offload response.
5523 \return eHalStatus
5524 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005525eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
5526 void *callbackContext, tANI_U8 sessionId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005527{
5528 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5529 eHalStatus status;
5530
5531 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5532 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005533 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 sme_ReleaseGlobalLock( &pMac->sme );
5535 }
5536
5537 return (status);
5538}
5539#endif // WLAN_FEATURE_GTK_OFFLOAD
5540
5541/* ---------------------------------------------------------------------------
5542 \fn sme_SetKeepAlive
5543 \brief API to set the Keep Alive feature.
5544 \param hHal - The handle returned by macOpen.
5545 \param pRequest - Pointer to the Keep Alive request.
5546 \return eHalStatus
5547 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005548eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
5549 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005550{
5551 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5552 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5554 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005555 status = pmcSetKeepAlive (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 sme_ReleaseGlobalLock( &pMac->sme );
5557 }
5558
5559 return (status);
5560}
5561
5562#ifdef FEATURE_WLAN_SCAN_PNO
5563/* ---------------------------------------------------------------------------
5564 \fn sme_SetPreferredNetworkList
5565 \brief API to set the Preferred Network List Offload feature.
5566 \param hHal - The handle returned by macOpen.
5567 \param pRequest - Pointer to the offload request.
5568 \return eHalStatus
5569 ---------------------------------------------------------------------------*/
5570eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
5571{
5572 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5573 eHalStatus status;
5574
5575 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5576 {
5577 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
5578 sme_ReleaseGlobalLock( &pMac->sme );
5579 }
5580
5581 return (status);
5582}
5583
5584eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
5585{
5586 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5587 eHalStatus status;
5588
5589 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5590 {
5591 pmcSetRssiFilter(hHal, rssiThreshold);
5592 sme_ReleaseGlobalLock( &pMac->sme );
5593 }
5594
5595 return (status);
5596}
5597
5598#endif // FEATURE_WLAN_SCAN_PNO
5599
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005600eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams, tANI_BOOLEAN forced)
Jeff Johnson295189b2012-06-20 16:38:30 -07005601{
5602 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5603 eHalStatus status;
5604
5605 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5606 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005607 pmcSetPowerParams(hHal, pwParams, forced);
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 sme_ReleaseGlobalLock( &pMac->sme );
5609 }
5610
5611 return (status);
5612}
5613
5614/* ---------------------------------------------------------------------------
5615 \fn sme_AbortMacScan
5616 \brief API to cancel MAC scan.
5617 \param hHal - The handle returned by macOpen.
5618 \return VOS_STATUS
5619 VOS_STATUS_E_FAILURE - failure
5620 VOS_STATUS_SUCCESS success
5621 ---------------------------------------------------------------------------*/
5622eHalStatus sme_AbortMacScan(tHalHandle hHal)
5623{
5624 eHalStatus status;
5625 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5626
5627 status = sme_AcquireGlobalLock( &pMac->sme );
5628 if ( HAL_STATUS_SUCCESS( status ) )
5629 {
5630 status = csrScanAbortMacScan(pMac);
5631
5632 sme_ReleaseGlobalLock( &pMac->sme );
5633 }
5634
5635 return ( status );
5636}
5637
5638/* ----------------------------------------------------------------------------
5639 \fn sme_GetOperationChannel
5640 \brief API to get current channel on which STA is parked
5641 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005642 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 \returns eHAL_STATUS_SUCCESS
5644 eHAL_STATUS_FAILURE
5645-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005646eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005647{
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5649 tCsrRoamSession *pSession;
5650
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005651 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005653 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005654
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005655 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
5656 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005657 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005658 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
5659 {
5660 *pChannel =pSession->connectedProfile.operationChannel;
5661 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 }
5663 }
5664 return eHAL_STATUS_FAILURE;
5665}// sme_GetOperationChannel ends here
5666
Jeff Johnson295189b2012-06-20 16:38:30 -07005667/* ---------------------------------------------------------------------------
5668
5669 \fn sme_RegisterMgtFrame
5670
5671 \brief To register managment frame of specified type and subtype.
5672 \param frameType - type of the frame that needs to be passed to HDD.
5673 \param matchData - data which needs to be matched before passing frame
5674 to HDD.
5675 \param matchDataLen - Length of matched data.
5676 \return eHalStatus
5677 -------------------------------------------------------------------------------*/
5678eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5679 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5680{
5681 eHalStatus status = eHAL_STATUS_SUCCESS;
5682 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5683
5684 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5685 {
5686 tSirRegisterMgmtFrame *pMsg;
5687 tANI_U16 len;
5688 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005689
5690 if(!pSession)
5691 {
5692 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08005693 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005694 return eHAL_STATUS_FAILURE;
5695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005696
5697 if( !pSession->sessionActive )
5698 {
5699 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005700 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 sme_ReleaseGlobalLock( &pMac->sme );
5702 return eHAL_STATUS_FAILURE;
5703 }
5704
5705 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5706
5707 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5708 if(HAL_STATUS_SUCCESS(status))
5709 {
5710 palZeroMemory(pMac->hHdd, pMsg, len);
5711 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5712 pMsg->length = len;
5713 pMsg->sessionId = sessionId;
5714 pMsg->registerFrame = VOS_TRUE;
5715 pMsg->frameType = frameType;
5716 pMsg->matchLen = matchLen;
5717 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5718 status = palSendMBMessage(pMac->hHdd, pMsg);
5719 }
5720 sme_ReleaseGlobalLock( &pMac->sme );
5721 }
5722 return status;
5723}
5724
5725/* ---------------------------------------------------------------------------
5726
5727 \fn sme_DeregisterMgtFrame
5728
5729 \brief To De-register managment frame of specified type and subtype.
5730 \param frameType - type of the frame that needs to be passed to HDD.
5731 \param matchData - data which needs to be matched before passing frame
5732 to HDD.
5733 \param matchDataLen - Length of matched data.
5734 \return eHalStatus
5735 -------------------------------------------------------------------------------*/
5736eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5737 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5738{
5739 eHalStatus status = eHAL_STATUS_SUCCESS;
5740 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5741
5742 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5743 {
5744 tSirRegisterMgmtFrame *pMsg;
5745 tANI_U16 len;
5746 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005747
5748 if(!pSession)
5749 {
5750 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08005751 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005752 return eHAL_STATUS_FAILURE;
5753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005754
5755 if( !pSession->sessionActive )
5756 {
5757 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005758 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 sme_ReleaseGlobalLock( &pMac->sme );
5760 return eHAL_STATUS_FAILURE;
5761 }
5762
5763 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5764
5765 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5766 if(HAL_STATUS_SUCCESS(status))
5767 {
5768 palZeroMemory(pMac->hHdd, pMsg, len);
5769 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5770 pMsg->length = len;
5771 pMsg->registerFrame = VOS_FALSE;
5772 pMsg->frameType = frameType;
5773 pMsg->matchLen = matchLen;
5774 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5775 status = palSendMBMessage(pMac->hHdd, pMsg);
5776 }
5777 sme_ReleaseGlobalLock( &pMac->sme );
5778 }
5779 return status;
5780}
5781
5782/* ---------------------------------------------------------------------------
5783 \fn sme_RemainOnChannel
5784 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
5785 \param hHal - The handle returned by macOpen.
5786 \param pRequest - channel
5787 \param duration - duration in ms
5788 \param callback - HDD registered callback to process reaminOnChannelRsp
5789 \param context - HDD Callback param
5790 \return eHalStatus
5791 ---------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005792eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
5793 tANI_U8 channel, tANI_U32 duration,
Gopichand Nakkala924e4552013-05-08 19:18:14 +05305794 remainOnChanCallback callback,
5795 void *pContext,
5796 tANI_U8 isP2PProbeReqAllowed)
Jeff Johnson295189b2012-06-20 16:38:30 -07005797{
5798 eHalStatus status = eHAL_STATUS_SUCCESS;
5799 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5800
5801 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5802 {
Gopichand Nakkala924e4552013-05-08 19:18:14 +05305803 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext,
5804 isP2PProbeReqAllowed
Jeff Johnson295189b2012-06-20 16:38:30 -07005805#ifdef WLAN_FEATURE_P2P_INTERNAL
5806 , eP2PRemainOnChnReasonUnknown
5807#endif
5808 );
5809 sme_ReleaseGlobalLock( &pMac->sme );
5810 }
5811 return(status);
5812}
5813
5814/* ---------------------------------------------------------------------------
5815 \fn sme_ReportProbeReq
5816 \brief API to enable/disable forwarding of probeReq to apps in p2p.
5817 \param hHal - The handle returned by macOpen.
5818 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
5819 \return eHalStatus
5820 ---------------------------------------------------------------------------*/
5821
5822#ifndef WLAN_FEATURE_CONCURRENT_P2P
5823eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
5824{
5825 eHalStatus status = eHAL_STATUS_SUCCESS;
5826 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5827
5828 do
5829 {
5830 //acquire the lock for the sme object
5831 status = sme_AcquireGlobalLock(&pMac->sme);
5832 if(HAL_STATUS_SUCCESS(status))
5833 {
5834 /* call set in context */
5835 pMac->p2pContext.probeReqForwarding = flag;
5836 //release the lock for the sme object
5837 sme_ReleaseGlobalLock( &pMac->sme );
5838 }
5839 } while(0);
5840
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005841 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005842
5843 return(status);
5844}
5845
5846/* ---------------------------------------------------------------------------
5847 \fn sme_updateP2pIe
5848 \brief API to set the P2p Ie in p2p context
5849 \param hHal - The handle returned by macOpen.
5850 \param p2pIe - Ptr to p2pIe from HDD.
5851 \param p2pIeLength: length of p2pIe
5852 \return eHalStatus
5853 ---------------------------------------------------------------------------*/
5854
5855eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
5856{
5857 eHalStatus status = eHAL_STATUS_SUCCESS;
5858 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5859
5860 //acquire the lock for the sme object
5861 status = sme_AcquireGlobalLock(&pMac->sme);
5862 if(HAL_STATUS_SUCCESS(status))
5863 {
5864 if(NULL != pMac->p2pContext.probeRspIe){
5865 vos_mem_free(pMac->p2pContext.probeRspIe);
5866 pMac->p2pContext.probeRspIeLength = 0;
5867 }
5868
5869 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
5870 if (NULL == pMac->p2pContext.probeRspIe)
5871 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005872 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 pMac->p2pContext.probeRspIeLength = 0;
5874 status = eHAL_STATUS_FAILURE;
5875 }
5876 else
5877 {
5878 pMac->p2pContext.probeRspIeLength = p2pIeLength;
5879
5880 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
5881 pMac->p2pContext.probeRspIe,
5882 pMac->p2pContext.probeRspIeLength );
5883 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
5884 p2pIeLength);
5885 }
5886
5887 //release the lock for the sme object
5888 sme_ReleaseGlobalLock( &pMac->sme );
5889 }
5890
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005891 smsLog(pMac, LOG2, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005892
5893 return(status);
5894}
5895#endif
5896
5897/* ---------------------------------------------------------------------------
5898 \fn sme_sendAction
5899 \brief API to send action frame from supplicant.
5900 \param hHal - The handle returned by macOpen.
5901 \return eHalStatus
5902 ---------------------------------------------------------------------------*/
5903
5904eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07005905 const tANI_U8 *pBuf, tANI_U32 len,
5906 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07005907{
5908 eHalStatus status = eHAL_STATUS_SUCCESS;
5909 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5910
5911 //acquire the lock for the sme object
5912 status = sme_AcquireGlobalLock(&pMac->sme);
5913 if(HAL_STATUS_SUCCESS(status))
5914 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005915 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 //release the lock for the sme object
5917 sme_ReleaseGlobalLock( &pMac->sme );
5918 }
5919
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005920 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005921
5922 return(status);
5923}
5924
5925eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
5926{
5927 eHalStatus status = eHAL_STATUS_SUCCESS;
5928 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5929
5930 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5931 {
5932 status = p2pCancelRemainOnChannel (hHal, sessionId);
5933 sme_ReleaseGlobalLock( &pMac->sme );
5934 }
5935 return(status);
5936}
5937
5938//Power Save Related
5939eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
5940{
5941 eHalStatus status = eHAL_STATUS_SUCCESS;
5942 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5943
5944 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5945 {
5946 status = p2pSetPs (hHal, data);
5947 sme_ReleaseGlobalLock( &pMac->sme );
5948 }
5949 return(status);
5950}
5951
Jeff Johnson295189b2012-06-20 16:38:30 -07005952
5953/* ---------------------------------------------------------------------------
5954
5955 \fn sme_ConfigureRxpFilter
5956
5957 \brief
5958 SME will pass this request to lower mac to set/reset the filter on RXP for
5959 multicast & broadcast traffic.
5960
5961 \param
5962
5963 hHal - The handle returned by macOpen.
5964
5965 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
5966 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
5967 on this param. In future we can use this as a mask to set various types of
5968 filters as suggested below:
5969 FILTER_ALL_MULTICAST:
5970 FILTER_ALL_BROADCAST:
5971 FILTER_ALL_MULTICAST_BROADCAST:
5972
5973
5974 \return eHalStatus
5975
5976
5977--------------------------------------------------------------------------- */
5978eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
5979 tpSirWlanSetRxpFilters wlanRxpFilterParam)
5980{
5981 eHalStatus status = eHAL_STATUS_SUCCESS;
5982 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5983 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5984 vos_msg_t vosMessage;
5985
5986 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5987 {
5988 /* serialize the req through MC thread */
5989 vosMessage.bodyptr = wlanRxpFilterParam;
5990 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
5991 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5992 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5993 {
5994 status = eHAL_STATUS_FAILURE;
5995 }
5996 sme_ReleaseGlobalLock( &pMac->sme );
5997 }
5998 return(status);
5999}
6000
Jeff Johnson295189b2012-06-20 16:38:30 -07006001/* ---------------------------------------------------------------------------
6002
6003 \fn sme_ConfigureSuspendInd
6004
6005 \brief
6006 SME will pass this request to lower mac to Indicate that the wlan needs to
6007 be suspended
6008
6009 \param
6010
6011 hHal - The handle returned by macOpen.
6012
6013 wlanSuspendParam- Depicts the wlan suspend params
6014
6015
6016 \return eHalStatus
6017
6018
6019--------------------------------------------------------------------------- */
6020eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
6021 tpSirWlanSuspendParam wlanSuspendParam)
6022{
6023 eHalStatus status = eHAL_STATUS_SUCCESS;
6024 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6025 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6026 vos_msg_t vosMessage;
6027
6028 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6029 {
6030 /* serialize the req through MC thread */
6031 vosMessage.bodyptr = wlanSuspendParam;
6032 vosMessage.type = WDA_WLAN_SUSPEND_IND;
6033 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6034 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6035 {
6036 status = eHAL_STATUS_FAILURE;
6037 }
6038 sme_ReleaseGlobalLock( &pMac->sme );
6039 }
6040 return(status);
6041}
6042
6043/* ---------------------------------------------------------------------------
6044
6045 \fn sme_ConfigureResumeReq
6046
6047 \brief
6048 SME will pass this request to lower mac to Indicate that the wlan needs to
6049 be Resumed
6050
6051 \param
6052
6053 hHal - The handle returned by macOpen.
6054
6055 wlanResumeParam- Depicts the wlan resume params
6056
6057
6058 \return eHalStatus
6059
6060
6061--------------------------------------------------------------------------- */
6062eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
6063 tpSirWlanResumeParam wlanResumeParam)
6064{
6065 eHalStatus status = eHAL_STATUS_SUCCESS;
6066 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6067 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6068 vos_msg_t vosMessage;
6069
6070 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6071 {
6072 /* serialize the req through MC thread */
6073 vosMessage.bodyptr = wlanResumeParam;
6074 vosMessage.type = WDA_WLAN_RESUME_REQ;
6075 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6076 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6077 {
6078 status = eHAL_STATUS_FAILURE;
6079 }
6080 sme_ReleaseGlobalLock( &pMac->sme );
6081 }
6082 return(status);
6083}
6084
Jeff Johnson295189b2012-06-20 16:38:30 -07006085/* ---------------------------------------------------------------------------
6086
6087 \fn sme_GetInfraSessionId
6088
6089 \brief To get the session ID for infra session, if connected
6090 This is a synchronous API.
6091
6092 \param hHal - The handle returned by macOpen.
6093
6094 \return sessionid, -1 if infra session is not connected
6095
6096 -------------------------------------------------------------------------------*/
6097tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
6098{
6099 eHalStatus status = eHAL_STATUS_FAILURE;
6100 tANI_S8 sessionid = -1;
6101 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6102
6103 status = sme_AcquireGlobalLock( &pMac->sme );
6104 if ( HAL_STATUS_SUCCESS( status ) )
6105 {
6106
6107 sessionid = csrGetInfraSessionId( pMac);
6108
6109 sme_ReleaseGlobalLock( &pMac->sme );
6110 }
6111
6112 return (sessionid);
6113}
6114
6115/* ---------------------------------------------------------------------------
6116
6117 \fn sme_GetInfraOperationChannel
6118
6119 \brief To get the operating channel for infra session, if connected
6120 This is a synchronous API.
6121
6122 \param hHal - The handle returned by macOpen.
6123 \param sessionId - the sessionId returned by sme_OpenSession.
6124
6125 \return operating channel, 0 if infra session is not connected
6126
6127 -------------------------------------------------------------------------------*/
6128tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
6129{
6130 eHalStatus status = eHAL_STATUS_FAILURE;
6131 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6132 tANI_U8 channel = 0;
6133 status = sme_AcquireGlobalLock( &pMac->sme );
6134 if ( HAL_STATUS_SUCCESS( status ) )
6135 {
6136
6137 channel = csrGetInfraOperationChannel( pMac, sessionId);
6138
6139 sme_ReleaseGlobalLock( &pMac->sme );
6140 }
6141
6142 return (channel);
6143}
6144
6145//This routine will return poerating channel on which other BSS is operating to be used for concurrency mode.
6146//If other BSS is not up or not connected it will return 0
6147tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
6148{
6149 eHalStatus status = eHAL_STATUS_FAILURE;
6150 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6151 tANI_U8 channel = 0;
6152 status = sme_AcquireGlobalLock( &pMac->sme );
6153 if ( HAL_STATUS_SUCCESS( status ) )
6154 {
6155
6156 channel = csrGetConcurrentOperationChannel( pMac );
6157 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006158 " Other Concurrent Channel = %d", __func__,channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 sme_ReleaseGlobalLock( &pMac->sme );
6160 }
6161
6162 return (channel);
6163}
6164
6165#ifdef FEATURE_WLAN_SCAN_PNO
6166/******************************************************************************
6167*
6168* Name: sme_PreferredNetworkFoundInd
6169*
6170* Description:
6171* Invoke Preferred Network Found Indication
6172*
6173* Parameters:
6174* hHal - HAL handle for device
6175* pMsg - found network description
6176*
6177* Returns: eHalStatus
6178*
6179******************************************************************************/
6180eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
6181{
6182 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6183 eHalStatus status = eHAL_STATUS_SUCCESS;
6184 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
Srikant Kuppa066904f2013-05-07 13:56:02 -07006185 v_U8_t dumpSsId[SIR_MAC_MAX_SSID_LENGTH + 1];
6186 tANI_U8 ssIdLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006187
6188 if (NULL == pMsg)
6189 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006190 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 status = eHAL_STATUS_FAILURE;
6192 }
6193 else
6194 {
6195 if (pPrefNetworkFoundInd->ssId.length > 0)
6196 {
Srikant Kuppa066904f2013-05-07 13:56:02 -07006197 ssIdLength = CSR_MIN(SIR_MAC_MAX_SSID_LENGTH,
6198 pPrefNetworkFoundInd->ssId.length);
6199 vos_mem_copy(dumpSsId, pPrefNetworkFoundInd->ssId.ssId, ssIdLength);
6200 dumpSsId[ssIdLength] = 0;
6201 smsLog(pMac, LOG2, "%s:SSID=%s frame length %d",
6202 __func__, dumpSsId, pPrefNetworkFoundInd->frameLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006203
Srikant Kuppa066904f2013-05-07 13:56:02 -07006204 //Save the frame to scan result
6205 if (pPrefNetworkFoundInd->mesgLen > sizeof(tSirPrefNetworkFoundInd))
6206 {
6207 //we may have a frame
6208 status = csrScanSavePreferredNetworkFound(pMac,
6209 pPrefNetworkFoundInd);
6210 if (!HAL_STATUS_SUCCESS(status))
6211 {
6212 smsLog(pMac, LOGE, FL(" fail to save preferred network"));
6213 }
6214 }
6215 else
6216 {
6217 smsLog(pMac, LOGE, FL(" not enough data length %d needed %d"),
6218 pPrefNetworkFoundInd->mesgLen, sizeof(tSirPrefNetworkFoundInd));
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 }
6220
Srikant Kuppa066904f2013-05-07 13:56:02 -07006221 /* Call Preferred Netowrk Found Indication callback routine. */
6222 if (HAL_STATUS_SUCCESS(status) && (pMac->pmc.prefNetwFoundCB != NULL))
6223 {
6224 pMac->pmc.prefNetwFoundCB(
6225 pMac->pmc.preferredNetworkFoundIndCallbackContext,
6226 pPrefNetworkFoundInd);
6227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 }
6229 else
6230 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006231 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 status = eHAL_STATUS_FAILURE;
6233 }
6234 }
6235
6236
6237 return(status);
6238}
6239
6240#endif // FEATURE_WLAN_SCAN_PNO
6241
6242
6243eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
6244{
6245 eHalStatus status = eHAL_STATUS_FAILURE;
6246 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6247
6248 status = sme_AcquireGlobalLock( &pMac->sme );
6249 if ( HAL_STATUS_SUCCESS( status ) )
6250 {
6251 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
6252 sme_ReleaseGlobalLock( &pMac->sme );
6253 }
6254
6255 return (status);
6256}
6257
6258
6259/* ---------------------------------------------------------------------------
6260
6261 \fn sme_SetTxPerTracking
6262
6263 \brief Set Tx PER tracking configuration parameters
6264
6265 \param hHal - The handle returned by macOpen.
6266 \param pTxPerTrackingConf - Tx PER configuration parameters
6267
6268 \return eHalStatus
6269
6270 -------------------------------------------------------------------------------*/
6271eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
6272 void (*pCallbackfn) (void *pCallbackContext),
6273 void *pCallbackContext,
6274 tpSirTxPerTrackingParam pTxPerTrackingParam)
6275{
6276 vos_msg_t msg;
6277 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
6278 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6279
6280 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6281 {
6282 pMac->sme.pTxPerHitCallback = pCallbackfn;
6283 pMac->sme.pTxPerHitCbContext = pCallbackContext;
6284 sme_ReleaseGlobalLock( &pMac->sme );
6285 }
6286
6287 // free this memory in failure case or WDA request callback function
6288 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
6289 if (NULL == pTxPerTrackingParamReq)
6290 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006291 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 -07006292 return eHAL_STATUS_FAILURE;
6293 }
6294
6295 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam, sizeof(tSirTxPerTrackingParam));
6296 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
6297 msg.reserved = 0;
6298 msg.bodyptr = pTxPerTrackingParamReq;
6299
6300 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6301 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006302 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 -07006303 vos_mem_free(pTxPerTrackingParamReq);
6304 return eHAL_STATUS_FAILURE;
6305 }
6306
6307 return eHAL_STATUS_SUCCESS;
6308}
6309
6310/* ---------------------------------------------------------------------------
6311
6312 \fn sme_HandleChangeCountryCode
6313
6314 \brief Change Country code, Reg Domain and channel list
6315
6316 \details Country Code Priority
6317 0 = 11D > Configured Country > NV
6318 1 = Configured Country > 11D > NV
6319 If Supplicant country code is priority than 11d is disabled.
6320 If 11D is enabled, we update the country code after every scan.
6321 Hence when Supplicant country code is priority, we don't need 11D info.
6322 Country code from Supplicant is set as current courtry code.
6323 User can send reset command XX (instead of country code) to reset the
6324 country code to default values which is read from NV.
6325 In case of reset, 11D is enabled and default NV code is Set as current country code
6326 If 11D is priority,
6327 Than Supplicant country code code is set to default code. But 11D code is set as current country code
6328
6329 \param pMac - The handle returned by macOpen.
6330 \param pMsgBuf - MSG Buffer
6331
6332 \return eHalStatus
6333
6334 -------------------------------------------------------------------------------*/
6335eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
6336{
6337 eHalStatus status = eHAL_STATUS_SUCCESS;
6338 tAniChangeCountryCodeReq *pMsg;
6339 v_REGDOMAIN_t domainIdIoctl;
6340 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6341 static uNvTables nvTables;
6342 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
6343
6344
6345 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
6346 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
6347 {
6348 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6349
6350 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
6351
6352 /* read the country code from NV and use it */
6353 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
6354 {
6355 palCopyMemory( pMac->hHdd, pMsg->countryCode , nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
6356 }
6357 else
6358 {
6359 status = eHAL_STATUS_FAILURE;
6360 return status;
6361 }
6362 }
6363 else
6364 {
6365 /* if Supplicant country code has priority, disable 11d */
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05306366 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
6367 pMsg->countryFromUserSpace)
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 {
6369 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
6370 }
6371 }
6372
6373 /* WEXT set country code means
6374 * 11D should be supported?
6375 * 11D Channel should be enforced?
6376 * 11D Country code should be matched?
6377 * 11D Reg Domian should be matched?
6378 * Country string changed */
6379 if(pMac->roam.configParam.Is11dSupportEnabled &&
6380 pMac->roam.configParam.fEnforce11dChannels &&
6381 pMac->roam.configParam.fEnforceCountryCodeMatch &&
6382 pMac->roam.configParam.fEnforceDefaultDomain &&
6383 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
6384 {
6385 /* All 11D related options are already enabled
6386 * Country string is not changed
6387 * Do not need do anything for country code change request */
6388 return eHAL_STATUS_SUCCESS;
6389 }
6390
6391 /* Set Current Country code and Current Regulatory domain */
6392 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
6393 if(eHAL_STATUS_SUCCESS != status)
6394 {
6395 /* Supplicant country code failed. So give 11D priority */
6396 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6397 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
6398 return status;
6399 }
6400
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 /* overwrite the defualt country code */
6402 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault, pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
6403
6404 /* Get Domain ID from country code */
6405 status = csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent,(v_REGDOMAIN_t *) &domainIdIoctl );
6406 if ( status != eHAL_STATUS_SUCCESS )
6407 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006408 smsLog( pMac, LOGE, FL(" fail to get regId %d"), domainIdIoctl );
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 return status;
6410 }
6411
6412 status = WDA_SetRegDomain(pMac, domainIdIoctl);
6413
6414 if ( status != eHAL_STATUS_SUCCESS )
6415 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006416 smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainIdIoctl );
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 return status;
6418 }
6419
6420 /* set to default domain ID */
6421 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
6422
6423 /* get the channels based on new cc */
6424 status = csrInitGetChannels( pMac );
6425
6426 if ( status != eHAL_STATUS_SUCCESS )
6427 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006428 smsLog( pMac, LOGE, FL(" fail to get Channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 return status;
6430 }
6431
6432 /* reset info based on new cc, and we are done */
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08006433 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 if( pMsg->changeCCCallback )
6435 {
6436 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
6437 }
6438
6439 return eHAL_STATUS_SUCCESS;
6440}
6441
6442#ifdef WLAN_FEATURE_PACKET_FILTERING
Amar Singhalf3a6e762013-02-19 15:06:50 -08006443eHalStatus sme_8023MulticastList (tHalHandle hHal, tANI_U8 sessionId, tpSirRcvFltMcAddrList pMulticastAddrs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006444{
6445 tpSirRcvFltMcAddrList pRequestBuf;
6446 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006447 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnsone7245742012-09-05 17:12:55 -07006448 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006449
6450 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306451 "ulMulticastAddrCnt=%d, multicastAddr[0]=%p", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006452 pMulticastAddrs->ulMulticastAddrCnt,
6453 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07006454
6455 /*
6456 *Find the connected Infra / P2P_client connected session
Amar Singhalf3a6e762013-02-19 15:06:50 -08006457 */
6458 if (CSR_IS_SESSION_VALID(pMac, sessionId) &&
6459 csrIsConnStateInfra(pMac, sessionId))
6460 {
6461 pSession = CSR_GET_SESSION( pMac, sessionId );
6462 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006463
6464 if(pSession == NULL )
6465 {
6466 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Unable to find "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006467 "the right session", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07006468 return eHAL_STATUS_FAILURE;
6469 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006470
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6472 if (NULL == pRequestBuf)
6473 {
6474 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006475 "allocate memory for 8023 Multicast List request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006476 return eHAL_STATUS_FAILED_ALLOC;
6477 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006478
6479 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6480 {
6481 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
6482 "indication as we are not connected", __func__);
6483 vos_mem_free(pRequestBuf);
6484 return eHAL_STATUS_FAILURE;
6485 }
6486
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
6488
Jeff Johnsone7245742012-09-05 17:12:55 -07006489 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6490 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
6491 sizeof(tSirMacAddr));
6492
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 msg.type = WDA_8023_MULTICAST_LIST_REQ;
6494 msg.reserved = 0;
6495 msg.bodyptr = pRequestBuf;
6496 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6497 {
6498 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006499 "post WDA_8023_MULTICAST_LIST message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 vos_mem_free(pRequestBuf);
6501 return eHAL_STATUS_FAILURE;
6502 }
6503
6504 return eHAL_STATUS_SUCCESS;
6505}
6506
Jeff Johnsone7245742012-09-05 17:12:55 -07006507eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
6508 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006509{
6510 tpSirRcvPktFilterCfgType pRequestBuf;
6511 v_SINT_t allocSize;
6512 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006513 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6514 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 v_U8_t idx=0;
6516
6517 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006518 "filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006519 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
6520
Madan Mohan Koyyalamudid4029622012-10-18 20:30:17 -07006521 allocSize = sizeof(tSirRcvPktFilterCfgType);
6522
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 pRequestBuf = vos_mem_malloc(allocSize);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006524
6525 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 {
6527 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006528 "allocate memory for Receive Filter Set Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 return eHAL_STATUS_FAILED_ALLOC;
6530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006531
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006532 if( NULL == pSession )
6533 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006534 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Session Not found ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006535 vos_mem_free(pRequestBuf);
6536 return eHAL_STATUS_FAILURE;
6537 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006538
6539 vos_mem_copy( pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6540 vos_mem_copy( pRcvPktFilterCfg->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006541 sizeof(tSirMacAddr));
6542
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006543 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
6544
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
6546 msg.reserved = 0;
6547 msg.bodyptr = pRequestBuf;
6548
6549 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6550 "FT %d FID %d ",
6551 pRequestBuf->filterType, pRequestBuf->filterId);
6552
6553 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6554 "params %d CT %d",
6555 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
6556
6557 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
6558 {
6559
6560 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006561 "Proto %d Comp Flag %d ",
Jeff Johnson295189b2012-06-20 16:38:30 -07006562 pRequestBuf->paramsData[idx].protocolLayer,
6563 pRequestBuf->paramsData[idx].cmpFlag);
6564
6565 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006566 "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 pRequestBuf->paramsData[idx].dataOffset,
6568 pRequestBuf->paramsData[idx].dataLength);
6569
6570 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006571 "CData: %d:%d:%d:%d:%d:%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006572 pRequestBuf->paramsData[idx].compareData[0],
6573 pRequestBuf->paramsData[idx].compareData[1],
6574 pRequestBuf->paramsData[idx].compareData[2],
6575 pRequestBuf->paramsData[idx].compareData[3],
6576 pRequestBuf->paramsData[idx].compareData[4],
6577 pRequestBuf->paramsData[idx].compareData[5]);
6578
6579 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006580 "MData: %d:%d:%d:%d:%d:%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006581 pRequestBuf->paramsData[idx].dataMask[0],
6582 pRequestBuf->paramsData[idx].dataMask[1],
6583 pRequestBuf->paramsData[idx].dataMask[2],
6584 pRequestBuf->paramsData[idx].dataMask[3],
6585 pRequestBuf->paramsData[idx].dataMask[4],
6586 pRequestBuf->paramsData[idx].dataMask[5]);
6587
6588 }
6589
6590 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6591 {
6592 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006593 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 vos_mem_free(pRequestBuf);
6595 return eHAL_STATUS_FAILURE;
6596 }
6597
6598 return eHAL_STATUS_SUCCESS;
6599}
6600
6601eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
6602 FilterMatchCountCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006603 void *callbackContext,
6604 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006605{
6606 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6607 eHalStatus status;
6608
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006609 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006610
6611 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
6612 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006613 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 sme_ReleaseGlobalLock( &pMac->sme );
6615 }
6616
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006617 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006618
6619 return (status);
6620}
6621
Jeff Johnsone7245742012-09-05 17:12:55 -07006622eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
6623 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006624{
6625 tpSirRcvFltPktClearParam pRequestBuf;
6626 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006627 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6628 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006629
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006630 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 pRcvFltPktClearParam->filterId);
6632
6633 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006634 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 {
6636 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6637 "%s: Not able to allocate memory for Receive Filter "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006638 "Clear Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 return eHAL_STATUS_FAILED_ALLOC;
6640 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006641 if( NULL == pSession )
6642 {
6643 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006644 "%s: Session Not find ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006645 vos_mem_free(pRequestBuf);
6646 return eHAL_STATUS_FAILURE;
6647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006648
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006649 vos_mem_copy( pRcvFltPktClearParam->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6650 vos_mem_copy( pRcvFltPktClearParam->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006651 sizeof(tSirMacAddr));
6652
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006653 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
6654
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
6656 msg.reserved = 0;
6657 msg.bodyptr = pRequestBuf;
6658 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6659 {
6660 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006661 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 vos_mem_free(pRequestBuf);
6663 return eHAL_STATUS_FAILURE;
6664 }
6665
6666 return eHAL_STATUS_SUCCESS;
6667}
6668#endif // WLAN_FEATURE_PACKET_FILTERING
6669
6670/* ---------------------------------------------------------------------------
6671 \fn sme_PreChannelSwitchIndFullPowerCB
6672 \brief call back function for the PMC full power request because of pre
6673 channel switch.
6674 \param callbackContext
6675 \param status
6676 ---------------------------------------------------------------------------*/
6677void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
6678 eHalStatus status)
6679{
6680 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
6681 tSirMbMsg *pMsg;
6682 tANI_U16 msgLen;
6683
6684 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
6685 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
6686 if(HAL_STATUS_SUCCESS(status))
6687 {
6688 palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen);
6689 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
6690 pMsg->msgLen = pal_cpu_to_be16(msgLen);
6691 status = palSendMBMessage(pMac->hHdd, pMsg);
6692 }
6693
6694 return;
6695}
6696
6697/* ---------------------------------------------------------------------------
6698 \fn sme_HandlePreChannelSwitchInd
6699 \brief Processes the indcation from PE for pre-channel switch.
6700 \param hHal
6701 \- The handle returned by macOpen. return eHalStatus
6702 ---------------------------------------------------------------------------*/
6703eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
6704{
6705 eHalStatus status = eHAL_STATUS_FAILURE;
6706 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6707 status = sme_AcquireGlobalLock( &pMac->sme );
6708 if ( HAL_STATUS_SUCCESS( status ) )
6709 {
6710 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
6711 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
6712 sme_ReleaseGlobalLock( &pMac->sme );
6713 }
6714
6715 return (status);
6716}
6717
6718/* ---------------------------------------------------------------------------
6719 \fn sme_HandlePostChannelSwitchInd
6720 \brief Processes the indcation from PE for post-channel switch.
6721 \param hHal
6722 \- The handle returned by macOpen. return eHalStatus
6723 ---------------------------------------------------------------------------*/
6724eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
6725{
6726 eHalStatus status = eHAL_STATUS_FAILURE;
6727 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6728
6729 status = sme_AcquireGlobalLock( &pMac->sme );
6730 if ( HAL_STATUS_SUCCESS( status ) )
6731 {
6732 status = pmcRequestBmps(hHal, NULL, NULL);
6733 sme_ReleaseGlobalLock( &pMac->sme );
6734 }
6735
6736 return (status);
6737}
6738
6739/* ---------------------------------------------------------------------------
6740
6741 \fn sme_IsChannelValid
6742
6743 \brief To check if the channel is valid for currently established domain
6744 This is a synchronous API.
6745
6746 \param hHal - The handle returned by macOpen.
6747 \param channel - channel to verify
6748
6749 \return TRUE/FALSE, TRUE if channel is valid
6750
6751 -------------------------------------------------------------------------------*/
6752tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
6753{
6754 eHalStatus status = eHAL_STATUS_FAILURE;
6755 tANI_BOOLEAN valid = FALSE;
6756 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6757
6758 status = sme_AcquireGlobalLock( &pMac->sme );
6759 if ( HAL_STATUS_SUCCESS( status ) )
6760 {
6761
6762 valid = csrRoamIsChannelValid( pMac, channel);
6763
6764 sme_ReleaseGlobalLock( &pMac->sme );
6765 }
6766
6767 return (valid);
6768}
6769
6770/* ---------------------------------------------------------------------------
6771 \fn sme_SetFreqBand
6772 \brief Used to set frequency band.
6773 \param hHal
6774 \eBand band value to be configured
6775 \- return eHalStatus
6776 -------------------------------------------------------------------------*/
6777eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
6778{
6779 eHalStatus status = eHAL_STATUS_FAILURE;
6780 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6781
6782 status = sme_AcquireGlobalLock( &pMac->sme );
6783 if ( HAL_STATUS_SUCCESS( status ) )
6784 {
6785 status = csrSetBand(hHal, eBand);
6786 sme_ReleaseGlobalLock( &pMac->sme );
6787 }
6788 return status;
6789}
6790
6791/* ---------------------------------------------------------------------------
6792 \fn sme_GetFreqBand
6793 \brief Used to get the current band settings.
6794 \param hHal
6795 \pBand pointer to hold band value
6796 \- return eHalStatus
6797 -------------------------------------------------------------------------*/
6798eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
6799{
6800 eHalStatus status = eHAL_STATUS_FAILURE;
6801 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6802
6803 status = sme_AcquireGlobalLock( &pMac->sme );
6804 if ( HAL_STATUS_SUCCESS( status ) )
6805 {
6806 *pBand = csrGetCurrentBand( hHal );
6807 sme_ReleaseGlobalLock( &pMac->sme );
6808 }
6809 return status;
6810}
6811
6812#ifdef WLAN_WAKEUP_EVENTS
6813/******************************************************************************
6814 \fn sme_WakeReasonIndCallback
6815
6816 \brief
6817 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
6818
6819 \param hHal - HAL handle for device
6820 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
6821
6822 \return eHalStatus
6823******************************************************************************/
6824eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
6825{
6826 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6827 eHalStatus status = eHAL_STATUS_SUCCESS;
6828 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
6829
6830 if (NULL == pMsg)
6831 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006832 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006833 status = eHAL_STATUS_FAILURE;
6834 }
6835 else
6836 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006837 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback");
Jeff Johnson295189b2012-06-20 16:38:30 -07006838
6839 /* Call Wake Reason Indication callback routine. */
6840 if (pMac->pmc.wakeReasonIndCB != NULL)
6841 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
6842
6843 pMac->pmc.wakeReasonIndCB = NULL;
6844 pMac->pmc.wakeReasonIndCBContext = NULL;
6845
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006846 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __func__, pWakeReasonInd->ulReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 }
6848
6849 return(status);
6850}
6851#endif // WLAN_WAKEUP_EVENTS
6852
6853
6854/* ---------------------------------------------------------------------------
6855
6856 \fn sme_SetMaxTxPower
6857
6858 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
6859 not persist over reboots.
6860
6861 \param hHal
6862 \param pBssid BSSID to set the power cap for
6863 \param pBssid pSelfMacAddress self MAC Address
6864 \param pBssid power to set in dB
6865 \- return eHalStatus
6866
6867 -------------------------------------------------------------------------------*/
6868eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr pBssid,
6869 tSirMacAddr pSelfMacAddress, v_S7_t dB)
6870{
6871 vos_msg_t msg;
6872 tpMaxTxPowerParams pMaxTxParams = NULL;
6873
6874 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
6875 if (NULL == pMaxTxParams)
6876 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006877 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 -07006878 return eHAL_STATUS_FAILURE;
6879 }
6880
6881 vos_mem_copy(pMaxTxParams->bssId, pBssid, SIR_MAC_ADDR_LENGTH);
6882 vos_mem_copy(pMaxTxParams->selfStaMacAddr , pSelfMacAddress,
6883 SIR_MAC_ADDR_LENGTH);
6884 pMaxTxParams->power = dB;
6885
6886 msg.type = WDA_SET_MAX_TX_POWER_REQ;
6887 msg.reserved = 0;
6888 msg.bodyptr = pMaxTxParams;
6889
6890 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6891 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006892 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 -07006893 vos_mem_free(pMaxTxParams);
6894 return eHAL_STATUS_FAILURE;
6895 }
6896
6897 return eHAL_STATUS_SUCCESS;
6898}
6899
Jeff Johnson295189b2012-06-20 16:38:30 -07006900/* ---------------------------------------------------------------------------
6901
schang86c22c42013-03-13 18:41:24 -07006902 \fn sme_SetTxPower
6903
6904 \brief Set Transmit Power dynamically. Note: this setting will
6905 not persist over reboots.
6906
6907 \param hHal
6908 \param sessionId Target Session ID
6909 \param mW power to set in mW
6910 \- return eHalStatus
6911
6912 -------------------------------------------------------------------------------*/
6913eHalStatus sme_SetTxPower(tHalHandle hHal, v_U8_t sessionId, v_U8_t mW)
6914{
6915
6916 eHalStatus status = eHAL_STATUS_FAILURE;
6917 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6918
6919 smsLog(pMac, LOG1, FL("set tx power %dmW"), mW);
6920 status = sme_AcquireGlobalLock(&pMac->sme);
6921 if (HAL_STATUS_SUCCESS(status))
6922 {
6923 status = csrSetTxPower(pMac, sessionId, mW);
6924 sme_ReleaseGlobalLock(&pMac->sme);
6925 }
6926 return status;
6927}
6928
6929/* ---------------------------------------------------------------------------
6930
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 \fn sme_HideSSID
6932
6933 \brief hide/show SSID dynamically. Note: this setting will
6934 not persist over reboots.
6935
6936 \param hHal
6937 \param sessionId
6938 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
6939 \- return eHalStatus
6940
6941 -------------------------------------------------------------------------------*/
6942eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
6943{
6944 eHalStatus status = eHAL_STATUS_SUCCESS;
6945 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6946 tANI_U16 len;
6947
6948 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6949 {
6950 tpSirUpdateParams pMsg;
6951 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006952
6953 if(!pSession)
6954 {
6955 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08006956 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006957 return eHAL_STATUS_FAILURE;
6958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006959
6960 if( !pSession->sessionActive )
6961 VOS_ASSERT(0);
6962
6963 /* Create the message and send to lim */
6964 len = sizeof(tSirUpdateParams);
6965 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
6966 if(HAL_STATUS_SUCCESS(status))
6967 {
6968 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirUpdateParams) );
6969 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
6970 pMsg->length = len;
6971 /* Data starts from here */
6972 pMsg->sessionId = sessionId;
6973 pMsg->ssidHidden = ssidHidden;
6974 status = palSendMBMessage(pMac->hHdd, pMsg);
6975 }
6976 sme_ReleaseGlobalLock( &pMac->sme );
6977 }
6978 return status;
6979}
Jeff Johnson295189b2012-06-20 16:38:30 -07006980
6981/* ---------------------------------------------------------------------------
6982
6983 \fn sme_SetTmLevel
6984 \brief Set Thermal Mitigation Level to RIVA
6985 \param hHal - The handle returned by macOpen.
6986 \param newTMLevel - new Thermal Mitigation Level
6987 \param tmMode - Thermal Mitigation handle mode, default 0
6988 \return eHalStatus
6989 ---------------------------------------------------------------------------*/
6990eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
6991{
6992 eHalStatus status = eHAL_STATUS_SUCCESS;
6993 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6994 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6995 vos_msg_t vosMessage;
6996 tAniSetTmLevelReq *setTmLevelReq = NULL;
6997
6998 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6999 {
7000 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
7001 if(NULL == setTmLevelReq)
7002 {
7003 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007004 "%s: Not able to allocate memory for sme_SetTmLevel", __func__);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08007005 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 return eHAL_STATUS_FAILURE;
7007 }
7008
7009 setTmLevelReq->tmMode = tmMode;
7010 setTmLevelReq->newTmLevel = newTMLevel;
7011
7012 /* serialize the req through MC thread */
7013 vosMessage.bodyptr = setTmLevelReq;
7014 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
7015 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
7016 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
7017 {
7018 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007019 "%s: Post Set TM Level MSG fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 vos_mem_free(setTmLevelReq);
7021 status = eHAL_STATUS_FAILURE;
7022 }
7023 sme_ReleaseGlobalLock( &pMac->sme );
7024 }
7025 return(status);
7026}
7027
7028/*---------------------------------------------------------------------------
7029
7030 \brief sme_featureCapsExchange() - SME interface to exchange capabilities between
7031 Host and FW.
7032
7033 \param hHal - HAL handle for device
7034
7035 \return NONE
7036
7037---------------------------------------------------------------------------*/
7038void sme_featureCapsExchange( tHalHandle hHal)
7039{
7040 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
7041 WDA_featureCapsExchange(vosContext);
7042}
Jeff Johnsond13512a2012-07-17 11:42:19 -07007043
Yathish9f22e662012-12-10 14:21:35 -08007044/*---------------------------------------------------------------------------
7045
7046 \brief sme_disableFeatureCapablity() - SME interface to disable Active mode offload capablity
7047 in Host.
7048
7049 \param hHal - HAL handle for device
7050
7051 \return NONE
7052
7053---------------------------------------------------------------------------*/
7054void sme_disableFeatureCapablity(tANI_U8 feature_index)
7055{
7056 WDA_disableCapablityFeature(feature_index);
7057}
7058
7059
Jeff Johnsond13512a2012-07-17 11:42:19 -07007060
7061/* ---------------------------------------------------------------------------
7062
7063 \fn sme_GetDefaultCountryCode
7064
7065 \brief Get the default country code from NV
7066
7067 \param hHal
7068 \param pCountry
7069 \- return eHalStatus
7070
7071 -------------------------------------------------------------------------------*/
7072eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
7073{
7074 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7075 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
7076}
7077
7078/* ---------------------------------------------------------------------------
7079
7080 \fn sme_GetCurrentCountryCode
7081
7082 \brief Get the current country code
7083
7084 \param hHal
7085 \param pCountry
7086 \- return eHalStatus
7087
7088 -------------------------------------------------------------------------------*/
7089eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
7090{
7091 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7092 return csrGetCurrentCountryCode(pMac, pCountry);
7093}
7094
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007095/* ---------------------------------------------------------------------------
7096 \fn sme_transportDebug
7097 \brief Dynamically monitoring Transport channels
7098 Private IOCTL will querry transport channel status if driver loaded
schang6295e542013-03-12 15:31:23 -07007099 \param hHal Upper MAC context
Jeff Johnsonb88db982012-12-10 13:34:59 -08007100 \param displaySnapshot Display transport channel snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007101 \param toggleStallDetect Enable stall detect feature
7102 This feature will take effect to data performance
7103 Not integrate till fully verification
7104 \- return NONE
7105 -------------------------------------------------------------------------*/
schang6295e542013-03-12 15:31:23 -07007106void sme_transportDebug(tHalHandle hHal, v_BOOL_t displaySnapshot, v_BOOL_t toggleStallDetect)
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007107{
schang6295e542013-03-12 15:31:23 -07007108 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7109
7110 if (NULL == pMac)
7111 {
7112 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7113 "%s: invalid context", __func__);
7114 return;
7115 }
7116 WDA_TransportChannelDebug(pMac, displaySnapshot, toggleStallDetect);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07007117}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007118
Kiran4a17ebe2013-01-31 10:43:43 -08007119/* ---------------------------------------------------------------------------
7120 \fn sme_ResetPowerValuesFor5G
7121 \brief Reset the power values for 5G band with NV power values.
7122 \param hHal - HAL handle for device
7123 \- return NONE
7124 -------------------------------------------------------------------------*/
7125void sme_ResetPowerValuesFor5G (tHalHandle hHal)
7126{
7127 tpAniSirGlobal pMac = PMAC_STRUCT (hHal);
7128 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
7129 csrApplyPower2Current(pMac); // Store the channel+power info in the global place: Cfg
7130}
7131
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007132#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
7133/* ---------------------------------------------------------------------------
7134 \fn sme_UpdateRoamPrefer5GHz
7135 \brief enable/disable Roam prefer 5G runtime option
7136 This function is called through dynamic setConfig callback function
7137 to configure the Roam prefer 5G runtime option
7138 \param hHal - HAL handle for device
7139 \param nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
7140 \- return Success or failure
7141 -------------------------------------------------------------------------*/
7142
7143eHalStatus sme_UpdateRoamPrefer5GHz(tHalHandle hHal, v_BOOL_t nRoamPrefer5GHz)
7144{
7145 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08007146 eHalStatus status = eHAL_STATUS_SUCCESS;
7147
7148 status = sme_AcquireGlobalLock( &pMac->sme );
7149 if ( HAL_STATUS_SUCCESS( status ) )
7150 {
7151 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7152 "%s: gRoamPrefer5GHz is changed from %d to %d", __func__,
7153 pMac->roam.configParam.nRoamPrefer5GHz,
7154 nRoamPrefer5GHz);
7155 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
7156 sme_ReleaseGlobalLock( &pMac->sme );
7157 }
7158
7159 return status ;
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007160}
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08007161
7162/* ---------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007163 \fn sme_setRoamIntraBand
7164 \brief enable/disable Intra band roaming
7165 This function is called through dynamic setConfig callback function
7166 to configure the intra band roaming
7167 \param hHal - HAL handle for device
7168 \param nRoamIntraBand Enable/Disable Intra band roaming
7169 \- return Success or failure
7170 -------------------------------------------------------------------------*/
7171eHalStatus sme_setRoamIntraBand(tHalHandle hHal, const v_BOOL_t nRoamIntraBand)
7172{
7173 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7174 eHalStatus status = eHAL_STATUS_SUCCESS;
7175
7176 status = sme_AcquireGlobalLock( &pMac->sme );
7177 if ( HAL_STATUS_SUCCESS( status ) )
7178 {
7179 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7180 "%s: gRoamIntraBand is changed from %d to %d", __func__,
7181 pMac->roam.configParam.nRoamIntraBand,
7182 nRoamIntraBand);
7183 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
7184 sme_ReleaseGlobalLock( &pMac->sme );
7185 }
7186
7187 return status ;
7188}
7189
7190/* ---------------------------------------------------------------------------
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007191 \fn sme_UpdateRoamScanNProbes
7192 \brief function to update roam scan N probes
7193 This function is called through dynamic setConfig callback function
7194 to update roam scan N probes
7195 \param hHal - HAL handle for device
7196 \param nProbes number of probe requests to be sent out
7197 \- return Success or failure
7198 -------------------------------------------------------------------------*/
7199eHalStatus sme_UpdateRoamScanNProbes(tHalHandle hHal, const v_U8_t nProbes)
7200{
7201 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7202 eHalStatus status = eHAL_STATUS_SUCCESS;
7203
7204 status = sme_AcquireGlobalLock( &pMac->sme );
7205 if ( HAL_STATUS_SUCCESS( status ) )
7206 {
7207 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7208 "%s: gRoamScanNProbes is changed from %d to %d", __func__,
7209 pMac->roam.configParam.nProbes,
7210 nProbes);
7211 pMac->roam.configParam.nProbes = nProbes;
7212 sme_ReleaseGlobalLock( &pMac->sme );
7213 }
7214#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7215 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7216 {
7217 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7218 REASON_NPROBES_CHANGED);
7219 }
7220#endif
7221 return status ;
7222}
7223
7224/* ---------------------------------------------------------------------------
7225 \fn sme_UpdateRoamScanHomeAwayTime
7226 \brief function to update roam scan Home away time
7227 This function is called through dynamic setConfig callback function
7228 to update roam scan home away time
7229 \param hHal - HAL handle for device
7230 \param nRoamScanAwayTime Scan home away time
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07007231 \param bSendOffloadCmd If TRUE then send offload command to firmware
7232 If FALSE then command is not sent to firmware
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007233 \- return Success or failure
7234 -------------------------------------------------------------------------*/
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07007235eHalStatus sme_UpdateRoamScanHomeAwayTime(tHalHandle hHal, const v_U16_t nRoamScanHomeAwayTime,
7236 const eAniBoolean bSendOffloadCmd)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007237{
7238 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7239 eHalStatus status = eHAL_STATUS_SUCCESS;
7240
7241 status = sme_AcquireGlobalLock( &pMac->sme );
7242 if ( HAL_STATUS_SUCCESS( status ) )
7243 {
7244 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7245 "%s: gRoamScanHomeAwayTime is changed from %d to %d", __func__,
7246 pMac->roam.configParam.nRoamScanHomeAwayTime,
7247 nRoamScanHomeAwayTime);
7248 pMac->roam.configParam.nRoamScanHomeAwayTime = nRoamScanHomeAwayTime;
7249 sme_ReleaseGlobalLock( &pMac->sme );
7250 }
7251
7252#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07007253 if (pMac->roam.configParam.isRoamOffloadScanEnabled && bSendOffloadCmd)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007254 {
7255 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7256 REASON_HOME_AWAY_TIME_CHANGED);
7257 }
7258#endif
7259 return status;
7260}
7261
7262
7263/* ---------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007264 \fn sme_getRoamIntraBand
7265 \brief get Intra band roaming
7266 \param hHal - HAL handle for device
7267 \- return Success or failure
7268 -------------------------------------------------------------------------*/
7269v_BOOL_t sme_getRoamIntraBand(tHalHandle hHal)
7270{
7271 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7272 return pMac->roam.configParam.nRoamIntraBand;
7273}
7274
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007275/* ---------------------------------------------------------------------------
7276 \fn sme_getRoamScanNProbes
7277 \brief get N Probes
7278 \param hHal - HAL handle for device
7279 \- return Success or failure
7280 -------------------------------------------------------------------------*/
7281v_U8_t sme_getRoamScanNProbes(tHalHandle hHal)
7282{
7283 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7284 return pMac->roam.configParam.nProbes;
7285}
7286
7287/* ---------------------------------------------------------------------------
7288 \fn sme_getRoamScanHomeAwayTime
7289 \brief get Roam scan home away time
7290 \param hHal - HAL handle for device
7291 \- return Success or failure
7292 -------------------------------------------------------------------------*/
7293v_U16_t sme_getRoamScanHomeAwayTime(tHalHandle hHal)
7294{
7295 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7296 return pMac->roam.configParam.nRoamScanHomeAwayTime;
7297}
7298
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007299
7300/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08007301 \fn sme_UpdateImmediateRoamRssiDiff
7302 \brief Update nImmediateRoamRssiDiff
7303 This function is called through dynamic setConfig callback function
7304 to configure nImmediateRoamRssiDiff
7305 Usage: adb shell iwpriv wlan0 setConfig gImmediateRoamRssiDiff=[0 .. 125]
7306 \param hHal - HAL handle for device
7307 \param nImmediateRoamRssiDiff - minimum rssi difference between potential
7308 candidate and current AP.
7309 \- return Success or failure
7310 -------------------------------------------------------------------------*/
7311
7312eHalStatus sme_UpdateImmediateRoamRssiDiff(tHalHandle hHal, v_U8_t nImmediateRoamRssiDiff)
7313{
7314 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08007315 eHalStatus status = eHAL_STATUS_SUCCESS;
7316
7317 status = sme_AcquireGlobalLock( &pMac->sme );
7318 if ( HAL_STATUS_SUCCESS( status ) )
7319 {
7320 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7321 "LFR runtime successfully set immediate roam rssi diff to %d - old value is %d - roam state is %d",
7322 nImmediateRoamRssiDiff,
7323 pMac->roam.configParam.nImmediateRoamRssiDiff,
7324 pMac->roam.neighborRoamInfo.neighborRoamState);
7325 pMac->roam.configParam.nImmediateRoamRssiDiff = nImmediateRoamRssiDiff;
7326 sme_ReleaseGlobalLock( &pMac->sme );
7327 }
7328
7329 return status ;
7330}
7331
7332/* ---------------------------------------------------------------------------
7333 \fn sme_UpdateRoamRssiDiff
7334 \brief Update RoamRssiDiff
7335 This function is called through dynamic setConfig callback function
7336 to configure RoamRssiDiff
7337 Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
7338 \param hHal - HAL handle for device
7339 \param RoamRssiDiff - minimum rssi difference between potential
7340 candidate and current AP.
7341 \- return Success or failure
7342 -------------------------------------------------------------------------*/
7343
7344eHalStatus sme_UpdateRoamRssiDiff(tHalHandle hHal, v_U8_t RoamRssiDiff)
7345{
7346 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7347 eHalStatus status = eHAL_STATUS_SUCCESS;
7348
7349 status = sme_AcquireGlobalLock( &pMac->sme );
7350 if ( HAL_STATUS_SUCCESS( status ) )
7351 {
7352 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7353 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %d",
7354 RoamRssiDiff,
7355 pMac->roam.configParam.RoamRssiDiff,
7356 pMac->roam.neighborRoamInfo.neighborRoamState);
7357 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
7358 sme_ReleaseGlobalLock( &pMac->sme );
7359 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07007360#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7361 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7362 {
7363 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_RSSI_DIFF_CHANGED);
7364 }
7365#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08007366 return status ;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08007367}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007368
7369/*--------------------------------------------------------------------------
7370 \brief sme_UpdateFastTransitionEnabled() - enable/disable Fast Transition support at runtime
7371 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7372 isFastTransitionEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08007373 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007374 \param hHal - The handle returned by macOpen.
7375 \return eHAL_STATUS_SUCCESS - SME update isFastTransitionEnabled config successfully.
7376 Other status means SME is failed to update isFastTransitionEnabled.
7377 \sa
7378 --------------------------------------------------------------------------*/
7379eHalStatus sme_UpdateFastTransitionEnabled(tHalHandle hHal,
7380 v_BOOL_t isFastTransitionEnabled)
7381{
7382 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08007383 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007384
Srinivas Girigowdade697412013-02-14 16:31:48 -08007385 status = sme_AcquireGlobalLock( &pMac->sme );
7386 if ( HAL_STATUS_SUCCESS( status ) )
7387 {
7388 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7389 "%s: FastTransitionEnabled is changed from %d to %d", __func__,
7390 pMac->roam.configParam.isFastTransitionEnabled,
7391 isFastTransitionEnabled);
7392 pMac->roam.configParam.isFastTransitionEnabled = isFastTransitionEnabled;
7393 sme_ReleaseGlobalLock( &pMac->sme );
7394 }
7395
7396 return status ;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007397}
Srinivas Girigowda100eb322013-03-15 16:48:20 -07007398
7399/* ---------------------------------------------------------------------------
Srinivas Girigowda100eb322013-03-15 16:48:20 -07007400 \fn sme_SetRoamScanControl
7401 \brief Set roam scan control
7402 This function is called to set roam scan control
7403 if roam scan control is set to 0, roaming scan cache is cleared
7404 any value other than 0 is treated as invalid value
7405 \param hHal - HAL handle for device
7406 \return eHAL_STATUS_SUCCESS - SME update config successfully.
7407 Other status means SME failure to update
7408 -------------------------------------------------------------------------*/
7409eHalStatus sme_SetRoamScanControl(tHalHandle hHal, v_BOOL_t roamScanControl)
7410{
7411 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7412 eHalStatus status = eHAL_STATUS_SUCCESS;
7413
7414 status = sme_AcquireGlobalLock( &pMac->sme );
7415 if ( HAL_STATUS_SUCCESS( status ) )
7416 {
7417 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7418 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %d",
7419 roamScanControl,
7420 pMac->roam.configParam.nRoamScanControl,
7421 pMac->roam.neighborRoamInfo.neighborRoamState);
7422 pMac->roam.configParam.nRoamScanControl = roamScanControl;
7423 if ( 0 == roamScanControl)
7424 {
7425 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7426 "LFR runtime successfully cleared roam scan cache");
7427 csrFlushBgScanRoamChannelList(pMac);
7428#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7429 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7430 {
7431 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_FLUSH_CHANNEL_LIST);
7432 }
7433#endif
7434 }
7435 sme_ReleaseGlobalLock( &pMac->sme );
7436 }
7437 return status ;
7438}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007439#endif /* (WLAN_FEATURE_VOWIFI_11R) || (FEATURE_WLAN_CCX) || (FEATURE_WLAN_LFR) */
7440
7441#ifdef FEATURE_WLAN_LFR
7442/*--------------------------------------------------------------------------
7443 \brief sme_UpdateIsFastRoamIniFeatureEnabled() - enable/disable LFR support at runtime
7444 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7445 isFastRoamIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08007446 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007447 \param hHal - The handle returned by macOpen.
7448 \return eHAL_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config successfully.
7449 Other status means SME is failed to update isFastRoamIniFeatureEnabled.
7450 \sa
7451 --------------------------------------------------------------------------*/
7452eHalStatus sme_UpdateIsFastRoamIniFeatureEnabled(tHalHandle hHal,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007453 const v_BOOL_t isFastRoamIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007454{
7455 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7456
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007457 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled == isFastRoamIniFeatureEnabled)
7458 {
7459 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7460 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)", __func__,
7461 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7462 isFastRoamIniFeatureEnabled);
7463 return eHAL_STATUS_SUCCESS;
7464 }
7465
Srinivas Girigowdade697412013-02-14 16:31:48 -08007466 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7467 "%s: FastRoamEnabled is changed from %d to %d", __func__,
7468 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7469 isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007470 pMac->roam.configParam.isFastRoamIniFeatureEnabled = isFastRoamIniFeatureEnabled;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007471 csrNeighborRoamUpdateFastRoamingEnabled(pMac, isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007472
7473 if(TRUE == isFastRoamIniFeatureEnabled)
7474 {
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007475 sme_UpdateConfigFwRssiMonitoring(hHal, TRUE);
7476 }
7477 else
7478 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08007479 /* CCX also depend on FW Monitoring.
7480 Hence Disabling LFR should check for CCX enable before disabling FW Monitoring */
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007481#ifdef FEATURE_WLAN_CCX
7482 if(FALSE == pMac->roam.configParam.isCcxIniFeatureEnabled)
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007483#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007484 {
7485 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Srinivas Girigowdade697412013-02-14 16:31:48 -08007486 "%s: Turn off FW Monitoring", __func__);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007487 sme_UpdateConfigFwRssiMonitoring(hHal, FALSE);
7488 }
7489 }
7490
7491 return eHAL_STATUS_SUCCESS;
7492}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07007493
7494#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7495/*--------------------------------------------------------------------------
7496 \brief sme_UpdateEnableFastRoamInConcurrency() - enable/disable LFR if Concurrent session exists
7497 This is a synchronuous call
7498 \param hHal - The handle returned by macOpen.
7499 \return eHAL_STATUS_SUCCESS
7500 Other status means SME is failed
7501 \sa
7502 --------------------------------------------------------------------------*/
7503
7504eHalStatus sme_UpdateEnableFastRoamInConcurrency(tHalHandle hHal,
7505 v_BOOL_t bFastRoamInConIniFeatureEnabled)
7506{
7507
7508 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7509 eHalStatus status = eHAL_STATUS_SUCCESS;
7510
7511 status = sme_AcquireGlobalLock( &pMac->sme );
7512 if ( HAL_STATUS_SUCCESS( status ) )
7513 {
7514 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = bFastRoamInConIniFeatureEnabled;
7515 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled)
7516 {
7517 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = 0;
7518 }
7519 sme_ReleaseGlobalLock( &pMac->sme );
7520 }
7521
7522 return status;
7523}
7524#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007525#endif /* FEATURE_WLAN_LFR */
7526
7527#ifdef FEATURE_WLAN_CCX
7528/*--------------------------------------------------------------------------
7529 \brief sme_UpdateIsCcxFeatureEnabled() - enable/disable CCX support at runtime
7530 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7531 isCcxIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08007532 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007533 \param hHal - The handle returned by macOpen.
7534 \return eHAL_STATUS_SUCCESS - SME update isCcxIniFeatureEnabled config successfully.
7535 Other status means SME is failed to update isCcxIniFeatureEnabled.
7536 \sa
7537 --------------------------------------------------------------------------*/
7538
7539eHalStatus sme_UpdateIsCcxFeatureEnabled(tHalHandle hHal,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007540 const v_BOOL_t isCcxIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007541{
7542 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7543
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007544 if (pMac->roam.configParam.isCcxIniFeatureEnabled == isCcxIniFeatureEnabled)
7545 {
7546 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7547 "%s: CCX Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)", __func__,
7548 pMac->roam.configParam.isCcxIniFeatureEnabled,
7549 isCcxIniFeatureEnabled);
7550 return eHAL_STATUS_SUCCESS;
7551 }
7552
Srinivas Girigowdade697412013-02-14 16:31:48 -08007553 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7554 "%s: CcxEnabled is changed from %d to %d", __func__,
7555 pMac->roam.configParam.isCcxIniFeatureEnabled,
7556 isCcxIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007557 pMac->roam.configParam.isCcxIniFeatureEnabled = isCcxIniFeatureEnabled;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007558 csrNeighborRoamUpdateCcxModeEnabled(pMac, isCcxIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007559
7560 if(TRUE == isCcxIniFeatureEnabled)
7561 {
7562 sme_UpdateFastTransitionEnabled(hHal, TRUE);
7563 sme_UpdateConfigFwRssiMonitoring(hHal, TRUE);
7564 }
7565 else
7566 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08007567 /* LFR also depend on FW Monitoring.
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007568 Hence Disabling CCX should check for LFR enable before disabling FW Monitoring and Fast Transition */
7569#ifdef FEATURE_WLAN_LFR
7570 if(FALSE == pMac->roam.configParam.isFastRoamIniFeatureEnabled)
7571#endif
7572 {
7573 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7574 "%s: Turn off FW Monitoring/Fast Transition", __func__);
7575 sme_UpdateFastTransitionEnabled(hHal, FALSE);
7576 sme_UpdateConfigFwRssiMonitoring(hHal, FALSE);
7577 }
7578 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07007579#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7580 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7581 {
7582 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CCX_INI_CFG_CHANGED);
7583 }
7584#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007585 return eHAL_STATUS_SUCCESS;
7586}
7587#endif /* FEATURE_WLAN_CCX */
7588
7589/*--------------------------------------------------------------------------
7590 \brief sme_UpdateConfigFwRssiMonitoring() - enable/disable firmware RSSI Monitoring at runtime
7591 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7592 fEnableFwRssiMonitoring.
Srinivas Girigowdade697412013-02-14 16:31:48 -08007593 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007594 \param hHal - The handle returned by macOpen.
7595 \return eHAL_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring. config successfully.
7596 Other status means SME is failed to update fEnableFwRssiMonitoring.
7597 \sa
7598 --------------------------------------------------------------------------*/
7599
7600eHalStatus sme_UpdateConfigFwRssiMonitoring(tHalHandle hHal,
7601 v_BOOL_t fEnableFwRssiMonitoring)
7602{
7603 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
7604
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007605 if (ccmCfgSetInt(hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR, fEnableFwRssiMonitoring,
7606 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
7607 {
7608 halStatus = eHAL_STATUS_FAILURE;
7609 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007610 "Failure: Could not pass on WNI_CFG_PS_RSSI_MONITOR configuration info to CCM");
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007611 }
7612
7613 return (halStatus);
7614}
7615
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007616#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srinivas Girigowdade697412013-02-14 16:31:48 -08007617/*--------------------------------------------------------------------------
7618 \brief sme_setNeighborLookupRssiThreshold() - update neighbor lookup rssi threshold
7619 This is a synchronous call
7620 \param hHal - The handle returned by macOpen.
7621 \return eHAL_STATUS_SUCCESS - SME update config successful.
7622 Other status means SME is failed to update
7623 \sa
7624 --------------------------------------------------------------------------*/
7625eHalStatus sme_setNeighborLookupRssiThreshold(tHalHandle hHal,
7626 v_U8_t neighborLookupRssiThreshold)
7627{
7628 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7629 eHalStatus status = eHAL_STATUS_SUCCESS;
7630
7631 status = sme_AcquireGlobalLock( &pMac->sme );
7632 if ( HAL_STATUS_SUCCESS( status ) )
7633 {
7634 status = csrNeighborRoamSetLookupRssiThreshold(pMac, neighborLookupRssiThreshold);
7635 if (HAL_STATUS_SUCCESS(status))
7636 {
7637 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7638 "LFR runtime successfully set Lookup threshold to %d - old value is %d - roam state is %d",
7639 neighborLookupRssiThreshold,
7640 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold,
7641 pMac->roam.neighborRoamInfo.neighborRoamState);
7642 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
7643 neighborLookupRssiThreshold;
7644 }
7645 sme_ReleaseGlobalLock( &pMac->sme );
7646 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08007647 return status;
7648}
7649
7650/*--------------------------------------------------------------------------
7651 \brief sme_setNeighborReassocRssiThreshold() - update neighbor reassoc rssi threshold
7652 This is a synchronous call
7653 \param hHal - The handle returned by macOpen.
7654 \return eHAL_STATUS_SUCCESS - SME update config successful.
7655 Other status means SME is failed to update
7656 \sa
7657 --------------------------------------------------------------------------*/
7658eHalStatus sme_setNeighborReassocRssiThreshold(tHalHandle hHal,
7659 v_U8_t neighborReassocRssiThreshold)
7660{
7661 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7662 eHalStatus status = eHAL_STATUS_SUCCESS;
7663
7664 status = sme_AcquireGlobalLock( &pMac->sme );
7665 if ( HAL_STATUS_SUCCESS( status ) )
7666 {
7667 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7668 "LFR runtime successfully set Reassoc threshold to %d - old value is %d - roam state is %d",
7669 neighborReassocRssiThreshold,
7670 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold,
7671 pMac->roam.neighborRoamInfo.neighborRoamState);
7672 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold =
7673 neighborReassocRssiThreshold;
7674 pMac->roam.neighborRoamInfo.cfgParams.neighborReassocThreshold =
7675 neighborReassocRssiThreshold;
7676 sme_ReleaseGlobalLock( &pMac->sme );
7677 }
7678
7679 return status ;
7680}
7681
7682
7683/*--------------------------------------------------------------------------
7684 \brief sme_getNeighborLookupRssiThreshold() - get neighbor lookup rssi threshold
7685 This is a synchronous call
7686 \param hHal - The handle returned by macOpen.
7687 \return eHAL_STATUS_SUCCESS - SME update config successful.
7688 Other status means SME is failed to update
7689 \sa
7690 --------------------------------------------------------------------------*/
7691v_U8_t sme_getNeighborLookupRssiThreshold(tHalHandle hHal)
7692{
7693 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7694 return pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
7695}
7696
7697/*--------------------------------------------------------------------------
7698 \brief sme_setNeighborScanRefreshPeriod() - set neighbor scan results refresh period
7699 This is a synchronous call
7700 \param hHal - The handle returned by macOpen.
7701 \return eHAL_STATUS_SUCCESS - SME update config successful.
7702 Other status means SME is failed to update
7703 \sa
7704 --------------------------------------------------------------------------*/
7705eHalStatus sme_setNeighborScanRefreshPeriod(tHalHandle hHal,
7706 v_U16_t neighborScanResultsRefreshPeriod)
7707{
7708 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7709 eHalStatus status = eHAL_STATUS_SUCCESS;
7710
7711 status = sme_AcquireGlobalLock( &pMac->sme );
7712 if ( HAL_STATUS_SUCCESS( status ) )
7713 {
7714 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7715 "LFR runtime successfully set roam scan refresh period to %d - old value is %d - roam state is %d",
7716 neighborScanResultsRefreshPeriod,
7717 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod,
7718 pMac->roam.neighborRoamInfo.neighborRoamState);
7719 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod =
7720 neighborScanResultsRefreshPeriod;
7721 pMac->roam.neighborRoamInfo.cfgParams.neighborResultsRefreshPeriod =
7722 neighborScanResultsRefreshPeriod;
7723
7724 sme_ReleaseGlobalLock( &pMac->sme );
7725 }
7726
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07007727#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7728 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7729 {
7730 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7731 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
7732 }
7733#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08007734 return status ;
7735}
7736
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07007737#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7738/*--------------------------------------------------------------------------
7739 \brief sme_UpdateRoamScanOffloadEnabled() - enable/disable roam scan offload feaure
7740 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7741 gRoamScanOffloadEnabled.
7742 This is a synchronous call
7743 \param hHal - The handle returned by macOpen.
7744 \return eHAL_STATUS_SUCCESS - SME update config successfully.
7745 Other status means SME is failed to update.
7746 \sa
7747 --------------------------------------------------------------------------*/
7748
7749eHalStatus sme_UpdateRoamScanOffloadEnabled(tHalHandle hHal,
7750 v_BOOL_t nRoamScanOffloadEnabled)
7751{
7752 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7753 eHalStatus status = eHAL_STATUS_SUCCESS;
7754
7755 status = sme_AcquireGlobalLock( &pMac->sme );
7756 if ( HAL_STATUS_SUCCESS( status ) )
7757 {
7758 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7759 "%s: gRoamScanOffloadEnabled is changed from %d to %d", __func__,
7760 pMac->roam.configParam.isRoamOffloadScanEnabled,
7761 nRoamScanOffloadEnabled);
7762 pMac->roam.configParam.isRoamOffloadScanEnabled = nRoamScanOffloadEnabled;
7763 sme_ReleaseGlobalLock( &pMac->sme );
7764 }
7765
7766 return status ;
7767}
7768#endif
7769
Srinivas Girigowdade697412013-02-14 16:31:48 -08007770/*--------------------------------------------------------------------------
7771 \brief sme_getNeighborScanRefreshPeriod() - get neighbor scan results refresh period
7772 This is a synchronous call
7773 \param hHal - The handle returned by macOpen.
7774 \return v_U16_t - Neighbor scan results refresh period value
7775 \sa
7776 --------------------------------------------------------------------------*/
7777v_U16_t sme_getNeighborScanRefreshPeriod(tHalHandle hHal)
7778{
7779 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7780 return pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
7781}
7782
7783/*--------------------------------------------------------------------------
7784 \brief sme_getEmptyScanRefreshPeriod() - get empty scan refresh period
7785 This is a synchronuous call
7786 \param hHal - The handle returned by macOpen.
7787 \return eHAL_STATUS_SUCCESS - SME update config successful.
7788 Other status means SME is failed to update
7789 \sa
7790 --------------------------------------------------------------------------*/
7791v_U16_t sme_getEmptyScanRefreshPeriod(tHalHandle hHal)
7792{
7793 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7794 return pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
7795}
7796
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007797/* ---------------------------------------------------------------------------
7798 \fn sme_UpdateEmptyScanRefreshPeriod
7799 \brief Update nEmptyScanRefreshPeriod
7800 This function is called through dynamic setConfig callback function
7801 to configure nEmptyScanRefreshPeriod
7802 Usage: adb shell iwpriv wlan0 setConfig nEmptyScanRefreshPeriod=[0 .. 60]
7803 \param hHal - HAL handle for device
7804 \param nEmptyScanRefreshPeriod - scan period following empty scan results.
7805 \- return Success or failure
7806 -------------------------------------------------------------------------*/
7807
7808eHalStatus sme_UpdateEmptyScanRefreshPeriod(tHalHandle hHal, v_U16_t nEmptyScanRefreshPeriod)
7809{
7810 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7811 eHalStatus status = eHAL_STATUS_SUCCESS;
7812
7813 status = sme_AcquireGlobalLock( &pMac->sme );
7814 if ( HAL_STATUS_SUCCESS( status ) )
7815 {
7816 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7817 "LFR runtime successfully set roam scan period to %d - old value is %d - roam state is %d",
7818 nEmptyScanRefreshPeriod,
7819 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod,
7820 pMac->roam.neighborRoamInfo.neighborRoamState);
7821 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
7822 pMac->roam.neighborRoamInfo.cfgParams.emptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
7823 sme_ReleaseGlobalLock( &pMac->sme );
7824 }
7825
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07007826#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7827 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7828 {
7829 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7830 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
7831 }
7832#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007833 return status ;
7834}
7835
7836/* ---------------------------------------------------------------------------
7837 \fn sme_setNeighborScanMinChanTime
7838 \brief Update nNeighborScanMinChanTime
7839 This function is called through dynamic setConfig callback function
7840 to configure gNeighborScanChannelMinTime
7841 Usage: adb shell iwpriv wlan0 setConfig gNeighborScanChannelMinTime=[0 .. 60]
7842 \param hHal - HAL handle for device
7843 \param nNeighborScanMinChanTime - Channel minimum dwell time
7844 \- return Success or failure
7845 -------------------------------------------------------------------------*/
7846eHalStatus sme_setNeighborScanMinChanTime(tHalHandle hHal, const v_U16_t nNeighborScanMinChanTime)
7847{
7848 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7849 eHalStatus status = eHAL_STATUS_SUCCESS;
7850
7851 status = sme_AcquireGlobalLock( &pMac->sme );
7852 if ( HAL_STATUS_SUCCESS( status ) )
7853 {
7854 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7855 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %d",
7856 nNeighborScanMinChanTime,
7857 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime,
7858 pMac->roam.neighborRoamInfo.neighborRoamState);
7859 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = nNeighborScanMinChanTime;
7860 pMac->roam.neighborRoamInfo.cfgParams.minChannelScanTime = nNeighborScanMinChanTime;
7861 sme_ReleaseGlobalLock( &pMac->sme );
7862 }
7863
7864 return status ;
7865}
7866
7867/* ---------------------------------------------------------------------------
7868 \fn sme_setNeighborScanMaxChanTime
7869 \brief Update nNeighborScanMaxChanTime
7870 This function is called through dynamic setConfig callback function
7871 to configure gNeighborScanChannelMaxTime
7872 Usage: adb shell iwpriv wlan0 setConfig gNeighborScanChannelMaxTime=[0 .. 60]
7873 \param hHal - HAL handle for device
7874 \param nNeighborScanMinChanTime - Channel maximum dwell time
7875 \- return Success or failure
7876 -------------------------------------------------------------------------*/
7877eHalStatus sme_setNeighborScanMaxChanTime(tHalHandle hHal, const v_U16_t nNeighborScanMaxChanTime)
7878{
7879 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7880 eHalStatus status = eHAL_STATUS_SUCCESS;
7881
7882 status = sme_AcquireGlobalLock( &pMac->sme );
7883 if ( HAL_STATUS_SUCCESS( status ) )
7884 {
7885 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7886 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %d",
7887 nNeighborScanMaxChanTime,
7888 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime,
7889 pMac->roam.neighborRoamInfo.neighborRoamState);
7890 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = nNeighborScanMaxChanTime;
7891 pMac->roam.neighborRoamInfo.cfgParams.maxChannelScanTime = nNeighborScanMaxChanTime;
7892 sme_ReleaseGlobalLock( &pMac->sme );
7893 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07007894#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7895 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7896 {
7897 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7898 REASON_SCAN_CH_TIME_CHANGED);
7899 }
7900#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007901
7902 return status ;
7903}
7904
7905/* ---------------------------------------------------------------------------
7906 \fn sme_getNeighborScanMinChanTime
7907 \brief get neighbor scan min channel time
7908 \param hHal - The handle returned by macOpen.
7909 \return v_U16_t - channel min time value
7910 -------------------------------------------------------------------------*/
7911v_U16_t sme_getNeighborScanMinChanTime(tHalHandle hHal)
7912{
7913 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7914 return pMac->roam.neighborRoamInfo.cfgParams.minChannelScanTime;
7915}
7916
7917/* ---------------------------------------------------------------------------
7918 \fn sme_getNeighborScanMaxChanTime
7919 \brief get neighbor scan max channel time
7920 \param hHal - The handle returned by macOpen.
7921 \return v_U16_t - channel max time value
7922 -------------------------------------------------------------------------*/
7923v_U16_t sme_getNeighborScanMaxChanTime(tHalHandle hHal)
7924{
7925 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7926 return pMac->roam.neighborRoamInfo.cfgParams.maxChannelScanTime;
7927}
7928
7929/* ---------------------------------------------------------------------------
7930 \fn sme_setNeighborScanPeriod
7931 \brief Update nNeighborScanPeriod
7932 This function is called through dynamic setConfig callback function
7933 to configure nNeighborScanPeriod
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07007934 Usage: adb shell iwpriv wlan0 setConfig nNeighborScanPeriod=[0 .. 1000]
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007935 \param hHal - HAL handle for device
7936 \param nNeighborScanPeriod - neighbor scan period
7937 \- return Success or failure
7938 -------------------------------------------------------------------------*/
7939eHalStatus sme_setNeighborScanPeriod(tHalHandle hHal, const v_U16_t nNeighborScanPeriod)
7940{
7941 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7942 eHalStatus status = eHAL_STATUS_SUCCESS;
7943
7944 status = sme_AcquireGlobalLock( &pMac->sme );
7945 if ( HAL_STATUS_SUCCESS( status ) )
7946 {
7947 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7948 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %d",
7949 nNeighborScanPeriod,
7950 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod,
7951 pMac->roam.neighborRoamInfo.neighborRoamState);
7952 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = nNeighborScanPeriod;
7953 pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod = nNeighborScanPeriod;
7954 sme_ReleaseGlobalLock( &pMac->sme );
7955 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07007956#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7957 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7958 {
7959 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7960 REASON_SCAN_HOME_TIME_CHANGED);
7961 }
7962#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007963
7964 return status ;
7965}
7966
7967/* ---------------------------------------------------------------------------
7968 \fn sme_getNeighborScanPeriod
7969 \brief get neighbor scan period
7970 \param hHal - The handle returned by macOpen.
7971 \return v_U16_t - neighbor scan period
7972 -------------------------------------------------------------------------*/
7973v_U16_t sme_getNeighborScanPeriod(tHalHandle hHal)
7974{
7975 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7976 return pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
7977}
7978
7979#endif
7980
Srinivas Girigowdade697412013-02-14 16:31:48 -08007981#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007982
Srinivas Girigowdade697412013-02-14 16:31:48 -08007983/*--------------------------------------------------------------------------
7984 \brief sme_getRoamRssiDiff() - get Roam rssi diff
7985 This is a synchronous call
7986 \param hHal - The handle returned by macOpen.
7987 \return v_U16_t - Rssi diff value
7988 \sa
7989 --------------------------------------------------------------------------*/
7990v_U8_t sme_getRoamRssiDiff(tHalHandle hHal)
7991{
7992 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7993 return pMac->roam.configParam.RoamRssiDiff;
7994}
7995
7996/*--------------------------------------------------------------------------
7997 \brief sme_ChangeRoamScanChannelList() - Change roam scan channel list
7998 This is a synchronous call
7999 \param hHal - The handle returned by macOpen.
8000 \return eHAL_STATUS_SUCCESS - SME update config successful.
8001 Other status means SME is failed to update
8002 \sa
8003 --------------------------------------------------------------------------*/
8004eHalStatus sme_ChangeRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
8005 tANI_U8 numChannels)
8006{
8007 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8008 eHalStatus status = eHAL_STATUS_SUCCESS;
8009 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008010 tANI_U8 oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
Srinivas Girigowdade697412013-02-14 16:31:48 -08008011 tANI_U8 newChannelList[128] = {0};
8012 tANI_U8 i = 0, j = 0;
8013
8014 status = sme_AcquireGlobalLock( &pMac->sme );
8015 if ( HAL_STATUS_SUCCESS( status ) )
8016 {
8017 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
8018 {
8019 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
8020 {
8021 j += snprintf(oldChannelList + j, sizeof(oldChannelList) - j," %d",
8022 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
8023 }
8024 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008025 csrFlushBgScanRoamChannelList(pMac);
8026 csrCreateBgScanRoamChannelList(pMac, pChannelList, numChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08008027 status = csrUpdateBgScanConfigIniChannelList(pMac, csrGetCurrentBand(hHal));
8028
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008029 if ( HAL_STATUS_SUCCESS( status ))
Srinivas Girigowdade697412013-02-14 16:31:48 -08008030 {
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008031 sme_SetRoamScanControl(hHal, 1);
8032 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -08008033 {
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008034 j = 0;
8035 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
8036 {
8037 j += snprintf(newChannelList + j, sizeof(newChannelList) - j," %d",
8038 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
8039 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08008040 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08008041
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008042 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8043 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
8044 newChannelList, oldChannelList,
8045 pMac->roam.neighborRoamInfo.neighborRoamState);
8046 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08008047 sme_ReleaseGlobalLock( &pMac->sme );
8048 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07008049#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8050 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8051 {
8052 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
8053 }
8054#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08008055
8056 return status ;
8057}
8058
8059/*--------------------------------------------------------------------------
8060 \brief sme_ChangeCountryValidChannelListByRevision() - Change Korea valid channel list
8061 based on country revision number
8062 This is a synchronous call
8063 \param hHal - The handle returned by macOpen.
8064 \return eHAL_STATUS_SUCCESS - SME update config successful.
8065 Other status means SME is failed to update
8066 \sa
8067 --------------------------------------------------------------------------*/
8068eHalStatus sme_ChangeCountryValidChannelListByRevision(tHalHandle hHal,
8069 tANI_U8 Revision)
8070{
8071 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8072 eHalStatus status = eHAL_STATUS_SUCCESS;
8073
8074 status = sme_AcquireGlobalLock( &pMac->sme );
8075 if ( HAL_STATUS_SUCCESS( status ) )
8076 {
8077 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8078 "LFR runtime successfully set country/revision to %s/%d - old value is %s/%d - roam state is %d",
8079 "KR", Revision, "KR",
8080 pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.revision,
8081 pMac->roam.neighborRoamInfo.neighborRoamState);
8082 csr_SetRevision(pMac, Revision);
8083 csrInitCountryValidChannelList(pMac, Revision);
8084 sme_ReleaseGlobalLock( &pMac->sme );
8085 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07008086#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8087 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8088 {
8089 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_VALID_CHANNEL_LIST_CHANGED);
8090 }
8091#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08008092
8093 return status ;
8094}
8095
8096
8097/*--------------------------------------------------------------------------
8098 \brief csrUpdateBgScanConfigIniChannelList() - Update bgscan roam cache
8099 This is a synchronous call
8100 \param hHal - The handle returned by macOpen.
8101 \return eHAL_STATUS_SUCCESS - SME update config successful.
8102 Other status means SME is failed to update
8103 \sa
8104 --------------------------------------------------------------------------*/
8105eHalStatus sme_UpdateBgScanConfigIniChannelList(tHalHandle hHal,
8106 eCsrBand eBand)
8107{
8108 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8109 return csrUpdateBgScanConfigIniChannelList(pMac, eBand);
8110}
8111
8112/*--------------------------------------------------------------------------
8113 \brief sme_getRoamScanChannelList() - get roam scan channel list
8114 This is a synchronous call
8115 \param hHal - The handle returned by macOpen.
8116 \return eHAL_STATUS_SUCCESS - SME update config successful.
8117 Other status means SME is failed to update
8118 \sa
8119 --------------------------------------------------------------------------*/
8120eHalStatus sme_getRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
8121 tANI_U8 *pNumChannels)
8122{
8123 int i = 0;
8124 tANI_U8 *pOutPtr = pChannelList;
8125 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8126 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8127 eHalStatus status = eHAL_STATUS_SUCCESS;
8128
8129 status = sme_AcquireGlobalLock( &pMac->sme );
8130 if ( HAL_STATUS_SUCCESS( status ) )
8131 {
8132 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
8133 {
8134 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
8135 "Roam Scan channel list is NOT yet initialized");
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008136 *pNumChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08008137 sme_ReleaseGlobalLock( &pMac->sme );
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008138 return status;
Srinivas Girigowdade697412013-02-14 16:31:48 -08008139 }
8140
8141 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
8142 for (i = 0; i < (*pNumChannels); i++)
8143 {
8144 pOutPtr[i] = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
8145 }
8146 pOutPtr[i] = '\0';
8147 sme_ReleaseGlobalLock( &pMac->sme );
8148 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08008149 return status ;
8150}
8151
8152/*--------------------------------------------------------------------------
8153 \brief sme_GetCountryRevision() - get Country revision index
8154 This is a synchronous call
8155 \param hHal - The handle returned by macOpen.
8156 \return eHAL_STATUS_SUCCESS - SME update config successful.
8157 Other status means SME is failed to update
8158 \sa
8159 --------------------------------------------------------------------------*/
8160eHalStatus sme_GetCountryRevision(tHalHandle hHal, tANI_U8 *pRevision)
8161{
8162 /* this is valid for Country KR only now */
8163 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8164 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8165 eHalStatus status = eHAL_STATUS_SUCCESS;
8166
8167 *pRevision = pNeighborRoamInfo->cfgParams.countryChannelInfo.revision;
8168
8169 return status;
8170}
8171
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008172/*--------------------------------------------------------------------------
8173 \brief sme_getIsCcxFeatureEnabled() - get CCX feature enabled or not
8174 This is a synchronuous call
8175 \param hHal - The handle returned by macOpen.
8176 \return TRUE (1) - if the CCX feature is enabled
8177 FALSE (0) - if feature is disabled (compile or runtime)
8178 \sa
8179 --------------------------------------------------------------------------*/
8180tANI_BOOLEAN sme_getIsCcxFeatureEnabled(tHalHandle hHal)
Srinivas Girigowdade697412013-02-14 16:31:48 -08008181{
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008182#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdade697412013-02-14 16:31:48 -08008183 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008184 return pMac->roam.configParam.isCcxIniFeatureEnabled;
8185#else
8186 return eANI_BOOLEAN_FALSE;
8187#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08008188}
8189
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008190/*--------------------------------------------------------------------------
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008191 \brief sme_GetRoamScanControl() - get scan control
8192 This is a synchronous call
8193 \param hHal - The handle returned by macOpen.
8194 \return v_BOOL_t - Enabled(1)/Disabled(0)
8195 \sa
8196 --------------------------------------------------------------------------*/
8197v_BOOL_t sme_GetRoamScanControl(tHalHandle hHal)
8198{
8199 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8200 return pMac->roam.configParam.nRoamScanControl;
8201}
8202#endif
8203
8204/*--------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008205 \brief sme_getIsLfrFeatureEnabled() - get LFR feature enabled or not
8206 This is a synchronuous call
8207 \param hHal - The handle returned by macOpen.
8208 \return TRUE (1) - if the feature is enabled
8209 FALSE (0) - if feature is disabled (compile or runtime)
8210 \sa
8211 --------------------------------------------------------------------------*/
8212tANI_BOOLEAN sme_getIsLfrFeatureEnabled(tHalHandle hHal)
8213{
8214#ifdef FEATURE_WLAN_LFR
8215 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8216 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
8217#else
8218 return eANI_BOOLEAN_FALSE;
8219#endif
8220}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08008221
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008222/*--------------------------------------------------------------------------
8223 \brief sme_getIsFtFeatureEnabled() - get FT feature enabled or not
8224 This is a synchronuous call
8225 \param hHal - The handle returned by macOpen.
8226 \return TRUE (1) - if the feature is enabled
8227 FALSE (0) - if feature is disabled (compile or runtime)
8228 \sa
8229 --------------------------------------------------------------------------*/
8230tANI_BOOLEAN sme_getIsFtFeatureEnabled(tHalHandle hHal)
8231{
8232#ifdef WLAN_FEATURE_VOWIFI_11R
8233 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8234 return pMac->roam.configParam.isFastTransitionEnabled;
8235#else
8236 return eANI_BOOLEAN_FALSE;
8237#endif
8238}
8239
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08008240
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008241/* ---------------------------------------------------------------------------
8242 \fn sme_IsFeatureSupportedByFW
8243 \brief Check if an feature is enabled by FW
8244
8245 \param feattEnumValue - Enumeration value from placeHolderInCapBitmap
8246 \- return 1/0 (TRUE/FALSE)
8247 -------------------------------------------------------------------------*/
8248tANI_U8 sme_IsFeatureSupportedByFW(tANI_U8 featEnumValue)
8249{
8250 return IS_FEATURE_SUPPORTED_BY_FW(featEnumValue);
8251}
8252#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308253
8254/* ---------------------------------------------------------------------------
8255 \fn sme_SendTdlsMgmtFrame
8256 \brief API to send TDLS management frames.
8257
8258 \param peerMac - peer's Mac Adress.
8259 \param tdlsLinkEstablishParams - TDLS Peer Link Establishment Parameters
8260 \- return VOS_STATUS_SUCCES
8261 -------------------------------------------------------------------------*/
8262VOS_STATUS sme_SendTdlsLinkEstablishParams(tHalHandle hHal,
8263 tANI_U8 sessionId,
8264 tSirMacAddr peerMac,
8265 tCsrTdlsLinkEstablishParams *tdlsLinkEstablishParams)
8266{
8267 eHalStatus status = eHAL_STATUS_SUCCESS;
8268 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8269
8270 status = sme_AcquireGlobalLock( &pMac->sme );
8271
8272 if ( HAL_STATUS_SUCCESS( status ) )
8273 {
8274 status = csrTdlsSendLinkEstablishParams(hHal, sessionId, peerMac, tdlsLinkEstablishParams) ;
8275 sme_ReleaseGlobalLock( &pMac->sme );
8276 }
8277 return status ;
8278}
8279
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008280/* ---------------------------------------------------------------------------
8281 \fn sme_SendTdlsMgmtFrame
8282 \brief API to send TDLS management frames.
8283
8284 \param peerMac - peer's Mac Adress.
8285 \param frame_type - Type of TDLS mgmt frame to be sent.
8286 \param dialog - dialog token used in the frame.
8287 \param status - status to be incuded in the frame.
8288 \param buf - additional IEs to be included
8289 \param len - lenght of additional Ies
Hoonki Leea34dd892013-02-05 22:56:02 -08008290 \param responder - Tdls request type
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008291 \- return VOS_STATUS_SUCCES
8292 -------------------------------------------------------------------------*/
8293VOS_STATUS sme_SendTdlsMgmtFrame(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08008294 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 -08008295{
8296 eHalStatus status = eHAL_STATUS_SUCCESS;
8297 tCsrTdlsSendMgmt sendTdlsReq = {{0}} ;
8298 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8299
8300 status = sme_AcquireGlobalLock( &pMac->sme );
8301 if ( HAL_STATUS_SUCCESS( status ) )
8302 {
8303 vos_mem_copy(sendTdlsReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
8304 sendTdlsReq.frameType = frame_type;
8305 sendTdlsReq.buf = buf;
8306 sendTdlsReq.len = len;
8307 sendTdlsReq.dialog = dialog;
8308 sendTdlsReq.statusCode = statusCode;
Hoonki Leea34dd892013-02-05 22:56:02 -08008309 sendTdlsReq.responder = responder;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008310
8311 status = csrTdlsSendMgmtReq(hHal, sessionId, &sendTdlsReq) ;
8312
8313 sme_ReleaseGlobalLock( &pMac->sme );
8314 }
8315
8316 return status ;
8317
8318}
8319/* ---------------------------------------------------------------------------
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008320 \fn sme_ChangeTdlsPeerSta
8321 \brief API to Update TDLS peer sta parameters.
8322
8323 \param peerMac - peer's Mac Adress.
8324 \param staParams - Peer Station Parameters
8325 \- return VOS_STATUS_SUCCES
8326 -------------------------------------------------------------------------*/
8327VOS_STATUS sme_ChangeTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac,
8328 tCsrStaParams *pstaParams)
8329{
8330 eHalStatus status = eHAL_STATUS_SUCCESS;
8331 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8332
8333 status = sme_AcquireGlobalLock( &pMac->sme );
8334 if ( HAL_STATUS_SUCCESS( status ) )
8335 {
8336 status = csrTdlsChangePeerSta(hHal, sessionId, peerMac,pstaParams);
8337
8338 sme_ReleaseGlobalLock( &pMac->sme );
8339 }
8340
8341 return status ;
8342
8343}
8344
8345/* ---------------------------------------------------------------------------
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008346 \fn sme_AddTdlsPeerSta
8347 \brief API to Add TDLS peer sta entry.
8348
8349 \param peerMac - peer's Mac Adress.
8350 \- return VOS_STATUS_SUCCES
8351 -------------------------------------------------------------------------*/
8352VOS_STATUS sme_AddTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
8353{
8354 eHalStatus status = eHAL_STATUS_SUCCESS;
8355 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8356
8357 status = sme_AcquireGlobalLock( &pMac->sme );
8358 if ( HAL_STATUS_SUCCESS( status ) )
8359 {
8360 status = csrTdlsAddPeerSta(hHal, sessionId, peerMac);
8361
8362 sme_ReleaseGlobalLock( &pMac->sme );
8363 }
8364
8365 return status ;
8366
8367}
8368/* ---------------------------------------------------------------------------
8369 \fn sme_DeleteTdlsPeerSta
8370 \brief API to Delete TDLS peer sta entry.
8371
8372 \param peerMac - peer's Mac Adress.
8373 \- return VOS_STATUS_SUCCES
8374 -------------------------------------------------------------------------*/
8375VOS_STATUS sme_DeleteTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
8376{
8377 eHalStatus status = eHAL_STATUS_SUCCESS;
8378 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8379
8380 status = sme_AcquireGlobalLock( &pMac->sme );
8381 if ( HAL_STATUS_SUCCESS( status ) )
8382 {
8383 status = csrTdlsDelPeerSta(hHal, sessionId, peerMac) ;
8384
8385 sme_ReleaseGlobalLock( &pMac->sme );
8386 }
8387
8388 return status ;
8389
8390}
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07008391/* ---------------------------------------------------------------------------
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008392 \fn sme_SetTdlsPowerSaveProhibited
8393 \API to set/reset the isTdlsPowerSaveProhibited.
8394
8395 \- return void
8396 -------------------------------------------------------------------------*/
8397void sme_SetTdlsPowerSaveProhibited(tHalHandle hHal, v_BOOL_t val)
8398{
8399 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8400
8401 pMac->isTdlsPowerSaveProhibited = val;
8402 return;
8403}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008404#endif
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05308405/* ---------------------------------------------------------------------------
8406 \fn sme_IsPmcBmps
8407 \API to Check if PMC state is BMPS.
8408
8409 \- return v_BOOL_t
8410 -------------------------------------------------------------------------*/
8411v_BOOL_t sme_IsPmcBmps(tHalHandle hHal)
8412{
8413 return (BMPS == pmcGetPmcState(hHal));
8414}
8415
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008416#ifdef FEATURE_WLAN_TDLS_INTERNAL
8417/*
8418 * SME API to start TDLS discovery Procedure
8419 */
8420VOS_STATUS sme_StartTdlsDiscoveryReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
8421{
8422 VOS_STATUS status = VOS_STATUS_SUCCESS;
8423 tCsrTdlsDisRequest disReq = {{0}} ;
8424 vos_mem_copy(disReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
8425 status = csrTdlsDiscoveryReq(hHal, sessionId, &disReq) ;
8426
8427 return status ;
8428
8429}
8430
8431/*
8432 * Process TDLS discovery results
8433 */
8434v_U8_t sme_GetTdlsDiscoveryResult(tHalHandle hHal,
8435 tSmeTdlsDisResult *disResult, v_U8_t listType)
8436{
8437 tCsrTdlsPeerLinkinfo *peerLinkInfo = NULL ;
8438 tSirTdlsPeerInfo *peerInfo = NULL ;
8439 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8440 tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
8441 tDblLinkList *peerList = &disInfo->tdlsPotentialPeerList ;
8442 tListElem *pEntry = NULL ;
8443 v_U8_t peerCnt = 0 ;
8444
8445 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008446 ("TDLS peer count = %d"),disInfo->tdlsPeerCount ) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008447 pEntry = csrLLPeekHead( peerList, LL_ACCESS_LOCK );
8448 while(pEntry)
8449 {
8450 peerLinkInfo = GET_BASE_ADDR( pEntry, tCsrTdlsPeerLinkinfo,
8451 tdlsPeerStaLink) ;
8452 peerInfo = &peerLinkInfo->tdlsDisPeerInfo ;
8453
8454 switch(listType)
8455 {
8456 case TDLS_SETUP_LIST:
8457 {
8458 if(TDLS_LINK_SETUP_STATE == peerInfo->tdlsPeerState)
8459 {
8460 palCopyMemory(pMac->hHdd, disResult[peerCnt].tdlsPeerMac,
8461 peerInfo->peerMac, sizeof(tSirMacAddr)) ;
8462 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
8463 peerCnt++ ;
8464 }
8465 break ;
8466 }
8467 case TDLS_DIS_LIST:
8468 {
8469 palCopyMemory(pMac->hHdd, disResult[peerCnt].tdlsPeerMac,
8470 peerInfo->peerMac, sizeof(tSirMacAddr)) ;
8471 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
8472 peerCnt++ ;
8473 break ;
8474 }
8475 default:
8476 {
8477 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008478 ("unknown list type ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008479 break ;
8480 }
8481 }
8482
8483 pEntry = csrLLNext( peerList, pEntry, LL_ACCESS_LOCK) ;
8484 }
8485
8486 return peerCnt ;
8487
8488}
8489
8490/*
8491 * SME API to start TDLS link setup Procedure.
8492 */
8493VOS_STATUS sme_StartTdlsLinkSetupReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
8494{
8495 VOS_STATUS status = VOS_STATUS_SUCCESS;
8496 tCsrTdlsSetupRequest setupReq = {{0}} ;
8497 vos_mem_copy(setupReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
8498 status = csrTdlsSetupReq(hHal, sessionId, &setupReq) ;
8499 return status ;
8500
8501}
8502
8503/*
8504 * SME API to start TDLS link Teardown Procedure.
8505 */
8506VOS_STATUS sme_StartTdlsLinkTeardownReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
8507{
8508 VOS_STATUS status = VOS_STATUS_SUCCESS;
8509 tCsrTdlsTeardownRequest teardownReq = {{0}} ;
8510 vos_mem_copy(teardownReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
8511 status = csrTdlsTeardownReq(hHal, sessionId, &teardownReq) ;
8512 return status ;
8513
8514}
8515
8516#endif /* FEATURE_WLAN_TDLS */
8517
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07008518eHalStatus sme_UpdateDfsSetting(tHalHandle hHal, tANI_U8 fUpdateEnableDFSChnlScan)
8519{
8520 eHalStatus status = eHAL_STATUS_FAILURE;
8521 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8522
8523 smsLog(pMac, LOG2, FL("enter"));
8524 status = sme_AcquireGlobalLock( &pMac->sme );
8525 if ( HAL_STATUS_SUCCESS( status ) )
8526 {
8527 pMac->scan.fEnableDFSChnlScan = fUpdateEnableDFSChnlScan;
8528 sme_ReleaseGlobalLock( &pMac->sme );
8529 }
8530 smsLog(pMac, LOG2, FL("exit status %d"), status);
8531
8532 return (status);
8533}
8534
Gopichand Nakkalae620d5a2013-04-26 05:45:57 -07008535/*
8536 * SME API to enable/disable WLAN driver initiated SSR
8537 */
8538void sme_UpdateEnableSSR(tHalHandle hHal, tANI_BOOLEAN enableSSR)
8539{
8540 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8541 eHalStatus status = eHAL_STATUS_SUCCESS;
8542
8543 status = sme_AcquireGlobalLock(&pMac->sme);
8544 if (HAL_STATUS_SUCCESS(status))
8545 {
8546 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8547 "SSR level is changed %d", enableSSR);
8548 /* not serializing this messsage, as this is only going
8549 * to set a variable in WDA/WDI
8550 */
8551 WDA_SetEnableSSR(enableSSR);
8552 sme_ReleaseGlobalLock(&pMac->sme);
8553 }
8554 return;
8555}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07008556
8557/*
8558 * SME API to determine the channel bonding mode
8559 */
8560VOS_STATUS sme_SelectCBMode(tHalHandle hHal, eCsrPhyMode eCsrPhyMode, tANI_U8 channel)
8561{
8562 tSmeConfigParams smeConfig;
8563 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8564
8565 if (
8566#ifdef WLAN_FEATURE_11AC
8567 eCSR_DOT11_MODE_11ac != eCsrPhyMode &&
8568 eCSR_DOT11_MODE_11ac_ONLY != eCsrPhyMode &&
8569#endif
8570 eCSR_DOT11_MODE_11n != eCsrPhyMode &&
8571 eCSR_DOT11_MODE_11n_ONLY != eCsrPhyMode
8572 )
8573 {
8574 return VOS_STATUS_SUCCESS;
8575 }
8576
8577 /* If channel bonding mode is not required */
8578 if ( !pMac->roam.configParam.channelBondingMode5GHz ) {
8579 return VOS_STATUS_SUCCESS;
8580 }
8581
8582 vos_mem_zero(&smeConfig, sizeof (tSmeConfigParams));
8583 sme_GetConfigParam(pMac, &smeConfig);
8584
8585#ifdef WLAN_FEATURE_11AC
8586 if ( eCSR_DOT11_MODE_11ac == eCsrPhyMode ||
8587 eCSR_DOT11_MODE_11ac_ONLY == eCsrPhyMode )
8588 {
8589 if ( channel== 36 || channel == 52 || channel == 100 ||
8590 channel == 116 || channel == 149 )
8591 {
8592 smeConfig.csrConfig.channelBondingMode5GHz =
8593 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1;
8594 }
8595 else if ( channel == 40 || channel == 56 || channel == 104 ||
8596 channel == 120 || channel == 153 )
8597 {
8598 smeConfig.csrConfig.channelBondingMode5GHz =
8599 PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW - 1;
8600 }
8601 else if ( channel == 44 || channel == 60 || channel == 108 ||
8602 channel == 124 || channel == 157 )
8603 {
8604 smeConfig.csrConfig.channelBondingMode5GHz =
8605 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH -1;
8606 }
8607 else if ( channel == 48 || channel == 64 || channel == 112 ||
8608 channel == 128 || channel == 161 )
8609 {
8610 smeConfig.csrConfig.channelBondingMode5GHz =
8611 PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH - 1;
8612 }
8613 else if ( channel == 165 )
8614 {
8615 smeConfig.csrConfig.channelBondingMode5GHz = 0;
8616 }
8617 }
8618#endif
8619
8620 if ( eCSR_DOT11_MODE_11n == eCsrPhyMode ||
8621 eCSR_DOT11_MODE_11n_ONLY == eCsrPhyMode )
8622 {
8623 if ( channel== 40 || channel == 48 || channel == 56 ||
8624 channel == 64 || channel == 104 || channel == 112 ||
8625 channel == 120 || channel == 128 || channel == 136 ||
8626 channel == 144 || channel == 153 || channel == 161 )
8627 {
8628 smeConfig.csrConfig.channelBondingMode5GHz = 1;
8629 }
8630 else if ( channel== 36 || channel == 44 || channel == 52 ||
8631 channel == 60 || channel == 100 || channel == 108 ||
8632 channel == 116 || channel == 124 || channel == 132 ||
8633 channel == 140 || channel == 149 || channel == 157 )
8634 {
8635 smeConfig.csrConfig.channelBondingMode5GHz = 2;
8636 }
8637 else if ( channel == 165 )
8638 {
8639 smeConfig.csrConfig.channelBondingMode5GHz = 0;
8640 }
8641 }
8642 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8643 "cbmode selected=%ld\n", smeConfig.csrConfig.channelBondingMode5GHz);
8644
8645 sme_UpdateConfig (pMac, &smeConfig);
8646 return VOS_STATUS_SUCCESS;
8647}
8648
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07008649/*--------------------------------------------------------------------------
8650
8651 \brief sme_SetCurrDeviceMode() - Sets the current operating device mode.
8652 \param hHal - The handle returned by macOpen.
8653 \param currDeviceMode - Current operating device mode.
8654 --------------------------------------------------------------------------*/
8655
8656void sme_SetCurrDeviceMode (tHalHandle hHal, tVOS_CON_MODE currDeviceMode)
8657{
8658 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8659 pMac->sme.currDeviceMode = currDeviceMode;
8660 return;
8661}
8662
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008663#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8664/*--------------------------------------------------------------------------
8665 \brief sme_HandoffRequest() - a wrapper function to Request a handoff
8666 from CSR.
8667 This is a synchronous call
8668 \param hHal - The handle returned by macOpen
8669 \param pHandoffInfo - info provided by HDD with the handoff request (namely:
8670 BSSID, channel etc.)
8671 \return eHAL_STATUS_SUCCESS - SME passed the request to CSR successfully.
8672 Other status means SME is failed to send the request.
8673 \sa
8674 --------------------------------------------------------------------------*/
8675
8676eHalStatus sme_HandoffRequest(tHalHandle hHal,
8677 tCsrHandoffRequest *pHandoffInfo)
8678{
8679 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8680 eHalStatus status = eHAL_STATUS_SUCCESS;
8681
8682 status = sme_AcquireGlobalLock( &pMac->sme );
8683 if ( HAL_STATUS_SUCCESS( status ) )
8684 {
8685 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8686 "%s: invoked", __func__);
8687 status = csrHandoffRequest(pMac, pHandoffInfo);
8688 sme_ReleaseGlobalLock( &pMac->sme );
8689 }
8690
8691 return status ;
8692}
8693#endif
8694
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07008695/*
8696 * SME API to check if there is any infra station or
8697 * P2P client is connected
8698 */
8699VOS_STATUS sme_isSta_p2p_clientConnected(tHalHandle hHal)
8700{
8701 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8702 if(csrIsInfraConnected(pMac))
8703 {
8704 return VOS_STATUS_SUCCESS;
8705 }
8706 return VOS_STATUS_E_FAILURE;
8707}
8708