blob: 35d144515b2823f22b58c7ae9bb40f9c939dac14 [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
75#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
76#include "halInternal.h"
77#endif
78
79#include "smsDebug.h"
80#include "sme_Api.h"
81#include "csrInsideApi.h"
82#include "smeInside.h"
83#include "csrInternal.h"
84#include "wlan_qct_wda.h"
85#include "halMsgApi.h"
86
87#ifdef WLAN_SOFTAP_FEATURE
88#include "sapApi.h"
89#endif
90
91
92
93#if !defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
94extern tSirRetStatus uMacPostCtrlMsg(void* pSirGlobal, tSirMbMsg* pMb);
95
96#include <wlan_qct_pal_api.h>
97#endif
98
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -080099#define READ_MEMORY_DUMP_CMD 9
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -0800100
Jeff Johnson295189b2012-06-20 16:38:30 -0700101// TxMB Functions
102extern eHalStatus pmcPrepareCommand( tpAniSirGlobal pMac, eSmeCommandType cmdType, void *pvParam,
103 tANI_U32 size, tSmeCmd **ppCmd );
104extern void pmcReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
105extern void qosReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
106#if defined WLAN_FEATURE_P2P
107extern eHalStatus p2pProcessRemainOnChannelCmd(tpAniSirGlobal pMac, tSmeCmd *p2pRemainonChn);
108extern eHalStatus sme_remainOnChnRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg);
109extern eHalStatus sme_mgmtFrmInd( tHalHandle hHal, tpSirSmeMgmtFrameInd pSmeMgmtFrm);
110extern eHalStatus sme_remainOnChnReady( tHalHandle hHal, tANI_U8* pMsg);
111extern eHalStatus sme_sendActionCnf( tHalHandle hHal, tANI_U8* pMsg);
112extern eHalStatus p2pProcessNoAReq(tpAniSirGlobal pMac, tSmeCmd *pNoACmd);
113#endif
114
115static eHalStatus initSmeCmdList(tpAniSirGlobal pMac);
116static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping );
117
118eCsrPhyMode sme_GetPhyMode(tHalHandle hHal);
119
120eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf);
121
122eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal);
123
124eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal);
125
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -0700126#ifdef FEATURE_WLAN_LFR
127tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac);
128#endif
129
Jeff Johnson295189b2012-06-20 16:38:30 -0700130//Internal SME APIs
131eHalStatus sme_AcquireGlobalLock( tSmeStruct *psSme)
132{
133 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
134
135 if(psSme)
136 {
137 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psSme->lkSmeGlobalLock) ) )
138 {
139 status = eHAL_STATUS_SUCCESS;
140 }
141 }
142
143 return (status);
144}
145
146
147eHalStatus sme_ReleaseGlobalLock( tSmeStruct *psSme)
148{
149 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
150
151 if(psSme)
152 {
153 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psSme->lkSmeGlobalLock) ) )
154 {
155 status = eHAL_STATUS_SUCCESS;
156 }
157 }
158
159 return (status);
160}
161
162
163
164static eHalStatus initSmeCmdList(tpAniSirGlobal pMac)
165{
166 eHalStatus status;
167 tSmeCmd *pCmd;
168
169 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
170 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdActiveList)))
171 {
172 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdPendingList)))
173 {
174 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdFreeList)))
175 {
176 status = palAllocateMemory(pMac->hHdd, (void **)&pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
177 if(HAL_STATUS_SUCCESS(status))
178 {
179 tANI_U32 c;
180
181 palZeroMemory(pMac->hHdd, pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
182 pMac->sme.pSmeCmdBufAddr = pCmd;
183 for(c = 0; c < pMac->sme.totalSmeCmd; c++)
184 {
185 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd[c].Link, LL_ACCESS_LOCK);
186 }
187 }
188 }
189 }
190 }
191
192 return (status);
193}
194
195
196void smeReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCmd)
197{
198 pCmd->command = eSmeNoCommand;
199 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd->Link, LL_ACCESS_LOCK);
200}
201
202
203
204static void smeReleaseCmdList(tpAniSirGlobal pMac, tDblLinkList *pList)
205{
206 tListElem *pEntry;
207 tSmeCmd *pCommand;
208
209 while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_LOCK)) != NULL)
210 {
211 //TODO: base on command type to call release functions
212 //reinitialize different command types so they can be reused
213 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
214 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
215 }
216}
217
218static void purgeSmeCmdList(tpAniSirGlobal pMac)
219{
220 //release any out standing commands back to free command list
221 smeReleaseCmdList(pMac, &pMac->sme.smeCmdPendingList);
222 smeReleaseCmdList(pMac, &pMac->sme.smeCmdActiveList);
223}
224
225void purgeSmeSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
226{
227 //release any out standing commands back to free command list
228 tListElem *pEntry, *pNext;
229 tSmeCmd *pCommand;
230 tDblLinkList *pList = &pMac->sme.smeCmdPendingList;
231 tDblLinkList localList;
232
233 vos_mem_zero(&localList, sizeof(tDblLinkList));
234 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
235 {
236 smsLog(pMac, LOGE, FL(" failed to open list"));
237 return;
238 }
239
240 csrLLLock(pList);
241 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
242 while(pEntry != NULL)
243 {
244 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
245 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
246 if(pCommand->sessionId == sessionId)
247 {
248 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
249 {
250 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
251 }
252 }
253 pEntry = pNext;
254 }
255 csrLLUnlock(pList);
256
257 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
258 {
259 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
260 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
261 }
262 csrLLClose(&localList);
263
264}
265
266
267static eHalStatus freeSmeCmdList(tpAniSirGlobal pMac)
268{
269 eHalStatus status = eHAL_STATUS_SUCCESS;
270
271 purgeSmeCmdList(pMac);
272 csrLLClose(&pMac->sme.smeCmdPendingList);
273 csrLLClose(&pMac->sme.smeCmdActiveList);
274 csrLLClose(&pMac->sme.smeCmdFreeList);
275
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800276 status = vos_lock_acquire(&pMac->sme.lkSmeGlobalLock);
277 if(status != eHAL_STATUS_SUCCESS)
278 {
279 smsLog(pMac, LOGE,
280 FL("Failed to acquire the lock status = %d\n"), status);
281 goto done;
282 }
283
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 if(NULL != pMac->sme.pSmeCmdBufAddr)
285 {
286 status = palFreeMemory(pMac->hHdd, pMac->sme.pSmeCmdBufAddr);
287 pMac->sme.pSmeCmdBufAddr = NULL;
288 }
289
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800290 status = vos_lock_release(&pMac->sme.lkSmeGlobalLock);
291 if(status != eHAL_STATUS_SUCCESS)
292 {
293 smsLog(pMac, LOGE,
294 FL("Failed to release the lock status = %d\n"), status);
295 }
296done:
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 return (status);
298}
299
300
301void dumpCsrCommandInfo(tpAniSirGlobal pMac, tSmeCmd *pCmd)
302{
303#ifdef WLAN_DEBUG
304 switch( pCmd->command )
305 {
306 case eSmeCommandScan:
307 smsLog( pMac, LOGE, " scan command reason is %d", pCmd->u.scanCmd.reason );
308 break;
309
310 case eSmeCommandRoam:
311 smsLog( pMac, LOGE, " roam command reason is %d", pCmd->u.roamCmd.roamReason );
312 break;
313
314 case eSmeCommandWmStatusChange:
315 smsLog( pMac, LOGE, " WMStatusChange command type is %d", pCmd->u.wmStatusChangeCmd.Type );
316 break;
317
318 case eSmeCommandSetKey:
319 smsLog( pMac, LOGE, " setKey command auth(%d) enc(%d)",
320 pCmd->u.setKeyCmd.authType, pCmd->u.setKeyCmd.encType );
321 break;
322
323 case eSmeCommandRemoveKey:
324 smsLog( pMac, LOGE, " removeKey command auth(%d) enc(%d)",
325 pCmd->u.removeKeyCmd.authType, pCmd->u.removeKeyCmd.encType );
326 break;
327
328 default:
329 break;
330 }
331#endif //#ifdef WLAN_DEBUG
332}
333
334tSmeCmd *smeGetCommandBuffer( tpAniSirGlobal pMac )
335{
336 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
337 tListElem *pEntry;
338
339 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK );
340
341 // If we can get another MS Msg buffer, then we are ok. Just link
342 // the entry onto the linked list. (We are using the linked list
343 // to keep track of tfhe message buffers).
344 if ( pEntry )
345 {
346 pRetCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
347 }
348 else {
349 int idx = 1;
350
351 //Cannot change pRetCmd here since it needs to return later.
352 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
353 if( pEntry )
354 {
355 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
356 }
357 smsLog( pMac, LOGE, "Out of command buffer.... command (0x%X) stuck\n",
358 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
359 if(pTempCmd)
360 {
361 if( eSmeCsrCommandMask & pTempCmd->command )
362 {
363 //CSR command is stuck. See what the reason code is for that command
364 dumpCsrCommandInfo(pMac, pTempCmd);
365 }
366 } //if(pTempCmd)
367
368 //dump what is in the pending queue
369 csrLLLock(&pMac->sme.smeCmdPendingList);
370 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
371 while(pEntry)
372 {
373 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
374 smsLog( pMac, LOGE, "Out of command buffer.... SME pending command #%d (0x%X)\n",
375 idx++, pTempCmd->command );
376 if( eSmeCsrCommandMask & pTempCmd->command )
377 {
378 //CSR command is stuck. See what the reason code is for that command
379 dumpCsrCommandInfo(pMac, pTempCmd);
380 }
381 pEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
382 }
383 csrLLUnlock(&pMac->sme.smeCmdPendingList);
384
385 //There may be some more command in CSR's own pending queue
386 csrLLLock(&pMac->roam.roamCmdPendingList);
387 pEntry = csrLLPeekHead( &pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK );
388 while(pEntry)
389 {
390 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
391 smsLog( pMac, LOGE, "Out of command buffer.... CSR pending command #%d (0x%X)\n",
392 idx++, pTempCmd->command );
393 dumpCsrCommandInfo(pMac, pTempCmd);
394 pEntry = csrLLNext( &pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
395 }
396 csrLLUnlock(&pMac->roam.roamCmdPendingList);
397 }
398
399 return( pRetCmd );
400}
401
402
403void smePushCommand( tpAniSirGlobal pMac, tSmeCmd *pCmd, tANI_BOOLEAN fHighPriority )
404{
405 if ( fHighPriority )
406 {
407 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
408 }
409 else
410 {
411 csrLLInsertTail( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
412 }
413
414 // process the command queue...
415 smeProcessPendingQueue( pMac );
416
417 return;
418}
419
420
421static eSmeCommandType smeIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand )
422{
423 eSmeCommandType pmcCommand = eSmeNoCommand;
424 tANI_BOOLEAN fFullPowerNeeded = eANI_BOOLEAN_FALSE;
425 tPmcState pmcState;
426 eHalStatus status;
427
428 do
429 {
430 pmcState = pmcGetPmcState(pMac);
431
432 status = csrIsFullPowerNeeded( pMac, pCommand, NULL, &fFullPowerNeeded );
433 if( !HAL_STATUS_SUCCESS(status) )
434 {
435 //PMC state is not right for the command, drop it
436 return ( eSmeDropCommand );
437 }
438 if( fFullPowerNeeded ) break;
439 fFullPowerNeeded = ( ( eSmeCommandAddTs == pCommand->command ) ||
440 ( eSmeCommandDelTs == pCommand->command ) );
441 if( fFullPowerNeeded ) break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700442#ifdef FEATURE_OEM_DATA_SUPPORT
443 fFullPowerNeeded = (pmcState == IMPS &&
444 eSmeCommandOemDataReq == pCommand->command);
445 if(fFullPowerNeeded) break;
446#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700447#ifdef WLAN_FEATURE_P2P
448 fFullPowerNeeded = (pmcState == IMPS &&
449 eSmeCommandRemainOnChannel == pCommand->command);
450 if(fFullPowerNeeded) break;
451#endif
452 } while(0);
453
454 if( fFullPowerNeeded )
455 {
456 switch( pmcState )
457 {
458 case IMPS:
459 case STANDBY:
460 pmcCommand = eSmeCommandExitImps;
461 break;
462
463 case BMPS:
464 pmcCommand = eSmeCommandExitBmps;
465 break;
466
467 case UAPSD:
468 pmcCommand = eSmeCommandExitUapsd;
469 break;
470
471 case WOWL:
472 pmcCommand = eSmeCommandExitWowl;
473 break;
474
475 default:
476 break;
477 }
478 }
479
480 return ( pmcCommand );
481}
482
483
484//For commands that need to do extra cleanup.
485static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
486{
487 if( eSmePmcCommandMask & pCommand->command )
488 {
489 pmcAbortCommand( pMac, pCommand, fStopping );
490 }
491 else if ( eSmeCsrCommandMask & pCommand->command )
492 {
493 csrAbortCommand( pMac, pCommand, fStopping );
494 }
495 else
496 {
497 switch( pCommand->command )
498 {
499#ifdef WLAN_FEATURE_P2P
500 case eSmeCommandRemainOnChannel:
501 if (NULL != pCommand->u.remainChlCmd.callback)
502 {
503 remainOnChanCallback callback =
504 pCommand->u.remainChlCmd.callback;
505 /* process the msg */
506 if( callback )
507 {
508 callback(pMac, pCommand->u.remainChlCmd.callbackCtx,
509 eCSR_SCAN_ABORT );
510 }
511 }
512 smeReleaseCommand( pMac, pCommand );
513 break;
514#endif
515 default:
516 smeReleaseCommand( pMac, pCommand );
517 break;
518 }
519 }
520}
521
522
523
524tANI_BOOLEAN smeProcessCommand( tpAniSirGlobal pMac )
525{
526 tANI_BOOLEAN fContinue = eANI_BOOLEAN_FALSE;
527 eHalStatus status = eHAL_STATUS_SUCCESS;
528 tListElem *pEntry;
529 tSmeCmd *pCommand;
530 eSmeCommandType pmcCommand = eSmeNoCommand;
531
532 // if the ActiveList is empty, then nothing is active so we can process a
533 // pending command...
534 //alwasy lock active list before locking pending list
535 csrLLLock( &pMac->sme.smeCmdActiveList );
536 if ( csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) )
537 {
538 if(!csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK))
539 {
540 //Peek the command
541 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK );
542 if( pEntry )
543 {
544 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
545 //We cannot execute any command in wait-for-key state until setKey is through.
546 if( CSR_IS_WAIT_FOR_KEY( pMac, pCommand->sessionId ) )
547 {
548 if( !CSR_IS_SET_KEY_COMMAND( pCommand ) )
549 {
550 csrLLUnlock( &pMac->sme.smeCmdActiveList );
551 smsLog(pMac, LOGE, " Cannot process command(%d) while waiting for key\n", pCommand->command);
552 return ( eANI_BOOLEAN_FALSE );
553 }
554 }
555 pmcCommand = smeIsFullPowerNeeded( pMac, pCommand );
556 if( eSmeDropCommand == pmcCommand )
557 {
558 //This command is not ok for current PMC state
559 if( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
560 {
561 smeAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE );
562 }
563 csrLLUnlock( &pMac->sme.smeCmdActiveList );
564 //tell caller to continue
565 return (eANI_BOOLEAN_TRUE);
566 }
567 else if( eSmeNoCommand != pmcCommand )
568 {
569 tExitBmpsInfo exitBmpsInfo;
570 void *pv = NULL;
571 tANI_U32 size = 0;
572 tSmeCmd *pPmcCmd = NULL;
573
574 if( eSmeCommandExitBmps == pmcCommand )
575 {
576 exitBmpsInfo.exitBmpsReason = eSME_REASON_OTHER;
577 pv = (void *)&exitBmpsInfo;
578 size = sizeof(tExitBmpsInfo);
579 }
580 //pmcCommand has to be one of the exit power save command
581 status = pmcPrepareCommand( pMac, pmcCommand, pv, size, &pPmcCmd );
582 if( HAL_STATUS_SUCCESS( status ) && pPmcCmd )
583 {
584 //Force this command to wake up the chip
585 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK );
586 csrLLUnlock( &pMac->sme.smeCmdActiveList );
587 fContinue = pmcProcessCommand( pMac, pPmcCmd );
588 if( fContinue )
589 {
590 //The command failed, remove it
591 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK ) )
592 {
593 pmcReleaseCommand( pMac, pPmcCmd );
594 }
595 }
596 }
597 else
598 {
599 csrLLUnlock( &pMac->sme.smeCmdActiveList );
600 smsLog( pMac, LOGE, FL( "Cannot issue command(0x%X) to wake up the chip. Status = %d\n"), pmcCommand, status );
601 //Let it retry
602 fContinue = eANI_BOOLEAN_TRUE;
603 }
604 return fContinue;
605 }
606 if ( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
607 {
608 // we can reuse the pCommand
609
610 // Insert the command onto the ActiveList...
611 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pCommand->Link, LL_ACCESS_NOLOCK );
612
613 // .... and process the command.
614
615 switch ( pCommand->command )
616 {
617
618 case eSmeCommandScan:
619 csrLLUnlock( &pMac->sme.smeCmdActiveList );
620 status = csrProcessScanCommand( pMac, pCommand );
621 break;
622
623 case eSmeCommandRoam:
624 csrLLUnlock( &pMac->sme.smeCmdActiveList );
625 status = csrRoamProcessCommand( pMac, pCommand );
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800626 if(!HAL_STATUS_SUCCESS(status))
627 {
628 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
629 &pCommand->Link, LL_ACCESS_LOCK ) )
630 {
631 csrReleaseCommandRoam( pMac, pCommand );
632 }
633 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 break;
635
636 case eSmeCommandWmStatusChange:
637 csrLLUnlock( &pMac->sme.smeCmdActiveList );
638 csrRoamProcessWmStatusChangeCommand(pMac, pCommand);
639 break;
640
641 case eSmeCommandSetKey:
642 csrLLUnlock( &pMac->sme.smeCmdActiveList );
643 status = csrRoamProcessSetKeyCommand( pMac, pCommand );
644 if(!HAL_STATUS_SUCCESS(status))
645 {
646 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
647 &pCommand->Link, LL_ACCESS_LOCK ) )
648 {
649 csrReleaseCommandSetKey( pMac, pCommand );
650 }
651 }
652 break;
653
654 case eSmeCommandRemoveKey:
655 csrLLUnlock( &pMac->sme.smeCmdActiveList );
656 status = csrRoamProcessRemoveKeyCommand( pMac, pCommand );
657 if(!HAL_STATUS_SUCCESS(status))
658 {
659 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
660 &pCommand->Link, LL_ACCESS_LOCK ) )
661 {
662 csrReleaseCommandRemoveKey( pMac, pCommand );
663 }
664 }
665 break;
666
667 case eSmeCommandAddStaSession:
668 csrLLUnlock( &pMac->sme.smeCmdActiveList );
669 csrProcessAddStaSessionCommand( pMac, pCommand );
670 break;
671 case eSmeCommandDelStaSession:
672 csrLLUnlock( &pMac->sme.smeCmdActiveList );
673 csrProcessDelStaSessionCommand( pMac, pCommand );
674 break;
675
Jeff Johnsone7245742012-09-05 17:12:55 -0700676#ifdef FEATURE_OEM_DATA_SUPPORT
677 case eSmeCommandOemDataReq:
678 csrLLUnlock(&pMac->sme.smeCmdActiveList);
679 oemData_ProcessOemDataReqCommand(pMac, pCommand);
680 break;
681#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700682#if defined WLAN_FEATURE_P2P
683 case eSmeCommandRemainOnChannel:
684 csrLLUnlock(&pMac->sme.smeCmdActiveList);
685 p2pProcessRemainOnChannelCmd(pMac, pCommand);
686 break;
687 case eSmeCommandNoAUpdate:
688 csrLLUnlock( &pMac->sme.smeCmdActiveList );
689 p2pProcessNoAReq(pMac,pCommand);
690#endif
691 case eSmeCommandEnterImps:
692 case eSmeCommandExitImps:
693 case eSmeCommandEnterBmps:
694 case eSmeCommandExitBmps:
695 case eSmeCommandEnterUapsd:
696 case eSmeCommandExitUapsd:
697 case eSmeCommandEnterWowl:
698 case eSmeCommandExitWowl:
699 csrLLUnlock( &pMac->sme.smeCmdActiveList );
700 fContinue = pmcProcessCommand( pMac, pCommand );
701 if( fContinue )
702 {
703 //The command failed, remove it
704 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
705 &pCommand->Link, LL_ACCESS_LOCK ) )
706 {
707 pmcReleaseCommand( pMac, pCommand );
708 }
709 }
710 break;
711
712 //Treat standby differently here because caller may not be able to handle
713 //the failure so we do our best here
714 case eSmeCommandEnterStandby:
715 if( csrIsConnStateDisconnected( pMac, pCommand->sessionId ) )
716 {
717 //It can continue
718 csrLLUnlock( &pMac->sme.smeCmdActiveList );
719 fContinue = pmcProcessCommand( pMac, pCommand );
720 if( fContinue )
721 {
722 //The command failed, remove it
723 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
724 &pCommand->Link, LL_ACCESS_LOCK ) )
725 {
726 pmcReleaseCommand( pMac, pCommand );
727 }
728 }
729 }
730 else
731 {
732 //Need to issue a disconnect first before processing this command
733 tSmeCmd *pNewCmd;
734
735 //We need to re-run the command
736 fContinue = eANI_BOOLEAN_TRUE;
737 //Pull off the standby command first
738 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
739 &pCommand->Link, LL_ACCESS_NOLOCK ) )
740 {
741 csrLLUnlock( &pMac->sme.smeCmdActiveList );
742 //Need to call CSR function here because the disconnect command
743 //is handled by CSR
744 pNewCmd = csrGetCommandBuffer( pMac );
745 if( NULL != pNewCmd )
746 {
747 //Put the standby command to the head of the pending list first
748 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCommand->Link,
749 LL_ACCESS_LOCK );
750 pNewCmd->command = eSmeCommandRoam;
751 pNewCmd->u.roamCmd.roamReason = eCsrForcedDisassoc;
752 //Put the disassoc command before the standby command
753 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pNewCmd->Link,
754 LL_ACCESS_LOCK );
755 }
756 else
757 {
758 //Continue the command here
759 fContinue = pmcProcessCommand( pMac, pCommand );
760 if( fContinue )
761 {
762 //The command failed, remove it
763 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
764 &pCommand->Link, LL_ACCESS_LOCK ) )
765 {
766 pmcReleaseCommand( pMac, pCommand );
767 }
768 }
769 }
770 }
771 else
772 {
773 csrLLUnlock( &pMac->sme.smeCmdActiveList );
774 smsLog( pMac, LOGE, FL(" failed to remove standby command\n") );
775 VOS_ASSERT(0);
776 }
777 }
778 break;
779
780 case eSmeCommandAddTs:
781 case eSmeCommandDelTs:
782 csrLLUnlock( &pMac->sme.smeCmdActiveList );
783#ifndef WLAN_MDM_CODE_REDUCTION_OPT
784 fContinue = qosProcessCommand( pMac, pCommand );
785 if( fContinue )
786 {
787 //The command failed, remove it
788 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
789 &pCommand->Link, LL_ACCESS_NOLOCK ) )
790 {
791//#ifndef WLAN_MDM_CODE_REDUCTION_OPT
792 qosReleaseCommand( pMac, pCommand );
793//#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
794 }
795 }
796#endif
797 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800798#ifdef FEATURE_WLAN_TDLS
799 case eSmeCommandTdlsSendMgmt:
800 case eSmeCommandTdlsAddPeer:
801 case eSmeCommandTdlsDelPeer:
802#ifdef FEATURE_WLAN_TDLS_INTERNAL
803 case eSmeCommandTdlsDiscovery:
804 case eSmeCommandTdlsLinkSetup:
805 case eSmeCommandTdlsLinkTear:
806 case eSmeCommandTdlsEnterUapsd:
807 case eSmeCommandTdlsExitUapsd:
808#endif
809 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800810 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800811 "sending TDLS Command 0x%x to PE\n", pCommand->command);
812
813 csrLLUnlock( &pMac->sme.smeCmdActiveList );
814 status = csrTdlsProcessCmd( pMac, pCommand );
815 }
816 break ;
817#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700818
819 default:
820 //something is wrong
821 //remove it from the active list
822 smsLog(pMac, LOGE, " csrProcessCommand processes an unknown command %d\n", pCommand->command);
823 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK );
824 csrLLUnlock( &pMac->sme.smeCmdActiveList );
825 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
826 smeReleaseCommand( pMac, pCommand );
827 status = eHAL_STATUS_FAILURE;
828 break;
829 }
830 if(!HAL_STATUS_SUCCESS(status))
831 {
832 fContinue = eANI_BOOLEAN_TRUE;
833 }
834 }//if(pEntry)
835 else
836 {
837 //This is odd. Some one else pull off the command.
838 csrLLUnlock( &pMac->sme.smeCmdActiveList );
839 }
840 }
841 else
842 {
843 csrLLUnlock( &pMac->sme.smeCmdActiveList );
844 }
845 }
846 else
847 {
848 //No command waiting
849 csrLLUnlock( &pMac->sme.smeCmdActiveList );
850 //This is only used to restart an idle mode scan, it means at least one other idle scan has finished.
851 if(pMac->scan.fRestartIdleScan && eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
852 {
853 tANI_U32 nTime = 0;
854
855 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
856 if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime)))
857 {
858 csrScanStartIdleScanTimer(pMac, nTime);
859 }
860 }
861 }
862 }
863 else {
864 csrLLUnlock( &pMac->sme.smeCmdActiveList );
865 }
866
867 return ( fContinue );
868}
869
870void smeProcessPendingQueue( tpAniSirGlobal pMac )
871{
872 while( smeProcessCommand( pMac ) );
873}
874
875
876tANI_BOOLEAN smeCommandPending(tpAniSirGlobal pMac)
877{
878 return ( !csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) ||
879 !csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK) );
880}
881
882
883
884//Global APIs
885
886/*--------------------------------------------------------------------------
887
888 \brief sme_Open() - Initialze all SME modules and put them at idle state
889
890 The function initializes each module inside SME, PMC, CCM, CSR, etc. . Upon
891 successfully return, all modules are at idle state ready to start.
892
893 smeOpen must be called before any other SME APIs can be involved.
894 smeOpen must be called after macOpen.
Srinivas Girigowdade697412013-02-14 16:31:48 -0800895 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 \param hHal - The handle returned by macOpen.
897
898 \return eHAL_STATUS_SUCCESS - SME is successfully initialized.
899
900 Other status means SME is failed to be initialized
901 \sa
902
903 --------------------------------------------------------------------------*/
904eHalStatus sme_Open(tHalHandle hHal)
905{
906 eHalStatus status = eHAL_STATUS_FAILURE;
907 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
908
909 do {
910 pMac->sme.state = SME_STATE_STOP;
911 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->sme.lkSmeGlobalLock ) ) )
912 {
913 smsLog( pMac, LOGE, "sme_Open failed init lock\n" );
914 status = eHAL_STATUS_FAILURE;
915 break;
916 }
917
918 status = ccmOpen(hHal);
919 if ( ! HAL_STATUS_SUCCESS( status ) ) {
920 smsLog( pMac, LOGE,
921 "ccmOpen failed during initialization with status=%d", status );
922 break;
923 }
924
925 status = csrOpen(pMac);
926 if ( ! HAL_STATUS_SUCCESS( status ) ) {
927 smsLog( pMac, LOGE,
928 "csrOpen failed during initialization with status=%d", status );
929 break;
930 }
931
932 status = pmcOpen(hHal);
933 if ( ! HAL_STATUS_SUCCESS( status ) ) {
934 smsLog( pMac, LOGE,
935 "pmcOpen failed during initialization with status=%d", status );
936 break;
937 }
938
939#ifndef WLAN_MDM_CODE_REDUCTION_OPT
940 status = sme_QosOpen(pMac);
941 if ( ! HAL_STATUS_SUCCESS( status ) ) {
942 smsLog( pMac, LOGE,
943 "Qos open failed during initialization with status=%d", status );
944 break;
945 }
946
947 status = btcOpen(pMac);
948 if ( ! HAL_STATUS_SUCCESS( status ) ) {
949 smsLog( pMac, LOGE,
950 "btcOpen open failed during initialization with status=%d", status );
951 break;
952 }
953#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700954#ifdef FEATURE_OEM_DATA_SUPPORT
955 status = oemData_OemDataReqOpen(pMac);
956 if ( ! HAL_STATUS_SUCCESS( status ) ) {
957 smsLog(pMac, LOGE,
958 "oemData_OemDataReqOpen failed during initialization with status=%d", status );
959 break;
960 }
961#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700962
963 if(!HAL_STATUS_SUCCESS((status = initSmeCmdList(pMac))))
964 break;
965
966#ifdef WLAN_SOFTAP_FEATURE
967 {
968 v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SAP, NULL);
969 if ( NULL == pvosGCtx ){
970 smsLog( pMac, LOGE, "WLANSAP_Open open failed during initialization");
971 status = eHAL_STATUS_FAILURE;
972 break;
973 }
974
975 status = WLANSAP_Open( pvosGCtx );
976 if ( ! HAL_STATUS_SUCCESS( status ) ) {
977 smsLog( pMac, LOGE,
978 "WLANSAP_Open open failed during initialization with status=%d", status );
979 break;
980 }
981 }
982#endif
983#if defined WLAN_FEATURE_VOWIFI
984 status = rrmOpen(pMac);
985 if ( ! HAL_STATUS_SUCCESS( status ) ) {
986 smsLog( pMac, LOGE,
987 "rrmOpen open failed during initialization with status=%d", status );
988 break;
989 }
990#endif
991
992#if defined WLAN_FEATURE_VOWIFI_11R
993 sme_FTOpen(pMac);
994#endif
995#if defined WLAN_FEATURE_P2P
996 sme_p2pOpen(pMac);
997#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800998#ifdef FEATURE_WLAN_TDLS
999 status = csrTdlsOpen(pMac) ;
1000 if ( ! HAL_STATUS_SUCCESS( status ) )
1001 {
1002 smsLog( pMac, LOGE, "Tdlspen open failed during initialization with \
1003 status=%d\n", status );
1004 break;
1005 }
1006#endif
1007
Jeff Johnson295189b2012-06-20 16:38:30 -07001008
1009 }while (0);
1010
1011 return status;
1012}
1013
1014#ifdef WLAN_SOFTAP_FEATURE
1015/*--------------------------------------------------------------------------
1016
1017 \brief sme_set11dinfo() - Set the 11d information about valid channels
1018 and there power using information from nvRAM
1019 This function is called only for AP.
1020
Srinivas Girigowdade697412013-02-14 16:31:48 -08001021 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001022
1023 \param hHal - The handle returned by macOpen.
1024 \Param pSmeConfigParams - a pointer to a caller allocated object of
1025 typedef struct _smeConfigParams.
1026
1027 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1028
1029 Other status means SME is failed to update the config parameters.
1030 \sa
1031--------------------------------------------------------------------------*/
1032
1033eHalStatus sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1034{
1035 eHalStatus status = eHAL_STATUS_FAILURE;
1036 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1037
1038 if (NULL == pSmeConfigParams ) {
1039 smsLog( pMac, LOGE,
1040 "Empty config param structure for SME, nothing to update");
1041 return status;
1042 }
1043
1044 status = csrSetChannels(hHal, &pSmeConfigParams->csrConfig );
1045 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1046 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d\n",
1047 status );
1048 }
1049 return status;
1050}
1051
1052/*--------------------------------------------------------------------------
1053
1054 \brief sme_getSoftApDomain() - Get the current regulatory domain of softAp.
1055
Srinivas Girigowdade697412013-02-14 16:31:48 -08001056 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001057
1058 \param hHal - The handle returned by HostapdAdapter.
1059 \Param v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
1060
1061 \return eHAL_STATUS_SUCCESS - SME successfully completed the request.
1062
1063 Other status means, failed to get the current regulatory domain.
1064 \sa
1065--------------------------------------------------------------------------*/
1066
1067eHalStatus sme_getSoftApDomain(tHalHandle hHal, v_REGDOMAIN_t *domainIdSoftAp)
1068{
1069 eHalStatus status = eHAL_STATUS_FAILURE;
1070 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1071
1072 if (NULL == domainIdSoftAp ) {
1073 smsLog( pMac, LOGE, "Uninitialized domain Id");
1074 return status;
1075 }
1076
1077 *domainIdSoftAp = pMac->scan.domainIdCurrent;
1078 status = eHAL_STATUS_SUCCESS;
1079
1080 return status;
1081}
1082
1083
1084eHalStatus sme_setRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
1085{
1086 eHalStatus status = eHAL_STATUS_FAILURE;
1087 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1088
1089 if (NULL == apCntryCode ) {
1090 smsLog( pMac, LOGE, "Empty Country Code, nothing to update");
1091 return status;
1092 }
1093
1094 status = csrSetRegInfo(hHal, apCntryCode );
1095 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1096 smsLog( pMac, LOGE, "csrSetRegInfo failed with status=%d\n",
1097 status );
1098 }
1099 return status;
1100}
1101
1102#endif
1103#ifdef FEATURE_WLAN_SCAN_PNO
1104/*--------------------------------------------------------------------------
1105
1106 \brief sme_UpdateChannelConfig() - Update channel configuration in RIVA.
1107
1108 It is used at driver start up to inform RIVA of the default channel
1109 configuration.
1110
Srinivas Girigowdade697412013-02-14 16:31:48 -08001111 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001112
1113 \param hHal - The handle returned by macOpen.
1114
1115 \return eHAL_STATUS_SUCCESS - SME update the channel config successfully.
1116
1117 Other status means SME is failed to update the channel config.
1118 \sa
1119
1120 --------------------------------------------------------------------------*/
1121eHalStatus sme_UpdateChannelConfig(tHalHandle hHal)
1122{
1123 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1124
1125 pmcUpdateScanParams( pMac, &(pMac->roam.configParam),
1126 &pMac->scan.base20MHzChannels, FALSE);
1127 return eHAL_STATUS_SUCCESS;
1128}
1129#endif // FEATURE_WLAN_SCAN_PNLO
1130
1131/*--------------------------------------------------------------------------
1132
1133 \brief sme_UpdateConfig() - Change configurations for all SME moduels
1134
1135 The function updates some configuration for modules in SME, CCM, CSR, etc
1136 during SMEs close open sequence.
1137
1138 Modules inside SME apply the new configuration at the next transaction.
1139
Srinivas Girigowdade697412013-02-14 16:31:48 -08001140 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001141
1142 \param hHal - The handle returned by macOpen.
1143 \Param pSmeConfigParams - a pointer to a caller allocated object of
1144 typedef struct _smeConfigParams.
1145
1146 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1147
1148 Other status means SME is failed to update the config parameters.
1149 \sa
1150
1151 --------------------------------------------------------------------------*/
1152eHalStatus sme_UpdateConfig(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1153{
1154 eHalStatus status = eHAL_STATUS_FAILURE;
1155 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1156
1157 if (NULL == pSmeConfigParams ) {
1158 smsLog( pMac, LOGE,
1159 "Empty config param structure for SME, nothing to update");
1160 return status;
1161 }
1162
1163 status = csrChangeDefaultConfigParam(pMac, &pSmeConfigParams->csrConfig);
1164
1165 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1166 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d\n",
1167 status );
1168 }
1169#if defined WLAN_FEATURE_P2P_INTERNAL
1170 status = p2pChangeDefaultConfigParam(pMac, &pSmeConfigParams->p2pConfig);
1171
1172 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1173 smsLog( pMac, LOGE, "p2pChangeDefaultConfigParam failed with status=%d\n",
1174 status );
1175 }
1176#endif
1177#if defined WLAN_FEATURE_VOWIFI
1178 status = rrmChangeDefaultConfigParam(hHal, &pSmeConfigParams->rrmConfig);
1179
1180 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1181 smsLog( pMac, LOGE, "rrmChangeDefaultConfigParam failed with status=%d\n",
1182 status );
1183 }
1184#endif
1185 //For SOC, CFG is set before start
1186 //We don't want to apply global CFG in connect state because that may cause some side affect
1187 if(
1188#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
1189 //For the new init sequence, CFGs need to apply before vos_start is call
1190 //No need to wait for ready state.
1191 SME_IS_READY(pMac) &&
1192#endif
1193 csrIsAllSessionDisconnected( pMac) )
1194 {
1195 csrSetGlobalCfgs(pMac);
1196 }
1197
1198 return status;
1199}
1200
1201/* ---------------------------------------------------------------------------
1202 \fn sme_ChangeConfigParams
1203 \brief The SME API exposed for HDD to provide config params to SME during
1204 SMEs stop -> start sequence.
1205
1206 If HDD changed the domain that will cause a reset. This function will
1207 provide the new set of 11d information for the new domain. Currrently this
1208 API provides info regarding 11d only at reset but we can extend this for
1209 other params (PMC, QoS) which needs to be initialized again at reset.
1210
Srinivas Girigowdade697412013-02-14 16:31:48 -08001211 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001212
1213 \param hHal - The handle returned by macOpen.
1214
1215 \Param
1216 pUpdateConfigParam - a pointer to a structure (tCsrUpdateConfigParam) that
1217 currently provides 11d related information like Country code,
1218 Regulatory domain, valid channel list, Tx power per channel, a
1219 list with active/passive scan allowed per valid channel.
1220
1221 \return eHalStatus
1222 ---------------------------------------------------------------------------*/
1223eHalStatus sme_ChangeConfigParams(tHalHandle hHal,
1224 tCsrUpdateConfigParam *pUpdateConfigParam)
1225{
1226 eHalStatus status = eHAL_STATUS_FAILURE;
1227 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1228
1229 if (NULL == pUpdateConfigParam ) {
1230 smsLog( pMac, LOGE,
1231 "Empty config param structure for SME, nothing to reset\n");
1232 return status;
1233 }
1234
1235 status = csrChangeConfigParams(pMac, pUpdateConfigParam);
1236
1237 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1238 smsLog( pMac, LOGE, "csrUpdateConfigParam failed with status=%d\n",
1239 status );
1240 }
1241
1242 return status;
1243
1244}
1245
1246/*--------------------------------------------------------------------------
1247
1248 \brief sme_HDDReadyInd() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1249 that the NIC is ready tio run.
1250
1251 The function is called by HDD at the end of initialization stage so PE/HAL can
1252 enable the NIC to running state.
1253
Srinivas Girigowdade697412013-02-14 16:31:48 -08001254 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 \param hHal - The handle returned by macOpen.
1256
1257 \return eHAL_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1258 successfully.
1259
1260 Other status means SME failed to send the message to PE.
1261 \sa
1262
1263 --------------------------------------------------------------------------*/
1264eHalStatus sme_HDDReadyInd(tHalHandle hHal)
1265{
1266 tSirSmeReadyReq Msg;
1267 eHalStatus status = eHAL_STATUS_FAILURE;
1268 tPmcPowerState powerState;
1269 tPmcSwitchState hwWlanSwitchState;
1270 tPmcSwitchState swWlanSwitchState;
1271 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1272
1273 do
1274 {
1275#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
1276 csrSetGlobalCfgs( pMac );
1277#endif
1278
1279 Msg.messageType = eWNI_SME_SYS_READY_IND;
1280 Msg.length = sizeof( tSirSmeReadyReq );
1281
1282 if (eSIR_FAILURE != uMacPostCtrlMsg( hHal, (tSirMbMsg*)&Msg ))
1283 {
1284 status = eHAL_STATUS_SUCCESS;
1285 }
1286 else
1287 {
1288 smsLog( pMac, LOGE,
1289 "uMacPostCtrlMsg failed to send eWNI_SME_SYS_READY_IND");
1290 break;
1291 }
1292
1293 status = pmcQueryPowerState( hHal, &powerState,
1294 &hwWlanSwitchState, &swWlanSwitchState );
1295 if ( ! HAL_STATUS_SUCCESS( status ) )
1296 {
1297 smsLog( pMac, LOGE, "pmcQueryPowerState failed with status=%d\n",
1298 status );
1299 break;
1300 }
1301
1302 if ( (ePMC_SWITCH_OFF != hwWlanSwitchState) &&
1303 (ePMC_SWITCH_OFF != swWlanSwitchState) )
1304 {
1305 status = csrReady(pMac);
1306 if ( ! HAL_STATUS_SUCCESS( status ) )
1307 {
1308 smsLog( pMac, LOGE, "csrReady failed with status=%d\n", status );
1309 break;
1310 }
1311 status = pmcReady(hHal);
1312 if ( ! HAL_STATUS_SUCCESS( status ) )
1313 {
1314 smsLog( pMac, LOGE, "pmcReady failed with status=%d\n", status );
1315 break;
1316 }
1317#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1318 if(VOS_STATUS_SUCCESS != btcReady(hHal))
1319 {
1320 status = eHAL_STATUS_FAILURE;
1321 smsLog( pMac, LOGE, "btcReady failed\n");
1322 break;
1323 }
1324#endif
1325
1326#if defined WLAN_FEATURE_VOWIFI
1327 if(VOS_STATUS_SUCCESS != rrmReady(hHal))
1328 {
1329 status = eHAL_STATUS_FAILURE;
1330 smsLog( pMac, LOGE, "rrmReady failed\n");
1331 break;
1332 }
1333#endif
1334 }
1335 pMac->sme.state = SME_STATE_READY;
1336 } while( 0 );
1337
1338 return status;
1339}
1340
1341/*--------------------------------------------------------------------------
1342
1343 \brief sme_Start() - Put all SME modules at ready state.
1344
1345 The function starts each module in SME, PMC, CCM, CSR, etc. . Upon
1346 successfully return, all modules are ready to run.
Srinivas Girigowdade697412013-02-14 16:31:48 -08001347 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 \param hHal - The handle returned by macOpen.
1349
1350 \return eHAL_STATUS_SUCCESS - SME is ready.
1351
1352 Other status means SME is failed to start
1353 \sa
1354
1355 --------------------------------------------------------------------------*/
1356eHalStatus sme_Start(tHalHandle hHal)
1357{
1358 eHalStatus status = eHAL_STATUS_FAILURE;
1359 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1360
1361 do
1362 {
1363#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
1364 ccmStart(hHal);
1365#endif
1366 status = csrStart(pMac);
1367 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1368 smsLog( pMac, LOGE, "csrStart failed during smeStart with status=%d\n",
1369 status );
1370 break;
1371 }
1372
1373 status = pmcStart(hHal);
1374 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1375 smsLog( pMac, LOGE, "pmcStart failed during smeStart with status=%d\n",
1376 status );
1377 break;
1378 }
1379
1380#ifdef WLAN_SOFTAP_FEATURE
1381 status = WLANSAP_Start(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1382 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1383 smsLog( pMac, LOGE, "WLANSAP_Start failed during smeStart with status=%d\n",
1384 status );
1385 break;
1386 }
1387#endif
1388 pMac->sme.state = SME_STATE_START;
1389 }while (0);
1390
1391 return status;
1392}
1393
1394
1395#ifdef WLAN_FEATURE_PACKET_FILTERING
1396/******************************************************************************
1397*
1398* Name: sme_PCFilterMatchCountResponseHandler
1399*
1400* Description:
1401* Invoke Packet Coalescing Filter Match Count callback routine
1402*
1403* Parameters:
1404* hHal - HAL handle for device
1405* pMsg - Pointer to tRcvFltPktMatchRsp structure
1406*
1407* Returns: eHalStatus
1408*
1409******************************************************************************/
1410eHalStatus sme_PCFilterMatchCountResponseHandler(tHalHandle hHal, void* pMsg)
1411{
1412 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1413 eHalStatus status = eHAL_STATUS_SUCCESS;
1414 tpSirRcvFltPktMatchRsp pRcvFltPktMatchRsp = (tpSirRcvFltPktMatchRsp)pMsg;
1415
1416 if (NULL == pMsg)
1417 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001418 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 status = eHAL_STATUS_FAILURE;
1420 }
1421 else
1422 {
1423 smsLog(pMac, LOG2, "SME: entering "
1424 "sme_FilterMatchCountResponseHandler\n");
1425
1426 /* Call Packet Coalescing Filter Match Count callback routine. */
1427 if (pMac->pmc.FilterMatchCountCB != NULL)
1428 pMac->pmc.FilterMatchCountCB(pMac->pmc.FilterMatchCountCBContext,
1429 pRcvFltPktMatchRsp);
1430
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001431 smsLog(pMac, LOG1, "%s: status=0x%x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 pRcvFltPktMatchRsp->status);
1433
1434 pMac->pmc.FilterMatchCountCB = NULL;
1435 pMac->pmc.FilterMatchCountCBContext = NULL;
1436 }
1437
1438 return(status);
1439}
1440#endif // WLAN_FEATURE_PACKET_FILTERING
1441
1442
1443/*--------------------------------------------------------------------------
1444
1445 \brief sme_ProcessMsg() - The main message processor for SME.
1446
1447 The function is called by a message dispatcher when to process a message
1448 targeted for SME.
1449
Srinivas Girigowdade697412013-02-14 16:31:48 -08001450 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001451 \param hHal - The handle returned by macOpen.
1452 \param pMsg - A pointer to a caller allocated object of tSirMsgQ.
1453
1454 \return eHAL_STATUS_SUCCESS - SME successfully process the message.
1455
1456 Other status means SME failed to process the message to HAL.
1457 \sa
1458
1459 --------------------------------------------------------------------------*/
1460eHalStatus sme_ProcessMsg(tHalHandle hHal, vos_msg_t* pMsg)
1461{
1462 eHalStatus status = eHAL_STATUS_FAILURE;
1463 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1464
1465 if (pMsg == NULL) {
1466 smsLog( pMac, LOGE, "Empty message for SME, nothing to process\n");
1467 return status;
1468 }
1469
1470 status = sme_AcquireGlobalLock( &pMac->sme );
1471 if ( HAL_STATUS_SUCCESS( status ) )
1472 {
1473 if( SME_IS_START(pMac) )
1474 {
1475 switch (pMsg->type) { // TODO: Will be modified to do a range check for msgs instead of having cases for each msgs
1476 case eWNI_PMC_ENTER_BMPS_RSP:
1477 case eWNI_PMC_EXIT_BMPS_RSP:
1478 case eWNI_PMC_EXIT_BMPS_IND:
1479 case eWNI_PMC_ENTER_IMPS_RSP:
1480 case eWNI_PMC_EXIT_IMPS_RSP:
1481 case eWNI_PMC_SMPS_STATE_IND:
1482 case eWNI_PMC_ENTER_UAPSD_RSP:
1483 case eWNI_PMC_EXIT_UAPSD_RSP:
1484 case eWNI_PMC_ENTER_WOWL_RSP:
1485 case eWNI_PMC_EXIT_WOWL_RSP:
1486 //PMC
1487 if (pMsg->bodyptr)
1488 {
1489 pmcMessageProcessor(hHal, pMsg->bodyptr);
1490 status = eHAL_STATUS_SUCCESS;
1491 vos_mem_free( pMsg->bodyptr );
1492 } else {
1493 smsLog( pMac, LOGE, "Empty rsp message for PMC, nothing to process\n");
1494 }
1495 break;
1496
1497 case WNI_CFG_SET_CNF:
1498 case WNI_CFG_DNLD_CNF:
1499 case WNI_CFG_GET_RSP:
1500 case WNI_CFG_ADD_GRP_ADDR_CNF:
1501 case WNI_CFG_DEL_GRP_ADDR_CNF:
1502 //CCM
1503 if (pMsg->bodyptr)
1504 {
1505 ccmCfgCnfMsgHandler(hHal, pMsg->bodyptr);
1506 status = eHAL_STATUS_SUCCESS;
1507 vos_mem_free( pMsg->bodyptr );
1508 } else {
1509 smsLog( pMac, LOGE, "Empty rsp message for CCM, nothing to process\n");
1510 }
1511 break;
1512
1513 case eWNI_SME_ADDTS_RSP:
1514 case eWNI_SME_DELTS_RSP:
1515 case eWNI_SME_DELTS_IND:
1516#ifdef WLAN_FEATURE_VOWIFI_11R
1517 case eWNI_SME_FT_AGGR_QOS_RSP:
1518#endif
1519 //QoS
1520 if (pMsg->bodyptr)
1521 {
1522#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1523 status = sme_QosMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
1524 vos_mem_free( pMsg->bodyptr );
1525#endif
1526 } else {
1527 smsLog( pMac, LOGE, "Empty rsp message for QoS, nothing to process\n");
1528 }
1529 break;
1530#if defined WLAN_FEATURE_VOWIFI
1531 case eWNI_SME_NEIGHBOR_REPORT_IND:
1532 case eWNI_SME_BEACON_REPORT_REQ_IND:
1533#if defined WLAN_VOWIFI_DEBUG
1534 smsLog( pMac, LOGE, "Received RRM message. Message Id = %d\n", pMsg->type );
1535#endif
1536 if ( pMsg->bodyptr )
1537 {
1538 status = sme_RrmMsgProcessor( pMac, pMsg->type, pMsg->bodyptr );
1539 vos_mem_free( pMsg->bodyptr );
1540 }
1541 else
1542 {
1543 smsLog( pMac, LOGE, "Empty message for RRM, nothing to process\n");
1544 }
1545 break;
1546#endif
1547
Jeff Johnsone7245742012-09-05 17:12:55 -07001548#ifdef FEATURE_OEM_DATA_SUPPORT
1549 //Handle the eWNI_SME_OEM_DATA_RSP:
1550 case eWNI_SME_OEM_DATA_RSP:
1551 if(pMsg->bodyptr)
1552 {
1553 status = sme_HandleOemDataRsp(pMac, pMsg->bodyptr);
1554 vos_mem_free(pMsg->bodyptr);
1555 }
1556 else
1557 {
1558 smsLog( pMac, LOGE, "Empty rsp message for oemData_ (eWNI_SME_OEM_DATA_RSP), nothing to process\n");
1559 }
1560 smeProcessPendingQueue( pMac );
1561 break;
1562#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001563
1564 case eWNI_SME_ADD_STA_SELF_RSP:
1565 if(pMsg->bodyptr)
1566 {
1567 status = csrProcessAddStaSessionRsp(pMac, pMsg->bodyptr);
1568 vos_mem_free(pMsg->bodyptr);
1569 }
1570 else
1571 {
1572 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ADD_STA_SELF_RSP), nothing to process\n");
1573 }
1574 break;
1575 case eWNI_SME_DEL_STA_SELF_RSP:
1576 if(pMsg->bodyptr)
1577 {
1578 status = csrProcessDelStaSessionRsp(pMac, pMsg->bodyptr);
1579 vos_mem_free(pMsg->bodyptr);
1580 }
1581 else
1582 {
1583 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_DEL_STA_SELF_RSP), nothing to process\n");
1584 }
1585 break;
1586#ifdef WLAN_FEATURE_P2P
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 case eWNI_SME_REMAIN_ON_CHN_RSP:
1588 if(pMsg->bodyptr)
1589 {
1590 status = sme_remainOnChnRsp(pMac, pMsg->bodyptr);
1591 vos_mem_free(pMsg->bodyptr);
1592 }
1593 else
1594 {
1595 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RSP), nothing to process\n");
1596 }
1597 break;
1598 case eWNI_SME_REMAIN_ON_CHN_RDY_IND:
1599 if(pMsg->bodyptr)
1600 {
1601 status = sme_remainOnChnReady(pMac, pMsg->bodyptr);
1602 vos_mem_free(pMsg->bodyptr);
1603 }
1604 else
1605 {
1606 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RDY_IND), nothing to process\n");
1607 }
1608 break;
1609 case eWNI_SME_MGMT_FRM_IND:
1610 if(pMsg->bodyptr)
1611 {
1612 sme_mgmtFrmInd(pMac, pMsg->bodyptr);
1613 vos_mem_free(pMsg->bodyptr);
1614 }
1615 else
1616 {
1617 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_MGMT_FRM_IND), nothing to process\n");
1618 }
1619 break;
1620 case eWNI_SME_ACTION_FRAME_SEND_CNF:
1621 if(pMsg->bodyptr)
1622 {
1623 status = sme_sendActionCnf(pMac, pMsg->bodyptr);
1624 vos_mem_free(pMsg->bodyptr);
1625 }
1626 else
1627 {
1628 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ACTION_FRAME_SEND_CNF), nothing to process\n");
1629 }
1630 break;
1631#endif
1632 case eWNI_SME_COEX_IND:
1633 if(pMsg->bodyptr)
1634 {
1635 status = btcHandleCoexInd((void *)pMac, pMsg->bodyptr);
1636 vos_mem_free(pMsg->bodyptr);
1637 }
1638 else
1639 {
1640 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process\n");
1641 }
1642 break;
1643
1644#ifdef FEATURE_WLAN_SCAN_PNO
1645 case eWNI_SME_PREF_NETWORK_FOUND_IND:
1646 if(pMsg->bodyptr)
1647 {
1648 status = sme_PreferredNetworkFoundInd((void *)pMac, pMsg->bodyptr);
1649 vos_mem_free(pMsg->bodyptr);
1650 }
1651 else
1652 {
1653 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_PREF_NETWORK_FOUND_IND), nothing to process\n");
1654 }
1655 break;
1656#endif // FEATURE_WLAN_SCAN_PNO
1657
1658 case eWNI_SME_TX_PER_HIT_IND:
1659 if (pMac->sme.pTxPerHitCallback)
1660 {
1661 pMac->sme.pTxPerHitCallback(pMac->sme.pTxPerHitCbContext);
1662 }
1663 break;
1664
1665 case eWNI_SME_CHANGE_COUNTRY_CODE:
1666 if(pMsg->bodyptr)
1667 {
1668 status = sme_HandleChangeCountryCode((void *)pMac, pMsg->bodyptr);
1669 vos_mem_free(pMsg->bodyptr);
1670 }
1671 else
1672 {
1673 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process\n");
1674 }
1675 break;
1676
1677#ifdef WLAN_FEATURE_PACKET_FILTERING
1678 case eWNI_PMC_PACKET_COALESCING_FILTER_MATCH_COUNT_RSP:
1679 if(pMsg->bodyptr)
1680 {
1681 status = sme_PCFilterMatchCountResponseHandler((void *)pMac, pMsg->bodyptr);
1682 vos_mem_free(pMsg->bodyptr);
1683 }
1684 else
1685 {
1686 smsLog(pMac, LOGE, "Empty rsp message for meas "
1687 "(PACKET_COALESCING_FILTER_MATCH_COUNT_RSP), nothing to process\n");
1688 }
1689 break;
1690#endif // WLAN_FEATURE_PACKET_FILTERING
1691 case eWNI_SME_PRE_SWITCH_CHL_IND:
1692 {
1693 status = sme_HandlePreChannelSwitchInd(pMac);
1694 break;
1695 }
1696
1697 case eWNI_SME_POST_SWITCH_CHL_IND:
1698 {
1699 status = sme_HandlePostChannelSwitchInd(pMac);
1700 break;
1701 }
1702
1703#ifdef WLAN_WAKEUP_EVENTS
1704 case eWNI_SME_WAKE_REASON_IND:
1705 if(pMsg->bodyptr)
1706 {
1707 status = sme_WakeReasonIndCallback((void *)pMac, pMsg->bodyptr);
1708 vos_mem_free(pMsg->bodyptr);
1709 }
1710 else
1711 {
1712 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_WAKE_REASON_IND), nothing to process\n");
1713 }
1714 break;
1715#endif // WLAN_WAKEUP_EVENTS
1716
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001717#ifdef FEATURE_WLAN_TDLS
1718 /*
1719 * command rescived from PE, SME tdls msg processor shall be called
1720 * to process commands recieved from PE
1721 */
1722 case eWNI_SME_TDLS_SEND_MGMT_RSP:
1723 case eWNI_SME_TDLS_ADD_STA_RSP:
Hoonki Leee6bfe942013-02-05 15:01:19 -08001724 case eWNI_SME_TDLS_DEL_STA_RSP:
1725 case eWNI_SME_TDLS_DEL_STA_IND:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001726 case eWNI_SME_TDLS_DEL_ALL_PEER_IND:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001727#ifdef FEATURE_WLAN_TDLS_INTERNAL
1728 case eWNI_SME_TDLS_DISCOVERY_START_RSP:
1729 case eWNI_SME_TDLS_DISCOVERY_START_IND:
1730 case eWNI_SME_TDLS_LINK_START_RSP:
1731 case eWNI_SME_TDLS_LINK_START_IND:
1732 case eWNI_SME_TDLS_TEARDOWN_RSP:
1733 case eWNI_SME_TDLS_TEARDOWN_IND:
1734 case eWNI_SME_ADD_TDLS_PEER_IND:
1735 case eWNI_SME_DELETE_TDLS_PEER_IND:
1736#endif
1737 {
1738 if (pMsg->bodyptr)
1739 {
1740 status = tdlsMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
1741 vos_mem_free( pMsg->bodyptr );
1742 }
1743 else
1744 {
1745 smsLog( pMac, LOGE, "Empty rsp message for TDLS, \
1746 nothing to process\n");
1747 }
1748 break;
1749 }
1750#endif
1751
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 default:
1753
1754 if ( ( pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN )
1755 && ( pMsg->type <= eWNI_SME_MSG_TYPES_END ) )
1756 {
1757 //CSR
1758 if (pMsg->bodyptr)
1759 {
1760 status = csrMsgProcessor(hHal, pMsg->bodyptr);
1761 vos_mem_free( pMsg->bodyptr );
1762 }
1763 else
1764 {
1765 smsLog( pMac, LOGE, "Empty rsp message for CSR, nothing to process\n");
1766 }
1767 }
1768 else
1769 {
1770 smsLog( pMac, LOGW, "Unknown message type %d, nothing to process\n",
1771 pMsg->type);
1772 if (pMsg->bodyptr)
1773 {
1774 vos_mem_free( pMsg->bodyptr );
1775 }
1776 }
1777 }//switch
1778 } //SME_IS_START
1779 else
1780 {
1781 smsLog( pMac, LOGW, "message type %d in stop state ignored\n", pMsg->type);
1782 if (pMsg->bodyptr)
1783 {
1784 vos_mem_free( pMsg->bodyptr );
1785 }
1786 }
1787 sme_ReleaseGlobalLock( &pMac->sme );
1788 }
1789 else
1790 {
1791 smsLog( pMac, LOGW, "Locking failed, bailing out\n");
1792 if (pMsg->bodyptr)
1793 {
1794 vos_mem_free( pMsg->bodyptr );
1795 }
1796 }
1797
1798 return status;
1799}
1800
1801
1802//No need to hold the global lock here because this function can only be called
1803//after sme_Stop.
1804v_VOID_t sme_FreeMsg( tHalHandle hHal, vos_msg_t* pMsg )
1805{
1806 if( pMsg )
1807 {
1808 if (pMsg->bodyptr)
1809 {
1810 vos_mem_free( pMsg->bodyptr );
1811 }
1812 }
1813
1814}
1815
1816
1817/*--------------------------------------------------------------------------
1818
1819 \brief sme_Stop() - Stop all SME modules and put them at idle state
1820
1821 The function stops each module in SME, PMC, CCM, CSR, etc. . Upon
1822 return, all modules are at idle state ready to start.
1823
Srinivas Girigowdade697412013-02-14 16:31:48 -08001824 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 \param hHal - The handle returned by macOpen
1826
1827 \return eHAL_STATUS_SUCCESS - SME is stopped.
1828
1829 Other status means SME is failed to stop but caller should still
1830 consider SME is stopped.
1831 \sa
1832
1833 --------------------------------------------------------------------------*/
1834eHalStatus sme_Stop(tHalHandle hHal, tANI_BOOLEAN pmcFlag)
1835{
1836 eHalStatus status = eHAL_STATUS_FAILURE;
1837 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
1838 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1839
1840#ifdef WLAN_SOFTAP_FEATURE
1841 status = WLANSAP_Stop(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1842 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1843 smsLog( pMac, LOGE, "WLANSAP_Stop failed during smeStop with status=%d\n",
1844 status );
1845 fail_status = status;
1846 }
1847#endif
1848
1849 p2pStop(hHal);
1850
1851 if(pmcFlag)
1852 {
1853 status = pmcStop(hHal);
1854 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1855 smsLog( pMac, LOGE, "pmcStop failed during smeStop with status=%d\n",
1856 status );
1857 fail_status = status;
1858 }
1859 }
1860
1861 status = csrStop(pMac);
1862 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1863 smsLog( pMac, LOGE, "csrStop failed during smeStop with status=%d\n",
1864 status );
1865 fail_status = status;
1866 }
1867
1868 ccmStop(hHal);
1869
1870 purgeSmeCmdList(pMac);
1871
1872 if (!HAL_STATUS_SUCCESS( fail_status )) {
1873 status = fail_status;
1874 }
1875
1876 pMac->sme.state = SME_STATE_STOP;
1877
1878 return status;
1879}
1880
1881/*--------------------------------------------------------------------------
1882
1883 \brief sme_Close() - Release all SME modules and their resources.
1884
1885 The function release each module in SME, PMC, CCM, CSR, etc. . Upon
1886 return, all modules are at closed state.
1887
1888 No SME APIs can be involved after smeClose except smeOpen.
1889 smeClose must be called before macClose.
Srinivas Girigowdade697412013-02-14 16:31:48 -08001890 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 \param hHal - The handle returned by macOpen
1892
1893 \return eHAL_STATUS_SUCCESS - SME is successfully close.
1894
1895 Other status means SME is failed to be closed but caller still cannot
1896 call any other SME functions except smeOpen.
1897 \sa
1898
1899 --------------------------------------------------------------------------*/
1900eHalStatus sme_Close(tHalHandle hHal)
1901{
1902 eHalStatus status = eHAL_STATUS_FAILURE;
1903 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
1904 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1905
1906 status = csrClose(pMac);
1907 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1908 smsLog( pMac, LOGE, "csrClose failed during sme close with status=%d\n",
1909 status );
1910 fail_status = status;
1911 }
1912
1913#ifdef WLAN_SOFTAP_FEATURE
1914 status = WLANSAP_Close(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1915 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1916 smsLog( pMac, LOGE, "WLANSAP_close failed during sme close with status=%d\n",
1917 status );
1918 fail_status = status;
1919 }
1920#endif
1921
1922#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1923 status = btcClose(hHal);
1924 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1925 smsLog( pMac, LOGE, "BTC close failed during sme close with status=%d\n",
1926 status );
1927 fail_status = status;
1928 }
1929
1930 status = sme_QosClose(pMac);
1931 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1932 smsLog( pMac, LOGE, "Qos close failed during sme close with status=%d\n",
1933 status );
1934 fail_status = status;
1935 }
1936#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001937#ifdef FEATURE_OEM_DATA_SUPPORT
1938 status = oemData_OemDataReqClose(hHal);
1939 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1940 smsLog( pMac, LOGE, "OEM DATA REQ close failed during sme close with status=%d\n",
1941 status );
1942 fail_status = status;
1943 }
1944#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001945
1946 status = ccmClose(hHal);
1947 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1948 smsLog( pMac, LOGE, "ccmClose failed during sme close with status=%d\n",
1949 status );
1950 fail_status = status;
1951 }
1952
1953 status = pmcClose(hHal);
1954 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1955 smsLog( pMac, LOGE, "pmcClose failed during sme close with status=%d\n",
1956 status );
1957 fail_status = status;
1958 }
1959#if defined WLAN_FEATURE_VOWIFI
1960 status = rrmClose(hHal);
1961 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1962 smsLog( pMac, LOGE, "RRM close failed during sme close with status=%d\n",
1963 status );
1964 fail_status = status;
1965 }
1966#endif
1967
1968#if defined WLAN_FEATURE_VOWIFI_11R
1969 sme_FTClose(hHal);
1970#endif
1971#if defined WLAN_FEATURE_P2P
1972 sme_p2pClose(hHal);
1973#endif
1974
1975 freeSmeCmdList(pMac);
1976
1977 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->sme.lkSmeGlobalLock ) ) )
1978 {
1979 fail_status = eHAL_STATUS_FAILURE;
1980 }
1981
1982 if (!HAL_STATUS_SUCCESS( fail_status )) {
1983 status = fail_status;
1984 }
1985
1986 pMac->sme.state = SME_STATE_STOP;
1987
1988 return status;
1989}
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001990#ifdef FEATURE_WLAN_LFR
1991tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac)
1992{
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07001993#if 0
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001994 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
1995 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1996 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
1997 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
1998 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
1999 return eANI_BOOLEAN_FALSE;
2000 default:
2001 return eANI_BOOLEAN_TRUE;
2002 }
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07002003#else
2004 /*
2005 * TODO: always return TRUE for now until
2006 * we figure out why we could be stuck in
2007 * one of the roaming states forever.
2008 */
2009 return eANI_BOOLEAN_TRUE;
2010#endif
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002011}
2012#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002013/* ---------------------------------------------------------------------------
2014 \fn sme_ScanRequest
2015 \brief a wrapper function to Request a 11d or full scan from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002016 This is an asynchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 \param pScanRequestID - pointer to an object to get back the request ID
2018 \param callback - a callback function that scan calls upon finish, will not
2019 be called if csrScanRequest returns error
2020 \param pContext - a pointer passed in for the callback
2021 \return eHalStatus
2022 ---------------------------------------------------------------------------*/
2023eHalStatus sme_ScanRequest(tHalHandle hHal, tANI_U8 sessionId, tCsrScanRequest *pscanReq,
2024 tANI_U32 *pScanRequestID,
2025 csrScanCompleteCallback callback, void *pContext)
2026{
2027 eHalStatus status = eHAL_STATUS_FAILURE;
2028 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2029
2030 smsLog(pMac, LOG2, FL("enter"));
2031 do
2032 {
2033 if(pMac->scan.fScanEnable)
2034 {
2035 status = sme_AcquireGlobalLock( &pMac->sme );
2036 if ( HAL_STATUS_SUCCESS( status ) )
2037 {
2038 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002039#ifdef FEATURE_WLAN_LFR
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002040 if(csrIsScanAllowed(pMac))
2041 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002042#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002043 status = csrScanRequest( hHal, sessionId, pscanReq,
2044 pScanRequestID, callback, pContext );
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002045#ifdef FEATURE_WLAN_LFR
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002046 }
2047 else
2048 {
Madan Mohan Koyyalamudiab4ab0d2012-10-24 14:26:50 -07002049 smsLog(pMac, LOGE, FL("Scan denied in state %d (sub-state %d)"),
2050 pMac->roam.neighborRoamInfo.neighborRoamState,
2051 pMac->roam.curSubState[sessionId]);
2052 /*HandOff is in progress. So schedule this scan later*/
2053 status = eHAL_STATUS_RESOURCES;
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002054 }
2055#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 }
2057
2058 sme_ReleaseGlobalLock( &pMac->sme );
2059 } //sme_AcquireGlobalLock success
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002060 else
2061 {
2062 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
2063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002064 } //if(pMac->scan.fScanEnable)
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002065 else
2066 {
2067 smsLog(pMac, LOGE, FL("fScanEnable FALSE"));
2068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 } while( 0 );
2070
2071 return (status);
2072
2073
2074}
2075
2076/* ---------------------------------------------------------------------------
2077 \fn sme_ScanGetResult
2078 \brief a wrapper function to request scan results from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002079 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 \param pFilter - If pFilter is NULL, all cached results are returned
2081 \param phResult - an object for the result.
2082 \return eHalStatus
2083 ---------------------------------------------------------------------------*/
2084eHalStatus sme_ScanGetResult(tHalHandle hHal, tANI_U8 sessionId, tCsrScanResultFilter *pFilter,
2085 tScanResultHandle *phResult)
2086{
2087 eHalStatus status = eHAL_STATUS_FAILURE;
2088 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2089
2090 smsLog(pMac, LOG2, FL("enter"));
2091 status = sme_AcquireGlobalLock( &pMac->sme );
2092 if ( HAL_STATUS_SUCCESS( status ) )
2093 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07002094 status = csrScanGetResult( hHal, pFilter, phResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 sme_ReleaseGlobalLock( &pMac->sme );
2096 }
2097 smsLog(pMac, LOG2, FL("exit status %d"), status);
2098
2099 return (status);
2100}
2101
2102
2103/* ---------------------------------------------------------------------------
2104 \fn sme_ScanFlushResult
2105 \brief a wrapper function to request CSR to clear scan results.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002106 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 \return eHalStatus
2108 ---------------------------------------------------------------------------*/
2109eHalStatus sme_ScanFlushResult(tHalHandle hHal, tANI_U8 sessionId)
2110{
2111 eHalStatus status = eHAL_STATUS_FAILURE;
2112 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2113
2114 status = sme_AcquireGlobalLock( &pMac->sme );
2115 if ( HAL_STATUS_SUCCESS( status ) )
2116 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07002117 status = csrScanFlushResult( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 sme_ReleaseGlobalLock( &pMac->sme );
2119 }
2120
2121 return (status);
2122}
2123
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002124eHalStatus sme_ScanFlushP2PResult(tHalHandle hHal, tANI_U8 sessionId)
2125{
2126 eHalStatus status = eHAL_STATUS_FAILURE;
2127 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2128
2129 status = sme_AcquireGlobalLock( &pMac->sme );
2130 if ( HAL_STATUS_SUCCESS( status ) )
2131 {
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302132 status = csrScanFlushSelectiveResult( hHal, VOS_TRUE );
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002133 sme_ReleaseGlobalLock( &pMac->sme );
2134 }
2135
2136 return (status);
2137}
Jeff Johnson295189b2012-06-20 16:38:30 -07002138
2139/* ---------------------------------------------------------------------------
2140 \fn sme_ScanResultGetFirst
2141 \brief a wrapper function to request CSR to returns the first element of
2142 scan result.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002143 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 \param hScanResult - returned from csrScanGetResult
2145 \return tCsrScanResultInfo * - NULL if no result
2146 ---------------------------------------------------------------------------*/
2147tCsrScanResultInfo *sme_ScanResultGetFirst(tHalHandle hHal,
2148 tScanResultHandle hScanResult)
2149{
2150 eHalStatus status = eHAL_STATUS_FAILURE;
2151 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2152 tCsrScanResultInfo *pRet = NULL;
2153
2154 status = sme_AcquireGlobalLock( &pMac->sme );
2155 if ( HAL_STATUS_SUCCESS( status ) )
2156 {
2157 pRet = csrScanResultGetFirst( pMac, hScanResult );
2158 sme_ReleaseGlobalLock( &pMac->sme );
2159 }
2160
2161 return (pRet);
2162}
2163
2164
2165/* ---------------------------------------------------------------------------
2166 \fn sme_ScanResultGetNext
2167 \brief a wrapper function to request CSR to returns the next element of
2168 scan result. It can be called without calling csrScanResultGetFirst
2169 first
Srinivas Girigowdade697412013-02-14 16:31:48 -08002170 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 \param hScanResult - returned from csrScanGetResult
2172 \return Null if no result or reach the end
2173 ---------------------------------------------------------------------------*/
2174tCsrScanResultInfo *sme_ScanResultGetNext(tHalHandle hHal,
2175 tScanResultHandle hScanResult)
2176{
2177 eHalStatus status = eHAL_STATUS_FAILURE;
2178 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2179 tCsrScanResultInfo *pRet = NULL;
2180
2181 status = sme_AcquireGlobalLock( &pMac->sme );
2182 if ( HAL_STATUS_SUCCESS( status ) )
2183 {
2184 pRet = csrScanResultGetNext( pMac, hScanResult );
2185 sme_ReleaseGlobalLock( &pMac->sme );
2186 }
2187
2188 return (pRet);
2189}
2190
2191
2192/* ---------------------------------------------------------------------------
2193 \fn sme_ScanSetBGScanparams
2194 \brief a wrapper function to request CSR to set BG scan params in PE
Srinivas Girigowdade697412013-02-14 16:31:48 -08002195 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 \param pScanReq - BG scan request structure
2197 \return eHalStatus
2198 ---------------------------------------------------------------------------*/
2199eHalStatus sme_ScanSetBGScanparams(tHalHandle hHal, tANI_U8 sessionId, tCsrBGScanRequest *pScanReq)
2200{
2201 eHalStatus status = eHAL_STATUS_FAILURE;
2202 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2203
2204 if( NULL != pScanReq )
2205 {
2206 status = sme_AcquireGlobalLock( &pMac->sme );
2207 if ( HAL_STATUS_SUCCESS( status ) )
2208 {
2209 status = csrScanSetBGScanparams( hHal, pScanReq );
2210 sme_ReleaseGlobalLock( &pMac->sme );
2211 }
2212 }
2213
2214 return (status);
2215}
2216
2217
2218/* ---------------------------------------------------------------------------
2219 \fn sme_ScanResultPurge
2220 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
2221 in the list and free memory for each item
Srinivas Girigowdade697412013-02-14 16:31:48 -08002222 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 \param hScanResult - returned from csrScanGetResult. hScanResult is
2224 considered gone by
2225 calling this function and even before this function reutrns.
2226 \return eHalStatus
2227 ---------------------------------------------------------------------------*/
2228eHalStatus sme_ScanResultPurge(tHalHandle hHal, tScanResultHandle hScanResult)
2229{
2230 eHalStatus status = eHAL_STATUS_FAILURE;
2231 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2232
2233 status = sme_AcquireGlobalLock( &pMac->sme );
2234 if ( HAL_STATUS_SUCCESS( status ) )
2235 {
2236 status = csrScanResultPurge( hHal, hScanResult );
2237 sme_ReleaseGlobalLock( &pMac->sme );
2238 }
2239
2240 return (status);
2241}
2242
2243/* ---------------------------------------------------------------------------
2244 \fn sme_ScanGetPMKIDCandidateList
2245 \brief a wrapper function to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08002246 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 \param pPmkidList - caller allocated buffer point to an array of
2248 tPmkidCandidateInfo
2249 \param pNumItems - pointer to a variable that has the number of
2250 tPmkidCandidateInfo allocated when retruning, this is
2251 either the number needed or number of items put into
2252 pPmkidList
2253 \return eHalStatus - when fail, it usually means the buffer allocated is not
2254 big enough and pNumItems
2255 has the number of tPmkidCandidateInfo.
2256 \Note: pNumItems is a number of tPmkidCandidateInfo,
2257 not sizeof(tPmkidCandidateInfo) * something
2258 ---------------------------------------------------------------------------*/
2259eHalStatus sme_ScanGetPMKIDCandidateList(tHalHandle hHal, tANI_U8 sessionId,
2260 tPmkidCandidateInfo *pPmkidList,
2261 tANI_U32 *pNumItems )
2262{
2263 eHalStatus status = eHAL_STATUS_FAILURE;
2264 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2265
2266 status = sme_AcquireGlobalLock( &pMac->sme );
2267 if ( HAL_STATUS_SUCCESS( status ) )
2268 {
2269 status = csrScanGetPMKIDCandidateList( pMac, sessionId, pPmkidList, pNumItems );
2270 sme_ReleaseGlobalLock( &pMac->sme );
2271 }
2272
2273 return (status);
2274}
2275
2276/*----------------------------------------------------------------------------
2277 \fn sme_RoamRegisterLinkQualityIndCallback
2278
2279 \brief
2280 a wrapper function to allow HDD to register a callback handler with CSR for
2281 link quality indications.
2282
2283 Only one callback may be registered at any time.
2284 In order to deregister the callback, a NULL cback may be provided.
2285
2286 Registration happens in the task context of the caller.
2287
2288 \param callback - Call back being registered
2289 \param pContext - user data
2290
2291 DEPENDENCIES: After CSR open
2292
2293 \return eHalStatus
2294-----------------------------------------------------------------------------*/
2295eHalStatus sme_RoamRegisterLinkQualityIndCallback(tHalHandle hHal, tANI_U8 sessionId,
2296 csrRoamLinkQualityIndCallback callback,
2297 void *pContext)
2298{
2299 return(csrRoamRegisterLinkQualityIndCallback((tpAniSirGlobal)hHal, callback, pContext));
2300}
2301
2302/* ---------------------------------------------------------------------------
2303 \fn sme_RoamRegisterCallback
2304 \brief a wrapper function to allow HDD to register a callback with CSR.
2305 Unlike scan, roam has one callback for all the roam requests
2306 \param callback - a callback function that roam calls upon when state changes
2307 \param pContext - a pointer passed in for the callback
2308 \return eHalStatus
2309 ---------------------------------------------------------------------------*/
2310eHalStatus sme_RoamRegisterCallback(tHalHandle hHal,
2311 csrRoamCompleteCallback callback,
2312 void *pContext)
2313{
2314 return(csrRoamRegisterCallback((tpAniSirGlobal)hHal, callback, pContext));
2315}
2316
2317eCsrPhyMode sme_GetPhyMode(tHalHandle hHal)
2318{
2319 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2320 return pMac->roam.configParam.phyMode;
2321}
2322
2323/* ---------------------------------------------------------------------------
2324 \fn sme_RoamConnect
2325 \brief a wrapper function to request CSR to inititiate an association
Srinivas Girigowdade697412013-02-14 16:31:48 -08002326 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 \param sessionId - the sessionId returned by sme_OpenSession.
2328 \param pProfile - description of the network to which to connect
2329 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
2330 from csrScanGetResult
2331 \param pRoamId - to get back the request ID
2332 \return eHalStatus
2333 ---------------------------------------------------------------------------*/
2334eHalStatus sme_RoamConnect(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2335 tANI_U32 *pRoamId)
2336{
2337 eHalStatus status = eHAL_STATUS_FAILURE;
2338 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2339
2340 smsLog(pMac, LOG2, FL("enter"));
2341 status = sme_AcquireGlobalLock( &pMac->sme );
2342 if ( HAL_STATUS_SUCCESS( status ) )
2343 {
2344 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2345 {
2346 status = csrRoamConnect( pMac, sessionId, pProfile, NULL, pRoamId );
2347 }
2348 else
2349 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002350 smsLog(pMac, LOGE, FL("invalid sessionID %d"), sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 status = eHAL_STATUS_INVALID_PARAMETER;
2352 }
2353 sme_ReleaseGlobalLock( &pMac->sme );
2354 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002355 else
2356 {
2357 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
2358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002359
2360 return (status);
2361}
2362
2363/* ---------------------------------------------------------------------------
2364 \fn sme_RoamReassoc
2365 \brief a wrapper function to request CSR to inititiate a re-association
2366 \param pProfile - can be NULL to join the currently connected AP. In that
2367 case modProfileFields should carry the modified field(s) which could trigger
2368 reassoc
2369 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
2370 that might need modification dynamically once STA is up & running and this
2371 could trigger a reassoc
2372 \param pRoamId - to get back the request ID
2373 \return eHalStatus
2374 -------------------------------------------------------------------------------*/
2375eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2376 tCsrRoamModifyProfileFields modProfileFields,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002377 tANI_U32 *pRoamId, v_BOOL_t fForce)
Jeff Johnson295189b2012-06-20 16:38:30 -07002378{
2379 eHalStatus status = eHAL_STATUS_FAILURE;
2380 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2381
2382 smsLog(pMac, LOG2, FL("enter"));
2383 status = sme_AcquireGlobalLock( &pMac->sme );
2384 if ( HAL_STATUS_SUCCESS( status ) )
2385 {
2386 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2387 {
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07002388 if((NULL == pProfile) && (fForce == 1))
2389 {
2390 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2391 /* to force the AP initiate fresh 802.1x authentication need to clear
2392 * the PMKID cache for that set the following boolean. this is needed
2393 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
2394 pSession->fIgnorePMKIDCache = TRUE;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002395 status = csrReassoc( pMac, sessionId, &modProfileFields, pRoamId , fForce);
2396 }
2397 else
2398 {
2399 status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
2400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 }
2402 else
2403 {
2404 status = eHAL_STATUS_INVALID_PARAMETER;
2405 }
2406 sme_ReleaseGlobalLock( &pMac->sme );
2407 }
2408
2409 return (status);
2410}
2411
2412/* ---------------------------------------------------------------------------
2413 \fn sme_RoamConnectToLastProfile
2414 \brief a wrapper function to request CSR to disconnect and reconnect with
2415 the same profile
Srinivas Girigowdade697412013-02-14 16:31:48 -08002416 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 \return eHalStatus. It returns fail if currently connected
2418 ---------------------------------------------------------------------------*/
2419eHalStatus sme_RoamConnectToLastProfile(tHalHandle hHal, tANI_U8 sessionId)
2420{
2421 eHalStatus status = eHAL_STATUS_FAILURE;
2422 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2423
2424 status = sme_AcquireGlobalLock( &pMac->sme );
2425 if ( HAL_STATUS_SUCCESS( status ) )
2426 {
2427 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2428 {
2429 status = csrRoamConnectToLastProfile( pMac, sessionId );
2430 }
2431 else
2432 {
2433 status = eHAL_STATUS_INVALID_PARAMETER;
2434 }
2435 sme_ReleaseGlobalLock( &pMac->sme );
2436 }
2437
2438 return (status);
2439}
2440
2441/* ---------------------------------------------------------------------------
2442 \fn sme_RoamDisconnect
2443 \brief a wrapper function to request CSR to disconnect from a network
Srinivas Girigowdade697412013-02-14 16:31:48 -08002444 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 \param reason -- To indicate the reason for disconnecting. Currently, only
2446 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
2447 \return eHalStatus
2448 ---------------------------------------------------------------------------*/
2449eHalStatus sme_RoamDisconnect(tHalHandle hHal, tANI_U8 sessionId, eCsrRoamDisconnectReason reason)
2450{
2451 eHalStatus status = eHAL_STATUS_FAILURE;
2452 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2453
2454 smsLog(pMac, LOG2, FL("enter"));
2455 status = sme_AcquireGlobalLock( &pMac->sme );
2456 if ( HAL_STATUS_SUCCESS( status ) )
2457 {
2458 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2459 {
2460 status = csrRoamDisconnect( pMac, sessionId, reason );
2461 }
2462 else
2463 {
2464 status = eHAL_STATUS_INVALID_PARAMETER;
2465 }
2466 sme_ReleaseGlobalLock( &pMac->sme );
2467 }
2468
2469 return (status);
2470}
2471
2472#ifdef WLAN_SOFTAP_FEATURE
2473/* ---------------------------------------------------------------------------
2474 \fn sme_RoamStopBss
2475 \brief To stop BSS for Soft AP. This is an asynchronous API.
2476 \param hHal - Global structure
2477 \param sessionId - sessionId of SoftAP
2478 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2479 -------------------------------------------------------------------------------*/
2480eHalStatus sme_RoamStopBss(tHalHandle hHal, tANI_U8 sessionId)
2481{
2482 eHalStatus status = eHAL_STATUS_FAILURE;
2483 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2484
2485 smsLog(pMac, LOG2, FL("enter"));
2486 status = sme_AcquireGlobalLock( &pMac->sme );
2487 if ( HAL_STATUS_SUCCESS( status ) )
2488 {
2489 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2490 {
Gopichand Nakkalaf44bdc52013-02-16 00:54:45 +05302491 status = csrRoamIssueStopBssCmd( pMac, sessionId, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002492 }
2493 else
2494 {
2495 status = eHAL_STATUS_INVALID_PARAMETER;
2496 }
2497 sme_ReleaseGlobalLock( &pMac->sme );
2498 }
2499
2500 return (status);
2501}
2502
2503/* ---------------------------------------------------------------------------
2504 \fn sme_RoamDisconnectSta
2505 \brief To disassociate a station. This is an asynchronous API.
2506 \param hHal - Global structure
2507 \param sessionId - sessionId of SoftAP
2508 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2509 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2510 -------------------------------------------------------------------------------*/
2511eHalStatus sme_RoamDisconnectSta(tHalHandle hHal, tANI_U8 sessionId,
2512 tANI_U8 *pPeerMacAddr)
2513{
2514 eHalStatus status = eHAL_STATUS_FAILURE;
2515 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2516
2517 if ( NULL == pMac )
2518 {
2519 VOS_ASSERT(0);
2520 return status;
2521 }
2522
2523 status = sme_AcquireGlobalLock( &pMac->sme );
2524 if ( HAL_STATUS_SUCCESS( status ) )
2525 {
2526 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2527 {
2528 status = csrRoamIssueDisassociateStaCmd( pMac, sessionId, pPeerMacAddr,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302529 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 }
2531 else
2532 {
2533 status = eHAL_STATUS_INVALID_PARAMETER;
2534 }
2535 sme_ReleaseGlobalLock( &pMac->sme );
2536 }
2537
2538 return (status);
2539}
2540
2541/* ---------------------------------------------------------------------------
2542 \fn sme_RoamDeauthSta
2543 \brief To disassociate a station. This is an asynchronous API.
2544 \param hHal - Global structure
2545 \param sessionId - sessionId of SoftAP
2546 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2547 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2548 -------------------------------------------------------------------------------*/
2549eHalStatus sme_RoamDeauthSta(tHalHandle hHal, tANI_U8 sessionId,
2550 tANI_U8 *pPeerMacAddr)
2551{
2552 eHalStatus status = eHAL_STATUS_FAILURE;
2553 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2554
2555 if ( NULL == pMac )
2556 {
2557 VOS_ASSERT(0);
2558 return status;
2559 }
2560
2561 status = sme_AcquireGlobalLock( &pMac->sme );
2562 if ( HAL_STATUS_SUCCESS( status ) )
2563 {
2564 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2565 {
2566 status = csrRoamIssueDeauthStaCmd( pMac, sessionId, pPeerMacAddr,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302567 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 }
2569 else
2570 {
2571 status = eHAL_STATUS_INVALID_PARAMETER;
2572 }
2573 sme_ReleaseGlobalLock( &pMac->sme );
2574 }
2575
2576 return (status);
2577}
2578
2579/* ---------------------------------------------------------------------------
2580 \fn sme_RoamTKIPCounterMeasures
2581 \brief To start or stop TKIP counter measures. This is an asynchronous API.
2582 \param sessionId - sessionId of SoftAP
2583 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2584 \return eHalStatus
2585 -------------------------------------------------------------------------------*/
2586eHalStatus sme_RoamTKIPCounterMeasures(tHalHandle hHal, tANI_U8 sessionId,
2587 tANI_BOOLEAN bEnable)
2588{
2589 eHalStatus status = eHAL_STATUS_FAILURE;
2590 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2591
2592 if ( NULL == pMac )
2593 {
2594 VOS_ASSERT(0);
2595 return status;
2596 }
2597
2598 status = sme_AcquireGlobalLock( &pMac->sme );
2599 if ( HAL_STATUS_SUCCESS( status ) )
2600 {
2601 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2602 {
2603 status = csrRoamIssueTkipCounterMeasures( pMac, sessionId, bEnable);
2604 }
2605 else
2606 {
2607 status = eHAL_STATUS_INVALID_PARAMETER;
2608 }
2609 sme_ReleaseGlobalLock( &pMac->sme );
2610 }
2611
2612 return (status);
2613}
2614
2615/* ---------------------------------------------------------------------------
2616 \fn sme_RoamGetAssociatedStas
2617 \brief To probe the list of associated stations from various modules of CORE stack.
2618 \This is an asynchronous API.
2619 \param sessionId - sessionId of SoftAP
2620 \param modId - Module from whom list of associtated stations is to be probed.
2621 If an invalid module is passed then by default VOS_MODULE_ID_PE will be probed
2622 \param pUsrContext - Opaque HDD context
2623 \param pfnSapEventCallback - Sap event callback in HDD
2624 \param pAssocBuf - Caller allocated memory to be filled with associatd stations info
2625 \return eHalStatus
2626 -------------------------------------------------------------------------------*/
2627eHalStatus sme_RoamGetAssociatedStas(tHalHandle hHal, tANI_U8 sessionId,
2628 VOS_MODULE_ID modId, void *pUsrContext,
2629 void *pfnSapEventCallback, tANI_U8 *pAssocStasBuf)
2630{
2631 eHalStatus status = eHAL_STATUS_FAILURE;
2632 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2633
2634 if ( NULL == pMac )
2635 {
2636 VOS_ASSERT(0);
2637 return status;
2638 }
2639
2640 status = sme_AcquireGlobalLock( &pMac->sme );
2641 if ( HAL_STATUS_SUCCESS( status ) )
2642 {
2643 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2644 {
2645 status = csrRoamGetAssociatedStas( pMac, sessionId, modId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2646 }
2647 else
2648 {
2649 status = eHAL_STATUS_INVALID_PARAMETER;
2650 }
2651 sme_ReleaseGlobalLock( &pMac->sme );
2652 }
2653
2654 return (status);
2655}
2656
2657/* ---------------------------------------------------------------------------
2658 \fn sme_RoamGetWpsSessionOverlap
2659 \brief To get the WPS PBC session overlap information.
2660 \This is an asynchronous API.
2661 \param sessionId - sessionId of SoftAP
2662 \param pUsrContext - Opaque HDD context
2663 \param pfnSapEventCallback - Sap event callback in HDD
2664 \pRemoveMac - pointer to Mac address which needs to be removed from session
2665 \return eHalStatus
2666 -------------------------------------------------------------------------------*/
2667eHalStatus sme_RoamGetWpsSessionOverlap(tHalHandle hHal, tANI_U8 sessionId,
2668 void *pUsrContext, void
2669 *pfnSapEventCallback, v_MACADDR_t pRemoveMac)
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 = csrRoamGetWpsSessionOverlap( pMac, sessionId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2686 }
2687 else
2688 {
2689 status = eHAL_STATUS_INVALID_PARAMETER;
2690 }
2691 sme_ReleaseGlobalLock( &pMac->sme );
2692 }
2693
2694 return (status);
2695}
2696
2697#endif
2698
2699/* ---------------------------------------------------------------------------
2700 \fn sme_RoamGetConnectState
2701 \brief a wrapper function to request CSR to return the current connect state
2702 of Roaming
Srinivas Girigowdade697412013-02-14 16:31:48 -08002703 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 \return eHalStatus
2705 ---------------------------------------------------------------------------*/
2706eHalStatus sme_RoamGetConnectState(tHalHandle hHal, tANI_U8 sessionId, eCsrConnectState *pState)
2707{
2708 eHalStatus status = eHAL_STATUS_FAILURE;
2709 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2710
2711 status = sme_AcquireGlobalLock( &pMac->sme );
2712 if ( HAL_STATUS_SUCCESS( status ) )
2713 {
2714 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2715 {
2716 status = csrRoamGetConnectState( pMac, sessionId, pState );
2717 }
2718 else
2719 {
2720 status = eHAL_STATUS_INVALID_PARAMETER;
2721 }
2722 sme_ReleaseGlobalLock( &pMac->sme );
2723 }
2724
2725 return (status);
2726}
2727
2728/* ---------------------------------------------------------------------------
2729 \fn sme_RoamGetConnectProfile
2730 \brief a wrapper function to request CSR to return the current connect
2731 profile. Caller must call csrRoamFreeConnectProfile after it is done
2732 and before reuse for another csrRoamGetConnectProfile call.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002733 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 \param pProfile - pointer to a caller allocated structure
2735 tCsrRoamConnectedProfile
2736 \return eHalStatus. Failure if not connected
2737 ---------------------------------------------------------------------------*/
2738eHalStatus sme_RoamGetConnectProfile(tHalHandle hHal, tANI_U8 sessionId,
2739 tCsrRoamConnectedProfile *pProfile)
2740{
2741 eHalStatus status = eHAL_STATUS_FAILURE;
2742 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2743
2744 status = sme_AcquireGlobalLock( &pMac->sme );
2745 if ( HAL_STATUS_SUCCESS( status ) )
2746 {
2747 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2748 {
2749 status = csrRoamGetConnectProfile( pMac, sessionId, pProfile );
2750 }
2751 else
2752 {
2753 status = eHAL_STATUS_INVALID_PARAMETER;
2754 }
2755 sme_ReleaseGlobalLock( &pMac->sme );
2756 }
2757
2758 return (status);
2759}
2760
2761/* ---------------------------------------------------------------------------
2762 \fn sme_RoamFreeConnectProfile
2763 \brief a wrapper function to request CSR to free and reinitialize the
2764 profile returned previously by csrRoamGetConnectProfile.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002765 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 \param pProfile - pointer to a caller allocated structure
2767 tCsrRoamConnectedProfile
2768 \return eHalStatus.
2769 ---------------------------------------------------------------------------*/
2770eHalStatus sme_RoamFreeConnectProfile(tHalHandle hHal,
2771 tCsrRoamConnectedProfile *pProfile)
2772{
2773 eHalStatus status = eHAL_STATUS_FAILURE;
2774 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2775
2776 status = sme_AcquireGlobalLock( &pMac->sme );
2777 if ( HAL_STATUS_SUCCESS( status ) )
2778 {
2779 status = csrRoamFreeConnectProfile( pMac, pProfile );
2780 sme_ReleaseGlobalLock( &pMac->sme );
2781 }
2782
2783 return (status);
2784}
2785
2786/* ---------------------------------------------------------------------------
2787 \fn sme_RoamSetPMKIDCache
2788 \brief a wrapper function to request CSR to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08002789 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 \param pPMKIDCache - caller allocated buffer point to an array of
2791 tPmkidCacheInfo
2792 \param numItems - a variable that has the number of tPmkidCacheInfo
2793 allocated when retruning, this is either the number needed
2794 or number of items put into pPMKIDCache
2795 \return eHalStatus - when fail, it usually means the buffer allocated is not
2796 big enough and pNumItems has the number of
2797 tPmkidCacheInfo.
2798 \Note: pNumItems is a number of tPmkidCacheInfo,
2799 not sizeof(tPmkidCacheInfo) * something
2800 ---------------------------------------------------------------------------*/
2801eHalStatus sme_RoamSetPMKIDCache( tHalHandle hHal, tANI_U8 sessionId, tPmkidCacheInfo *pPMKIDCache,
2802 tANI_U32 numItems )
2803{
2804 eHalStatus status = eHAL_STATUS_FAILURE;
2805 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2806
2807 status = sme_AcquireGlobalLock( &pMac->sme );
2808 if ( HAL_STATUS_SUCCESS( status ) )
2809 {
2810 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2811 {
2812 status = csrRoamSetPMKIDCache( pMac, sessionId, pPMKIDCache, numItems );
2813 }
2814 else
2815 {
2816 status = eHAL_STATUS_INVALID_PARAMETER;
2817 }
2818 sme_ReleaseGlobalLock( &pMac->sme );
2819 }
2820
2821 return (status);
2822}
2823
2824/* ---------------------------------------------------------------------------
2825 \fn sme_RoamGetSecurityReqIE
2826 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
2827 passes to PE to JOIN request or START_BSS request
Srinivas Girigowdade697412013-02-14 16:31:48 -08002828 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 \param pLen - caller allocated memory that has the length of pBuf as input.
2830 Upon returned, *pLen has the needed or IE length in pBuf.
2831 \param pBuf - Caller allocated memory that contain the IE field, if any,
2832 upon return
2833 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
2834 \return eHalStatus - when fail, it usually means the buffer allocated is not
2835 big enough
2836 ---------------------------------------------------------------------------*/
2837eHalStatus sme_RoamGetSecurityReqIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
2838 tANI_U8 *pBuf, eCsrSecurityType secType)
2839{
2840 eHalStatus status = eHAL_STATUS_FAILURE;
2841 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2842
2843 status = sme_AcquireGlobalLock( &pMac->sme );
2844 if ( HAL_STATUS_SUCCESS( status ) )
2845 {
2846 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2847 {
2848 status = csrRoamGetWpaRsnReqIE( hHal, sessionId, pLen, pBuf );
2849 }
2850 else
2851 {
2852 status = eHAL_STATUS_INVALID_PARAMETER;
2853 }
2854 sme_ReleaseGlobalLock( &pMac->sme );
2855 }
2856
2857 return (status);
2858}
2859
2860/* ---------------------------------------------------------------------------
2861 \fn sme_RoamGetSecurityRspIE
2862 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE from
2863 the beacon or probe rsp if connected
Srinivas Girigowdade697412013-02-14 16:31:48 -08002864 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 \param pLen - caller allocated memory that has the length of pBuf as input.
2866 Upon returned, *pLen has the needed or IE length in pBuf.
2867 \param pBuf - Caller allocated memory that contain the IE field, if any,
2868 upon return
2869 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
2870 \return eHalStatus - when fail, it usually means the buffer allocated is not
2871 big enough
2872 ---------------------------------------------------------------------------*/
2873eHalStatus sme_RoamGetSecurityRspIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
2874 tANI_U8 *pBuf, eCsrSecurityType secType)
2875{
2876 eHalStatus status = eHAL_STATUS_FAILURE;
2877 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2878
2879 status = sme_AcquireGlobalLock( &pMac->sme );
2880 if ( HAL_STATUS_SUCCESS( status ) )
2881 {
2882 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2883 {
2884 status = csrRoamGetWpaRsnRspIE( pMac, sessionId, pLen, pBuf );
2885 }
2886 else
2887 {
2888 status = eHAL_STATUS_INVALID_PARAMETER;
2889 }
2890 sme_ReleaseGlobalLock( &pMac->sme );
2891 }
2892
2893 return (status);
2894
2895}
2896
2897
2898/* ---------------------------------------------------------------------------
2899 \fn sme_RoamGetNumPMKIDCache
2900 \brief a wrapper function to request CSR to return number of PMKID cache
2901 entries
Srinivas Girigowdade697412013-02-14 16:31:48 -08002902 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 \return tANI_U32 - the number of PMKID cache entries
2904 ---------------------------------------------------------------------------*/
2905tANI_U32 sme_RoamGetNumPMKIDCache(tHalHandle hHal, tANI_U8 sessionId)
2906{
2907 eHalStatus status = eHAL_STATUS_FAILURE;
2908 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2909 tANI_U32 numPmkidCache = 0;
2910
2911 status = sme_AcquireGlobalLock( &pMac->sme );
2912 if ( HAL_STATUS_SUCCESS( status ) )
2913 {
2914 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2915 {
2916 numPmkidCache = csrRoamGetNumPMKIDCache( pMac, sessionId );
2917 status = eHAL_STATUS_SUCCESS;
2918 }
2919 else
2920 {
2921 status = eHAL_STATUS_INVALID_PARAMETER;
2922 }
2923 sme_ReleaseGlobalLock( &pMac->sme );
2924 }
2925
2926 return (numPmkidCache);
2927}
2928
2929/* ---------------------------------------------------------------------------
2930 \fn sme_RoamGetPMKIDCache
2931 \brief a wrapper function to request CSR to return PMKID cache from CSR
Srinivas Girigowdade697412013-02-14 16:31:48 -08002932 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002933 \param pNum - caller allocated memory that has the space of the number of
2934 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
2935 needed or actually number in tPmkidCacheInfo.
2936 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
2937 any, upon return
2938 \return eHalStatus - when fail, it usually means the buffer allocated is not
2939 big enough
2940 ---------------------------------------------------------------------------*/
2941eHalStatus sme_RoamGetPMKIDCache(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pNum,
2942 tPmkidCacheInfo *pPmkidCache)
2943{
2944 eHalStatus status = eHAL_STATUS_FAILURE;
2945 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2946
2947 status = sme_AcquireGlobalLock( &pMac->sme );
2948 if ( HAL_STATUS_SUCCESS( status ) )
2949 {
2950 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2951 {
2952 status = csrRoamGetPMKIDCache( pMac, sessionId, pNum, pPmkidCache );
2953 }
2954 else
2955 {
2956 status = eHAL_STATUS_INVALID_PARAMETER;
2957 }
2958 sme_ReleaseGlobalLock( &pMac->sme );
2959 }
2960
2961 return (status);
2962}
2963
2964
2965/* ---------------------------------------------------------------------------
2966 \fn sme_GetConfigParam
2967 \brief a wrapper function that HDD calls to get the global settings
2968 currently maintained by CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002969 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 \param pParam - caller allocated memory
2971 \return eHalStatus
2972 ---------------------------------------------------------------------------*/
2973eHalStatus sme_GetConfigParam(tHalHandle hHal, tSmeConfigParams *pParam)
2974{
2975 eHalStatus status = eHAL_STATUS_FAILURE;
2976 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2977
2978 status = sme_AcquireGlobalLock( &pMac->sme );
2979 if ( HAL_STATUS_SUCCESS( status ) )
2980 {
2981 status = csrGetConfigParam(pMac, &pParam->csrConfig);
2982 if (status != eHAL_STATUS_SUCCESS)
2983 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002984 smsLog( pMac, LOGE, "%s csrGetConfigParam failed\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 sme_ReleaseGlobalLock( &pMac->sme );
2986 return status;
2987 }
2988#if defined WLAN_FEATURE_P2P_INTERNAL
2989 status = p2pGetConfigParam(pMac, &pParam->p2pConfig);
2990 if (status != eHAL_STATUS_SUCCESS)
2991 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002992 smsLog( pMac, LOGE, "%s p2pGetConfigParam failed\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 sme_ReleaseGlobalLock( &pMac->sme );
2994 return status;
2995 }
2996#endif
2997 sme_ReleaseGlobalLock( &pMac->sme );
2998 }
2999
3000 return (status);
3001}
3002
3003/* ---------------------------------------------------------------------------
3004 \fn sme_CfgSetInt
3005 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003006 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 \param cfgId - Configuration Parameter ID (type) for STA.
3008 \param ccmValue - The information related to Configuration Parameter ID
3009 which needs to be saved in CFG
3010 \param callback - To be registered by CSR with CCM. Once the CFG done with
3011 saving the information in the database, it notifies CCM &
3012 then the callback will be invoked to notify.
3013 \param toBeSaved - To save the request for future reference
3014 \return eHalStatus
3015 ---------------------------------------------------------------------------*/
3016eHalStatus sme_CfgSetInt(tHalHandle hHal, tANI_U32 cfgId, tANI_U32 ccmValue,
3017 tCcmCfgSetCallback callback, eAniBoolean toBeSaved)
3018{
3019 return(ccmCfgSetInt(hHal, cfgId, ccmValue, callback, toBeSaved));
3020}
3021
3022/* ---------------------------------------------------------------------------
3023 \fn sme_CfgSetStr
3024 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003025 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 \param cfgId - Configuration Parameter ID (type) for STA.
3027 \param pStr - Pointer to the byte array which carries the information needs
3028 to be saved in CFG
3029 \param length - Length of the data to be saved
3030 \param callback - To be registered by CSR with CCM. Once the CFG done with
3031 saving the information in the database, it notifies CCM &
3032 then the callback will be invoked to notify.
3033 \param toBeSaved - To save the request for future reference
3034 \return eHalStatus
3035 ---------------------------------------------------------------------------*/
3036eHalStatus sme_CfgSetStr(tHalHandle hHal, tANI_U32 cfgId, tANI_U8 *pStr,
3037 tANI_U32 length, tCcmCfgSetCallback callback,
3038 eAniBoolean toBeSaved)
3039{
3040 return(ccmCfgSetStr(hHal, cfgId, pStr, length, callback, toBeSaved));
3041}
3042
3043/* ---------------------------------------------------------------------------
3044 \fn sme_GetModifyProfileFields
3045 \brief HDD or SME - QOS calls this function to get the current values of
3046 connected profile fields, changing which can cause reassoc.
3047 This function must be called after CFG is downloaded and STA is in connected
3048 state. Also, make sure to call this function to get the current profile
3049 fields before calling the reassoc. So that pModifyProfileFields will have
3050 all the latest values plus the one(s) has been updated as part of reassoc
3051 request.
3052 \param pModifyProfileFields - pointer to the connected profile fields
3053 changing which can cause reassoc
3054
3055 \return eHalStatus
3056 -------------------------------------------------------------------------------*/
3057eHalStatus sme_GetModifyProfileFields(tHalHandle hHal, tANI_U8 sessionId,
3058 tCsrRoamModifyProfileFields * pModifyProfileFields)
3059{
3060 eHalStatus status = eHAL_STATUS_FAILURE;
3061 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3062
3063 status = sme_AcquireGlobalLock( &pMac->sme );
3064 if ( HAL_STATUS_SUCCESS( status ) )
3065 {
3066 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3067 {
3068 status = csrGetModifyProfileFields(pMac, sessionId, pModifyProfileFields);
3069 }
3070 else
3071 {
3072 status = eHAL_STATUS_INVALID_PARAMETER;
3073 }
3074 sme_ReleaseGlobalLock( &pMac->sme );
3075 }
3076
3077 return (status);
3078}
3079
3080/*--------------------------------------------------------------------------
3081 \fn sme_SetConfigPowerSave
3082 \brief Wrapper fn to change power save configuration in SME (PMC) module.
3083 For BMPS related configuration, this function also updates the CFG
3084 and sends a message to FW to pick up the new values. Note: Calling
3085 this function only updates the configuration and does not enable
3086 the specified power save mode.
3087 \param hHal - The handle returned by macOpen.
3088 \param psMode - Power Saving mode being modified
3089 \param pConfigParams - a pointer to a caller allocated object of type
3090 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
3091 \return eHalStatus
3092 --------------------------------------------------------------------------*/
3093eHalStatus sme_SetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
3094 void *pConfigParams)
3095{
3096 eHalStatus status = eHAL_STATUS_FAILURE;
3097 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3098
3099 if (NULL == pConfigParams ) {
3100 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3101 "nothing to update");
3102 return eHAL_STATUS_FAILURE;
3103 }
3104
3105 status = sme_AcquireGlobalLock( &pMac->sme );
3106 if ( HAL_STATUS_SUCCESS( status ) )
3107 {
3108 status = pmcSetConfigPowerSave(hHal, psMode, pConfigParams);
3109 sme_ReleaseGlobalLock( &pMac->sme );
3110 }
3111
3112 return (status);
3113}
3114
3115/*--------------------------------------------------------------------------
3116 \fn sme_GetConfigPowerSave
3117 \brief Wrapper fn to retrieve power save configuration in SME (PMC) module
3118 \param hHal - The handle returned by macOpen.
3119 \param psMode - Power Saving mode
3120 \param pConfigParams - a pointer to a caller allocated object of type
3121 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
3122 \return eHalStatus
3123 --------------------------------------------------------------------------*/
3124eHalStatus sme_GetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
3125 void *pConfigParams)
3126{
3127 eHalStatus status = eHAL_STATUS_FAILURE;
3128 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3129
3130 if (NULL == pConfigParams ) {
3131 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3132 "nothing to update");
3133 return eHAL_STATUS_FAILURE;
3134 }
3135
3136 status = sme_AcquireGlobalLock( &pMac->sme );
3137 if ( HAL_STATUS_SUCCESS( status ) )
3138 {
3139 status = pmcGetConfigPowerSave(hHal, psMode, pConfigParams);
3140 sme_ReleaseGlobalLock( &pMac->sme );
3141 }
3142
3143 return (status);
3144}
3145
3146/* ---------------------------------------------------------------------------
3147 \fn sme_SignalPowerEvent
3148 \brief Signals to PMC that a power event has occurred. Used for putting
3149 the chip into deep sleep mode.
3150 \param hHal - The handle returned by macOpen.
3151 \param event - the event that has occurred
3152 \return eHalStatus
3153 ---------------------------------------------------------------------------*/
3154eHalStatus sme_SignalPowerEvent (tHalHandle hHal, tPmcPowerEvent event)
3155{
3156 eHalStatus status = eHAL_STATUS_FAILURE;
3157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3158
3159 status = sme_AcquireGlobalLock( &pMac->sme );
3160 if ( HAL_STATUS_SUCCESS( status ) )
3161 {
3162 status = pmcSignalPowerEvent(hHal, event);
3163 sme_ReleaseGlobalLock( &pMac->sme );
3164 }
3165
3166 return (status);
3167}
3168
3169/* ---------------------------------------------------------------------------
3170 \fn sme_EnablePowerSave
3171 \brief Enables one of the power saving modes.
3172 \param hHal - The handle returned by macOpen.
3173 \param psMode - The power saving mode to enable. If BMPS mode is enabled
3174 while the chip is operating in Full Power, PMC will start
3175 a timer that will try to put the chip in BMPS mode after
3176 expiry.
3177 \return eHalStatus
3178 ---------------------------------------------------------------------------*/
3179eHalStatus sme_EnablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3180{
3181 eHalStatus status = eHAL_STATUS_FAILURE;
3182 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3183
3184 status = sme_AcquireGlobalLock( &pMac->sme );
3185 if ( HAL_STATUS_SUCCESS( status ) )
3186 {
3187 status = pmcEnablePowerSave(hHal, psMode);
3188 sme_ReleaseGlobalLock( &pMac->sme );
3189 }
3190
3191 return (status);
3192}
3193
3194/* ---------------------------------------------------------------------------
3195 \fn sme_DisablePowerSave
3196 \brief Disables one of the power saving modes.
3197 \param hHal - The handle returned by macOpen.
3198 \param psMode - The power saving mode to disable. Disabling does not imply
3199 that device will be brought out of the current PS mode. This
3200 is purely a configuration API.
3201 \return eHalStatus
3202 ---------------------------------------------------------------------------*/
3203eHalStatus sme_DisablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3204{
3205 eHalStatus status = eHAL_STATUS_FAILURE;
3206 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3207
3208 status = sme_AcquireGlobalLock( &pMac->sme );
3209 if ( HAL_STATUS_SUCCESS( status ) )
3210 {
3211 status = pmcDisablePowerSave(hHal, psMode);
3212 sme_ReleaseGlobalLock( &pMac->sme );
3213 }
3214
3215 return (status);
3216 }
3217
3218/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +05303219+ \fn sme_SetHostPowerSave
3220+ \brief Enables BMPS logic to be controlled by User level apps
3221+ \param hHal - The handle returned by macOpen.
3222+ \param psMode - The power saving mode to disable. Disabling does not imply
3223+ that device will be brought out of the current PS mode. This
3224+ is purely a configuration API.
3225+ \return eHalStatus
3226+ ---------------------------------------------------------------------------*/
3227eHalStatus sme_SetHostPowerSave (tHalHandle hHal, v_BOOL_t psMode)
3228{
3229 eHalStatus status = eHAL_STATUS_FAILURE;
3230 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3231
3232 pMac->pmc.isHostPsEn = psMode;
3233
3234 return (status);
3235}
3236
3237/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 \fn sme_StartAutoBmpsTimer
3239 \brief Starts a timer that periodically polls all the registered
3240 module for entry into Bmps mode. This timer is started only if BMPS is
3241 enabled and whenever the device is in full power.
3242 \param hHal - The handle returned by macOpen.
3243 \return eHalStatus
3244 ---------------------------------------------------------------------------*/
3245eHalStatus sme_StartAutoBmpsTimer ( tHalHandle hHal)
3246{
3247 eHalStatus status = eHAL_STATUS_FAILURE;
3248 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3249
3250 status = sme_AcquireGlobalLock( &pMac->sme );
3251 if ( HAL_STATUS_SUCCESS( status ) )
3252 {
3253 status = pmcStartAutoBmpsTimer(hHal);
3254 sme_ReleaseGlobalLock( &pMac->sme );
3255 }
3256
3257 return (status);
3258}
3259/* ---------------------------------------------------------------------------
3260 \fn sme_StopAutoBmpsTimer
3261 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
3262 Stopping the timer does not cause a device state change. Only the timer
3263 is stopped. If "Full Power" is desired, use the sme_RequestFullPower API
3264 \param hHal - The handle returned by macOpen.
3265 \return eHalStatus
3266 ---------------------------------------------------------------------------*/
3267eHalStatus sme_StopAutoBmpsTimer ( tHalHandle hHal)
3268{
3269 eHalStatus status = eHAL_STATUS_FAILURE;
3270 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3271
3272 status = sme_AcquireGlobalLock( &pMac->sme );
3273 if ( HAL_STATUS_SUCCESS( status ) )
3274 {
3275 status = pmcStopAutoBmpsTimer(hHal);
3276 sme_ReleaseGlobalLock( &pMac->sme );
3277 }
3278
3279 return (status);
3280}
3281/* ---------------------------------------------------------------------------
3282 \fn sme_QueryPowerState
3283 \brief Returns the current power state of the device.
3284 \param hHal - The handle returned by macOpen.
3285 \param pPowerState - pointer to location to return power state (LOW or HIGH)
3286 \param pSwWlanSwitchState - ptr to location to return SW WLAN Switch state
3287 \return eHalStatus
3288 ---------------------------------------------------------------------------*/
3289eHalStatus sme_QueryPowerState (
3290 tHalHandle hHal,
3291 tPmcPowerState *pPowerState,
3292 tPmcSwitchState *pSwWlanSwitchState)
3293{
3294 eHalStatus status = eHAL_STATUS_FAILURE;
3295 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3296
3297 status = sme_AcquireGlobalLock( &pMac->sme );
3298 if ( HAL_STATUS_SUCCESS( status ) )
3299 {
3300 status = pmcQueryPowerState (hHal, pPowerState, NULL, pSwWlanSwitchState);
3301 sme_ReleaseGlobalLock( &pMac->sme );
3302 }
3303
3304 return (status);
3305}
3306
3307/* ---------------------------------------------------------------------------
3308 \fn sme_IsPowerSaveEnabled
3309 \brief Checks if the device is able to enter a particular power save mode
3310 This does not imply that the device is in a particular PS mode
3311 \param hHal - The handle returned by macOpen.
3312 \param psMode - the power saving mode
3313 \return eHalStatus
3314 ---------------------------------------------------------------------------*/
3315tANI_BOOLEAN sme_IsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
3316{
3317 eHalStatus status = eHAL_STATUS_FAILURE;
3318 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3319 tANI_BOOLEAN result = false;
3320
3321 status = sme_AcquireGlobalLock( &pMac->sme );
3322 if ( HAL_STATUS_SUCCESS( status ) )
3323 {
3324 result = pmcIsPowerSaveEnabled(hHal, psMode);
3325 sme_ReleaseGlobalLock( &pMac->sme );
3326 return result;
3327 }
3328
3329 return false;
3330}
3331
3332/* ---------------------------------------------------------------------------
3333 \fn sme_RequestFullPower
3334 \brief Request that the device be brought to full power state. When the
3335 device enters Full Power PMC will start a BMPS timer if BMPS PS mode
3336 is enabled. On timer expiry PMC will attempt to put the device in
3337 BMPS mode if following holds true:
3338 - BMPS mode is enabled
3339 - Polling of all modules through the Power Save Check routine passes
3340 - STA is associated to an access point
3341 \param hHal - The handle returned by macOpen.
3342 \param - callbackRoutine Callback routine invoked in case of success/failure
3343 \return eHalStatus - status
3344 eHAL_STATUS_SUCCESS - device brought to full power state
3345 eHAL_STATUS_FAILURE - device cannot be brought to full power state
3346 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
3347 ---------------------------------------------------------------------------*/
3348eHalStatus sme_RequestFullPower (
3349 tHalHandle hHal,
3350 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3351 void *callbackContext,
3352 tRequestFullPowerReason fullPowerReason)
3353{
3354 eHalStatus status = eHAL_STATUS_FAILURE;
3355 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3356
3357 status = sme_AcquireGlobalLock( &pMac->sme );
3358 if ( HAL_STATUS_SUCCESS( status ) )
3359 {
3360 status = pmcRequestFullPower(hHal, callbackRoutine, callbackContext, fullPowerReason);
3361 sme_ReleaseGlobalLock( &pMac->sme );
3362 }
3363
3364 return (status);
3365}
3366
3367/* ---------------------------------------------------------------------------
3368 \fn sme_RequestBmps
3369 \brief Request that the device be put in BMPS state. Request will be
3370 accepted only if BMPS mode is enabled and power save check routine
3371 passes.
3372 \param hHal - The handle returned by macOpen.
3373 \param - callbackRoutine Callback routine invoked in case of success/failure
3374 \return eHalStatus
3375 eHAL_STATUS_SUCCESS - device is in BMPS state
3376 eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
3377 eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state
3378 ---------------------------------------------------------------------------*/
3379eHalStatus sme_RequestBmps (
3380 tHalHandle hHal,
3381 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3382 void *callbackContext)
3383{
3384 eHalStatus status = eHAL_STATUS_FAILURE;
3385 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3386
3387 status = sme_AcquireGlobalLock( &pMac->sme );
3388 if ( HAL_STATUS_SUCCESS( status ) )
3389 {
3390 status = pmcRequestBmps(hHal, callbackRoutine, callbackContext);
3391 sme_ReleaseGlobalLock( &pMac->sme );
3392 }
3393
3394 return (status);
3395}
3396
3397
3398/* ---------------------------------------------------------------------------
3399 \fn sme_SetDHCPTillPowerActiveFlag
3400 \brief Sets/Clears DHCP related flag in PMC to disable/enable auto BMPS
3401 entry by PMC
3402 \param hHal - The handle returned by macOpen.
3403 ---------------------------------------------------------------------------*/
3404void sme_SetDHCPTillPowerActiveFlag(tHalHandle hHal, tANI_U8 flag)
3405{
3406 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3407
3408 // Set/Clear the DHCP flag which will disable/enable auto BMPS entery by PMC
3409 pMac->pmc.remainInPowerActiveTillDHCP = flag;
3410}
3411
3412
3413/* ---------------------------------------------------------------------------
3414 \fn sme_StartUapsd
3415 \brief Request that the device be put in UAPSD state. If the device is in
3416 Full Power it will be put in BMPS mode first and then into UAPSD
3417 mode.
3418 \param hHal - The handle returned by macOpen.
3419 \param - callbackRoutine Callback routine invoked in case of success/failure
3420 eHAL_STATUS_SUCCESS - device is in UAPSD state
3421 eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
3422 eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
3423 eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
3424 \return eHalStatus
3425 ---------------------------------------------------------------------------*/
3426eHalStatus sme_StartUapsd (
3427 tHalHandle hHal,
3428 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3429 void *callbackContext)
3430{
3431 eHalStatus status = eHAL_STATUS_FAILURE;
3432 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3433
3434 status = sme_AcquireGlobalLock( &pMac->sme );
3435 if ( HAL_STATUS_SUCCESS( status ) )
3436 {
3437 status = pmcStartUapsd(hHal, callbackRoutine, callbackContext);
3438 sme_ReleaseGlobalLock( &pMac->sme );
3439 }
3440
3441 return (status);
3442 }
3443
3444/* ---------------------------------------------------------------------------
3445 \fn sme_StopUapsd
3446 \brief Request that the device be put out of UAPSD state. Device will be
3447 put in in BMPS state after stop UAPSD completes.
3448 \param hHal - The handle returned by macOpen.
3449 \return eHalStatus
3450 eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
3451 eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
3452 ---------------------------------------------------------------------------*/
3453eHalStatus sme_StopUapsd (tHalHandle hHal)
3454{
3455 eHalStatus status = eHAL_STATUS_FAILURE;
3456 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3457
3458 status = sme_AcquireGlobalLock( &pMac->sme );
3459 if ( HAL_STATUS_SUCCESS( status ) )
3460 {
3461 status = pmcStopUapsd(hHal);
3462 sme_ReleaseGlobalLock( &pMac->sme );
3463 }
3464
3465 return (status);
3466}
3467
3468/* ---------------------------------------------------------------------------
3469 \fn sme_RequestStandby
3470 \brief Request that the device be put in standby. It is HDD's responsibility
3471 to bring the chip to full power and do a disassoc before calling
3472 this API.
3473 \param hHal - The handle returned by macOpen.
3474 \param - callbackRoutine Callback routine invoked in case of success/failure
3475 \return eHalStatus
3476 eHAL_STATUS_SUCCESS - device is in Standby mode
3477 eHAL_STATUS_FAILURE - device cannot be put in standby mode
3478 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
3479 ---------------------------------------------------------------------------*/
3480eHalStatus sme_RequestStandby (
3481 tHalHandle hHal,
3482 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3483 void *callbackContext)
3484{
3485 eHalStatus status = eHAL_STATUS_FAILURE;
3486 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3487
3488 smsLog( pMac, LOG1, FL("") );
3489 status = sme_AcquireGlobalLock( &pMac->sme );
3490 if ( HAL_STATUS_SUCCESS( status ) )
3491 {
3492 status = pmcRequestStandby(hHal, callbackRoutine, callbackContext);
3493 sme_ReleaseGlobalLock( &pMac->sme );
3494 }
3495
3496 return (status);
3497}
3498
3499/* ---------------------------------------------------------------------------
3500 \fn sme_RegisterPowerSaveCheck
3501 \brief Register a power save check routine that is called whenever
3502 the device is about to enter one of the power save modes.
3503 \param hHal - The handle returned by macOpen.
3504 \param checkRoutine - Power save check routine to be registered
3505 \return eHalStatus
3506 eHAL_STATUS_SUCCESS - successfully registered
3507 eHAL_STATUS_FAILURE - not successfully registered
3508 ---------------------------------------------------------------------------*/
3509eHalStatus sme_RegisterPowerSaveCheck (
3510 tHalHandle hHal,
3511 tANI_BOOLEAN (*checkRoutine) (void *checkContext), void *checkContext)
3512{
3513 eHalStatus status = eHAL_STATUS_FAILURE;
3514 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3515
3516 status = sme_AcquireGlobalLock( &pMac->sme );
3517 if ( HAL_STATUS_SUCCESS( status ) )
3518 {
3519 status = pmcRegisterPowerSaveCheck (hHal, checkRoutine, checkContext);
3520 sme_ReleaseGlobalLock( &pMac->sme );
3521 }
3522
3523 return (status);
3524}
3525
3526/* ---------------------------------------------------------------------------
3527 \fn sme_DeregisterPowerSaveCheck
3528 \brief Deregister a power save check routine
3529 \param hHal - The handle returned by macOpen.
3530 \param checkRoutine - Power save check routine to be deregistered
3531 \return eHalStatus
3532 eHAL_STATUS_SUCCESS - successfully deregistered
3533 eHAL_STATUS_FAILURE - not successfully deregistered
3534 ---------------------------------------------------------------------------*/
3535eHalStatus sme_DeregisterPowerSaveCheck (
3536 tHalHandle hHal,
3537 tANI_BOOLEAN (*checkRoutine) (void *checkContext))
3538{
3539 eHalStatus status = eHAL_STATUS_FAILURE;
3540 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3541
3542 status = sme_AcquireGlobalLock( &pMac->sme );
3543 if ( HAL_STATUS_SUCCESS( status ) )
3544 {
3545 status = pmcDeregisterPowerSaveCheck (hHal, checkRoutine);
3546 sme_ReleaseGlobalLock( &pMac->sme );
3547 }
3548
3549 return (status);
3550}
3551
3552/* ---------------------------------------------------------------------------
3553 \fn sme_RegisterDeviceStateUpdateInd
3554 \brief Register a callback routine that is called whenever
3555 the device enters a new device state (Full Power, BMPS, UAPSD)
3556 \param hHal - The handle returned by macOpen.
3557 \param callbackRoutine - Callback routine to be registered
3558 \param callbackContext - Cookie to be passed back during callback
3559 \return eHalStatus
3560 eHAL_STATUS_SUCCESS - successfully registered
3561 eHAL_STATUS_FAILURE - not successfully registered
3562 ---------------------------------------------------------------------------*/
3563eHalStatus sme_RegisterDeviceStateUpdateInd (
3564 tHalHandle hHal,
3565 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
3566 void *callbackContext)
3567{
3568 eHalStatus status = eHAL_STATUS_FAILURE;
3569 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3570
3571 status = sme_AcquireGlobalLock( &pMac->sme );
3572 if ( HAL_STATUS_SUCCESS( status ) )
3573 {
3574 status = pmcRegisterDeviceStateUpdateInd (hHal, callbackRoutine, callbackContext);
3575 sme_ReleaseGlobalLock( &pMac->sme );
3576 }
3577
3578 return (status);
3579}
3580
3581/* ---------------------------------------------------------------------------
3582 \fn sme_DeregisterDeviceStateUpdateInd
3583 \brief Deregister a routine that was registered for device state changes
3584 \param hHal - The handle returned by macOpen.
3585 \param callbackRoutine - Callback routine to be deregistered
3586 \return eHalStatus
3587 eHAL_STATUS_SUCCESS - successfully deregistered
3588 eHAL_STATUS_FAILURE - not successfully deregistered
3589 ---------------------------------------------------------------------------*/
3590eHalStatus sme_DeregisterDeviceStateUpdateInd (
3591 tHalHandle hHal,
3592 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
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 = pmcDeregisterDeviceStateUpdateInd (hHal, callbackRoutine);
3601 sme_ReleaseGlobalLock( &pMac->sme );
3602 }
3603
3604 return (status);
3605}
3606
3607/* ---------------------------------------------------------------------------
3608 \fn sme_WowlAddBcastPattern
3609 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
3610 do a pattern match on these patterns when Wowl is enabled during BMPS
3611 mode. Note that Firmware performs the pattern matching only on
3612 broadcast frames and while Libra is in BMPS mode.
3613 \param hHal - The handle returned by macOpen.
3614 \param pattern - Pattern to be added
3615 \return eHalStatus
3616 eHAL_STATUS_FAILURE Cannot add pattern
3617 eHAL_STATUS_SUCCESS Request accepted.
3618 ---------------------------------------------------------------------------*/
3619eHalStatus sme_WowlAddBcastPattern (
3620 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003621 tpSirWowlAddBcastPtrn pattern,
3622 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003623{
3624 eHalStatus status = eHAL_STATUS_FAILURE;
3625 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3626 status = sme_AcquireGlobalLock( &pMac->sme );
3627 if ( HAL_STATUS_SUCCESS( status ) )
3628 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003629 status = pmcWowlAddBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 sme_ReleaseGlobalLock( &pMac->sme );
3631 }
3632
3633 return (status);
3634}
3635
3636/* ---------------------------------------------------------------------------
3637 \fn sme_WowlDelBcastPattern
3638 \brief Delete a pattern that was added for Pattern Byte Matching.
3639 \param hHal - The handle returned by macOpen.
3640 \param pattern - Pattern to be deleted
3641 \return eHalStatus
3642 eHAL_STATUS_FAILURE Cannot delete pattern
3643 eHAL_STATUS_SUCCESS Request accepted.
3644 ---------------------------------------------------------------------------*/
3645eHalStatus sme_WowlDelBcastPattern (
3646 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003647 tpSirWowlDelBcastPtrn pattern,
3648 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003649{
3650 eHalStatus status = eHAL_STATUS_FAILURE;
3651 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3652 status = sme_AcquireGlobalLock( &pMac->sme );
3653 if ( HAL_STATUS_SUCCESS( status ) )
3654 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003655 status = pmcWowlDelBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 sme_ReleaseGlobalLock( &pMac->sme );
3657 }
3658
3659 return (status);
3660}
3661
3662/* ---------------------------------------------------------------------------
3663 \fn sme_EnterWowl
3664 \brief This is the SME API exposed to HDD to request enabling of WOWL mode.
3665 WoWLAN works on top of BMPS mode. If the device is not in BMPS mode,
3666 SME will will cache the information that WOWL has been enabled and
3667 attempt to put the device in BMPS. On entry into BMPS, SME will
3668 enable the WOWL mode.
3669 Note 1: If we exit BMPS mode (someone requests full power), we
3670 will NOT resume WOWL when we go back to BMPS again. Request for full
3671 power (while in WOWL mode) means disable WOWL and go to full power.
3672 Note 2: Both UAPSD and WOWL work on top of BMPS. On entry into BMPS, SME
3673 will give priority to UAPSD and enable only UAPSD if both UAPSD and WOWL
3674 are required. Currently there is no requirement or use case to support
3675 UAPSD and WOWL at the same time.
3676
3677 \param hHal - The handle returned by macOpen.
3678 \param enterWowlCallbackRoutine - Callback routine provided by HDD.
3679 Used for success/failure notification by SME
3680 \param enterWowlCallbackContext - A cookie passed by HDD, that is passed back to HDD
3681 at the time of callback.
3682 \param wakeReasonIndCB - Callback routine provided by HDD.
3683 Used for Wake Reason Indication by SME
3684 \param wakeReasonIndCBContext - A cookie passed by HDD, that is passed back to HDD
3685 at the time of callback.
3686 \return eHalStatus
3687 eHAL_STATUS_SUCCESS Device is already in WoWLAN mode
3688 eHAL_STATUS_FAILURE Device cannot enter WoWLAN mode.
3689 eHAL_STATUS_PMC_PENDING Request accepted. SME will enable WOWL after
3690 BMPS mode is entered.
3691 ---------------------------------------------------------------------------*/
3692eHalStatus sme_EnterWowl (
3693 tHalHandle hHal,
3694 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
3695 void *enterWowlCallbackContext,
3696#ifdef WLAN_WAKEUP_EVENTS
3697 void (*wakeIndicationCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
3698 void *wakeIndicationCBContext,
3699#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003700 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003701{
3702 eHalStatus status = eHAL_STATUS_FAILURE;
3703 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3704 status = sme_AcquireGlobalLock( &pMac->sme );
3705 if ( HAL_STATUS_SUCCESS( status ) )
3706 {
3707 status = pmcEnterWowl (hHal, enterWowlCallbackRoutine, enterWowlCallbackContext,
3708#ifdef WLAN_WAKEUP_EVENTS
3709 wakeIndicationCB, wakeIndicationCBContext,
3710#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003711 wowlEnterParams, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 sme_ReleaseGlobalLock( &pMac->sme );
3713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 return (status);
3715}
3716/* ---------------------------------------------------------------------------
3717 \fn sme_ExitWowl
3718 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
3719 SME will initiate exit from WoWLAN mode and device will be put in BMPS
3720 mode.
3721 \param hHal - The handle returned by macOpen.
3722 \return eHalStatus
3723 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
3724 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
3725 ---------------------------------------------------------------------------*/
3726eHalStatus sme_ExitWowl (tHalHandle hHal)
3727{
3728 eHalStatus status = eHAL_STATUS_FAILURE;
3729 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3730 status = sme_AcquireGlobalLock( &pMac->sme );
3731 if ( HAL_STATUS_SUCCESS( status ) )
3732 {
3733 status = pmcExitWowl (hHal);
3734 sme_ReleaseGlobalLock( &pMac->sme );
3735 }
3736
3737 return (status);
3738}
3739
3740/* ---------------------------------------------------------------------------
3741
3742 \fn sme_RoamSetKey
3743
3744 \brief To set encryption key. This function should be called only when connected
3745 This is an asynchronous API.
3746
3747 \param pSetKeyInfo - pointer to a caller allocated object of tCsrSetContextInfo
3748
3749 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3750
3751 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3752
3753 FAILURE or RESOURCES The API finished and failed.
3754
3755 -------------------------------------------------------------------------------*/
3756eHalStatus sme_RoamSetKey(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 *pRoamId)
3757{
3758 eHalStatus status = eHAL_STATUS_FAILURE;
3759 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3760 tANI_U32 roamId;
3761#ifdef WLAN_SOFTAP_FEATURE
3762 tANI_U32 i;
3763 tCsrRoamSession *pSession = NULL;
3764#endif
3765
3766 status = sme_AcquireGlobalLock( &pMac->sme );
3767 if ( HAL_STATUS_SUCCESS( status ) )
3768 {
3769 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3770 if(pRoamId)
3771 {
3772 *pRoamId = roamId;
3773 }
3774
3775#ifdef WLAN_SOFTAP_FEATURE
3776 smsLog(pMac, LOG2, FL("keyLength\n"), pSetKey->keyLength);
3777
3778 for(i=0; i<pSetKey->keyLength; i++)
3779 smsLog(pMac, LOG2, FL("%02x"), pSetKey->Key[i]);
3780
3781 smsLog(pMac, LOG2, "\n sessionId=%d roamId=%d\n", sessionId, roamId);
3782
3783 pSession = CSR_GET_SESSION(pMac, sessionId);
3784
Jeff Johnson32d95a32012-09-10 13:15:23 -07003785 if(!pSession)
3786 {
3787 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3788 return eHAL_STATUS_FAILURE;
3789 }
3790
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
3792 {
3793 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
3794 {
3795 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
3796 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
3797 {
3798 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3799 }
3800 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
3801 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
3802 {
3803 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3804 }
3805 }
3806 }
3807#endif
3808
3809 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
3810 sme_ReleaseGlobalLock( &pMac->sme );
3811 }
3812
3813 return (status);
3814}
3815
3816
3817/* ---------------------------------------------------------------------------
3818
3819 \fn sme_RoamRemoveKey
3820
3821 \brief To set encryption key. This is an asynchronous API.
3822
3823 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
3824
3825 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3826
3827 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3828
3829 FAILURE or RESOURCES The API finished and failed.
3830
3831 -------------------------------------------------------------------------------*/
3832eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
3833 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
3834{
3835 eHalStatus status = eHAL_STATUS_FAILURE;
3836 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3837 tANI_U32 roamId;
3838
3839 status = sme_AcquireGlobalLock( &pMac->sme );
3840 if ( HAL_STATUS_SUCCESS( status ) )
3841 {
3842 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3843 if(pRoamId)
3844 {
3845 *pRoamId = roamId;
3846 }
3847 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
3848 sme_ReleaseGlobalLock( &pMac->sme );
3849 }
3850
3851 return (status);
3852}
3853
3854/* ---------------------------------------------------------------------------
3855 \fn sme_GetRssi
3856 \brief a wrapper function that client calls to register a callback to get RSSI
3857
3858 \param callback - SME sends back the requested stats using the callback
3859 \param staId - The station ID for which the stats is requested for
3860 \param pContext - user context to be passed back along with the callback
3861 \param pVosContext - vos context
3862 \return eHalStatus
3863 ---------------------------------------------------------------------------*/
3864eHalStatus sme_GetRssi(tHalHandle hHal,
3865 tCsrRssiCallback callback,
3866 tANI_U8 staId, tCsrBssid bssId,
3867 void *pContext, void* pVosContext)
3868{
3869 eHalStatus status = eHAL_STATUS_FAILURE;
3870 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3871
3872 status = sme_AcquireGlobalLock( &pMac->sme );
3873 if ( HAL_STATUS_SUCCESS( status ) )
3874 {
3875 status = csrGetRssi( pMac, callback,
3876 staId, bssId, pContext, pVosContext);
3877 sme_ReleaseGlobalLock( &pMac->sme );
3878 }
3879 return (status);
3880}
3881
3882/* ---------------------------------------------------------------------------
3883 \fn sme_GetStatistics
3884 \brief a wrapper function that client calls to register a callback to get
3885 different PHY level statistics from CSR.
3886
3887 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
3888 \param statsMask - The different category/categories of stats requester is looking for
3889 \param callback - SME sends back the requested stats using the callback
3890 \param periodicity - If requester needs periodic update in millisec, 0 means
3891 it's an one time request
3892 \param cache - If requester is happy with cached stats
3893 \param staId - The station ID for which the stats is requested for
3894 \param pContext - user context to be passed back along with the callback
3895 \return eHalStatus
3896 ---------------------------------------------------------------------------*/
3897eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
3898 tANI_U32 statsMask,
3899 tCsrStatsCallback callback,
3900 tANI_U32 periodicity, tANI_BOOLEAN cache,
3901 tANI_U8 staId, void *pContext)
3902{
3903 eHalStatus status = eHAL_STATUS_FAILURE;
3904 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3905
3906 status = sme_AcquireGlobalLock( &pMac->sme );
3907 if ( HAL_STATUS_SUCCESS( status ) )
3908 {
3909 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
3910 periodicity, cache, staId, pContext);
3911 sme_ReleaseGlobalLock( &pMac->sme );
3912 }
3913
3914 return (status);
3915
3916}
3917
3918/* ---------------------------------------------------------------------------
3919
3920 \fn sme_GetCountryCode
3921
3922 \brief To return the current country code. If no country code is applied, default country code is
3923 used to fill the buffer.
3924 If 11d supported is turned off, an error is return and the last applied/default country code is used.
3925 This is a synchronous API.
3926
3927 \param pBuf - pointer to a caller allocated buffer for returned country code.
3928
3929 \param pbLen For input, this parameter indicates how big is the buffer.
3930 Upon return, this parameter has the number of bytes for country. If pBuf
3931 doesn't have enough space, this function returns
3932 fail status and this parameter contains the number that is needed.
3933
3934 \return eHalStatus SUCCESS.
3935
3936 FAILURE or RESOURCES The API finished and failed.
3937
3938 -------------------------------------------------------------------------------*/
3939eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
3940{
3941 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3942
3943 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
3944}
3945
3946
3947/* ---------------------------------------------------------------------------
3948
3949 \fn sme_SetCountryCode
3950
3951 \brief To change the current/default country code.
3952 If 11d supported is turned off, an error is return.
3953 This is a synchronous API.
3954
3955 \param pCountry - pointer to a caller allocated buffer for the country code.
3956
3957 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
3958 whether a reset is required.
3959
3960 \return eHalStatus SUCCESS.
3961
3962 FAILURE or RESOURCES The API finished and failed.
3963
3964 -------------------------------------------------------------------------------*/
3965eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
3966{
3967 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3968
3969 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
3970}
3971
3972
3973/* ---------------------------------------------------------------------------
3974 \fn sme_ResetCountryCodeInformation
3975 \brief this function is to reset the country code current being used back to EEPROM default
3976 this includes channel list and power setting. This is a synchronous API.
3977 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
3978 a restart is needed to apply the change
3979 \return eHalStatus
3980 -------------------------------------------------------------------------------*/
3981eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
3982{
3983 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3984
3985 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
3986}
3987
3988
3989/* ---------------------------------------------------------------------------
3990 \fn sme_GetSupportedCountryCode
3991 \brief this function is to get a list of the country code current being supported
3992 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
3993 this has the country code list. 3 bytes for each country code. This may be NULL if
3994 caller wants to know the needed byte count.
3995 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
3996 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
3997 \return eHalStatus
3998 -------------------------------------------------------------------------------*/
3999eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
4000{
4001 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4002
4003 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
4004}
4005
4006
4007/* ---------------------------------------------------------------------------
4008 \fn sme_GetCurrentRegulatoryDomain
4009 \brief this function is to get the current regulatory domain. This is a synchronous API.
4010 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4011 SME. The function fails if 11d support is turned off.
4012 \param pDomain - Caller allocated buffer to return the current domain.
4013 \return eHalStatus SUCCESS.
4014
4015 FAILURE or RESOURCES The API finished and failed.
4016 -------------------------------------------------------------------------------*/
4017eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
4018{
4019 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4020 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4021
4022 if( pDomain )
4023 {
4024 if( csrIs11dSupported( pMac ) )
4025 {
4026 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
4027 status = eHAL_STATUS_SUCCESS;
4028 }
4029 else
4030 {
4031 status = eHAL_STATUS_FAILURE;
4032 }
4033 }
4034
4035 return ( status );
4036}
4037
4038
4039/* ---------------------------------------------------------------------------
4040 \fn sme_SetRegulatoryDomain
4041 \brief this function is to set the current regulatory domain.
4042 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4043 SME. This is a synchronous API.
4044 \param domainId - indicate the domain (defined in the driver) needs to set to.
4045 See v_REGDOMAIN_t for definition
4046 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
4047 a restart is needed to apply the change
4048 \return eHalStatus
4049 -------------------------------------------------------------------------------*/
4050eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
4051{
4052 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4053
4054 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
4055}
4056
4057
4058/* ---------------------------------------------------------------------------
4059
4060 \fn sme_GetRegulatoryDomainForCountry
4061
4062 \brief To return a regulatory domain base on a country code. This is a synchronous API.
4063
4064 \param pCountry - pointer to a caller allocated buffer for input country code.
4065
4066 \param pDomainId Upon successful return, it is the domain that country belongs to.
4067 If it is NULL, returning success means that the country code is known.
4068
4069 \return eHalStatus SUCCESS.
4070
4071 FAILURE or RESOURCES The API finished and failed.
4072
4073 -------------------------------------------------------------------------------*/
4074eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
4075{
4076 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4077
4078 return ( csrGetRegulatoryDomainForCountry( pMac, pCountry, pDomainId ) );
4079}
4080
4081
4082
4083
4084/* ---------------------------------------------------------------------------
4085
4086 \fn sme_GetSupportedRegulatoryDomains
4087
4088 \brief To return a list of supported regulatory domains. This is a synchronous API.
4089
4090 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
4091
4092 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
4093 Upon return, this parameter has the number for supported domains. If pDomains
4094 doesn't have enough space for all the supported domains, this function returns
4095 fail status and this parameter contains the number that is needed.
4096
4097 \return eHalStatus SUCCESS.
4098
4099 FAILURE or RESOURCES The API finished and failed.
4100
4101 -------------------------------------------------------------------------------*/
4102eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
4103{
4104 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4105
4106 //We support all domains for now
4107 if( pNumDomains )
4108 {
4109 if( NUM_REG_DOMAINS <= *pNumDomains )
4110 {
4111 status = eHAL_STATUS_SUCCESS;
4112 }
4113 *pNumDomains = NUM_REG_DOMAINS;
4114 }
4115 if( HAL_STATUS_SUCCESS( status ) )
4116 {
4117 if( pDomains )
4118 {
4119 pDomains[0] = REGDOMAIN_FCC;
4120 pDomains[1] = REGDOMAIN_ETSI;
4121 pDomains[2] = REGDOMAIN_JAPAN;
4122 pDomains[3] = REGDOMAIN_WORLD;
4123 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
4124 pDomains[5] = REGDOMAIN_APAC;
4125 pDomains[6] = REGDOMAIN_KOREA;
4126 pDomains[7] = REGDOMAIN_HI_5GHZ;
4127 pDomains[8] = REGDOMAIN_NO_5GHZ;
4128 }
4129 else
4130 {
4131 status = eHAL_STATUS_INVALID_PARAMETER;
4132 }
4133 }
4134
4135 return ( status );
4136}
4137
4138
4139//some support functions
4140tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
4141{
4142 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4143
4144 return ( csrIs11dSupported( pMac ) );
4145}
4146
4147
4148tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
4149{
4150 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4151
4152 return ( csrIs11hSupported( pMac ) );
4153}
4154
4155
4156tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
4157{
4158 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4159
4160 return ( csrIsWmmSupported( pMac ) );
4161}
4162
4163//Upper layer to get the list of the base channels to scan for passively 11d info from csr
4164eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
4165{
4166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4167
4168 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
4169}
4170
4171/* ---------------------------------------------------------------------------
4172
4173 \fn sme_ChangeCountryCode
4174
4175 \brief Change Country code from upperlayer during WLAN driver operation.
4176 This is a synchronous API.
4177
4178 \param hHal - The handle returned by macOpen.
4179
4180 \param pCountry New Country Code String
4181
4182 \return eHalStatus SUCCESS.
4183
4184 FAILURE or RESOURCES The API finished and failed.
4185
4186 -------------------------------------------------------------------------------*/
4187eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
4188 tSmeChangeCountryCallback callback,
4189 tANI_U8 *pCountry,
4190 void *pContext,
4191 void* pVosContext )
4192{
4193 eHalStatus status = eHAL_STATUS_FAILURE;
4194 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4195 vos_msg_t msg;
4196 tAniChangeCountryCodeReq *pMsg;
4197
4198 status = sme_AcquireGlobalLock( &pMac->sme );
4199 if ( HAL_STATUS_SUCCESS( status ) )
4200 {
4201 smsLog(pMac, LOG1, FL(" called\n"));
4202 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniChangeCountryCodeReq));
4203 if ( !HAL_STATUS_SUCCESS(status) )
4204 {
4205 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req \n");
4206 return status;
4207 }
4208
4209 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
4210 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
4211 palCopyMemory(pMac->hHdd, pMsg->countryCode, pCountry, 3);
4212 pMsg->changeCCCallback = callback;
4213 pMsg->pDevContext = pContext;
4214 pMsg->pVosContext = pVosContext;
4215
4216 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4217 msg.bodyptr = pMsg;
4218 msg.reserved = 0;
4219
4220 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
4221 {
4222 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self \n");
4223 palFreeMemory(pMac->hHdd, (void *)pMsg);
4224 status = eHAL_STATUS_FAILURE;
4225 }
4226 smsLog(pMac, LOG1, FL(" returned\n"));
4227 sme_ReleaseGlobalLock( &pMac->sme );
4228 }
4229
4230 return (status);
4231}
4232
4233/* ---------------------------------------------------------------------------
4234 \fn sme_BtcSignalBtEvent
4235 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
4236 BT event type and the current operating mode of Libra (full power,
4237 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
4238 would be employed.
4239 \param hHal - The handle returned by macOpen.
4240 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
4241 Caller owns the memory and is responsible for freeing it.
4242 \return VOS_STATUS
4243 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
4244 if BTC execution mode is set to BTC_WLAN_ONLY
4245 or BTC_PTA_ONLY.
4246 VOS_STATUS_SUCCESS BT Event passed to HAL
4247 ---------------------------------------------------------------------------*/
4248VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
4249{
4250 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4251#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4252 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4253
4254 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4255 {
4256 status = btcSignalBTEvent (hHal, pBtEvent);
4257 sme_ReleaseGlobalLock( &pMac->sme );
4258 }
4259#endif
4260 return (status);
4261}
4262
4263/* ---------------------------------------------------------------------------
4264 \fn sme_BtcSetConfig
4265 \brief API to change the current Bluetooth Coexistence (BTC) configuration
4266 This function should be invoked only after CFG download has completed.
4267 Calling it after sme_HDDReadyInd is recommended.
4268 \param hHal - The handle returned by macOpen.
4269 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
4270 Caller owns the memory and is responsible for freeing it.
4271 \return VOS_STATUS
4272 VOS_STATUS_E_FAILURE Config not passed to HAL.
4273 VOS_STATUS_SUCCESS Config passed to HAL
4274 ---------------------------------------------------------------------------*/
4275VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4276{
4277 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4278#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4279 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4280 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4281 {
4282 status = btcSetConfig (hHal, pSmeBtcConfig);
4283 sme_ReleaseGlobalLock( &pMac->sme );
4284 }
4285#endif
4286 return (status);
4287}
4288
4289/* ---------------------------------------------------------------------------
4290 \fn sme_BtcGetConfig
4291 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
4292 \param hHal - The handle returned by macOpen.
4293 \param pSmeBtcConfig - Pointer to a caller allocated object of type
4294 tSmeBtcConfig. Caller owns the memory and is responsible
4295 for freeing it.
4296 \return VOS_STATUS
4297 VOS_STATUS_E_FAILURE - failure
4298 VOS_STATUS_SUCCESS success
4299 ---------------------------------------------------------------------------*/
4300VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4301{
4302 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4303#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4304 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4305
4306 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4307 {
4308 status = btcGetConfig (hHal, pSmeBtcConfig);
4309 sme_ReleaseGlobalLock( &pMac->sme );
4310 }
4311#endif
4312 return (status);
4313}
4314/* ---------------------------------------------------------------------------
4315 \fn sme_SetCfgPrivacy
4316 \brief API to set configure privacy parameters
4317 \param hHal - The handle returned by macOpen.
4318 \param pProfile - Pointer CSR Roam profile.
4319 \param fPrivacy - This parameter indicates status of privacy
4320
4321 \return void
4322 ---------------------------------------------------------------------------*/
4323void sme_SetCfgPrivacy( tHalHandle hHal,
4324 tCsrRoamProfile *pProfile,
4325 tANI_BOOLEAN fPrivacy
4326 )
4327{
4328 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4329 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4330 {
4331 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
4332 sme_ReleaseGlobalLock( &pMac->sme );
4333 }
4334}
4335
4336#if defined WLAN_FEATURE_VOWIFI
4337/* ---------------------------------------------------------------------------
4338 \fn sme_NeighborReportRequest
4339 \brief API to request neighbor report.
4340 \param hHal - The handle returned by macOpen.
4341 \param pRrmNeighborReq - Pointer to a caller allocated object of type
4342 tRrmNeighborReq. Caller owns the memory and is responsible
4343 for freeing it.
4344 \return VOS_STATUS
4345 VOS_STATUS_E_FAILURE - failure
4346 VOS_STATUS_SUCCESS success
4347 ---------------------------------------------------------------------------*/
4348VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
4349 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
4350{
4351 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4352 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4353
4354 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4355 {
4356 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
4357 sme_ReleaseGlobalLock( &pMac->sme );
4358 }
4359
4360 return (status);
4361}
4362#endif
4363
4364//The following are debug APIs to support direct read/write register/memory
4365//They are placed in SME because HW cannot be access when in LOW_POWER state
4366//AND not connected. The knowledge and synchronization is done in SME
4367
4368//sme_DbgReadRegister
4369//Caller needs to validate the input values
4370VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
4371{
4372 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4373 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4374#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4375 tHddHandle hHdd = pMac->hHdd;
4376#endif
4377 tPmcPowerState PowerState;
4378 tANI_U32 sessionId = 0;
4379
4380 /* 1) To make Quarky work in FTM mode **************************************/
4381
4382 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4383 {
4384#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4385 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue)))
4386#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08004387 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004388#endif
4389 {
4390 return VOS_STATUS_SUCCESS;
4391 }
4392 return VOS_STATUS_E_FAILURE;
4393 }
4394
4395 /* 2) NON FTM mode driver *************************************************/
4396
4397 /* Acquire SME global lock */
4398 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4399 {
4400 return VOS_STATUS_E_FAILURE;
4401 }
4402
4403 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4404 {
4405 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4406 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4407 {
4408#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4409 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue )))
4410#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08004411 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004412#endif
4413 {
4414 status = VOS_STATUS_SUCCESS;
4415 }
4416 else
4417 {
4418 status = VOS_STATUS_E_FAILURE;
4419 }
4420 }
4421 else
4422 {
4423 status = VOS_STATUS_E_FAILURE;
4424 }
4425 }
4426
4427 /* This is a hack for Qualky/pttWniSocket
4428 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4429 if ( VOS_STATUS_SUCCESS != status )
4430 {
4431 *pRegValue = 0xDEADBEEF;
4432 status = VOS_STATUS_SUCCESS;
4433 }
4434
4435 /* Release SME global lock */
4436 sme_ReleaseGlobalLock(&pMac->sme);
4437
4438 return (status);
4439}
4440
4441
4442//sme_DbgWriteRegister
4443//Caller needs to validate the input values
4444VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
4445{
4446 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4447 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4448#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4449 tHddHandle hHdd = pMac->hHdd;
4450#endif
4451 tPmcPowerState PowerState;
4452 tANI_U32 sessionId = 0;
4453
4454 /* 1) To make Quarky work in FTM mode **************************************/
4455
4456 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4457 {
4458#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4459 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4460#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4461 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4462#endif
4463 {
4464 return VOS_STATUS_SUCCESS;
4465 }
4466 return VOS_STATUS_E_FAILURE;
4467 }
4468
4469 /* 2) NON FTM mode driver *************************************************/
4470
4471 /* Acquire SME global lock */
4472 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4473 {
4474 return VOS_STATUS_E_FAILURE;
4475 }
4476
4477 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4478 {
4479 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4480 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4481 {
4482#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4483 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4484#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4485 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4486#endif
4487 {
4488 status = VOS_STATUS_SUCCESS;
4489 }
4490 else
4491 {
4492 status = VOS_STATUS_E_FAILURE;
4493 }
4494 }
4495 else
4496 {
4497 status = VOS_STATUS_E_FAILURE;
4498 }
4499 }
4500
4501 /* Release SME global lock */
4502 sme_ReleaseGlobalLock(&pMac->sme);
4503
4504 return (status);
4505}
4506
4507
4508
4509//sme_DbgReadMemory
4510//Caller needs to validate the input values
4511//pBuf caller allocated buffer has the length of nLen
4512VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4513{
4514 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4515 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4516#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4517 v_PVOID_t pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *)hHal);
4518 tHddHandle hHdd = pMac->hHdd;
4519#endif
4520 tPmcPowerState PowerState;
4521 tANI_U32 sessionId = 0;
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004522 tANI_U32 cmd = READ_MEMORY_DUMP_CMD;
4523 tANI_U32 arg1 = memAddr;
4524 tANI_U32 arg2 = nLen/4;
4525 tANI_U32 arg3 = 4;
4526 tANI_U32 arg4 = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 /* 1) To make Quarky work in FTM mode **************************************/
4528
4529 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4530 {
4531#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4532 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4533#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004534 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8*)pBuf))
Jeff Johnson295189b2012-06-20 16:38:30 -07004535#endif
4536 {
4537 return VOS_STATUS_SUCCESS;
4538 }
4539 return VOS_STATUS_E_FAILURE;
4540 }
4541
4542 /* 2) NON FTM mode driver *************************************************/
4543
4544 /* Acquire SME global lock */
4545 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4546 {
4547 return VOS_STATUS_E_FAILURE;
4548 }
4549
4550 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4551 {
4552 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4553 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4554 {
4555#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4556 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(pvosGCTx, memAddr, (void *)pBuf, nLen)))
4557#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004558 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8 *)pBuf))
Jeff Johnson295189b2012-06-20 16:38:30 -07004559#endif
4560 {
4561 status = VOS_STATUS_SUCCESS;
4562 }
4563 else
4564 {
4565 status = VOS_STATUS_E_FAILURE;
4566 }
4567 }
4568 else
4569 {
4570 status = VOS_STATUS_E_FAILURE;
4571 }
4572 }
4573
4574 /* This is a hack for Qualky/pttWniSocket
4575 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4576 if (VOS_STATUS_SUCCESS != status)
4577 {
4578 vos_mem_set(pBuf, nLen, 0xCD);
4579 status = VOS_STATUS_SUCCESS;
4580 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware\n"));
4581 }
4582
4583 /* Release SME lock */
4584 sme_ReleaseGlobalLock(&pMac->sme);
4585
4586 return (status);
4587}
4588
4589
4590//sme_DbgWriteMemory
4591//Caller needs to validate the input values
4592VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4593{
4594 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4595 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4596#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4597 tHddHandle hHdd = pMac->hHdd;
4598#endif
4599 tPmcPowerState PowerState;
4600 tANI_U32 sessionId = 0;
4601
4602 /* 1) To make Quarky work in FTM mode **************************************/
4603
4604 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4605 {
4606#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4607 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4608#elif defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4609 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory( memAddr, (void *)pBuf, nLen))
4610#endif
4611 {
4612 return VOS_STATUS_SUCCESS;
4613 }
4614 return VOS_STATUS_E_FAILURE;
4615 }
4616
4617 /* 2) NON FTM mode driver *************************************************/
4618
4619 /* Acquire SME global lock */
4620 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4621 {
4622 return VOS_STATUS_E_FAILURE;
4623 }
4624
4625 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4626 {
4627 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4628 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4629 {
4630#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4631 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4632#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4633 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
4634#endif
4635 {
4636 status = VOS_STATUS_SUCCESS;
4637 }
4638 else
4639 {
4640 status = VOS_STATUS_E_FAILURE;
4641 }
4642 }
4643 else
4644 {
4645 status = VOS_STATUS_E_FAILURE;
4646 }
4647 }
4648
4649 /* Release Global lock */
4650 sme_ReleaseGlobalLock(&pMac->sme);
4651
4652 return (status);
4653}
4654
4655
4656void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
4657{
4658#ifdef WLAN_DEBUG
4659 // Verify against current log level
4660 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
4661 return;
4662 else
4663 {
4664 va_list marker;
4665
4666 va_start( marker, pString ); /* Initialize variable arguments. */
4667
4668 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
4669
4670 va_end( marker ); /* Reset variable arguments. */
4671 }
4672#endif
4673}
Jeff Johnson295189b2012-06-20 16:38:30 -07004674
Jeff Johnson295189b2012-06-20 16:38:30 -07004675/* ---------------------------------------------------------------------------
4676 \fn sme_GetWcnssWlanCompiledVersion
4677 \brief This API returns the version of the WCNSS WLAN API with
4678 which the HOST driver was built
4679 \param hHal - The handle returned by macOpen.
4680 \param pVersion - Points to the Version structure to be filled
4681 \return VOS_STATUS
4682 VOS_STATUS_E_INVAL - failure
4683 VOS_STATUS_SUCCESS success
4684 ---------------------------------------------------------------------------*/
4685VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
4686 tSirVersionType *pVersion)
4687{
4688 VOS_STATUS status = VOS_STATUS_SUCCESS;
4689 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4690 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4691
4692 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4693 {
4694 if( pVersion != NULL )
4695 {
4696 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
4697 }
4698 else
4699 {
4700 status = VOS_STATUS_E_INVAL;
4701 }
4702 sme_ReleaseGlobalLock( &pMac->sme );
4703 }
4704
4705 return (status);
4706}
4707
4708
4709/* ---------------------------------------------------------------------------
4710 \fn sme_GetWcnssWlanReportedVersion
4711 \brief This API returns the version of the WCNSS WLAN API with
4712 which the WCNSS driver reports it was built
4713 \param hHal - The handle returned by macOpen.
4714 \param pVersion - Points to the Version structure to be filled
4715 \return VOS_STATUS
4716 VOS_STATUS_E_INVAL - failure
4717 VOS_STATUS_SUCCESS success
4718 ---------------------------------------------------------------------------*/
4719VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
4720 tSirVersionType *pVersion)
4721{
4722 VOS_STATUS status = VOS_STATUS_SUCCESS;
4723 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4724 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4725
4726 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4727 {
4728 if( pVersion != NULL )
4729 {
4730 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
4731 }
4732 else
4733 {
4734 status = VOS_STATUS_E_INVAL;
4735 }
4736 sme_ReleaseGlobalLock( &pMac->sme );
4737 }
4738
4739 return (status);
4740}
4741
4742
4743/* ---------------------------------------------------------------------------
4744 \fn sme_GetWcnssSoftwareVersion
4745 \brief This API returns the version string of the WCNSS driver
4746 \param hHal - The handle returned by macOpen.
4747 \param pVersion - Points to the Version string buffer to be filled
4748 \param versionBufferSize - THe size of the Version string buffer
4749 \return VOS_STATUS
4750 VOS_STATUS_E_INVAL - failure
4751 VOS_STATUS_SUCCESS success
4752 ---------------------------------------------------------------------------*/
4753VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
4754 tANI_U8 *pVersion,
4755 tANI_U32 versionBufferSize)
4756{
4757 VOS_STATUS status = VOS_STATUS_SUCCESS;
4758 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4759 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4760
4761 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4762 {
4763 if( pVersion != NULL )
4764 {
4765 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
4766 versionBufferSize);
4767 }
4768 else
4769 {
4770 status = VOS_STATUS_E_INVAL;
4771 }
4772 sme_ReleaseGlobalLock( &pMac->sme );
4773 }
4774
4775 return (status);
4776}
4777
4778
4779/* ---------------------------------------------------------------------------
4780 \fn sme_GetWcnssHardwareVersion
4781 \brief This API returns the version string of the WCNSS hardware
4782 \param hHal - The handle returned by macOpen.
4783 \param pVersion - Points to the Version string buffer to be filled
4784 \param versionBufferSize - THe size of the Version string buffer
4785 \return VOS_STATUS
4786 VOS_STATUS_E_INVAL - failure
4787 VOS_STATUS_SUCCESS success
4788 ---------------------------------------------------------------------------*/
4789VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
4790 tANI_U8 *pVersion,
4791 tANI_U32 versionBufferSize)
4792{
4793 VOS_STATUS status = VOS_STATUS_SUCCESS;
4794 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4795 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4796
4797 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4798 {
4799 if( pVersion != NULL )
4800 {
4801 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
4802 versionBufferSize);
4803 }
4804 else
4805 {
4806 status = VOS_STATUS_E_INVAL;
4807 }
4808 sme_ReleaseGlobalLock( &pMac->sme );
4809 }
4810
4811 return (status);
4812}
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004813
Jeff Johnson295189b2012-06-20 16:38:30 -07004814
4815#ifdef FEATURE_WLAN_WAPI
4816/* ---------------------------------------------------------------------------
4817 \fn sme_RoamSetBKIDCache
4818 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
4819 candidate list.
4820 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4821 it is opened (by calling halOpen).
4822 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
4823 \param numItems - a variable that has the number of tBkidCacheInfo allocated
4824 when retruning, this is the number of items put into pBKIDCache
4825 \return eHalStatus - when fail, it usually means the buffer allocated is not
4826 big enough and pNumItems has the number of tBkidCacheInfo.
4827 ---------------------------------------------------------------------------*/
4828eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
4829 tANI_U32 numItems )
4830{
4831 eHalStatus status = eHAL_STATUS_FAILURE;
4832 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4833
4834 status = sme_AcquireGlobalLock( &pMac->sme );
4835 if ( HAL_STATUS_SUCCESS( status ) )
4836 {
4837 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
4838 sme_ReleaseGlobalLock( &pMac->sme );
4839 }
4840
4841 return (status);
4842}
4843
4844/* ---------------------------------------------------------------------------
4845 \fn sme_RoamGetBKIDCache
4846 \brief The SME API exposed to HDD to allow HDD to request SME to return its
4847 BKID cache.
4848 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4849 it is opened (by calling halOpen).
4850 \param pNum - caller allocated memory that has the space of the number of
4851 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
4852 in SME cache.
4853 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
4854 upon return
4855 \return eHalStatus - when fail, it usually means the buffer allocated is not
4856 big enough.
4857 ---------------------------------------------------------------------------*/
4858eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
4859 tBkidCacheInfo *pBkidCache)
4860{
4861 eHalStatus status = eHAL_STATUS_FAILURE;
4862 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4863
4864 status = sme_AcquireGlobalLock( &pMac->sme );
4865 if ( HAL_STATUS_SUCCESS( status ) )
4866 {
4867 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded\n"));
4868 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
4869 sme_ReleaseGlobalLock( &pMac->sme );
4870 }
4871
4872 return (status);
4873}
4874
4875/* ---------------------------------------------------------------------------
4876 \fn sme_RoamGetNumBKIDCache
4877 \brief The SME API exposed to HDD to allow HDD to request SME to return the
4878 number of BKID cache entries.
4879 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4880 it is opened (by calling halOpen).
4881 \return tANI_U32 - the number of BKID cache entries.
4882 ---------------------------------------------------------------------------*/
4883tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
4884{
4885 eHalStatus status = eHAL_STATUS_FAILURE;
4886 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4887 tANI_U32 numBkidCache = 0;
4888
4889 status = sme_AcquireGlobalLock( &pMac->sme );
4890 if ( HAL_STATUS_SUCCESS( status ) )
4891 {
4892 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
4893 sme_ReleaseGlobalLock( &pMac->sme );
4894 }
4895
4896 return (numBkidCache);
4897}
4898
4899/* ---------------------------------------------------------------------------
4900 \fn sme_ScanGetBKIDCandidateList
4901 \brief a wrapper function to return the BKID candidate list
4902 \param pBkidList - caller allocated buffer point to an array of
4903 tBkidCandidateInfo
4904 \param pNumItems - pointer to a variable that has the number of
4905 tBkidCandidateInfo allocated when retruning, this is
4906 either the number needed or number of items put into
4907 pPmkidList
4908 \return eHalStatus - when fail, it usually means the buffer allocated is not
4909 big enough and pNumItems
4910 has the number of tBkidCandidateInfo.
4911 \Note: pNumItems is a number of tBkidCandidateInfo,
4912 not sizeof(tBkidCandidateInfo) * something
4913 ---------------------------------------------------------------------------*/
4914eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
4915 tBkidCandidateInfo *pBkidList,
4916 tANI_U32 *pNumItems )
4917{
4918 eHalStatus status = eHAL_STATUS_FAILURE;
4919 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4920
4921 status = sme_AcquireGlobalLock( &pMac->sme );
4922 if ( HAL_STATUS_SUCCESS( status ) )
4923 {
4924 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
4925 sme_ReleaseGlobalLock( &pMac->sme );
4926 }
4927
4928 return (status);
4929}
4930#endif /* FEATURE_WLAN_WAPI */
4931
Jeff Johnsone7245742012-09-05 17:12:55 -07004932#ifdef FEATURE_OEM_DATA_SUPPORT
4933
4934/*****************************************************************************
4935 OEM DATA related modifications and function additions
4936 *****************************************************************************/
4937
4938/* ---------------------------------------------------------------------------
4939 \fn sme_getOemDataRsp
4940 \brief a wrapper function to obtain the OEM DATA RSP
4941 \param pOemDataRsp - A pointer to the response object
4942 \param pContext - a pointer passed in for the callback
4943 \return eHalStatus
4944 ---------------------------------------------------------------------------*/
4945eHalStatus sme_getOemDataRsp(tHalHandle hHal,
4946 tOemDataRsp **pOemDataRsp)
4947{
4948 eHalStatus status = eHAL_STATUS_SUCCESS;
4949 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4950
4951 do
4952 {
4953 //acquire the lock for the sme object
4954 status = sme_AcquireGlobalLock(&pMac->sme);
4955
4956 if(!HAL_STATUS_SUCCESS(status))
4957 {
4958 break;
4959 }
4960
4961 if(pMac->oemData.pOemDataRsp != NULL)
4962 {
4963 *pOemDataRsp = pMac->oemData.pOemDataRsp;
4964 }
4965 else
4966 {
4967 status = eHAL_STATUS_FAILURE;
4968 }
4969
4970 //release the lock for the sme object
4971 sme_ReleaseGlobalLock( &pMac->sme );
4972
4973 } while(0);
4974
4975 return status;
4976}
4977
4978/* ---------------------------------------------------------------------------
4979 \fn sme_OemDataReq
4980 \brief a wrapper function for OEM DATA REQ
4981 \param sessionId - session id to be used.
4982 \param pOemDataReqId - pointer to an object to get back the request ID
4983 \param callback - a callback function that is called upon finish
4984 \param pContext - a pointer passed in for the callback
4985 \return eHalStatus
4986 ---------------------------------------------------------------------------*/
4987eHalStatus sme_OemDataReq(tHalHandle hHal,
4988 tANI_U8 sessionId,
4989 tOemDataReqConfig *pOemDataReqConfig,
4990 tANI_U32 *pOemDataReqID,
4991 oemData_OemDataReqCompleteCallback callback,
4992 void *pContext)
4993{
4994 eHalStatus status = eHAL_STATUS_SUCCESS;
4995 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4996
4997 do
4998 {
4999 //acquire the lock for the sme object
5000 status = sme_AcquireGlobalLock(&pMac->sme);
5001 if(HAL_STATUS_SUCCESS(status))
5002 {
5003 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
5004
5005 if(pOemDataReqID)
5006 {
5007 *pOemDataReqID = lOemDataReqId;
5008 }
5009 else
5010 return eHAL_STATUS_FAILURE;
5011
5012 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
5013
5014 //release the lock for the sme object
5015 sme_ReleaseGlobalLock( &pMac->sme );
5016 }
5017 } while(0);
5018
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005019 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07005020
5021 return(status);
5022}
5023
5024#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005025
5026/*--------------------------------------------------------------------------
5027
5028 \brief sme_OpenSession() - Open a session for scan/roam operation.
5029
5030 This is a synchronous API.
5031
5032
5033 \param hHal - The handle returned by macOpen.
5034 \param callback - A pointer to the function caller specifies for roam/connect status indication
5035 \param pContext - The context passed with callback
5036 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
5037 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
5038
5039 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
5040
5041 Other status means SME is failed to open the session.
5042 eHAL_STATUS_RESOURCES - no more session available.
5043 \sa
5044
5045 --------------------------------------------------------------------------*/
5046eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback, void *pContext,
5047 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId)
5048{
5049 eHalStatus status;
5050 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5051
5052 if( NULL == pbSessionId )
5053 {
5054 status = eHAL_STATUS_INVALID_PARAMETER;
5055 }
5056 else
5057 {
5058 status = sme_AcquireGlobalLock( &pMac->sme );
5059 if ( HAL_STATUS_SUCCESS( status ) )
5060 {
5061 status = csrRoamOpenSession( pMac, callback, pContext, pSelfMacAddr, pbSessionId );
5062
5063 sme_ReleaseGlobalLock( &pMac->sme );
5064 }
5065 }
5066
5067 return ( status );
5068}
5069
5070
5071/*--------------------------------------------------------------------------
5072
5073 \brief sme_CloseSession() - Open a session for scan/roam operation.
5074
5075 This is a synchronous API.
5076
5077
5078 \param hHal - The handle returned by macOpen.
5079
5080 \param sessionId - A previous opened session's ID.
5081
5082 \return eHAL_STATUS_SUCCESS - session is closed.
5083
5084 Other status means SME is failed to open the session.
5085 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
5086 \sa
5087
5088 --------------------------------------------------------------------------*/
5089eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
5090 csrRoamSessionCloseCallback callback, void *pContext)
5091{
5092 eHalStatus status;
5093 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5094
5095 status = sme_AcquireGlobalLock( &pMac->sme );
5096 if ( HAL_STATUS_SUCCESS( status ) )
5097 {
5098 status = csrRoamCloseSession( pMac, sessionId, FALSE,
5099 callback, pContext );
5100
5101 sme_ReleaseGlobalLock( &pMac->sme );
5102 }
5103
5104 return ( status );
5105}
5106
5107#ifdef WLAN_SOFTAP_FEATURE
5108/* ---------------------------------------------------------------------------
5109
5110 \fn sme_RoamUpdateAPWPSIE
5111
5112 \brief To update AP's WPS IE. This function should be called after SME AP session is created
5113 This is an asynchronous API.
5114
5115 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
5116
5117 \return eHalStatus – SUCCESS –
5118
5119 FAILURE or RESOURCES – The API finished and failed.
5120
5121 -------------------------------------------------------------------------------*/
5122eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
5123{
5124
5125 eHalStatus status = eHAL_STATUS_FAILURE;
5126 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5127
5128 status = sme_AcquireGlobalLock( &pMac->sme );
5129 if ( HAL_STATUS_SUCCESS( status ) )
5130 {
5131
5132 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
5133
5134 sme_ReleaseGlobalLock( &pMac->sme );
5135 }
5136
5137 return (status);
5138}
5139/* ---------------------------------------------------------------------------
5140
5141 \fn sme_RoamUpdateAPWPARSNIEs
5142
5143 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
5144 This is an asynchronous API.
5145
5146 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
5147
5148 \return eHalStatus – SUCCESS –
5149
5150 FAILURE or RESOURCES – The API finished and failed.
5151
5152 -------------------------------------------------------------------------------*/
5153eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
5154{
5155
5156 eHalStatus status = eHAL_STATUS_FAILURE;
5157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5158
5159 status = sme_AcquireGlobalLock( &pMac->sme );
5160 if ( HAL_STATUS_SUCCESS( status ) )
5161 {
5162
5163 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
5164
5165 sme_ReleaseGlobalLock( &pMac->sme );
5166 }
5167
5168 return (status);
5169}
5170#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005171/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07005172
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005173 \fn sme_ChangeMCCBeaconInterval
5174
5175 \brief To update P2P-GO beaconInterval. This function should be called after
5176 disassociating all the station is done
5177 This is an asynchronous API.
5178
5179 \param
5180
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005181 \return eHalStatus SUCCESS
5182 FAILURE or RESOURCES
5183 The API finished and failed.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005184
5185 -------------------------------------------------------------------------------*/
5186eHalStatus sme_ChangeMCCBeaconInterval(tHalHandle hHal, tANI_U8 sessionId)
5187{
5188 eHalStatus status = eHAL_STATUS_FAILURE;
5189 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5190
5191 smsLog(pMac, LOG1, FL("Update Beacon PARAMS \n"));
5192 status = sme_AcquireGlobalLock( &pMac->sme );
5193 if ( HAL_STATUS_SUCCESS( status ) )
5194 {
5195 status = csrSendChngMCCBeaconInterval( pMac, sessionId);
5196 sme_ReleaseGlobalLock( &pMac->sme );
5197 }
5198 return (status);
5199}
Jeff Johnson295189b2012-06-20 16:38:30 -07005200
5201/*-------------------------------------------------------------------------------*
5202
5203 \fn sme_sendBTAmpEvent
5204
5205 \brief to receive the coex priorty request from BT-AMP PAL
5206 and send the BT_AMP link state to HAL
5207
5208 \param btAmpEvent - btAmpEvent
5209
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005210 \return eHalStatus: SUCCESS : BTAmp event successfully sent to HAL
Jeff Johnson295189b2012-06-20 16:38:30 -07005211
5212 FAILURE: API failed
5213
5214-------------------------------------------------------------------------------*/
5215
5216eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
5217{
5218 vos_msg_t msg;
5219 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
5220 eHalStatus status = eHAL_STATUS_FAILURE;
5221
5222 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tpSmeBtAmpEvent));
5223 if (NULL == ptrSmeBtAmpEvent)
5224 {
5225 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005226 "Not able to allocate memory for BTAmp event", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 return status;
5228 }
5229
5230 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
5231 msg.type = WDA_SIGNAL_BTAMP_EVENT;
5232 msg.reserved = 0;
5233 msg.bodyptr = ptrSmeBtAmpEvent;
5234
5235 //status = halFW_SendBTAmpEventMesg(pMac, event);
5236
5237 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5238 {
5239 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005240 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 vos_mem_free(ptrSmeBtAmpEvent);
5242 return status;
5243 }
5244
5245 return eHAL_STATUS_SUCCESS;
5246
5247}
5248
5249/* ---------------------------------------------------------------------------
5250 \fn sme_SetHostOffload
5251 \brief API to set the host offload feature.
5252 \param hHal - The handle returned by macOpen.
5253 \param pRequest - Pointer to the offload request.
5254 \return eHalStatus
5255 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005256eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
5257 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005258{
5259 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07005260 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005261
5262 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5263 {
5264#ifdef WLAN_NS_OFFLOAD
5265 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
5266 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005267 status = pmcSetNSOffload( hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 }
5269 else
5270#endif //WLAN_NS_OFFLOAD
5271 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005272 status = pmcSetHostOffload (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 }
5274 sme_ReleaseGlobalLock( &pMac->sme );
5275 }
5276
5277 return (status);
5278}
5279
5280#ifdef WLAN_FEATURE_GTK_OFFLOAD
5281/* ---------------------------------------------------------------------------
5282 \fn sme_SetGTKOffload
5283 \brief API to set GTK offload information.
5284 \param hHal - The handle returned by macOpen.
5285 \param pRequest - Pointer to the GTK offload request.
5286 \return eHalStatus
5287 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005288eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest,
5289 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005290{
5291 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5292 eHalStatus status;
5293
5294 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5295 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005296 status = pmcSetGTKOffload( hHal, pRequest, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005297 sme_ReleaseGlobalLock( &pMac->sme );
5298 }
5299
5300 return (status);
5301}
5302
5303/* ---------------------------------------------------------------------------
5304 \fn sme_GetGTKOffload
5305 \brief API to get GTK offload information.
5306 \param hHal - The handle returned by macOpen.
5307 \param pRequest - Pointer to the GTK offload response.
5308 \return eHalStatus
5309 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005310eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
5311 void *callbackContext, tANI_U8 sessionId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005312{
5313 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5314 eHalStatus status;
5315
5316 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5317 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005318 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005319 sme_ReleaseGlobalLock( &pMac->sme );
5320 }
5321
5322 return (status);
5323}
5324#endif // WLAN_FEATURE_GTK_OFFLOAD
5325
5326/* ---------------------------------------------------------------------------
5327 \fn sme_SetKeepAlive
5328 \brief API to set the Keep Alive feature.
5329 \param hHal - The handle returned by macOpen.
5330 \param pRequest - Pointer to the Keep Alive request.
5331 \return eHalStatus
5332 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005333eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
5334 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005335{
5336 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5337 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5339 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005340 status = pmcSetKeepAlive (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 sme_ReleaseGlobalLock( &pMac->sme );
5342 }
5343
5344 return (status);
5345}
5346
5347#ifdef FEATURE_WLAN_SCAN_PNO
5348/* ---------------------------------------------------------------------------
5349 \fn sme_SetPreferredNetworkList
5350 \brief API to set the Preferred Network List Offload feature.
5351 \param hHal - The handle returned by macOpen.
5352 \param pRequest - Pointer to the offload request.
5353 \return eHalStatus
5354 ---------------------------------------------------------------------------*/
5355eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
5356{
5357 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5358 eHalStatus status;
5359
5360 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5361 {
5362 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
5363 sme_ReleaseGlobalLock( &pMac->sme );
5364 }
5365
5366 return (status);
5367}
5368
5369eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
5370{
5371 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5372 eHalStatus status;
5373
5374 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5375 {
5376 pmcSetRssiFilter(hHal, rssiThreshold);
5377 sme_ReleaseGlobalLock( &pMac->sme );
5378 }
5379
5380 return (status);
5381}
5382
5383#endif // FEATURE_WLAN_SCAN_PNO
5384
5385eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams)
5386{
5387 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5388 eHalStatus status;
5389
5390 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5391 {
5392 pmcSetPowerParams(hHal, pwParams);
5393 sme_ReleaseGlobalLock( &pMac->sme );
5394 }
5395
5396 return (status);
5397}
5398
5399/* ---------------------------------------------------------------------------
5400 \fn sme_AbortMacScan
5401 \brief API to cancel MAC scan.
5402 \param hHal - The handle returned by macOpen.
5403 \return VOS_STATUS
5404 VOS_STATUS_E_FAILURE - failure
5405 VOS_STATUS_SUCCESS success
5406 ---------------------------------------------------------------------------*/
5407eHalStatus sme_AbortMacScan(tHalHandle hHal)
5408{
5409 eHalStatus status;
5410 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5411
5412 status = sme_AcquireGlobalLock( &pMac->sme );
5413 if ( HAL_STATUS_SUCCESS( status ) )
5414 {
5415 status = csrScanAbortMacScan(pMac);
5416
5417 sme_ReleaseGlobalLock( &pMac->sme );
5418 }
5419
5420 return ( status );
5421}
5422
5423/* ----------------------------------------------------------------------------
5424 \fn sme_GetOperationChannel
5425 \brief API to get current channel on which STA is parked
5426 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005427 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 \returns eHAL_STATUS_SUCCESS
5429 eHAL_STATUS_FAILURE
5430-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005431eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005432{
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5434 tCsrRoamSession *pSession;
5435
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005436 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005438 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005439
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005440 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
5441 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005442#ifdef WLAN_SOFTAP_FEATURE
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005443 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
5444#endif
5445 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
5446 {
5447 *pChannel =pSession->connectedProfile.operationChannel;
5448 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 }
5450 }
5451 return eHAL_STATUS_FAILURE;
5452}// sme_GetOperationChannel ends here
5453
5454#ifdef WLAN_FEATURE_P2P
5455/* ---------------------------------------------------------------------------
5456
5457 \fn sme_RegisterMgtFrame
5458
5459 \brief To register managment frame of specified type and subtype.
5460 \param frameType - type of the frame that needs to be passed to HDD.
5461 \param matchData - data which needs to be matched before passing frame
5462 to HDD.
5463 \param matchDataLen - Length of matched data.
5464 \return eHalStatus
5465 -------------------------------------------------------------------------------*/
5466eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5467 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5468{
5469 eHalStatus status = eHAL_STATUS_SUCCESS;
5470 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5471
5472 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5473 {
5474 tSirRegisterMgmtFrame *pMsg;
5475 tANI_U16 len;
5476 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005477
5478 if(!pSession)
5479 {
5480 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5481 return eHAL_STATUS_FAILURE;
5482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005483
5484 if( !pSession->sessionActive )
5485 {
5486 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005487 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 sme_ReleaseGlobalLock( &pMac->sme );
5489 return eHAL_STATUS_FAILURE;
5490 }
5491
5492 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5493
5494 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5495 if(HAL_STATUS_SUCCESS(status))
5496 {
5497 palZeroMemory(pMac->hHdd, pMsg, len);
5498 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5499 pMsg->length = len;
5500 pMsg->sessionId = sessionId;
5501 pMsg->registerFrame = VOS_TRUE;
5502 pMsg->frameType = frameType;
5503 pMsg->matchLen = matchLen;
5504 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5505 status = palSendMBMessage(pMac->hHdd, pMsg);
5506 }
5507 sme_ReleaseGlobalLock( &pMac->sme );
5508 }
5509 return status;
5510}
5511
5512/* ---------------------------------------------------------------------------
5513
5514 \fn sme_DeregisterMgtFrame
5515
5516 \brief To De-register managment frame of specified type and subtype.
5517 \param frameType - type of the frame that needs to be passed to HDD.
5518 \param matchData - data which needs to be matched before passing frame
5519 to HDD.
5520 \param matchDataLen - Length of matched data.
5521 \return eHalStatus
5522 -------------------------------------------------------------------------------*/
5523eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5524 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5525{
5526 eHalStatus status = eHAL_STATUS_SUCCESS;
5527 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5528
5529 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5530 {
5531 tSirRegisterMgmtFrame *pMsg;
5532 tANI_U16 len;
5533 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005534
5535 if(!pSession)
5536 {
5537 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5538 return eHAL_STATUS_FAILURE;
5539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005540
5541 if( !pSession->sessionActive )
5542 {
5543 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005544 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 sme_ReleaseGlobalLock( &pMac->sme );
5546 return eHAL_STATUS_FAILURE;
5547 }
5548
5549 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5550
5551 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5552 if(HAL_STATUS_SUCCESS(status))
5553 {
5554 palZeroMemory(pMac->hHdd, pMsg, len);
5555 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5556 pMsg->length = len;
5557 pMsg->registerFrame = VOS_FALSE;
5558 pMsg->frameType = frameType;
5559 pMsg->matchLen = matchLen;
5560 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5561 status = palSendMBMessage(pMac->hHdd, pMsg);
5562 }
5563 sme_ReleaseGlobalLock( &pMac->sme );
5564 }
5565 return status;
5566}
5567
5568/* ---------------------------------------------------------------------------
5569 \fn sme_RemainOnChannel
5570 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
5571 \param hHal - The handle returned by macOpen.
5572 \param pRequest - channel
5573 \param duration - duration in ms
5574 \param callback - HDD registered callback to process reaminOnChannelRsp
5575 \param context - HDD Callback param
5576 \return eHalStatus
5577 ---------------------------------------------------------------------------*/
5578
5579eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
5580 tANI_U8 channel, tANI_U32 duration,
5581 remainOnChanCallback callback,
5582 void *pContext)
5583{
5584 eHalStatus status = eHAL_STATUS_SUCCESS;
5585 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5586
5587 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5588 {
5589 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext
5590#ifdef WLAN_FEATURE_P2P_INTERNAL
5591 , eP2PRemainOnChnReasonUnknown
5592#endif
5593 );
5594 sme_ReleaseGlobalLock( &pMac->sme );
5595 }
5596 return(status);
5597}
5598
5599/* ---------------------------------------------------------------------------
5600 \fn sme_ReportProbeReq
5601 \brief API to enable/disable forwarding of probeReq to apps in p2p.
5602 \param hHal - The handle returned by macOpen.
5603 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
5604 \return eHalStatus
5605 ---------------------------------------------------------------------------*/
5606
5607#ifndef WLAN_FEATURE_CONCURRENT_P2P
5608eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
5609{
5610 eHalStatus status = eHAL_STATUS_SUCCESS;
5611 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5612
5613 do
5614 {
5615 //acquire the lock for the sme object
5616 status = sme_AcquireGlobalLock(&pMac->sme);
5617 if(HAL_STATUS_SUCCESS(status))
5618 {
5619 /* call set in context */
5620 pMac->p2pContext.probeReqForwarding = flag;
5621 //release the lock for the sme object
5622 sme_ReleaseGlobalLock( &pMac->sme );
5623 }
5624 } while(0);
5625
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005626 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005627
5628 return(status);
5629}
5630
5631/* ---------------------------------------------------------------------------
5632 \fn sme_updateP2pIe
5633 \brief API to set the P2p Ie in p2p context
5634 \param hHal - The handle returned by macOpen.
5635 \param p2pIe - Ptr to p2pIe from HDD.
5636 \param p2pIeLength: length of p2pIe
5637 \return eHalStatus
5638 ---------------------------------------------------------------------------*/
5639
5640eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
5641{
5642 eHalStatus status = eHAL_STATUS_SUCCESS;
5643 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5644
5645 //acquire the lock for the sme object
5646 status = sme_AcquireGlobalLock(&pMac->sme);
5647 if(HAL_STATUS_SUCCESS(status))
5648 {
5649 if(NULL != pMac->p2pContext.probeRspIe){
5650 vos_mem_free(pMac->p2pContext.probeRspIe);
5651 pMac->p2pContext.probeRspIeLength = 0;
5652 }
5653
5654 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
5655 if (NULL == pMac->p2pContext.probeRspIe)
5656 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005657 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 pMac->p2pContext.probeRspIeLength = 0;
5659 status = eHAL_STATUS_FAILURE;
5660 }
5661 else
5662 {
5663 pMac->p2pContext.probeRspIeLength = p2pIeLength;
5664
5665 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
5666 pMac->p2pContext.probeRspIe,
5667 pMac->p2pContext.probeRspIeLength );
5668 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
5669 p2pIeLength);
5670 }
5671
5672 //release the lock for the sme object
5673 sme_ReleaseGlobalLock( &pMac->sme );
5674 }
5675
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005676 smsLog(pMac, LOG2, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005677
5678 return(status);
5679}
5680#endif
5681
5682/* ---------------------------------------------------------------------------
5683 \fn sme_sendAction
5684 \brief API to send action frame from supplicant.
5685 \param hHal - The handle returned by macOpen.
5686 \return eHalStatus
5687 ---------------------------------------------------------------------------*/
5688
5689eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07005690 const tANI_U8 *pBuf, tANI_U32 len,
5691 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07005692{
5693 eHalStatus status = eHAL_STATUS_SUCCESS;
5694 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5695
5696 //acquire the lock for the sme object
5697 status = sme_AcquireGlobalLock(&pMac->sme);
5698 if(HAL_STATUS_SUCCESS(status))
5699 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005700 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 //release the lock for the sme object
5702 sme_ReleaseGlobalLock( &pMac->sme );
5703 }
5704
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005705 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005706
5707 return(status);
5708}
5709
5710eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
5711{
5712 eHalStatus status = eHAL_STATUS_SUCCESS;
5713 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5714
5715 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5716 {
5717 status = p2pCancelRemainOnChannel (hHal, sessionId);
5718 sme_ReleaseGlobalLock( &pMac->sme );
5719 }
5720 return(status);
5721}
5722
5723//Power Save Related
5724eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
5725{
5726 eHalStatus status = eHAL_STATUS_SUCCESS;
5727 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5728
5729 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5730 {
5731 status = p2pSetPs (hHal, data);
5732 sme_ReleaseGlobalLock( &pMac->sme );
5733 }
5734 return(status);
5735}
5736
5737#endif
5738
5739/* ---------------------------------------------------------------------------
5740
5741 \fn sme_ConfigureRxpFilter
5742
5743 \brief
5744 SME will pass this request to lower mac to set/reset the filter on RXP for
5745 multicast & broadcast traffic.
5746
5747 \param
5748
5749 hHal - The handle returned by macOpen.
5750
5751 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
5752 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
5753 on this param. In future we can use this as a mask to set various types of
5754 filters as suggested below:
5755 FILTER_ALL_MULTICAST:
5756 FILTER_ALL_BROADCAST:
5757 FILTER_ALL_MULTICAST_BROADCAST:
5758
5759
5760 \return eHalStatus
5761
5762
5763--------------------------------------------------------------------------- */
5764eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
5765 tpSirWlanSetRxpFilters wlanRxpFilterParam)
5766{
5767 eHalStatus status = eHAL_STATUS_SUCCESS;
5768 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5769 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5770 vos_msg_t vosMessage;
5771
5772 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5773 {
5774 /* serialize the req through MC thread */
5775 vosMessage.bodyptr = wlanRxpFilterParam;
5776 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
5777 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5778 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5779 {
5780 status = eHAL_STATUS_FAILURE;
5781 }
5782 sme_ReleaseGlobalLock( &pMac->sme );
5783 }
5784 return(status);
5785}
5786
5787#ifdef FEATURE_WLAN_INTEGRATED_SOC
5788/* ---------------------------------------------------------------------------
5789
5790 \fn sme_ConfigureSuspendInd
5791
5792 \brief
5793 SME will pass this request to lower mac to Indicate that the wlan needs to
5794 be suspended
5795
5796 \param
5797
5798 hHal - The handle returned by macOpen.
5799
5800 wlanSuspendParam- Depicts the wlan suspend params
5801
5802
5803 \return eHalStatus
5804
5805
5806--------------------------------------------------------------------------- */
5807eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
5808 tpSirWlanSuspendParam wlanSuspendParam)
5809{
5810 eHalStatus status = eHAL_STATUS_SUCCESS;
5811 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5812 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5813 vos_msg_t vosMessage;
5814
5815 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5816 {
5817 /* serialize the req through MC thread */
5818 vosMessage.bodyptr = wlanSuspendParam;
5819 vosMessage.type = WDA_WLAN_SUSPEND_IND;
5820 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5821 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5822 {
5823 status = eHAL_STATUS_FAILURE;
5824 }
5825 sme_ReleaseGlobalLock( &pMac->sme );
5826 }
5827 return(status);
5828}
5829
5830/* ---------------------------------------------------------------------------
5831
5832 \fn sme_ConfigureResumeReq
5833
5834 \brief
5835 SME will pass this request to lower mac to Indicate that the wlan needs to
5836 be Resumed
5837
5838 \param
5839
5840 hHal - The handle returned by macOpen.
5841
5842 wlanResumeParam- Depicts the wlan resume params
5843
5844
5845 \return eHalStatus
5846
5847
5848--------------------------------------------------------------------------- */
5849eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
5850 tpSirWlanResumeParam wlanResumeParam)
5851{
5852 eHalStatus status = eHAL_STATUS_SUCCESS;
5853 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5854 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5855 vos_msg_t vosMessage;
5856
5857 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5858 {
5859 /* serialize the req through MC thread */
5860 vosMessage.bodyptr = wlanResumeParam;
5861 vosMessage.type = WDA_WLAN_RESUME_REQ;
5862 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5863 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5864 {
5865 status = eHAL_STATUS_FAILURE;
5866 }
5867 sme_ReleaseGlobalLock( &pMac->sme );
5868 }
5869 return(status);
5870}
5871
5872#endif
5873/* ---------------------------------------------------------------------------
5874
5875 \fn sme_GetInfraSessionId
5876
5877 \brief To get the session ID for infra session, if connected
5878 This is a synchronous API.
5879
5880 \param hHal - The handle returned by macOpen.
5881
5882 \return sessionid, -1 if infra session is not connected
5883
5884 -------------------------------------------------------------------------------*/
5885tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
5886{
5887 eHalStatus status = eHAL_STATUS_FAILURE;
5888 tANI_S8 sessionid = -1;
5889 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5890
5891 status = sme_AcquireGlobalLock( &pMac->sme );
5892 if ( HAL_STATUS_SUCCESS( status ) )
5893 {
5894
5895 sessionid = csrGetInfraSessionId( pMac);
5896
5897 sme_ReleaseGlobalLock( &pMac->sme );
5898 }
5899
5900 return (sessionid);
5901}
5902
5903/* ---------------------------------------------------------------------------
5904
5905 \fn sme_GetInfraOperationChannel
5906
5907 \brief To get the operating channel for infra session, if connected
5908 This is a synchronous API.
5909
5910 \param hHal - The handle returned by macOpen.
5911 \param sessionId - the sessionId returned by sme_OpenSession.
5912
5913 \return operating channel, 0 if infra session is not connected
5914
5915 -------------------------------------------------------------------------------*/
5916tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
5917{
5918 eHalStatus status = eHAL_STATUS_FAILURE;
5919 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5920 tANI_U8 channel = 0;
5921 status = sme_AcquireGlobalLock( &pMac->sme );
5922 if ( HAL_STATUS_SUCCESS( status ) )
5923 {
5924
5925 channel = csrGetInfraOperationChannel( pMac, sessionId);
5926
5927 sme_ReleaseGlobalLock( &pMac->sme );
5928 }
5929
5930 return (channel);
5931}
5932
5933//This routine will return poerating channel on which other BSS is operating to be used for concurrency mode.
5934//If other BSS is not up or not connected it will return 0
5935tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
5936{
5937 eHalStatus status = eHAL_STATUS_FAILURE;
5938 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5939 tANI_U8 channel = 0;
5940 status = sme_AcquireGlobalLock( &pMac->sme );
5941 if ( HAL_STATUS_SUCCESS( status ) )
5942 {
5943
5944 channel = csrGetConcurrentOperationChannel( pMac );
5945 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005946 " Other Concurrent Channel = %d", __func__,channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 sme_ReleaseGlobalLock( &pMac->sme );
5948 }
5949
5950 return (channel);
5951}
5952
5953#ifdef FEATURE_WLAN_SCAN_PNO
5954/******************************************************************************
5955*
5956* Name: sme_PreferredNetworkFoundInd
5957*
5958* Description:
5959* Invoke Preferred Network Found Indication
5960*
5961* Parameters:
5962* hHal - HAL handle for device
5963* pMsg - found network description
5964*
5965* Returns: eHalStatus
5966*
5967******************************************************************************/
5968eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
5969{
5970 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5971 eHalStatus status = eHAL_STATUS_SUCCESS;
5972 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
5973
5974 if (NULL == pMsg)
5975 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005976 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 status = eHAL_STATUS_FAILURE;
5978 }
5979 else
5980 {
5981 if (pPrefNetworkFoundInd->ssId.length > 0)
5982 {
5983 smsLog(pMac, LOG1, "Preferred Network Found Indication in %s(), SSID=%s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005984 __func__, pPrefNetworkFoundInd->ssId.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005985
5986
5987 /* Call Preferred Netowrk Found Indication callback routine. */
5988 if (pMac->pmc.prefNetwFoundCB != NULL)
5989 {
5990 pMac->pmc.prefNetwFoundCB(pMac->pmc.preferredNetworkFoundIndCallbackContext, pPrefNetworkFoundInd);
5991 }
5992
5993 }
5994 else
5995 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005996 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 status = eHAL_STATUS_FAILURE;
5998 }
5999 }
6000
6001
6002 return(status);
6003}
6004
6005#endif // FEATURE_WLAN_SCAN_PNO
6006
6007
6008eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
6009{
6010 eHalStatus status = eHAL_STATUS_FAILURE;
6011 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6012
6013 status = sme_AcquireGlobalLock( &pMac->sme );
6014 if ( HAL_STATUS_SUCCESS( status ) )
6015 {
6016 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
6017 sme_ReleaseGlobalLock( &pMac->sme );
6018 }
6019
6020 return (status);
6021}
6022
6023
6024/* ---------------------------------------------------------------------------
6025
6026 \fn sme_SetTxPerTracking
6027
6028 \brief Set Tx PER tracking configuration parameters
6029
6030 \param hHal - The handle returned by macOpen.
6031 \param pTxPerTrackingConf - Tx PER configuration parameters
6032
6033 \return eHalStatus
6034
6035 -------------------------------------------------------------------------------*/
6036eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
6037 void (*pCallbackfn) (void *pCallbackContext),
6038 void *pCallbackContext,
6039 tpSirTxPerTrackingParam pTxPerTrackingParam)
6040{
6041 vos_msg_t msg;
6042 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
6043 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6044
6045 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6046 {
6047 pMac->sme.pTxPerHitCallback = pCallbackfn;
6048 pMac->sme.pTxPerHitCbContext = pCallbackContext;
6049 sme_ReleaseGlobalLock( &pMac->sme );
6050 }
6051
6052 // free this memory in failure case or WDA request callback function
6053 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
6054 if (NULL == pTxPerTrackingParamReq)
6055 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006056 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 -07006057 return eHAL_STATUS_FAILURE;
6058 }
6059
6060 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam, sizeof(tSirTxPerTrackingParam));
6061 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
6062 msg.reserved = 0;
6063 msg.bodyptr = pTxPerTrackingParamReq;
6064
6065 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6066 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006067 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 -07006068 vos_mem_free(pTxPerTrackingParamReq);
6069 return eHAL_STATUS_FAILURE;
6070 }
6071
6072 return eHAL_STATUS_SUCCESS;
6073}
6074
6075/* ---------------------------------------------------------------------------
6076
6077 \fn sme_HandleChangeCountryCode
6078
6079 \brief Change Country code, Reg Domain and channel list
6080
6081 \details Country Code Priority
6082 0 = 11D > Configured Country > NV
6083 1 = Configured Country > 11D > NV
6084 If Supplicant country code is priority than 11d is disabled.
6085 If 11D is enabled, we update the country code after every scan.
6086 Hence when Supplicant country code is priority, we don't need 11D info.
6087 Country code from Supplicant is set as current courtry code.
6088 User can send reset command XX (instead of country code) to reset the
6089 country code to default values which is read from NV.
6090 In case of reset, 11D is enabled and default NV code is Set as current country code
6091 If 11D is priority,
6092 Than Supplicant country code code is set to default code. But 11D code is set as current country code
6093
6094 \param pMac - The handle returned by macOpen.
6095 \param pMsgBuf - MSG Buffer
6096
6097 \return eHalStatus
6098
6099 -------------------------------------------------------------------------------*/
6100eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
6101{
6102 eHalStatus status = eHAL_STATUS_SUCCESS;
6103 tAniChangeCountryCodeReq *pMsg;
6104 v_REGDOMAIN_t domainIdIoctl;
6105 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6106 static uNvTables nvTables;
6107 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
6108
6109
6110 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
6111 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
6112 {
6113 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6114
6115 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
6116
6117 /* read the country code from NV and use it */
6118 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
6119 {
6120 palCopyMemory( pMac->hHdd, pMsg->countryCode , nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
6121 }
6122 else
6123 {
6124 status = eHAL_STATUS_FAILURE;
6125 return status;
6126 }
6127 }
6128 else
6129 {
6130 /* if Supplicant country code has priority, disable 11d */
6131 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority)
6132 {
6133 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
6134 }
6135 }
6136
6137 /* WEXT set country code means
6138 * 11D should be supported?
6139 * 11D Channel should be enforced?
6140 * 11D Country code should be matched?
6141 * 11D Reg Domian should be matched?
6142 * Country string changed */
6143 if(pMac->roam.configParam.Is11dSupportEnabled &&
6144 pMac->roam.configParam.fEnforce11dChannels &&
6145 pMac->roam.configParam.fEnforceCountryCodeMatch &&
6146 pMac->roam.configParam.fEnforceDefaultDomain &&
6147 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
6148 {
6149 /* All 11D related options are already enabled
6150 * Country string is not changed
6151 * Do not need do anything for country code change request */
6152 return eHAL_STATUS_SUCCESS;
6153 }
6154
6155 /* Set Current Country code and Current Regulatory domain */
6156 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
6157 if(eHAL_STATUS_SUCCESS != status)
6158 {
6159 /* Supplicant country code failed. So give 11D priority */
6160 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6161 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
6162 return status;
6163 }
6164
6165 /* purge current scan results
6166 if i don't do this than I still get old ap's (of different country code) as available (even if they are powered off).
6167 Looks like a bug in current scan sequence.
6168 */
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07006169 csrScanFlushResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006170
6171 /* overwrite the defualt country code */
6172 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault, pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
6173
6174 /* Get Domain ID from country code */
6175 status = csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent,(v_REGDOMAIN_t *) &domainIdIoctl );
6176 if ( status != eHAL_STATUS_SUCCESS )
6177 {
6178 smsLog( pMac, LOGE, FL(" fail to get regId %d\n"), domainIdIoctl );
6179 return status;
6180 }
6181
6182 status = WDA_SetRegDomain(pMac, domainIdIoctl);
6183
6184 if ( status != eHAL_STATUS_SUCCESS )
6185 {
6186 smsLog( pMac, LOGE, FL(" fail to set regId %d\n"), domainIdIoctl );
6187 return status;
6188 }
6189
6190 /* set to default domain ID */
6191 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
6192
6193 /* get the channels based on new cc */
6194 status = csrInitGetChannels( pMac );
6195
6196 if ( status != eHAL_STATUS_SUCCESS )
6197 {
6198 smsLog( pMac, LOGE, FL(" fail to get Channels \n"));
6199 return status;
6200 }
6201
6202 /* reset info based on new cc, and we are done */
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08006203 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 if( pMsg->changeCCCallback )
6205 {
6206 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
6207 }
6208
6209 return eHAL_STATUS_SUCCESS;
6210}
6211
6212#ifdef WLAN_FEATURE_PACKET_FILTERING
Amar Singhalf3a6e762013-02-19 15:06:50 -08006213eHalStatus sme_8023MulticastList (tHalHandle hHal, tANI_U8 sessionId, tpSirRcvFltMcAddrList pMulticastAddrs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006214{
6215 tpSirRcvFltMcAddrList pRequestBuf;
6216 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006217 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnsone7245742012-09-05 17:12:55 -07006218 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006219
6220 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006221 "ulMulticastAddrCnt=%d, multicastAddr[0]=%d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 pMulticastAddrs->ulMulticastAddrCnt,
6223 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07006224
6225 /*
6226 *Find the connected Infra / P2P_client connected session
Amar Singhalf3a6e762013-02-19 15:06:50 -08006227 */
6228 if (CSR_IS_SESSION_VALID(pMac, sessionId) &&
6229 csrIsConnStateInfra(pMac, sessionId))
6230 {
6231 pSession = CSR_GET_SESSION( pMac, sessionId );
6232 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006233
6234 if(pSession == NULL )
6235 {
6236 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Unable to find "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006237 "the right session", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07006238 return eHAL_STATUS_FAILURE;
6239 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006240
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6242 if (NULL == pRequestBuf)
6243 {
6244 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006245 "allocate memory for 8023 Multicast List request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 return eHAL_STATUS_FAILED_ALLOC;
6247 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006248
6249 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6250 {
6251 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
6252 "indication as we are not connected", __func__);
6253 vos_mem_free(pRequestBuf);
6254 return eHAL_STATUS_FAILURE;
6255 }
6256
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
6258
Jeff Johnsone7245742012-09-05 17:12:55 -07006259 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6260 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
6261 sizeof(tSirMacAddr));
6262
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 msg.type = WDA_8023_MULTICAST_LIST_REQ;
6264 msg.reserved = 0;
6265 msg.bodyptr = pRequestBuf;
6266 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6267 {
6268 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006269 "post WDA_8023_MULTICAST_LIST message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 vos_mem_free(pRequestBuf);
6271 return eHAL_STATUS_FAILURE;
6272 }
6273
6274 return eHAL_STATUS_SUCCESS;
6275}
6276
Jeff Johnsone7245742012-09-05 17:12:55 -07006277eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
6278 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006279{
6280 tpSirRcvPktFilterCfgType pRequestBuf;
6281 v_SINT_t allocSize;
6282 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006283 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6284 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 v_U8_t idx=0;
6286
6287 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006288 "filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
6290
Madan Mohan Koyyalamudid4029622012-10-18 20:30:17 -07006291 allocSize = sizeof(tSirRcvPktFilterCfgType);
6292
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 pRequestBuf = vos_mem_malloc(allocSize);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006294
6295 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006296 {
6297 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006298 "allocate memory for Receive Filter Set Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 return eHAL_STATUS_FAILED_ALLOC;
6300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006301
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006302 if( NULL == pSession )
6303 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006304 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Session Not found ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006305 vos_mem_free(pRequestBuf);
6306 return eHAL_STATUS_FAILURE;
6307 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006308
6309 vos_mem_copy( pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6310 vos_mem_copy( pRcvPktFilterCfg->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006311 sizeof(tSirMacAddr));
6312
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006313 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
6314
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
6316 msg.reserved = 0;
6317 msg.bodyptr = pRequestBuf;
6318
6319 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6320 "FT %d FID %d ",
6321 pRequestBuf->filterType, pRequestBuf->filterId);
6322
6323 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6324 "params %d CT %d",
6325 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
6326
6327 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
6328 {
6329
6330 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6331 "Proto %d Comp Flag %d \n",
6332 pRequestBuf->paramsData[idx].protocolLayer,
6333 pRequestBuf->paramsData[idx].cmpFlag);
6334
6335 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6336 "Data Offset %d Data Len %d\n",
6337 pRequestBuf->paramsData[idx].dataOffset,
6338 pRequestBuf->paramsData[idx].dataLength);
6339
6340 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6341 "CData: %d:%d:%d:%d:%d:%d\n",
6342 pRequestBuf->paramsData[idx].compareData[0],
6343 pRequestBuf->paramsData[idx].compareData[1],
6344 pRequestBuf->paramsData[idx].compareData[2],
6345 pRequestBuf->paramsData[idx].compareData[3],
6346 pRequestBuf->paramsData[idx].compareData[4],
6347 pRequestBuf->paramsData[idx].compareData[5]);
6348
6349 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6350 "MData: %d:%d:%d:%d:%d:%d\n",
6351 pRequestBuf->paramsData[idx].dataMask[0],
6352 pRequestBuf->paramsData[idx].dataMask[1],
6353 pRequestBuf->paramsData[idx].dataMask[2],
6354 pRequestBuf->paramsData[idx].dataMask[3],
6355 pRequestBuf->paramsData[idx].dataMask[4],
6356 pRequestBuf->paramsData[idx].dataMask[5]);
6357
6358 }
6359
6360 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6361 {
6362 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006363 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 vos_mem_free(pRequestBuf);
6365 return eHAL_STATUS_FAILURE;
6366 }
6367
6368 return eHAL_STATUS_SUCCESS;
6369}
6370
6371eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
6372 FilterMatchCountCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006373 void *callbackContext,
6374 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006375{
6376 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6377 eHalStatus status;
6378
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006379 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006380
6381 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
6382 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006383 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 sme_ReleaseGlobalLock( &pMac->sme );
6385 }
6386
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006387 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006388
6389 return (status);
6390}
6391
Jeff Johnsone7245742012-09-05 17:12:55 -07006392eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
6393 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006394{
6395 tpSirRcvFltPktClearParam pRequestBuf;
6396 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006397 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6398 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006399
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006400 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 pRcvFltPktClearParam->filterId);
6402
6403 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006404 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 {
6406 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6407 "%s: Not able to allocate memory for Receive Filter "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006408 "Clear Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 return eHAL_STATUS_FAILED_ALLOC;
6410 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006411 if( NULL == pSession )
6412 {
6413 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006414 "%s: Session Not find ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006415 vos_mem_free(pRequestBuf);
6416 return eHAL_STATUS_FAILURE;
6417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006418
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006419 vos_mem_copy( pRcvFltPktClearParam->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6420 vos_mem_copy( pRcvFltPktClearParam->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006421 sizeof(tSirMacAddr));
6422
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006423 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
6424
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
6426 msg.reserved = 0;
6427 msg.bodyptr = pRequestBuf;
6428 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6429 {
6430 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006431 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 vos_mem_free(pRequestBuf);
6433 return eHAL_STATUS_FAILURE;
6434 }
6435
6436 return eHAL_STATUS_SUCCESS;
6437}
6438#endif // WLAN_FEATURE_PACKET_FILTERING
6439
6440/* ---------------------------------------------------------------------------
6441 \fn sme_PreChannelSwitchIndFullPowerCB
6442 \brief call back function for the PMC full power request because of pre
6443 channel switch.
6444 \param callbackContext
6445 \param status
6446 ---------------------------------------------------------------------------*/
6447void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
6448 eHalStatus status)
6449{
6450 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
6451 tSirMbMsg *pMsg;
6452 tANI_U16 msgLen;
6453
6454 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
6455 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
6456 if(HAL_STATUS_SUCCESS(status))
6457 {
6458 palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen);
6459 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
6460 pMsg->msgLen = pal_cpu_to_be16(msgLen);
6461 status = palSendMBMessage(pMac->hHdd, pMsg);
6462 }
6463
6464 return;
6465}
6466
6467/* ---------------------------------------------------------------------------
6468 \fn sme_HandlePreChannelSwitchInd
6469 \brief Processes the indcation from PE for pre-channel switch.
6470 \param hHal
6471 \- The handle returned by macOpen. return eHalStatus
6472 ---------------------------------------------------------------------------*/
6473eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
6474{
6475 eHalStatus status = eHAL_STATUS_FAILURE;
6476 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6477 status = sme_AcquireGlobalLock( &pMac->sme );
6478 if ( HAL_STATUS_SUCCESS( status ) )
6479 {
6480 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
6481 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
6482 sme_ReleaseGlobalLock( &pMac->sme );
6483 }
6484
6485 return (status);
6486}
6487
6488/* ---------------------------------------------------------------------------
6489 \fn sme_HandlePostChannelSwitchInd
6490 \brief Processes the indcation from PE for post-channel switch.
6491 \param hHal
6492 \- The handle returned by macOpen. return eHalStatus
6493 ---------------------------------------------------------------------------*/
6494eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
6495{
6496 eHalStatus status = eHAL_STATUS_FAILURE;
6497 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6498
6499 status = sme_AcquireGlobalLock( &pMac->sme );
6500 if ( HAL_STATUS_SUCCESS( status ) )
6501 {
6502 status = pmcRequestBmps(hHal, NULL, NULL);
6503 sme_ReleaseGlobalLock( &pMac->sme );
6504 }
6505
6506 return (status);
6507}
6508
6509/* ---------------------------------------------------------------------------
6510
6511 \fn sme_IsChannelValid
6512
6513 \brief To check if the channel is valid for currently established domain
6514 This is a synchronous API.
6515
6516 \param hHal - The handle returned by macOpen.
6517 \param channel - channel to verify
6518
6519 \return TRUE/FALSE, TRUE if channel is valid
6520
6521 -------------------------------------------------------------------------------*/
6522tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
6523{
6524 eHalStatus status = eHAL_STATUS_FAILURE;
6525 tANI_BOOLEAN valid = FALSE;
6526 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6527
6528 status = sme_AcquireGlobalLock( &pMac->sme );
6529 if ( HAL_STATUS_SUCCESS( status ) )
6530 {
6531
6532 valid = csrRoamIsChannelValid( pMac, channel);
6533
6534 sme_ReleaseGlobalLock( &pMac->sme );
6535 }
6536
6537 return (valid);
6538}
6539
6540/* ---------------------------------------------------------------------------
6541 \fn sme_SetFreqBand
6542 \brief Used to set frequency band.
6543 \param hHal
6544 \eBand band value to be configured
6545 \- return eHalStatus
6546 -------------------------------------------------------------------------*/
6547eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
6548{
6549 eHalStatus status = eHAL_STATUS_FAILURE;
6550 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6551
6552 status = sme_AcquireGlobalLock( &pMac->sme );
6553 if ( HAL_STATUS_SUCCESS( status ) )
6554 {
6555 status = csrSetBand(hHal, eBand);
6556 sme_ReleaseGlobalLock( &pMac->sme );
6557 }
6558 return status;
6559}
6560
6561/* ---------------------------------------------------------------------------
6562 \fn sme_GetFreqBand
6563 \brief Used to get the current band settings.
6564 \param hHal
6565 \pBand pointer to hold band value
6566 \- return eHalStatus
6567 -------------------------------------------------------------------------*/
6568eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
6569{
6570 eHalStatus status = eHAL_STATUS_FAILURE;
6571 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6572
6573 status = sme_AcquireGlobalLock( &pMac->sme );
6574 if ( HAL_STATUS_SUCCESS( status ) )
6575 {
6576 *pBand = csrGetCurrentBand( hHal );
6577 sme_ReleaseGlobalLock( &pMac->sme );
6578 }
6579 return status;
6580}
6581
6582#ifdef WLAN_WAKEUP_EVENTS
6583/******************************************************************************
6584 \fn sme_WakeReasonIndCallback
6585
6586 \brief
6587 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
6588
6589 \param hHal - HAL handle for device
6590 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
6591
6592 \return eHalStatus
6593******************************************************************************/
6594eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
6595{
6596 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6597 eHalStatus status = eHAL_STATUS_SUCCESS;
6598 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
6599
6600 if (NULL == pMsg)
6601 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006602 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 status = eHAL_STATUS_FAILURE;
6604 }
6605 else
6606 {
6607 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback\n");
6608
6609 /* Call Wake Reason Indication callback routine. */
6610 if (pMac->pmc.wakeReasonIndCB != NULL)
6611 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
6612
6613 pMac->pmc.wakeReasonIndCB = NULL;
6614 pMac->pmc.wakeReasonIndCBContext = NULL;
6615
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006616 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __func__, pWakeReasonInd->ulReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 }
6618
6619 return(status);
6620}
6621#endif // WLAN_WAKEUP_EVENTS
6622
6623
6624/* ---------------------------------------------------------------------------
6625
6626 \fn sme_SetMaxTxPower
6627
6628 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
6629 not persist over reboots.
6630
6631 \param hHal
6632 \param pBssid BSSID to set the power cap for
6633 \param pBssid pSelfMacAddress self MAC Address
6634 \param pBssid power to set in dB
6635 \- return eHalStatus
6636
6637 -------------------------------------------------------------------------------*/
6638eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr pBssid,
6639 tSirMacAddr pSelfMacAddress, v_S7_t dB)
6640{
6641 vos_msg_t msg;
6642 tpMaxTxPowerParams pMaxTxParams = NULL;
6643
6644 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
6645 if (NULL == pMaxTxParams)
6646 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006647 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 -07006648 return eHAL_STATUS_FAILURE;
6649 }
6650
6651 vos_mem_copy(pMaxTxParams->bssId, pBssid, SIR_MAC_ADDR_LENGTH);
6652 vos_mem_copy(pMaxTxParams->selfStaMacAddr , pSelfMacAddress,
6653 SIR_MAC_ADDR_LENGTH);
6654 pMaxTxParams->power = dB;
6655
6656 msg.type = WDA_SET_MAX_TX_POWER_REQ;
6657 msg.reserved = 0;
6658 msg.bodyptr = pMaxTxParams;
6659
6660 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6661 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006662 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 -07006663 vos_mem_free(pMaxTxParams);
6664 return eHAL_STATUS_FAILURE;
6665 }
6666
6667 return eHAL_STATUS_SUCCESS;
6668}
6669
6670#ifdef WLAN_SOFTAP_FEATURE
6671/* ---------------------------------------------------------------------------
6672
6673 \fn sme_HideSSID
6674
6675 \brief hide/show SSID dynamically. Note: this setting will
6676 not persist over reboots.
6677
6678 \param hHal
6679 \param sessionId
6680 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
6681 \- return eHalStatus
6682
6683 -------------------------------------------------------------------------------*/
6684eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
6685{
6686 eHalStatus status = eHAL_STATUS_SUCCESS;
6687 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6688 tANI_U16 len;
6689
6690 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6691 {
6692 tpSirUpdateParams pMsg;
6693 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006694
6695 if(!pSession)
6696 {
6697 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6698 return eHAL_STATUS_FAILURE;
6699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006700
6701 if( !pSession->sessionActive )
6702 VOS_ASSERT(0);
6703
6704 /* Create the message and send to lim */
6705 len = sizeof(tSirUpdateParams);
6706 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
6707 if(HAL_STATUS_SUCCESS(status))
6708 {
6709 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirUpdateParams) );
6710 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
6711 pMsg->length = len;
6712 /* Data starts from here */
6713 pMsg->sessionId = sessionId;
6714 pMsg->ssidHidden = ssidHidden;
6715 status = palSendMBMessage(pMac->hHdd, pMsg);
6716 }
6717 sme_ReleaseGlobalLock( &pMac->sme );
6718 }
6719 return status;
6720}
6721#endif
6722
6723/* ---------------------------------------------------------------------------
6724
6725 \fn sme_SetTmLevel
6726 \brief Set Thermal Mitigation Level to RIVA
6727 \param hHal - The handle returned by macOpen.
6728 \param newTMLevel - new Thermal Mitigation Level
6729 \param tmMode - Thermal Mitigation handle mode, default 0
6730 \return eHalStatus
6731 ---------------------------------------------------------------------------*/
6732eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
6733{
6734 eHalStatus status = eHAL_STATUS_SUCCESS;
6735 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6736 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6737 vos_msg_t vosMessage;
6738 tAniSetTmLevelReq *setTmLevelReq = NULL;
6739
6740 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6741 {
6742 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
6743 if(NULL == setTmLevelReq)
6744 {
6745 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006746 "%s: Not able to allocate memory for sme_SetTmLevel", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 return eHAL_STATUS_FAILURE;
6748 }
6749
6750 setTmLevelReq->tmMode = tmMode;
6751 setTmLevelReq->newTmLevel = newTMLevel;
6752
6753 /* serialize the req through MC thread */
6754 vosMessage.bodyptr = setTmLevelReq;
6755 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
6756 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6757 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6758 {
6759 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006760 "%s: Post Set TM Level MSG fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 vos_mem_free(setTmLevelReq);
6762 status = eHAL_STATUS_FAILURE;
6763 }
6764 sme_ReleaseGlobalLock( &pMac->sme );
6765 }
6766 return(status);
6767}
6768
6769/*---------------------------------------------------------------------------
6770
6771 \brief sme_featureCapsExchange() - SME interface to exchange capabilities between
6772 Host and FW.
6773
6774 \param hHal - HAL handle for device
6775
6776 \return NONE
6777
6778---------------------------------------------------------------------------*/
6779void sme_featureCapsExchange( tHalHandle hHal)
6780{
6781 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
6782 WDA_featureCapsExchange(vosContext);
6783}
Jeff Johnsond13512a2012-07-17 11:42:19 -07006784
Yathish9f22e662012-12-10 14:21:35 -08006785/*---------------------------------------------------------------------------
6786
6787 \brief sme_disableFeatureCapablity() - SME interface to disable Active mode offload capablity
6788 in Host.
6789
6790 \param hHal - HAL handle for device
6791
6792 \return NONE
6793
6794---------------------------------------------------------------------------*/
6795void sme_disableFeatureCapablity(tANI_U8 feature_index)
6796{
6797 WDA_disableCapablityFeature(feature_index);
6798}
6799
6800
Jeff Johnsond13512a2012-07-17 11:42:19 -07006801
6802/* ---------------------------------------------------------------------------
6803
6804 \fn sme_GetDefaultCountryCode
6805
6806 \brief Get the default country code from NV
6807
6808 \param hHal
6809 \param pCountry
6810 \- return eHalStatus
6811
6812 -------------------------------------------------------------------------------*/
6813eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
6814{
6815 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6816 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
6817}
6818
6819/* ---------------------------------------------------------------------------
6820
6821 \fn sme_GetCurrentCountryCode
6822
6823 \brief Get the current country code
6824
6825 \param hHal
6826 \param pCountry
6827 \- return eHalStatus
6828
6829 -------------------------------------------------------------------------------*/
6830eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
6831{
6832 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6833 return csrGetCurrentCountryCode(pMac, pCountry);
6834}
6835
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006836/* ---------------------------------------------------------------------------
6837 \fn sme_transportDebug
6838 \brief Dynamically monitoring Transport channels
6839 Private IOCTL will querry transport channel status if driver loaded
Jeff Johnsonb88db982012-12-10 13:34:59 -08006840 \param displaySnapshot Display transport channel snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006841 \param toggleStallDetect Enable stall detect feature
6842 This feature will take effect to data performance
6843 Not integrate till fully verification
6844 \- return NONE
6845 -------------------------------------------------------------------------*/
6846void sme_transportDebug
6847(
6848 v_BOOL_t displaySnapshot,
6849 v_BOOL_t toggleStallDetect
6850)
6851{
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07006852 WDA_TransportChannelDebug(displaySnapshot, toggleStallDetect);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07006853}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08006854
Kiran4a17ebe2013-01-31 10:43:43 -08006855/* ---------------------------------------------------------------------------
6856 \fn sme_ResetPowerValuesFor5G
6857 \brief Reset the power values for 5G band with NV power values.
6858 \param hHal - HAL handle for device
6859 \- return NONE
6860 -------------------------------------------------------------------------*/
6861void sme_ResetPowerValuesFor5G (tHalHandle hHal)
6862{
6863 tpAniSirGlobal pMac = PMAC_STRUCT (hHal);
6864 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
6865 csrApplyPower2Current(pMac); // Store the channel+power info in the global place: Cfg
6866}
6867
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08006868#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
6869/* ---------------------------------------------------------------------------
6870 \fn sme_UpdateRoamPrefer5GHz
6871 \brief enable/disable Roam prefer 5G runtime option
6872 This function is called through dynamic setConfig callback function
6873 to configure the Roam prefer 5G runtime option
6874 \param hHal - HAL handle for device
6875 \param nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6876 \- return Success or failure
6877 -------------------------------------------------------------------------*/
6878
6879eHalStatus sme_UpdateRoamPrefer5GHz(tHalHandle hHal, v_BOOL_t nRoamPrefer5GHz)
6880{
6881 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08006882 eHalStatus status = eHAL_STATUS_SUCCESS;
6883
6884 status = sme_AcquireGlobalLock( &pMac->sme );
6885 if ( HAL_STATUS_SUCCESS( status ) )
6886 {
6887 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6888 "%s: gRoamPrefer5GHz is changed from %d to %d", __func__,
6889 pMac->roam.configParam.nRoamPrefer5GHz,
6890 nRoamPrefer5GHz);
6891 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6892 sme_ReleaseGlobalLock( &pMac->sme );
6893 }
6894
6895 return status ;
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08006896}
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08006897
6898/* ---------------------------------------------------------------------------
6899 \fn sme_UpdateImmediateRoamRssiDiff
6900 \brief Update nImmediateRoamRssiDiff
6901 This function is called through dynamic setConfig callback function
6902 to configure nImmediateRoamRssiDiff
6903 Usage: adb shell iwpriv wlan0 setConfig gImmediateRoamRssiDiff=[0 .. 125]
6904 \param hHal - HAL handle for device
6905 \param nImmediateRoamRssiDiff - minimum rssi difference between potential
6906 candidate and current AP.
6907 \- return Success or failure
6908 -------------------------------------------------------------------------*/
6909
6910eHalStatus sme_UpdateImmediateRoamRssiDiff(tHalHandle hHal, v_U8_t nImmediateRoamRssiDiff)
6911{
6912 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08006913 eHalStatus status = eHAL_STATUS_SUCCESS;
6914
6915 status = sme_AcquireGlobalLock( &pMac->sme );
6916 if ( HAL_STATUS_SUCCESS( status ) )
6917 {
6918 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
6919 "LFR runtime successfully set immediate roam rssi diff to %d - old value is %d - roam state is %d",
6920 nImmediateRoamRssiDiff,
6921 pMac->roam.configParam.nImmediateRoamRssiDiff,
6922 pMac->roam.neighborRoamInfo.neighborRoamState);
6923 pMac->roam.configParam.nImmediateRoamRssiDiff = nImmediateRoamRssiDiff;
6924 sme_ReleaseGlobalLock( &pMac->sme );
6925 }
6926
6927 return status ;
6928}
6929
6930/* ---------------------------------------------------------------------------
6931 \fn sme_UpdateRoamRssiDiff
6932 \brief Update RoamRssiDiff
6933 This function is called through dynamic setConfig callback function
6934 to configure RoamRssiDiff
6935 Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6936 \param hHal - HAL handle for device
6937 \param RoamRssiDiff - minimum rssi difference between potential
6938 candidate and current AP.
6939 \- return Success or failure
6940 -------------------------------------------------------------------------*/
6941
6942eHalStatus sme_UpdateRoamRssiDiff(tHalHandle hHal, v_U8_t RoamRssiDiff)
6943{
6944 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6945 eHalStatus status = eHAL_STATUS_SUCCESS;
6946
6947 status = sme_AcquireGlobalLock( &pMac->sme );
6948 if ( HAL_STATUS_SUCCESS( status ) )
6949 {
6950 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
6951 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %d",
6952 RoamRssiDiff,
6953 pMac->roam.configParam.RoamRssiDiff,
6954 pMac->roam.neighborRoamInfo.neighborRoamState);
6955 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
6956 sme_ReleaseGlobalLock( &pMac->sme );
6957 }
6958
6959 return status ;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08006960}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08006961
6962/*--------------------------------------------------------------------------
6963 \brief sme_UpdateFastTransitionEnabled() - enable/disable Fast Transition support at runtime
6964 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6965 isFastTransitionEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08006966 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08006967 \param hHal - The handle returned by macOpen.
6968 \return eHAL_STATUS_SUCCESS - SME update isFastTransitionEnabled config successfully.
6969 Other status means SME is failed to update isFastTransitionEnabled.
6970 \sa
6971 --------------------------------------------------------------------------*/
6972eHalStatus sme_UpdateFastTransitionEnabled(tHalHandle hHal,
6973 v_BOOL_t isFastTransitionEnabled)
6974{
6975 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08006976 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08006977
Srinivas Girigowdade697412013-02-14 16:31:48 -08006978 status = sme_AcquireGlobalLock( &pMac->sme );
6979 if ( HAL_STATUS_SUCCESS( status ) )
6980 {
6981 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6982 "%s: FastTransitionEnabled is changed from %d to %d", __func__,
6983 pMac->roam.configParam.isFastTransitionEnabled,
6984 isFastTransitionEnabled);
6985 pMac->roam.configParam.isFastTransitionEnabled = isFastTransitionEnabled;
6986 sme_ReleaseGlobalLock( &pMac->sme );
6987 }
6988
6989 return status ;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08006990}
6991#endif /* (WLAN_FEATURE_VOWIFI_11R) || (FEATURE_WLAN_CCX) || (FEATURE_WLAN_LFR) */
6992
6993#ifdef FEATURE_WLAN_LFR
6994/*--------------------------------------------------------------------------
6995 \brief sme_UpdateIsFastRoamIniFeatureEnabled() - enable/disable LFR support at runtime
6996 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6997 isFastRoamIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08006998 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08006999 \param hHal - The handle returned by macOpen.
7000 \return eHAL_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config successfully.
7001 Other status means SME is failed to update isFastRoamIniFeatureEnabled.
7002 \sa
7003 --------------------------------------------------------------------------*/
7004eHalStatus sme_UpdateIsFastRoamIniFeatureEnabled(tHalHandle hHal,
7005 v_BOOL_t isFastRoamIniFeatureEnabled)
7006{
7007 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7008
Srinivas Girigowdade697412013-02-14 16:31:48 -08007009 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7010 "%s: FastRoamEnabled is changed from %d to %d", __func__,
7011 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7012 isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007013 pMac->roam.configParam.isFastRoamIniFeatureEnabled = isFastRoamIniFeatureEnabled;
7014
7015 if(TRUE == isFastRoamIniFeatureEnabled)
7016 {
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007017 sme_UpdateConfigFwRssiMonitoring(hHal, TRUE);
7018 }
7019 else
7020 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08007021 /* CCX also depend on FW Monitoring.
7022 Hence Disabling LFR should check for CCX enable before disabling FW Monitoring */
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007023#ifdef FEATURE_WLAN_CCX
7024 if(FALSE == pMac->roam.configParam.isCcxIniFeatureEnabled)
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007025#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007026 {
7027 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Srinivas Girigowdade697412013-02-14 16:31:48 -08007028 "%s: Turn off FW Monitoring", __func__);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007029 sme_UpdateConfigFwRssiMonitoring(hHal, FALSE);
7030 }
7031 }
7032
7033 return eHAL_STATUS_SUCCESS;
7034}
7035#endif /* FEATURE_WLAN_LFR */
7036
7037#ifdef FEATURE_WLAN_CCX
7038/*--------------------------------------------------------------------------
7039 \brief sme_UpdateIsCcxFeatureEnabled() - enable/disable CCX support at runtime
7040 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7041 isCcxIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08007042 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007043 \param hHal - The handle returned by macOpen.
7044 \return eHAL_STATUS_SUCCESS - SME update isCcxIniFeatureEnabled config successfully.
7045 Other status means SME is failed to update isCcxIniFeatureEnabled.
7046 \sa
7047 --------------------------------------------------------------------------*/
7048
7049eHalStatus sme_UpdateIsCcxFeatureEnabled(tHalHandle hHal,
7050 v_BOOL_t isCcxIniFeatureEnabled)
7051{
7052 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7053
Srinivas Girigowdade697412013-02-14 16:31:48 -08007054 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7055 "%s: CcxEnabled is changed from %d to %d", __func__,
7056 pMac->roam.configParam.isCcxIniFeatureEnabled,
7057 isCcxIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007058 pMac->roam.configParam.isCcxIniFeatureEnabled = isCcxIniFeatureEnabled;
7059
7060 if(TRUE == isCcxIniFeatureEnabled)
7061 {
7062 sme_UpdateFastTransitionEnabled(hHal, TRUE);
7063 sme_UpdateConfigFwRssiMonitoring(hHal, TRUE);
7064 }
7065 else
7066 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08007067 /* LFR also depend on FW Monitoring.
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007068 Hence Disabling CCX should check for LFR enable before disabling FW Monitoring and Fast Transition */
7069#ifdef FEATURE_WLAN_LFR
7070 if(FALSE == pMac->roam.configParam.isFastRoamIniFeatureEnabled)
7071#endif
7072 {
7073 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7074 "%s: Turn off FW Monitoring/Fast Transition", __func__);
7075 sme_UpdateFastTransitionEnabled(hHal, FALSE);
7076 sme_UpdateConfigFwRssiMonitoring(hHal, FALSE);
7077 }
7078 }
7079 return eHAL_STATUS_SUCCESS;
7080}
7081#endif /* FEATURE_WLAN_CCX */
7082
7083/*--------------------------------------------------------------------------
7084 \brief sme_UpdateConfigFwRssiMonitoring() - enable/disable firmware RSSI Monitoring at runtime
7085 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7086 fEnableFwRssiMonitoring.
Srinivas Girigowdade697412013-02-14 16:31:48 -08007087 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007088 \param hHal - The handle returned by macOpen.
7089 \return eHAL_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring. config successfully.
7090 Other status means SME is failed to update fEnableFwRssiMonitoring.
7091 \sa
7092 --------------------------------------------------------------------------*/
7093
7094eHalStatus sme_UpdateConfigFwRssiMonitoring(tHalHandle hHal,
7095 v_BOOL_t fEnableFwRssiMonitoring)
7096{
7097 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
7098
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007099 if (ccmCfgSetInt(hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR, fEnableFwRssiMonitoring,
7100 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
7101 {
7102 halStatus = eHAL_STATUS_FAILURE;
7103 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7104 "Failure: Could not pass on WNI_CFG_PS_RSSI_MONITOR configuration info to CCM\n");
7105 }
7106
7107 return (halStatus);
7108}
7109
Srinivas Girigowdade697412013-02-14 16:31:48 -08007110/*--------------------------------------------------------------------------
7111 \brief sme_setNeighborLookupRssiThreshold() - update neighbor lookup rssi threshold
7112 This is a synchronous call
7113 \param hHal - The handle returned by macOpen.
7114 \return eHAL_STATUS_SUCCESS - SME update config successful.
7115 Other status means SME is failed to update
7116 \sa
7117 --------------------------------------------------------------------------*/
7118eHalStatus sme_setNeighborLookupRssiThreshold(tHalHandle hHal,
7119 v_U8_t neighborLookupRssiThreshold)
7120{
7121 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7122 eHalStatus status = eHAL_STATUS_SUCCESS;
7123
7124 status = sme_AcquireGlobalLock( &pMac->sme );
7125 if ( HAL_STATUS_SUCCESS( status ) )
7126 {
7127 status = csrNeighborRoamSetLookupRssiThreshold(pMac, neighborLookupRssiThreshold);
7128 if (HAL_STATUS_SUCCESS(status))
7129 {
7130 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7131 "LFR runtime successfully set Lookup threshold to %d - old value is %d - roam state is %d",
7132 neighborLookupRssiThreshold,
7133 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold,
7134 pMac->roam.neighborRoamInfo.neighborRoamState);
7135 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
7136 neighborLookupRssiThreshold;
7137 }
7138 sme_ReleaseGlobalLock( &pMac->sme );
7139 }
7140
7141 return status;
7142}
7143
7144/*--------------------------------------------------------------------------
7145 \brief sme_setNeighborReassocRssiThreshold() - update neighbor reassoc rssi threshold
7146 This is a synchronous call
7147 \param hHal - The handle returned by macOpen.
7148 \return eHAL_STATUS_SUCCESS - SME update config successful.
7149 Other status means SME is failed to update
7150 \sa
7151 --------------------------------------------------------------------------*/
7152eHalStatus sme_setNeighborReassocRssiThreshold(tHalHandle hHal,
7153 v_U8_t neighborReassocRssiThreshold)
7154{
7155 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7156 eHalStatus status = eHAL_STATUS_SUCCESS;
7157
7158 status = sme_AcquireGlobalLock( &pMac->sme );
7159 if ( HAL_STATUS_SUCCESS( status ) )
7160 {
7161 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7162 "LFR runtime successfully set Reassoc threshold to %d - old value is %d - roam state is %d",
7163 neighborReassocRssiThreshold,
7164 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold,
7165 pMac->roam.neighborRoamInfo.neighborRoamState);
7166 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold =
7167 neighborReassocRssiThreshold;
7168 pMac->roam.neighborRoamInfo.cfgParams.neighborReassocThreshold =
7169 neighborReassocRssiThreshold;
7170 sme_ReleaseGlobalLock( &pMac->sme );
7171 }
7172
7173 return status ;
7174}
7175
7176
7177/*--------------------------------------------------------------------------
7178 \brief sme_getNeighborLookupRssiThreshold() - get neighbor lookup rssi threshold
7179 This is a synchronous call
7180 \param hHal - The handle returned by macOpen.
7181 \return eHAL_STATUS_SUCCESS - SME update config successful.
7182 Other status means SME is failed to update
7183 \sa
7184 --------------------------------------------------------------------------*/
7185v_U8_t sme_getNeighborLookupRssiThreshold(tHalHandle hHal)
7186{
7187 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7188 return pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
7189}
7190
7191/*--------------------------------------------------------------------------
7192 \brief sme_setNeighborScanRefreshPeriod() - set neighbor scan results refresh period
7193 This is a synchronous call
7194 \param hHal - The handle returned by macOpen.
7195 \return eHAL_STATUS_SUCCESS - SME update config successful.
7196 Other status means SME is failed to update
7197 \sa
7198 --------------------------------------------------------------------------*/
7199eHalStatus sme_setNeighborScanRefreshPeriod(tHalHandle hHal,
7200 v_U16_t neighborScanResultsRefreshPeriod)
7201{
7202 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7203 eHalStatus status = eHAL_STATUS_SUCCESS;
7204
7205 status = sme_AcquireGlobalLock( &pMac->sme );
7206 if ( HAL_STATUS_SUCCESS( status ) )
7207 {
7208 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7209 "LFR runtime successfully set roam scan refresh period to %d - old value is %d - roam state is %d",
7210 neighborScanResultsRefreshPeriod,
7211 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod,
7212 pMac->roam.neighborRoamInfo.neighborRoamState);
7213 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod =
7214 neighborScanResultsRefreshPeriod;
7215 pMac->roam.neighborRoamInfo.cfgParams.neighborResultsRefreshPeriod =
7216 neighborScanResultsRefreshPeriod;
7217
7218 sme_ReleaseGlobalLock( &pMac->sme );
7219 }
7220
7221 return status ;
7222}
7223
7224/*--------------------------------------------------------------------------
7225 \brief sme_getNeighborScanRefreshPeriod() - get neighbor scan results refresh period
7226 This is a synchronous call
7227 \param hHal - The handle returned by macOpen.
7228 \return v_U16_t - Neighbor scan results refresh period value
7229 \sa
7230 --------------------------------------------------------------------------*/
7231v_U16_t sme_getNeighborScanRefreshPeriod(tHalHandle hHal)
7232{
7233 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7234 return pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
7235}
7236
7237/*--------------------------------------------------------------------------
7238 \brief sme_getEmptyScanRefreshPeriod() - get empty scan refresh period
7239 This is a synchronuous call
7240 \param hHal - The handle returned by macOpen.
7241 \return eHAL_STATUS_SUCCESS - SME update config successful.
7242 Other status means SME is failed to update
7243 \sa
7244 --------------------------------------------------------------------------*/
7245v_U16_t sme_getEmptyScanRefreshPeriod(tHalHandle hHal)
7246{
7247 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7248 return pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
7249}
7250
7251#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
7252/*--------------------------------------------------------------------------
7253 \brief sme_getRoamRssiDiff() - get Roam rssi diff
7254 This is a synchronous call
7255 \param hHal - The handle returned by macOpen.
7256 \return v_U16_t - Rssi diff value
7257 \sa
7258 --------------------------------------------------------------------------*/
7259v_U8_t sme_getRoamRssiDiff(tHalHandle hHal)
7260{
7261 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7262 return pMac->roam.configParam.RoamRssiDiff;
7263}
7264
7265/*--------------------------------------------------------------------------
7266 \brief sme_ChangeRoamScanChannelList() - Change roam scan channel list
7267 This is a synchronous call
7268 \param hHal - The handle returned by macOpen.
7269 \return eHAL_STATUS_SUCCESS - SME update config successful.
7270 Other status means SME is failed to update
7271 \sa
7272 --------------------------------------------------------------------------*/
7273eHalStatus sme_ChangeRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
7274 tANI_U8 numChannels)
7275{
7276 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7277 eHalStatus status = eHAL_STATUS_SUCCESS;
7278 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7279 tANI_U8 oldChannelList[128] = {0};
7280 tANI_U8 newChannelList[128] = {0};
7281 tANI_U8 i = 0, j = 0;
7282
7283 status = sme_AcquireGlobalLock( &pMac->sme );
7284 if ( HAL_STATUS_SUCCESS( status ) )
7285 {
7286 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
7287 {
7288 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
7289 {
7290 j += snprintf(oldChannelList + j, sizeof(oldChannelList) - j," %d",
7291 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
7292 }
7293 }
7294 csrFlushAndCreateBgScanRoamChannelList(pMac, pChannelList, numChannels);
7295 status = csrUpdateBgScanConfigIniChannelList(pMac, csrGetCurrentBand(hHal));
7296
7297 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
7298 {
7299 j = 0;
7300 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
7301 {
7302 j += snprintf(newChannelList + j, sizeof(newChannelList) - j," %d",
7303 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
7304 }
7305 }
7306
7307 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7308 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
7309 newChannelList, oldChannelList,
7310 pMac->roam.neighborRoamInfo.neighborRoamState);
7311 sme_ReleaseGlobalLock( &pMac->sme );
7312 }
7313
7314 return status ;
7315}
7316
7317/*--------------------------------------------------------------------------
7318 \brief sme_ChangeCountryValidChannelListByRevision() - Change Korea valid channel list
7319 based on country revision number
7320 This is a synchronous call
7321 \param hHal - The handle returned by macOpen.
7322 \return eHAL_STATUS_SUCCESS - SME update config successful.
7323 Other status means SME is failed to update
7324 \sa
7325 --------------------------------------------------------------------------*/
7326eHalStatus sme_ChangeCountryValidChannelListByRevision(tHalHandle hHal,
7327 tANI_U8 Revision)
7328{
7329 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7330 eHalStatus status = eHAL_STATUS_SUCCESS;
7331
7332 status = sme_AcquireGlobalLock( &pMac->sme );
7333 if ( HAL_STATUS_SUCCESS( status ) )
7334 {
7335 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7336 "LFR runtime successfully set country/revision to %s/%d - old value is %s/%d - roam state is %d",
7337 "KR", Revision, "KR",
7338 pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.revision,
7339 pMac->roam.neighborRoamInfo.neighborRoamState);
7340 csr_SetRevision(pMac, Revision);
7341 csrInitCountryValidChannelList(pMac, Revision);
7342 sme_ReleaseGlobalLock( &pMac->sme );
7343 }
7344
7345 return status ;
7346}
7347
7348
7349/*--------------------------------------------------------------------------
7350 \brief csrUpdateBgScanConfigIniChannelList() - Update bgscan roam cache
7351 This is a synchronous call
7352 \param hHal - The handle returned by macOpen.
7353 \return eHAL_STATUS_SUCCESS - SME update config successful.
7354 Other status means SME is failed to update
7355 \sa
7356 --------------------------------------------------------------------------*/
7357eHalStatus sme_UpdateBgScanConfigIniChannelList(tHalHandle hHal,
7358 eCsrBand eBand)
7359{
7360 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7361 return csrUpdateBgScanConfigIniChannelList(pMac, eBand);
7362}
7363
7364/*--------------------------------------------------------------------------
7365 \brief sme_getRoamScanChannelList() - get roam scan channel list
7366 This is a synchronous call
7367 \param hHal - The handle returned by macOpen.
7368 \return eHAL_STATUS_SUCCESS - SME update config successful.
7369 Other status means SME is failed to update
7370 \sa
7371 --------------------------------------------------------------------------*/
7372eHalStatus sme_getRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
7373 tANI_U8 *pNumChannels)
7374{
7375 int i = 0;
7376 tANI_U8 *pOutPtr = pChannelList;
7377 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7378 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7379 eHalStatus status = eHAL_STATUS_SUCCESS;
7380
7381 status = sme_AcquireGlobalLock( &pMac->sme );
7382 if ( HAL_STATUS_SUCCESS( status ) )
7383 {
7384 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
7385 {
7386 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
7387 "Roam Scan channel list is NOT yet initialized");
7388 sme_ReleaseGlobalLock( &pMac->sme );
7389 return eHAL_STATUS_NOT_INITIALIZED;
7390 }
7391
7392 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
7393 for (i = 0; i < (*pNumChannels); i++)
7394 {
7395 pOutPtr[i] = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
7396 }
7397 pOutPtr[i] = '\0';
7398 sme_ReleaseGlobalLock( &pMac->sme );
7399 }
7400
7401 return status ;
7402}
7403
7404/*--------------------------------------------------------------------------
7405 \brief sme_GetCountryRevision() - get Country revision index
7406 This is a synchronous call
7407 \param hHal - The handle returned by macOpen.
7408 \return eHAL_STATUS_SUCCESS - SME update config successful.
7409 Other status means SME is failed to update
7410 \sa
7411 --------------------------------------------------------------------------*/
7412eHalStatus sme_GetCountryRevision(tHalHandle hHal, tANI_U8 *pRevision)
7413{
7414 /* this is valid for Country KR only now */
7415 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7416 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7417 eHalStatus status = eHAL_STATUS_SUCCESS;
7418
7419 *pRevision = pNeighborRoamInfo->cfgParams.countryChannelInfo.revision;
7420
7421 return status;
7422}
7423
7424#endif
7425
7426/* ---------------------------------------------------------------------------
7427 \fn sme_UpdateEmptyScanRefreshPeriod
7428 \brief Update nEmptyScanRefreshPeriod
7429 This function is called through dynamic setConfig callback function
7430 to configure nEmptyScanRefreshPeriod
7431 Usage: adb shell iwpriv wlan0 setConfig nEmptyScanRefreshPeriod=[0 .. 60]
7432 \param hHal - HAL handle for device
7433 \param nEmptyScanRefreshPeriod - scan period following empty scan results.
7434 \- return Success or failure
7435 -------------------------------------------------------------------------*/
7436
7437eHalStatus sme_UpdateEmptyScanRefreshPeriod(tHalHandle hHal, v_U16_t nEmptyScanRefreshPeriod)
7438{
7439 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7440 eHalStatus status = eHAL_STATUS_SUCCESS;
7441
7442 status = sme_AcquireGlobalLock( &pMac->sme );
7443 if ( HAL_STATUS_SUCCESS( status ) )
7444 {
7445 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7446 "LFR runtime successfully set roam scan period to %d - old value is %d - roam state is %d",
7447 nEmptyScanRefreshPeriod,
7448 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod,
7449 pMac->roam.neighborRoamInfo.neighborRoamState);
7450 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
7451 pMac->roam.neighborRoamInfo.cfgParams.emptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
7452 sme_ReleaseGlobalLock( &pMac->sme );
7453 }
7454
7455 return status ;
7456
7457}
7458
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007459
7460
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007461/* ---------------------------------------------------------------------------
7462 \fn sme_IsFeatureSupportedByFW
7463 \brief Check if an feature is enabled by FW
7464
7465 \param feattEnumValue - Enumeration value from placeHolderInCapBitmap
7466 \- return 1/0 (TRUE/FALSE)
7467 -------------------------------------------------------------------------*/
7468tANI_U8 sme_IsFeatureSupportedByFW(tANI_U8 featEnumValue)
7469{
7470 return IS_FEATURE_SUPPORTED_BY_FW(featEnumValue);
7471}
7472#ifdef FEATURE_WLAN_TDLS
7473/* ---------------------------------------------------------------------------
7474 \fn sme_SendTdlsMgmtFrame
7475 \brief API to send TDLS management frames.
7476
7477 \param peerMac - peer's Mac Adress.
7478 \param frame_type - Type of TDLS mgmt frame to be sent.
7479 \param dialog - dialog token used in the frame.
7480 \param status - status to be incuded in the frame.
7481 \param buf - additional IEs to be included
7482 \param len - lenght of additional Ies
Hoonki Leea34dd892013-02-05 22:56:02 -08007483 \param responder - Tdls request type
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007484 \- return VOS_STATUS_SUCCES
7485 -------------------------------------------------------------------------*/
7486VOS_STATUS sme_SendTdlsMgmtFrame(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08007487 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 -08007488{
7489 eHalStatus status = eHAL_STATUS_SUCCESS;
7490 tCsrTdlsSendMgmt sendTdlsReq = {{0}} ;
7491 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7492
7493 status = sme_AcquireGlobalLock( &pMac->sme );
7494 if ( HAL_STATUS_SUCCESS( status ) )
7495 {
7496 vos_mem_copy(sendTdlsReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7497 sendTdlsReq.frameType = frame_type;
7498 sendTdlsReq.buf = buf;
7499 sendTdlsReq.len = len;
7500 sendTdlsReq.dialog = dialog;
7501 sendTdlsReq.statusCode = statusCode;
Hoonki Leea34dd892013-02-05 22:56:02 -08007502 sendTdlsReq.responder = responder;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007503
7504 status = csrTdlsSendMgmtReq(hHal, sessionId, &sendTdlsReq) ;
7505
7506 sme_ReleaseGlobalLock( &pMac->sme );
7507 }
7508
7509 return status ;
7510
7511}
7512/* ---------------------------------------------------------------------------
7513 \fn sme_AddTdlsPeerSta
7514 \brief API to Add TDLS peer sta entry.
7515
7516 \param peerMac - peer's Mac Adress.
7517 \- return VOS_STATUS_SUCCES
7518 -------------------------------------------------------------------------*/
7519VOS_STATUS sme_AddTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7520{
7521 eHalStatus status = eHAL_STATUS_SUCCESS;
7522 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7523
7524 status = sme_AcquireGlobalLock( &pMac->sme );
7525 if ( HAL_STATUS_SUCCESS( status ) )
7526 {
7527 status = csrTdlsAddPeerSta(hHal, sessionId, peerMac);
7528
7529 sme_ReleaseGlobalLock( &pMac->sme );
7530 }
7531
7532 return status ;
7533
7534}
7535/* ---------------------------------------------------------------------------
7536 \fn sme_DeleteTdlsPeerSta
7537 \brief API to Delete TDLS peer sta entry.
7538
7539 \param peerMac - peer's Mac Adress.
7540 \- return VOS_STATUS_SUCCES
7541 -------------------------------------------------------------------------*/
7542VOS_STATUS sme_DeleteTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7543{
7544 eHalStatus status = eHAL_STATUS_SUCCESS;
7545 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7546
7547 status = sme_AcquireGlobalLock( &pMac->sme );
7548 if ( HAL_STATUS_SUCCESS( status ) )
7549 {
7550 status = csrTdlsDelPeerSta(hHal, sessionId, peerMac) ;
7551
7552 sme_ReleaseGlobalLock( &pMac->sme );
7553 }
7554
7555 return status ;
7556
7557}
7558#endif
7559#ifdef FEATURE_WLAN_TDLS_INTERNAL
7560/*
7561 * SME API to start TDLS discovery Procedure
7562 */
7563VOS_STATUS sme_StartTdlsDiscoveryReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7564{
7565 VOS_STATUS status = VOS_STATUS_SUCCESS;
7566 tCsrTdlsDisRequest disReq = {{0}} ;
7567 vos_mem_copy(disReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7568 status = csrTdlsDiscoveryReq(hHal, sessionId, &disReq) ;
7569
7570 return status ;
7571
7572}
7573
7574/*
7575 * Process TDLS discovery results
7576 */
7577v_U8_t sme_GetTdlsDiscoveryResult(tHalHandle hHal,
7578 tSmeTdlsDisResult *disResult, v_U8_t listType)
7579{
7580 tCsrTdlsPeerLinkinfo *peerLinkInfo = NULL ;
7581 tSirTdlsPeerInfo *peerInfo = NULL ;
7582 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7583 tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
7584 tDblLinkList *peerList = &disInfo->tdlsPotentialPeerList ;
7585 tListElem *pEntry = NULL ;
7586 v_U8_t peerCnt = 0 ;
7587
7588 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7589 ("TDLS peer count = %d\n"),disInfo->tdlsPeerCount ) ;
7590 pEntry = csrLLPeekHead( peerList, LL_ACCESS_LOCK );
7591 while(pEntry)
7592 {
7593 peerLinkInfo = GET_BASE_ADDR( pEntry, tCsrTdlsPeerLinkinfo,
7594 tdlsPeerStaLink) ;
7595 peerInfo = &peerLinkInfo->tdlsDisPeerInfo ;
7596
7597 switch(listType)
7598 {
7599 case TDLS_SETUP_LIST:
7600 {
7601 if(TDLS_LINK_SETUP_STATE == peerInfo->tdlsPeerState)
7602 {
7603 palCopyMemory(pMac->hHdd, disResult[peerCnt].tdlsPeerMac,
7604 peerInfo->peerMac, sizeof(tSirMacAddr)) ;
7605 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
7606 peerCnt++ ;
7607 }
7608 break ;
7609 }
7610 case TDLS_DIS_LIST:
7611 {
7612 palCopyMemory(pMac->hHdd, disResult[peerCnt].tdlsPeerMac,
7613 peerInfo->peerMac, sizeof(tSirMacAddr)) ;
7614 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
7615 peerCnt++ ;
7616 break ;
7617 }
7618 default:
7619 {
7620 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7621 ("unknown list type \n")) ;
7622 break ;
7623 }
7624 }
7625
7626 pEntry = csrLLNext( peerList, pEntry, LL_ACCESS_LOCK) ;
7627 }
7628
7629 return peerCnt ;
7630
7631}
7632
7633/*
7634 * SME API to start TDLS link setup Procedure.
7635 */
7636VOS_STATUS sme_StartTdlsLinkSetupReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7637{
7638 VOS_STATUS status = VOS_STATUS_SUCCESS;
7639 tCsrTdlsSetupRequest setupReq = {{0}} ;
7640 vos_mem_copy(setupReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7641 status = csrTdlsSetupReq(hHal, sessionId, &setupReq) ;
7642 return status ;
7643
7644}
7645
7646/*
7647 * SME API to start TDLS link Teardown Procedure.
7648 */
7649VOS_STATUS sme_StartTdlsLinkTeardownReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7650{
7651 VOS_STATUS status = VOS_STATUS_SUCCESS;
7652 tCsrTdlsTeardownRequest teardownReq = {{0}} ;
7653 vos_mem_copy(teardownReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7654 status = csrTdlsTeardownReq(hHal, sessionId, &teardownReq) ;
7655 return status ;
7656
7657}
7658
7659#endif /* FEATURE_WLAN_TDLS */
7660