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