blob: b647296d524fb47f6c67c971a9c4e8a0b073f6c4 [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 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001343 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001344 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
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001356 smsLog(pMac, LOG1, "%s: status=0x%x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 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{
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07001883#if 0
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001884 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
1885 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1886 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
1887 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
1888 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
1889 return eANI_BOOLEAN_FALSE;
1890 default:
1891 return eANI_BOOLEAN_TRUE;
1892 }
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07001893#else
1894 /*
1895 * TODO: always return TRUE for now until
1896 * we figure out why we could be stuck in
1897 * one of the roaming states forever.
1898 */
1899 return eANI_BOOLEAN_TRUE;
1900#endif
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001901}
1902#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001903/* ---------------------------------------------------------------------------
1904 \fn sme_ScanRequest
1905 \brief a wrapper function to Request a 11d or full scan from CSR.
1906 This is an asynchronuous call
1907 \param pScanRequestID - pointer to an object to get back the request ID
1908 \param callback - a callback function that scan calls upon finish, will not
1909 be called if csrScanRequest returns error
1910 \param pContext - a pointer passed in for the callback
1911 \return eHalStatus
1912 ---------------------------------------------------------------------------*/
1913eHalStatus sme_ScanRequest(tHalHandle hHal, tANI_U8 sessionId, tCsrScanRequest *pscanReq,
1914 tANI_U32 *pScanRequestID,
1915 csrScanCompleteCallback callback, void *pContext)
1916{
1917 eHalStatus status = eHAL_STATUS_FAILURE;
1918 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1919
1920 smsLog(pMac, LOG2, FL("enter"));
1921 do
1922 {
1923 if(pMac->scan.fScanEnable)
1924 {
1925 status = sme_AcquireGlobalLock( &pMac->sme );
1926 if ( HAL_STATUS_SUCCESS( status ) )
1927 {
1928 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001929#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07001930 if(csrIsScanAllowed(pMac)) {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001931#endif
1932 status = csrScanRequest( hHal, sessionId, pscanReq,
1933 pScanRequestID, callback, pContext );
1934#ifdef FEATURE_WLAN_LFR
1935 } else {
Madan Mohan Koyyalamudiab4ab0d2012-10-24 14:26:50 -07001936 smsLog(pMac, LOGE, FL("Scan denied in state %d (sub-state %d)"),
1937 pMac->roam.neighborRoamInfo.neighborRoamState,
1938 pMac->roam.curSubState[sessionId]);
1939 /*HandOff is in progress. So schedule this scan later*/
1940 status = eHAL_STATUS_RESOURCES;
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001941 }
1942#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 }
1944
1945 sme_ReleaseGlobalLock( &pMac->sme );
1946 } //sme_AcquireGlobalLock success
1947 } //if(pMac->scan.fScanEnable)
1948 } while( 0 );
1949
1950 return (status);
1951
1952
1953}
1954
1955/* ---------------------------------------------------------------------------
1956 \fn sme_ScanGetResult
1957 \brief a wrapper function to request scan results from CSR.
1958 This is a synchronuous call
1959 \param pFilter - If pFilter is NULL, all cached results are returned
1960 \param phResult - an object for the result.
1961 \return eHalStatus
1962 ---------------------------------------------------------------------------*/
1963eHalStatus sme_ScanGetResult(tHalHandle hHal, tANI_U8 sessionId, tCsrScanResultFilter *pFilter,
1964 tScanResultHandle *phResult)
1965{
1966 eHalStatus status = eHAL_STATUS_FAILURE;
1967 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1968
1969 smsLog(pMac, LOG2, FL("enter"));
1970 status = sme_AcquireGlobalLock( &pMac->sme );
1971 if ( HAL_STATUS_SUCCESS( status ) )
1972 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07001973 status = csrScanGetResult( hHal, pFilter, phResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 sme_ReleaseGlobalLock( &pMac->sme );
1975 }
1976 smsLog(pMac, LOG2, FL("exit status %d"), status);
1977
1978 return (status);
1979}
1980
1981
1982/* ---------------------------------------------------------------------------
1983 \fn sme_ScanFlushResult
1984 \brief a wrapper function to request CSR to clear scan results.
1985 This is a synchronuous call
1986 \return eHalStatus
1987 ---------------------------------------------------------------------------*/
1988eHalStatus sme_ScanFlushResult(tHalHandle hHal, tANI_U8 sessionId)
1989{
1990 eHalStatus status = eHAL_STATUS_FAILURE;
1991 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1992
1993 status = sme_AcquireGlobalLock( &pMac->sme );
1994 if ( HAL_STATUS_SUCCESS( status ) )
1995 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07001996 status = csrScanFlushResult( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 sme_ReleaseGlobalLock( &pMac->sme );
1998 }
1999
2000 return (status);
2001}
2002
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002003eHalStatus sme_ScanFlushP2PResult(tHalHandle hHal, tANI_U8 sessionId)
2004{
2005 eHalStatus status = eHAL_STATUS_FAILURE;
2006 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2007
2008 status = sme_AcquireGlobalLock( &pMac->sme );
2009 if ( HAL_STATUS_SUCCESS( status ) )
2010 {
2011 status = csrScanFlushP2PResult( hHal );
2012 sme_ReleaseGlobalLock( &pMac->sme );
2013 }
2014
2015 return (status);
2016}
Jeff Johnson295189b2012-06-20 16:38:30 -07002017
2018/* ---------------------------------------------------------------------------
2019 \fn sme_ScanResultGetFirst
2020 \brief a wrapper function to request CSR to returns the first element of
2021 scan result.
2022 This is a synchronuous call
2023 \param hScanResult - returned from csrScanGetResult
2024 \return tCsrScanResultInfo * - NULL if no result
2025 ---------------------------------------------------------------------------*/
2026tCsrScanResultInfo *sme_ScanResultGetFirst(tHalHandle hHal,
2027 tScanResultHandle hScanResult)
2028{
2029 eHalStatus status = eHAL_STATUS_FAILURE;
2030 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2031 tCsrScanResultInfo *pRet = NULL;
2032
2033 status = sme_AcquireGlobalLock( &pMac->sme );
2034 if ( HAL_STATUS_SUCCESS( status ) )
2035 {
2036 pRet = csrScanResultGetFirst( pMac, hScanResult );
2037 sme_ReleaseGlobalLock( &pMac->sme );
2038 }
2039
2040 return (pRet);
2041}
2042
2043
2044/* ---------------------------------------------------------------------------
2045 \fn sme_ScanResultGetNext
2046 \brief a wrapper function to request CSR to returns the next element of
2047 scan result. It can be called without calling csrScanResultGetFirst
2048 first
2049 This is a synchronuous call
2050 \param hScanResult - returned from csrScanGetResult
2051 \return Null if no result or reach the end
2052 ---------------------------------------------------------------------------*/
2053tCsrScanResultInfo *sme_ScanResultGetNext(tHalHandle hHal,
2054 tScanResultHandle hScanResult)
2055{
2056 eHalStatus status = eHAL_STATUS_FAILURE;
2057 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2058 tCsrScanResultInfo *pRet = NULL;
2059
2060 status = sme_AcquireGlobalLock( &pMac->sme );
2061 if ( HAL_STATUS_SUCCESS( status ) )
2062 {
2063 pRet = csrScanResultGetNext( pMac, hScanResult );
2064 sme_ReleaseGlobalLock( &pMac->sme );
2065 }
2066
2067 return (pRet);
2068}
2069
2070
2071/* ---------------------------------------------------------------------------
2072 \fn sme_ScanSetBGScanparams
2073 \brief a wrapper function to request CSR to set BG scan params in PE
2074 This is a synchronuous call
2075 \param pScanReq - BG scan request structure
2076 \return eHalStatus
2077 ---------------------------------------------------------------------------*/
2078eHalStatus sme_ScanSetBGScanparams(tHalHandle hHal, tANI_U8 sessionId, tCsrBGScanRequest *pScanReq)
2079{
2080 eHalStatus status = eHAL_STATUS_FAILURE;
2081 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2082
2083 if( NULL != pScanReq )
2084 {
2085 status = sme_AcquireGlobalLock( &pMac->sme );
2086 if ( HAL_STATUS_SUCCESS( status ) )
2087 {
2088 status = csrScanSetBGScanparams( hHal, pScanReq );
2089 sme_ReleaseGlobalLock( &pMac->sme );
2090 }
2091 }
2092
2093 return (status);
2094}
2095
2096
2097/* ---------------------------------------------------------------------------
2098 \fn sme_ScanResultPurge
2099 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
2100 in the list and free memory for each item
2101 This is a synchronuous call
2102 \param hScanResult - returned from csrScanGetResult. hScanResult is
2103 considered gone by
2104 calling this function and even before this function reutrns.
2105 \return eHalStatus
2106 ---------------------------------------------------------------------------*/
2107eHalStatus sme_ScanResultPurge(tHalHandle hHal, tScanResultHandle hScanResult)
2108{
2109 eHalStatus status = eHAL_STATUS_FAILURE;
2110 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2111
2112 status = sme_AcquireGlobalLock( &pMac->sme );
2113 if ( HAL_STATUS_SUCCESS( status ) )
2114 {
2115 status = csrScanResultPurge( hHal, hScanResult );
2116 sme_ReleaseGlobalLock( &pMac->sme );
2117 }
2118
2119 return (status);
2120}
2121
2122/* ---------------------------------------------------------------------------
2123 \fn sme_ScanGetPMKIDCandidateList
2124 \brief a wrapper function to return the PMKID candidate list
2125 This is a synchronuous call
2126 \param pPmkidList - caller allocated buffer point to an array of
2127 tPmkidCandidateInfo
2128 \param pNumItems - pointer to a variable that has the number of
2129 tPmkidCandidateInfo allocated when retruning, this is
2130 either the number needed or number of items put into
2131 pPmkidList
2132 \return eHalStatus - when fail, it usually means the buffer allocated is not
2133 big enough and pNumItems
2134 has the number of tPmkidCandidateInfo.
2135 \Note: pNumItems is a number of tPmkidCandidateInfo,
2136 not sizeof(tPmkidCandidateInfo) * something
2137 ---------------------------------------------------------------------------*/
2138eHalStatus sme_ScanGetPMKIDCandidateList(tHalHandle hHal, tANI_U8 sessionId,
2139 tPmkidCandidateInfo *pPmkidList,
2140 tANI_U32 *pNumItems )
2141{
2142 eHalStatus status = eHAL_STATUS_FAILURE;
2143 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2144
2145 status = sme_AcquireGlobalLock( &pMac->sme );
2146 if ( HAL_STATUS_SUCCESS( status ) )
2147 {
2148 status = csrScanGetPMKIDCandidateList( pMac, sessionId, pPmkidList, pNumItems );
2149 sme_ReleaseGlobalLock( &pMac->sme );
2150 }
2151
2152 return (status);
2153}
2154
2155/*----------------------------------------------------------------------------
2156 \fn sme_RoamRegisterLinkQualityIndCallback
2157
2158 \brief
2159 a wrapper function to allow HDD to register a callback handler with CSR for
2160 link quality indications.
2161
2162 Only one callback may be registered at any time.
2163 In order to deregister the callback, a NULL cback may be provided.
2164
2165 Registration happens in the task context of the caller.
2166
2167 \param callback - Call back being registered
2168 \param pContext - user data
2169
2170 DEPENDENCIES: After CSR open
2171
2172 \return eHalStatus
2173-----------------------------------------------------------------------------*/
2174eHalStatus sme_RoamRegisterLinkQualityIndCallback(tHalHandle hHal, tANI_U8 sessionId,
2175 csrRoamLinkQualityIndCallback callback,
2176 void *pContext)
2177{
2178 return(csrRoamRegisterLinkQualityIndCallback((tpAniSirGlobal)hHal, callback, pContext));
2179}
2180
2181/* ---------------------------------------------------------------------------
2182 \fn sme_RoamRegisterCallback
2183 \brief a wrapper function to allow HDD to register a callback with CSR.
2184 Unlike scan, roam has one callback for all the roam requests
2185 \param callback - a callback function that roam calls upon when state changes
2186 \param pContext - a pointer passed in for the callback
2187 \return eHalStatus
2188 ---------------------------------------------------------------------------*/
2189eHalStatus sme_RoamRegisterCallback(tHalHandle hHal,
2190 csrRoamCompleteCallback callback,
2191 void *pContext)
2192{
2193 return(csrRoamRegisterCallback((tpAniSirGlobal)hHal, callback, pContext));
2194}
2195
2196eCsrPhyMode sme_GetPhyMode(tHalHandle hHal)
2197{
2198 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2199 return pMac->roam.configParam.phyMode;
2200}
2201
2202/* ---------------------------------------------------------------------------
2203 \fn sme_RoamConnect
2204 \brief a wrapper function to request CSR to inititiate an association
2205 This is an asynchronuous call.
2206 \param sessionId - the sessionId returned by sme_OpenSession.
2207 \param pProfile - description of the network to which to connect
2208 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
2209 from csrScanGetResult
2210 \param pRoamId - to get back the request ID
2211 \return eHalStatus
2212 ---------------------------------------------------------------------------*/
2213eHalStatus sme_RoamConnect(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2214 tANI_U32 *pRoamId)
2215{
2216 eHalStatus status = eHAL_STATUS_FAILURE;
2217 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2218
2219 smsLog(pMac, LOG2, FL("enter"));
2220 status = sme_AcquireGlobalLock( &pMac->sme );
2221 if ( HAL_STATUS_SUCCESS( status ) )
2222 {
2223 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2224 {
2225 status = csrRoamConnect( pMac, sessionId, pProfile, NULL, pRoamId );
2226 }
2227 else
2228 {
2229 status = eHAL_STATUS_INVALID_PARAMETER;
2230 }
2231 sme_ReleaseGlobalLock( &pMac->sme );
2232 }
2233
2234 return (status);
2235}
2236
2237/* ---------------------------------------------------------------------------
2238 \fn sme_RoamReassoc
2239 \brief a wrapper function to request CSR to inititiate a re-association
2240 \param pProfile - can be NULL to join the currently connected AP. In that
2241 case modProfileFields should carry the modified field(s) which could trigger
2242 reassoc
2243 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
2244 that might need modification dynamically once STA is up & running and this
2245 could trigger a reassoc
2246 \param pRoamId - to get back the request ID
2247 \return eHalStatus
2248 -------------------------------------------------------------------------------*/
2249eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2250 tCsrRoamModifyProfileFields modProfileFields,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002251 tANI_U32 *pRoamId, v_BOOL_t fForce)
Jeff Johnson295189b2012-06-20 16:38:30 -07002252{
2253 eHalStatus status = eHAL_STATUS_FAILURE;
2254 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2255
2256 smsLog(pMac, LOG2, FL("enter"));
2257 status = sme_AcquireGlobalLock( &pMac->sme );
2258 if ( HAL_STATUS_SUCCESS( status ) )
2259 {
2260 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2261 {
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07002262 if((NULL == pProfile) && (fForce == 1))
2263 {
2264 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2265 /* to force the AP initiate fresh 802.1x authentication need to clear
2266 * the PMKID cache for that set the following boolean. this is needed
2267 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
2268 pSession->fIgnorePMKIDCache = TRUE;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002269 status = csrReassoc( pMac, sessionId, &modProfileFields, pRoamId , fForce);
2270 }
2271 else
2272 {
2273 status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
2274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 }
2276 else
2277 {
2278 status = eHAL_STATUS_INVALID_PARAMETER;
2279 }
2280 sme_ReleaseGlobalLock( &pMac->sme );
2281 }
2282
2283 return (status);
2284}
2285
2286/* ---------------------------------------------------------------------------
2287 \fn sme_RoamConnectToLastProfile
2288 \brief a wrapper function to request CSR to disconnect and reconnect with
2289 the same profile
2290 This is an asynchronuous call.
2291 \return eHalStatus. It returns fail if currently connected
2292 ---------------------------------------------------------------------------*/
2293eHalStatus sme_RoamConnectToLastProfile(tHalHandle hHal, tANI_U8 sessionId)
2294{
2295 eHalStatus status = eHAL_STATUS_FAILURE;
2296 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2297
2298 status = sme_AcquireGlobalLock( &pMac->sme );
2299 if ( HAL_STATUS_SUCCESS( status ) )
2300 {
2301 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2302 {
2303 status = csrRoamConnectToLastProfile( pMac, sessionId );
2304 }
2305 else
2306 {
2307 status = eHAL_STATUS_INVALID_PARAMETER;
2308 }
2309 sme_ReleaseGlobalLock( &pMac->sme );
2310 }
2311
2312 return (status);
2313}
2314
2315/* ---------------------------------------------------------------------------
2316 \fn sme_RoamDisconnect
2317 \brief a wrapper function to request CSR to disconnect from a network
2318 This is an asynchronuous call.
2319 \param reason -- To indicate the reason for disconnecting. Currently, only
2320 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
2321 \return eHalStatus
2322 ---------------------------------------------------------------------------*/
2323eHalStatus sme_RoamDisconnect(tHalHandle hHal, tANI_U8 sessionId, eCsrRoamDisconnectReason reason)
2324{
2325 eHalStatus status = eHAL_STATUS_FAILURE;
2326 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2327
2328 smsLog(pMac, LOG2, FL("enter"));
2329 status = sme_AcquireGlobalLock( &pMac->sme );
2330 if ( HAL_STATUS_SUCCESS( status ) )
2331 {
2332 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2333 {
2334 status = csrRoamDisconnect( pMac, sessionId, reason );
2335 }
2336 else
2337 {
2338 status = eHAL_STATUS_INVALID_PARAMETER;
2339 }
2340 sme_ReleaseGlobalLock( &pMac->sme );
2341 }
2342
2343 return (status);
2344}
2345
2346#ifdef WLAN_SOFTAP_FEATURE
2347/* ---------------------------------------------------------------------------
2348 \fn sme_RoamStopBss
2349 \brief To stop BSS for Soft AP. This is an asynchronous API.
2350 \param hHal - Global structure
2351 \param sessionId - sessionId of SoftAP
2352 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2353 -------------------------------------------------------------------------------*/
2354eHalStatus sme_RoamStopBss(tHalHandle hHal, tANI_U8 sessionId)
2355{
2356 eHalStatus status = eHAL_STATUS_FAILURE;
2357 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2358
2359 smsLog(pMac, LOG2, FL("enter"));
2360 status = sme_AcquireGlobalLock( &pMac->sme );
2361 if ( HAL_STATUS_SUCCESS( status ) )
2362 {
2363 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2364 {
2365 status = csrRoamIssueStopBssCmd( pMac, sessionId, eANI_BOOLEAN_TRUE );
2366 }
2367 else
2368 {
2369 status = eHAL_STATUS_INVALID_PARAMETER;
2370 }
2371 sme_ReleaseGlobalLock( &pMac->sme );
2372 }
2373
2374 return (status);
2375}
2376
2377/* ---------------------------------------------------------------------------
2378 \fn sme_RoamDisconnectSta
2379 \brief To disassociate a station. This is an asynchronous API.
2380 \param hHal - Global structure
2381 \param sessionId - sessionId of SoftAP
2382 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2383 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2384 -------------------------------------------------------------------------------*/
2385eHalStatus sme_RoamDisconnectSta(tHalHandle hHal, tANI_U8 sessionId,
2386 tANI_U8 *pPeerMacAddr)
2387{
2388 eHalStatus status = eHAL_STATUS_FAILURE;
2389 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2390
2391 if ( NULL == pMac )
2392 {
2393 VOS_ASSERT(0);
2394 return status;
2395 }
2396
2397 status = sme_AcquireGlobalLock( &pMac->sme );
2398 if ( HAL_STATUS_SUCCESS( status ) )
2399 {
2400 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2401 {
2402 status = csrRoamIssueDisassociateStaCmd( pMac, sessionId, pPeerMacAddr,
2403 eSIR_MAC_UNSPEC_FAILURE_REASON);
2404 }
2405 else
2406 {
2407 status = eHAL_STATUS_INVALID_PARAMETER;
2408 }
2409 sme_ReleaseGlobalLock( &pMac->sme );
2410 }
2411
2412 return (status);
2413}
2414
2415/* ---------------------------------------------------------------------------
2416 \fn sme_RoamDeauthSta
2417 \brief To disassociate a station. This is an asynchronous API.
2418 \param hHal - Global structure
2419 \param sessionId - sessionId of SoftAP
2420 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2421 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2422 -------------------------------------------------------------------------------*/
2423eHalStatus sme_RoamDeauthSta(tHalHandle hHal, tANI_U8 sessionId,
2424 tANI_U8 *pPeerMacAddr)
2425{
2426 eHalStatus status = eHAL_STATUS_FAILURE;
2427 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2428
2429 if ( NULL == pMac )
2430 {
2431 VOS_ASSERT(0);
2432 return status;
2433 }
2434
2435 status = sme_AcquireGlobalLock( &pMac->sme );
2436 if ( HAL_STATUS_SUCCESS( status ) )
2437 {
2438 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2439 {
2440 status = csrRoamIssueDeauthStaCmd( pMac, sessionId, pPeerMacAddr,
2441 eSIR_MAC_UNSPEC_FAILURE_REASON);
2442 }
2443 else
2444 {
2445 status = eHAL_STATUS_INVALID_PARAMETER;
2446 }
2447 sme_ReleaseGlobalLock( &pMac->sme );
2448 }
2449
2450 return (status);
2451}
2452
2453/* ---------------------------------------------------------------------------
2454 \fn sme_RoamTKIPCounterMeasures
2455 \brief To start or stop TKIP counter measures. This is an asynchronous API.
2456 \param sessionId - sessionId of SoftAP
2457 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2458 \return eHalStatus
2459 -------------------------------------------------------------------------------*/
2460eHalStatus sme_RoamTKIPCounterMeasures(tHalHandle hHal, tANI_U8 sessionId,
2461 tANI_BOOLEAN bEnable)
2462{
2463 eHalStatus status = eHAL_STATUS_FAILURE;
2464 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2465
2466 if ( NULL == pMac )
2467 {
2468 VOS_ASSERT(0);
2469 return status;
2470 }
2471
2472 status = sme_AcquireGlobalLock( &pMac->sme );
2473 if ( HAL_STATUS_SUCCESS( status ) )
2474 {
2475 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2476 {
2477 status = csrRoamIssueTkipCounterMeasures( pMac, sessionId, bEnable);
2478 }
2479 else
2480 {
2481 status = eHAL_STATUS_INVALID_PARAMETER;
2482 }
2483 sme_ReleaseGlobalLock( &pMac->sme );
2484 }
2485
2486 return (status);
2487}
2488
2489/* ---------------------------------------------------------------------------
2490 \fn sme_RoamGetAssociatedStas
2491 \brief To probe the list of associated stations from various modules of CORE stack.
2492 \This is an asynchronous API.
2493 \param sessionId - sessionId of SoftAP
2494 \param modId - Module from whom list of associtated stations is to be probed.
2495 If an invalid module is passed then by default VOS_MODULE_ID_PE will be probed
2496 \param pUsrContext - Opaque HDD context
2497 \param pfnSapEventCallback - Sap event callback in HDD
2498 \param pAssocBuf - Caller allocated memory to be filled with associatd stations info
2499 \return eHalStatus
2500 -------------------------------------------------------------------------------*/
2501eHalStatus sme_RoamGetAssociatedStas(tHalHandle hHal, tANI_U8 sessionId,
2502 VOS_MODULE_ID modId, void *pUsrContext,
2503 void *pfnSapEventCallback, tANI_U8 *pAssocStasBuf)
2504{
2505 eHalStatus status = eHAL_STATUS_FAILURE;
2506 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2507
2508 if ( NULL == pMac )
2509 {
2510 VOS_ASSERT(0);
2511 return status;
2512 }
2513
2514 status = sme_AcquireGlobalLock( &pMac->sme );
2515 if ( HAL_STATUS_SUCCESS( status ) )
2516 {
2517 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2518 {
2519 status = csrRoamGetAssociatedStas( pMac, sessionId, modId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2520 }
2521 else
2522 {
2523 status = eHAL_STATUS_INVALID_PARAMETER;
2524 }
2525 sme_ReleaseGlobalLock( &pMac->sme );
2526 }
2527
2528 return (status);
2529}
2530
2531/* ---------------------------------------------------------------------------
2532 \fn sme_RoamGetWpsSessionOverlap
2533 \brief To get the WPS PBC session overlap information.
2534 \This is an asynchronous API.
2535 \param sessionId - sessionId of SoftAP
2536 \param pUsrContext - Opaque HDD context
2537 \param pfnSapEventCallback - Sap event callback in HDD
2538 \pRemoveMac - pointer to Mac address which needs to be removed from session
2539 \return eHalStatus
2540 -------------------------------------------------------------------------------*/
2541eHalStatus sme_RoamGetWpsSessionOverlap(tHalHandle hHal, tANI_U8 sessionId,
2542 void *pUsrContext, void
2543 *pfnSapEventCallback, v_MACADDR_t pRemoveMac)
2544{
2545 eHalStatus status = eHAL_STATUS_FAILURE;
2546 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2547
2548 if ( NULL == pMac )
2549 {
2550 VOS_ASSERT(0);
2551 return status;
2552 }
2553
2554 status = sme_AcquireGlobalLock( &pMac->sme );
2555 if ( HAL_STATUS_SUCCESS( status ) )
2556 {
2557 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2558 {
2559 status = csrRoamGetWpsSessionOverlap( pMac, sessionId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2560 }
2561 else
2562 {
2563 status = eHAL_STATUS_INVALID_PARAMETER;
2564 }
2565 sme_ReleaseGlobalLock( &pMac->sme );
2566 }
2567
2568 return (status);
2569}
2570
2571#endif
2572
2573/* ---------------------------------------------------------------------------
2574 \fn sme_RoamGetConnectState
2575 \brief a wrapper function to request CSR to return the current connect state
2576 of Roaming
2577 This is a synchronuous call.
2578 \return eHalStatus
2579 ---------------------------------------------------------------------------*/
2580eHalStatus sme_RoamGetConnectState(tHalHandle hHal, tANI_U8 sessionId, eCsrConnectState *pState)
2581{
2582 eHalStatus status = eHAL_STATUS_FAILURE;
2583 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2584
2585 status = sme_AcquireGlobalLock( &pMac->sme );
2586 if ( HAL_STATUS_SUCCESS( status ) )
2587 {
2588 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2589 {
2590 status = csrRoamGetConnectState( pMac, sessionId, pState );
2591 }
2592 else
2593 {
2594 status = eHAL_STATUS_INVALID_PARAMETER;
2595 }
2596 sme_ReleaseGlobalLock( &pMac->sme );
2597 }
2598
2599 return (status);
2600}
2601
2602/* ---------------------------------------------------------------------------
2603 \fn sme_RoamGetConnectProfile
2604 \brief a wrapper function to request CSR to return the current connect
2605 profile. Caller must call csrRoamFreeConnectProfile after it is done
2606 and before reuse for another csrRoamGetConnectProfile call.
2607 This is a synchronuous call.
2608 \param pProfile - pointer to a caller allocated structure
2609 tCsrRoamConnectedProfile
2610 \return eHalStatus. Failure if not connected
2611 ---------------------------------------------------------------------------*/
2612eHalStatus sme_RoamGetConnectProfile(tHalHandle hHal, tANI_U8 sessionId,
2613 tCsrRoamConnectedProfile *pProfile)
2614{
2615 eHalStatus status = eHAL_STATUS_FAILURE;
2616 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2617
2618 status = sme_AcquireGlobalLock( &pMac->sme );
2619 if ( HAL_STATUS_SUCCESS( status ) )
2620 {
2621 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2622 {
2623 status = csrRoamGetConnectProfile( pMac, sessionId, pProfile );
2624 }
2625 else
2626 {
2627 status = eHAL_STATUS_INVALID_PARAMETER;
2628 }
2629 sme_ReleaseGlobalLock( &pMac->sme );
2630 }
2631
2632 return (status);
2633}
2634
2635/* ---------------------------------------------------------------------------
2636 \fn sme_RoamFreeConnectProfile
2637 \brief a wrapper function to request CSR to free and reinitialize the
2638 profile returned previously by csrRoamGetConnectProfile.
2639 This is a synchronuous call.
2640 \param pProfile - pointer to a caller allocated structure
2641 tCsrRoamConnectedProfile
2642 \return eHalStatus.
2643 ---------------------------------------------------------------------------*/
2644eHalStatus sme_RoamFreeConnectProfile(tHalHandle hHal,
2645 tCsrRoamConnectedProfile *pProfile)
2646{
2647 eHalStatus status = eHAL_STATUS_FAILURE;
2648 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2649
2650 status = sme_AcquireGlobalLock( &pMac->sme );
2651 if ( HAL_STATUS_SUCCESS( status ) )
2652 {
2653 status = csrRoamFreeConnectProfile( pMac, pProfile );
2654 sme_ReleaseGlobalLock( &pMac->sme );
2655 }
2656
2657 return (status);
2658}
2659
2660/* ---------------------------------------------------------------------------
2661 \fn sme_RoamSetPMKIDCache
2662 \brief a wrapper function to request CSR to return the PMKID candidate list
2663 This is a synchronuous call.
2664 \param pPMKIDCache - caller allocated buffer point to an array of
2665 tPmkidCacheInfo
2666 \param numItems - a variable that has the number of tPmkidCacheInfo
2667 allocated when retruning, this is either the number needed
2668 or number of items put into pPMKIDCache
2669 \return eHalStatus - when fail, it usually means the buffer allocated is not
2670 big enough and pNumItems has the number of
2671 tPmkidCacheInfo.
2672 \Note: pNumItems is a number of tPmkidCacheInfo,
2673 not sizeof(tPmkidCacheInfo) * something
2674 ---------------------------------------------------------------------------*/
2675eHalStatus sme_RoamSetPMKIDCache( tHalHandle hHal, tANI_U8 sessionId, tPmkidCacheInfo *pPMKIDCache,
2676 tANI_U32 numItems )
2677{
2678 eHalStatus status = eHAL_STATUS_FAILURE;
2679 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2680
2681 status = sme_AcquireGlobalLock( &pMac->sme );
2682 if ( HAL_STATUS_SUCCESS( status ) )
2683 {
2684 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2685 {
2686 status = csrRoamSetPMKIDCache( pMac, sessionId, pPMKIDCache, numItems );
2687 }
2688 else
2689 {
2690 status = eHAL_STATUS_INVALID_PARAMETER;
2691 }
2692 sme_ReleaseGlobalLock( &pMac->sme );
2693 }
2694
2695 return (status);
2696}
2697
2698/* ---------------------------------------------------------------------------
2699 \fn sme_RoamGetSecurityReqIE
2700 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
2701 passes to PE to JOIN request or START_BSS request
2702 This is a synchronuous call.
2703 \param pLen - caller allocated memory that has the length of pBuf as input.
2704 Upon returned, *pLen has the needed or IE length in pBuf.
2705 \param pBuf - Caller allocated memory that contain the IE field, if any,
2706 upon return
2707 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
2708 \return eHalStatus - when fail, it usually means the buffer allocated is not
2709 big enough
2710 ---------------------------------------------------------------------------*/
2711eHalStatus sme_RoamGetSecurityReqIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
2712 tANI_U8 *pBuf, eCsrSecurityType secType)
2713{
2714 eHalStatus status = eHAL_STATUS_FAILURE;
2715 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2716
2717 status = sme_AcquireGlobalLock( &pMac->sme );
2718 if ( HAL_STATUS_SUCCESS( status ) )
2719 {
2720 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2721 {
2722 status = csrRoamGetWpaRsnReqIE( hHal, sessionId, pLen, pBuf );
2723 }
2724 else
2725 {
2726 status = eHAL_STATUS_INVALID_PARAMETER;
2727 }
2728 sme_ReleaseGlobalLock( &pMac->sme );
2729 }
2730
2731 return (status);
2732}
2733
2734/* ---------------------------------------------------------------------------
2735 \fn sme_RoamGetSecurityRspIE
2736 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE from
2737 the beacon or probe rsp if connected
2738 This is a synchronuous call.
2739 \param pLen - caller allocated memory that has the length of pBuf as input.
2740 Upon returned, *pLen has the needed or IE length in pBuf.
2741 \param pBuf - Caller allocated memory that contain the IE field, if any,
2742 upon return
2743 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
2744 \return eHalStatus - when fail, it usually means the buffer allocated is not
2745 big enough
2746 ---------------------------------------------------------------------------*/
2747eHalStatus sme_RoamGetSecurityRspIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
2748 tANI_U8 *pBuf, eCsrSecurityType secType)
2749{
2750 eHalStatus status = eHAL_STATUS_FAILURE;
2751 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2752
2753 status = sme_AcquireGlobalLock( &pMac->sme );
2754 if ( HAL_STATUS_SUCCESS( status ) )
2755 {
2756 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2757 {
2758 status = csrRoamGetWpaRsnRspIE( pMac, sessionId, pLen, pBuf );
2759 }
2760 else
2761 {
2762 status = eHAL_STATUS_INVALID_PARAMETER;
2763 }
2764 sme_ReleaseGlobalLock( &pMac->sme );
2765 }
2766
2767 return (status);
2768
2769}
2770
2771
2772/* ---------------------------------------------------------------------------
2773 \fn sme_RoamGetNumPMKIDCache
2774 \brief a wrapper function to request CSR to return number of PMKID cache
2775 entries
2776 This is a synchronuous call.
2777 \return tANI_U32 - the number of PMKID cache entries
2778 ---------------------------------------------------------------------------*/
2779tANI_U32 sme_RoamGetNumPMKIDCache(tHalHandle hHal, tANI_U8 sessionId)
2780{
2781 eHalStatus status = eHAL_STATUS_FAILURE;
2782 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2783 tANI_U32 numPmkidCache = 0;
2784
2785 status = sme_AcquireGlobalLock( &pMac->sme );
2786 if ( HAL_STATUS_SUCCESS( status ) )
2787 {
2788 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2789 {
2790 numPmkidCache = csrRoamGetNumPMKIDCache( pMac, sessionId );
2791 status = eHAL_STATUS_SUCCESS;
2792 }
2793 else
2794 {
2795 status = eHAL_STATUS_INVALID_PARAMETER;
2796 }
2797 sme_ReleaseGlobalLock( &pMac->sme );
2798 }
2799
2800 return (numPmkidCache);
2801}
2802
2803/* ---------------------------------------------------------------------------
2804 \fn sme_RoamGetPMKIDCache
2805 \brief a wrapper function to request CSR to return PMKID cache from CSR
2806 This is a synchronuous call.
2807 \param pNum - caller allocated memory that has the space of the number of
2808 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
2809 needed or actually number in tPmkidCacheInfo.
2810 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
2811 any, upon return
2812 \return eHalStatus - when fail, it usually means the buffer allocated is not
2813 big enough
2814 ---------------------------------------------------------------------------*/
2815eHalStatus sme_RoamGetPMKIDCache(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pNum,
2816 tPmkidCacheInfo *pPmkidCache)
2817{
2818 eHalStatus status = eHAL_STATUS_FAILURE;
2819 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2820
2821 status = sme_AcquireGlobalLock( &pMac->sme );
2822 if ( HAL_STATUS_SUCCESS( status ) )
2823 {
2824 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2825 {
2826 status = csrRoamGetPMKIDCache( pMac, sessionId, pNum, pPmkidCache );
2827 }
2828 else
2829 {
2830 status = eHAL_STATUS_INVALID_PARAMETER;
2831 }
2832 sme_ReleaseGlobalLock( &pMac->sme );
2833 }
2834
2835 return (status);
2836}
2837
2838
2839/* ---------------------------------------------------------------------------
2840 \fn sme_GetConfigParam
2841 \brief a wrapper function that HDD calls to get the global settings
2842 currently maintained by CSR.
2843 This is a synchronuous call.
2844 \param pParam - caller allocated memory
2845 \return eHalStatus
2846 ---------------------------------------------------------------------------*/
2847eHalStatus sme_GetConfigParam(tHalHandle hHal, tSmeConfigParams *pParam)
2848{
2849 eHalStatus status = eHAL_STATUS_FAILURE;
2850 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2851
2852 status = sme_AcquireGlobalLock( &pMac->sme );
2853 if ( HAL_STATUS_SUCCESS( status ) )
2854 {
2855 status = csrGetConfigParam(pMac, &pParam->csrConfig);
2856 if (status != eHAL_STATUS_SUCCESS)
2857 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002858 smsLog( pMac, LOGE, "%s csrGetConfigParam failed\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 sme_ReleaseGlobalLock( &pMac->sme );
2860 return status;
2861 }
2862#if defined WLAN_FEATURE_P2P_INTERNAL
2863 status = p2pGetConfigParam(pMac, &pParam->p2pConfig);
2864 if (status != eHAL_STATUS_SUCCESS)
2865 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002866 smsLog( pMac, LOGE, "%s p2pGetConfigParam failed\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 sme_ReleaseGlobalLock( &pMac->sme );
2868 return status;
2869 }
2870#endif
2871 sme_ReleaseGlobalLock( &pMac->sme );
2872 }
2873
2874 return (status);
2875}
2876
2877/* ---------------------------------------------------------------------------
2878 \fn sme_CfgSetInt
2879 \brief a wrapper function that HDD calls to set parameters in CFG.
2880 This is a synchronuous call.
2881 \param cfgId - Configuration Parameter ID (type) for STA.
2882 \param ccmValue - The information related to Configuration Parameter ID
2883 which needs to be saved in CFG
2884 \param callback - To be registered by CSR with CCM. Once the CFG done with
2885 saving the information in the database, it notifies CCM &
2886 then the callback will be invoked to notify.
2887 \param toBeSaved - To save the request for future reference
2888 \return eHalStatus
2889 ---------------------------------------------------------------------------*/
2890eHalStatus sme_CfgSetInt(tHalHandle hHal, tANI_U32 cfgId, tANI_U32 ccmValue,
2891 tCcmCfgSetCallback callback, eAniBoolean toBeSaved)
2892{
2893 return(ccmCfgSetInt(hHal, cfgId, ccmValue, callback, toBeSaved));
2894}
2895
2896/* ---------------------------------------------------------------------------
2897 \fn sme_CfgSetStr
2898 \brief a wrapper function that HDD calls to set parameters in CFG.
2899 This is a synchronuous call.
2900 \param cfgId - Configuration Parameter ID (type) for STA.
2901 \param pStr - Pointer to the byte array which carries the information needs
2902 to be saved in CFG
2903 \param length - Length of the data to be saved
2904 \param callback - To be registered by CSR with CCM. Once the CFG done with
2905 saving the information in the database, it notifies CCM &
2906 then the callback will be invoked to notify.
2907 \param toBeSaved - To save the request for future reference
2908 \return eHalStatus
2909 ---------------------------------------------------------------------------*/
2910eHalStatus sme_CfgSetStr(tHalHandle hHal, tANI_U32 cfgId, tANI_U8 *pStr,
2911 tANI_U32 length, tCcmCfgSetCallback callback,
2912 eAniBoolean toBeSaved)
2913{
2914 return(ccmCfgSetStr(hHal, cfgId, pStr, length, callback, toBeSaved));
2915}
2916
2917/* ---------------------------------------------------------------------------
2918 \fn sme_GetModifyProfileFields
2919 \brief HDD or SME - QOS calls this function to get the current values of
2920 connected profile fields, changing which can cause reassoc.
2921 This function must be called after CFG is downloaded and STA is in connected
2922 state. Also, make sure to call this function to get the current profile
2923 fields before calling the reassoc. So that pModifyProfileFields will have
2924 all the latest values plus the one(s) has been updated as part of reassoc
2925 request.
2926 \param pModifyProfileFields - pointer to the connected profile fields
2927 changing which can cause reassoc
2928
2929 \return eHalStatus
2930 -------------------------------------------------------------------------------*/
2931eHalStatus sme_GetModifyProfileFields(tHalHandle hHal, tANI_U8 sessionId,
2932 tCsrRoamModifyProfileFields * pModifyProfileFields)
2933{
2934 eHalStatus status = eHAL_STATUS_FAILURE;
2935 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2936
2937 status = sme_AcquireGlobalLock( &pMac->sme );
2938 if ( HAL_STATUS_SUCCESS( status ) )
2939 {
2940 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2941 {
2942 status = csrGetModifyProfileFields(pMac, sessionId, pModifyProfileFields);
2943 }
2944 else
2945 {
2946 status = eHAL_STATUS_INVALID_PARAMETER;
2947 }
2948 sme_ReleaseGlobalLock( &pMac->sme );
2949 }
2950
2951 return (status);
2952}
2953
2954/*--------------------------------------------------------------------------
2955 \fn sme_SetConfigPowerSave
2956 \brief Wrapper fn to change power save configuration in SME (PMC) module.
2957 For BMPS related configuration, this function also updates the CFG
2958 and sends a message to FW to pick up the new values. Note: Calling
2959 this function only updates the configuration and does not enable
2960 the specified power save mode.
2961 \param hHal - The handle returned by macOpen.
2962 \param psMode - Power Saving mode being modified
2963 \param pConfigParams - a pointer to a caller allocated object of type
2964 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
2965 \return eHalStatus
2966 --------------------------------------------------------------------------*/
2967eHalStatus sme_SetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
2968 void *pConfigParams)
2969{
2970 eHalStatus status = eHAL_STATUS_FAILURE;
2971 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2972
2973 if (NULL == pConfigParams ) {
2974 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
2975 "nothing to update");
2976 return eHAL_STATUS_FAILURE;
2977 }
2978
2979 status = sme_AcquireGlobalLock( &pMac->sme );
2980 if ( HAL_STATUS_SUCCESS( status ) )
2981 {
2982 status = pmcSetConfigPowerSave(hHal, psMode, pConfigParams);
2983 sme_ReleaseGlobalLock( &pMac->sme );
2984 }
2985
2986 return (status);
2987}
2988
2989/*--------------------------------------------------------------------------
2990 \fn sme_GetConfigPowerSave
2991 \brief Wrapper fn to retrieve power save configuration in SME (PMC) module
2992 \param hHal - The handle returned by macOpen.
2993 \param psMode - Power Saving mode
2994 \param pConfigParams - a pointer to a caller allocated object of type
2995 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
2996 \return eHalStatus
2997 --------------------------------------------------------------------------*/
2998eHalStatus sme_GetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
2999 void *pConfigParams)
3000{
3001 eHalStatus status = eHAL_STATUS_FAILURE;
3002 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3003
3004 if (NULL == pConfigParams ) {
3005 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3006 "nothing to update");
3007 return eHAL_STATUS_FAILURE;
3008 }
3009
3010 status = sme_AcquireGlobalLock( &pMac->sme );
3011 if ( HAL_STATUS_SUCCESS( status ) )
3012 {
3013 status = pmcGetConfigPowerSave(hHal, psMode, pConfigParams);
3014 sme_ReleaseGlobalLock( &pMac->sme );
3015 }
3016
3017 return (status);
3018}
3019
3020/* ---------------------------------------------------------------------------
3021 \fn sme_SignalPowerEvent
3022 \brief Signals to PMC that a power event has occurred. Used for putting
3023 the chip into deep sleep mode.
3024 \param hHal - The handle returned by macOpen.
3025 \param event - the event that has occurred
3026 \return eHalStatus
3027 ---------------------------------------------------------------------------*/
3028eHalStatus sme_SignalPowerEvent (tHalHandle hHal, tPmcPowerEvent event)
3029{
3030 eHalStatus status = eHAL_STATUS_FAILURE;
3031 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3032
3033 status = sme_AcquireGlobalLock( &pMac->sme );
3034 if ( HAL_STATUS_SUCCESS( status ) )
3035 {
3036 status = pmcSignalPowerEvent(hHal, event);
3037 sme_ReleaseGlobalLock( &pMac->sme );
3038 }
3039
3040 return (status);
3041}
3042
3043/* ---------------------------------------------------------------------------
3044 \fn sme_EnablePowerSave
3045 \brief Enables one of the power saving modes.
3046 \param hHal - The handle returned by macOpen.
3047 \param psMode - The power saving mode to enable. If BMPS mode is enabled
3048 while the chip is operating in Full Power, PMC will start
3049 a timer that will try to put the chip in BMPS mode after
3050 expiry.
3051 \return eHalStatus
3052 ---------------------------------------------------------------------------*/
3053eHalStatus sme_EnablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3054{
3055 eHalStatus status = eHAL_STATUS_FAILURE;
3056 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3057
3058 status = sme_AcquireGlobalLock( &pMac->sme );
3059 if ( HAL_STATUS_SUCCESS( status ) )
3060 {
3061 status = pmcEnablePowerSave(hHal, psMode);
3062 sme_ReleaseGlobalLock( &pMac->sme );
3063 }
3064
3065 return (status);
3066}
3067
3068/* ---------------------------------------------------------------------------
3069 \fn sme_DisablePowerSave
3070 \brief Disables one of the power saving modes.
3071 \param hHal - The handle returned by macOpen.
3072 \param psMode - The power saving mode to disable. Disabling does not imply
3073 that device will be brought out of the current PS mode. This
3074 is purely a configuration API.
3075 \return eHalStatus
3076 ---------------------------------------------------------------------------*/
3077eHalStatus sme_DisablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3078{
3079 eHalStatus status = eHAL_STATUS_FAILURE;
3080 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3081
3082 status = sme_AcquireGlobalLock( &pMac->sme );
3083 if ( HAL_STATUS_SUCCESS( status ) )
3084 {
3085 status = pmcDisablePowerSave(hHal, psMode);
3086 sme_ReleaseGlobalLock( &pMac->sme );
3087 }
3088
3089 return (status);
3090 }
3091
3092/* ---------------------------------------------------------------------------
3093 \fn sme_StartAutoBmpsTimer
3094 \brief Starts a timer that periodically polls all the registered
3095 module for entry into Bmps mode. This timer is started only if BMPS is
3096 enabled and whenever the device is in full power.
3097 \param hHal - The handle returned by macOpen.
3098 \return eHalStatus
3099 ---------------------------------------------------------------------------*/
3100eHalStatus sme_StartAutoBmpsTimer ( tHalHandle hHal)
3101{
3102 eHalStatus status = eHAL_STATUS_FAILURE;
3103 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3104
3105 status = sme_AcquireGlobalLock( &pMac->sme );
3106 if ( HAL_STATUS_SUCCESS( status ) )
3107 {
3108 status = pmcStartAutoBmpsTimer(hHal);
3109 sme_ReleaseGlobalLock( &pMac->sme );
3110 }
3111
3112 return (status);
3113}
3114/* ---------------------------------------------------------------------------
3115 \fn sme_StopAutoBmpsTimer
3116 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
3117 Stopping the timer does not cause a device state change. Only the timer
3118 is stopped. If "Full Power" is desired, use the sme_RequestFullPower API
3119 \param hHal - The handle returned by macOpen.
3120 \return eHalStatus
3121 ---------------------------------------------------------------------------*/
3122eHalStatus sme_StopAutoBmpsTimer ( tHalHandle hHal)
3123{
3124 eHalStatus status = eHAL_STATUS_FAILURE;
3125 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3126
3127 status = sme_AcquireGlobalLock( &pMac->sme );
3128 if ( HAL_STATUS_SUCCESS( status ) )
3129 {
3130 status = pmcStopAutoBmpsTimer(hHal);
3131 sme_ReleaseGlobalLock( &pMac->sme );
3132 }
3133
3134 return (status);
3135}
3136/* ---------------------------------------------------------------------------
3137 \fn sme_QueryPowerState
3138 \brief Returns the current power state of the device.
3139 \param hHal - The handle returned by macOpen.
3140 \param pPowerState - pointer to location to return power state (LOW or HIGH)
3141 \param pSwWlanSwitchState - ptr to location to return SW WLAN Switch state
3142 \return eHalStatus
3143 ---------------------------------------------------------------------------*/
3144eHalStatus sme_QueryPowerState (
3145 tHalHandle hHal,
3146 tPmcPowerState *pPowerState,
3147 tPmcSwitchState *pSwWlanSwitchState)
3148{
3149 eHalStatus status = eHAL_STATUS_FAILURE;
3150 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3151
3152 status = sme_AcquireGlobalLock( &pMac->sme );
3153 if ( HAL_STATUS_SUCCESS( status ) )
3154 {
3155 status = pmcQueryPowerState (hHal, pPowerState, NULL, pSwWlanSwitchState);
3156 sme_ReleaseGlobalLock( &pMac->sme );
3157 }
3158
3159 return (status);
3160}
3161
3162/* ---------------------------------------------------------------------------
3163 \fn sme_IsPowerSaveEnabled
3164 \brief Checks if the device is able to enter a particular power save mode
3165 This does not imply that the device is in a particular PS mode
3166 \param hHal - The handle returned by macOpen.
3167 \param psMode - the power saving mode
3168 \return eHalStatus
3169 ---------------------------------------------------------------------------*/
3170tANI_BOOLEAN sme_IsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
3171{
3172 eHalStatus status = eHAL_STATUS_FAILURE;
3173 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3174 tANI_BOOLEAN result = false;
3175
3176 status = sme_AcquireGlobalLock( &pMac->sme );
3177 if ( HAL_STATUS_SUCCESS( status ) )
3178 {
3179 result = pmcIsPowerSaveEnabled(hHal, psMode);
3180 sme_ReleaseGlobalLock( &pMac->sme );
3181 return result;
3182 }
3183
3184 return false;
3185}
3186
3187/* ---------------------------------------------------------------------------
3188 \fn sme_RequestFullPower
3189 \brief Request that the device be brought to full power state. When the
3190 device enters Full Power PMC will start a BMPS timer if BMPS PS mode
3191 is enabled. On timer expiry PMC will attempt to put the device in
3192 BMPS mode if following holds true:
3193 - BMPS mode is enabled
3194 - Polling of all modules through the Power Save Check routine passes
3195 - STA is associated to an access point
3196 \param hHal - The handle returned by macOpen.
3197 \param - callbackRoutine Callback routine invoked in case of success/failure
3198 \return eHalStatus - status
3199 eHAL_STATUS_SUCCESS - device brought to full power state
3200 eHAL_STATUS_FAILURE - device cannot be brought to full power state
3201 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
3202 ---------------------------------------------------------------------------*/
3203eHalStatus sme_RequestFullPower (
3204 tHalHandle hHal,
3205 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3206 void *callbackContext,
3207 tRequestFullPowerReason fullPowerReason)
3208{
3209 eHalStatus status = eHAL_STATUS_FAILURE;
3210 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3211
3212 status = sme_AcquireGlobalLock( &pMac->sme );
3213 if ( HAL_STATUS_SUCCESS( status ) )
3214 {
3215 status = pmcRequestFullPower(hHal, callbackRoutine, callbackContext, fullPowerReason);
3216 sme_ReleaseGlobalLock( &pMac->sme );
3217 }
3218
3219 return (status);
3220}
3221
3222/* ---------------------------------------------------------------------------
3223 \fn sme_RequestBmps
3224 \brief Request that the device be put in BMPS state. Request will be
3225 accepted only if BMPS mode is enabled and power save check routine
3226 passes.
3227 \param hHal - The handle returned by macOpen.
3228 \param - callbackRoutine Callback routine invoked in case of success/failure
3229 \return eHalStatus
3230 eHAL_STATUS_SUCCESS - device is in BMPS state
3231 eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
3232 eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state
3233 ---------------------------------------------------------------------------*/
3234eHalStatus sme_RequestBmps (
3235 tHalHandle hHal,
3236 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3237 void *callbackContext)
3238{
3239 eHalStatus status = eHAL_STATUS_FAILURE;
3240 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3241
3242 status = sme_AcquireGlobalLock( &pMac->sme );
3243 if ( HAL_STATUS_SUCCESS( status ) )
3244 {
3245 status = pmcRequestBmps(hHal, callbackRoutine, callbackContext);
3246 sme_ReleaseGlobalLock( &pMac->sme );
3247 }
3248
3249 return (status);
3250}
3251
3252
3253/* ---------------------------------------------------------------------------
3254 \fn sme_SetDHCPTillPowerActiveFlag
3255 \brief Sets/Clears DHCP related flag in PMC to disable/enable auto BMPS
3256 entry by PMC
3257 \param hHal - The handle returned by macOpen.
3258 ---------------------------------------------------------------------------*/
3259void sme_SetDHCPTillPowerActiveFlag(tHalHandle hHal, tANI_U8 flag)
3260{
3261 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3262
3263 // Set/Clear the DHCP flag which will disable/enable auto BMPS entery by PMC
3264 pMac->pmc.remainInPowerActiveTillDHCP = flag;
3265}
3266
3267
3268/* ---------------------------------------------------------------------------
3269 \fn sme_StartUapsd
3270 \brief Request that the device be put in UAPSD state. If the device is in
3271 Full Power it will be put in BMPS mode first and then into UAPSD
3272 mode.
3273 \param hHal - The handle returned by macOpen.
3274 \param - callbackRoutine Callback routine invoked in case of success/failure
3275 eHAL_STATUS_SUCCESS - device is in UAPSD state
3276 eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
3277 eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
3278 eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
3279 \return eHalStatus
3280 ---------------------------------------------------------------------------*/
3281eHalStatus sme_StartUapsd (
3282 tHalHandle hHal,
3283 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3284 void *callbackContext)
3285{
3286 eHalStatus status = eHAL_STATUS_FAILURE;
3287 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3288
3289 status = sme_AcquireGlobalLock( &pMac->sme );
3290 if ( HAL_STATUS_SUCCESS( status ) )
3291 {
3292 status = pmcStartUapsd(hHal, callbackRoutine, callbackContext);
3293 sme_ReleaseGlobalLock( &pMac->sme );
3294 }
3295
3296 return (status);
3297 }
3298
3299/* ---------------------------------------------------------------------------
3300 \fn sme_StopUapsd
3301 \brief Request that the device be put out of UAPSD state. Device will be
3302 put in in BMPS state after stop UAPSD completes.
3303 \param hHal - The handle returned by macOpen.
3304 \return eHalStatus
3305 eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
3306 eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
3307 ---------------------------------------------------------------------------*/
3308eHalStatus sme_StopUapsd (tHalHandle hHal)
3309{
3310 eHalStatus status = eHAL_STATUS_FAILURE;
3311 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3312
3313 status = sme_AcquireGlobalLock( &pMac->sme );
3314 if ( HAL_STATUS_SUCCESS( status ) )
3315 {
3316 status = pmcStopUapsd(hHal);
3317 sme_ReleaseGlobalLock( &pMac->sme );
3318 }
3319
3320 return (status);
3321}
3322
3323/* ---------------------------------------------------------------------------
3324 \fn sme_RequestStandby
3325 \brief Request that the device be put in standby. It is HDD's responsibility
3326 to bring the chip to full power and do a disassoc before calling
3327 this API.
3328 \param hHal - The handle returned by macOpen.
3329 \param - callbackRoutine Callback routine invoked in case of success/failure
3330 \return eHalStatus
3331 eHAL_STATUS_SUCCESS - device is in Standby mode
3332 eHAL_STATUS_FAILURE - device cannot be put in standby mode
3333 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
3334 ---------------------------------------------------------------------------*/
3335eHalStatus sme_RequestStandby (
3336 tHalHandle hHal,
3337 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3338 void *callbackContext)
3339{
3340 eHalStatus status = eHAL_STATUS_FAILURE;
3341 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3342
3343 smsLog( pMac, LOG1, FL("") );
3344 status = sme_AcquireGlobalLock( &pMac->sme );
3345 if ( HAL_STATUS_SUCCESS( status ) )
3346 {
3347 status = pmcRequestStandby(hHal, callbackRoutine, callbackContext);
3348 sme_ReleaseGlobalLock( &pMac->sme );
3349 }
3350
3351 return (status);
3352}
3353
3354/* ---------------------------------------------------------------------------
3355 \fn sme_RegisterPowerSaveCheck
3356 \brief Register a power save check routine that is called whenever
3357 the device is about to enter one of the power save modes.
3358 \param hHal - The handle returned by macOpen.
3359 \param checkRoutine - Power save check routine to be registered
3360 \return eHalStatus
3361 eHAL_STATUS_SUCCESS - successfully registered
3362 eHAL_STATUS_FAILURE - not successfully registered
3363 ---------------------------------------------------------------------------*/
3364eHalStatus sme_RegisterPowerSaveCheck (
3365 tHalHandle hHal,
3366 tANI_BOOLEAN (*checkRoutine) (void *checkContext), void *checkContext)
3367{
3368 eHalStatus status = eHAL_STATUS_FAILURE;
3369 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3370
3371 status = sme_AcquireGlobalLock( &pMac->sme );
3372 if ( HAL_STATUS_SUCCESS( status ) )
3373 {
3374 status = pmcRegisterPowerSaveCheck (hHal, checkRoutine, checkContext);
3375 sme_ReleaseGlobalLock( &pMac->sme );
3376 }
3377
3378 return (status);
3379}
3380
3381/* ---------------------------------------------------------------------------
3382 \fn sme_DeregisterPowerSaveCheck
3383 \brief Deregister a power save check routine
3384 \param hHal - The handle returned by macOpen.
3385 \param checkRoutine - Power save check routine to be deregistered
3386 \return eHalStatus
3387 eHAL_STATUS_SUCCESS - successfully deregistered
3388 eHAL_STATUS_FAILURE - not successfully deregistered
3389 ---------------------------------------------------------------------------*/
3390eHalStatus sme_DeregisterPowerSaveCheck (
3391 tHalHandle hHal,
3392 tANI_BOOLEAN (*checkRoutine) (void *checkContext))
3393{
3394 eHalStatus status = eHAL_STATUS_FAILURE;
3395 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3396
3397 status = sme_AcquireGlobalLock( &pMac->sme );
3398 if ( HAL_STATUS_SUCCESS( status ) )
3399 {
3400 status = pmcDeregisterPowerSaveCheck (hHal, checkRoutine);
3401 sme_ReleaseGlobalLock( &pMac->sme );
3402 }
3403
3404 return (status);
3405}
3406
3407/* ---------------------------------------------------------------------------
3408 \fn sme_RegisterDeviceStateUpdateInd
3409 \brief Register a callback routine that is called whenever
3410 the device enters a new device state (Full Power, BMPS, UAPSD)
3411 \param hHal - The handle returned by macOpen.
3412 \param callbackRoutine - Callback routine to be registered
3413 \param callbackContext - Cookie to be passed back during callback
3414 \return eHalStatus
3415 eHAL_STATUS_SUCCESS - successfully registered
3416 eHAL_STATUS_FAILURE - not successfully registered
3417 ---------------------------------------------------------------------------*/
3418eHalStatus sme_RegisterDeviceStateUpdateInd (
3419 tHalHandle hHal,
3420 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
3421 void *callbackContext)
3422{
3423 eHalStatus status = eHAL_STATUS_FAILURE;
3424 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3425
3426 status = sme_AcquireGlobalLock( &pMac->sme );
3427 if ( HAL_STATUS_SUCCESS( status ) )
3428 {
3429 status = pmcRegisterDeviceStateUpdateInd (hHal, callbackRoutine, callbackContext);
3430 sme_ReleaseGlobalLock( &pMac->sme );
3431 }
3432
3433 return (status);
3434}
3435
3436/* ---------------------------------------------------------------------------
3437 \fn sme_DeregisterDeviceStateUpdateInd
3438 \brief Deregister a routine that was registered for device state changes
3439 \param hHal - The handle returned by macOpen.
3440 \param callbackRoutine - Callback routine to be deregistered
3441 \return eHalStatus
3442 eHAL_STATUS_SUCCESS - successfully deregistered
3443 eHAL_STATUS_FAILURE - not successfully deregistered
3444 ---------------------------------------------------------------------------*/
3445eHalStatus sme_DeregisterDeviceStateUpdateInd (
3446 tHalHandle hHal,
3447 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
3448{
3449 eHalStatus status = eHAL_STATUS_FAILURE;
3450 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3451
3452 status = sme_AcquireGlobalLock( &pMac->sme );
3453 if ( HAL_STATUS_SUCCESS( status ) )
3454 {
3455 status = pmcDeregisterDeviceStateUpdateInd (hHal, callbackRoutine);
3456 sme_ReleaseGlobalLock( &pMac->sme );
3457 }
3458
3459 return (status);
3460}
3461
3462/* ---------------------------------------------------------------------------
3463 \fn sme_WowlAddBcastPattern
3464 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
3465 do a pattern match on these patterns when Wowl is enabled during BMPS
3466 mode. Note that Firmware performs the pattern matching only on
3467 broadcast frames and while Libra is in BMPS mode.
3468 \param hHal - The handle returned by macOpen.
3469 \param pattern - Pattern to be added
3470 \return eHalStatus
3471 eHAL_STATUS_FAILURE Cannot add pattern
3472 eHAL_STATUS_SUCCESS Request accepted.
3473 ---------------------------------------------------------------------------*/
3474eHalStatus sme_WowlAddBcastPattern (
3475 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003476 tpSirWowlAddBcastPtrn pattern,
3477 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003478{
3479 eHalStatus status = eHAL_STATUS_FAILURE;
3480 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3481 status = sme_AcquireGlobalLock( &pMac->sme );
3482 if ( HAL_STATUS_SUCCESS( status ) )
3483 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003484 status = pmcWowlAddBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 sme_ReleaseGlobalLock( &pMac->sme );
3486 }
3487
3488 return (status);
3489}
3490
3491/* ---------------------------------------------------------------------------
3492 \fn sme_WowlDelBcastPattern
3493 \brief Delete a pattern that was added for Pattern Byte Matching.
3494 \param hHal - The handle returned by macOpen.
3495 \param pattern - Pattern to be deleted
3496 \return eHalStatus
3497 eHAL_STATUS_FAILURE Cannot delete pattern
3498 eHAL_STATUS_SUCCESS Request accepted.
3499 ---------------------------------------------------------------------------*/
3500eHalStatus sme_WowlDelBcastPattern (
3501 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003502 tpSirWowlDelBcastPtrn pattern,
3503 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003504{
3505 eHalStatus status = eHAL_STATUS_FAILURE;
3506 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3507 status = sme_AcquireGlobalLock( &pMac->sme );
3508 if ( HAL_STATUS_SUCCESS( status ) )
3509 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003510 status = pmcWowlDelBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 sme_ReleaseGlobalLock( &pMac->sme );
3512 }
3513
3514 return (status);
3515}
3516
3517/* ---------------------------------------------------------------------------
3518 \fn sme_EnterWowl
3519 \brief This is the SME API exposed to HDD to request enabling of WOWL mode.
3520 WoWLAN works on top of BMPS mode. If the device is not in BMPS mode,
3521 SME will will cache the information that WOWL has been enabled and
3522 attempt to put the device in BMPS. On entry into BMPS, SME will
3523 enable the WOWL mode.
3524 Note 1: If we exit BMPS mode (someone requests full power), we
3525 will NOT resume WOWL when we go back to BMPS again. Request for full
3526 power (while in WOWL mode) means disable WOWL and go to full power.
3527 Note 2: Both UAPSD and WOWL work on top of BMPS. On entry into BMPS, SME
3528 will give priority to UAPSD and enable only UAPSD if both UAPSD and WOWL
3529 are required. Currently there is no requirement or use case to support
3530 UAPSD and WOWL at the same time.
3531
3532 \param hHal - The handle returned by macOpen.
3533 \param enterWowlCallbackRoutine - Callback routine provided by HDD.
3534 Used for success/failure notification by SME
3535 \param enterWowlCallbackContext - A cookie passed by HDD, that is passed back to HDD
3536 at the time of callback.
3537 \param wakeReasonIndCB - Callback routine provided by HDD.
3538 Used for Wake Reason Indication by SME
3539 \param wakeReasonIndCBContext - A cookie passed by HDD, that is passed back to HDD
3540 at the time of callback.
3541 \return eHalStatus
3542 eHAL_STATUS_SUCCESS Device is already in WoWLAN mode
3543 eHAL_STATUS_FAILURE Device cannot enter WoWLAN mode.
3544 eHAL_STATUS_PMC_PENDING Request accepted. SME will enable WOWL after
3545 BMPS mode is entered.
3546 ---------------------------------------------------------------------------*/
3547eHalStatus sme_EnterWowl (
3548 tHalHandle hHal,
3549 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
3550 void *enterWowlCallbackContext,
3551#ifdef WLAN_WAKEUP_EVENTS
3552 void (*wakeIndicationCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
3553 void *wakeIndicationCBContext,
3554#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003555 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003556{
3557 eHalStatus status = eHAL_STATUS_FAILURE;
3558 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3559 status = sme_AcquireGlobalLock( &pMac->sme );
3560 if ( HAL_STATUS_SUCCESS( status ) )
3561 {
3562 status = pmcEnterWowl (hHal, enterWowlCallbackRoutine, enterWowlCallbackContext,
3563#ifdef WLAN_WAKEUP_EVENTS
3564 wakeIndicationCB, wakeIndicationCBContext,
3565#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003566 wowlEnterParams, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 sme_ReleaseGlobalLock( &pMac->sme );
3568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 return (status);
3570}
3571/* ---------------------------------------------------------------------------
3572 \fn sme_ExitWowl
3573 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
3574 SME will initiate exit from WoWLAN mode and device will be put in BMPS
3575 mode.
3576 \param hHal - The handle returned by macOpen.
3577 \return eHalStatus
3578 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
3579 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
3580 ---------------------------------------------------------------------------*/
3581eHalStatus sme_ExitWowl (tHalHandle hHal)
3582{
3583 eHalStatus status = eHAL_STATUS_FAILURE;
3584 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3585 status = sme_AcquireGlobalLock( &pMac->sme );
3586 if ( HAL_STATUS_SUCCESS( status ) )
3587 {
3588 status = pmcExitWowl (hHal);
3589 sme_ReleaseGlobalLock( &pMac->sme );
3590 }
3591
3592 return (status);
3593}
3594
3595/* ---------------------------------------------------------------------------
3596
3597 \fn sme_RoamSetKey
3598
3599 \brief To set encryption key. This function should be called only when connected
3600 This is an asynchronous API.
3601
3602 \param pSetKeyInfo - pointer to a caller allocated object of tCsrSetContextInfo
3603
3604 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3605
3606 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3607
3608 FAILURE or RESOURCES The API finished and failed.
3609
3610 -------------------------------------------------------------------------------*/
3611eHalStatus sme_RoamSetKey(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 *pRoamId)
3612{
3613 eHalStatus status = eHAL_STATUS_FAILURE;
3614 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3615 tANI_U32 roamId;
3616#ifdef WLAN_SOFTAP_FEATURE
3617 tANI_U32 i;
3618 tCsrRoamSession *pSession = NULL;
3619#endif
3620
3621 status = sme_AcquireGlobalLock( &pMac->sme );
3622 if ( HAL_STATUS_SUCCESS( status ) )
3623 {
3624 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3625 if(pRoamId)
3626 {
3627 *pRoamId = roamId;
3628 }
3629
3630#ifdef WLAN_SOFTAP_FEATURE
3631 smsLog(pMac, LOG2, FL("keyLength\n"), pSetKey->keyLength);
3632
3633 for(i=0; i<pSetKey->keyLength; i++)
3634 smsLog(pMac, LOG2, FL("%02x"), pSetKey->Key[i]);
3635
3636 smsLog(pMac, LOG2, "\n sessionId=%d roamId=%d\n", sessionId, roamId);
3637
3638 pSession = CSR_GET_SESSION(pMac, sessionId);
3639
Jeff Johnson32d95a32012-09-10 13:15:23 -07003640 if(!pSession)
3641 {
3642 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3643 return eHAL_STATUS_FAILURE;
3644 }
3645
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
3647 {
3648 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
3649 {
3650 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
3651 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
3652 {
3653 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3654 }
3655 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
3656 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
3657 {
3658 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3659 }
3660 }
3661 }
3662#endif
3663
3664 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
3665 sme_ReleaseGlobalLock( &pMac->sme );
3666 }
3667
3668 return (status);
3669}
3670
3671
3672/* ---------------------------------------------------------------------------
3673
3674 \fn sme_RoamRemoveKey
3675
3676 \brief To set encryption key. This is an asynchronous API.
3677
3678 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
3679
3680 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3681
3682 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3683
3684 FAILURE or RESOURCES The API finished and failed.
3685
3686 -------------------------------------------------------------------------------*/
3687eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
3688 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
3689{
3690 eHalStatus status = eHAL_STATUS_FAILURE;
3691 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3692 tANI_U32 roamId;
3693
3694 status = sme_AcquireGlobalLock( &pMac->sme );
3695 if ( HAL_STATUS_SUCCESS( status ) )
3696 {
3697 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3698 if(pRoamId)
3699 {
3700 *pRoamId = roamId;
3701 }
3702 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
3703 sme_ReleaseGlobalLock( &pMac->sme );
3704 }
3705
3706 return (status);
3707}
3708
3709/* ---------------------------------------------------------------------------
3710 \fn sme_GetRssi
3711 \brief a wrapper function that client calls to register a callback to get RSSI
3712
3713 \param callback - SME sends back the requested stats using the callback
3714 \param staId - The station ID for which the stats is requested for
3715 \param pContext - user context to be passed back along with the callback
3716 \param pVosContext - vos context
3717 \return eHalStatus
3718 ---------------------------------------------------------------------------*/
3719eHalStatus sme_GetRssi(tHalHandle hHal,
3720 tCsrRssiCallback callback,
3721 tANI_U8 staId, tCsrBssid bssId,
3722 void *pContext, void* pVosContext)
3723{
3724 eHalStatus status = eHAL_STATUS_FAILURE;
3725 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3726
3727 status = sme_AcquireGlobalLock( &pMac->sme );
3728 if ( HAL_STATUS_SUCCESS( status ) )
3729 {
3730 status = csrGetRssi( pMac, callback,
3731 staId, bssId, pContext, pVosContext);
3732 sme_ReleaseGlobalLock( &pMac->sme );
3733 }
3734 return (status);
3735}
3736
3737/* ---------------------------------------------------------------------------
3738 \fn sme_GetStatistics
3739 \brief a wrapper function that client calls to register a callback to get
3740 different PHY level statistics from CSR.
3741
3742 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
3743 \param statsMask - The different category/categories of stats requester is looking for
3744 \param callback - SME sends back the requested stats using the callback
3745 \param periodicity - If requester needs periodic update in millisec, 0 means
3746 it's an one time request
3747 \param cache - If requester is happy with cached stats
3748 \param staId - The station ID for which the stats is requested for
3749 \param pContext - user context to be passed back along with the callback
3750 \return eHalStatus
3751 ---------------------------------------------------------------------------*/
3752eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
3753 tANI_U32 statsMask,
3754 tCsrStatsCallback callback,
3755 tANI_U32 periodicity, tANI_BOOLEAN cache,
3756 tANI_U8 staId, void *pContext)
3757{
3758 eHalStatus status = eHAL_STATUS_FAILURE;
3759 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3760
3761 status = sme_AcquireGlobalLock( &pMac->sme );
3762 if ( HAL_STATUS_SUCCESS( status ) )
3763 {
3764 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
3765 periodicity, cache, staId, pContext);
3766 sme_ReleaseGlobalLock( &pMac->sme );
3767 }
3768
3769 return (status);
3770
3771}
3772
3773/* ---------------------------------------------------------------------------
3774
3775 \fn sme_GetCountryCode
3776
3777 \brief To return the current country code. If no country code is applied, default country code is
3778 used to fill the buffer.
3779 If 11d supported is turned off, an error is return and the last applied/default country code is used.
3780 This is a synchronous API.
3781
3782 \param pBuf - pointer to a caller allocated buffer for returned country code.
3783
3784 \param pbLen For input, this parameter indicates how big is the buffer.
3785 Upon return, this parameter has the number of bytes for country. If pBuf
3786 doesn't have enough space, this function returns
3787 fail status and this parameter contains the number that is needed.
3788
3789 \return eHalStatus SUCCESS.
3790
3791 FAILURE or RESOURCES The API finished and failed.
3792
3793 -------------------------------------------------------------------------------*/
3794eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
3795{
3796 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3797
3798 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
3799}
3800
3801
3802/* ---------------------------------------------------------------------------
3803
3804 \fn sme_SetCountryCode
3805
3806 \brief To change the current/default country code.
3807 If 11d supported is turned off, an error is return.
3808 This is a synchronous API.
3809
3810 \param pCountry - pointer to a caller allocated buffer for the country code.
3811
3812 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
3813 whether a reset is required.
3814
3815 \return eHalStatus SUCCESS.
3816
3817 FAILURE or RESOURCES The API finished and failed.
3818
3819 -------------------------------------------------------------------------------*/
3820eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
3821{
3822 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3823
3824 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
3825}
3826
3827
3828/* ---------------------------------------------------------------------------
3829 \fn sme_ResetCountryCodeInformation
3830 \brief this function is to reset the country code current being used back to EEPROM default
3831 this includes channel list and power setting. This is a synchronous API.
3832 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
3833 a restart is needed to apply the change
3834 \return eHalStatus
3835 -------------------------------------------------------------------------------*/
3836eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
3837{
3838 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3839
3840 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
3841}
3842
3843
3844/* ---------------------------------------------------------------------------
3845 \fn sme_GetSupportedCountryCode
3846 \brief this function is to get a list of the country code current being supported
3847 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
3848 this has the country code list. 3 bytes for each country code. This may be NULL if
3849 caller wants to know the needed byte count.
3850 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
3851 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
3852 \return eHalStatus
3853 -------------------------------------------------------------------------------*/
3854eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
3855{
3856 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3857
3858 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
3859}
3860
3861
3862/* ---------------------------------------------------------------------------
3863 \fn sme_GetCurrentRegulatoryDomain
3864 \brief this function is to get the current regulatory domain. This is a synchronous API.
3865 This function must be called after CFG is downloaded and all the band/mode setting already passed into
3866 SME. The function fails if 11d support is turned off.
3867 \param pDomain - Caller allocated buffer to return the current domain.
3868 \return eHalStatus SUCCESS.
3869
3870 FAILURE or RESOURCES The API finished and failed.
3871 -------------------------------------------------------------------------------*/
3872eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
3873{
3874 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3875 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
3876
3877 if( pDomain )
3878 {
3879 if( csrIs11dSupported( pMac ) )
3880 {
3881 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
3882 status = eHAL_STATUS_SUCCESS;
3883 }
3884 else
3885 {
3886 status = eHAL_STATUS_FAILURE;
3887 }
3888 }
3889
3890 return ( status );
3891}
3892
3893
3894/* ---------------------------------------------------------------------------
3895 \fn sme_SetRegulatoryDomain
3896 \brief this function is to set the current regulatory domain.
3897 This function must be called after CFG is downloaded and all the band/mode setting already passed into
3898 SME. This is a synchronous API.
3899 \param domainId - indicate the domain (defined in the driver) needs to set to.
3900 See v_REGDOMAIN_t for definition
3901 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
3902 a restart is needed to apply the change
3903 \return eHalStatus
3904 -------------------------------------------------------------------------------*/
3905eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
3906{
3907 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3908
3909 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
3910}
3911
3912
3913/* ---------------------------------------------------------------------------
3914
3915 \fn sme_GetRegulatoryDomainForCountry
3916
3917 \brief To return a regulatory domain base on a country code. This is a synchronous API.
3918
3919 \param pCountry - pointer to a caller allocated buffer for input country code.
3920
3921 \param pDomainId Upon successful return, it is the domain that country belongs to.
3922 If it is NULL, returning success means that the country code is known.
3923
3924 \return eHalStatus SUCCESS.
3925
3926 FAILURE or RESOURCES The API finished and failed.
3927
3928 -------------------------------------------------------------------------------*/
3929eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
3930{
3931 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3932
3933 return ( csrGetRegulatoryDomainForCountry( pMac, pCountry, pDomainId ) );
3934}
3935
3936
3937
3938
3939/* ---------------------------------------------------------------------------
3940
3941 \fn sme_GetSupportedRegulatoryDomains
3942
3943 \brief To return a list of supported regulatory domains. This is a synchronous API.
3944
3945 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
3946
3947 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
3948 Upon return, this parameter has the number for supported domains. If pDomains
3949 doesn't have enough space for all the supported domains, this function returns
3950 fail status and this parameter contains the number that is needed.
3951
3952 \return eHalStatus SUCCESS.
3953
3954 FAILURE or RESOURCES The API finished and failed.
3955
3956 -------------------------------------------------------------------------------*/
3957eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
3958{
3959 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
3960
3961 //We support all domains for now
3962 if( pNumDomains )
3963 {
3964 if( NUM_REG_DOMAINS <= *pNumDomains )
3965 {
3966 status = eHAL_STATUS_SUCCESS;
3967 }
3968 *pNumDomains = NUM_REG_DOMAINS;
3969 }
3970 if( HAL_STATUS_SUCCESS( status ) )
3971 {
3972 if( pDomains )
3973 {
3974 pDomains[0] = REGDOMAIN_FCC;
3975 pDomains[1] = REGDOMAIN_ETSI;
3976 pDomains[2] = REGDOMAIN_JAPAN;
3977 pDomains[3] = REGDOMAIN_WORLD;
3978 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
3979 pDomains[5] = REGDOMAIN_APAC;
3980 pDomains[6] = REGDOMAIN_KOREA;
3981 pDomains[7] = REGDOMAIN_HI_5GHZ;
3982 pDomains[8] = REGDOMAIN_NO_5GHZ;
3983 }
3984 else
3985 {
3986 status = eHAL_STATUS_INVALID_PARAMETER;
3987 }
3988 }
3989
3990 return ( status );
3991}
3992
3993
3994//some support functions
3995tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
3996{
3997 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3998
3999 return ( csrIs11dSupported( pMac ) );
4000}
4001
4002
4003tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
4004{
4005 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4006
4007 return ( csrIs11hSupported( pMac ) );
4008}
4009
4010
4011tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
4012{
4013 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4014
4015 return ( csrIsWmmSupported( pMac ) );
4016}
4017
4018//Upper layer to get the list of the base channels to scan for passively 11d info from csr
4019eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
4020{
4021 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4022
4023 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
4024}
4025
4026/* ---------------------------------------------------------------------------
4027
4028 \fn sme_ChangeCountryCode
4029
4030 \brief Change Country code from upperlayer during WLAN driver operation.
4031 This is a synchronous API.
4032
4033 \param hHal - The handle returned by macOpen.
4034
4035 \param pCountry New Country Code String
4036
4037 \return eHalStatus SUCCESS.
4038
4039 FAILURE or RESOURCES The API finished and failed.
4040
4041 -------------------------------------------------------------------------------*/
4042eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
4043 tSmeChangeCountryCallback callback,
4044 tANI_U8 *pCountry,
4045 void *pContext,
4046 void* pVosContext )
4047{
4048 eHalStatus status = eHAL_STATUS_FAILURE;
4049 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4050 vos_msg_t msg;
4051 tAniChangeCountryCodeReq *pMsg;
4052
4053 status = sme_AcquireGlobalLock( &pMac->sme );
4054 if ( HAL_STATUS_SUCCESS( status ) )
4055 {
4056 smsLog(pMac, LOG1, FL(" called\n"));
4057 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniChangeCountryCodeReq));
4058 if ( !HAL_STATUS_SUCCESS(status) )
4059 {
4060 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req \n");
4061 return status;
4062 }
4063
4064 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
4065 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
4066 palCopyMemory(pMac->hHdd, pMsg->countryCode, pCountry, 3);
4067 pMsg->changeCCCallback = callback;
4068 pMsg->pDevContext = pContext;
4069 pMsg->pVosContext = pVosContext;
4070
4071 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4072 msg.bodyptr = pMsg;
4073 msg.reserved = 0;
4074
4075 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
4076 {
4077 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self \n");
4078 palFreeMemory(pMac->hHdd, (void *)pMsg);
4079 status = eHAL_STATUS_FAILURE;
4080 }
4081 smsLog(pMac, LOG1, FL(" returned\n"));
4082 sme_ReleaseGlobalLock( &pMac->sme );
4083 }
4084
4085 return (status);
4086}
4087
4088/* ---------------------------------------------------------------------------
4089 \fn sme_BtcSignalBtEvent
4090 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
4091 BT event type and the current operating mode of Libra (full power,
4092 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
4093 would be employed.
4094 \param hHal - The handle returned by macOpen.
4095 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
4096 Caller owns the memory and is responsible for freeing it.
4097 \return VOS_STATUS
4098 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
4099 if BTC execution mode is set to BTC_WLAN_ONLY
4100 or BTC_PTA_ONLY.
4101 VOS_STATUS_SUCCESS BT Event passed to HAL
4102 ---------------------------------------------------------------------------*/
4103VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
4104{
4105 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4106#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4107 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4108
4109 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4110 {
4111 status = btcSignalBTEvent (hHal, pBtEvent);
4112 sme_ReleaseGlobalLock( &pMac->sme );
4113 }
4114#endif
4115 return (status);
4116}
4117
4118/* ---------------------------------------------------------------------------
4119 \fn sme_BtcSetConfig
4120 \brief API to change the current Bluetooth Coexistence (BTC) configuration
4121 This function should be invoked only after CFG download has completed.
4122 Calling it after sme_HDDReadyInd is recommended.
4123 \param hHal - The handle returned by macOpen.
4124 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
4125 Caller owns the memory and is responsible for freeing it.
4126 \return VOS_STATUS
4127 VOS_STATUS_E_FAILURE Config not passed to HAL.
4128 VOS_STATUS_SUCCESS Config passed to HAL
4129 ---------------------------------------------------------------------------*/
4130VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4131{
4132 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4133#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4134 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4135 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4136 {
4137 status = btcSetConfig (hHal, pSmeBtcConfig);
4138 sme_ReleaseGlobalLock( &pMac->sme );
4139 }
4140#endif
4141 return (status);
4142}
4143
4144/* ---------------------------------------------------------------------------
4145 \fn sme_BtcGetConfig
4146 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
4147 \param hHal - The handle returned by macOpen.
4148 \param pSmeBtcConfig - Pointer to a caller allocated object of type
4149 tSmeBtcConfig. Caller owns the memory and is responsible
4150 for freeing it.
4151 \return VOS_STATUS
4152 VOS_STATUS_E_FAILURE - failure
4153 VOS_STATUS_SUCCESS success
4154 ---------------------------------------------------------------------------*/
4155VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4156{
4157 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4158#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4159 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4160
4161 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4162 {
4163 status = btcGetConfig (hHal, pSmeBtcConfig);
4164 sme_ReleaseGlobalLock( &pMac->sme );
4165 }
4166#endif
4167 return (status);
4168}
4169/* ---------------------------------------------------------------------------
4170 \fn sme_SetCfgPrivacy
4171 \brief API to set configure privacy parameters
4172 \param hHal - The handle returned by macOpen.
4173 \param pProfile - Pointer CSR Roam profile.
4174 \param fPrivacy - This parameter indicates status of privacy
4175
4176 \return void
4177 ---------------------------------------------------------------------------*/
4178void sme_SetCfgPrivacy( tHalHandle hHal,
4179 tCsrRoamProfile *pProfile,
4180 tANI_BOOLEAN fPrivacy
4181 )
4182{
4183 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4184 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4185 {
4186 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
4187 sme_ReleaseGlobalLock( &pMac->sme );
4188 }
4189}
4190
4191#if defined WLAN_FEATURE_VOWIFI
4192/* ---------------------------------------------------------------------------
4193 \fn sme_NeighborReportRequest
4194 \brief API to request neighbor report.
4195 \param hHal - The handle returned by macOpen.
4196 \param pRrmNeighborReq - Pointer to a caller allocated object of type
4197 tRrmNeighborReq. Caller owns the memory and is responsible
4198 for freeing it.
4199 \return VOS_STATUS
4200 VOS_STATUS_E_FAILURE - failure
4201 VOS_STATUS_SUCCESS success
4202 ---------------------------------------------------------------------------*/
4203VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
4204 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
4205{
4206 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4207 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4208
4209 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4210 {
4211 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
4212 sme_ReleaseGlobalLock( &pMac->sme );
4213 }
4214
4215 return (status);
4216}
4217#endif
4218
4219//The following are debug APIs to support direct read/write register/memory
4220//They are placed in SME because HW cannot be access when in LOW_POWER state
4221//AND not connected. The knowledge and synchronization is done in SME
4222
4223//sme_DbgReadRegister
4224//Caller needs to validate the input values
4225VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
4226{
4227 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4228 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4229#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4230 tHddHandle hHdd = pMac->hHdd;
4231#endif
4232 tPmcPowerState PowerState;
4233 tANI_U32 sessionId = 0;
4234
4235 /* 1) To make Quarky work in FTM mode **************************************/
4236
4237 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4238 {
4239#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4240 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue)))
4241#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4242 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
4243#endif
4244 {
4245 return VOS_STATUS_SUCCESS;
4246 }
4247 return VOS_STATUS_E_FAILURE;
4248 }
4249
4250 /* 2) NON FTM mode driver *************************************************/
4251
4252 /* Acquire SME global lock */
4253 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4254 {
4255 return VOS_STATUS_E_FAILURE;
4256 }
4257
4258 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4259 {
4260 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4261 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4262 {
4263#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4264 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue )))
4265#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4266 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
4267#endif
4268 {
4269 status = VOS_STATUS_SUCCESS;
4270 }
4271 else
4272 {
4273 status = VOS_STATUS_E_FAILURE;
4274 }
4275 }
4276 else
4277 {
4278 status = VOS_STATUS_E_FAILURE;
4279 }
4280 }
4281
4282 /* This is a hack for Qualky/pttWniSocket
4283 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4284 if ( VOS_STATUS_SUCCESS != status )
4285 {
4286 *pRegValue = 0xDEADBEEF;
4287 status = VOS_STATUS_SUCCESS;
4288 }
4289
4290 /* Release SME global lock */
4291 sme_ReleaseGlobalLock(&pMac->sme);
4292
4293 return (status);
4294}
4295
4296
4297//sme_DbgWriteRegister
4298//Caller needs to validate the input values
4299VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
4300{
4301 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4302 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4303#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4304 tHddHandle hHdd = pMac->hHdd;
4305#endif
4306 tPmcPowerState PowerState;
4307 tANI_U32 sessionId = 0;
4308
4309 /* 1) To make Quarky work in FTM mode **************************************/
4310
4311 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4312 {
4313#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4314 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4315#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4316 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4317#endif
4318 {
4319 return VOS_STATUS_SUCCESS;
4320 }
4321 return VOS_STATUS_E_FAILURE;
4322 }
4323
4324 /* 2) NON FTM mode driver *************************************************/
4325
4326 /* Acquire SME global lock */
4327 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4328 {
4329 return VOS_STATUS_E_FAILURE;
4330 }
4331
4332 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4333 {
4334 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4335 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4336 {
4337#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4338 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4339#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4340 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4341#endif
4342 {
4343 status = VOS_STATUS_SUCCESS;
4344 }
4345 else
4346 {
4347 status = VOS_STATUS_E_FAILURE;
4348 }
4349 }
4350 else
4351 {
4352 status = VOS_STATUS_E_FAILURE;
4353 }
4354 }
4355
4356 /* Release SME global lock */
4357 sme_ReleaseGlobalLock(&pMac->sme);
4358
4359 return (status);
4360}
4361
4362
4363
4364//sme_DbgReadMemory
4365//Caller needs to validate the input values
4366//pBuf caller allocated buffer has the length of nLen
4367VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4368{
4369 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4370 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4371#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4372 v_PVOID_t pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *)hHal);
4373 tHddHandle hHdd = pMac->hHdd;
4374#endif
4375 tPmcPowerState PowerState;
4376 tANI_U32 sessionId = 0;
4377
4378 /* 1) To make Quarky work in FTM mode **************************************/
4379
4380 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4381 {
4382#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4383 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4384#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4385 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadMemory(memAddr, (void *)pBuf, nLen))
4386#endif
4387 {
4388 return VOS_STATUS_SUCCESS;
4389 }
4390 return VOS_STATUS_E_FAILURE;
4391 }
4392
4393 /* 2) NON FTM mode driver *************************************************/
4394
4395 /* Acquire SME global lock */
4396 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4397 {
4398 return VOS_STATUS_E_FAILURE;
4399 }
4400
4401 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4402 {
4403 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4404 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4405 {
4406#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4407 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(pvosGCTx, memAddr, (void *)pBuf, nLen)))
4408#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4409 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadMemory(memAddr, (void *)pBuf, nLen))
4410#endif
4411 {
4412 status = VOS_STATUS_SUCCESS;
4413 }
4414 else
4415 {
4416 status = VOS_STATUS_E_FAILURE;
4417 }
4418 }
4419 else
4420 {
4421 status = VOS_STATUS_E_FAILURE;
4422 }
4423 }
4424
4425 /* This is a hack for Qualky/pttWniSocket
4426 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4427 if (VOS_STATUS_SUCCESS != status)
4428 {
4429 vos_mem_set(pBuf, nLen, 0xCD);
4430 status = VOS_STATUS_SUCCESS;
4431 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware\n"));
4432 }
4433
4434 /* Release SME lock */
4435 sme_ReleaseGlobalLock(&pMac->sme);
4436
4437 return (status);
4438}
4439
4440
4441//sme_DbgWriteMemory
4442//Caller needs to validate the input values
4443VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4444{
4445 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4446 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4447#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4448 tHddHandle hHdd = pMac->hHdd;
4449#endif
4450 tPmcPowerState PowerState;
4451 tANI_U32 sessionId = 0;
4452
4453 /* 1) To make Quarky work in FTM mode **************************************/
4454
4455 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4456 {
4457#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4458 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4459#elif defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4460 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory( memAddr, (void *)pBuf, nLen))
4461#endif
4462 {
4463 return VOS_STATUS_SUCCESS;
4464 }
4465 return VOS_STATUS_E_FAILURE;
4466 }
4467
4468 /* 2) NON FTM mode driver *************************************************/
4469
4470 /* Acquire SME global lock */
4471 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4472 {
4473 return VOS_STATUS_E_FAILURE;
4474 }
4475
4476 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4477 {
4478 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4479 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4480 {
4481#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4482 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4483#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4484 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
4485#endif
4486 {
4487 status = VOS_STATUS_SUCCESS;
4488 }
4489 else
4490 {
4491 status = VOS_STATUS_E_FAILURE;
4492 }
4493 }
4494 else
4495 {
4496 status = VOS_STATUS_E_FAILURE;
4497 }
4498 }
4499
4500 /* Release Global lock */
4501 sme_ReleaseGlobalLock(&pMac->sme);
4502
4503 return (status);
4504}
4505
4506
4507void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
4508{
4509#ifdef WLAN_DEBUG
4510 // Verify against current log level
4511 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
4512 return;
4513 else
4514 {
4515 va_list marker;
4516
4517 va_start( marker, pString ); /* Initialize variable arguments. */
4518
4519 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
4520
4521 va_end( marker ); /* Reset variable arguments. */
4522 }
4523#endif
4524}
4525#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
4526/* ---------------------------------------------------------------------------
4527 \fn sme_GetFwVersion
4528 \brief This API returns the firmware version.
4529 \param hHal - The handle returned by macOpen.
4530 \param version - Points to the FwVersionInfo structure.
4531 \return VOS_STATUS
4532 VOS_STATUS_E_INVAL - failure
4533 VOS_STATUS_SUCCESS success
4534 ---------------------------------------------------------------------------*/
4535VOS_STATUS sme_GetFwVersion (tHalHandle hHal,FwVersionInfo *pVersion)
4536{
4537 VOS_STATUS status = VOS_STATUS_SUCCESS;
4538 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4539
4540 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4541 {
4542 if( pVersion != NULL ) {
4543 vos_mem_copy((v_VOID_t*)pVersion,(v_VOID_t*)&pMac->hal.FwParam.fwVersion, sizeof(FwVersionInfo));
4544 }
4545 else {
4546 status = VOS_STATUS_E_INVAL;
4547 }
4548 sme_ReleaseGlobalLock( &pMac->sme );
4549 }
4550
4551 return (status);
4552}
4553#endif
4554
4555#ifdef FEATURE_WLAN_INTEGRATED_SOC
4556/* ---------------------------------------------------------------------------
4557 \fn sme_GetWcnssWlanCompiledVersion
4558 \brief This API returns the version of the WCNSS WLAN API with
4559 which the HOST driver was built
4560 \param hHal - The handle returned by macOpen.
4561 \param pVersion - Points to the Version structure to be filled
4562 \return VOS_STATUS
4563 VOS_STATUS_E_INVAL - failure
4564 VOS_STATUS_SUCCESS success
4565 ---------------------------------------------------------------------------*/
4566VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
4567 tSirVersionType *pVersion)
4568{
4569 VOS_STATUS status = VOS_STATUS_SUCCESS;
4570 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4571 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4572
4573 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4574 {
4575 if( pVersion != NULL )
4576 {
4577 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
4578 }
4579 else
4580 {
4581 status = VOS_STATUS_E_INVAL;
4582 }
4583 sme_ReleaseGlobalLock( &pMac->sme );
4584 }
4585
4586 return (status);
4587}
4588
4589
4590/* ---------------------------------------------------------------------------
4591 \fn sme_GetWcnssWlanReportedVersion
4592 \brief This API returns the version of the WCNSS WLAN API with
4593 which the WCNSS driver reports it was built
4594 \param hHal - The handle returned by macOpen.
4595 \param pVersion - Points to the Version structure to be filled
4596 \return VOS_STATUS
4597 VOS_STATUS_E_INVAL - failure
4598 VOS_STATUS_SUCCESS success
4599 ---------------------------------------------------------------------------*/
4600VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
4601 tSirVersionType *pVersion)
4602{
4603 VOS_STATUS status = VOS_STATUS_SUCCESS;
4604 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4605 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4606
4607 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4608 {
4609 if( pVersion != NULL )
4610 {
4611 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
4612 }
4613 else
4614 {
4615 status = VOS_STATUS_E_INVAL;
4616 }
4617 sme_ReleaseGlobalLock( &pMac->sme );
4618 }
4619
4620 return (status);
4621}
4622
4623
4624/* ---------------------------------------------------------------------------
4625 \fn sme_GetWcnssSoftwareVersion
4626 \brief This API returns the version string of the WCNSS driver
4627 \param hHal - The handle returned by macOpen.
4628 \param pVersion - Points to the Version string buffer to be filled
4629 \param versionBufferSize - THe size of the Version string buffer
4630 \return VOS_STATUS
4631 VOS_STATUS_E_INVAL - failure
4632 VOS_STATUS_SUCCESS success
4633 ---------------------------------------------------------------------------*/
4634VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
4635 tANI_U8 *pVersion,
4636 tANI_U32 versionBufferSize)
4637{
4638 VOS_STATUS status = VOS_STATUS_SUCCESS;
4639 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4640 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4641
4642 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4643 {
4644 if( pVersion != NULL )
4645 {
4646 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
4647 versionBufferSize);
4648 }
4649 else
4650 {
4651 status = VOS_STATUS_E_INVAL;
4652 }
4653 sme_ReleaseGlobalLock( &pMac->sme );
4654 }
4655
4656 return (status);
4657}
4658
4659
4660/* ---------------------------------------------------------------------------
4661 \fn sme_GetWcnssHardwareVersion
4662 \brief This API returns the version string of the WCNSS hardware
4663 \param hHal - The handle returned by macOpen.
4664 \param pVersion - Points to the Version string buffer to be filled
4665 \param versionBufferSize - THe size of the Version string buffer
4666 \return VOS_STATUS
4667 VOS_STATUS_E_INVAL - failure
4668 VOS_STATUS_SUCCESS success
4669 ---------------------------------------------------------------------------*/
4670VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
4671 tANI_U8 *pVersion,
4672 tANI_U32 versionBufferSize)
4673{
4674 VOS_STATUS status = VOS_STATUS_SUCCESS;
4675 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4676 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4677
4678 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4679 {
4680 if( pVersion != NULL )
4681 {
4682 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
4683 versionBufferSize);
4684 }
4685 else
4686 {
4687 status = VOS_STATUS_E_INVAL;
4688 }
4689 sme_ReleaseGlobalLock( &pMac->sme );
4690 }
4691
4692 return (status);
4693}
4694#endif
4695
4696#ifdef FEATURE_WLAN_WAPI
4697/* ---------------------------------------------------------------------------
4698 \fn sme_RoamSetBKIDCache
4699 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
4700 candidate list.
4701 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4702 it is opened (by calling halOpen).
4703 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
4704 \param numItems - a variable that has the number of tBkidCacheInfo allocated
4705 when retruning, this is the number of items put into pBKIDCache
4706 \return eHalStatus - when fail, it usually means the buffer allocated is not
4707 big enough and pNumItems has the number of tBkidCacheInfo.
4708 ---------------------------------------------------------------------------*/
4709eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
4710 tANI_U32 numItems )
4711{
4712 eHalStatus status = eHAL_STATUS_FAILURE;
4713 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4714
4715 status = sme_AcquireGlobalLock( &pMac->sme );
4716 if ( HAL_STATUS_SUCCESS( status ) )
4717 {
4718 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
4719 sme_ReleaseGlobalLock( &pMac->sme );
4720 }
4721
4722 return (status);
4723}
4724
4725/* ---------------------------------------------------------------------------
4726 \fn sme_RoamGetBKIDCache
4727 \brief The SME API exposed to HDD to allow HDD to request SME to return its
4728 BKID cache.
4729 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4730 it is opened (by calling halOpen).
4731 \param pNum - caller allocated memory that has the space of the number of
4732 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
4733 in SME cache.
4734 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
4735 upon return
4736 \return eHalStatus - when fail, it usually means the buffer allocated is not
4737 big enough.
4738 ---------------------------------------------------------------------------*/
4739eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
4740 tBkidCacheInfo *pBkidCache)
4741{
4742 eHalStatus status = eHAL_STATUS_FAILURE;
4743 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4744
4745 status = sme_AcquireGlobalLock( &pMac->sme );
4746 if ( HAL_STATUS_SUCCESS( status ) )
4747 {
4748 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded\n"));
4749 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
4750 sme_ReleaseGlobalLock( &pMac->sme );
4751 }
4752
4753 return (status);
4754}
4755
4756/* ---------------------------------------------------------------------------
4757 \fn sme_RoamGetNumBKIDCache
4758 \brief The SME API exposed to HDD to allow HDD to request SME to return the
4759 number of BKID cache entries.
4760 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4761 it is opened (by calling halOpen).
4762 \return tANI_U32 - the number of BKID cache entries.
4763 ---------------------------------------------------------------------------*/
4764tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
4765{
4766 eHalStatus status = eHAL_STATUS_FAILURE;
4767 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4768 tANI_U32 numBkidCache = 0;
4769
4770 status = sme_AcquireGlobalLock( &pMac->sme );
4771 if ( HAL_STATUS_SUCCESS( status ) )
4772 {
4773 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
4774 sme_ReleaseGlobalLock( &pMac->sme );
4775 }
4776
4777 return (numBkidCache);
4778}
4779
4780/* ---------------------------------------------------------------------------
4781 \fn sme_ScanGetBKIDCandidateList
4782 \brief a wrapper function to return the BKID candidate list
4783 \param pBkidList - caller allocated buffer point to an array of
4784 tBkidCandidateInfo
4785 \param pNumItems - pointer to a variable that has the number of
4786 tBkidCandidateInfo allocated when retruning, this is
4787 either the number needed or number of items put into
4788 pPmkidList
4789 \return eHalStatus - when fail, it usually means the buffer allocated is not
4790 big enough and pNumItems
4791 has the number of tBkidCandidateInfo.
4792 \Note: pNumItems is a number of tBkidCandidateInfo,
4793 not sizeof(tBkidCandidateInfo) * something
4794 ---------------------------------------------------------------------------*/
4795eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
4796 tBkidCandidateInfo *pBkidList,
4797 tANI_U32 *pNumItems )
4798{
4799 eHalStatus status = eHAL_STATUS_FAILURE;
4800 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4801
4802 status = sme_AcquireGlobalLock( &pMac->sme );
4803 if ( HAL_STATUS_SUCCESS( status ) )
4804 {
4805 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
4806 sme_ReleaseGlobalLock( &pMac->sme );
4807 }
4808
4809 return (status);
4810}
4811#endif /* FEATURE_WLAN_WAPI */
4812
Jeff Johnsone7245742012-09-05 17:12:55 -07004813#ifdef FEATURE_OEM_DATA_SUPPORT
4814
4815/*****************************************************************************
4816 OEM DATA related modifications and function additions
4817 *****************************************************************************/
4818
4819/* ---------------------------------------------------------------------------
4820 \fn sme_getOemDataRsp
4821 \brief a wrapper function to obtain the OEM DATA RSP
4822 \param pOemDataRsp - A pointer to the response object
4823 \param pContext - a pointer passed in for the callback
4824 \return eHalStatus
4825 ---------------------------------------------------------------------------*/
4826eHalStatus sme_getOemDataRsp(tHalHandle hHal,
4827 tOemDataRsp **pOemDataRsp)
4828{
4829 eHalStatus status = eHAL_STATUS_SUCCESS;
4830 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4831
4832 do
4833 {
4834 //acquire the lock for the sme object
4835 status = sme_AcquireGlobalLock(&pMac->sme);
4836
4837 if(!HAL_STATUS_SUCCESS(status))
4838 {
4839 break;
4840 }
4841
4842 if(pMac->oemData.pOemDataRsp != NULL)
4843 {
4844 *pOemDataRsp = pMac->oemData.pOemDataRsp;
4845 }
4846 else
4847 {
4848 status = eHAL_STATUS_FAILURE;
4849 }
4850
4851 //release the lock for the sme object
4852 sme_ReleaseGlobalLock( &pMac->sme );
4853
4854 } while(0);
4855
4856 return status;
4857}
4858
4859/* ---------------------------------------------------------------------------
4860 \fn sme_OemDataReq
4861 \brief a wrapper function for OEM DATA REQ
4862 \param sessionId - session id to be used.
4863 \param pOemDataReqId - pointer to an object to get back the request ID
4864 \param callback - a callback function that is called upon finish
4865 \param pContext - a pointer passed in for the callback
4866 \return eHalStatus
4867 ---------------------------------------------------------------------------*/
4868eHalStatus sme_OemDataReq(tHalHandle hHal,
4869 tANI_U8 sessionId,
4870 tOemDataReqConfig *pOemDataReqConfig,
4871 tANI_U32 *pOemDataReqID,
4872 oemData_OemDataReqCompleteCallback callback,
4873 void *pContext)
4874{
4875 eHalStatus status = eHAL_STATUS_SUCCESS;
4876 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4877
4878 do
4879 {
4880 //acquire the lock for the sme object
4881 status = sme_AcquireGlobalLock(&pMac->sme);
4882 if(HAL_STATUS_SUCCESS(status))
4883 {
4884 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
4885
4886 if(pOemDataReqID)
4887 {
4888 *pOemDataReqID = lOemDataReqId;
4889 }
4890 else
4891 return eHAL_STATUS_FAILURE;
4892
4893 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
4894
4895 //release the lock for the sme object
4896 sme_ReleaseGlobalLock( &pMac->sme );
4897 }
4898 } while(0);
4899
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004900 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07004901
4902 return(status);
4903}
4904
4905#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004906
4907/*--------------------------------------------------------------------------
4908
4909 \brief sme_OpenSession() - Open a session for scan/roam operation.
4910
4911 This is a synchronous API.
4912
4913
4914 \param hHal - The handle returned by macOpen.
4915 \param callback - A pointer to the function caller specifies for roam/connect status indication
4916 \param pContext - The context passed with callback
4917 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
4918 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
4919
4920 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
4921
4922 Other status means SME is failed to open the session.
4923 eHAL_STATUS_RESOURCES - no more session available.
4924 \sa
4925
4926 --------------------------------------------------------------------------*/
4927eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback, void *pContext,
4928 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId)
4929{
4930 eHalStatus status;
4931 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4932
4933 if( NULL == pbSessionId )
4934 {
4935 status = eHAL_STATUS_INVALID_PARAMETER;
4936 }
4937 else
4938 {
4939 status = sme_AcquireGlobalLock( &pMac->sme );
4940 if ( HAL_STATUS_SUCCESS( status ) )
4941 {
4942 status = csrRoamOpenSession( pMac, callback, pContext, pSelfMacAddr, pbSessionId );
4943
4944 sme_ReleaseGlobalLock( &pMac->sme );
4945 }
4946 }
4947
4948 return ( status );
4949}
4950
4951
4952/*--------------------------------------------------------------------------
4953
4954 \brief sme_CloseSession() - Open a session for scan/roam operation.
4955
4956 This is a synchronous API.
4957
4958
4959 \param hHal - The handle returned by macOpen.
4960
4961 \param sessionId - A previous opened session's ID.
4962
4963 \return eHAL_STATUS_SUCCESS - session is closed.
4964
4965 Other status means SME is failed to open the session.
4966 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
4967 \sa
4968
4969 --------------------------------------------------------------------------*/
4970eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
4971 csrRoamSessionCloseCallback callback, void *pContext)
4972{
4973 eHalStatus status;
4974 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4975
4976 status = sme_AcquireGlobalLock( &pMac->sme );
4977 if ( HAL_STATUS_SUCCESS( status ) )
4978 {
4979 status = csrRoamCloseSession( pMac, sessionId, FALSE,
4980 callback, pContext );
4981
4982 sme_ReleaseGlobalLock( &pMac->sme );
4983 }
4984
4985 return ( status );
4986}
4987
4988#ifdef WLAN_SOFTAP_FEATURE
4989/* ---------------------------------------------------------------------------
4990
4991 \fn sme_RoamUpdateAPWPSIE
4992
4993 \brief To update AP's WPS IE. This function should be called after SME AP session is created
4994 This is an asynchronous API.
4995
4996 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
4997
4998 \return eHalStatus – SUCCESS –
4999
5000 FAILURE or RESOURCES – The API finished and failed.
5001
5002 -------------------------------------------------------------------------------*/
5003eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
5004{
5005
5006 eHalStatus status = eHAL_STATUS_FAILURE;
5007 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5008
5009 status = sme_AcquireGlobalLock( &pMac->sme );
5010 if ( HAL_STATUS_SUCCESS( status ) )
5011 {
5012
5013 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
5014
5015 sme_ReleaseGlobalLock( &pMac->sme );
5016 }
5017
5018 return (status);
5019}
5020/* ---------------------------------------------------------------------------
5021
5022 \fn sme_RoamUpdateAPWPARSNIEs
5023
5024 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
5025 This is an asynchronous API.
5026
5027 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
5028
5029 \return eHalStatus – SUCCESS –
5030
5031 FAILURE or RESOURCES – The API finished and failed.
5032
5033 -------------------------------------------------------------------------------*/
5034eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
5035{
5036
5037 eHalStatus status = eHAL_STATUS_FAILURE;
5038 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5039
5040 status = sme_AcquireGlobalLock( &pMac->sme );
5041 if ( HAL_STATUS_SUCCESS( status ) )
5042 {
5043
5044 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
5045
5046 sme_ReleaseGlobalLock( &pMac->sme );
5047 }
5048
5049 return (status);
5050}
5051#endif
5052
5053
5054/*-------------------------------------------------------------------------------*
5055
5056 \fn sme_sendBTAmpEvent
5057
5058 \brief to receive the coex priorty request from BT-AMP PAL
5059 and send the BT_AMP link state to HAL
5060
5061 \param btAmpEvent - btAmpEvent
5062
5063 \return eHalStatus: SUCESS : BTAmp event successfully sent to HAL
5064
5065 FAILURE: API failed
5066
5067-------------------------------------------------------------------------------*/
5068
5069eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
5070{
5071 vos_msg_t msg;
5072 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
5073 eHalStatus status = eHAL_STATUS_FAILURE;
5074
5075 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tpSmeBtAmpEvent));
5076 if (NULL == ptrSmeBtAmpEvent)
5077 {
5078 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005079 "Not able to allocate memory for BTAmp event", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 return status;
5081 }
5082
5083 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
5084 msg.type = WDA_SIGNAL_BTAMP_EVENT;
5085 msg.reserved = 0;
5086 msg.bodyptr = ptrSmeBtAmpEvent;
5087
5088 //status = halFW_SendBTAmpEventMesg(pMac, event);
5089
5090 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5091 {
5092 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005093 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 vos_mem_free(ptrSmeBtAmpEvent);
5095 return status;
5096 }
5097
5098 return eHAL_STATUS_SUCCESS;
5099
5100}
5101
5102/* ---------------------------------------------------------------------------
5103 \fn sme_SetHostOffload
5104 \brief API to set the host offload feature.
5105 \param hHal - The handle returned by macOpen.
5106 \param pRequest - Pointer to the offload request.
5107 \return eHalStatus
5108 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005109eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
5110 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005111{
5112 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07005113 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005114
5115 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5116 {
5117#ifdef WLAN_NS_OFFLOAD
5118 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
5119 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005120 status = pmcSetNSOffload( hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 }
5122 else
5123#endif //WLAN_NS_OFFLOAD
5124 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005125 status = pmcSetHostOffload (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005126 }
5127 sme_ReleaseGlobalLock( &pMac->sme );
5128 }
5129
5130 return (status);
5131}
5132
5133#ifdef WLAN_FEATURE_GTK_OFFLOAD
5134/* ---------------------------------------------------------------------------
5135 \fn sme_SetGTKOffload
5136 \brief API to set GTK offload information.
5137 \param hHal - The handle returned by macOpen.
5138 \param pRequest - Pointer to the GTK offload request.
5139 \return eHalStatus
5140 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005141eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest,
5142 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005143{
5144 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5145 eHalStatus status;
5146
5147 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5148 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005149 status = pmcSetGTKOffload( hHal, pRequest, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 sme_ReleaseGlobalLock( &pMac->sme );
5151 }
5152
5153 return (status);
5154}
5155
5156/* ---------------------------------------------------------------------------
5157 \fn sme_GetGTKOffload
5158 \brief API to get GTK offload information.
5159 \param hHal - The handle returned by macOpen.
5160 \param pRequest - Pointer to the GTK offload response.
5161 \return eHalStatus
5162 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005163eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
5164 void *callbackContext, tANI_U8 sessionId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005165{
5166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5167 eHalStatus status;
5168
5169 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5170 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005171 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005172 sme_ReleaseGlobalLock( &pMac->sme );
5173 }
5174
5175 return (status);
5176}
5177#endif // WLAN_FEATURE_GTK_OFFLOAD
5178
5179/* ---------------------------------------------------------------------------
5180 \fn sme_SetKeepAlive
5181 \brief API to set the Keep Alive feature.
5182 \param hHal - The handle returned by macOpen.
5183 \param pRequest - Pointer to the Keep Alive request.
5184 \return eHalStatus
5185 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005186eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
5187 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005188{
5189 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5190 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5192 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005193 status = pmcSetKeepAlive (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005194 sme_ReleaseGlobalLock( &pMac->sme );
5195 }
5196
5197 return (status);
5198}
5199
5200#ifdef FEATURE_WLAN_SCAN_PNO
5201/* ---------------------------------------------------------------------------
5202 \fn sme_SetPreferredNetworkList
5203 \brief API to set the Preferred Network List Offload feature.
5204 \param hHal - The handle returned by macOpen.
5205 \param pRequest - Pointer to the offload request.
5206 \return eHalStatus
5207 ---------------------------------------------------------------------------*/
5208eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
5209{
5210 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5211 eHalStatus status;
5212
5213 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5214 {
5215 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
5216 sme_ReleaseGlobalLock( &pMac->sme );
5217 }
5218
5219 return (status);
5220}
5221
5222eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
5223{
5224 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5225 eHalStatus status;
5226
5227 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5228 {
5229 pmcSetRssiFilter(hHal, rssiThreshold);
5230 sme_ReleaseGlobalLock( &pMac->sme );
5231 }
5232
5233 return (status);
5234}
5235
5236#endif // FEATURE_WLAN_SCAN_PNO
5237
5238eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams)
5239{
5240 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5241 eHalStatus status;
5242
5243 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5244 {
5245 pmcSetPowerParams(hHal, pwParams);
5246 sme_ReleaseGlobalLock( &pMac->sme );
5247 }
5248
5249 return (status);
5250}
5251
5252/* ---------------------------------------------------------------------------
5253 \fn sme_AbortMacScan
5254 \brief API to cancel MAC scan.
5255 \param hHal - The handle returned by macOpen.
5256 \return VOS_STATUS
5257 VOS_STATUS_E_FAILURE - failure
5258 VOS_STATUS_SUCCESS success
5259 ---------------------------------------------------------------------------*/
5260eHalStatus sme_AbortMacScan(tHalHandle hHal)
5261{
5262 eHalStatus status;
5263 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5264
5265 status = sme_AcquireGlobalLock( &pMac->sme );
5266 if ( HAL_STATUS_SUCCESS( status ) )
5267 {
5268 status = csrScanAbortMacScan(pMac);
5269
5270 sme_ReleaseGlobalLock( &pMac->sme );
5271 }
5272
5273 return ( status );
5274}
5275
5276/* ----------------------------------------------------------------------------
5277 \fn sme_GetOperationChannel
5278 \brief API to get current channel on which STA is parked
5279 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005280 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 \returns eHAL_STATUS_SUCCESS
5282 eHAL_STATUS_FAILURE
5283-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005284eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005285{
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5287 tCsrRoamSession *pSession;
5288
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005289 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005291 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005292
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005293 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
5294 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005295#ifdef WLAN_SOFTAP_FEATURE
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005296 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
5297#endif
5298 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
5299 {
5300 *pChannel =pSession->connectedProfile.operationChannel;
5301 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 }
5303 }
5304 return eHAL_STATUS_FAILURE;
5305}// sme_GetOperationChannel ends here
5306
5307#ifdef WLAN_FEATURE_P2P
5308/* ---------------------------------------------------------------------------
5309
5310 \fn sme_RegisterMgtFrame
5311
5312 \brief To register managment frame of specified type and subtype.
5313 \param frameType - type of the frame that needs to be passed to HDD.
5314 \param matchData - data which needs to be matched before passing frame
5315 to HDD.
5316 \param matchDataLen - Length of matched data.
5317 \return eHalStatus
5318 -------------------------------------------------------------------------------*/
5319eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5320 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5321{
5322 eHalStatus status = eHAL_STATUS_SUCCESS;
5323 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5324
5325 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5326 {
5327 tSirRegisterMgmtFrame *pMsg;
5328 tANI_U16 len;
5329 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005330
5331 if(!pSession)
5332 {
5333 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5334 return eHAL_STATUS_FAILURE;
5335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005336
5337 if( !pSession->sessionActive )
5338 {
5339 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005340 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 sme_ReleaseGlobalLock( &pMac->sme );
5342 return eHAL_STATUS_FAILURE;
5343 }
5344
5345 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5346
5347 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5348 if(HAL_STATUS_SUCCESS(status))
5349 {
5350 palZeroMemory(pMac->hHdd, pMsg, len);
5351 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5352 pMsg->length = len;
5353 pMsg->sessionId = sessionId;
5354 pMsg->registerFrame = VOS_TRUE;
5355 pMsg->frameType = frameType;
5356 pMsg->matchLen = matchLen;
5357 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5358 status = palSendMBMessage(pMac->hHdd, pMsg);
5359 }
5360 sme_ReleaseGlobalLock( &pMac->sme );
5361 }
5362 return status;
5363}
5364
5365/* ---------------------------------------------------------------------------
5366
5367 \fn sme_DeregisterMgtFrame
5368
5369 \brief To De-register managment frame of specified type and subtype.
5370 \param frameType - type of the frame that needs to be passed to HDD.
5371 \param matchData - data which needs to be matched before passing frame
5372 to HDD.
5373 \param matchDataLen - Length of matched data.
5374 \return eHalStatus
5375 -------------------------------------------------------------------------------*/
5376eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5377 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5378{
5379 eHalStatus status = eHAL_STATUS_SUCCESS;
5380 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5381
5382 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5383 {
5384 tSirRegisterMgmtFrame *pMsg;
5385 tANI_U16 len;
5386 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005387
5388 if(!pSession)
5389 {
5390 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5391 return eHAL_STATUS_FAILURE;
5392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005393
5394 if( !pSession->sessionActive )
5395 {
5396 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005397 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 sme_ReleaseGlobalLock( &pMac->sme );
5399 return eHAL_STATUS_FAILURE;
5400 }
5401
5402 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5403
5404 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5405 if(HAL_STATUS_SUCCESS(status))
5406 {
5407 palZeroMemory(pMac->hHdd, pMsg, len);
5408 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5409 pMsg->length = len;
5410 pMsg->registerFrame = VOS_FALSE;
5411 pMsg->frameType = frameType;
5412 pMsg->matchLen = matchLen;
5413 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5414 status = palSendMBMessage(pMac->hHdd, pMsg);
5415 }
5416 sme_ReleaseGlobalLock( &pMac->sme );
5417 }
5418 return status;
5419}
5420
5421/* ---------------------------------------------------------------------------
5422 \fn sme_RemainOnChannel
5423 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
5424 \param hHal - The handle returned by macOpen.
5425 \param pRequest - channel
5426 \param duration - duration in ms
5427 \param callback - HDD registered callback to process reaminOnChannelRsp
5428 \param context - HDD Callback param
5429 \return eHalStatus
5430 ---------------------------------------------------------------------------*/
5431
5432eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
5433 tANI_U8 channel, tANI_U32 duration,
5434 remainOnChanCallback callback,
5435 void *pContext)
5436{
5437 eHalStatus status = eHAL_STATUS_SUCCESS;
5438 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5439
5440 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5441 {
5442 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext
5443#ifdef WLAN_FEATURE_P2P_INTERNAL
5444 , eP2PRemainOnChnReasonUnknown
5445#endif
5446 );
5447 sme_ReleaseGlobalLock( &pMac->sme );
5448 }
5449 return(status);
5450}
5451
5452/* ---------------------------------------------------------------------------
5453 \fn sme_ReportProbeReq
5454 \brief API to enable/disable forwarding of probeReq to apps in p2p.
5455 \param hHal - The handle returned by macOpen.
5456 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
5457 \return eHalStatus
5458 ---------------------------------------------------------------------------*/
5459
5460#ifndef WLAN_FEATURE_CONCURRENT_P2P
5461eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
5462{
5463 eHalStatus status = eHAL_STATUS_SUCCESS;
5464 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5465
5466 do
5467 {
5468 //acquire the lock for the sme object
5469 status = sme_AcquireGlobalLock(&pMac->sme);
5470 if(HAL_STATUS_SUCCESS(status))
5471 {
5472 /* call set in context */
5473 pMac->p2pContext.probeReqForwarding = flag;
5474 //release the lock for the sme object
5475 sme_ReleaseGlobalLock( &pMac->sme );
5476 }
5477 } while(0);
5478
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005479 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005480
5481 return(status);
5482}
5483
5484/* ---------------------------------------------------------------------------
5485 \fn sme_updateP2pIe
5486 \brief API to set the P2p Ie in p2p context
5487 \param hHal - The handle returned by macOpen.
5488 \param p2pIe - Ptr to p2pIe from HDD.
5489 \param p2pIeLength: length of p2pIe
5490 \return eHalStatus
5491 ---------------------------------------------------------------------------*/
5492
5493eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
5494{
5495 eHalStatus status = eHAL_STATUS_SUCCESS;
5496 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5497
5498 //acquire the lock for the sme object
5499 status = sme_AcquireGlobalLock(&pMac->sme);
5500 if(HAL_STATUS_SUCCESS(status))
5501 {
5502 if(NULL != pMac->p2pContext.probeRspIe){
5503 vos_mem_free(pMac->p2pContext.probeRspIe);
5504 pMac->p2pContext.probeRspIeLength = 0;
5505 }
5506
5507 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
5508 if (NULL == pMac->p2pContext.probeRspIe)
5509 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005510 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 pMac->p2pContext.probeRspIeLength = 0;
5512 status = eHAL_STATUS_FAILURE;
5513 }
5514 else
5515 {
5516 pMac->p2pContext.probeRspIeLength = p2pIeLength;
5517
5518 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
5519 pMac->p2pContext.probeRspIe,
5520 pMac->p2pContext.probeRspIeLength );
5521 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
5522 p2pIeLength);
5523 }
5524
5525 //release the lock for the sme object
5526 sme_ReleaseGlobalLock( &pMac->sme );
5527 }
5528
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005529 smsLog(pMac, LOG2, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005530
5531 return(status);
5532}
5533#endif
5534
5535/* ---------------------------------------------------------------------------
5536 \fn sme_sendAction
5537 \brief API to send action frame from supplicant.
5538 \param hHal - The handle returned by macOpen.
5539 \return eHalStatus
5540 ---------------------------------------------------------------------------*/
5541
5542eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07005543 const tANI_U8 *pBuf, tANI_U32 len,
5544 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07005545{
5546 eHalStatus status = eHAL_STATUS_SUCCESS;
5547 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5548
5549 //acquire the lock for the sme object
5550 status = sme_AcquireGlobalLock(&pMac->sme);
5551 if(HAL_STATUS_SUCCESS(status))
5552 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005553 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 //release the lock for the sme object
5555 sme_ReleaseGlobalLock( &pMac->sme );
5556 }
5557
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005558 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005559
5560 return(status);
5561}
5562
5563eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
5564{
5565 eHalStatus status = eHAL_STATUS_SUCCESS;
5566 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5567
5568 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5569 {
5570 status = p2pCancelRemainOnChannel (hHal, sessionId);
5571 sme_ReleaseGlobalLock( &pMac->sme );
5572 }
5573 return(status);
5574}
5575
5576//Power Save Related
5577eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
5578{
5579 eHalStatus status = eHAL_STATUS_SUCCESS;
5580 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5581
5582 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5583 {
5584 status = p2pSetPs (hHal, data);
5585 sme_ReleaseGlobalLock( &pMac->sme );
5586 }
5587 return(status);
5588}
5589
5590#endif
5591
5592/* ---------------------------------------------------------------------------
5593
5594 \fn sme_ConfigureRxpFilter
5595
5596 \brief
5597 SME will pass this request to lower mac to set/reset the filter on RXP for
5598 multicast & broadcast traffic.
5599
5600 \param
5601
5602 hHal - The handle returned by macOpen.
5603
5604 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
5605 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
5606 on this param. In future we can use this as a mask to set various types of
5607 filters as suggested below:
5608 FILTER_ALL_MULTICAST:
5609 FILTER_ALL_BROADCAST:
5610 FILTER_ALL_MULTICAST_BROADCAST:
5611
5612
5613 \return eHalStatus
5614
5615
5616--------------------------------------------------------------------------- */
5617eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
5618 tpSirWlanSetRxpFilters wlanRxpFilterParam)
5619{
5620 eHalStatus status = eHAL_STATUS_SUCCESS;
5621 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5622 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5623 vos_msg_t vosMessage;
5624
5625 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5626 {
5627 /* serialize the req through MC thread */
5628 vosMessage.bodyptr = wlanRxpFilterParam;
5629 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
5630 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5631 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5632 {
5633 status = eHAL_STATUS_FAILURE;
5634 }
5635 sme_ReleaseGlobalLock( &pMac->sme );
5636 }
5637 return(status);
5638}
5639
5640#ifdef FEATURE_WLAN_INTEGRATED_SOC
5641/* ---------------------------------------------------------------------------
5642
5643 \fn sme_ConfigureSuspendInd
5644
5645 \brief
5646 SME will pass this request to lower mac to Indicate that the wlan needs to
5647 be suspended
5648
5649 \param
5650
5651 hHal - The handle returned by macOpen.
5652
5653 wlanSuspendParam- Depicts the wlan suspend params
5654
5655
5656 \return eHalStatus
5657
5658
5659--------------------------------------------------------------------------- */
5660eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
5661 tpSirWlanSuspendParam wlanSuspendParam)
5662{
5663 eHalStatus status = eHAL_STATUS_SUCCESS;
5664 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5665 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5666 vos_msg_t vosMessage;
5667
5668 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5669 {
5670 /* serialize the req through MC thread */
5671 vosMessage.bodyptr = wlanSuspendParam;
5672 vosMessage.type = WDA_WLAN_SUSPEND_IND;
5673 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5674 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5675 {
5676 status = eHAL_STATUS_FAILURE;
5677 }
5678 sme_ReleaseGlobalLock( &pMac->sme );
5679 }
5680 return(status);
5681}
5682
5683/* ---------------------------------------------------------------------------
5684
5685 \fn sme_ConfigureResumeReq
5686
5687 \brief
5688 SME will pass this request to lower mac to Indicate that the wlan needs to
5689 be Resumed
5690
5691 \param
5692
5693 hHal - The handle returned by macOpen.
5694
5695 wlanResumeParam- Depicts the wlan resume params
5696
5697
5698 \return eHalStatus
5699
5700
5701--------------------------------------------------------------------------- */
5702eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
5703 tpSirWlanResumeParam wlanResumeParam)
5704{
5705 eHalStatus status = eHAL_STATUS_SUCCESS;
5706 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5707 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5708 vos_msg_t vosMessage;
5709
5710 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5711 {
5712 /* serialize the req through MC thread */
5713 vosMessage.bodyptr = wlanResumeParam;
5714 vosMessage.type = WDA_WLAN_RESUME_REQ;
5715 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5716 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5717 {
5718 status = eHAL_STATUS_FAILURE;
5719 }
5720 sme_ReleaseGlobalLock( &pMac->sme );
5721 }
5722 return(status);
5723}
5724
5725#endif
5726/* ---------------------------------------------------------------------------
5727
5728 \fn sme_GetInfraSessionId
5729
5730 \brief To get the session ID for infra session, if connected
5731 This is a synchronous API.
5732
5733 \param hHal - The handle returned by macOpen.
5734
5735 \return sessionid, -1 if infra session is not connected
5736
5737 -------------------------------------------------------------------------------*/
5738tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
5739{
5740 eHalStatus status = eHAL_STATUS_FAILURE;
5741 tANI_S8 sessionid = -1;
5742 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5743
5744 status = sme_AcquireGlobalLock( &pMac->sme );
5745 if ( HAL_STATUS_SUCCESS( status ) )
5746 {
5747
5748 sessionid = csrGetInfraSessionId( pMac);
5749
5750 sme_ReleaseGlobalLock( &pMac->sme );
5751 }
5752
5753 return (sessionid);
5754}
5755
5756/* ---------------------------------------------------------------------------
5757
5758 \fn sme_GetInfraOperationChannel
5759
5760 \brief To get the operating channel for infra session, if connected
5761 This is a synchronous API.
5762
5763 \param hHal - The handle returned by macOpen.
5764 \param sessionId - the sessionId returned by sme_OpenSession.
5765
5766 \return operating channel, 0 if infra session is not connected
5767
5768 -------------------------------------------------------------------------------*/
5769tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
5770{
5771 eHalStatus status = eHAL_STATUS_FAILURE;
5772 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5773 tANI_U8 channel = 0;
5774 status = sme_AcquireGlobalLock( &pMac->sme );
5775 if ( HAL_STATUS_SUCCESS( status ) )
5776 {
5777
5778 channel = csrGetInfraOperationChannel( pMac, sessionId);
5779
5780 sme_ReleaseGlobalLock( &pMac->sme );
5781 }
5782
5783 return (channel);
5784}
5785
5786//This routine will return poerating channel on which other BSS is operating to be used for concurrency mode.
5787//If other BSS is not up or not connected it will return 0
5788tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
5789{
5790 eHalStatus status = eHAL_STATUS_FAILURE;
5791 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5792 tANI_U8 channel = 0;
5793 status = sme_AcquireGlobalLock( &pMac->sme );
5794 if ( HAL_STATUS_SUCCESS( status ) )
5795 {
5796
5797 channel = csrGetConcurrentOperationChannel( pMac );
5798 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005799 " Other Concurrent Channel = %d", __func__,channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005800 sme_ReleaseGlobalLock( &pMac->sme );
5801 }
5802
5803 return (channel);
5804}
5805
5806#ifdef FEATURE_WLAN_SCAN_PNO
5807/******************************************************************************
5808*
5809* Name: sme_PreferredNetworkFoundInd
5810*
5811* Description:
5812* Invoke Preferred Network Found Indication
5813*
5814* Parameters:
5815* hHal - HAL handle for device
5816* pMsg - found network description
5817*
5818* Returns: eHalStatus
5819*
5820******************************************************************************/
5821eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
5822{
5823 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5824 eHalStatus status = eHAL_STATUS_SUCCESS;
5825 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
5826
5827 if (NULL == pMsg)
5828 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005829 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 status = eHAL_STATUS_FAILURE;
5831 }
5832 else
5833 {
5834 if (pPrefNetworkFoundInd->ssId.length > 0)
5835 {
5836 smsLog(pMac, LOG1, "Preferred Network Found Indication in %s(), SSID=%s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005837 __func__, pPrefNetworkFoundInd->ssId.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005838
5839
5840 /* Call Preferred Netowrk Found Indication callback routine. */
5841 if (pMac->pmc.prefNetwFoundCB != NULL)
5842 {
5843 pMac->pmc.prefNetwFoundCB(pMac->pmc.preferredNetworkFoundIndCallbackContext, pPrefNetworkFoundInd);
5844 }
5845
5846 }
5847 else
5848 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005849 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 status = eHAL_STATUS_FAILURE;
5851 }
5852 }
5853
5854
5855 return(status);
5856}
5857
5858#endif // FEATURE_WLAN_SCAN_PNO
5859
5860
5861eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
5862{
5863 eHalStatus status = eHAL_STATUS_FAILURE;
5864 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5865
5866 status = sme_AcquireGlobalLock( &pMac->sme );
5867 if ( HAL_STATUS_SUCCESS( status ) )
5868 {
5869 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
5870 sme_ReleaseGlobalLock( &pMac->sme );
5871 }
5872
5873 return (status);
5874}
5875
5876
5877/* ---------------------------------------------------------------------------
5878
5879 \fn sme_SetTxPerTracking
5880
5881 \brief Set Tx PER tracking configuration parameters
5882
5883 \param hHal - The handle returned by macOpen.
5884 \param pTxPerTrackingConf - Tx PER configuration parameters
5885
5886 \return eHalStatus
5887
5888 -------------------------------------------------------------------------------*/
5889eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
5890 void (*pCallbackfn) (void *pCallbackContext),
5891 void *pCallbackContext,
5892 tpSirTxPerTrackingParam pTxPerTrackingParam)
5893{
5894 vos_msg_t msg;
5895 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
5896 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5897
5898 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5899 {
5900 pMac->sme.pTxPerHitCallback = pCallbackfn;
5901 pMac->sme.pTxPerHitCbContext = pCallbackContext;
5902 sme_ReleaseGlobalLock( &pMac->sme );
5903 }
5904
5905 // free this memory in failure case or WDA request callback function
5906 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
5907 if (NULL == pTxPerTrackingParamReq)
5908 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005909 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for tSirTxPerTrackingParam", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 return eHAL_STATUS_FAILURE;
5911 }
5912
5913 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam, sizeof(tSirTxPerTrackingParam));
5914 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
5915 msg.reserved = 0;
5916 msg.bodyptr = pTxPerTrackingParamReq;
5917
5918 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5919 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005920 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_SET_TX_PER_TRACKING_REQ message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 vos_mem_free(pTxPerTrackingParamReq);
5922 return eHAL_STATUS_FAILURE;
5923 }
5924
5925 return eHAL_STATUS_SUCCESS;
5926}
5927
5928/* ---------------------------------------------------------------------------
5929
5930 \fn sme_HandleChangeCountryCode
5931
5932 \brief Change Country code, Reg Domain and channel list
5933
5934 \details Country Code Priority
5935 0 = 11D > Configured Country > NV
5936 1 = Configured Country > 11D > NV
5937 If Supplicant country code is priority than 11d is disabled.
5938 If 11D is enabled, we update the country code after every scan.
5939 Hence when Supplicant country code is priority, we don't need 11D info.
5940 Country code from Supplicant is set as current courtry code.
5941 User can send reset command XX (instead of country code) to reset the
5942 country code to default values which is read from NV.
5943 In case of reset, 11D is enabled and default NV code is Set as current country code
5944 If 11D is priority,
5945 Than Supplicant country code code is set to default code. But 11D code is set as current country code
5946
5947 \param pMac - The handle returned by macOpen.
5948 \param pMsgBuf - MSG Buffer
5949
5950 \return eHalStatus
5951
5952 -------------------------------------------------------------------------------*/
5953eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
5954{
5955 eHalStatus status = eHAL_STATUS_SUCCESS;
5956 tAniChangeCountryCodeReq *pMsg;
5957 v_REGDOMAIN_t domainIdIoctl;
5958 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5959 static uNvTables nvTables;
5960 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
5961
5962
5963 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
5964 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
5965 {
5966 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
5967
5968 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
5969
5970 /* read the country code from NV and use it */
5971 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
5972 {
5973 palCopyMemory( pMac->hHdd, pMsg->countryCode , nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
5974 }
5975 else
5976 {
5977 status = eHAL_STATUS_FAILURE;
5978 return status;
5979 }
5980 }
5981 else
5982 {
5983 /* if Supplicant country code has priority, disable 11d */
5984 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority)
5985 {
5986 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
5987 }
5988 }
5989
5990 /* WEXT set country code means
5991 * 11D should be supported?
5992 * 11D Channel should be enforced?
5993 * 11D Country code should be matched?
5994 * 11D Reg Domian should be matched?
5995 * Country string changed */
5996 if(pMac->roam.configParam.Is11dSupportEnabled &&
5997 pMac->roam.configParam.fEnforce11dChannels &&
5998 pMac->roam.configParam.fEnforceCountryCodeMatch &&
5999 pMac->roam.configParam.fEnforceDefaultDomain &&
6000 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
6001 {
6002 /* All 11D related options are already enabled
6003 * Country string is not changed
6004 * Do not need do anything for country code change request */
6005 return eHAL_STATUS_SUCCESS;
6006 }
6007
6008 /* Set Current Country code and Current Regulatory domain */
6009 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
6010 if(eHAL_STATUS_SUCCESS != status)
6011 {
6012 /* Supplicant country code failed. So give 11D priority */
6013 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6014 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
6015 return status;
6016 }
6017
6018 /* purge current scan results
6019 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).
6020 Looks like a bug in current scan sequence.
6021 */
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07006022 csrScanFlushResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006023
6024 /* overwrite the defualt country code */
6025 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault, pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
6026
6027 /* Get Domain ID from country code */
6028 status = csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent,(v_REGDOMAIN_t *) &domainIdIoctl );
6029 if ( status != eHAL_STATUS_SUCCESS )
6030 {
6031 smsLog( pMac, LOGE, FL(" fail to get regId %d\n"), domainIdIoctl );
6032 return status;
6033 }
6034
6035 status = WDA_SetRegDomain(pMac, domainIdIoctl);
6036
6037 if ( status != eHAL_STATUS_SUCCESS )
6038 {
6039 smsLog( pMac, LOGE, FL(" fail to set regId %d\n"), domainIdIoctl );
6040 return status;
6041 }
6042
6043 /* set to default domain ID */
6044 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
6045
6046 /* get the channels based on new cc */
6047 status = csrInitGetChannels( pMac );
6048
6049 if ( status != eHAL_STATUS_SUCCESS )
6050 {
6051 smsLog( pMac, LOGE, FL(" fail to get Channels \n"));
6052 return status;
6053 }
6054
6055 /* reset info based on new cc, and we are done */
6056 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE);
6057 if( pMsg->changeCCCallback )
6058 {
6059 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
6060 }
6061
6062 return eHAL_STATUS_SUCCESS;
6063}
6064
6065#ifdef WLAN_FEATURE_PACKET_FILTERING
6066eHalStatus sme_8023MulticastList (tHalHandle hHal, tpSirRcvFltMcAddrList pMulticastAddrs)
6067{
6068 tpSirRcvFltMcAddrList pRequestBuf;
6069 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006070 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6071 tANI_U8 sessionId = 0;
6072 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006073
6074 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006075 "ulMulticastAddrCnt=%d, multicastAddr[0]=%d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 pMulticastAddrs->ulMulticastAddrCnt,
6077 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07006078
6079 /*
6080 *Find the connected Infra / P2P_client connected session
6081 */
6082 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
6083 {
6084 if( CSR_IS_SESSION_VALID( pMac, sessionId ) &&
6085 ( csrIsConnStateInfra( pMac, sessionId )) )
6086 {
6087 pSession = CSR_GET_SESSION( pMac, sessionId );
6088 }
6089 }
6090
6091 if(pSession == NULL )
6092 {
6093 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Unable to find "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006094 "the right session", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07006095 return eHAL_STATUS_FAILURE;
6096 }
6097
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6099 if (NULL == pRequestBuf)
6100 {
6101 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006102 "allocate memory for 8023 Multicast List request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006103 return eHAL_STATUS_FAILED_ALLOC;
6104 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006105
6106 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6107 {
6108 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006109 "indication as we are not connected", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006110 vos_mem_free(pRequestBuf);
6111 return eHAL_STATUS_FAILURE;
6112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
6114
Jeff Johnsone7245742012-09-05 17:12:55 -07006115 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6116 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
6117 sizeof(tSirMacAddr));
6118
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 msg.type = WDA_8023_MULTICAST_LIST_REQ;
6120 msg.reserved = 0;
6121 msg.bodyptr = pRequestBuf;
6122 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6123 {
6124 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006125 "post WDA_8023_MULTICAST_LIST message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 vos_mem_free(pRequestBuf);
6127 return eHAL_STATUS_FAILURE;
6128 }
6129
6130 return eHAL_STATUS_SUCCESS;
6131}
6132
Jeff Johnsone7245742012-09-05 17:12:55 -07006133eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
6134 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006135{
6136 tpSirRcvPktFilterCfgType pRequestBuf;
6137 v_SINT_t allocSize;
6138 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006139 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6140 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 v_U8_t idx=0;
6142
6143 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006144 "filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
6146
Madan Mohan Koyyalamudid4029622012-10-18 20:30:17 -07006147 allocSize = sizeof(tSirRcvPktFilterCfgType);
6148
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 pRequestBuf = vos_mem_malloc(allocSize);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006150
6151 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 {
6153 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006154 "allocate memory for Receive Filter Set Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 return eHAL_STATUS_FAILED_ALLOC;
6156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006157
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006158 if( NULL == pSession )
6159 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006160 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Session Not found ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006161 vos_mem_free(pRequestBuf);
6162 return eHAL_STATUS_FAILURE;
6163 }
6164
6165 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6166 {
6167 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006168 "indication as we are not connected", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006169 vos_mem_free(pRequestBuf);
6170 return eHAL_STATUS_FAILURE;
6171 }
6172
6173 vos_mem_copy( pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6174 vos_mem_copy( pRcvPktFilterCfg->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006175 sizeof(tSirMacAddr));
6176
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006177 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
6178
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
6180 msg.reserved = 0;
6181 msg.bodyptr = pRequestBuf;
6182
6183 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6184 "FT %d FID %d ",
6185 pRequestBuf->filterType, pRequestBuf->filterId);
6186
6187 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6188 "params %d CT %d",
6189 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
6190
6191 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
6192 {
6193
6194 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6195 "Proto %d Comp Flag %d \n",
6196 pRequestBuf->paramsData[idx].protocolLayer,
6197 pRequestBuf->paramsData[idx].cmpFlag);
6198
6199 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6200 "Data Offset %d Data Len %d\n",
6201 pRequestBuf->paramsData[idx].dataOffset,
6202 pRequestBuf->paramsData[idx].dataLength);
6203
6204 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6205 "CData: %d:%d:%d:%d:%d:%d\n",
6206 pRequestBuf->paramsData[idx].compareData[0],
6207 pRequestBuf->paramsData[idx].compareData[1],
6208 pRequestBuf->paramsData[idx].compareData[2],
6209 pRequestBuf->paramsData[idx].compareData[3],
6210 pRequestBuf->paramsData[idx].compareData[4],
6211 pRequestBuf->paramsData[idx].compareData[5]);
6212
6213 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6214 "MData: %d:%d:%d:%d:%d:%d\n",
6215 pRequestBuf->paramsData[idx].dataMask[0],
6216 pRequestBuf->paramsData[idx].dataMask[1],
6217 pRequestBuf->paramsData[idx].dataMask[2],
6218 pRequestBuf->paramsData[idx].dataMask[3],
6219 pRequestBuf->paramsData[idx].dataMask[4],
6220 pRequestBuf->paramsData[idx].dataMask[5]);
6221
6222 }
6223
6224 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6225 {
6226 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006227 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 vos_mem_free(pRequestBuf);
6229 return eHAL_STATUS_FAILURE;
6230 }
6231
6232 return eHAL_STATUS_SUCCESS;
6233}
6234
6235eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
6236 FilterMatchCountCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006237 void *callbackContext,
6238 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006239{
6240 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6241 eHalStatus status;
6242
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006243 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006244
6245 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
6246 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006247 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006248 sme_ReleaseGlobalLock( &pMac->sme );
6249 }
6250
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006251 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006252
6253 return (status);
6254}
6255
Jeff Johnsone7245742012-09-05 17:12:55 -07006256eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
6257 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006258{
6259 tpSirRcvFltPktClearParam pRequestBuf;
6260 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006261 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6262 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006263
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006264 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 pRcvFltPktClearParam->filterId);
6266
6267 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006268 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 {
6270 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6271 "%s: Not able to allocate memory for Receive Filter "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006272 "Clear Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 return eHAL_STATUS_FAILED_ALLOC;
6274 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006275 if( NULL == pSession )
6276 {
6277 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006278 "%s: Session Not find ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006279 vos_mem_free(pRequestBuf);
6280 return eHAL_STATUS_FAILURE;
6281 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006282
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006283 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6284 {
6285 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006286 "indication as we are not connected", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006287 vos_mem_free(pRequestBuf);
6288 return eHAL_STATUS_FAILURE;
6289 }
6290
6291 vos_mem_copy( pRcvFltPktClearParam->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6292 vos_mem_copy( pRcvFltPktClearParam->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006293 sizeof(tSirMacAddr));
6294
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006295 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
6296
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
6298 msg.reserved = 0;
6299 msg.bodyptr = pRequestBuf;
6300 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6301 {
6302 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006303 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006304 vos_mem_free(pRequestBuf);
6305 return eHAL_STATUS_FAILURE;
6306 }
6307
6308 return eHAL_STATUS_SUCCESS;
6309}
6310#endif // WLAN_FEATURE_PACKET_FILTERING
6311
6312/* ---------------------------------------------------------------------------
6313 \fn sme_PreChannelSwitchIndFullPowerCB
6314 \brief call back function for the PMC full power request because of pre
6315 channel switch.
6316 \param callbackContext
6317 \param status
6318 ---------------------------------------------------------------------------*/
6319void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
6320 eHalStatus status)
6321{
6322 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
6323 tSirMbMsg *pMsg;
6324 tANI_U16 msgLen;
6325
6326 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
6327 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
6328 if(HAL_STATUS_SUCCESS(status))
6329 {
6330 palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen);
6331 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
6332 pMsg->msgLen = pal_cpu_to_be16(msgLen);
6333 status = palSendMBMessage(pMac->hHdd, pMsg);
6334 }
6335
6336 return;
6337}
6338
6339/* ---------------------------------------------------------------------------
6340 \fn sme_HandlePreChannelSwitchInd
6341 \brief Processes the indcation from PE for pre-channel switch.
6342 \param hHal
6343 \- The handle returned by macOpen. return eHalStatus
6344 ---------------------------------------------------------------------------*/
6345eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
6346{
6347 eHalStatus status = eHAL_STATUS_FAILURE;
6348 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6349 status = sme_AcquireGlobalLock( &pMac->sme );
6350 if ( HAL_STATUS_SUCCESS( status ) )
6351 {
6352 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
6353 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
6354 sme_ReleaseGlobalLock( &pMac->sme );
6355 }
6356
6357 return (status);
6358}
6359
6360/* ---------------------------------------------------------------------------
6361 \fn sme_HandlePostChannelSwitchInd
6362 \brief Processes the indcation from PE for post-channel switch.
6363 \param hHal
6364 \- The handle returned by macOpen. return eHalStatus
6365 ---------------------------------------------------------------------------*/
6366eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
6367{
6368 eHalStatus status = eHAL_STATUS_FAILURE;
6369 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6370
6371 status = sme_AcquireGlobalLock( &pMac->sme );
6372 if ( HAL_STATUS_SUCCESS( status ) )
6373 {
6374 status = pmcRequestBmps(hHal, NULL, NULL);
6375 sme_ReleaseGlobalLock( &pMac->sme );
6376 }
6377
6378 return (status);
6379}
6380
6381/* ---------------------------------------------------------------------------
6382
6383 \fn sme_IsChannelValid
6384
6385 \brief To check if the channel is valid for currently established domain
6386 This is a synchronous API.
6387
6388 \param hHal - The handle returned by macOpen.
6389 \param channel - channel to verify
6390
6391 \return TRUE/FALSE, TRUE if channel is valid
6392
6393 -------------------------------------------------------------------------------*/
6394tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
6395{
6396 eHalStatus status = eHAL_STATUS_FAILURE;
6397 tANI_BOOLEAN valid = FALSE;
6398 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6399
6400 status = sme_AcquireGlobalLock( &pMac->sme );
6401 if ( HAL_STATUS_SUCCESS( status ) )
6402 {
6403
6404 valid = csrRoamIsChannelValid( pMac, channel);
6405
6406 sme_ReleaseGlobalLock( &pMac->sme );
6407 }
6408
6409 return (valid);
6410}
6411
6412/* ---------------------------------------------------------------------------
6413 \fn sme_SetFreqBand
6414 \brief Used to set frequency band.
6415 \param hHal
6416 \eBand band value to be configured
6417 \- return eHalStatus
6418 -------------------------------------------------------------------------*/
6419eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
6420{
6421 eHalStatus status = eHAL_STATUS_FAILURE;
6422 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6423
6424 status = sme_AcquireGlobalLock( &pMac->sme );
6425 if ( HAL_STATUS_SUCCESS( status ) )
6426 {
6427 status = csrSetBand(hHal, eBand);
6428 sme_ReleaseGlobalLock( &pMac->sme );
6429 }
6430 return status;
6431}
6432
6433/* ---------------------------------------------------------------------------
6434 \fn sme_GetFreqBand
6435 \brief Used to get the current band settings.
6436 \param hHal
6437 \pBand pointer to hold band value
6438 \- return eHalStatus
6439 -------------------------------------------------------------------------*/
6440eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
6441{
6442 eHalStatus status = eHAL_STATUS_FAILURE;
6443 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6444
6445 status = sme_AcquireGlobalLock( &pMac->sme );
6446 if ( HAL_STATUS_SUCCESS( status ) )
6447 {
6448 *pBand = csrGetCurrentBand( hHal );
6449 sme_ReleaseGlobalLock( &pMac->sme );
6450 }
6451 return status;
6452}
6453
6454#ifdef WLAN_WAKEUP_EVENTS
6455/******************************************************************************
6456 \fn sme_WakeReasonIndCallback
6457
6458 \brief
6459 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
6460
6461 \param hHal - HAL handle for device
6462 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
6463
6464 \return eHalStatus
6465******************************************************************************/
6466eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
6467{
6468 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6469 eHalStatus status = eHAL_STATUS_SUCCESS;
6470 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
6471
6472 if (NULL == pMsg)
6473 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006474 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 status = eHAL_STATUS_FAILURE;
6476 }
6477 else
6478 {
6479 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback\n");
6480
6481 /* Call Wake Reason Indication callback routine. */
6482 if (pMac->pmc.wakeReasonIndCB != NULL)
6483 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
6484
6485 pMac->pmc.wakeReasonIndCB = NULL;
6486 pMac->pmc.wakeReasonIndCBContext = NULL;
6487
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006488 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __func__, pWakeReasonInd->ulReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 }
6490
6491 return(status);
6492}
6493#endif // WLAN_WAKEUP_EVENTS
6494
6495
6496/* ---------------------------------------------------------------------------
6497
6498 \fn sme_SetMaxTxPower
6499
6500 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
6501 not persist over reboots.
6502
6503 \param hHal
6504 \param pBssid BSSID to set the power cap for
6505 \param pBssid pSelfMacAddress self MAC Address
6506 \param pBssid power to set in dB
6507 \- return eHalStatus
6508
6509 -------------------------------------------------------------------------------*/
6510eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr pBssid,
6511 tSirMacAddr pSelfMacAddress, v_S7_t dB)
6512{
6513 vos_msg_t msg;
6514 tpMaxTxPowerParams pMaxTxParams = NULL;
6515
6516 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
6517 if (NULL == pMaxTxParams)
6518 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006519 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for pMaxTxParams", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 return eHAL_STATUS_FAILURE;
6521 }
6522
6523 vos_mem_copy(pMaxTxParams->bssId, pBssid, SIR_MAC_ADDR_LENGTH);
6524 vos_mem_copy(pMaxTxParams->selfStaMacAddr , pSelfMacAddress,
6525 SIR_MAC_ADDR_LENGTH);
6526 pMaxTxParams->power = dB;
6527
6528 msg.type = WDA_SET_MAX_TX_POWER_REQ;
6529 msg.reserved = 0;
6530 msg.bodyptr = pMaxTxParams;
6531
6532 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6533 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006534 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_SET_MAX_TX_POWER_REQ message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 vos_mem_free(pMaxTxParams);
6536 return eHAL_STATUS_FAILURE;
6537 }
6538
6539 return eHAL_STATUS_SUCCESS;
6540}
6541
6542#ifdef WLAN_SOFTAP_FEATURE
6543/* ---------------------------------------------------------------------------
6544
6545 \fn sme_HideSSID
6546
6547 \brief hide/show SSID dynamically. Note: this setting will
6548 not persist over reboots.
6549
6550 \param hHal
6551 \param sessionId
6552 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
6553 \- return eHalStatus
6554
6555 -------------------------------------------------------------------------------*/
6556eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
6557{
6558 eHalStatus status = eHAL_STATUS_SUCCESS;
6559 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6560 tANI_U16 len;
6561
6562 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6563 {
6564 tpSirUpdateParams pMsg;
6565 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006566
6567 if(!pSession)
6568 {
6569 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6570 return eHAL_STATUS_FAILURE;
6571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006572
6573 if( !pSession->sessionActive )
6574 VOS_ASSERT(0);
6575
6576 /* Create the message and send to lim */
6577 len = sizeof(tSirUpdateParams);
6578 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
6579 if(HAL_STATUS_SUCCESS(status))
6580 {
6581 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirUpdateParams) );
6582 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
6583 pMsg->length = len;
6584 /* Data starts from here */
6585 pMsg->sessionId = sessionId;
6586 pMsg->ssidHidden = ssidHidden;
6587 status = palSendMBMessage(pMac->hHdd, pMsg);
6588 }
6589 sme_ReleaseGlobalLock( &pMac->sme );
6590 }
6591 return status;
6592}
6593#endif
6594
6595/* ---------------------------------------------------------------------------
6596
6597 \fn sme_SetTmLevel
6598 \brief Set Thermal Mitigation Level to RIVA
6599 \param hHal - The handle returned by macOpen.
6600 \param newTMLevel - new Thermal Mitigation Level
6601 \param tmMode - Thermal Mitigation handle mode, default 0
6602 \return eHalStatus
6603 ---------------------------------------------------------------------------*/
6604eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
6605{
6606 eHalStatus status = eHAL_STATUS_SUCCESS;
6607 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6608 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6609 vos_msg_t vosMessage;
6610 tAniSetTmLevelReq *setTmLevelReq = NULL;
6611
6612 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6613 {
6614 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
6615 if(NULL == setTmLevelReq)
6616 {
6617 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006618 "%s: Not able to allocate memory for sme_SetTmLevel", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 return eHAL_STATUS_FAILURE;
6620 }
6621
6622 setTmLevelReq->tmMode = tmMode;
6623 setTmLevelReq->newTmLevel = newTMLevel;
6624
6625 /* serialize the req through MC thread */
6626 vosMessage.bodyptr = setTmLevelReq;
6627 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
6628 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6629 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6630 {
6631 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006632 "%s: Post Set TM Level MSG fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 vos_mem_free(setTmLevelReq);
6634 status = eHAL_STATUS_FAILURE;
6635 }
6636 sme_ReleaseGlobalLock( &pMac->sme );
6637 }
6638 return(status);
6639}
6640
6641/*---------------------------------------------------------------------------
6642
6643 \brief sme_featureCapsExchange() - SME interface to exchange capabilities between
6644 Host and FW.
6645
6646 \param hHal - HAL handle for device
6647
6648 \return NONE
6649
6650---------------------------------------------------------------------------*/
6651void sme_featureCapsExchange( tHalHandle hHal)
6652{
6653 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
6654 WDA_featureCapsExchange(vosContext);
6655}
Jeff Johnsond13512a2012-07-17 11:42:19 -07006656
6657
6658/* ---------------------------------------------------------------------------
6659
6660 \fn sme_GetDefaultCountryCode
6661
6662 \brief Get the default country code from NV
6663
6664 \param hHal
6665 \param pCountry
6666 \- return eHalStatus
6667
6668 -------------------------------------------------------------------------------*/
6669eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
6670{
6671 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6672 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
6673}
6674
6675/* ---------------------------------------------------------------------------
6676
6677 \fn sme_GetCurrentCountryCode
6678
6679 \brief Get the current country code
6680
6681 \param hHal
6682 \param pCountry
6683 \- return eHalStatus
6684
6685 -------------------------------------------------------------------------------*/
6686eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
6687{
6688 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6689 return csrGetCurrentCountryCode(pMac, pCountry);
6690}
6691
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006692/* ---------------------------------------------------------------------------
6693 \fn sme_transportDebug
6694 \brief Dynamically monitoring Transport channels
6695 Private IOCTL will querry transport channel status if driver loaded
6696 \param displaySnapshot Dispaly transport cahnnel snapshot option
6697 \param toggleStallDetect Enable stall detect feature
6698 This feature will take effect to data performance
6699 Not integrate till fully verification
6700 \- return NONE
6701 -------------------------------------------------------------------------*/
6702void sme_transportDebug
6703(
6704 v_BOOL_t displaySnapshot,
6705 v_BOOL_t toggleStallDetect
6706)
6707{
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07006708 WDA_TransportChannelDebug(displaySnapshot, toggleStallDetect);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07006709}