blob: afedf75c50f95099e12ade7965295794492e5878 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson32d95a32012-09-10 13:15:23 -07002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -07003 *
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
22/**=========================================================================
23
24 \file smeApi.c
25
26 \brief Definitions for SME APIs
27
28 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
29
30 Qualcomm Confidential and Proprietary.
31
32 ========================================================================*/
33
34/*===========================================================================
35
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42
43
44 when who what, where, why
45---------- --- --------------------------------------------------------
4606/03/10 js Added support to hostapd driven
47 * deauth/disassoc/mic failure
48
49===========================================================================*/
50
51/*--------------------------------------------------------------------------
52 Include Files
53 ------------------------------------------------------------------------*/
54
55#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
56#include "halInternal.h"
57#endif
58
59#include "smsDebug.h"
60#include "sme_Api.h"
61#include "csrInsideApi.h"
62#include "smeInside.h"
63#include "csrInternal.h"
64#include "wlan_qct_wda.h"
65#include "halMsgApi.h"
66
67#ifdef WLAN_SOFTAP_FEATURE
68#include "sapApi.h"
69#endif
70
71
72
73#if !defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
74extern tSirRetStatus uMacPostCtrlMsg(void* pSirGlobal, tSirMbMsg* pMb);
75
76#include <wlan_qct_pal_api.h>
77#endif
78
79// TxMB Functions
80extern eHalStatus pmcPrepareCommand( tpAniSirGlobal pMac, eSmeCommandType cmdType, void *pvParam,
81 tANI_U32 size, tSmeCmd **ppCmd );
82extern void pmcReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
83extern void qosReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
84#if defined WLAN_FEATURE_P2P
85extern eHalStatus p2pProcessRemainOnChannelCmd(tpAniSirGlobal pMac, tSmeCmd *p2pRemainonChn);
86extern eHalStatus sme_remainOnChnRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg);
87extern eHalStatus sme_mgmtFrmInd( tHalHandle hHal, tpSirSmeMgmtFrameInd pSmeMgmtFrm);
88extern eHalStatus sme_remainOnChnReady( tHalHandle hHal, tANI_U8* pMsg);
89extern eHalStatus sme_sendActionCnf( tHalHandle hHal, tANI_U8* pMsg);
90extern eHalStatus p2pProcessNoAReq(tpAniSirGlobal pMac, tSmeCmd *pNoACmd);
91#endif
92
93static eHalStatus initSmeCmdList(tpAniSirGlobal pMac);
94static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping );
95
96eCsrPhyMode sme_GetPhyMode(tHalHandle hHal);
97
98eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf);
99
100eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal);
101
102eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal);
103
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -0700104#ifdef FEATURE_WLAN_LFR
105tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac);
106#endif
107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108//Internal SME APIs
109eHalStatus sme_AcquireGlobalLock( tSmeStruct *psSme)
110{
111 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
112
113 if(psSme)
114 {
115 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psSme->lkSmeGlobalLock) ) )
116 {
117 status = eHAL_STATUS_SUCCESS;
118 }
119 }
120
121 return (status);
122}
123
124
125eHalStatus sme_ReleaseGlobalLock( tSmeStruct *psSme)
126{
127 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
128
129 if(psSme)
130 {
131 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psSme->lkSmeGlobalLock) ) )
132 {
133 status = eHAL_STATUS_SUCCESS;
134 }
135 }
136
137 return (status);
138}
139
140
141
142static eHalStatus initSmeCmdList(tpAniSirGlobal pMac)
143{
144 eHalStatus status;
145 tSmeCmd *pCmd;
146
147 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
148 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdActiveList)))
149 {
150 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdPendingList)))
151 {
152 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdFreeList)))
153 {
154 status = palAllocateMemory(pMac->hHdd, (void **)&pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
155 if(HAL_STATUS_SUCCESS(status))
156 {
157 tANI_U32 c;
158
159 palZeroMemory(pMac->hHdd, pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
160 pMac->sme.pSmeCmdBufAddr = pCmd;
161 for(c = 0; c < pMac->sme.totalSmeCmd; c++)
162 {
163 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd[c].Link, LL_ACCESS_LOCK);
164 }
165 }
166 }
167 }
168 }
169
170 return (status);
171}
172
173
174void smeReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCmd)
175{
176 pCmd->command = eSmeNoCommand;
177 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd->Link, LL_ACCESS_LOCK);
178}
179
180
181
182static void smeReleaseCmdList(tpAniSirGlobal pMac, tDblLinkList *pList)
183{
184 tListElem *pEntry;
185 tSmeCmd *pCommand;
186
187 while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_LOCK)) != NULL)
188 {
189 //TODO: base on command type to call release functions
190 //reinitialize different command types so they can be reused
191 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
192 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
193 }
194}
195
196static void purgeSmeCmdList(tpAniSirGlobal pMac)
197{
198 //release any out standing commands back to free command list
199 smeReleaseCmdList(pMac, &pMac->sme.smeCmdPendingList);
200 smeReleaseCmdList(pMac, &pMac->sme.smeCmdActiveList);
201}
202
203void purgeSmeSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
204{
205 //release any out standing commands back to free command list
206 tListElem *pEntry, *pNext;
207 tSmeCmd *pCommand;
208 tDblLinkList *pList = &pMac->sme.smeCmdPendingList;
209 tDblLinkList localList;
210
211 vos_mem_zero(&localList, sizeof(tDblLinkList));
212 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
213 {
214 smsLog(pMac, LOGE, FL(" failed to open list"));
215 return;
216 }
217
218 csrLLLock(pList);
219 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
220 while(pEntry != NULL)
221 {
222 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
223 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
224 if(pCommand->sessionId == sessionId)
225 {
226 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
227 {
228 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
229 }
230 }
231 pEntry = pNext;
232 }
233 csrLLUnlock(pList);
234
235 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
236 {
237 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
238 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
239 }
240 csrLLClose(&localList);
241
242}
243
244
245static eHalStatus freeSmeCmdList(tpAniSirGlobal pMac)
246{
247 eHalStatus status = eHAL_STATUS_SUCCESS;
248
249 purgeSmeCmdList(pMac);
250 csrLLClose(&pMac->sme.smeCmdPendingList);
251 csrLLClose(&pMac->sme.smeCmdActiveList);
252 csrLLClose(&pMac->sme.smeCmdFreeList);
253
254 if(NULL != pMac->sme.pSmeCmdBufAddr)
255 {
256 status = palFreeMemory(pMac->hHdd, pMac->sme.pSmeCmdBufAddr);
257 pMac->sme.pSmeCmdBufAddr = NULL;
258 }
259
260 return (status);
261}
262
263
264void dumpCsrCommandInfo(tpAniSirGlobal pMac, tSmeCmd *pCmd)
265{
266#ifdef WLAN_DEBUG
267 switch( pCmd->command )
268 {
269 case eSmeCommandScan:
270 smsLog( pMac, LOGE, " scan command reason is %d", pCmd->u.scanCmd.reason );
271 break;
272
273 case eSmeCommandRoam:
274 smsLog( pMac, LOGE, " roam command reason is %d", pCmd->u.roamCmd.roamReason );
275 break;
276
277 case eSmeCommandWmStatusChange:
278 smsLog( pMac, LOGE, " WMStatusChange command type is %d", pCmd->u.wmStatusChangeCmd.Type );
279 break;
280
281 case eSmeCommandSetKey:
282 smsLog( pMac, LOGE, " setKey command auth(%d) enc(%d)",
283 pCmd->u.setKeyCmd.authType, pCmd->u.setKeyCmd.encType );
284 break;
285
286 case eSmeCommandRemoveKey:
287 smsLog( pMac, LOGE, " removeKey command auth(%d) enc(%d)",
288 pCmd->u.removeKeyCmd.authType, pCmd->u.removeKeyCmd.encType );
289 break;
290
291 default:
292 break;
293 }
294#endif //#ifdef WLAN_DEBUG
295}
296
297tSmeCmd *smeGetCommandBuffer( tpAniSirGlobal pMac )
298{
299 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
300 tListElem *pEntry;
301
302 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK );
303
304 // If we can get another MS Msg buffer, then we are ok. Just link
305 // the entry onto the linked list. (We are using the linked list
306 // to keep track of tfhe message buffers).
307 if ( pEntry )
308 {
309 pRetCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
310 }
311 else {
312 int idx = 1;
313
314 //Cannot change pRetCmd here since it needs to return later.
315 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
316 if( pEntry )
317 {
318 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
319 }
320 smsLog( pMac, LOGE, "Out of command buffer.... command (0x%X) stuck\n",
321 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
322 if(pTempCmd)
323 {
324 if( eSmeCsrCommandMask & pTempCmd->command )
325 {
326 //CSR command is stuck. See what the reason code is for that command
327 dumpCsrCommandInfo(pMac, pTempCmd);
328 }
329 } //if(pTempCmd)
330
331 //dump what is in the pending queue
332 csrLLLock(&pMac->sme.smeCmdPendingList);
333 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
334 while(pEntry)
335 {
336 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
337 smsLog( pMac, LOGE, "Out of command buffer.... SME pending command #%d (0x%X)\n",
338 idx++, pTempCmd->command );
339 if( eSmeCsrCommandMask & pTempCmd->command )
340 {
341 //CSR command is stuck. See what the reason code is for that command
342 dumpCsrCommandInfo(pMac, pTempCmd);
343 }
344 pEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
345 }
346 csrLLUnlock(&pMac->sme.smeCmdPendingList);
347
348 //There may be some more command in CSR's own pending queue
349 csrLLLock(&pMac->roam.roamCmdPendingList);
350 pEntry = csrLLPeekHead( &pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK );
351 while(pEntry)
352 {
353 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
354 smsLog( pMac, LOGE, "Out of command buffer.... CSR pending command #%d (0x%X)\n",
355 idx++, pTempCmd->command );
356 dumpCsrCommandInfo(pMac, pTempCmd);
357 pEntry = csrLLNext( &pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
358 }
359 csrLLUnlock(&pMac->roam.roamCmdPendingList);
360 }
361
362 return( pRetCmd );
363}
364
365
366void smePushCommand( tpAniSirGlobal pMac, tSmeCmd *pCmd, tANI_BOOLEAN fHighPriority )
367{
368 if ( fHighPriority )
369 {
370 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
371 }
372 else
373 {
374 csrLLInsertTail( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
375 }
376
377 // process the command queue...
378 smeProcessPendingQueue( pMac );
379
380 return;
381}
382
383
384static eSmeCommandType smeIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand )
385{
386 eSmeCommandType pmcCommand = eSmeNoCommand;
387 tANI_BOOLEAN fFullPowerNeeded = eANI_BOOLEAN_FALSE;
388 tPmcState pmcState;
389 eHalStatus status;
390
391 do
392 {
393 pmcState = pmcGetPmcState(pMac);
394
395 status = csrIsFullPowerNeeded( pMac, pCommand, NULL, &fFullPowerNeeded );
396 if( !HAL_STATUS_SUCCESS(status) )
397 {
398 //PMC state is not right for the command, drop it
399 return ( eSmeDropCommand );
400 }
401 if( fFullPowerNeeded ) break;
402 fFullPowerNeeded = ( ( eSmeCommandAddTs == pCommand->command ) ||
403 ( eSmeCommandDelTs == pCommand->command ) );
404 if( fFullPowerNeeded ) break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700405#ifdef FEATURE_OEM_DATA_SUPPORT
406 fFullPowerNeeded = (pmcState == IMPS &&
407 eSmeCommandOemDataReq == pCommand->command);
408 if(fFullPowerNeeded) break;
409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700410#ifdef WLAN_FEATURE_P2P
411 fFullPowerNeeded = (pmcState == IMPS &&
412 eSmeCommandRemainOnChannel == pCommand->command);
413 if(fFullPowerNeeded) break;
414#endif
415 } while(0);
416
417 if( fFullPowerNeeded )
418 {
419 switch( pmcState )
420 {
421 case IMPS:
422 case STANDBY:
423 pmcCommand = eSmeCommandExitImps;
424 break;
425
426 case BMPS:
427 pmcCommand = eSmeCommandExitBmps;
428 break;
429
430 case UAPSD:
431 pmcCommand = eSmeCommandExitUapsd;
432 break;
433
434 case WOWL:
435 pmcCommand = eSmeCommandExitWowl;
436 break;
437
438 default:
439 break;
440 }
441 }
442
443 return ( pmcCommand );
444}
445
446
447//For commands that need to do extra cleanup.
448static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
449{
450 if( eSmePmcCommandMask & pCommand->command )
451 {
452 pmcAbortCommand( pMac, pCommand, fStopping );
453 }
454 else if ( eSmeCsrCommandMask & pCommand->command )
455 {
456 csrAbortCommand( pMac, pCommand, fStopping );
457 }
458 else
459 {
460 switch( pCommand->command )
461 {
462#ifdef WLAN_FEATURE_P2P
463 case eSmeCommandRemainOnChannel:
464 if (NULL != pCommand->u.remainChlCmd.callback)
465 {
466 remainOnChanCallback callback =
467 pCommand->u.remainChlCmd.callback;
468 /* process the msg */
469 if( callback )
470 {
471 callback(pMac, pCommand->u.remainChlCmd.callbackCtx,
472 eCSR_SCAN_ABORT );
473 }
474 }
475 smeReleaseCommand( pMac, pCommand );
476 break;
477#endif
478 default:
479 smeReleaseCommand( pMac, pCommand );
480 break;
481 }
482 }
483}
484
485
486
487tANI_BOOLEAN smeProcessCommand( tpAniSirGlobal pMac )
488{
489 tANI_BOOLEAN fContinue = eANI_BOOLEAN_FALSE;
490 eHalStatus status = eHAL_STATUS_SUCCESS;
491 tListElem *pEntry;
492 tSmeCmd *pCommand;
493 eSmeCommandType pmcCommand = eSmeNoCommand;
494
495 // if the ActiveList is empty, then nothing is active so we can process a
496 // pending command...
497 //alwasy lock active list before locking pending list
498 csrLLLock( &pMac->sme.smeCmdActiveList );
499 if ( csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) )
500 {
501 if(!csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK))
502 {
503 //Peek the command
504 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK );
505 if( pEntry )
506 {
507 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
508 //We cannot execute any command in wait-for-key state until setKey is through.
509 if( CSR_IS_WAIT_FOR_KEY( pMac, pCommand->sessionId ) )
510 {
511 if( !CSR_IS_SET_KEY_COMMAND( pCommand ) )
512 {
513 csrLLUnlock( &pMac->sme.smeCmdActiveList );
514 smsLog(pMac, LOGE, " Cannot process command(%d) while waiting for key\n", pCommand->command);
515 return ( eANI_BOOLEAN_FALSE );
516 }
517 }
518 pmcCommand = smeIsFullPowerNeeded( pMac, pCommand );
519 if( eSmeDropCommand == pmcCommand )
520 {
521 //This command is not ok for current PMC state
522 if( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
523 {
524 smeAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE );
525 }
526 csrLLUnlock( &pMac->sme.smeCmdActiveList );
527 //tell caller to continue
528 return (eANI_BOOLEAN_TRUE);
529 }
530 else if( eSmeNoCommand != pmcCommand )
531 {
532 tExitBmpsInfo exitBmpsInfo;
533 void *pv = NULL;
534 tANI_U32 size = 0;
535 tSmeCmd *pPmcCmd = NULL;
536
537 if( eSmeCommandExitBmps == pmcCommand )
538 {
539 exitBmpsInfo.exitBmpsReason = eSME_REASON_OTHER;
540 pv = (void *)&exitBmpsInfo;
541 size = sizeof(tExitBmpsInfo);
542 }
543 //pmcCommand has to be one of the exit power save command
544 status = pmcPrepareCommand( pMac, pmcCommand, pv, size, &pPmcCmd );
545 if( HAL_STATUS_SUCCESS( status ) && pPmcCmd )
546 {
547 //Force this command to wake up the chip
548 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK );
549 csrLLUnlock( &pMac->sme.smeCmdActiveList );
550 fContinue = pmcProcessCommand( pMac, pPmcCmd );
551 if( fContinue )
552 {
553 //The command failed, remove it
554 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK ) )
555 {
556 pmcReleaseCommand( pMac, pPmcCmd );
557 }
558 }
559 }
560 else
561 {
562 csrLLUnlock( &pMac->sme.smeCmdActiveList );
563 smsLog( pMac, LOGE, FL( "Cannot issue command(0x%X) to wake up the chip. Status = %d\n"), pmcCommand, status );
564 //Let it retry
565 fContinue = eANI_BOOLEAN_TRUE;
566 }
567 return fContinue;
568 }
569 if ( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
570 {
571 // we can reuse the pCommand
572
573 // Insert the command onto the ActiveList...
574 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pCommand->Link, LL_ACCESS_NOLOCK );
575
576 // .... and process the command.
577
578 switch ( pCommand->command )
579 {
580
581 case eSmeCommandScan:
582 csrLLUnlock( &pMac->sme.smeCmdActiveList );
583 status = csrProcessScanCommand( pMac, pCommand );
584 break;
585
586 case eSmeCommandRoam:
587 csrLLUnlock( &pMac->sme.smeCmdActiveList );
588 status = csrRoamProcessCommand( pMac, pCommand );
589 break;
590
591 case eSmeCommandWmStatusChange:
592 csrLLUnlock( &pMac->sme.smeCmdActiveList );
593 csrRoamProcessWmStatusChangeCommand(pMac, pCommand);
594 break;
595
596 case eSmeCommandSetKey:
597 csrLLUnlock( &pMac->sme.smeCmdActiveList );
598 status = csrRoamProcessSetKeyCommand( pMac, pCommand );
599 if(!HAL_STATUS_SUCCESS(status))
600 {
601 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
602 &pCommand->Link, LL_ACCESS_LOCK ) )
603 {
604 csrReleaseCommandSetKey( pMac, pCommand );
605 }
606 }
607 break;
608
609 case eSmeCommandRemoveKey:
610 csrLLUnlock( &pMac->sme.smeCmdActiveList );
611 status = csrRoamProcessRemoveKeyCommand( pMac, pCommand );
612 if(!HAL_STATUS_SUCCESS(status))
613 {
614 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
615 &pCommand->Link, LL_ACCESS_LOCK ) )
616 {
617 csrReleaseCommandRemoveKey( pMac, pCommand );
618 }
619 }
620 break;
621
622 case eSmeCommandAddStaSession:
623 csrLLUnlock( &pMac->sme.smeCmdActiveList );
624 csrProcessAddStaSessionCommand( pMac, pCommand );
625 break;
626 case eSmeCommandDelStaSession:
627 csrLLUnlock( &pMac->sme.smeCmdActiveList );
628 csrProcessDelStaSessionCommand( pMac, pCommand );
629 break;
630
Jeff Johnsone7245742012-09-05 17:12:55 -0700631#ifdef FEATURE_OEM_DATA_SUPPORT
632 case eSmeCommandOemDataReq:
633 csrLLUnlock(&pMac->sme.smeCmdActiveList);
634 oemData_ProcessOemDataReqCommand(pMac, pCommand);
635 break;
636#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700637#if defined WLAN_FEATURE_P2P
638 case eSmeCommandRemainOnChannel:
639 csrLLUnlock(&pMac->sme.smeCmdActiveList);
640 p2pProcessRemainOnChannelCmd(pMac, pCommand);
641 break;
642 case eSmeCommandNoAUpdate:
643 csrLLUnlock( &pMac->sme.smeCmdActiveList );
644 p2pProcessNoAReq(pMac,pCommand);
645#endif
646 case eSmeCommandEnterImps:
647 case eSmeCommandExitImps:
648 case eSmeCommandEnterBmps:
649 case eSmeCommandExitBmps:
650 case eSmeCommandEnterUapsd:
651 case eSmeCommandExitUapsd:
652 case eSmeCommandEnterWowl:
653 case eSmeCommandExitWowl:
654 csrLLUnlock( &pMac->sme.smeCmdActiveList );
655 fContinue = pmcProcessCommand( pMac, pCommand );
656 if( fContinue )
657 {
658 //The command failed, remove it
659 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
660 &pCommand->Link, LL_ACCESS_LOCK ) )
661 {
662 pmcReleaseCommand( pMac, pCommand );
663 }
664 }
665 break;
666
667 //Treat standby differently here because caller may not be able to handle
668 //the failure so we do our best here
669 case eSmeCommandEnterStandby:
670 if( csrIsConnStateDisconnected( pMac, pCommand->sessionId ) )
671 {
672 //It can continue
673 csrLLUnlock( &pMac->sme.smeCmdActiveList );
674 fContinue = pmcProcessCommand( pMac, pCommand );
675 if( fContinue )
676 {
677 //The command failed, remove it
678 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
679 &pCommand->Link, LL_ACCESS_LOCK ) )
680 {
681 pmcReleaseCommand( pMac, pCommand );
682 }
683 }
684 }
685 else
686 {
687 //Need to issue a disconnect first before processing this command
688 tSmeCmd *pNewCmd;
689
690 //We need to re-run the command
691 fContinue = eANI_BOOLEAN_TRUE;
692 //Pull off the standby command first
693 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
694 &pCommand->Link, LL_ACCESS_NOLOCK ) )
695 {
696 csrLLUnlock( &pMac->sme.smeCmdActiveList );
697 //Need to call CSR function here because the disconnect command
698 //is handled by CSR
699 pNewCmd = csrGetCommandBuffer( pMac );
700 if( NULL != pNewCmd )
701 {
702 //Put the standby command to the head of the pending list first
703 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCommand->Link,
704 LL_ACCESS_LOCK );
705 pNewCmd->command = eSmeCommandRoam;
706 pNewCmd->u.roamCmd.roamReason = eCsrForcedDisassoc;
707 //Put the disassoc command before the standby command
708 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pNewCmd->Link,
709 LL_ACCESS_LOCK );
710 }
711 else
712 {
713 //Continue the command here
714 fContinue = pmcProcessCommand( pMac, pCommand );
715 if( fContinue )
716 {
717 //The command failed, remove it
718 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
719 &pCommand->Link, LL_ACCESS_LOCK ) )
720 {
721 pmcReleaseCommand( pMac, pCommand );
722 }
723 }
724 }
725 }
726 else
727 {
728 csrLLUnlock( &pMac->sme.smeCmdActiveList );
729 smsLog( pMac, LOGE, FL(" failed to remove standby command\n") );
730 VOS_ASSERT(0);
731 }
732 }
733 break;
734
735 case eSmeCommandAddTs:
736 case eSmeCommandDelTs:
737 csrLLUnlock( &pMac->sme.smeCmdActiveList );
738#ifndef WLAN_MDM_CODE_REDUCTION_OPT
739 fContinue = qosProcessCommand( pMac, pCommand );
740 if( fContinue )
741 {
742 //The command failed, remove it
743 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
744 &pCommand->Link, LL_ACCESS_NOLOCK ) )
745 {
746//#ifndef WLAN_MDM_CODE_REDUCTION_OPT
747 qosReleaseCommand( pMac, pCommand );
748//#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
749 }
750 }
751#endif
752 break;
753
754 default:
755 //something is wrong
756 //remove it from the active list
757 smsLog(pMac, LOGE, " csrProcessCommand processes an unknown command %d\n", pCommand->command);
758 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK );
759 csrLLUnlock( &pMac->sme.smeCmdActiveList );
760 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
761 smeReleaseCommand( pMac, pCommand );
762 status = eHAL_STATUS_FAILURE;
763 break;
764 }
765 if(!HAL_STATUS_SUCCESS(status))
766 {
767 fContinue = eANI_BOOLEAN_TRUE;
768 }
769 }//if(pEntry)
770 else
771 {
772 //This is odd. Some one else pull off the command.
773 csrLLUnlock( &pMac->sme.smeCmdActiveList );
774 }
775 }
776 else
777 {
778 csrLLUnlock( &pMac->sme.smeCmdActiveList );
779 }
780 }
781 else
782 {
783 //No command waiting
784 csrLLUnlock( &pMac->sme.smeCmdActiveList );
785 //This is only used to restart an idle mode scan, it means at least one other idle scan has finished.
786 if(pMac->scan.fRestartIdleScan && eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
787 {
788 tANI_U32 nTime = 0;
789
790 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
791 if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime)))
792 {
793 csrScanStartIdleScanTimer(pMac, nTime);
794 }
795 }
796 }
797 }
798 else {
799 csrLLUnlock( &pMac->sme.smeCmdActiveList );
800 }
801
802 return ( fContinue );
803}
804
805void smeProcessPendingQueue( tpAniSirGlobal pMac )
806{
807 while( smeProcessCommand( pMac ) );
808}
809
810
811tANI_BOOLEAN smeCommandPending(tpAniSirGlobal pMac)
812{
813 return ( !csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) ||
814 !csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK) );
815}
816
817
818
819//Global APIs
820
821/*--------------------------------------------------------------------------
822
823 \brief sme_Open() - Initialze all SME modules and put them at idle state
824
825 The function initializes each module inside SME, PMC, CCM, CSR, etc. . Upon
826 successfully return, all modules are at idle state ready to start.
827
828 smeOpen must be called before any other SME APIs can be involved.
829 smeOpen must be called after macOpen.
830 This is a synchronuous call
831 \param hHal - The handle returned by macOpen.
832
833 \return eHAL_STATUS_SUCCESS - SME is successfully initialized.
834
835 Other status means SME is failed to be initialized
836 \sa
837
838 --------------------------------------------------------------------------*/
839eHalStatus sme_Open(tHalHandle hHal)
840{
841 eHalStatus status = eHAL_STATUS_FAILURE;
842 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
843
844 do {
845 pMac->sme.state = SME_STATE_STOP;
846 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->sme.lkSmeGlobalLock ) ) )
847 {
848 smsLog( pMac, LOGE, "sme_Open failed init lock\n" );
849 status = eHAL_STATUS_FAILURE;
850 break;
851 }
852
853 status = ccmOpen(hHal);
854 if ( ! HAL_STATUS_SUCCESS( status ) ) {
855 smsLog( pMac, LOGE,
856 "ccmOpen failed during initialization with status=%d", status );
857 break;
858 }
859
860 status = csrOpen(pMac);
861 if ( ! HAL_STATUS_SUCCESS( status ) ) {
862 smsLog( pMac, LOGE,
863 "csrOpen failed during initialization with status=%d", status );
864 break;
865 }
866
867 status = pmcOpen(hHal);
868 if ( ! HAL_STATUS_SUCCESS( status ) ) {
869 smsLog( pMac, LOGE,
870 "pmcOpen failed during initialization with status=%d", status );
871 break;
872 }
873
874#ifndef WLAN_MDM_CODE_REDUCTION_OPT
875 status = sme_QosOpen(pMac);
876 if ( ! HAL_STATUS_SUCCESS( status ) ) {
877 smsLog( pMac, LOGE,
878 "Qos open failed during initialization with status=%d", status );
879 break;
880 }
881
882 status = btcOpen(pMac);
883 if ( ! HAL_STATUS_SUCCESS( status ) ) {
884 smsLog( pMac, LOGE,
885 "btcOpen open failed during initialization with status=%d", status );
886 break;
887 }
888#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700889#ifdef FEATURE_OEM_DATA_SUPPORT
890 status = oemData_OemDataReqOpen(pMac);
891 if ( ! HAL_STATUS_SUCCESS( status ) ) {
892 smsLog(pMac, LOGE,
893 "oemData_OemDataReqOpen failed during initialization with status=%d", status );
894 break;
895 }
896#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700897
898 if(!HAL_STATUS_SUCCESS((status = initSmeCmdList(pMac))))
899 break;
900
901#ifdef WLAN_SOFTAP_FEATURE
902 {
903 v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SAP, NULL);
904 if ( NULL == pvosGCtx ){
905 smsLog( pMac, LOGE, "WLANSAP_Open open failed during initialization");
906 status = eHAL_STATUS_FAILURE;
907 break;
908 }
909
910 status = WLANSAP_Open( pvosGCtx );
911 if ( ! HAL_STATUS_SUCCESS( status ) ) {
912 smsLog( pMac, LOGE,
913 "WLANSAP_Open open failed during initialization with status=%d", status );
914 break;
915 }
916 }
917#endif
918#if defined WLAN_FEATURE_VOWIFI
919 status = rrmOpen(pMac);
920 if ( ! HAL_STATUS_SUCCESS( status ) ) {
921 smsLog( pMac, LOGE,
922 "rrmOpen open failed during initialization with status=%d", status );
923 break;
924 }
925#endif
926
927#if defined WLAN_FEATURE_VOWIFI_11R
928 sme_FTOpen(pMac);
929#endif
930#if defined WLAN_FEATURE_P2P
931 sme_p2pOpen(pMac);
932#endif
933
934 }while (0);
935
936 return status;
937}
938
939#ifdef WLAN_SOFTAP_FEATURE
940/*--------------------------------------------------------------------------
941
942 \brief sme_set11dinfo() - Set the 11d information about valid channels
943 and there power using information from nvRAM
944 This function is called only for AP.
945
946 This is a synchronuous call
947
948 \param hHal - The handle returned by macOpen.
949 \Param pSmeConfigParams - a pointer to a caller allocated object of
950 typedef struct _smeConfigParams.
951
952 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
953
954 Other status means SME is failed to update the config parameters.
955 \sa
956--------------------------------------------------------------------------*/
957
958eHalStatus sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
959{
960 eHalStatus status = eHAL_STATUS_FAILURE;
961 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
962
963 if (NULL == pSmeConfigParams ) {
964 smsLog( pMac, LOGE,
965 "Empty config param structure for SME, nothing to update");
966 return status;
967 }
968
969 status = csrSetChannels(hHal, &pSmeConfigParams->csrConfig );
970 if ( ! HAL_STATUS_SUCCESS( status ) ) {
971 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d\n",
972 status );
973 }
974 return status;
975}
976
977/*--------------------------------------------------------------------------
978
979 \brief sme_getSoftApDomain() - Get the current regulatory domain of softAp.
980
981 This is a synchronuous call
982
983 \param hHal - The handle returned by HostapdAdapter.
984 \Param v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
985
986 \return eHAL_STATUS_SUCCESS - SME successfully completed the request.
987
988 Other status means, failed to get the current regulatory domain.
989 \sa
990--------------------------------------------------------------------------*/
991
992eHalStatus sme_getSoftApDomain(tHalHandle hHal, v_REGDOMAIN_t *domainIdSoftAp)
993{
994 eHalStatus status = eHAL_STATUS_FAILURE;
995 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
996
997 if (NULL == domainIdSoftAp ) {
998 smsLog( pMac, LOGE, "Uninitialized domain Id");
999 return status;
1000 }
1001
1002 *domainIdSoftAp = pMac->scan.domainIdCurrent;
1003 status = eHAL_STATUS_SUCCESS;
1004
1005 return status;
1006}
1007
1008
1009eHalStatus sme_setRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
1010{
1011 eHalStatus status = eHAL_STATUS_FAILURE;
1012 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1013
1014 if (NULL == apCntryCode ) {
1015 smsLog( pMac, LOGE, "Empty Country Code, nothing to update");
1016 return status;
1017 }
1018
1019 status = csrSetRegInfo(hHal, apCntryCode );
1020 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1021 smsLog( pMac, LOGE, "csrSetRegInfo failed with status=%d\n",
1022 status );
1023 }
1024 return status;
1025}
1026
1027#endif
1028#ifdef FEATURE_WLAN_SCAN_PNO
1029/*--------------------------------------------------------------------------
1030
1031 \brief sme_UpdateChannelConfig() - Update channel configuration in RIVA.
1032
1033 It is used at driver start up to inform RIVA of the default channel
1034 configuration.
1035
1036 This is a synchronuous call
1037
1038 \param hHal - The handle returned by macOpen.
1039
1040 \return eHAL_STATUS_SUCCESS - SME update the channel config successfully.
1041
1042 Other status means SME is failed to update the channel config.
1043 \sa
1044
1045 --------------------------------------------------------------------------*/
1046eHalStatus sme_UpdateChannelConfig(tHalHandle hHal)
1047{
1048 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1049
1050 pmcUpdateScanParams( pMac, &(pMac->roam.configParam),
1051 &pMac->scan.base20MHzChannels, FALSE);
1052 return eHAL_STATUS_SUCCESS;
1053}
1054#endif // FEATURE_WLAN_SCAN_PNLO
1055
1056/*--------------------------------------------------------------------------
1057
1058 \brief sme_UpdateConfig() - Change configurations for all SME moduels
1059
1060 The function updates some configuration for modules in SME, CCM, CSR, etc
1061 during SMEs close open sequence.
1062
1063 Modules inside SME apply the new configuration at the next transaction.
1064
1065 This is a synchronuous call
1066
1067 \param hHal - The handle returned by macOpen.
1068 \Param pSmeConfigParams - a pointer to a caller allocated object of
1069 typedef struct _smeConfigParams.
1070
1071 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1072
1073 Other status means SME is failed to update the config parameters.
1074 \sa
1075
1076 --------------------------------------------------------------------------*/
1077eHalStatus sme_UpdateConfig(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1078{
1079 eHalStatus status = eHAL_STATUS_FAILURE;
1080 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1081
1082 if (NULL == pSmeConfigParams ) {
1083 smsLog( pMac, LOGE,
1084 "Empty config param structure for SME, nothing to update");
1085 return status;
1086 }
1087
1088 status = csrChangeDefaultConfigParam(pMac, &pSmeConfigParams->csrConfig);
1089
1090 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1091 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d\n",
1092 status );
1093 }
1094#if defined WLAN_FEATURE_P2P_INTERNAL
1095 status = p2pChangeDefaultConfigParam(pMac, &pSmeConfigParams->p2pConfig);
1096
1097 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1098 smsLog( pMac, LOGE, "p2pChangeDefaultConfigParam failed with status=%d\n",
1099 status );
1100 }
1101#endif
1102#if defined WLAN_FEATURE_VOWIFI
1103 status = rrmChangeDefaultConfigParam(hHal, &pSmeConfigParams->rrmConfig);
1104
1105 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1106 smsLog( pMac, LOGE, "rrmChangeDefaultConfigParam failed with status=%d\n",
1107 status );
1108 }
1109#endif
1110 //For SOC, CFG is set before start
1111 //We don't want to apply global CFG in connect state because that may cause some side affect
1112 if(
1113#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
1114 //For the new init sequence, CFGs need to apply before vos_start is call
1115 //No need to wait for ready state.
1116 SME_IS_READY(pMac) &&
1117#endif
1118 csrIsAllSessionDisconnected( pMac) )
1119 {
1120 csrSetGlobalCfgs(pMac);
1121 }
1122
1123 return status;
1124}
1125
1126/* ---------------------------------------------------------------------------
1127 \fn sme_ChangeConfigParams
1128 \brief The SME API exposed for HDD to provide config params to SME during
1129 SMEs stop -> start sequence.
1130
1131 If HDD changed the domain that will cause a reset. This function will
1132 provide the new set of 11d information for the new domain. Currrently this
1133 API provides info regarding 11d only at reset but we can extend this for
1134 other params (PMC, QoS) which needs to be initialized again at reset.
1135
1136 This is a synchronuous call
1137
1138 \param hHal - The handle returned by macOpen.
1139
1140 \Param
1141 pUpdateConfigParam - a pointer to a structure (tCsrUpdateConfigParam) that
1142 currently provides 11d related information like Country code,
1143 Regulatory domain, valid channel list, Tx power per channel, a
1144 list with active/passive scan allowed per valid channel.
1145
1146 \return eHalStatus
1147 ---------------------------------------------------------------------------*/
1148eHalStatus sme_ChangeConfigParams(tHalHandle hHal,
1149 tCsrUpdateConfigParam *pUpdateConfigParam)
1150{
1151 eHalStatus status = eHAL_STATUS_FAILURE;
1152 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1153
1154 if (NULL == pUpdateConfigParam ) {
1155 smsLog( pMac, LOGE,
1156 "Empty config param structure for SME, nothing to reset\n");
1157 return status;
1158 }
1159
1160 status = csrChangeConfigParams(pMac, pUpdateConfigParam);
1161
1162 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1163 smsLog( pMac, LOGE, "csrUpdateConfigParam failed with status=%d\n",
1164 status );
1165 }
1166
1167 return status;
1168
1169}
1170
1171/*--------------------------------------------------------------------------
1172
1173 \brief sme_HDDReadyInd() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1174 that the NIC is ready tio run.
1175
1176 The function is called by HDD at the end of initialization stage so PE/HAL can
1177 enable the NIC to running state.
1178
1179 This is a synchronuous call
1180 \param hHal - The handle returned by macOpen.
1181
1182 \return eHAL_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1183 successfully.
1184
1185 Other status means SME failed to send the message to PE.
1186 \sa
1187
1188 --------------------------------------------------------------------------*/
1189eHalStatus sme_HDDReadyInd(tHalHandle hHal)
1190{
1191 tSirSmeReadyReq Msg;
1192 eHalStatus status = eHAL_STATUS_FAILURE;
1193 tPmcPowerState powerState;
1194 tPmcSwitchState hwWlanSwitchState;
1195 tPmcSwitchState swWlanSwitchState;
1196 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1197
1198 do
1199 {
1200#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
1201 csrSetGlobalCfgs( pMac );
1202#endif
1203
1204 Msg.messageType = eWNI_SME_SYS_READY_IND;
1205 Msg.length = sizeof( tSirSmeReadyReq );
1206
1207 if (eSIR_FAILURE != uMacPostCtrlMsg( hHal, (tSirMbMsg*)&Msg ))
1208 {
1209 status = eHAL_STATUS_SUCCESS;
1210 }
1211 else
1212 {
1213 smsLog( pMac, LOGE,
1214 "uMacPostCtrlMsg failed to send eWNI_SME_SYS_READY_IND");
1215 break;
1216 }
1217
1218 status = pmcQueryPowerState( hHal, &powerState,
1219 &hwWlanSwitchState, &swWlanSwitchState );
1220 if ( ! HAL_STATUS_SUCCESS( status ) )
1221 {
1222 smsLog( pMac, LOGE, "pmcQueryPowerState failed with status=%d\n",
1223 status );
1224 break;
1225 }
1226
1227 if ( (ePMC_SWITCH_OFF != hwWlanSwitchState) &&
1228 (ePMC_SWITCH_OFF != swWlanSwitchState) )
1229 {
1230 status = csrReady(pMac);
1231 if ( ! HAL_STATUS_SUCCESS( status ) )
1232 {
1233 smsLog( pMac, LOGE, "csrReady failed with status=%d\n", status );
1234 break;
1235 }
1236 status = pmcReady(hHal);
1237 if ( ! HAL_STATUS_SUCCESS( status ) )
1238 {
1239 smsLog( pMac, LOGE, "pmcReady failed with status=%d\n", status );
1240 break;
1241 }
1242#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1243 if(VOS_STATUS_SUCCESS != btcReady(hHal))
1244 {
1245 status = eHAL_STATUS_FAILURE;
1246 smsLog( pMac, LOGE, "btcReady failed\n");
1247 break;
1248 }
1249#endif
1250
1251#if defined WLAN_FEATURE_VOWIFI
1252 if(VOS_STATUS_SUCCESS != rrmReady(hHal))
1253 {
1254 status = eHAL_STATUS_FAILURE;
1255 smsLog( pMac, LOGE, "rrmReady failed\n");
1256 break;
1257 }
1258#endif
1259 }
1260 pMac->sme.state = SME_STATE_READY;
1261 } while( 0 );
1262
1263 return status;
1264}
1265
1266/*--------------------------------------------------------------------------
1267
1268 \brief sme_Start() - Put all SME modules at ready state.
1269
1270 The function starts each module in SME, PMC, CCM, CSR, etc. . Upon
1271 successfully return, all modules are ready to run.
1272 This is a synchronuous call
1273 \param hHal - The handle returned by macOpen.
1274
1275 \return eHAL_STATUS_SUCCESS - SME is ready.
1276
1277 Other status means SME is failed to start
1278 \sa
1279
1280 --------------------------------------------------------------------------*/
1281eHalStatus sme_Start(tHalHandle hHal)
1282{
1283 eHalStatus status = eHAL_STATUS_FAILURE;
1284 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1285
1286 do
1287 {
1288#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
1289 ccmStart(hHal);
1290#endif
1291 status = csrStart(pMac);
1292 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1293 smsLog( pMac, LOGE, "csrStart failed during smeStart with status=%d\n",
1294 status );
1295 break;
1296 }
1297
1298 status = pmcStart(hHal);
1299 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1300 smsLog( pMac, LOGE, "pmcStart failed during smeStart with status=%d\n",
1301 status );
1302 break;
1303 }
1304
1305#ifdef WLAN_SOFTAP_FEATURE
1306 status = WLANSAP_Start(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1307 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1308 smsLog( pMac, LOGE, "WLANSAP_Start failed during smeStart with status=%d\n",
1309 status );
1310 break;
1311 }
1312#endif
1313 pMac->sme.state = SME_STATE_START;
1314 }while (0);
1315
1316 return status;
1317}
1318
1319
1320#ifdef WLAN_FEATURE_PACKET_FILTERING
1321/******************************************************************************
1322*
1323* Name: sme_PCFilterMatchCountResponseHandler
1324*
1325* Description:
1326* Invoke Packet Coalescing Filter Match Count callback routine
1327*
1328* Parameters:
1329* hHal - HAL handle for device
1330* pMsg - Pointer to tRcvFltPktMatchRsp structure
1331*
1332* Returns: eHalStatus
1333*
1334******************************************************************************/
1335eHalStatus sme_PCFilterMatchCountResponseHandler(tHalHandle hHal, void* pMsg)
1336{
1337 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1338 eHalStatus status = eHAL_STATUS_SUCCESS;
1339 tpSirRcvFltPktMatchRsp pRcvFltPktMatchRsp = (tpSirRcvFltPktMatchRsp)pMsg;
1340
1341 if (NULL == pMsg)
1342 {
1343 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __FUNCTION__);
1344 status = eHAL_STATUS_FAILURE;
1345 }
1346 else
1347 {
1348 smsLog(pMac, LOG2, "SME: entering "
1349 "sme_FilterMatchCountResponseHandler\n");
1350
1351 /* Call Packet Coalescing Filter Match Count callback routine. */
1352 if (pMac->pmc.FilterMatchCountCB != NULL)
1353 pMac->pmc.FilterMatchCountCB(pMac->pmc.FilterMatchCountCBContext,
1354 pRcvFltPktMatchRsp);
1355
1356 smsLog(pMac, LOG1, "%s: status=0x%x", __FUNCTION__,
1357 pRcvFltPktMatchRsp->status);
1358
1359 pMac->pmc.FilterMatchCountCB = NULL;
1360 pMac->pmc.FilterMatchCountCBContext = NULL;
1361 }
1362
1363 return(status);
1364}
1365#endif // WLAN_FEATURE_PACKET_FILTERING
1366
1367
1368/*--------------------------------------------------------------------------
1369
1370 \brief sme_ProcessMsg() - The main message processor for SME.
1371
1372 The function is called by a message dispatcher when to process a message
1373 targeted for SME.
1374
1375 This is a synchronuous call
1376 \param hHal - The handle returned by macOpen.
1377 \param pMsg - A pointer to a caller allocated object of tSirMsgQ.
1378
1379 \return eHAL_STATUS_SUCCESS - SME successfully process the message.
1380
1381 Other status means SME failed to process the message to HAL.
1382 \sa
1383
1384 --------------------------------------------------------------------------*/
1385eHalStatus sme_ProcessMsg(tHalHandle hHal, vos_msg_t* pMsg)
1386{
1387 eHalStatus status = eHAL_STATUS_FAILURE;
1388 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1389
1390 if (pMsg == NULL) {
1391 smsLog( pMac, LOGE, "Empty message for SME, nothing to process\n");
1392 return status;
1393 }
1394
1395 status = sme_AcquireGlobalLock( &pMac->sme );
1396 if ( HAL_STATUS_SUCCESS( status ) )
1397 {
1398 if( SME_IS_START(pMac) )
1399 {
1400 switch (pMsg->type) { // TODO: Will be modified to do a range check for msgs instead of having cases for each msgs
1401 case eWNI_PMC_ENTER_BMPS_RSP:
1402 case eWNI_PMC_EXIT_BMPS_RSP:
1403 case eWNI_PMC_EXIT_BMPS_IND:
1404 case eWNI_PMC_ENTER_IMPS_RSP:
1405 case eWNI_PMC_EXIT_IMPS_RSP:
1406 case eWNI_PMC_SMPS_STATE_IND:
1407 case eWNI_PMC_ENTER_UAPSD_RSP:
1408 case eWNI_PMC_EXIT_UAPSD_RSP:
1409 case eWNI_PMC_ENTER_WOWL_RSP:
1410 case eWNI_PMC_EXIT_WOWL_RSP:
1411 //PMC
1412 if (pMsg->bodyptr)
1413 {
1414 pmcMessageProcessor(hHal, pMsg->bodyptr);
1415 status = eHAL_STATUS_SUCCESS;
1416 vos_mem_free( pMsg->bodyptr );
1417 } else {
1418 smsLog( pMac, LOGE, "Empty rsp message for PMC, nothing to process\n");
1419 }
1420 break;
1421
1422 case WNI_CFG_SET_CNF:
1423 case WNI_CFG_DNLD_CNF:
1424 case WNI_CFG_GET_RSP:
1425 case WNI_CFG_ADD_GRP_ADDR_CNF:
1426 case WNI_CFG_DEL_GRP_ADDR_CNF:
1427 //CCM
1428 if (pMsg->bodyptr)
1429 {
1430 ccmCfgCnfMsgHandler(hHal, pMsg->bodyptr);
1431 status = eHAL_STATUS_SUCCESS;
1432 vos_mem_free( pMsg->bodyptr );
1433 } else {
1434 smsLog( pMac, LOGE, "Empty rsp message for CCM, nothing to process\n");
1435 }
1436 break;
1437
1438 case eWNI_SME_ADDTS_RSP:
1439 case eWNI_SME_DELTS_RSP:
1440 case eWNI_SME_DELTS_IND:
1441#ifdef WLAN_FEATURE_VOWIFI_11R
1442 case eWNI_SME_FT_AGGR_QOS_RSP:
1443#endif
1444 //QoS
1445 if (pMsg->bodyptr)
1446 {
1447#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1448 status = sme_QosMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
1449 vos_mem_free( pMsg->bodyptr );
1450#endif
1451 } else {
1452 smsLog( pMac, LOGE, "Empty rsp message for QoS, nothing to process\n");
1453 }
1454 break;
1455#if defined WLAN_FEATURE_VOWIFI
1456 case eWNI_SME_NEIGHBOR_REPORT_IND:
1457 case eWNI_SME_BEACON_REPORT_REQ_IND:
1458#if defined WLAN_VOWIFI_DEBUG
1459 smsLog( pMac, LOGE, "Received RRM message. Message Id = %d\n", pMsg->type );
1460#endif
1461 if ( pMsg->bodyptr )
1462 {
1463 status = sme_RrmMsgProcessor( pMac, pMsg->type, pMsg->bodyptr );
1464 vos_mem_free( pMsg->bodyptr );
1465 }
1466 else
1467 {
1468 smsLog( pMac, LOGE, "Empty message for RRM, nothing to process\n");
1469 }
1470 break;
1471#endif
1472
Jeff Johnsone7245742012-09-05 17:12:55 -07001473#ifdef FEATURE_OEM_DATA_SUPPORT
1474 //Handle the eWNI_SME_OEM_DATA_RSP:
1475 case eWNI_SME_OEM_DATA_RSP:
1476 if(pMsg->bodyptr)
1477 {
1478 status = sme_HandleOemDataRsp(pMac, pMsg->bodyptr);
1479 vos_mem_free(pMsg->bodyptr);
1480 }
1481 else
1482 {
1483 smsLog( pMac, LOGE, "Empty rsp message for oemData_ (eWNI_SME_OEM_DATA_RSP), nothing to process\n");
1484 }
1485 smeProcessPendingQueue( pMac );
1486 break;
1487#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001488
1489 case eWNI_SME_ADD_STA_SELF_RSP:
1490 if(pMsg->bodyptr)
1491 {
1492 status = csrProcessAddStaSessionRsp(pMac, pMsg->bodyptr);
1493 vos_mem_free(pMsg->bodyptr);
1494 }
1495 else
1496 {
1497 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ADD_STA_SELF_RSP), nothing to process\n");
1498 }
1499 break;
1500 case eWNI_SME_DEL_STA_SELF_RSP:
1501 if(pMsg->bodyptr)
1502 {
1503 status = csrProcessDelStaSessionRsp(pMac, pMsg->bodyptr);
1504 vos_mem_free(pMsg->bodyptr);
1505 }
1506 else
1507 {
1508 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_DEL_STA_SELF_RSP), nothing to process\n");
1509 }
1510 break;
1511#ifdef WLAN_FEATURE_P2P
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 case eWNI_SME_REMAIN_ON_CHN_RSP:
1513 if(pMsg->bodyptr)
1514 {
1515 status = sme_remainOnChnRsp(pMac, pMsg->bodyptr);
1516 vos_mem_free(pMsg->bodyptr);
1517 }
1518 else
1519 {
1520 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RSP), nothing to process\n");
1521 }
1522 break;
1523 case eWNI_SME_REMAIN_ON_CHN_RDY_IND:
1524 if(pMsg->bodyptr)
1525 {
1526 status = sme_remainOnChnReady(pMac, pMsg->bodyptr);
1527 vos_mem_free(pMsg->bodyptr);
1528 }
1529 else
1530 {
1531 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RDY_IND), nothing to process\n");
1532 }
1533 break;
1534 case eWNI_SME_MGMT_FRM_IND:
1535 if(pMsg->bodyptr)
1536 {
1537 sme_mgmtFrmInd(pMac, pMsg->bodyptr);
1538 vos_mem_free(pMsg->bodyptr);
1539 }
1540 else
1541 {
1542 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_MGMT_FRM_IND), nothing to process\n");
1543 }
1544 break;
1545 case eWNI_SME_ACTION_FRAME_SEND_CNF:
1546 if(pMsg->bodyptr)
1547 {
1548 status = sme_sendActionCnf(pMac, pMsg->bodyptr);
1549 vos_mem_free(pMsg->bodyptr);
1550 }
1551 else
1552 {
1553 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ACTION_FRAME_SEND_CNF), nothing to process\n");
1554 }
1555 break;
1556#endif
1557 case eWNI_SME_COEX_IND:
1558 if(pMsg->bodyptr)
1559 {
1560 status = btcHandleCoexInd((void *)pMac, pMsg->bodyptr);
1561 vos_mem_free(pMsg->bodyptr);
1562 }
1563 else
1564 {
1565 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process\n");
1566 }
1567 break;
1568
1569#ifdef FEATURE_WLAN_SCAN_PNO
1570 case eWNI_SME_PREF_NETWORK_FOUND_IND:
1571 if(pMsg->bodyptr)
1572 {
1573 status = sme_PreferredNetworkFoundInd((void *)pMac, pMsg->bodyptr);
1574 vos_mem_free(pMsg->bodyptr);
1575 }
1576 else
1577 {
1578 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_PREF_NETWORK_FOUND_IND), nothing to process\n");
1579 }
1580 break;
1581#endif // FEATURE_WLAN_SCAN_PNO
1582
1583 case eWNI_SME_TX_PER_HIT_IND:
1584 if (pMac->sme.pTxPerHitCallback)
1585 {
1586 pMac->sme.pTxPerHitCallback(pMac->sme.pTxPerHitCbContext);
1587 }
1588 break;
1589
1590 case eWNI_SME_CHANGE_COUNTRY_CODE:
1591 if(pMsg->bodyptr)
1592 {
1593 status = sme_HandleChangeCountryCode((void *)pMac, pMsg->bodyptr);
1594 vos_mem_free(pMsg->bodyptr);
1595 }
1596 else
1597 {
1598 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process\n");
1599 }
1600 break;
1601
1602#ifdef WLAN_FEATURE_PACKET_FILTERING
1603 case eWNI_PMC_PACKET_COALESCING_FILTER_MATCH_COUNT_RSP:
1604 if(pMsg->bodyptr)
1605 {
1606 status = sme_PCFilterMatchCountResponseHandler((void *)pMac, pMsg->bodyptr);
1607 vos_mem_free(pMsg->bodyptr);
1608 }
1609 else
1610 {
1611 smsLog(pMac, LOGE, "Empty rsp message for meas "
1612 "(PACKET_COALESCING_FILTER_MATCH_COUNT_RSP), nothing to process\n");
1613 }
1614 break;
1615#endif // WLAN_FEATURE_PACKET_FILTERING
1616 case eWNI_SME_PRE_SWITCH_CHL_IND:
1617 {
1618 status = sme_HandlePreChannelSwitchInd(pMac);
1619 break;
1620 }
1621
1622 case eWNI_SME_POST_SWITCH_CHL_IND:
1623 {
1624 status = sme_HandlePostChannelSwitchInd(pMac);
1625 break;
1626 }
1627
1628#ifdef WLAN_WAKEUP_EVENTS
1629 case eWNI_SME_WAKE_REASON_IND:
1630 if(pMsg->bodyptr)
1631 {
1632 status = sme_WakeReasonIndCallback((void *)pMac, pMsg->bodyptr);
1633 vos_mem_free(pMsg->bodyptr);
1634 }
1635 else
1636 {
1637 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_WAKE_REASON_IND), nothing to process\n");
1638 }
1639 break;
1640#endif // WLAN_WAKEUP_EVENTS
1641
1642 default:
1643
1644 if ( ( pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN )
1645 && ( pMsg->type <= eWNI_SME_MSG_TYPES_END ) )
1646 {
1647 //CSR
1648 if (pMsg->bodyptr)
1649 {
1650 status = csrMsgProcessor(hHal, pMsg->bodyptr);
1651 vos_mem_free( pMsg->bodyptr );
1652 }
1653 else
1654 {
1655 smsLog( pMac, LOGE, "Empty rsp message for CSR, nothing to process\n");
1656 }
1657 }
1658 else
1659 {
1660 smsLog( pMac, LOGW, "Unknown message type %d, nothing to process\n",
1661 pMsg->type);
1662 if (pMsg->bodyptr)
1663 {
1664 vos_mem_free( pMsg->bodyptr );
1665 }
1666 }
1667 }//switch
1668 } //SME_IS_START
1669 else
1670 {
1671 smsLog( pMac, LOGW, "message type %d in stop state ignored\n", pMsg->type);
1672 if (pMsg->bodyptr)
1673 {
1674 vos_mem_free( pMsg->bodyptr );
1675 }
1676 }
1677 sme_ReleaseGlobalLock( &pMac->sme );
1678 }
1679 else
1680 {
1681 smsLog( pMac, LOGW, "Locking failed, bailing out\n");
1682 if (pMsg->bodyptr)
1683 {
1684 vos_mem_free( pMsg->bodyptr );
1685 }
1686 }
1687
1688 return status;
1689}
1690
1691
1692//No need to hold the global lock here because this function can only be called
1693//after sme_Stop.
1694v_VOID_t sme_FreeMsg( tHalHandle hHal, vos_msg_t* pMsg )
1695{
1696 if( pMsg )
1697 {
1698 if (pMsg->bodyptr)
1699 {
1700 vos_mem_free( pMsg->bodyptr );
1701 }
1702 }
1703
1704}
1705
1706
1707/*--------------------------------------------------------------------------
1708
1709 \brief sme_Stop() - Stop all SME modules and put them at idle state
1710
1711 The function stops each module in SME, PMC, CCM, CSR, etc. . Upon
1712 return, all modules are at idle state ready to start.
1713
1714 This is a synchronuous call
1715 \param hHal - The handle returned by macOpen
1716
1717 \return eHAL_STATUS_SUCCESS - SME is stopped.
1718
1719 Other status means SME is failed to stop but caller should still
1720 consider SME is stopped.
1721 \sa
1722
1723 --------------------------------------------------------------------------*/
1724eHalStatus sme_Stop(tHalHandle hHal, tANI_BOOLEAN pmcFlag)
1725{
1726 eHalStatus status = eHAL_STATUS_FAILURE;
1727 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
1728 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1729
1730#ifdef WLAN_SOFTAP_FEATURE
1731 status = WLANSAP_Stop(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1732 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1733 smsLog( pMac, LOGE, "WLANSAP_Stop failed during smeStop with status=%d\n",
1734 status );
1735 fail_status = status;
1736 }
1737#endif
1738
1739 p2pStop(hHal);
1740
1741 if(pmcFlag)
1742 {
1743 status = pmcStop(hHal);
1744 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1745 smsLog( pMac, LOGE, "pmcStop failed during smeStop with status=%d\n",
1746 status );
1747 fail_status = status;
1748 }
1749 }
1750
1751 status = csrStop(pMac);
1752 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1753 smsLog( pMac, LOGE, "csrStop failed during smeStop with status=%d\n",
1754 status );
1755 fail_status = status;
1756 }
1757
1758 ccmStop(hHal);
1759
1760 purgeSmeCmdList(pMac);
1761
1762 if (!HAL_STATUS_SUCCESS( fail_status )) {
1763 status = fail_status;
1764 }
1765
1766 pMac->sme.state = SME_STATE_STOP;
1767
1768 return status;
1769}
1770
1771/*--------------------------------------------------------------------------
1772
1773 \brief sme_Close() - Release all SME modules and their resources.
1774
1775 The function release each module in SME, PMC, CCM, CSR, etc. . Upon
1776 return, all modules are at closed state.
1777
1778 No SME APIs can be involved after smeClose except smeOpen.
1779 smeClose must be called before macClose.
1780 This is a synchronuous call
1781 \param hHal - The handle returned by macOpen
1782
1783 \return eHAL_STATUS_SUCCESS - SME is successfully close.
1784
1785 Other status means SME is failed to be closed but caller still cannot
1786 call any other SME functions except smeOpen.
1787 \sa
1788
1789 --------------------------------------------------------------------------*/
1790eHalStatus sme_Close(tHalHandle hHal)
1791{
1792 eHalStatus status = eHAL_STATUS_FAILURE;
1793 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
1794 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1795
1796 status = csrClose(pMac);
1797 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1798 smsLog( pMac, LOGE, "csrClose failed during sme close with status=%d\n",
1799 status );
1800 fail_status = status;
1801 }
1802
1803#ifdef WLAN_SOFTAP_FEATURE
1804 status = WLANSAP_Close(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1805 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1806 smsLog( pMac, LOGE, "WLANSAP_close failed during sme close with status=%d\n",
1807 status );
1808 fail_status = status;
1809 }
1810#endif
1811
1812#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1813 status = btcClose(hHal);
1814 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1815 smsLog( pMac, LOGE, "BTC close failed during sme close with status=%d\n",
1816 status );
1817 fail_status = status;
1818 }
1819
1820 status = sme_QosClose(pMac);
1821 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1822 smsLog( pMac, LOGE, "Qos close failed during sme close with status=%d\n",
1823 status );
1824 fail_status = status;
1825 }
1826#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001827#ifdef FEATURE_OEM_DATA_SUPPORT
1828 status = oemData_OemDataReqClose(hHal);
1829 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1830 smsLog( pMac, LOGE, "OEM DATA REQ close failed during sme close with status=%d\n",
1831 status );
1832 fail_status = status;
1833 }
1834#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001835
1836 status = ccmClose(hHal);
1837 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1838 smsLog( pMac, LOGE, "ccmClose failed during sme close with status=%d\n",
1839 status );
1840 fail_status = status;
1841 }
1842
1843 status = pmcClose(hHal);
1844 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1845 smsLog( pMac, LOGE, "pmcClose failed during sme close with status=%d\n",
1846 status );
1847 fail_status = status;
1848 }
1849#if defined WLAN_FEATURE_VOWIFI
1850 status = rrmClose(hHal);
1851 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1852 smsLog( pMac, LOGE, "RRM close failed during sme close with status=%d\n",
1853 status );
1854 fail_status = status;
1855 }
1856#endif
1857
1858#if defined WLAN_FEATURE_VOWIFI_11R
1859 sme_FTClose(hHal);
1860#endif
1861#if defined WLAN_FEATURE_P2P
1862 sme_p2pClose(hHal);
1863#endif
1864
1865 freeSmeCmdList(pMac);
1866
1867 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->sme.lkSmeGlobalLock ) ) )
1868 {
1869 fail_status = eHAL_STATUS_FAILURE;
1870 }
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}
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001880#ifdef FEATURE_WLAN_LFR
1881tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac)
1882{
1883 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
1884 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1885 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
1886 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
1887 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
1888 return eANI_BOOLEAN_FALSE;
1889 default:
1890 return eANI_BOOLEAN_TRUE;
1891 }
1892}
1893#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001894/* ---------------------------------------------------------------------------
1895 \fn sme_ScanRequest
1896 \brief a wrapper function to Request a 11d or full scan from CSR.
1897 This is an asynchronuous call
1898 \param pScanRequestID - pointer to an object to get back the request ID
1899 \param callback - a callback function that scan calls upon finish, will not
1900 be called if csrScanRequest returns error
1901 \param pContext - a pointer passed in for the callback
1902 \return eHalStatus
1903 ---------------------------------------------------------------------------*/
1904eHalStatus sme_ScanRequest(tHalHandle hHal, tANI_U8 sessionId, tCsrScanRequest *pscanReq,
1905 tANI_U32 *pScanRequestID,
1906 csrScanCompleteCallback callback, void *pContext)
1907{
1908 eHalStatus status = eHAL_STATUS_FAILURE;
1909 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1910
1911 smsLog(pMac, LOG2, FL("enter"));
1912 do
1913 {
1914 if(pMac->scan.fScanEnable)
1915 {
1916 status = sme_AcquireGlobalLock( &pMac->sme );
1917 if ( HAL_STATUS_SUCCESS( status ) )
1918 {
1919 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001920#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07001921 if(csrIsScanAllowed(pMac)) {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001922#endif
1923 status = csrScanRequest( hHal, sessionId, pscanReq,
1924 pScanRequestID, callback, pContext );
1925#ifdef FEATURE_WLAN_LFR
1926 } else {
1927 /*HandOff is in progress. So schedule this scan later*/
1928 status = eHAL_STATUS_RESOURCES;
1929 }
1930#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 }
1932
1933 sme_ReleaseGlobalLock( &pMac->sme );
1934 } //sme_AcquireGlobalLock success
1935 } //if(pMac->scan.fScanEnable)
1936 } while( 0 );
1937
1938 return (status);
1939
1940
1941}
1942
1943/* ---------------------------------------------------------------------------
1944 \fn sme_ScanGetResult
1945 \brief a wrapper function to request scan results from CSR.
1946 This is a synchronuous call
1947 \param pFilter - If pFilter is NULL, all cached results are returned
1948 \param phResult - an object for the result.
1949 \return eHalStatus
1950 ---------------------------------------------------------------------------*/
1951eHalStatus sme_ScanGetResult(tHalHandle hHal, tANI_U8 sessionId, tCsrScanResultFilter *pFilter,
1952 tScanResultHandle *phResult)
1953{
1954 eHalStatus status = eHAL_STATUS_FAILURE;
1955 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1956
1957 smsLog(pMac, LOG2, FL("enter"));
1958 status = sme_AcquireGlobalLock( &pMac->sme );
1959 if ( HAL_STATUS_SUCCESS( status ) )
1960 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07001961 status = csrScanGetResult( hHal, pFilter, phResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 sme_ReleaseGlobalLock( &pMac->sme );
1963 }
1964 smsLog(pMac, LOG2, FL("exit status %d"), status);
1965
1966 return (status);
1967}
1968
1969
1970/* ---------------------------------------------------------------------------
1971 \fn sme_ScanFlushResult
1972 \brief a wrapper function to request CSR to clear scan results.
1973 This is a synchronuous call
1974 \return eHalStatus
1975 ---------------------------------------------------------------------------*/
1976eHalStatus sme_ScanFlushResult(tHalHandle hHal, tANI_U8 sessionId)
1977{
1978 eHalStatus status = eHAL_STATUS_FAILURE;
1979 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1980
1981 status = sme_AcquireGlobalLock( &pMac->sme );
1982 if ( HAL_STATUS_SUCCESS( status ) )
1983 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07001984 status = csrScanFlushResult( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 sme_ReleaseGlobalLock( &pMac->sme );
1986 }
1987
1988 return (status);
1989}
1990
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07001991eHalStatus sme_ScanFlushP2PResult(tHalHandle hHal, tANI_U8 sessionId)
1992{
1993 eHalStatus status = eHAL_STATUS_FAILURE;
1994 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1995
1996 status = sme_AcquireGlobalLock( &pMac->sme );
1997 if ( HAL_STATUS_SUCCESS( status ) )
1998 {
1999 status = csrScanFlushP2PResult( hHal );
2000 sme_ReleaseGlobalLock( &pMac->sme );
2001 }
2002
2003 return (status);
2004}
Jeff Johnson295189b2012-06-20 16:38:30 -07002005
2006/* ---------------------------------------------------------------------------
2007 \fn sme_ScanResultGetFirst
2008 \brief a wrapper function to request CSR to returns the first element of
2009 scan result.
2010 This is a synchronuous call
2011 \param hScanResult - returned from csrScanGetResult
2012 \return tCsrScanResultInfo * - NULL if no result
2013 ---------------------------------------------------------------------------*/
2014tCsrScanResultInfo *sme_ScanResultGetFirst(tHalHandle hHal,
2015 tScanResultHandle hScanResult)
2016{
2017 eHalStatus status = eHAL_STATUS_FAILURE;
2018 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2019 tCsrScanResultInfo *pRet = NULL;
2020
2021 status = sme_AcquireGlobalLock( &pMac->sme );
2022 if ( HAL_STATUS_SUCCESS( status ) )
2023 {
2024 pRet = csrScanResultGetFirst( pMac, hScanResult );
2025 sme_ReleaseGlobalLock( &pMac->sme );
2026 }
2027
2028 return (pRet);
2029}
2030
2031
2032/* ---------------------------------------------------------------------------
2033 \fn sme_ScanResultGetNext
2034 \brief a wrapper function to request CSR to returns the next element of
2035 scan result. It can be called without calling csrScanResultGetFirst
2036 first
2037 This is a synchronuous call
2038 \param hScanResult - returned from csrScanGetResult
2039 \return Null if no result or reach the end
2040 ---------------------------------------------------------------------------*/
2041tCsrScanResultInfo *sme_ScanResultGetNext(tHalHandle hHal,
2042 tScanResultHandle hScanResult)
2043{
2044 eHalStatus status = eHAL_STATUS_FAILURE;
2045 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2046 tCsrScanResultInfo *pRet = NULL;
2047
2048 status = sme_AcquireGlobalLock( &pMac->sme );
2049 if ( HAL_STATUS_SUCCESS( status ) )
2050 {
2051 pRet = csrScanResultGetNext( pMac, hScanResult );
2052 sme_ReleaseGlobalLock( &pMac->sme );
2053 }
2054
2055 return (pRet);
2056}
2057
2058
2059/* ---------------------------------------------------------------------------
2060 \fn sme_ScanSetBGScanparams
2061 \brief a wrapper function to request CSR to set BG scan params in PE
2062 This is a synchronuous call
2063 \param pScanReq - BG scan request structure
2064 \return eHalStatus
2065 ---------------------------------------------------------------------------*/
2066eHalStatus sme_ScanSetBGScanparams(tHalHandle hHal, tANI_U8 sessionId, tCsrBGScanRequest *pScanReq)
2067{
2068 eHalStatus status = eHAL_STATUS_FAILURE;
2069 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2070
2071 if( NULL != pScanReq )
2072 {
2073 status = sme_AcquireGlobalLock( &pMac->sme );
2074 if ( HAL_STATUS_SUCCESS( status ) )
2075 {
2076 status = csrScanSetBGScanparams( hHal, pScanReq );
2077 sme_ReleaseGlobalLock( &pMac->sme );
2078 }
2079 }
2080
2081 return (status);
2082}
2083
2084
2085/* ---------------------------------------------------------------------------
2086 \fn sme_ScanResultPurge
2087 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
2088 in the list and free memory for each item
2089 This is a synchronuous call
2090 \param hScanResult - returned from csrScanGetResult. hScanResult is
2091 considered gone by
2092 calling this function and even before this function reutrns.
2093 \return eHalStatus
2094 ---------------------------------------------------------------------------*/
2095eHalStatus sme_ScanResultPurge(tHalHandle hHal, tScanResultHandle hScanResult)
2096{
2097 eHalStatus status = eHAL_STATUS_FAILURE;
2098 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2099
2100 status = sme_AcquireGlobalLock( &pMac->sme );
2101 if ( HAL_STATUS_SUCCESS( status ) )
2102 {
2103 status = csrScanResultPurge( hHal, hScanResult );
2104 sme_ReleaseGlobalLock( &pMac->sme );
2105 }
2106
2107 return (status);
2108}
2109
2110/* ---------------------------------------------------------------------------
2111 \fn sme_ScanGetPMKIDCandidateList
2112 \brief a wrapper function to return the PMKID candidate list
2113 This is a synchronuous call
2114 \param pPmkidList - caller allocated buffer point to an array of
2115 tPmkidCandidateInfo
2116 \param pNumItems - pointer to a variable that has the number of
2117 tPmkidCandidateInfo allocated when retruning, this is
2118 either the number needed or number of items put into
2119 pPmkidList
2120 \return eHalStatus - when fail, it usually means the buffer allocated is not
2121 big enough and pNumItems
2122 has the number of tPmkidCandidateInfo.
2123 \Note: pNumItems is a number of tPmkidCandidateInfo,
2124 not sizeof(tPmkidCandidateInfo) * something
2125 ---------------------------------------------------------------------------*/
2126eHalStatus sme_ScanGetPMKIDCandidateList(tHalHandle hHal, tANI_U8 sessionId,
2127 tPmkidCandidateInfo *pPmkidList,
2128 tANI_U32 *pNumItems )
2129{
2130 eHalStatus status = eHAL_STATUS_FAILURE;
2131 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2132
2133 status = sme_AcquireGlobalLock( &pMac->sme );
2134 if ( HAL_STATUS_SUCCESS( status ) )
2135 {
2136 status = csrScanGetPMKIDCandidateList( pMac, sessionId, pPmkidList, pNumItems );
2137 sme_ReleaseGlobalLock( &pMac->sme );
2138 }
2139
2140 return (status);
2141}
2142
2143/*----------------------------------------------------------------------------
2144 \fn sme_RoamRegisterLinkQualityIndCallback
2145
2146 \brief
2147 a wrapper function to allow HDD to register a callback handler with CSR for
2148 link quality indications.
2149
2150 Only one callback may be registered at any time.
2151 In order to deregister the callback, a NULL cback may be provided.
2152
2153 Registration happens in the task context of the caller.
2154
2155 \param callback - Call back being registered
2156 \param pContext - user data
2157
2158 DEPENDENCIES: After CSR open
2159
2160 \return eHalStatus
2161-----------------------------------------------------------------------------*/
2162eHalStatus sme_RoamRegisterLinkQualityIndCallback(tHalHandle hHal, tANI_U8 sessionId,
2163 csrRoamLinkQualityIndCallback callback,
2164 void *pContext)
2165{
2166 return(csrRoamRegisterLinkQualityIndCallback((tpAniSirGlobal)hHal, callback, pContext));
2167}
2168
2169/* ---------------------------------------------------------------------------
2170 \fn sme_RoamRegisterCallback
2171 \brief a wrapper function to allow HDD to register a callback with CSR.
2172 Unlike scan, roam has one callback for all the roam requests
2173 \param callback - a callback function that roam calls upon when state changes
2174 \param pContext - a pointer passed in for the callback
2175 \return eHalStatus
2176 ---------------------------------------------------------------------------*/
2177eHalStatus sme_RoamRegisterCallback(tHalHandle hHal,
2178 csrRoamCompleteCallback callback,
2179 void *pContext)
2180{
2181 return(csrRoamRegisterCallback((tpAniSirGlobal)hHal, callback, pContext));
2182}
2183
2184eCsrPhyMode sme_GetPhyMode(tHalHandle hHal)
2185{
2186 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2187 return pMac->roam.configParam.phyMode;
2188}
2189
2190/* ---------------------------------------------------------------------------
2191 \fn sme_RoamConnect
2192 \brief a wrapper function to request CSR to inititiate an association
2193 This is an asynchronuous call.
2194 \param sessionId - the sessionId returned by sme_OpenSession.
2195 \param pProfile - description of the network to which to connect
2196 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
2197 from csrScanGetResult
2198 \param pRoamId - to get back the request ID
2199 \return eHalStatus
2200 ---------------------------------------------------------------------------*/
2201eHalStatus sme_RoamConnect(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2202 tANI_U32 *pRoamId)
2203{
2204 eHalStatus status = eHAL_STATUS_FAILURE;
2205 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2206
2207 smsLog(pMac, LOG2, FL("enter"));
2208 status = sme_AcquireGlobalLock( &pMac->sme );
2209 if ( HAL_STATUS_SUCCESS( status ) )
2210 {
2211 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2212 {
2213 status = csrRoamConnect( pMac, sessionId, pProfile, NULL, pRoamId );
2214 }
2215 else
2216 {
2217 status = eHAL_STATUS_INVALID_PARAMETER;
2218 }
2219 sme_ReleaseGlobalLock( &pMac->sme );
2220 }
2221
2222 return (status);
2223}
2224
2225/* ---------------------------------------------------------------------------
2226 \fn sme_RoamReassoc
2227 \brief a wrapper function to request CSR to inititiate a re-association
2228 \param pProfile - can be NULL to join the currently connected AP. In that
2229 case modProfileFields should carry the modified field(s) which could trigger
2230 reassoc
2231 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
2232 that might need modification dynamically once STA is up & running and this
2233 could trigger a reassoc
2234 \param pRoamId - to get back the request ID
2235 \return eHalStatus
2236 -------------------------------------------------------------------------------*/
2237eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2238 tCsrRoamModifyProfileFields modProfileFields,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002239 tANI_U32 *pRoamId, v_BOOL_t fForce)
Jeff Johnson295189b2012-06-20 16:38:30 -07002240{
2241 eHalStatus status = eHAL_STATUS_FAILURE;
2242 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2243
2244 smsLog(pMac, LOG2, FL("enter"));
2245 status = sme_AcquireGlobalLock( &pMac->sme );
2246 if ( HAL_STATUS_SUCCESS( status ) )
2247 {
2248 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2249 {
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07002250 if((NULL == pProfile) && (fForce == 1))
2251 {
2252 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2253 /* to force the AP initiate fresh 802.1x authentication need to clear
2254 * the PMKID cache for that set the following boolean. this is needed
2255 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
2256 pSession->fIgnorePMKIDCache = TRUE;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002257 status = csrReassoc( pMac, sessionId, &modProfileFields, pRoamId , fForce);
2258 }
2259 else
2260 {
2261 status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
2262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 }
2264 else
2265 {
2266 status = eHAL_STATUS_INVALID_PARAMETER;
2267 }
2268 sme_ReleaseGlobalLock( &pMac->sme );
2269 }
2270
2271 return (status);
2272}
2273
2274/* ---------------------------------------------------------------------------
2275 \fn sme_RoamConnectToLastProfile
2276 \brief a wrapper function to request CSR to disconnect and reconnect with
2277 the same profile
2278 This is an asynchronuous call.
2279 \return eHalStatus. It returns fail if currently connected
2280 ---------------------------------------------------------------------------*/
2281eHalStatus sme_RoamConnectToLastProfile(tHalHandle hHal, tANI_U8 sessionId)
2282{
2283 eHalStatus status = eHAL_STATUS_FAILURE;
2284 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2285
2286 status = sme_AcquireGlobalLock( &pMac->sme );
2287 if ( HAL_STATUS_SUCCESS( status ) )
2288 {
2289 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2290 {
2291 status = csrRoamConnectToLastProfile( pMac, sessionId );
2292 }
2293 else
2294 {
2295 status = eHAL_STATUS_INVALID_PARAMETER;
2296 }
2297 sme_ReleaseGlobalLock( &pMac->sme );
2298 }
2299
2300 return (status);
2301}
2302
2303/* ---------------------------------------------------------------------------
2304 \fn sme_RoamDisconnect
2305 \brief a wrapper function to request CSR to disconnect from a network
2306 This is an asynchronuous call.
2307 \param reason -- To indicate the reason for disconnecting. Currently, only
2308 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
2309 \return eHalStatus
2310 ---------------------------------------------------------------------------*/
2311eHalStatus sme_RoamDisconnect(tHalHandle hHal, tANI_U8 sessionId, eCsrRoamDisconnectReason reason)
2312{
2313 eHalStatus status = eHAL_STATUS_FAILURE;
2314 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2315
2316 smsLog(pMac, LOG2, FL("enter"));
2317 status = sme_AcquireGlobalLock( &pMac->sme );
2318 if ( HAL_STATUS_SUCCESS( status ) )
2319 {
2320 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2321 {
2322 status = csrRoamDisconnect( pMac, sessionId, reason );
2323 }
2324 else
2325 {
2326 status = eHAL_STATUS_INVALID_PARAMETER;
2327 }
2328 sme_ReleaseGlobalLock( &pMac->sme );
2329 }
2330
2331 return (status);
2332}
2333
2334#ifdef WLAN_SOFTAP_FEATURE
2335/* ---------------------------------------------------------------------------
2336 \fn sme_RoamStopBss
2337 \brief To stop BSS for Soft AP. This is an asynchronous API.
2338 \param hHal - Global structure
2339 \param sessionId - sessionId of SoftAP
2340 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2341 -------------------------------------------------------------------------------*/
2342eHalStatus sme_RoamStopBss(tHalHandle hHal, tANI_U8 sessionId)
2343{
2344 eHalStatus status = eHAL_STATUS_FAILURE;
2345 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2346
2347 smsLog(pMac, LOG2, FL("enter"));
2348 status = sme_AcquireGlobalLock( &pMac->sme );
2349 if ( HAL_STATUS_SUCCESS( status ) )
2350 {
2351 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2352 {
2353 status = csrRoamIssueStopBssCmd( pMac, sessionId, eANI_BOOLEAN_TRUE );
2354 }
2355 else
2356 {
2357 status = eHAL_STATUS_INVALID_PARAMETER;
2358 }
2359 sme_ReleaseGlobalLock( &pMac->sme );
2360 }
2361
2362 return (status);
2363}
2364
2365/* ---------------------------------------------------------------------------
2366 \fn sme_RoamDisconnectSta
2367 \brief To disassociate a station. This is an asynchronous API.
2368 \param hHal - Global structure
2369 \param sessionId - sessionId of SoftAP
2370 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2371 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2372 -------------------------------------------------------------------------------*/
2373eHalStatus sme_RoamDisconnectSta(tHalHandle hHal, tANI_U8 sessionId,
2374 tANI_U8 *pPeerMacAddr)
2375{
2376 eHalStatus status = eHAL_STATUS_FAILURE;
2377 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2378
2379 if ( NULL == pMac )
2380 {
2381 VOS_ASSERT(0);
2382 return status;
2383 }
2384
2385 status = sme_AcquireGlobalLock( &pMac->sme );
2386 if ( HAL_STATUS_SUCCESS( status ) )
2387 {
2388 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2389 {
2390 status = csrRoamIssueDisassociateStaCmd( pMac, sessionId, pPeerMacAddr,
2391 eSIR_MAC_UNSPEC_FAILURE_REASON);
2392 }
2393 else
2394 {
2395 status = eHAL_STATUS_INVALID_PARAMETER;
2396 }
2397 sme_ReleaseGlobalLock( &pMac->sme );
2398 }
2399
2400 return (status);
2401}
2402
2403/* ---------------------------------------------------------------------------
2404 \fn sme_RoamDeauthSta
2405 \brief To disassociate a station. This is an asynchronous API.
2406 \param hHal - Global structure
2407 \param sessionId - sessionId of SoftAP
2408 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2409 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2410 -------------------------------------------------------------------------------*/
2411eHalStatus sme_RoamDeauthSta(tHalHandle hHal, tANI_U8 sessionId,
2412 tANI_U8 *pPeerMacAddr)
2413{
2414 eHalStatus status = eHAL_STATUS_FAILURE;
2415 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2416
2417 if ( NULL == pMac )
2418 {
2419 VOS_ASSERT(0);
2420 return status;
2421 }
2422
2423 status = sme_AcquireGlobalLock( &pMac->sme );
2424 if ( HAL_STATUS_SUCCESS( status ) )
2425 {
2426 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2427 {
2428 status = csrRoamIssueDeauthStaCmd( pMac, sessionId, pPeerMacAddr,
2429 eSIR_MAC_UNSPEC_FAILURE_REASON);
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_RoamTKIPCounterMeasures
2443 \brief To start or stop TKIP counter measures. This is an asynchronous API.
2444 \param sessionId - sessionId of SoftAP
2445 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2446 \return eHalStatus
2447 -------------------------------------------------------------------------------*/
2448eHalStatus sme_RoamTKIPCounterMeasures(tHalHandle hHal, tANI_U8 sessionId,
2449 tANI_BOOLEAN bEnable)
2450{
2451 eHalStatus status = eHAL_STATUS_FAILURE;
2452 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2453
2454 if ( NULL == pMac )
2455 {
2456 VOS_ASSERT(0);
2457 return status;
2458 }
2459
2460 status = sme_AcquireGlobalLock( &pMac->sme );
2461 if ( HAL_STATUS_SUCCESS( status ) )
2462 {
2463 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2464 {
2465 status = csrRoamIssueTkipCounterMeasures( pMac, sessionId, bEnable);
2466 }
2467 else
2468 {
2469 status = eHAL_STATUS_INVALID_PARAMETER;
2470 }
2471 sme_ReleaseGlobalLock( &pMac->sme );
2472 }
2473
2474 return (status);
2475}
2476
2477/* ---------------------------------------------------------------------------
2478 \fn sme_RoamGetAssociatedStas
2479 \brief To probe the list of associated stations from various modules of CORE stack.
2480 \This is an asynchronous API.
2481 \param sessionId - sessionId of SoftAP
2482 \param modId - Module from whom list of associtated stations is to be probed.
2483 If an invalid module is passed then by default VOS_MODULE_ID_PE will be probed
2484 \param pUsrContext - Opaque HDD context
2485 \param pfnSapEventCallback - Sap event callback in HDD
2486 \param pAssocBuf - Caller allocated memory to be filled with associatd stations info
2487 \return eHalStatus
2488 -------------------------------------------------------------------------------*/
2489eHalStatus sme_RoamGetAssociatedStas(tHalHandle hHal, tANI_U8 sessionId,
2490 VOS_MODULE_ID modId, void *pUsrContext,
2491 void *pfnSapEventCallback, tANI_U8 *pAssocStasBuf)
2492{
2493 eHalStatus status = eHAL_STATUS_FAILURE;
2494 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2495
2496 if ( NULL == pMac )
2497 {
2498 VOS_ASSERT(0);
2499 return status;
2500 }
2501
2502 status = sme_AcquireGlobalLock( &pMac->sme );
2503 if ( HAL_STATUS_SUCCESS( status ) )
2504 {
2505 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2506 {
2507 status = csrRoamGetAssociatedStas( pMac, sessionId, modId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2508 }
2509 else
2510 {
2511 status = eHAL_STATUS_INVALID_PARAMETER;
2512 }
2513 sme_ReleaseGlobalLock( &pMac->sme );
2514 }
2515
2516 return (status);
2517}
2518
2519/* ---------------------------------------------------------------------------
2520 \fn sme_RoamGetWpsSessionOverlap
2521 \brief To get the WPS PBC session overlap information.
2522 \This is an asynchronous API.
2523 \param sessionId - sessionId of SoftAP
2524 \param pUsrContext - Opaque HDD context
2525 \param pfnSapEventCallback - Sap event callback in HDD
2526 \pRemoveMac - pointer to Mac address which needs to be removed from session
2527 \return eHalStatus
2528 -------------------------------------------------------------------------------*/
2529eHalStatus sme_RoamGetWpsSessionOverlap(tHalHandle hHal, tANI_U8 sessionId,
2530 void *pUsrContext, void
2531 *pfnSapEventCallback, v_MACADDR_t pRemoveMac)
2532{
2533 eHalStatus status = eHAL_STATUS_FAILURE;
2534 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2535
2536 if ( NULL == pMac )
2537 {
2538 VOS_ASSERT(0);
2539 return status;
2540 }
2541
2542 status = sme_AcquireGlobalLock( &pMac->sme );
2543 if ( HAL_STATUS_SUCCESS( status ) )
2544 {
2545 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2546 {
2547 status = csrRoamGetWpsSessionOverlap( pMac, sessionId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2548 }
2549 else
2550 {
2551 status = eHAL_STATUS_INVALID_PARAMETER;
2552 }
2553 sme_ReleaseGlobalLock( &pMac->sme );
2554 }
2555
2556 return (status);
2557}
2558
2559#endif
2560
2561/* ---------------------------------------------------------------------------
2562 \fn sme_RoamGetConnectState
2563 \brief a wrapper function to request CSR to return the current connect state
2564 of Roaming
2565 This is a synchronuous call.
2566 \return eHalStatus
2567 ---------------------------------------------------------------------------*/
2568eHalStatus sme_RoamGetConnectState(tHalHandle hHal, tANI_U8 sessionId, eCsrConnectState *pState)
2569{
2570 eHalStatus status = eHAL_STATUS_FAILURE;
2571 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2572
2573 status = sme_AcquireGlobalLock( &pMac->sme );
2574 if ( HAL_STATUS_SUCCESS( status ) )
2575 {
2576 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2577 {
2578 status = csrRoamGetConnectState( pMac, sessionId, pState );
2579 }
2580 else
2581 {
2582 status = eHAL_STATUS_INVALID_PARAMETER;
2583 }
2584 sme_ReleaseGlobalLock( &pMac->sme );
2585 }
2586
2587 return (status);
2588}
2589
2590/* ---------------------------------------------------------------------------
2591 \fn sme_RoamGetConnectProfile
2592 \brief a wrapper function to request CSR to return the current connect
2593 profile. Caller must call csrRoamFreeConnectProfile after it is done
2594 and before reuse for another csrRoamGetConnectProfile call.
2595 This is a synchronuous call.
2596 \param pProfile - pointer to a caller allocated structure
2597 tCsrRoamConnectedProfile
2598 \return eHalStatus. Failure if not connected
2599 ---------------------------------------------------------------------------*/
2600eHalStatus sme_RoamGetConnectProfile(tHalHandle hHal, tANI_U8 sessionId,
2601 tCsrRoamConnectedProfile *pProfile)
2602{
2603 eHalStatus status = eHAL_STATUS_FAILURE;
2604 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2605
2606 status = sme_AcquireGlobalLock( &pMac->sme );
2607 if ( HAL_STATUS_SUCCESS( status ) )
2608 {
2609 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2610 {
2611 status = csrRoamGetConnectProfile( pMac, sessionId, pProfile );
2612 }
2613 else
2614 {
2615 status = eHAL_STATUS_INVALID_PARAMETER;
2616 }
2617 sme_ReleaseGlobalLock( &pMac->sme );
2618 }
2619
2620 return (status);
2621}
2622
2623/* ---------------------------------------------------------------------------
2624 \fn sme_RoamFreeConnectProfile
2625 \brief a wrapper function to request CSR to free and reinitialize the
2626 profile returned previously by csrRoamGetConnectProfile.
2627 This is a synchronuous call.
2628 \param pProfile - pointer to a caller allocated structure
2629 tCsrRoamConnectedProfile
2630 \return eHalStatus.
2631 ---------------------------------------------------------------------------*/
2632eHalStatus sme_RoamFreeConnectProfile(tHalHandle hHal,
2633 tCsrRoamConnectedProfile *pProfile)
2634{
2635 eHalStatus status = eHAL_STATUS_FAILURE;
2636 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2637
2638 status = sme_AcquireGlobalLock( &pMac->sme );
2639 if ( HAL_STATUS_SUCCESS( status ) )
2640 {
2641 status = csrRoamFreeConnectProfile( pMac, pProfile );
2642 sme_ReleaseGlobalLock( &pMac->sme );
2643 }
2644
2645 return (status);
2646}
2647
2648/* ---------------------------------------------------------------------------
2649 \fn sme_RoamSetPMKIDCache
2650 \brief a wrapper function to request CSR to return the PMKID candidate list
2651 This is a synchronuous call.
2652 \param pPMKIDCache - caller allocated buffer point to an array of
2653 tPmkidCacheInfo
2654 \param numItems - a variable that has the number of tPmkidCacheInfo
2655 allocated when retruning, this is either the number needed
2656 or number of items put into pPMKIDCache
2657 \return eHalStatus - when fail, it usually means the buffer allocated is not
2658 big enough and pNumItems has the number of
2659 tPmkidCacheInfo.
2660 \Note: pNumItems is a number of tPmkidCacheInfo,
2661 not sizeof(tPmkidCacheInfo) * something
2662 ---------------------------------------------------------------------------*/
2663eHalStatus sme_RoamSetPMKIDCache( tHalHandle hHal, tANI_U8 sessionId, tPmkidCacheInfo *pPMKIDCache,
2664 tANI_U32 numItems )
2665{
2666 eHalStatus status = eHAL_STATUS_FAILURE;
2667 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2668
2669 status = sme_AcquireGlobalLock( &pMac->sme );
2670 if ( HAL_STATUS_SUCCESS( status ) )
2671 {
2672 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2673 {
2674 status = csrRoamSetPMKIDCache( pMac, sessionId, pPMKIDCache, numItems );
2675 }
2676 else
2677 {
2678 status = eHAL_STATUS_INVALID_PARAMETER;
2679 }
2680 sme_ReleaseGlobalLock( &pMac->sme );
2681 }
2682
2683 return (status);
2684}
2685
2686/* ---------------------------------------------------------------------------
2687 \fn sme_RoamGetSecurityReqIE
2688 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
2689 passes to PE to JOIN request or START_BSS request
2690 This is a synchronuous call.
2691 \param pLen - caller allocated memory that has the length of pBuf as input.
2692 Upon returned, *pLen has the needed or IE length in pBuf.
2693 \param pBuf - Caller allocated memory that contain the IE field, if any,
2694 upon return
2695 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
2696 \return eHalStatus - when fail, it usually means the buffer allocated is not
2697 big enough
2698 ---------------------------------------------------------------------------*/
2699eHalStatus sme_RoamGetSecurityReqIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
2700 tANI_U8 *pBuf, eCsrSecurityType secType)
2701{
2702 eHalStatus status = eHAL_STATUS_FAILURE;
2703 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2704
2705 status = sme_AcquireGlobalLock( &pMac->sme );
2706 if ( HAL_STATUS_SUCCESS( status ) )
2707 {
2708 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2709 {
2710 status = csrRoamGetWpaRsnReqIE( hHal, sessionId, pLen, pBuf );
2711 }
2712 else
2713 {
2714 status = eHAL_STATUS_INVALID_PARAMETER;
2715 }
2716 sme_ReleaseGlobalLock( &pMac->sme );
2717 }
2718
2719 return (status);
2720}
2721
2722/* ---------------------------------------------------------------------------
2723 \fn sme_RoamGetSecurityRspIE
2724 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE from
2725 the beacon or probe rsp if connected
2726 This is a synchronuous call.
2727 \param pLen - caller allocated memory that has the length of pBuf as input.
2728 Upon returned, *pLen has the needed or IE length in pBuf.
2729 \param pBuf - Caller allocated memory that contain the IE field, if any,
2730 upon return
2731 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
2732 \return eHalStatus - when fail, it usually means the buffer allocated is not
2733 big enough
2734 ---------------------------------------------------------------------------*/
2735eHalStatus sme_RoamGetSecurityRspIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
2736 tANI_U8 *pBuf, eCsrSecurityType secType)
2737{
2738 eHalStatus status = eHAL_STATUS_FAILURE;
2739 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2740
2741 status = sme_AcquireGlobalLock( &pMac->sme );
2742 if ( HAL_STATUS_SUCCESS( status ) )
2743 {
2744 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2745 {
2746 status = csrRoamGetWpaRsnRspIE( pMac, sessionId, pLen, pBuf );
2747 }
2748 else
2749 {
2750 status = eHAL_STATUS_INVALID_PARAMETER;
2751 }
2752 sme_ReleaseGlobalLock( &pMac->sme );
2753 }
2754
2755 return (status);
2756
2757}
2758
2759
2760/* ---------------------------------------------------------------------------
2761 \fn sme_RoamGetNumPMKIDCache
2762 \brief a wrapper function to request CSR to return number of PMKID cache
2763 entries
2764 This is a synchronuous call.
2765 \return tANI_U32 - the number of PMKID cache entries
2766 ---------------------------------------------------------------------------*/
2767tANI_U32 sme_RoamGetNumPMKIDCache(tHalHandle hHal, tANI_U8 sessionId)
2768{
2769 eHalStatus status = eHAL_STATUS_FAILURE;
2770 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2771 tANI_U32 numPmkidCache = 0;
2772
2773 status = sme_AcquireGlobalLock( &pMac->sme );
2774 if ( HAL_STATUS_SUCCESS( status ) )
2775 {
2776 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2777 {
2778 numPmkidCache = csrRoamGetNumPMKIDCache( pMac, sessionId );
2779 status = eHAL_STATUS_SUCCESS;
2780 }
2781 else
2782 {
2783 status = eHAL_STATUS_INVALID_PARAMETER;
2784 }
2785 sme_ReleaseGlobalLock( &pMac->sme );
2786 }
2787
2788 return (numPmkidCache);
2789}
2790
2791/* ---------------------------------------------------------------------------
2792 \fn sme_RoamGetPMKIDCache
2793 \brief a wrapper function to request CSR to return PMKID cache from CSR
2794 This is a synchronuous call.
2795 \param pNum - caller allocated memory that has the space of the number of
2796 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
2797 needed or actually number in tPmkidCacheInfo.
2798 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
2799 any, upon return
2800 \return eHalStatus - when fail, it usually means the buffer allocated is not
2801 big enough
2802 ---------------------------------------------------------------------------*/
2803eHalStatus sme_RoamGetPMKIDCache(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pNum,
2804 tPmkidCacheInfo *pPmkidCache)
2805{
2806 eHalStatus status = eHAL_STATUS_FAILURE;
2807 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2808
2809 status = sme_AcquireGlobalLock( &pMac->sme );
2810 if ( HAL_STATUS_SUCCESS( status ) )
2811 {
2812 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2813 {
2814 status = csrRoamGetPMKIDCache( pMac, sessionId, pNum, pPmkidCache );
2815 }
2816 else
2817 {
2818 status = eHAL_STATUS_INVALID_PARAMETER;
2819 }
2820 sme_ReleaseGlobalLock( &pMac->sme );
2821 }
2822
2823 return (status);
2824}
2825
2826
2827/* ---------------------------------------------------------------------------
2828 \fn sme_GetConfigParam
2829 \brief a wrapper function that HDD calls to get the global settings
2830 currently maintained by CSR.
2831 This is a synchronuous call.
2832 \param pParam - caller allocated memory
2833 \return eHalStatus
2834 ---------------------------------------------------------------------------*/
2835eHalStatus sme_GetConfigParam(tHalHandle hHal, tSmeConfigParams *pParam)
2836{
2837 eHalStatus status = eHAL_STATUS_FAILURE;
2838 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2839
2840 status = sme_AcquireGlobalLock( &pMac->sme );
2841 if ( HAL_STATUS_SUCCESS( status ) )
2842 {
2843 status = csrGetConfigParam(pMac, &pParam->csrConfig);
2844 if (status != eHAL_STATUS_SUCCESS)
2845 {
2846 smsLog( pMac, LOGE, "%s csrGetConfigParam failed\n", __FUNCTION__);
2847 sme_ReleaseGlobalLock( &pMac->sme );
2848 return status;
2849 }
2850#if defined WLAN_FEATURE_P2P_INTERNAL
2851 status = p2pGetConfigParam(pMac, &pParam->p2pConfig);
2852 if (status != eHAL_STATUS_SUCCESS)
2853 {
2854 smsLog( pMac, LOGE, "%s p2pGetConfigParam failed\n", __FUNCTION__);
2855 sme_ReleaseGlobalLock( &pMac->sme );
2856 return status;
2857 }
2858#endif
2859 sme_ReleaseGlobalLock( &pMac->sme );
2860 }
2861
2862 return (status);
2863}
2864
2865/* ---------------------------------------------------------------------------
2866 \fn sme_CfgSetInt
2867 \brief a wrapper function that HDD calls to set parameters in CFG.
2868 This is a synchronuous call.
2869 \param cfgId - Configuration Parameter ID (type) for STA.
2870 \param ccmValue - The information related to Configuration Parameter ID
2871 which needs to be saved in CFG
2872 \param callback - To be registered by CSR with CCM. Once the CFG done with
2873 saving the information in the database, it notifies CCM &
2874 then the callback will be invoked to notify.
2875 \param toBeSaved - To save the request for future reference
2876 \return eHalStatus
2877 ---------------------------------------------------------------------------*/
2878eHalStatus sme_CfgSetInt(tHalHandle hHal, tANI_U32 cfgId, tANI_U32 ccmValue,
2879 tCcmCfgSetCallback callback, eAniBoolean toBeSaved)
2880{
2881 return(ccmCfgSetInt(hHal, cfgId, ccmValue, callback, toBeSaved));
2882}
2883
2884/* ---------------------------------------------------------------------------
2885 \fn sme_CfgSetStr
2886 \brief a wrapper function that HDD calls to set parameters in CFG.
2887 This is a synchronuous call.
2888 \param cfgId - Configuration Parameter ID (type) for STA.
2889 \param pStr - Pointer to the byte array which carries the information needs
2890 to be saved in CFG
2891 \param length - Length of the data to be saved
2892 \param callback - To be registered by CSR with CCM. Once the CFG done with
2893 saving the information in the database, it notifies CCM &
2894 then the callback will be invoked to notify.
2895 \param toBeSaved - To save the request for future reference
2896 \return eHalStatus
2897 ---------------------------------------------------------------------------*/
2898eHalStatus sme_CfgSetStr(tHalHandle hHal, tANI_U32 cfgId, tANI_U8 *pStr,
2899 tANI_U32 length, tCcmCfgSetCallback callback,
2900 eAniBoolean toBeSaved)
2901{
2902 return(ccmCfgSetStr(hHal, cfgId, pStr, length, callback, toBeSaved));
2903}
2904
2905/* ---------------------------------------------------------------------------
2906 \fn sme_GetModifyProfileFields
2907 \brief HDD or SME - QOS calls this function to get the current values of
2908 connected profile fields, changing which can cause reassoc.
2909 This function must be called after CFG is downloaded and STA is in connected
2910 state. Also, make sure to call this function to get the current profile
2911 fields before calling the reassoc. So that pModifyProfileFields will have
2912 all the latest values plus the one(s) has been updated as part of reassoc
2913 request.
2914 \param pModifyProfileFields - pointer to the connected profile fields
2915 changing which can cause reassoc
2916
2917 \return eHalStatus
2918 -------------------------------------------------------------------------------*/
2919eHalStatus sme_GetModifyProfileFields(tHalHandle hHal, tANI_U8 sessionId,
2920 tCsrRoamModifyProfileFields * pModifyProfileFields)
2921{
2922 eHalStatus status = eHAL_STATUS_FAILURE;
2923 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2924
2925 status = sme_AcquireGlobalLock( &pMac->sme );
2926 if ( HAL_STATUS_SUCCESS( status ) )
2927 {
2928 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2929 {
2930 status = csrGetModifyProfileFields(pMac, sessionId, pModifyProfileFields);
2931 }
2932 else
2933 {
2934 status = eHAL_STATUS_INVALID_PARAMETER;
2935 }
2936 sme_ReleaseGlobalLock( &pMac->sme );
2937 }
2938
2939 return (status);
2940}
2941
2942/*--------------------------------------------------------------------------
2943 \fn sme_SetConfigPowerSave
2944 \brief Wrapper fn to change power save configuration in SME (PMC) module.
2945 For BMPS related configuration, this function also updates the CFG
2946 and sends a message to FW to pick up the new values. Note: Calling
2947 this function only updates the configuration and does not enable
2948 the specified power save mode.
2949 \param hHal - The handle returned by macOpen.
2950 \param psMode - Power Saving mode being modified
2951 \param pConfigParams - a pointer to a caller allocated object of type
2952 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
2953 \return eHalStatus
2954 --------------------------------------------------------------------------*/
2955eHalStatus sme_SetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
2956 void *pConfigParams)
2957{
2958 eHalStatus status = eHAL_STATUS_FAILURE;
2959 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2960
2961 if (NULL == pConfigParams ) {
2962 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
2963 "nothing to update");
2964 return eHAL_STATUS_FAILURE;
2965 }
2966
2967 status = sme_AcquireGlobalLock( &pMac->sme );
2968 if ( HAL_STATUS_SUCCESS( status ) )
2969 {
2970 status = pmcSetConfigPowerSave(hHal, psMode, pConfigParams);
2971 sme_ReleaseGlobalLock( &pMac->sme );
2972 }
2973
2974 return (status);
2975}
2976
2977/*--------------------------------------------------------------------------
2978 \fn sme_GetConfigPowerSave
2979 \brief Wrapper fn to retrieve power save configuration in SME (PMC) module
2980 \param hHal - The handle returned by macOpen.
2981 \param psMode - Power Saving mode
2982 \param pConfigParams - a pointer to a caller allocated object of type
2983 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
2984 \return eHalStatus
2985 --------------------------------------------------------------------------*/
2986eHalStatus sme_GetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
2987 void *pConfigParams)
2988{
2989 eHalStatus status = eHAL_STATUS_FAILURE;
2990 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2991
2992 if (NULL == pConfigParams ) {
2993 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
2994 "nothing to update");
2995 return eHAL_STATUS_FAILURE;
2996 }
2997
2998 status = sme_AcquireGlobalLock( &pMac->sme );
2999 if ( HAL_STATUS_SUCCESS( status ) )
3000 {
3001 status = pmcGetConfigPowerSave(hHal, psMode, pConfigParams);
3002 sme_ReleaseGlobalLock( &pMac->sme );
3003 }
3004
3005 return (status);
3006}
3007
3008/* ---------------------------------------------------------------------------
3009 \fn sme_SignalPowerEvent
3010 \brief Signals to PMC that a power event has occurred. Used for putting
3011 the chip into deep sleep mode.
3012 \param hHal - The handle returned by macOpen.
3013 \param event - the event that has occurred
3014 \return eHalStatus
3015 ---------------------------------------------------------------------------*/
3016eHalStatus sme_SignalPowerEvent (tHalHandle hHal, tPmcPowerEvent event)
3017{
3018 eHalStatus status = eHAL_STATUS_FAILURE;
3019 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3020
3021 status = sme_AcquireGlobalLock( &pMac->sme );
3022 if ( HAL_STATUS_SUCCESS( status ) )
3023 {
3024 status = pmcSignalPowerEvent(hHal, event);
3025 sme_ReleaseGlobalLock( &pMac->sme );
3026 }
3027
3028 return (status);
3029}
3030
3031/* ---------------------------------------------------------------------------
3032 \fn sme_EnablePowerSave
3033 \brief Enables one of the power saving modes.
3034 \param hHal - The handle returned by macOpen.
3035 \param psMode - The power saving mode to enable. If BMPS mode is enabled
3036 while the chip is operating in Full Power, PMC will start
3037 a timer that will try to put the chip in BMPS mode after
3038 expiry.
3039 \return eHalStatus
3040 ---------------------------------------------------------------------------*/
3041eHalStatus sme_EnablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3042{
3043 eHalStatus status = eHAL_STATUS_FAILURE;
3044 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3045
3046 status = sme_AcquireGlobalLock( &pMac->sme );
3047 if ( HAL_STATUS_SUCCESS( status ) )
3048 {
3049 status = pmcEnablePowerSave(hHal, psMode);
3050 sme_ReleaseGlobalLock( &pMac->sme );
3051 }
3052
3053 return (status);
3054}
3055
3056/* ---------------------------------------------------------------------------
3057 \fn sme_DisablePowerSave
3058 \brief Disables one of the power saving modes.
3059 \param hHal - The handle returned by macOpen.
3060 \param psMode - The power saving mode to disable. Disabling does not imply
3061 that device will be brought out of the current PS mode. This
3062 is purely a configuration API.
3063 \return eHalStatus
3064 ---------------------------------------------------------------------------*/
3065eHalStatus sme_DisablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3066{
3067 eHalStatus status = eHAL_STATUS_FAILURE;
3068 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3069
3070 status = sme_AcquireGlobalLock( &pMac->sme );
3071 if ( HAL_STATUS_SUCCESS( status ) )
3072 {
3073 status = pmcDisablePowerSave(hHal, psMode);
3074 sme_ReleaseGlobalLock( &pMac->sme );
3075 }
3076
3077 return (status);
3078 }
3079
3080/* ---------------------------------------------------------------------------
3081 \fn sme_StartAutoBmpsTimer
3082 \brief Starts a timer that periodically polls all the registered
3083 module for entry into Bmps mode. This timer is started only if BMPS is
3084 enabled and whenever the device is in full power.
3085 \param hHal - The handle returned by macOpen.
3086 \return eHalStatus
3087 ---------------------------------------------------------------------------*/
3088eHalStatus sme_StartAutoBmpsTimer ( tHalHandle hHal)
3089{
3090 eHalStatus status = eHAL_STATUS_FAILURE;
3091 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3092
3093 status = sme_AcquireGlobalLock( &pMac->sme );
3094 if ( HAL_STATUS_SUCCESS( status ) )
3095 {
3096 status = pmcStartAutoBmpsTimer(hHal);
3097 sme_ReleaseGlobalLock( &pMac->sme );
3098 }
3099
3100 return (status);
3101}
3102/* ---------------------------------------------------------------------------
3103 \fn sme_StopAutoBmpsTimer
3104 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
3105 Stopping the timer does not cause a device state change. Only the timer
3106 is stopped. If "Full Power" is desired, use the sme_RequestFullPower API
3107 \param hHal - The handle returned by macOpen.
3108 \return eHalStatus
3109 ---------------------------------------------------------------------------*/
3110eHalStatus sme_StopAutoBmpsTimer ( tHalHandle hHal)
3111{
3112 eHalStatus status = eHAL_STATUS_FAILURE;
3113 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3114
3115 status = sme_AcquireGlobalLock( &pMac->sme );
3116 if ( HAL_STATUS_SUCCESS( status ) )
3117 {
3118 status = pmcStopAutoBmpsTimer(hHal);
3119 sme_ReleaseGlobalLock( &pMac->sme );
3120 }
3121
3122 return (status);
3123}
3124/* ---------------------------------------------------------------------------
3125 \fn sme_QueryPowerState
3126 \brief Returns the current power state of the device.
3127 \param hHal - The handle returned by macOpen.
3128 \param pPowerState - pointer to location to return power state (LOW or HIGH)
3129 \param pSwWlanSwitchState - ptr to location to return SW WLAN Switch state
3130 \return eHalStatus
3131 ---------------------------------------------------------------------------*/
3132eHalStatus sme_QueryPowerState (
3133 tHalHandle hHal,
3134 tPmcPowerState *pPowerState,
3135 tPmcSwitchState *pSwWlanSwitchState)
3136{
3137 eHalStatus status = eHAL_STATUS_FAILURE;
3138 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3139
3140 status = sme_AcquireGlobalLock( &pMac->sme );
3141 if ( HAL_STATUS_SUCCESS( status ) )
3142 {
3143 status = pmcQueryPowerState (hHal, pPowerState, NULL, pSwWlanSwitchState);
3144 sme_ReleaseGlobalLock( &pMac->sme );
3145 }
3146
3147 return (status);
3148}
3149
3150/* ---------------------------------------------------------------------------
3151 \fn sme_IsPowerSaveEnabled
3152 \brief Checks if the device is able to enter a particular power save mode
3153 This does not imply that the device is in a particular PS mode
3154 \param hHal - The handle returned by macOpen.
3155 \param psMode - the power saving mode
3156 \return eHalStatus
3157 ---------------------------------------------------------------------------*/
3158tANI_BOOLEAN sme_IsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
3159{
3160 eHalStatus status = eHAL_STATUS_FAILURE;
3161 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3162 tANI_BOOLEAN result = false;
3163
3164 status = sme_AcquireGlobalLock( &pMac->sme );
3165 if ( HAL_STATUS_SUCCESS( status ) )
3166 {
3167 result = pmcIsPowerSaveEnabled(hHal, psMode);
3168 sme_ReleaseGlobalLock( &pMac->sme );
3169 return result;
3170 }
3171
3172 return false;
3173}
3174
3175/* ---------------------------------------------------------------------------
3176 \fn sme_RequestFullPower
3177 \brief Request that the device be brought to full power state. When the
3178 device enters Full Power PMC will start a BMPS timer if BMPS PS mode
3179 is enabled. On timer expiry PMC will attempt to put the device in
3180 BMPS mode if following holds true:
3181 - BMPS mode is enabled
3182 - Polling of all modules through the Power Save Check routine passes
3183 - STA is associated to an access point
3184 \param hHal - The handle returned by macOpen.
3185 \param - callbackRoutine Callback routine invoked in case of success/failure
3186 \return eHalStatus - status
3187 eHAL_STATUS_SUCCESS - device brought to full power state
3188 eHAL_STATUS_FAILURE - device cannot be brought to full power state
3189 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
3190 ---------------------------------------------------------------------------*/
3191eHalStatus sme_RequestFullPower (
3192 tHalHandle hHal,
3193 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3194 void *callbackContext,
3195 tRequestFullPowerReason fullPowerReason)
3196{
3197 eHalStatus status = eHAL_STATUS_FAILURE;
3198 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3199
3200 status = sme_AcquireGlobalLock( &pMac->sme );
3201 if ( HAL_STATUS_SUCCESS( status ) )
3202 {
3203 status = pmcRequestFullPower(hHal, callbackRoutine, callbackContext, fullPowerReason);
3204 sme_ReleaseGlobalLock( &pMac->sme );
3205 }
3206
3207 return (status);
3208}
3209
3210/* ---------------------------------------------------------------------------
3211 \fn sme_RequestBmps
3212 \brief Request that the device be put in BMPS state. Request will be
3213 accepted only if BMPS mode is enabled and power save check routine
3214 passes.
3215 \param hHal - The handle returned by macOpen.
3216 \param - callbackRoutine Callback routine invoked in case of success/failure
3217 \return eHalStatus
3218 eHAL_STATUS_SUCCESS - device is in BMPS state
3219 eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
3220 eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state
3221 ---------------------------------------------------------------------------*/
3222eHalStatus sme_RequestBmps (
3223 tHalHandle hHal,
3224 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3225 void *callbackContext)
3226{
3227 eHalStatus status = eHAL_STATUS_FAILURE;
3228 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3229
3230 status = sme_AcquireGlobalLock( &pMac->sme );
3231 if ( HAL_STATUS_SUCCESS( status ) )
3232 {
3233 status = pmcRequestBmps(hHal, callbackRoutine, callbackContext);
3234 sme_ReleaseGlobalLock( &pMac->sme );
3235 }
3236
3237 return (status);
3238}
3239
3240
3241/* ---------------------------------------------------------------------------
3242 \fn sme_SetDHCPTillPowerActiveFlag
3243 \brief Sets/Clears DHCP related flag in PMC to disable/enable auto BMPS
3244 entry by PMC
3245 \param hHal - The handle returned by macOpen.
3246 ---------------------------------------------------------------------------*/
3247void sme_SetDHCPTillPowerActiveFlag(tHalHandle hHal, tANI_U8 flag)
3248{
3249 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3250
3251 // Set/Clear the DHCP flag which will disable/enable auto BMPS entery by PMC
3252 pMac->pmc.remainInPowerActiveTillDHCP = flag;
3253}
3254
3255
3256/* ---------------------------------------------------------------------------
3257 \fn sme_StartUapsd
3258 \brief Request that the device be put in UAPSD state. If the device is in
3259 Full Power it will be put in BMPS mode first and then into UAPSD
3260 mode.
3261 \param hHal - The handle returned by macOpen.
3262 \param - callbackRoutine Callback routine invoked in case of success/failure
3263 eHAL_STATUS_SUCCESS - device is in UAPSD state
3264 eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
3265 eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
3266 eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
3267 \return eHalStatus
3268 ---------------------------------------------------------------------------*/
3269eHalStatus sme_StartUapsd (
3270 tHalHandle hHal,
3271 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3272 void *callbackContext)
3273{
3274 eHalStatus status = eHAL_STATUS_FAILURE;
3275 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3276
3277 status = sme_AcquireGlobalLock( &pMac->sme );
3278 if ( HAL_STATUS_SUCCESS( status ) )
3279 {
3280 status = pmcStartUapsd(hHal, callbackRoutine, callbackContext);
3281 sme_ReleaseGlobalLock( &pMac->sme );
3282 }
3283
3284 return (status);
3285 }
3286
3287/* ---------------------------------------------------------------------------
3288 \fn sme_StopUapsd
3289 \brief Request that the device be put out of UAPSD state. Device will be
3290 put in in BMPS state after stop UAPSD completes.
3291 \param hHal - The handle returned by macOpen.
3292 \return eHalStatus
3293 eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
3294 eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
3295 ---------------------------------------------------------------------------*/
3296eHalStatus sme_StopUapsd (tHalHandle hHal)
3297{
3298 eHalStatus status = eHAL_STATUS_FAILURE;
3299 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3300
3301 status = sme_AcquireGlobalLock( &pMac->sme );
3302 if ( HAL_STATUS_SUCCESS( status ) )
3303 {
3304 status = pmcStopUapsd(hHal);
3305 sme_ReleaseGlobalLock( &pMac->sme );
3306 }
3307
3308 return (status);
3309}
3310
3311/* ---------------------------------------------------------------------------
3312 \fn sme_RequestStandby
3313 \brief Request that the device be put in standby. It is HDD's responsibility
3314 to bring the chip to full power and do a disassoc before calling
3315 this API.
3316 \param hHal - The handle returned by macOpen.
3317 \param - callbackRoutine Callback routine invoked in case of success/failure
3318 \return eHalStatus
3319 eHAL_STATUS_SUCCESS - device is in Standby mode
3320 eHAL_STATUS_FAILURE - device cannot be put in standby mode
3321 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
3322 ---------------------------------------------------------------------------*/
3323eHalStatus sme_RequestStandby (
3324 tHalHandle hHal,
3325 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3326 void *callbackContext)
3327{
3328 eHalStatus status = eHAL_STATUS_FAILURE;
3329 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3330
3331 smsLog( pMac, LOG1, FL("") );
3332 status = sme_AcquireGlobalLock( &pMac->sme );
3333 if ( HAL_STATUS_SUCCESS( status ) )
3334 {
3335 status = pmcRequestStandby(hHal, callbackRoutine, callbackContext);
3336 sme_ReleaseGlobalLock( &pMac->sme );
3337 }
3338
3339 return (status);
3340}
3341
3342/* ---------------------------------------------------------------------------
3343 \fn sme_RegisterPowerSaveCheck
3344 \brief Register a power save check routine that is called whenever
3345 the device is about to enter one of the power save modes.
3346 \param hHal - The handle returned by macOpen.
3347 \param checkRoutine - Power save check routine to be registered
3348 \return eHalStatus
3349 eHAL_STATUS_SUCCESS - successfully registered
3350 eHAL_STATUS_FAILURE - not successfully registered
3351 ---------------------------------------------------------------------------*/
3352eHalStatus sme_RegisterPowerSaveCheck (
3353 tHalHandle hHal,
3354 tANI_BOOLEAN (*checkRoutine) (void *checkContext), void *checkContext)
3355{
3356 eHalStatus status = eHAL_STATUS_FAILURE;
3357 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3358
3359 status = sme_AcquireGlobalLock( &pMac->sme );
3360 if ( HAL_STATUS_SUCCESS( status ) )
3361 {
3362 status = pmcRegisterPowerSaveCheck (hHal, checkRoutine, checkContext);
3363 sme_ReleaseGlobalLock( &pMac->sme );
3364 }
3365
3366 return (status);
3367}
3368
3369/* ---------------------------------------------------------------------------
3370 \fn sme_DeregisterPowerSaveCheck
3371 \brief Deregister a power save check routine
3372 \param hHal - The handle returned by macOpen.
3373 \param checkRoutine - Power save check routine to be deregistered
3374 \return eHalStatus
3375 eHAL_STATUS_SUCCESS - successfully deregistered
3376 eHAL_STATUS_FAILURE - not successfully deregistered
3377 ---------------------------------------------------------------------------*/
3378eHalStatus sme_DeregisterPowerSaveCheck (
3379 tHalHandle hHal,
3380 tANI_BOOLEAN (*checkRoutine) (void *checkContext))
3381{
3382 eHalStatus status = eHAL_STATUS_FAILURE;
3383 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3384
3385 status = sme_AcquireGlobalLock( &pMac->sme );
3386 if ( HAL_STATUS_SUCCESS( status ) )
3387 {
3388 status = pmcDeregisterPowerSaveCheck (hHal, checkRoutine);
3389 sme_ReleaseGlobalLock( &pMac->sme );
3390 }
3391
3392 return (status);
3393}
3394
3395/* ---------------------------------------------------------------------------
3396 \fn sme_RegisterDeviceStateUpdateInd
3397 \brief Register a callback routine that is called whenever
3398 the device enters a new device state (Full Power, BMPS, UAPSD)
3399 \param hHal - The handle returned by macOpen.
3400 \param callbackRoutine - Callback routine to be registered
3401 \param callbackContext - Cookie to be passed back during callback
3402 \return eHalStatus
3403 eHAL_STATUS_SUCCESS - successfully registered
3404 eHAL_STATUS_FAILURE - not successfully registered
3405 ---------------------------------------------------------------------------*/
3406eHalStatus sme_RegisterDeviceStateUpdateInd (
3407 tHalHandle hHal,
3408 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
3409 void *callbackContext)
3410{
3411 eHalStatus status = eHAL_STATUS_FAILURE;
3412 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3413
3414 status = sme_AcquireGlobalLock( &pMac->sme );
3415 if ( HAL_STATUS_SUCCESS( status ) )
3416 {
3417 status = pmcRegisterDeviceStateUpdateInd (hHal, callbackRoutine, callbackContext);
3418 sme_ReleaseGlobalLock( &pMac->sme );
3419 }
3420
3421 return (status);
3422}
3423
3424/* ---------------------------------------------------------------------------
3425 \fn sme_DeregisterDeviceStateUpdateInd
3426 \brief Deregister a routine that was registered for device state changes
3427 \param hHal - The handle returned by macOpen.
3428 \param callbackRoutine - Callback routine to be deregistered
3429 \return eHalStatus
3430 eHAL_STATUS_SUCCESS - successfully deregistered
3431 eHAL_STATUS_FAILURE - not successfully deregistered
3432 ---------------------------------------------------------------------------*/
3433eHalStatus sme_DeregisterDeviceStateUpdateInd (
3434 tHalHandle hHal,
3435 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
3436{
3437 eHalStatus status = eHAL_STATUS_FAILURE;
3438 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3439
3440 status = sme_AcquireGlobalLock( &pMac->sme );
3441 if ( HAL_STATUS_SUCCESS( status ) )
3442 {
3443 status = pmcDeregisterDeviceStateUpdateInd (hHal, callbackRoutine);
3444 sme_ReleaseGlobalLock( &pMac->sme );
3445 }
3446
3447 return (status);
3448}
3449
3450/* ---------------------------------------------------------------------------
3451 \fn sme_WowlAddBcastPattern
3452 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
3453 do a pattern match on these patterns when Wowl is enabled during BMPS
3454 mode. Note that Firmware performs the pattern matching only on
3455 broadcast frames and while Libra is in BMPS mode.
3456 \param hHal - The handle returned by macOpen.
3457 \param pattern - Pattern to be added
3458 \return eHalStatus
3459 eHAL_STATUS_FAILURE Cannot add pattern
3460 eHAL_STATUS_SUCCESS Request accepted.
3461 ---------------------------------------------------------------------------*/
3462eHalStatus sme_WowlAddBcastPattern (
3463 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003464 tpSirWowlAddBcastPtrn pattern,
3465 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003466{
3467 eHalStatus status = eHAL_STATUS_FAILURE;
3468 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3469 status = sme_AcquireGlobalLock( &pMac->sme );
3470 if ( HAL_STATUS_SUCCESS( status ) )
3471 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003472 status = pmcWowlAddBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 sme_ReleaseGlobalLock( &pMac->sme );
3474 }
3475
3476 return (status);
3477}
3478
3479/* ---------------------------------------------------------------------------
3480 \fn sme_WowlDelBcastPattern
3481 \brief Delete a pattern that was added for Pattern Byte Matching.
3482 \param hHal - The handle returned by macOpen.
3483 \param pattern - Pattern to be deleted
3484 \return eHalStatus
3485 eHAL_STATUS_FAILURE Cannot delete pattern
3486 eHAL_STATUS_SUCCESS Request accepted.
3487 ---------------------------------------------------------------------------*/
3488eHalStatus sme_WowlDelBcastPattern (
3489 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003490 tpSirWowlDelBcastPtrn pattern,
3491 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003492{
3493 eHalStatus status = eHAL_STATUS_FAILURE;
3494 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3495 status = sme_AcquireGlobalLock( &pMac->sme );
3496 if ( HAL_STATUS_SUCCESS( status ) )
3497 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003498 status = pmcWowlDelBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 sme_ReleaseGlobalLock( &pMac->sme );
3500 }
3501
3502 return (status);
3503}
3504
3505/* ---------------------------------------------------------------------------
3506 \fn sme_EnterWowl
3507 \brief This is the SME API exposed to HDD to request enabling of WOWL mode.
3508 WoWLAN works on top of BMPS mode. If the device is not in BMPS mode,
3509 SME will will cache the information that WOWL has been enabled and
3510 attempt to put the device in BMPS. On entry into BMPS, SME will
3511 enable the WOWL mode.
3512 Note 1: If we exit BMPS mode (someone requests full power), we
3513 will NOT resume WOWL when we go back to BMPS again. Request for full
3514 power (while in WOWL mode) means disable WOWL and go to full power.
3515 Note 2: Both UAPSD and WOWL work on top of BMPS. On entry into BMPS, SME
3516 will give priority to UAPSD and enable only UAPSD if both UAPSD and WOWL
3517 are required. Currently there is no requirement or use case to support
3518 UAPSD and WOWL at the same time.
3519
3520 \param hHal - The handle returned by macOpen.
3521 \param enterWowlCallbackRoutine - Callback routine provided by HDD.
3522 Used for success/failure notification by SME
3523 \param enterWowlCallbackContext - A cookie passed by HDD, that is passed back to HDD
3524 at the time of callback.
3525 \param wakeReasonIndCB - Callback routine provided by HDD.
3526 Used for Wake Reason Indication by SME
3527 \param wakeReasonIndCBContext - A cookie passed by HDD, that is passed back to HDD
3528 at the time of callback.
3529 \return eHalStatus
3530 eHAL_STATUS_SUCCESS Device is already in WoWLAN mode
3531 eHAL_STATUS_FAILURE Device cannot enter WoWLAN mode.
3532 eHAL_STATUS_PMC_PENDING Request accepted. SME will enable WOWL after
3533 BMPS mode is entered.
3534 ---------------------------------------------------------------------------*/
3535eHalStatus sme_EnterWowl (
3536 tHalHandle hHal,
3537 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
3538 void *enterWowlCallbackContext,
3539#ifdef WLAN_WAKEUP_EVENTS
3540 void (*wakeIndicationCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
3541 void *wakeIndicationCBContext,
3542#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003543 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003544{
3545 eHalStatus status = eHAL_STATUS_FAILURE;
3546 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3547 status = sme_AcquireGlobalLock( &pMac->sme );
3548 if ( HAL_STATUS_SUCCESS( status ) )
3549 {
3550 status = pmcEnterWowl (hHal, enterWowlCallbackRoutine, enterWowlCallbackContext,
3551#ifdef WLAN_WAKEUP_EVENTS
3552 wakeIndicationCB, wakeIndicationCBContext,
3553#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003554 wowlEnterParams, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 sme_ReleaseGlobalLock( &pMac->sme );
3556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 return (status);
3558}
3559/* ---------------------------------------------------------------------------
3560 \fn sme_ExitWowl
3561 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
3562 SME will initiate exit from WoWLAN mode and device will be put in BMPS
3563 mode.
3564 \param hHal - The handle returned by macOpen.
3565 \return eHalStatus
3566 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
3567 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
3568 ---------------------------------------------------------------------------*/
3569eHalStatus sme_ExitWowl (tHalHandle hHal)
3570{
3571 eHalStatus status = eHAL_STATUS_FAILURE;
3572 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3573 status = sme_AcquireGlobalLock( &pMac->sme );
3574 if ( HAL_STATUS_SUCCESS( status ) )
3575 {
3576 status = pmcExitWowl (hHal);
3577 sme_ReleaseGlobalLock( &pMac->sme );
3578 }
3579
3580 return (status);
3581}
3582
3583/* ---------------------------------------------------------------------------
3584
3585 \fn sme_RoamSetKey
3586
3587 \brief To set encryption key. This function should be called only when connected
3588 This is an asynchronous API.
3589
3590 \param pSetKeyInfo - pointer to a caller allocated object of tCsrSetContextInfo
3591
3592 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3593
3594 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3595
3596 FAILURE or RESOURCES The API finished and failed.
3597
3598 -------------------------------------------------------------------------------*/
3599eHalStatus sme_RoamSetKey(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 *pRoamId)
3600{
3601 eHalStatus status = eHAL_STATUS_FAILURE;
3602 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3603 tANI_U32 roamId;
3604#ifdef WLAN_SOFTAP_FEATURE
3605 tANI_U32 i;
3606 tCsrRoamSession *pSession = NULL;
3607#endif
3608
3609 status = sme_AcquireGlobalLock( &pMac->sme );
3610 if ( HAL_STATUS_SUCCESS( status ) )
3611 {
3612 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3613 if(pRoamId)
3614 {
3615 *pRoamId = roamId;
3616 }
3617
3618#ifdef WLAN_SOFTAP_FEATURE
3619 smsLog(pMac, LOG2, FL("keyLength\n"), pSetKey->keyLength);
3620
3621 for(i=0; i<pSetKey->keyLength; i++)
3622 smsLog(pMac, LOG2, FL("%02x"), pSetKey->Key[i]);
3623
3624 smsLog(pMac, LOG2, "\n sessionId=%d roamId=%d\n", sessionId, roamId);
3625
3626 pSession = CSR_GET_SESSION(pMac, sessionId);
3627
Jeff Johnson32d95a32012-09-10 13:15:23 -07003628 if(!pSession)
3629 {
3630 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3631 return eHAL_STATUS_FAILURE;
3632 }
3633
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
3635 {
3636 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
3637 {
3638 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
3639 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
3640 {
3641 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3642 }
3643 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
3644 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
3645 {
3646 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3647 }
3648 }
3649 }
3650#endif
3651
3652 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
3653 sme_ReleaseGlobalLock( &pMac->sme );
3654 }
3655
3656 return (status);
3657}
3658
3659
3660/* ---------------------------------------------------------------------------
3661
3662 \fn sme_RoamRemoveKey
3663
3664 \brief To set encryption key. This is an asynchronous API.
3665
3666 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
3667
3668 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3669
3670 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3671
3672 FAILURE or RESOURCES The API finished and failed.
3673
3674 -------------------------------------------------------------------------------*/
3675eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
3676 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
3677{
3678 eHalStatus status = eHAL_STATUS_FAILURE;
3679 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3680 tANI_U32 roamId;
3681
3682 status = sme_AcquireGlobalLock( &pMac->sme );
3683 if ( HAL_STATUS_SUCCESS( status ) )
3684 {
3685 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3686 if(pRoamId)
3687 {
3688 *pRoamId = roamId;
3689 }
3690 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
3691 sme_ReleaseGlobalLock( &pMac->sme );
3692 }
3693
3694 return (status);
3695}
3696
3697/* ---------------------------------------------------------------------------
3698 \fn sme_GetRssi
3699 \brief a wrapper function that client calls to register a callback to get RSSI
3700
3701 \param callback - SME sends back the requested stats using the callback
3702 \param staId - The station ID for which the stats is requested for
3703 \param pContext - user context to be passed back along with the callback
3704 \param pVosContext - vos context
3705 \return eHalStatus
3706 ---------------------------------------------------------------------------*/
3707eHalStatus sme_GetRssi(tHalHandle hHal,
3708 tCsrRssiCallback callback,
3709 tANI_U8 staId, tCsrBssid bssId,
3710 void *pContext, void* pVosContext)
3711{
3712 eHalStatus status = eHAL_STATUS_FAILURE;
3713 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3714
3715 status = sme_AcquireGlobalLock( &pMac->sme );
3716 if ( HAL_STATUS_SUCCESS( status ) )
3717 {
3718 status = csrGetRssi( pMac, callback,
3719 staId, bssId, pContext, pVosContext);
3720 sme_ReleaseGlobalLock( &pMac->sme );
3721 }
3722 return (status);
3723}
3724
3725/* ---------------------------------------------------------------------------
3726 \fn sme_GetStatistics
3727 \brief a wrapper function that client calls to register a callback to get
3728 different PHY level statistics from CSR.
3729
3730 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
3731 \param statsMask - The different category/categories of stats requester is looking for
3732 \param callback - SME sends back the requested stats using the callback
3733 \param periodicity - If requester needs periodic update in millisec, 0 means
3734 it's an one time request
3735 \param cache - If requester is happy with cached stats
3736 \param staId - The station ID for which the stats is requested for
3737 \param pContext - user context to be passed back along with the callback
3738 \return eHalStatus
3739 ---------------------------------------------------------------------------*/
3740eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
3741 tANI_U32 statsMask,
3742 tCsrStatsCallback callback,
3743 tANI_U32 periodicity, tANI_BOOLEAN cache,
3744 tANI_U8 staId, void *pContext)
3745{
3746 eHalStatus status = eHAL_STATUS_FAILURE;
3747 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3748
3749 status = sme_AcquireGlobalLock( &pMac->sme );
3750 if ( HAL_STATUS_SUCCESS( status ) )
3751 {
3752 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
3753 periodicity, cache, staId, pContext);
3754 sme_ReleaseGlobalLock( &pMac->sme );
3755 }
3756
3757 return (status);
3758
3759}
3760
3761/* ---------------------------------------------------------------------------
3762
3763 \fn sme_GetCountryCode
3764
3765 \brief To return the current country code. If no country code is applied, default country code is
3766 used to fill the buffer.
3767 If 11d supported is turned off, an error is return and the last applied/default country code is used.
3768 This is a synchronous API.
3769
3770 \param pBuf - pointer to a caller allocated buffer for returned country code.
3771
3772 \param pbLen For input, this parameter indicates how big is the buffer.
3773 Upon return, this parameter has the number of bytes for country. If pBuf
3774 doesn't have enough space, this function returns
3775 fail status and this parameter contains the number that is needed.
3776
3777 \return eHalStatus SUCCESS.
3778
3779 FAILURE or RESOURCES The API finished and failed.
3780
3781 -------------------------------------------------------------------------------*/
3782eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
3783{
3784 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3785
3786 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
3787}
3788
3789
3790/* ---------------------------------------------------------------------------
3791
3792 \fn sme_SetCountryCode
3793
3794 \brief To change the current/default country code.
3795 If 11d supported is turned off, an error is return.
3796 This is a synchronous API.
3797
3798 \param pCountry - pointer to a caller allocated buffer for the country code.
3799
3800 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
3801 whether a reset is required.
3802
3803 \return eHalStatus SUCCESS.
3804
3805 FAILURE or RESOURCES The API finished and failed.
3806
3807 -------------------------------------------------------------------------------*/
3808eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
3809{
3810 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3811
3812 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
3813}
3814
3815
3816/* ---------------------------------------------------------------------------
3817 \fn sme_ResetCountryCodeInformation
3818 \brief this function is to reset the country code current being used back to EEPROM default
3819 this includes channel list and power setting. This is a synchronous API.
3820 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
3821 a restart is needed to apply the change
3822 \return eHalStatus
3823 -------------------------------------------------------------------------------*/
3824eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
3825{
3826 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3827
3828 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
3829}
3830
3831
3832/* ---------------------------------------------------------------------------
3833 \fn sme_GetSupportedCountryCode
3834 \brief this function is to get a list of the country code current being supported
3835 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
3836 this has the country code list. 3 bytes for each country code. This may be NULL if
3837 caller wants to know the needed byte count.
3838 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
3839 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
3840 \return eHalStatus
3841 -------------------------------------------------------------------------------*/
3842eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
3843{
3844 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3845
3846 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
3847}
3848
3849
3850/* ---------------------------------------------------------------------------
3851 \fn sme_GetCurrentRegulatoryDomain
3852 \brief this function is to get the current regulatory domain. This is a synchronous API.
3853 This function must be called after CFG is downloaded and all the band/mode setting already passed into
3854 SME. The function fails if 11d support is turned off.
3855 \param pDomain - Caller allocated buffer to return the current domain.
3856 \return eHalStatus SUCCESS.
3857
3858 FAILURE or RESOURCES The API finished and failed.
3859 -------------------------------------------------------------------------------*/
3860eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
3861{
3862 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3863 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
3864
3865 if( pDomain )
3866 {
3867 if( csrIs11dSupported( pMac ) )
3868 {
3869 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
3870 status = eHAL_STATUS_SUCCESS;
3871 }
3872 else
3873 {
3874 status = eHAL_STATUS_FAILURE;
3875 }
3876 }
3877
3878 return ( status );
3879}
3880
3881
3882/* ---------------------------------------------------------------------------
3883 \fn sme_SetRegulatoryDomain
3884 \brief this function is to set the current regulatory domain.
3885 This function must be called after CFG is downloaded and all the band/mode setting already passed into
3886 SME. This is a synchronous API.
3887 \param domainId - indicate the domain (defined in the driver) needs to set to.
3888 See v_REGDOMAIN_t for definition
3889 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
3890 a restart is needed to apply the change
3891 \return eHalStatus
3892 -------------------------------------------------------------------------------*/
3893eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
3894{
3895 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3896
3897 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
3898}
3899
3900
3901/* ---------------------------------------------------------------------------
3902
3903 \fn sme_GetRegulatoryDomainForCountry
3904
3905 \brief To return a regulatory domain base on a country code. This is a synchronous API.
3906
3907 \param pCountry - pointer to a caller allocated buffer for input country code.
3908
3909 \param pDomainId Upon successful return, it is the domain that country belongs to.
3910 If it is NULL, returning success means that the country code is known.
3911
3912 \return eHalStatus SUCCESS.
3913
3914 FAILURE or RESOURCES The API finished and failed.
3915
3916 -------------------------------------------------------------------------------*/
3917eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
3918{
3919 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3920
3921 return ( csrGetRegulatoryDomainForCountry( pMac, pCountry, pDomainId ) );
3922}
3923
3924
3925
3926
3927/* ---------------------------------------------------------------------------
3928
3929 \fn sme_GetSupportedRegulatoryDomains
3930
3931 \brief To return a list of supported regulatory domains. This is a synchronous API.
3932
3933 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
3934
3935 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
3936 Upon return, this parameter has the number for supported domains. If pDomains
3937 doesn't have enough space for all the supported domains, this function returns
3938 fail status and this parameter contains the number that is needed.
3939
3940 \return eHalStatus SUCCESS.
3941
3942 FAILURE or RESOURCES The API finished and failed.
3943
3944 -------------------------------------------------------------------------------*/
3945eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
3946{
3947 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
3948
3949 //We support all domains for now
3950 if( pNumDomains )
3951 {
3952 if( NUM_REG_DOMAINS <= *pNumDomains )
3953 {
3954 status = eHAL_STATUS_SUCCESS;
3955 }
3956 *pNumDomains = NUM_REG_DOMAINS;
3957 }
3958 if( HAL_STATUS_SUCCESS( status ) )
3959 {
3960 if( pDomains )
3961 {
3962 pDomains[0] = REGDOMAIN_FCC;
3963 pDomains[1] = REGDOMAIN_ETSI;
3964 pDomains[2] = REGDOMAIN_JAPAN;
3965 pDomains[3] = REGDOMAIN_WORLD;
3966 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
3967 pDomains[5] = REGDOMAIN_APAC;
3968 pDomains[6] = REGDOMAIN_KOREA;
3969 pDomains[7] = REGDOMAIN_HI_5GHZ;
3970 pDomains[8] = REGDOMAIN_NO_5GHZ;
3971 }
3972 else
3973 {
3974 status = eHAL_STATUS_INVALID_PARAMETER;
3975 }
3976 }
3977
3978 return ( status );
3979}
3980
3981
3982//some support functions
3983tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
3984{
3985 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3986
3987 return ( csrIs11dSupported( pMac ) );
3988}
3989
3990
3991tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
3992{
3993 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3994
3995 return ( csrIs11hSupported( pMac ) );
3996}
3997
3998
3999tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
4000{
4001 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4002
4003 return ( csrIsWmmSupported( pMac ) );
4004}
4005
4006//Upper layer to get the list of the base channels to scan for passively 11d info from csr
4007eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
4008{
4009 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4010
4011 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
4012}
4013
4014/* ---------------------------------------------------------------------------
4015
4016 \fn sme_ChangeCountryCode
4017
4018 \brief Change Country code from upperlayer during WLAN driver operation.
4019 This is a synchronous API.
4020
4021 \param hHal - The handle returned by macOpen.
4022
4023 \param pCountry New Country Code String
4024
4025 \return eHalStatus SUCCESS.
4026
4027 FAILURE or RESOURCES The API finished and failed.
4028
4029 -------------------------------------------------------------------------------*/
4030eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
4031 tSmeChangeCountryCallback callback,
4032 tANI_U8 *pCountry,
4033 void *pContext,
4034 void* pVosContext )
4035{
4036 eHalStatus status = eHAL_STATUS_FAILURE;
4037 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4038 vos_msg_t msg;
4039 tAniChangeCountryCodeReq *pMsg;
4040
4041 status = sme_AcquireGlobalLock( &pMac->sme );
4042 if ( HAL_STATUS_SUCCESS( status ) )
4043 {
4044 smsLog(pMac, LOG1, FL(" called\n"));
4045 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniChangeCountryCodeReq));
4046 if ( !HAL_STATUS_SUCCESS(status) )
4047 {
4048 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req \n");
4049 return status;
4050 }
4051
4052 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
4053 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
4054 palCopyMemory(pMac->hHdd, pMsg->countryCode, pCountry, 3);
4055 pMsg->changeCCCallback = callback;
4056 pMsg->pDevContext = pContext;
4057 pMsg->pVosContext = pVosContext;
4058
4059 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4060 msg.bodyptr = pMsg;
4061 msg.reserved = 0;
4062
4063 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
4064 {
4065 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self \n");
4066 palFreeMemory(pMac->hHdd, (void *)pMsg);
4067 status = eHAL_STATUS_FAILURE;
4068 }
4069 smsLog(pMac, LOG1, FL(" returned\n"));
4070 sme_ReleaseGlobalLock( &pMac->sme );
4071 }
4072
4073 return (status);
4074}
4075
4076/* ---------------------------------------------------------------------------
4077 \fn sme_BtcSignalBtEvent
4078 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
4079 BT event type and the current operating mode of Libra (full power,
4080 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
4081 would be employed.
4082 \param hHal - The handle returned by macOpen.
4083 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
4084 Caller owns the memory and is responsible for freeing it.
4085 \return VOS_STATUS
4086 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
4087 if BTC execution mode is set to BTC_WLAN_ONLY
4088 or BTC_PTA_ONLY.
4089 VOS_STATUS_SUCCESS BT Event passed to HAL
4090 ---------------------------------------------------------------------------*/
4091VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
4092{
4093 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4094#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4095 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4096
4097 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4098 {
4099 status = btcSignalBTEvent (hHal, pBtEvent);
4100 sme_ReleaseGlobalLock( &pMac->sme );
4101 }
4102#endif
4103 return (status);
4104}
4105
4106/* ---------------------------------------------------------------------------
4107 \fn sme_BtcSetConfig
4108 \brief API to change the current Bluetooth Coexistence (BTC) configuration
4109 This function should be invoked only after CFG download has completed.
4110 Calling it after sme_HDDReadyInd is recommended.
4111 \param hHal - The handle returned by macOpen.
4112 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
4113 Caller owns the memory and is responsible for freeing it.
4114 \return VOS_STATUS
4115 VOS_STATUS_E_FAILURE Config not passed to HAL.
4116 VOS_STATUS_SUCCESS Config passed to HAL
4117 ---------------------------------------------------------------------------*/
4118VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4119{
4120 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4121#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4122 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4123 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4124 {
4125 status = btcSetConfig (hHal, pSmeBtcConfig);
4126 sme_ReleaseGlobalLock( &pMac->sme );
4127 }
4128#endif
4129 return (status);
4130}
4131
4132/* ---------------------------------------------------------------------------
4133 \fn sme_BtcGetConfig
4134 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
4135 \param hHal - The handle returned by macOpen.
4136 \param pSmeBtcConfig - Pointer to a caller allocated object of type
4137 tSmeBtcConfig. Caller owns the memory and is responsible
4138 for freeing it.
4139 \return VOS_STATUS
4140 VOS_STATUS_E_FAILURE - failure
4141 VOS_STATUS_SUCCESS success
4142 ---------------------------------------------------------------------------*/
4143VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4144{
4145 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4146#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4147 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4148
4149 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4150 {
4151 status = btcGetConfig (hHal, pSmeBtcConfig);
4152 sme_ReleaseGlobalLock( &pMac->sme );
4153 }
4154#endif
4155 return (status);
4156}
4157/* ---------------------------------------------------------------------------
4158 \fn sme_SetCfgPrivacy
4159 \brief API to set configure privacy parameters
4160 \param hHal - The handle returned by macOpen.
4161 \param pProfile - Pointer CSR Roam profile.
4162 \param fPrivacy - This parameter indicates status of privacy
4163
4164 \return void
4165 ---------------------------------------------------------------------------*/
4166void sme_SetCfgPrivacy( tHalHandle hHal,
4167 tCsrRoamProfile *pProfile,
4168 tANI_BOOLEAN fPrivacy
4169 )
4170{
4171 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4172 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4173 {
4174 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
4175 sme_ReleaseGlobalLock( &pMac->sme );
4176 }
4177}
4178
4179#if defined WLAN_FEATURE_VOWIFI
4180/* ---------------------------------------------------------------------------
4181 \fn sme_NeighborReportRequest
4182 \brief API to request neighbor report.
4183 \param hHal - The handle returned by macOpen.
4184 \param pRrmNeighborReq - Pointer to a caller allocated object of type
4185 tRrmNeighborReq. Caller owns the memory and is responsible
4186 for freeing it.
4187 \return VOS_STATUS
4188 VOS_STATUS_E_FAILURE - failure
4189 VOS_STATUS_SUCCESS success
4190 ---------------------------------------------------------------------------*/
4191VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
4192 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
4193{
4194 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4195 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4196
4197 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4198 {
4199 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
4200 sme_ReleaseGlobalLock( &pMac->sme );
4201 }
4202
4203 return (status);
4204}
4205#endif
4206
4207//The following are debug APIs to support direct read/write register/memory
4208//They are placed in SME because HW cannot be access when in LOW_POWER state
4209//AND not connected. The knowledge and synchronization is done in SME
4210
4211//sme_DbgReadRegister
4212//Caller needs to validate the input values
4213VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
4214{
4215 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4216 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4217#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4218 tHddHandle hHdd = pMac->hHdd;
4219#endif
4220 tPmcPowerState PowerState;
4221 tANI_U32 sessionId = 0;
4222
4223 /* 1) To make Quarky work in FTM mode **************************************/
4224
4225 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4226 {
4227#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4228 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue)))
4229#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4230 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
4231#endif
4232 {
4233 return VOS_STATUS_SUCCESS;
4234 }
4235 return VOS_STATUS_E_FAILURE;
4236 }
4237
4238 /* 2) NON FTM mode driver *************************************************/
4239
4240 /* Acquire SME global lock */
4241 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4242 {
4243 return VOS_STATUS_E_FAILURE;
4244 }
4245
4246 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4247 {
4248 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4249 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4250 {
4251#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4252 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue )))
4253#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4254 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
4255#endif
4256 {
4257 status = VOS_STATUS_SUCCESS;
4258 }
4259 else
4260 {
4261 status = VOS_STATUS_E_FAILURE;
4262 }
4263 }
4264 else
4265 {
4266 status = VOS_STATUS_E_FAILURE;
4267 }
4268 }
4269
4270 /* This is a hack for Qualky/pttWniSocket
4271 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4272 if ( VOS_STATUS_SUCCESS != status )
4273 {
4274 *pRegValue = 0xDEADBEEF;
4275 status = VOS_STATUS_SUCCESS;
4276 }
4277
4278 /* Release SME global lock */
4279 sme_ReleaseGlobalLock(&pMac->sme);
4280
4281 return (status);
4282}
4283
4284
4285//sme_DbgWriteRegister
4286//Caller needs to validate the input values
4287VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
4288{
4289 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4290 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4291#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4292 tHddHandle hHdd = pMac->hHdd;
4293#endif
4294 tPmcPowerState PowerState;
4295 tANI_U32 sessionId = 0;
4296
4297 /* 1) To make Quarky work in FTM mode **************************************/
4298
4299 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4300 {
4301#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4302 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4303#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4304 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4305#endif
4306 {
4307 return VOS_STATUS_SUCCESS;
4308 }
4309 return VOS_STATUS_E_FAILURE;
4310 }
4311
4312 /* 2) NON FTM mode driver *************************************************/
4313
4314 /* Acquire SME global lock */
4315 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4316 {
4317 return VOS_STATUS_E_FAILURE;
4318 }
4319
4320 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4321 {
4322 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4323 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4324 {
4325#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4326 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4327#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4328 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4329#endif
4330 {
4331 status = VOS_STATUS_SUCCESS;
4332 }
4333 else
4334 {
4335 status = VOS_STATUS_E_FAILURE;
4336 }
4337 }
4338 else
4339 {
4340 status = VOS_STATUS_E_FAILURE;
4341 }
4342 }
4343
4344 /* Release SME global lock */
4345 sme_ReleaseGlobalLock(&pMac->sme);
4346
4347 return (status);
4348}
4349
4350
4351
4352//sme_DbgReadMemory
4353//Caller needs to validate the input values
4354//pBuf caller allocated buffer has the length of nLen
4355VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4356{
4357 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4358 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4359#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4360 v_PVOID_t pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *)hHal);
4361 tHddHandle hHdd = pMac->hHdd;
4362#endif
4363 tPmcPowerState PowerState;
4364 tANI_U32 sessionId = 0;
4365
4366 /* 1) To make Quarky work in FTM mode **************************************/
4367
4368 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4369 {
4370#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4371 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4372#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4373 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadMemory(memAddr, (void *)pBuf, nLen))
4374#endif
4375 {
4376 return VOS_STATUS_SUCCESS;
4377 }
4378 return VOS_STATUS_E_FAILURE;
4379 }
4380
4381 /* 2) NON FTM mode driver *************************************************/
4382
4383 /* Acquire SME global lock */
4384 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4385 {
4386 return VOS_STATUS_E_FAILURE;
4387 }
4388
4389 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4390 {
4391 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4392 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4393 {
4394#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4395 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(pvosGCTx, memAddr, (void *)pBuf, nLen)))
4396#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4397 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadMemory(memAddr, (void *)pBuf, nLen))
4398#endif
4399 {
4400 status = VOS_STATUS_SUCCESS;
4401 }
4402 else
4403 {
4404 status = VOS_STATUS_E_FAILURE;
4405 }
4406 }
4407 else
4408 {
4409 status = VOS_STATUS_E_FAILURE;
4410 }
4411 }
4412
4413 /* This is a hack for Qualky/pttWniSocket
4414 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4415 if (VOS_STATUS_SUCCESS != status)
4416 {
4417 vos_mem_set(pBuf, nLen, 0xCD);
4418 status = VOS_STATUS_SUCCESS;
4419 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware\n"));
4420 }
4421
4422 /* Release SME lock */
4423 sme_ReleaseGlobalLock(&pMac->sme);
4424
4425 return (status);
4426}
4427
4428
4429//sme_DbgWriteMemory
4430//Caller needs to validate the input values
4431VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4432{
4433 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4434 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4435#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4436 tHddHandle hHdd = pMac->hHdd;
4437#endif
4438 tPmcPowerState PowerState;
4439 tANI_U32 sessionId = 0;
4440
4441 /* 1) To make Quarky work in FTM mode **************************************/
4442
4443 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4444 {
4445#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4446 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4447#elif defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4448 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory( memAddr, (void *)pBuf, nLen))
4449#endif
4450 {
4451 return VOS_STATUS_SUCCESS;
4452 }
4453 return VOS_STATUS_E_FAILURE;
4454 }
4455
4456 /* 2) NON FTM mode driver *************************************************/
4457
4458 /* Acquire SME global lock */
4459 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4460 {
4461 return VOS_STATUS_E_FAILURE;
4462 }
4463
4464 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4465 {
4466 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4467 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4468 {
4469#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4470 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4471#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4472 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
4473#endif
4474 {
4475 status = VOS_STATUS_SUCCESS;
4476 }
4477 else
4478 {
4479 status = VOS_STATUS_E_FAILURE;
4480 }
4481 }
4482 else
4483 {
4484 status = VOS_STATUS_E_FAILURE;
4485 }
4486 }
4487
4488 /* Release Global lock */
4489 sme_ReleaseGlobalLock(&pMac->sme);
4490
4491 return (status);
4492}
4493
4494
4495void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
4496{
4497#ifdef WLAN_DEBUG
4498 // Verify against current log level
4499 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
4500 return;
4501 else
4502 {
4503 va_list marker;
4504
4505 va_start( marker, pString ); /* Initialize variable arguments. */
4506
4507 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
4508
4509 va_end( marker ); /* Reset variable arguments. */
4510 }
4511#endif
4512}
4513#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
4514/* ---------------------------------------------------------------------------
4515 \fn sme_GetFwVersion
4516 \brief This API returns the firmware version.
4517 \param hHal - The handle returned by macOpen.
4518 \param version - Points to the FwVersionInfo structure.
4519 \return VOS_STATUS
4520 VOS_STATUS_E_INVAL - failure
4521 VOS_STATUS_SUCCESS success
4522 ---------------------------------------------------------------------------*/
4523VOS_STATUS sme_GetFwVersion (tHalHandle hHal,FwVersionInfo *pVersion)
4524{
4525 VOS_STATUS status = VOS_STATUS_SUCCESS;
4526 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4527
4528 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4529 {
4530 if( pVersion != NULL ) {
4531 vos_mem_copy((v_VOID_t*)pVersion,(v_VOID_t*)&pMac->hal.FwParam.fwVersion, sizeof(FwVersionInfo));
4532 }
4533 else {
4534 status = VOS_STATUS_E_INVAL;
4535 }
4536 sme_ReleaseGlobalLock( &pMac->sme );
4537 }
4538
4539 return (status);
4540}
4541#endif
4542
4543#ifdef FEATURE_WLAN_INTEGRATED_SOC
4544/* ---------------------------------------------------------------------------
4545 \fn sme_GetWcnssWlanCompiledVersion
4546 \brief This API returns the version of the WCNSS WLAN API with
4547 which the HOST driver was built
4548 \param hHal - The handle returned by macOpen.
4549 \param pVersion - Points to the Version structure to be filled
4550 \return VOS_STATUS
4551 VOS_STATUS_E_INVAL - failure
4552 VOS_STATUS_SUCCESS success
4553 ---------------------------------------------------------------------------*/
4554VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
4555 tSirVersionType *pVersion)
4556{
4557 VOS_STATUS status = VOS_STATUS_SUCCESS;
4558 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4559 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4560
4561 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4562 {
4563 if( pVersion != NULL )
4564 {
4565 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
4566 }
4567 else
4568 {
4569 status = VOS_STATUS_E_INVAL;
4570 }
4571 sme_ReleaseGlobalLock( &pMac->sme );
4572 }
4573
4574 return (status);
4575}
4576
4577
4578/* ---------------------------------------------------------------------------
4579 \fn sme_GetWcnssWlanReportedVersion
4580 \brief This API returns the version of the WCNSS WLAN API with
4581 which the WCNSS driver reports it was built
4582 \param hHal - The handle returned by macOpen.
4583 \param pVersion - Points to the Version structure to be filled
4584 \return VOS_STATUS
4585 VOS_STATUS_E_INVAL - failure
4586 VOS_STATUS_SUCCESS success
4587 ---------------------------------------------------------------------------*/
4588VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
4589 tSirVersionType *pVersion)
4590{
4591 VOS_STATUS status = VOS_STATUS_SUCCESS;
4592 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4593 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4594
4595 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4596 {
4597 if( pVersion != NULL )
4598 {
4599 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
4600 }
4601 else
4602 {
4603 status = VOS_STATUS_E_INVAL;
4604 }
4605 sme_ReleaseGlobalLock( &pMac->sme );
4606 }
4607
4608 return (status);
4609}
4610
4611
4612/* ---------------------------------------------------------------------------
4613 \fn sme_GetWcnssSoftwareVersion
4614 \brief This API returns the version string of the WCNSS driver
4615 \param hHal - The handle returned by macOpen.
4616 \param pVersion - Points to the Version string buffer to be filled
4617 \param versionBufferSize - THe size of the Version string buffer
4618 \return VOS_STATUS
4619 VOS_STATUS_E_INVAL - failure
4620 VOS_STATUS_SUCCESS success
4621 ---------------------------------------------------------------------------*/
4622VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
4623 tANI_U8 *pVersion,
4624 tANI_U32 versionBufferSize)
4625{
4626 VOS_STATUS status = VOS_STATUS_SUCCESS;
4627 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4628 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4629
4630 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4631 {
4632 if( pVersion != NULL )
4633 {
4634 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
4635 versionBufferSize);
4636 }
4637 else
4638 {
4639 status = VOS_STATUS_E_INVAL;
4640 }
4641 sme_ReleaseGlobalLock( &pMac->sme );
4642 }
4643
4644 return (status);
4645}
4646
4647
4648/* ---------------------------------------------------------------------------
4649 \fn sme_GetWcnssHardwareVersion
4650 \brief This API returns the version string of the WCNSS hardware
4651 \param hHal - The handle returned by macOpen.
4652 \param pVersion - Points to the Version string buffer to be filled
4653 \param versionBufferSize - THe size of the Version string buffer
4654 \return VOS_STATUS
4655 VOS_STATUS_E_INVAL - failure
4656 VOS_STATUS_SUCCESS success
4657 ---------------------------------------------------------------------------*/
4658VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
4659 tANI_U8 *pVersion,
4660 tANI_U32 versionBufferSize)
4661{
4662 VOS_STATUS status = VOS_STATUS_SUCCESS;
4663 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4664 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4665
4666 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4667 {
4668 if( pVersion != NULL )
4669 {
4670 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
4671 versionBufferSize);
4672 }
4673 else
4674 {
4675 status = VOS_STATUS_E_INVAL;
4676 }
4677 sme_ReleaseGlobalLock( &pMac->sme );
4678 }
4679
4680 return (status);
4681}
4682#endif
4683
4684#ifdef FEATURE_WLAN_WAPI
4685/* ---------------------------------------------------------------------------
4686 \fn sme_RoamSetBKIDCache
4687 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
4688 candidate list.
4689 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4690 it is opened (by calling halOpen).
4691 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
4692 \param numItems - a variable that has the number of tBkidCacheInfo allocated
4693 when retruning, this is the number of items put into pBKIDCache
4694 \return eHalStatus - when fail, it usually means the buffer allocated is not
4695 big enough and pNumItems has the number of tBkidCacheInfo.
4696 ---------------------------------------------------------------------------*/
4697eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
4698 tANI_U32 numItems )
4699{
4700 eHalStatus status = eHAL_STATUS_FAILURE;
4701 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4702
4703 status = sme_AcquireGlobalLock( &pMac->sme );
4704 if ( HAL_STATUS_SUCCESS( status ) )
4705 {
4706 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
4707 sme_ReleaseGlobalLock( &pMac->sme );
4708 }
4709
4710 return (status);
4711}
4712
4713/* ---------------------------------------------------------------------------
4714 \fn sme_RoamGetBKIDCache
4715 \brief The SME API exposed to HDD to allow HDD to request SME to return its
4716 BKID cache.
4717 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4718 it is opened (by calling halOpen).
4719 \param pNum - caller allocated memory that has the space of the number of
4720 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
4721 in SME cache.
4722 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
4723 upon return
4724 \return eHalStatus - when fail, it usually means the buffer allocated is not
4725 big enough.
4726 ---------------------------------------------------------------------------*/
4727eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
4728 tBkidCacheInfo *pBkidCache)
4729{
4730 eHalStatus status = eHAL_STATUS_FAILURE;
4731 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4732
4733 status = sme_AcquireGlobalLock( &pMac->sme );
4734 if ( HAL_STATUS_SUCCESS( status ) )
4735 {
4736 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded\n"));
4737 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
4738 sme_ReleaseGlobalLock( &pMac->sme );
4739 }
4740
4741 return (status);
4742}
4743
4744/* ---------------------------------------------------------------------------
4745 \fn sme_RoamGetNumBKIDCache
4746 \brief The SME API exposed to HDD to allow HDD to request SME to return the
4747 number of BKID cache entries.
4748 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4749 it is opened (by calling halOpen).
4750 \return tANI_U32 - the number of BKID cache entries.
4751 ---------------------------------------------------------------------------*/
4752tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
4753{
4754 eHalStatus status = eHAL_STATUS_FAILURE;
4755 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4756 tANI_U32 numBkidCache = 0;
4757
4758 status = sme_AcquireGlobalLock( &pMac->sme );
4759 if ( HAL_STATUS_SUCCESS( status ) )
4760 {
4761 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
4762 sme_ReleaseGlobalLock( &pMac->sme );
4763 }
4764
4765 return (numBkidCache);
4766}
4767
4768/* ---------------------------------------------------------------------------
4769 \fn sme_ScanGetBKIDCandidateList
4770 \brief a wrapper function to return the BKID candidate list
4771 \param pBkidList - caller allocated buffer point to an array of
4772 tBkidCandidateInfo
4773 \param pNumItems - pointer to a variable that has the number of
4774 tBkidCandidateInfo allocated when retruning, this is
4775 either the number needed or number of items put into
4776 pPmkidList
4777 \return eHalStatus - when fail, it usually means the buffer allocated is not
4778 big enough and pNumItems
4779 has the number of tBkidCandidateInfo.
4780 \Note: pNumItems is a number of tBkidCandidateInfo,
4781 not sizeof(tBkidCandidateInfo) * something
4782 ---------------------------------------------------------------------------*/
4783eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
4784 tBkidCandidateInfo *pBkidList,
4785 tANI_U32 *pNumItems )
4786{
4787 eHalStatus status = eHAL_STATUS_FAILURE;
4788 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4789
4790 status = sme_AcquireGlobalLock( &pMac->sme );
4791 if ( HAL_STATUS_SUCCESS( status ) )
4792 {
4793 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
4794 sme_ReleaseGlobalLock( &pMac->sme );
4795 }
4796
4797 return (status);
4798}
4799#endif /* FEATURE_WLAN_WAPI */
4800
Jeff Johnsone7245742012-09-05 17:12:55 -07004801#ifdef FEATURE_OEM_DATA_SUPPORT
4802
4803/*****************************************************************************
4804 OEM DATA related modifications and function additions
4805 *****************************************************************************/
4806
4807/* ---------------------------------------------------------------------------
4808 \fn sme_getOemDataRsp
4809 \brief a wrapper function to obtain the OEM DATA RSP
4810 \param pOemDataRsp - A pointer to the response object
4811 \param pContext - a pointer passed in for the callback
4812 \return eHalStatus
4813 ---------------------------------------------------------------------------*/
4814eHalStatus sme_getOemDataRsp(tHalHandle hHal,
4815 tOemDataRsp **pOemDataRsp)
4816{
4817 eHalStatus status = eHAL_STATUS_SUCCESS;
4818 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4819
4820 do
4821 {
4822 //acquire the lock for the sme object
4823 status = sme_AcquireGlobalLock(&pMac->sme);
4824
4825 if(!HAL_STATUS_SUCCESS(status))
4826 {
4827 break;
4828 }
4829
4830 if(pMac->oemData.pOemDataRsp != NULL)
4831 {
4832 *pOemDataRsp = pMac->oemData.pOemDataRsp;
4833 }
4834 else
4835 {
4836 status = eHAL_STATUS_FAILURE;
4837 }
4838
4839 //release the lock for the sme object
4840 sme_ReleaseGlobalLock( &pMac->sme );
4841
4842 } while(0);
4843
4844 return status;
4845}
4846
4847/* ---------------------------------------------------------------------------
4848 \fn sme_OemDataReq
4849 \brief a wrapper function for OEM DATA REQ
4850 \param sessionId - session id to be used.
4851 \param pOemDataReqId - pointer to an object to get back the request ID
4852 \param callback - a callback function that is called upon finish
4853 \param pContext - a pointer passed in for the callback
4854 \return eHalStatus
4855 ---------------------------------------------------------------------------*/
4856eHalStatus sme_OemDataReq(tHalHandle hHal,
4857 tANI_U8 sessionId,
4858 tOemDataReqConfig *pOemDataReqConfig,
4859 tANI_U32 *pOemDataReqID,
4860 oemData_OemDataReqCompleteCallback callback,
4861 void *pContext)
4862{
4863 eHalStatus status = eHAL_STATUS_SUCCESS;
4864 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4865
4866 do
4867 {
4868 //acquire the lock for the sme object
4869 status = sme_AcquireGlobalLock(&pMac->sme);
4870 if(HAL_STATUS_SUCCESS(status))
4871 {
4872 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
4873
4874 if(pOemDataReqID)
4875 {
4876 *pOemDataReqID = lOemDataReqId;
4877 }
4878 else
4879 return eHAL_STATUS_FAILURE;
4880
4881 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
4882
4883 //release the lock for the sme object
4884 sme_ReleaseGlobalLock( &pMac->sme );
4885 }
4886 } while(0);
4887
4888 smsLog(pMac, LOGW, "exiting function %s\n", __FUNCTION__);
4889
4890 return(status);
4891}
4892
4893#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004894
4895/*--------------------------------------------------------------------------
4896
4897 \brief sme_OpenSession() - Open a session for scan/roam operation.
4898
4899 This is a synchronous API.
4900
4901
4902 \param hHal - The handle returned by macOpen.
4903 \param callback - A pointer to the function caller specifies for roam/connect status indication
4904 \param pContext - The context passed with callback
4905 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
4906 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
4907
4908 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
4909
4910 Other status means SME is failed to open the session.
4911 eHAL_STATUS_RESOURCES - no more session available.
4912 \sa
4913
4914 --------------------------------------------------------------------------*/
4915eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback, void *pContext,
4916 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId)
4917{
4918 eHalStatus status;
4919 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4920
4921 if( NULL == pbSessionId )
4922 {
4923 status = eHAL_STATUS_INVALID_PARAMETER;
4924 }
4925 else
4926 {
4927 status = sme_AcquireGlobalLock( &pMac->sme );
4928 if ( HAL_STATUS_SUCCESS( status ) )
4929 {
4930 status = csrRoamOpenSession( pMac, callback, pContext, pSelfMacAddr, pbSessionId );
4931
4932 sme_ReleaseGlobalLock( &pMac->sme );
4933 }
4934 }
4935
4936 return ( status );
4937}
4938
4939
4940/*--------------------------------------------------------------------------
4941
4942 \brief sme_CloseSession() - Open a session for scan/roam operation.
4943
4944 This is a synchronous API.
4945
4946
4947 \param hHal - The handle returned by macOpen.
4948
4949 \param sessionId - A previous opened session's ID.
4950
4951 \return eHAL_STATUS_SUCCESS - session is closed.
4952
4953 Other status means SME is failed to open the session.
4954 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
4955 \sa
4956
4957 --------------------------------------------------------------------------*/
4958eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
4959 csrRoamSessionCloseCallback callback, void *pContext)
4960{
4961 eHalStatus status;
4962 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4963
4964 status = sme_AcquireGlobalLock( &pMac->sme );
4965 if ( HAL_STATUS_SUCCESS( status ) )
4966 {
4967 status = csrRoamCloseSession( pMac, sessionId, FALSE,
4968 callback, pContext );
4969
4970 sme_ReleaseGlobalLock( &pMac->sme );
4971 }
4972
4973 return ( status );
4974}
4975
4976#ifdef WLAN_SOFTAP_FEATURE
4977/* ---------------------------------------------------------------------------
4978
4979 \fn sme_RoamUpdateAPWPSIE
4980
4981 \brief To update AP's WPS IE. This function should be called after SME AP session is created
4982 This is an asynchronous API.
4983
4984 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
4985
4986 \return eHalStatus – SUCCESS –
4987
4988 FAILURE or RESOURCES – The API finished and failed.
4989
4990 -------------------------------------------------------------------------------*/
4991eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
4992{
4993
4994 eHalStatus status = eHAL_STATUS_FAILURE;
4995 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4996
4997 status = sme_AcquireGlobalLock( &pMac->sme );
4998 if ( HAL_STATUS_SUCCESS( status ) )
4999 {
5000
5001 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
5002
5003 sme_ReleaseGlobalLock( &pMac->sme );
5004 }
5005
5006 return (status);
5007}
5008/* ---------------------------------------------------------------------------
5009
5010 \fn sme_RoamUpdateAPWPARSNIEs
5011
5012 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
5013 This is an asynchronous API.
5014
5015 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
5016
5017 \return eHalStatus – SUCCESS –
5018
5019 FAILURE or RESOURCES – The API finished and failed.
5020
5021 -------------------------------------------------------------------------------*/
5022eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
5023{
5024
5025 eHalStatus status = eHAL_STATUS_FAILURE;
5026 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5027
5028 status = sme_AcquireGlobalLock( &pMac->sme );
5029 if ( HAL_STATUS_SUCCESS( status ) )
5030 {
5031
5032 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
5033
5034 sme_ReleaseGlobalLock( &pMac->sme );
5035 }
5036
5037 return (status);
5038}
5039#endif
5040
5041
5042/*-------------------------------------------------------------------------------*
5043
5044 \fn sme_sendBTAmpEvent
5045
5046 \brief to receive the coex priorty request from BT-AMP PAL
5047 and send the BT_AMP link state to HAL
5048
5049 \param btAmpEvent - btAmpEvent
5050
5051 \return eHalStatus: SUCESS : BTAmp event successfully sent to HAL
5052
5053 FAILURE: API failed
5054
5055-------------------------------------------------------------------------------*/
5056
5057eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
5058{
5059 vos_msg_t msg;
5060 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
5061 eHalStatus status = eHAL_STATUS_FAILURE;
5062
5063 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tpSmeBtAmpEvent));
5064 if (NULL == ptrSmeBtAmpEvent)
5065 {
5066 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
5067 "Not able to allocate memory for BTAmp event", __FUNCTION__);
5068 return status;
5069 }
5070
5071 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
5072 msg.type = WDA_SIGNAL_BTAMP_EVENT;
5073 msg.reserved = 0;
5074 msg.bodyptr = ptrSmeBtAmpEvent;
5075
5076 //status = halFW_SendBTAmpEventMesg(pMac, event);
5077
5078 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5079 {
5080 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
5081 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __FUNCTION__);
5082 vos_mem_free(ptrSmeBtAmpEvent);
5083 return status;
5084 }
5085
5086 return eHAL_STATUS_SUCCESS;
5087
5088}
5089
5090/* ---------------------------------------------------------------------------
5091 \fn sme_SetHostOffload
5092 \brief API to set the host offload feature.
5093 \param hHal - The handle returned by macOpen.
5094 \param pRequest - Pointer to the offload request.
5095 \return eHalStatus
5096 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005097eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
5098 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005099{
5100 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07005101 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005102
5103 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5104 {
5105#ifdef WLAN_NS_OFFLOAD
5106 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
5107 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005108 status = pmcSetNSOffload( hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005109 }
5110 else
5111#endif //WLAN_NS_OFFLOAD
5112 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005113 status = pmcSetHostOffload (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 }
5115 sme_ReleaseGlobalLock( &pMac->sme );
5116 }
5117
5118 return (status);
5119}
5120
5121#ifdef WLAN_FEATURE_GTK_OFFLOAD
5122/* ---------------------------------------------------------------------------
5123 \fn sme_SetGTKOffload
5124 \brief API to set GTK offload information.
5125 \param hHal - The handle returned by macOpen.
5126 \param pRequest - Pointer to the GTK offload request.
5127 \return eHalStatus
5128 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005129eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest,
5130 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005131{
5132 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5133 eHalStatus status;
5134
5135 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5136 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005137 status = pmcSetGTKOffload( hHal, pRequest, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 sme_ReleaseGlobalLock( &pMac->sme );
5139 }
5140
5141 return (status);
5142}
5143
5144/* ---------------------------------------------------------------------------
5145 \fn sme_GetGTKOffload
5146 \brief API to get GTK offload information.
5147 \param hHal - The handle returned by macOpen.
5148 \param pRequest - Pointer to the GTK offload response.
5149 \return eHalStatus
5150 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005151eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
5152 void *callbackContext, tANI_U8 sessionId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005153{
5154 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5155 eHalStatus status;
5156
5157 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5158 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005159 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 sme_ReleaseGlobalLock( &pMac->sme );
5161 }
5162
5163 return (status);
5164}
5165#endif // WLAN_FEATURE_GTK_OFFLOAD
5166
5167/* ---------------------------------------------------------------------------
5168 \fn sme_SetKeepAlive
5169 \brief API to set the Keep Alive feature.
5170 \param hHal - The handle returned by macOpen.
5171 \param pRequest - Pointer to the Keep Alive request.
5172 \return eHalStatus
5173 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005174eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
5175 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005176{
5177 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5178 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5180 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005181 status = pmcSetKeepAlive (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 sme_ReleaseGlobalLock( &pMac->sme );
5183 }
5184
5185 return (status);
5186}
5187
5188#ifdef FEATURE_WLAN_SCAN_PNO
5189/* ---------------------------------------------------------------------------
5190 \fn sme_SetPreferredNetworkList
5191 \brief API to set the Preferred Network List Offload feature.
5192 \param hHal - The handle returned by macOpen.
5193 \param pRequest - Pointer to the offload request.
5194 \return eHalStatus
5195 ---------------------------------------------------------------------------*/
5196eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
5197{
5198 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5199 eHalStatus status;
5200
5201 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5202 {
5203 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
5204 sme_ReleaseGlobalLock( &pMac->sme );
5205 }
5206
5207 return (status);
5208}
5209
5210eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
5211{
5212 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5213 eHalStatus status;
5214
5215 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5216 {
5217 pmcSetRssiFilter(hHal, rssiThreshold);
5218 sme_ReleaseGlobalLock( &pMac->sme );
5219 }
5220
5221 return (status);
5222}
5223
5224#endif // FEATURE_WLAN_SCAN_PNO
5225
5226eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams)
5227{
5228 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5229 eHalStatus status;
5230
5231 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5232 {
5233 pmcSetPowerParams(hHal, pwParams);
5234 sme_ReleaseGlobalLock( &pMac->sme );
5235 }
5236
5237 return (status);
5238}
5239
5240/* ---------------------------------------------------------------------------
5241 \fn sme_AbortMacScan
5242 \brief API to cancel MAC scan.
5243 \param hHal - The handle returned by macOpen.
5244 \return VOS_STATUS
5245 VOS_STATUS_E_FAILURE - failure
5246 VOS_STATUS_SUCCESS success
5247 ---------------------------------------------------------------------------*/
5248eHalStatus sme_AbortMacScan(tHalHandle hHal)
5249{
5250 eHalStatus status;
5251 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5252
5253 status = sme_AcquireGlobalLock( &pMac->sme );
5254 if ( HAL_STATUS_SUCCESS( status ) )
5255 {
5256 status = csrScanAbortMacScan(pMac);
5257
5258 sme_ReleaseGlobalLock( &pMac->sme );
5259 }
5260
5261 return ( status );
5262}
5263
5264/* ----------------------------------------------------------------------------
5265 \fn sme_GetOperationChannel
5266 \brief API to get current channel on which STA is parked
5267 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005268 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 \returns eHAL_STATUS_SUCCESS
5270 eHAL_STATUS_FAILURE
5271-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005272eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005273{
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5275 tCsrRoamSession *pSession;
5276
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005277 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005279 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005280
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005281 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
5282 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005283#ifdef WLAN_SOFTAP_FEATURE
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005284 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
5285#endif
5286 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
5287 {
5288 *pChannel =pSession->connectedProfile.operationChannel;
5289 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 }
5291 }
5292 return eHAL_STATUS_FAILURE;
5293}// sme_GetOperationChannel ends here
5294
5295#ifdef WLAN_FEATURE_P2P
5296/* ---------------------------------------------------------------------------
5297
5298 \fn sme_RegisterMgtFrame
5299
5300 \brief To register managment frame of specified type and subtype.
5301 \param frameType - type of the frame that needs to be passed to HDD.
5302 \param matchData - data which needs to be matched before passing frame
5303 to HDD.
5304 \param matchDataLen - Length of matched data.
5305 \return eHalStatus
5306 -------------------------------------------------------------------------------*/
5307eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5308 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5309{
5310 eHalStatus status = eHAL_STATUS_SUCCESS;
5311 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5312
5313 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5314 {
5315 tSirRegisterMgmtFrame *pMsg;
5316 tANI_U16 len;
5317 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005318
5319 if(!pSession)
5320 {
5321 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5322 return eHAL_STATUS_FAILURE;
5323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005324
5325 if( !pSession->sessionActive )
5326 {
5327 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
5328 "%s Invalid Sessionid", __FUNCTION__);
5329 sme_ReleaseGlobalLock( &pMac->sme );
5330 return eHAL_STATUS_FAILURE;
5331 }
5332
5333 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5334
5335 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5336 if(HAL_STATUS_SUCCESS(status))
5337 {
5338 palZeroMemory(pMac->hHdd, pMsg, len);
5339 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5340 pMsg->length = len;
5341 pMsg->sessionId = sessionId;
5342 pMsg->registerFrame = VOS_TRUE;
5343 pMsg->frameType = frameType;
5344 pMsg->matchLen = matchLen;
5345 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5346 status = palSendMBMessage(pMac->hHdd, pMsg);
5347 }
5348 sme_ReleaseGlobalLock( &pMac->sme );
5349 }
5350 return status;
5351}
5352
5353/* ---------------------------------------------------------------------------
5354
5355 \fn sme_DeregisterMgtFrame
5356
5357 \brief To De-register managment frame of specified type and subtype.
5358 \param frameType - type of the frame that needs to be passed to HDD.
5359 \param matchData - data which needs to be matched before passing frame
5360 to HDD.
5361 \param matchDataLen - Length of matched data.
5362 \return eHalStatus
5363 -------------------------------------------------------------------------------*/
5364eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5365 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5366{
5367 eHalStatus status = eHAL_STATUS_SUCCESS;
5368 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5369
5370 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5371 {
5372 tSirRegisterMgmtFrame *pMsg;
5373 tANI_U16 len;
5374 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005375
5376 if(!pSession)
5377 {
5378 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5379 return eHAL_STATUS_FAILURE;
5380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005381
5382 if( !pSession->sessionActive )
5383 {
5384 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
5385 "%s Invalid Sessionid", __FUNCTION__);
5386 sme_ReleaseGlobalLock( &pMac->sme );
5387 return eHAL_STATUS_FAILURE;
5388 }
5389
5390 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5391
5392 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5393 if(HAL_STATUS_SUCCESS(status))
5394 {
5395 palZeroMemory(pMac->hHdd, pMsg, len);
5396 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5397 pMsg->length = len;
5398 pMsg->registerFrame = VOS_FALSE;
5399 pMsg->frameType = frameType;
5400 pMsg->matchLen = matchLen;
5401 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5402 status = palSendMBMessage(pMac->hHdd, pMsg);
5403 }
5404 sme_ReleaseGlobalLock( &pMac->sme );
5405 }
5406 return status;
5407}
5408
5409/* ---------------------------------------------------------------------------
5410 \fn sme_RemainOnChannel
5411 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
5412 \param hHal - The handle returned by macOpen.
5413 \param pRequest - channel
5414 \param duration - duration in ms
5415 \param callback - HDD registered callback to process reaminOnChannelRsp
5416 \param context - HDD Callback param
5417 \return eHalStatus
5418 ---------------------------------------------------------------------------*/
5419
5420eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
5421 tANI_U8 channel, tANI_U32 duration,
5422 remainOnChanCallback callback,
5423 void *pContext)
5424{
5425 eHalStatus status = eHAL_STATUS_SUCCESS;
5426 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5427
5428 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5429 {
5430 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext
5431#ifdef WLAN_FEATURE_P2P_INTERNAL
5432 , eP2PRemainOnChnReasonUnknown
5433#endif
5434 );
5435 sme_ReleaseGlobalLock( &pMac->sme );
5436 }
5437 return(status);
5438}
5439
5440/* ---------------------------------------------------------------------------
5441 \fn sme_ReportProbeReq
5442 \brief API to enable/disable forwarding of probeReq to apps in p2p.
5443 \param hHal - The handle returned by macOpen.
5444 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
5445 \return eHalStatus
5446 ---------------------------------------------------------------------------*/
5447
5448#ifndef WLAN_FEATURE_CONCURRENT_P2P
5449eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
5450{
5451 eHalStatus status = eHAL_STATUS_SUCCESS;
5452 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5453
5454 do
5455 {
5456 //acquire the lock for the sme object
5457 status = sme_AcquireGlobalLock(&pMac->sme);
5458 if(HAL_STATUS_SUCCESS(status))
5459 {
5460 /* call set in context */
5461 pMac->p2pContext.probeReqForwarding = flag;
5462 //release the lock for the sme object
5463 sme_ReleaseGlobalLock( &pMac->sme );
5464 }
5465 } while(0);
5466
5467 smsLog(pMac, LOGW, "exiting function %s\n", __FUNCTION__);
5468
5469 return(status);
5470}
5471
5472/* ---------------------------------------------------------------------------
5473 \fn sme_updateP2pIe
5474 \brief API to set the P2p Ie in p2p context
5475 \param hHal - The handle returned by macOpen.
5476 \param p2pIe - Ptr to p2pIe from HDD.
5477 \param p2pIeLength: length of p2pIe
5478 \return eHalStatus
5479 ---------------------------------------------------------------------------*/
5480
5481eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
5482{
5483 eHalStatus status = eHAL_STATUS_SUCCESS;
5484 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5485
5486 //acquire the lock for the sme object
5487 status = sme_AcquireGlobalLock(&pMac->sme);
5488 if(HAL_STATUS_SUCCESS(status))
5489 {
5490 if(NULL != pMac->p2pContext.probeRspIe){
5491 vos_mem_free(pMac->p2pContext.probeRspIe);
5492 pMac->p2pContext.probeRspIeLength = 0;
5493 }
5494
5495 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
5496 if (NULL == pMac->p2pContext.probeRspIe)
5497 {
5498 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __FUNCTION__);
5499 pMac->p2pContext.probeRspIeLength = 0;
5500 status = eHAL_STATUS_FAILURE;
5501 }
5502 else
5503 {
5504 pMac->p2pContext.probeRspIeLength = p2pIeLength;
5505
5506 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
5507 pMac->p2pContext.probeRspIe,
5508 pMac->p2pContext.probeRspIeLength );
5509 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
5510 p2pIeLength);
5511 }
5512
5513 //release the lock for the sme object
5514 sme_ReleaseGlobalLock( &pMac->sme );
5515 }
5516
5517 smsLog(pMac, LOG2, "exiting function %s\n", __FUNCTION__);
5518
5519 return(status);
5520}
5521#endif
5522
5523/* ---------------------------------------------------------------------------
5524 \fn sme_sendAction
5525 \brief API to send action frame from supplicant.
5526 \param hHal - The handle returned by macOpen.
5527 \return eHalStatus
5528 ---------------------------------------------------------------------------*/
5529
5530eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07005531 const tANI_U8 *pBuf, tANI_U32 len,
5532 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07005533{
5534 eHalStatus status = eHAL_STATUS_SUCCESS;
5535 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5536
5537 //acquire the lock for the sme object
5538 status = sme_AcquireGlobalLock(&pMac->sme);
5539 if(HAL_STATUS_SUCCESS(status))
5540 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005541 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 //release the lock for the sme object
5543 sme_ReleaseGlobalLock( &pMac->sme );
5544 }
5545
5546 smsLog(pMac, LOGW, "exiting function %s\n", __FUNCTION__);
5547
5548 return(status);
5549}
5550
5551eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
5552{
5553 eHalStatus status = eHAL_STATUS_SUCCESS;
5554 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5555
5556 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5557 {
5558 status = p2pCancelRemainOnChannel (hHal, sessionId);
5559 sme_ReleaseGlobalLock( &pMac->sme );
5560 }
5561 return(status);
5562}
5563
5564//Power Save Related
5565eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
5566{
5567 eHalStatus status = eHAL_STATUS_SUCCESS;
5568 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5569
5570 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5571 {
5572 status = p2pSetPs (hHal, data);
5573 sme_ReleaseGlobalLock( &pMac->sme );
5574 }
5575 return(status);
5576}
5577
5578#endif
5579
5580/* ---------------------------------------------------------------------------
5581
5582 \fn sme_ConfigureRxpFilter
5583
5584 \brief
5585 SME will pass this request to lower mac to set/reset the filter on RXP for
5586 multicast & broadcast traffic.
5587
5588 \param
5589
5590 hHal - The handle returned by macOpen.
5591
5592 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
5593 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
5594 on this param. In future we can use this as a mask to set various types of
5595 filters as suggested below:
5596 FILTER_ALL_MULTICAST:
5597 FILTER_ALL_BROADCAST:
5598 FILTER_ALL_MULTICAST_BROADCAST:
5599
5600
5601 \return eHalStatus
5602
5603
5604--------------------------------------------------------------------------- */
5605eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
5606 tpSirWlanSetRxpFilters wlanRxpFilterParam)
5607{
5608 eHalStatus status = eHAL_STATUS_SUCCESS;
5609 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5610 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5611 vos_msg_t vosMessage;
5612
5613 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5614 {
5615 /* serialize the req through MC thread */
5616 vosMessage.bodyptr = wlanRxpFilterParam;
5617 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
5618 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5619 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5620 {
5621 status = eHAL_STATUS_FAILURE;
5622 }
5623 sme_ReleaseGlobalLock( &pMac->sme );
5624 }
5625 return(status);
5626}
5627
5628#ifdef FEATURE_WLAN_INTEGRATED_SOC
5629/* ---------------------------------------------------------------------------
5630
5631 \fn sme_ConfigureSuspendInd
5632
5633 \brief
5634 SME will pass this request to lower mac to Indicate that the wlan needs to
5635 be suspended
5636
5637 \param
5638
5639 hHal - The handle returned by macOpen.
5640
5641 wlanSuspendParam- Depicts the wlan suspend params
5642
5643
5644 \return eHalStatus
5645
5646
5647--------------------------------------------------------------------------- */
5648eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
5649 tpSirWlanSuspendParam wlanSuspendParam)
5650{
5651 eHalStatus status = eHAL_STATUS_SUCCESS;
5652 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5653 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5654 vos_msg_t vosMessage;
5655
5656 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5657 {
5658 /* serialize the req through MC thread */
5659 vosMessage.bodyptr = wlanSuspendParam;
5660 vosMessage.type = WDA_WLAN_SUSPEND_IND;
5661 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5662 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5663 {
5664 status = eHAL_STATUS_FAILURE;
5665 }
5666 sme_ReleaseGlobalLock( &pMac->sme );
5667 }
5668 return(status);
5669}
5670
5671/* ---------------------------------------------------------------------------
5672
5673 \fn sme_ConfigureResumeReq
5674
5675 \brief
5676 SME will pass this request to lower mac to Indicate that the wlan needs to
5677 be Resumed
5678
5679 \param
5680
5681 hHal - The handle returned by macOpen.
5682
5683 wlanResumeParam- Depicts the wlan resume params
5684
5685
5686 \return eHalStatus
5687
5688
5689--------------------------------------------------------------------------- */
5690eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
5691 tpSirWlanResumeParam wlanResumeParam)
5692{
5693 eHalStatus status = eHAL_STATUS_SUCCESS;
5694 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5695 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5696 vos_msg_t vosMessage;
5697
5698 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5699 {
5700 /* serialize the req through MC thread */
5701 vosMessage.bodyptr = wlanResumeParam;
5702 vosMessage.type = WDA_WLAN_RESUME_REQ;
5703 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5704 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5705 {
5706 status = eHAL_STATUS_FAILURE;
5707 }
5708 sme_ReleaseGlobalLock( &pMac->sme );
5709 }
5710 return(status);
5711}
5712
5713#endif
5714/* ---------------------------------------------------------------------------
5715
5716 \fn sme_GetInfraSessionId
5717
5718 \brief To get the session ID for infra session, if connected
5719 This is a synchronous API.
5720
5721 \param hHal - The handle returned by macOpen.
5722
5723 \return sessionid, -1 if infra session is not connected
5724
5725 -------------------------------------------------------------------------------*/
5726tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
5727{
5728 eHalStatus status = eHAL_STATUS_FAILURE;
5729 tANI_S8 sessionid = -1;
5730 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5731
5732 status = sme_AcquireGlobalLock( &pMac->sme );
5733 if ( HAL_STATUS_SUCCESS( status ) )
5734 {
5735
5736 sessionid = csrGetInfraSessionId( pMac);
5737
5738 sme_ReleaseGlobalLock( &pMac->sme );
5739 }
5740
5741 return (sessionid);
5742}
5743
5744/* ---------------------------------------------------------------------------
5745
5746 \fn sme_GetInfraOperationChannel
5747
5748 \brief To get the operating channel for infra session, if connected
5749 This is a synchronous API.
5750
5751 \param hHal - The handle returned by macOpen.
5752 \param sessionId - the sessionId returned by sme_OpenSession.
5753
5754 \return operating channel, 0 if infra session is not connected
5755
5756 -------------------------------------------------------------------------------*/
5757tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
5758{
5759 eHalStatus status = eHAL_STATUS_FAILURE;
5760 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5761 tANI_U8 channel = 0;
5762 status = sme_AcquireGlobalLock( &pMac->sme );
5763 if ( HAL_STATUS_SUCCESS( status ) )
5764 {
5765
5766 channel = csrGetInfraOperationChannel( pMac, sessionId);
5767
5768 sme_ReleaseGlobalLock( &pMac->sme );
5769 }
5770
5771 return (channel);
5772}
5773
5774//This routine will return poerating channel on which other BSS is operating to be used for concurrency mode.
5775//If other BSS is not up or not connected it will return 0
5776tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
5777{
5778 eHalStatus status = eHAL_STATUS_FAILURE;
5779 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5780 tANI_U8 channel = 0;
5781 status = sme_AcquireGlobalLock( &pMac->sme );
5782 if ( HAL_STATUS_SUCCESS( status ) )
5783 {
5784
5785 channel = csrGetConcurrentOperationChannel( pMac );
5786 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
5787 " Other Concurrent Channel = %d", __FUNCTION__,channel);
5788 sme_ReleaseGlobalLock( &pMac->sme );
5789 }
5790
5791 return (channel);
5792}
5793
5794#ifdef FEATURE_WLAN_SCAN_PNO
5795/******************************************************************************
5796*
5797* Name: sme_PreferredNetworkFoundInd
5798*
5799* Description:
5800* Invoke Preferred Network Found Indication
5801*
5802* Parameters:
5803* hHal - HAL handle for device
5804* pMsg - found network description
5805*
5806* Returns: eHalStatus
5807*
5808******************************************************************************/
5809eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
5810{
5811 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5812 eHalStatus status = eHAL_STATUS_SUCCESS;
5813 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
5814
5815 if (NULL == pMsg)
5816 {
5817 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __FUNCTION__);
5818 status = eHAL_STATUS_FAILURE;
5819 }
5820 else
5821 {
5822 if (pPrefNetworkFoundInd->ssId.length > 0)
5823 {
5824 smsLog(pMac, LOG1, "Preferred Network Found Indication in %s(), SSID=%s",
5825 __FUNCTION__, pPrefNetworkFoundInd->ssId.ssId);
5826
5827
5828 /* Call Preferred Netowrk Found Indication callback routine. */
5829 if (pMac->pmc.prefNetwFoundCB != NULL)
5830 {
5831 pMac->pmc.prefNetwFoundCB(pMac->pmc.preferredNetworkFoundIndCallbackContext, pPrefNetworkFoundInd);
5832 }
5833
5834 }
5835 else
5836 {
5837 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL\n", __FUNCTION__);
5838 status = eHAL_STATUS_FAILURE;
5839 }
5840 }
5841
5842
5843 return(status);
5844}
5845
5846#endif // FEATURE_WLAN_SCAN_PNO
5847
5848
5849eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
5850{
5851 eHalStatus status = eHAL_STATUS_FAILURE;
5852 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5853
5854 status = sme_AcquireGlobalLock( &pMac->sme );
5855 if ( HAL_STATUS_SUCCESS( status ) )
5856 {
5857 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
5858 sme_ReleaseGlobalLock( &pMac->sme );
5859 }
5860
5861 return (status);
5862}
5863
5864
5865/* ---------------------------------------------------------------------------
5866
5867 \fn sme_SetTxPerTracking
5868
5869 \brief Set Tx PER tracking configuration parameters
5870
5871 \param hHal - The handle returned by macOpen.
5872 \param pTxPerTrackingConf - Tx PER configuration parameters
5873
5874 \return eHalStatus
5875
5876 -------------------------------------------------------------------------------*/
5877eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
5878 void (*pCallbackfn) (void *pCallbackContext),
5879 void *pCallbackContext,
5880 tpSirTxPerTrackingParam pTxPerTrackingParam)
5881{
5882 vos_msg_t msg;
5883 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
5884 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5885
5886 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5887 {
5888 pMac->sme.pTxPerHitCallback = pCallbackfn;
5889 pMac->sme.pTxPerHitCbContext = pCallbackContext;
5890 sme_ReleaseGlobalLock( &pMac->sme );
5891 }
5892
5893 // free this memory in failure case or WDA request callback function
5894 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
5895 if (NULL == pTxPerTrackingParamReq)
5896 {
5897 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for tSirTxPerTrackingParam", __FUNCTION__);
5898 return eHAL_STATUS_FAILURE;
5899 }
5900
5901 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam, sizeof(tSirTxPerTrackingParam));
5902 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
5903 msg.reserved = 0;
5904 msg.bodyptr = pTxPerTrackingParamReq;
5905
5906 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5907 {
5908 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_SET_TX_PER_TRACKING_REQ message to WDA", __FUNCTION__);
5909 vos_mem_free(pTxPerTrackingParamReq);
5910 return eHAL_STATUS_FAILURE;
5911 }
5912
5913 return eHAL_STATUS_SUCCESS;
5914}
5915
5916/* ---------------------------------------------------------------------------
5917
5918 \fn sme_HandleChangeCountryCode
5919
5920 \brief Change Country code, Reg Domain and channel list
5921
5922 \details Country Code Priority
5923 0 = 11D > Configured Country > NV
5924 1 = Configured Country > 11D > NV
5925 If Supplicant country code is priority than 11d is disabled.
5926 If 11D is enabled, we update the country code after every scan.
5927 Hence when Supplicant country code is priority, we don't need 11D info.
5928 Country code from Supplicant is set as current courtry code.
5929 User can send reset command XX (instead of country code) to reset the
5930 country code to default values which is read from NV.
5931 In case of reset, 11D is enabled and default NV code is Set as current country code
5932 If 11D is priority,
5933 Than Supplicant country code code is set to default code. But 11D code is set as current country code
5934
5935 \param pMac - The handle returned by macOpen.
5936 \param pMsgBuf - MSG Buffer
5937
5938 \return eHalStatus
5939
5940 -------------------------------------------------------------------------------*/
5941eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
5942{
5943 eHalStatus status = eHAL_STATUS_SUCCESS;
5944 tAniChangeCountryCodeReq *pMsg;
5945 v_REGDOMAIN_t domainIdIoctl;
5946 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5947 static uNvTables nvTables;
5948 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
5949
5950
5951 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
5952 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
5953 {
5954 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
5955
5956 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
5957
5958 /* read the country code from NV and use it */
5959 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
5960 {
5961 palCopyMemory( pMac->hHdd, pMsg->countryCode , nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
5962 }
5963 else
5964 {
5965 status = eHAL_STATUS_FAILURE;
5966 return status;
5967 }
5968 }
5969 else
5970 {
5971 /* if Supplicant country code has priority, disable 11d */
5972 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority)
5973 {
5974 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
5975 }
5976 }
5977
5978 /* WEXT set country code means
5979 * 11D should be supported?
5980 * 11D Channel should be enforced?
5981 * 11D Country code should be matched?
5982 * 11D Reg Domian should be matched?
5983 * Country string changed */
5984 if(pMac->roam.configParam.Is11dSupportEnabled &&
5985 pMac->roam.configParam.fEnforce11dChannels &&
5986 pMac->roam.configParam.fEnforceCountryCodeMatch &&
5987 pMac->roam.configParam.fEnforceDefaultDomain &&
5988 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
5989 {
5990 /* All 11D related options are already enabled
5991 * Country string is not changed
5992 * Do not need do anything for country code change request */
5993 return eHAL_STATUS_SUCCESS;
5994 }
5995
5996 /* Set Current Country code and Current Regulatory domain */
5997 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
5998 if(eHAL_STATUS_SUCCESS != status)
5999 {
6000 /* Supplicant country code failed. So give 11D priority */
6001 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6002 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
6003 return status;
6004 }
6005
6006 /* purge current scan results
6007 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).
6008 Looks like a bug in current scan sequence.
6009 */
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07006010 csrScanFlushResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006011
6012 /* overwrite the defualt country code */
6013 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault, pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
6014
6015 /* Get Domain ID from country code */
6016 status = csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent,(v_REGDOMAIN_t *) &domainIdIoctl );
6017 if ( status != eHAL_STATUS_SUCCESS )
6018 {
6019 smsLog( pMac, LOGE, FL(" fail to get regId %d\n"), domainIdIoctl );
6020 return status;
6021 }
6022
6023 status = WDA_SetRegDomain(pMac, domainIdIoctl);
6024
6025 if ( status != eHAL_STATUS_SUCCESS )
6026 {
6027 smsLog( pMac, LOGE, FL(" fail to set regId %d\n"), domainIdIoctl );
6028 return status;
6029 }
6030
6031 /* set to default domain ID */
6032 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
6033
6034 /* get the channels based on new cc */
6035 status = csrInitGetChannels( pMac );
6036
6037 if ( status != eHAL_STATUS_SUCCESS )
6038 {
6039 smsLog( pMac, LOGE, FL(" fail to get Channels \n"));
6040 return status;
6041 }
6042
6043 /* reset info based on new cc, and we are done */
6044 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE);
6045 if( pMsg->changeCCCallback )
6046 {
6047 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
6048 }
6049
6050 return eHAL_STATUS_SUCCESS;
6051}
6052
6053#ifdef WLAN_FEATURE_PACKET_FILTERING
6054eHalStatus sme_8023MulticastList (tHalHandle hHal, tpSirRcvFltMcAddrList pMulticastAddrs)
6055{
6056 tpSirRcvFltMcAddrList pRequestBuf;
6057 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006058 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6059 tANI_U8 sessionId = 0;
6060 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006061
6062 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
6063 "ulMulticastAddrCnt=%d, multicastAddr[0]=%d", __FUNCTION__,
6064 pMulticastAddrs->ulMulticastAddrCnt,
6065 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07006066
6067 /*
6068 *Find the connected Infra / P2P_client connected session
6069 */
6070 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
6071 {
6072 if( CSR_IS_SESSION_VALID( pMac, sessionId ) &&
6073 ( csrIsConnStateInfra( pMac, sessionId )) )
6074 {
6075 pSession = CSR_GET_SESSION( pMac, sessionId );
6076 }
6077 }
6078
6079 if(pSession == NULL )
6080 {
6081 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Unable to find "
6082 "the right session", __FUNCTION__);
6083 return eHAL_STATUS_FAILURE;
6084 }
6085
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6087 if (NULL == pRequestBuf)
6088 {
6089 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
6090 "allocate memory for 8023 Multicast List request", __FUNCTION__);
6091 return eHAL_STATUS_FAILED_ALLOC;
6092 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006093
6094 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6095 {
6096 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
6097 "indication as we are not connected", __FUNCTION__);
6098 vos_mem_free(pRequestBuf);
6099 return eHAL_STATUS_FAILURE;
6100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
6102
Jeff Johnsone7245742012-09-05 17:12:55 -07006103 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6104 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
6105 sizeof(tSirMacAddr));
6106
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 msg.type = WDA_8023_MULTICAST_LIST_REQ;
6108 msg.reserved = 0;
6109 msg.bodyptr = pRequestBuf;
6110 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6111 {
6112 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
6113 "post WDA_8023_MULTICAST_LIST message to WDA", __FUNCTION__);
6114 vos_mem_free(pRequestBuf);
6115 return eHAL_STATUS_FAILURE;
6116 }
6117
6118 return eHAL_STATUS_SUCCESS;
6119}
6120
Jeff Johnsone7245742012-09-05 17:12:55 -07006121eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
6122 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006123{
6124 tpSirRcvPktFilterCfgType pRequestBuf;
6125 v_SINT_t allocSize;
6126 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006127 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6128 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 v_U8_t idx=0;
6130
6131 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
6132 "filterId = %d", __FUNCTION__,
6133 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
6134
Madan Mohan Koyyalamudid4029622012-10-18 20:30:17 -07006135 allocSize = sizeof(tSirRcvPktFilterCfgType);
6136
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 pRequestBuf = vos_mem_malloc(allocSize);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006138
6139 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 {
6141 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
6142 "allocate memory for Receive Filter Set Filter request", __FUNCTION__);
6143 return eHAL_STATUS_FAILED_ALLOC;
6144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006145
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006146 if( NULL == pSession )
6147 {
6148 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Session Not found ", __FUNCTION__);
6149 vos_mem_free(pRequestBuf);
6150 return eHAL_STATUS_FAILURE;
6151 }
6152
6153 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6154 {
6155 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
6156 "indication as we are not connected", __FUNCTION__);
6157 vos_mem_free(pRequestBuf);
6158 return eHAL_STATUS_FAILURE;
6159 }
6160
6161 vos_mem_copy( pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6162 vos_mem_copy( pRcvPktFilterCfg->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006163 sizeof(tSirMacAddr));
6164
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006165 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
6166
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
6168 msg.reserved = 0;
6169 msg.bodyptr = pRequestBuf;
6170
6171 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6172 "FT %d FID %d ",
6173 pRequestBuf->filterType, pRequestBuf->filterId);
6174
6175 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6176 "params %d CT %d",
6177 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
6178
6179 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
6180 {
6181
6182 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6183 "Proto %d Comp Flag %d \n",
6184 pRequestBuf->paramsData[idx].protocolLayer,
6185 pRequestBuf->paramsData[idx].cmpFlag);
6186
6187 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6188 "Data Offset %d Data Len %d\n",
6189 pRequestBuf->paramsData[idx].dataOffset,
6190 pRequestBuf->paramsData[idx].dataLength);
6191
6192 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6193 "CData: %d:%d:%d:%d:%d:%d\n",
6194 pRequestBuf->paramsData[idx].compareData[0],
6195 pRequestBuf->paramsData[idx].compareData[1],
6196 pRequestBuf->paramsData[idx].compareData[2],
6197 pRequestBuf->paramsData[idx].compareData[3],
6198 pRequestBuf->paramsData[idx].compareData[4],
6199 pRequestBuf->paramsData[idx].compareData[5]);
6200
6201 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6202 "MData: %d:%d:%d:%d:%d:%d\n",
6203 pRequestBuf->paramsData[idx].dataMask[0],
6204 pRequestBuf->paramsData[idx].dataMask[1],
6205 pRequestBuf->paramsData[idx].dataMask[2],
6206 pRequestBuf->paramsData[idx].dataMask[3],
6207 pRequestBuf->paramsData[idx].dataMask[4],
6208 pRequestBuf->paramsData[idx].dataMask[5]);
6209
6210 }
6211
6212 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6213 {
6214 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
6215 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __FUNCTION__);
6216 vos_mem_free(pRequestBuf);
6217 return eHAL_STATUS_FAILURE;
6218 }
6219
6220 return eHAL_STATUS_SUCCESS;
6221}
6222
6223eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
6224 FilterMatchCountCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006225 void *callbackContext,
6226 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006227{
6228 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6229 eHalStatus status;
6230
6231 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __FUNCTION__);
6232
6233 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
6234 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006235 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 sme_ReleaseGlobalLock( &pMac->sme );
6237 }
6238
6239 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __FUNCTION__);
6240
6241 return (status);
6242}
6243
Jeff Johnsone7245742012-09-05 17:12:55 -07006244eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
6245 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006246{
6247 tpSirRcvFltPktClearParam pRequestBuf;
6248 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006249 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6250 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006251
6252 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __FUNCTION__,
6253 pRcvFltPktClearParam->filterId);
6254
6255 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006256 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 {
6258 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6259 "%s: Not able to allocate memory for Receive Filter "
6260 "Clear Filter request", __FUNCTION__);
6261 return eHAL_STATUS_FAILED_ALLOC;
6262 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006263 if( NULL == pSession )
6264 {
6265 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6266 "%s: Session Not find ", __FUNCTION__);
6267 vos_mem_free(pRequestBuf);
6268 return eHAL_STATUS_FAILURE;
6269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006270
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006271 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6272 {
6273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
6274 "indication as we are not connected", __FUNCTION__);
6275 vos_mem_free(pRequestBuf);
6276 return eHAL_STATUS_FAILURE;
6277 }
6278
6279 vos_mem_copy( pRcvFltPktClearParam->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6280 vos_mem_copy( pRcvFltPktClearParam->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006281 sizeof(tSirMacAddr));
6282
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006283 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
6284
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
6286 msg.reserved = 0;
6287 msg.bodyptr = pRequestBuf;
6288 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6289 {
6290 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
6291 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __FUNCTION__);
6292 vos_mem_free(pRequestBuf);
6293 return eHAL_STATUS_FAILURE;
6294 }
6295
6296 return eHAL_STATUS_SUCCESS;
6297}
6298#endif // WLAN_FEATURE_PACKET_FILTERING
6299
6300/* ---------------------------------------------------------------------------
6301 \fn sme_PreChannelSwitchIndFullPowerCB
6302 \brief call back function for the PMC full power request because of pre
6303 channel switch.
6304 \param callbackContext
6305 \param status
6306 ---------------------------------------------------------------------------*/
6307void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
6308 eHalStatus status)
6309{
6310 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
6311 tSirMbMsg *pMsg;
6312 tANI_U16 msgLen;
6313
6314 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
6315 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
6316 if(HAL_STATUS_SUCCESS(status))
6317 {
6318 palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen);
6319 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
6320 pMsg->msgLen = pal_cpu_to_be16(msgLen);
6321 status = palSendMBMessage(pMac->hHdd, pMsg);
6322 }
6323
6324 return;
6325}
6326
6327/* ---------------------------------------------------------------------------
6328 \fn sme_HandlePreChannelSwitchInd
6329 \brief Processes the indcation from PE for pre-channel switch.
6330 \param hHal
6331 \- The handle returned by macOpen. return eHalStatus
6332 ---------------------------------------------------------------------------*/
6333eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
6334{
6335 eHalStatus status = eHAL_STATUS_FAILURE;
6336 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6337 status = sme_AcquireGlobalLock( &pMac->sme );
6338 if ( HAL_STATUS_SUCCESS( status ) )
6339 {
6340 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
6341 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
6342 sme_ReleaseGlobalLock( &pMac->sme );
6343 }
6344
6345 return (status);
6346}
6347
6348/* ---------------------------------------------------------------------------
6349 \fn sme_HandlePostChannelSwitchInd
6350 \brief Processes the indcation from PE for post-channel switch.
6351 \param hHal
6352 \- The handle returned by macOpen. return eHalStatus
6353 ---------------------------------------------------------------------------*/
6354eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
6355{
6356 eHalStatus status = eHAL_STATUS_FAILURE;
6357 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6358
6359 status = sme_AcquireGlobalLock( &pMac->sme );
6360 if ( HAL_STATUS_SUCCESS( status ) )
6361 {
6362 status = pmcRequestBmps(hHal, NULL, NULL);
6363 sme_ReleaseGlobalLock( &pMac->sme );
6364 }
6365
6366 return (status);
6367}
6368
6369/* ---------------------------------------------------------------------------
6370
6371 \fn sme_IsChannelValid
6372
6373 \brief To check if the channel is valid for currently established domain
6374 This is a synchronous API.
6375
6376 \param hHal - The handle returned by macOpen.
6377 \param channel - channel to verify
6378
6379 \return TRUE/FALSE, TRUE if channel is valid
6380
6381 -------------------------------------------------------------------------------*/
6382tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
6383{
6384 eHalStatus status = eHAL_STATUS_FAILURE;
6385 tANI_BOOLEAN valid = FALSE;
6386 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6387
6388 status = sme_AcquireGlobalLock( &pMac->sme );
6389 if ( HAL_STATUS_SUCCESS( status ) )
6390 {
6391
6392 valid = csrRoamIsChannelValid( pMac, channel);
6393
6394 sme_ReleaseGlobalLock( &pMac->sme );
6395 }
6396
6397 return (valid);
6398}
6399
6400/* ---------------------------------------------------------------------------
6401 \fn sme_SetFreqBand
6402 \brief Used to set frequency band.
6403 \param hHal
6404 \eBand band value to be configured
6405 \- return eHalStatus
6406 -------------------------------------------------------------------------*/
6407eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
6408{
6409 eHalStatus status = eHAL_STATUS_FAILURE;
6410 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6411
6412 status = sme_AcquireGlobalLock( &pMac->sme );
6413 if ( HAL_STATUS_SUCCESS( status ) )
6414 {
6415 status = csrSetBand(hHal, eBand);
6416 sme_ReleaseGlobalLock( &pMac->sme );
6417 }
6418 return status;
6419}
6420
6421/* ---------------------------------------------------------------------------
6422 \fn sme_GetFreqBand
6423 \brief Used to get the current band settings.
6424 \param hHal
6425 \pBand pointer to hold band value
6426 \- return eHalStatus
6427 -------------------------------------------------------------------------*/
6428eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
6429{
6430 eHalStatus status = eHAL_STATUS_FAILURE;
6431 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6432
6433 status = sme_AcquireGlobalLock( &pMac->sme );
6434 if ( HAL_STATUS_SUCCESS( status ) )
6435 {
6436 *pBand = csrGetCurrentBand( hHal );
6437 sme_ReleaseGlobalLock( &pMac->sme );
6438 }
6439 return status;
6440}
6441
6442#ifdef WLAN_WAKEUP_EVENTS
6443/******************************************************************************
6444 \fn sme_WakeReasonIndCallback
6445
6446 \brief
6447 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
6448
6449 \param hHal - HAL handle for device
6450 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
6451
6452 \return eHalStatus
6453******************************************************************************/
6454eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
6455{
6456 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6457 eHalStatus status = eHAL_STATUS_SUCCESS;
6458 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
6459
6460 if (NULL == pMsg)
6461 {
6462 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __FUNCTION__);
6463 status = eHAL_STATUS_FAILURE;
6464 }
6465 else
6466 {
6467 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback\n");
6468
6469 /* Call Wake Reason Indication callback routine. */
6470 if (pMac->pmc.wakeReasonIndCB != NULL)
6471 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
6472
6473 pMac->pmc.wakeReasonIndCB = NULL;
6474 pMac->pmc.wakeReasonIndCBContext = NULL;
6475
6476 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __FUNCTION__, pWakeReasonInd->ulReason);
6477 }
6478
6479 return(status);
6480}
6481#endif // WLAN_WAKEUP_EVENTS
6482
6483
6484/* ---------------------------------------------------------------------------
6485
6486 \fn sme_SetMaxTxPower
6487
6488 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
6489 not persist over reboots.
6490
6491 \param hHal
6492 \param pBssid BSSID to set the power cap for
6493 \param pBssid pSelfMacAddress self MAC Address
6494 \param pBssid power to set in dB
6495 \- return eHalStatus
6496
6497 -------------------------------------------------------------------------------*/
6498eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr pBssid,
6499 tSirMacAddr pSelfMacAddress, v_S7_t dB)
6500{
6501 vos_msg_t msg;
6502 tpMaxTxPowerParams pMaxTxParams = NULL;
6503
6504 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
6505 if (NULL == pMaxTxParams)
6506 {
6507 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for pMaxTxParams", __FUNCTION__);
6508 return eHAL_STATUS_FAILURE;
6509 }
6510
6511 vos_mem_copy(pMaxTxParams->bssId, pBssid, SIR_MAC_ADDR_LENGTH);
6512 vos_mem_copy(pMaxTxParams->selfStaMacAddr , pSelfMacAddress,
6513 SIR_MAC_ADDR_LENGTH);
6514 pMaxTxParams->power = dB;
6515
6516 msg.type = WDA_SET_MAX_TX_POWER_REQ;
6517 msg.reserved = 0;
6518 msg.bodyptr = pMaxTxParams;
6519
6520 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6521 {
6522 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_SET_MAX_TX_POWER_REQ message to WDA", __FUNCTION__);
6523 vos_mem_free(pMaxTxParams);
6524 return eHAL_STATUS_FAILURE;
6525 }
6526
6527 return eHAL_STATUS_SUCCESS;
6528}
6529
6530#ifdef WLAN_SOFTAP_FEATURE
6531/* ---------------------------------------------------------------------------
6532
6533 \fn sme_HideSSID
6534
6535 \brief hide/show SSID dynamically. Note: this setting will
6536 not persist over reboots.
6537
6538 \param hHal
6539 \param sessionId
6540 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
6541 \- return eHalStatus
6542
6543 -------------------------------------------------------------------------------*/
6544eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
6545{
6546 eHalStatus status = eHAL_STATUS_SUCCESS;
6547 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6548 tANI_U16 len;
6549
6550 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6551 {
6552 tpSirUpdateParams pMsg;
6553 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006554
6555 if(!pSession)
6556 {
6557 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6558 return eHAL_STATUS_FAILURE;
6559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006560
6561 if( !pSession->sessionActive )
6562 VOS_ASSERT(0);
6563
6564 /* Create the message and send to lim */
6565 len = sizeof(tSirUpdateParams);
6566 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
6567 if(HAL_STATUS_SUCCESS(status))
6568 {
6569 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirUpdateParams) );
6570 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
6571 pMsg->length = len;
6572 /* Data starts from here */
6573 pMsg->sessionId = sessionId;
6574 pMsg->ssidHidden = ssidHidden;
6575 status = palSendMBMessage(pMac->hHdd, pMsg);
6576 }
6577 sme_ReleaseGlobalLock( &pMac->sme );
6578 }
6579 return status;
6580}
6581#endif
6582
6583/* ---------------------------------------------------------------------------
6584
6585 \fn sme_SetTmLevel
6586 \brief Set Thermal Mitigation Level to RIVA
6587 \param hHal - The handle returned by macOpen.
6588 \param newTMLevel - new Thermal Mitigation Level
6589 \param tmMode - Thermal Mitigation handle mode, default 0
6590 \return eHalStatus
6591 ---------------------------------------------------------------------------*/
6592eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
6593{
6594 eHalStatus status = eHAL_STATUS_SUCCESS;
6595 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6596 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6597 vos_msg_t vosMessage;
6598 tAniSetTmLevelReq *setTmLevelReq = NULL;
6599
6600 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6601 {
6602 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
6603 if(NULL == setTmLevelReq)
6604 {
6605 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6606 "%s: Not able to allocate memory for sme_SetTmLevel", __FUNCTION__);
6607 return eHAL_STATUS_FAILURE;
6608 }
6609
6610 setTmLevelReq->tmMode = tmMode;
6611 setTmLevelReq->newTmLevel = newTMLevel;
6612
6613 /* serialize the req through MC thread */
6614 vosMessage.bodyptr = setTmLevelReq;
6615 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
6616 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6617 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6618 {
6619 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6620 "%s: Post Set TM Level MSG fail", __FUNCTION__);
6621 vos_mem_free(setTmLevelReq);
6622 status = eHAL_STATUS_FAILURE;
6623 }
6624 sme_ReleaseGlobalLock( &pMac->sme );
6625 }
6626 return(status);
6627}
6628
6629/*---------------------------------------------------------------------------
6630
6631 \brief sme_featureCapsExchange() - SME interface to exchange capabilities between
6632 Host and FW.
6633
6634 \param hHal - HAL handle for device
6635
6636 \return NONE
6637
6638---------------------------------------------------------------------------*/
6639void sme_featureCapsExchange( tHalHandle hHal)
6640{
6641 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
6642 WDA_featureCapsExchange(vosContext);
6643}
Jeff Johnsond13512a2012-07-17 11:42:19 -07006644
6645
6646/* ---------------------------------------------------------------------------
6647
6648 \fn sme_GetDefaultCountryCode
6649
6650 \brief Get the default country code from NV
6651
6652 \param hHal
6653 \param pCountry
6654 \- return eHalStatus
6655
6656 -------------------------------------------------------------------------------*/
6657eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
6658{
6659 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6660 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
6661}
6662
6663/* ---------------------------------------------------------------------------
6664
6665 \fn sme_GetCurrentCountryCode
6666
6667 \brief Get the current country code
6668
6669 \param hHal
6670 \param pCountry
6671 \- return eHalStatus
6672
6673 -------------------------------------------------------------------------------*/
6674eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
6675{
6676 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6677 return csrGetCurrentCountryCode(pMac, pCountry);
6678}
6679
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006680/* ---------------------------------------------------------------------------
6681 \fn sme_transportDebug
6682 \brief Dynamically monitoring Transport channels
6683 Private IOCTL will querry transport channel status if driver loaded
6684 \param displaySnapshot Dispaly transport cahnnel snapshot option
6685 \param toggleStallDetect Enable stall detect feature
6686 This feature will take effect to data performance
6687 Not integrate till fully verification
6688 \- return NONE
6689 -------------------------------------------------------------------------*/
6690void sme_transportDebug
6691(
6692 v_BOOL_t displaySnapshot,
6693 v_BOOL_t toggleStallDetect
6694)
6695{
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07006696 WDA_TransportChannelDebug(displaySnapshot, toggleStallDetect);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07006697}