blob: 2dac130888bb886cebc45f360a8694cd6f98f603 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
2 * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
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 {
1935 status = csrScanGetResult( hHal, pFilter, phResult );
1936 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 {
1958 status = csrScanFlushResult( hHal );
1959 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
3575 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
3576 {
3577 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
3578 {
3579 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
3580 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
3581 {
3582 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3583 }
3584 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
3585 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
3586 {
3587 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3588 }
3589 }
3590 }
3591#endif
3592
3593 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
3594 sme_ReleaseGlobalLock( &pMac->sme );
3595 }
3596
3597 return (status);
3598}
3599
3600
3601/* ---------------------------------------------------------------------------
3602
3603 \fn sme_RoamRemoveKey
3604
3605 \brief To set encryption key. This is an asynchronous API.
3606
3607 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
3608
3609 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3610
3611 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3612
3613 FAILURE or RESOURCES The API finished and failed.
3614
3615 -------------------------------------------------------------------------------*/
3616eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
3617 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
3618{
3619 eHalStatus status = eHAL_STATUS_FAILURE;
3620 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3621 tANI_U32 roamId;
3622
3623 status = sme_AcquireGlobalLock( &pMac->sme );
3624 if ( HAL_STATUS_SUCCESS( status ) )
3625 {
3626 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3627 if(pRoamId)
3628 {
3629 *pRoamId = roamId;
3630 }
3631 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
3632 sme_ReleaseGlobalLock( &pMac->sme );
3633 }
3634
3635 return (status);
3636}
3637
3638/* ---------------------------------------------------------------------------
3639 \fn sme_GetRssi
3640 \brief a wrapper function that client calls to register a callback to get RSSI
3641
3642 \param callback - SME sends back the requested stats using the callback
3643 \param staId - The station ID for which the stats is requested for
3644 \param pContext - user context to be passed back along with the callback
3645 \param pVosContext - vos context
3646 \return eHalStatus
3647 ---------------------------------------------------------------------------*/
3648eHalStatus sme_GetRssi(tHalHandle hHal,
3649 tCsrRssiCallback callback,
3650 tANI_U8 staId, tCsrBssid bssId,
3651 void *pContext, void* pVosContext)
3652{
3653 eHalStatus status = eHAL_STATUS_FAILURE;
3654 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3655
3656 status = sme_AcquireGlobalLock( &pMac->sme );
3657 if ( HAL_STATUS_SUCCESS( status ) )
3658 {
3659 status = csrGetRssi( pMac, callback,
3660 staId, bssId, pContext, pVosContext);
3661 sme_ReleaseGlobalLock( &pMac->sme );
3662 }
3663 return (status);
3664}
3665
3666/* ---------------------------------------------------------------------------
3667 \fn sme_GetStatistics
3668 \brief a wrapper function that client calls to register a callback to get
3669 different PHY level statistics from CSR.
3670
3671 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
3672 \param statsMask - The different category/categories of stats requester is looking for
3673 \param callback - SME sends back the requested stats using the callback
3674 \param periodicity - If requester needs periodic update in millisec, 0 means
3675 it's an one time request
3676 \param cache - If requester is happy with cached stats
3677 \param staId - The station ID for which the stats is requested for
3678 \param pContext - user context to be passed back along with the callback
3679 \return eHalStatus
3680 ---------------------------------------------------------------------------*/
3681eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
3682 tANI_U32 statsMask,
3683 tCsrStatsCallback callback,
3684 tANI_U32 periodicity, tANI_BOOLEAN cache,
3685 tANI_U8 staId, void *pContext)
3686{
3687 eHalStatus status = eHAL_STATUS_FAILURE;
3688 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3689
3690 status = sme_AcquireGlobalLock( &pMac->sme );
3691 if ( HAL_STATUS_SUCCESS( status ) )
3692 {
3693 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
3694 periodicity, cache, staId, pContext);
3695 sme_ReleaseGlobalLock( &pMac->sme );
3696 }
3697
3698 return (status);
3699
3700}
3701
3702/* ---------------------------------------------------------------------------
3703
3704 \fn sme_GetCountryCode
3705
3706 \brief To return the current country code. If no country code is applied, default country code is
3707 used to fill the buffer.
3708 If 11d supported is turned off, an error is return and the last applied/default country code is used.
3709 This is a synchronous API.
3710
3711 \param pBuf - pointer to a caller allocated buffer for returned country code.
3712
3713 \param pbLen For input, this parameter indicates how big is the buffer.
3714 Upon return, this parameter has the number of bytes for country. If pBuf
3715 doesn't have enough space, this function returns
3716 fail status and this parameter contains the number that is needed.
3717
3718 \return eHalStatus SUCCESS.
3719
3720 FAILURE or RESOURCES The API finished and failed.
3721
3722 -------------------------------------------------------------------------------*/
3723eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
3724{
3725 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3726
3727 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
3728}
3729
3730
3731/* ---------------------------------------------------------------------------
3732
3733 \fn sme_SetCountryCode
3734
3735 \brief To change the current/default country code.
3736 If 11d supported is turned off, an error is return.
3737 This is a synchronous API.
3738
3739 \param pCountry - pointer to a caller allocated buffer for the country code.
3740
3741 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
3742 whether a reset is required.
3743
3744 \return eHalStatus SUCCESS.
3745
3746 FAILURE or RESOURCES The API finished and failed.
3747
3748 -------------------------------------------------------------------------------*/
3749eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
3750{
3751 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3752
3753 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
3754}
3755
3756
3757/* ---------------------------------------------------------------------------
3758 \fn sme_ResetCountryCodeInformation
3759 \brief this function is to reset the country code current being used back to EEPROM default
3760 this includes channel list and power setting. This is a synchronous API.
3761 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
3762 a restart is needed to apply the change
3763 \return eHalStatus
3764 -------------------------------------------------------------------------------*/
3765eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
3766{
3767 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3768
3769 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
3770}
3771
3772
3773/* ---------------------------------------------------------------------------
3774 \fn sme_GetSupportedCountryCode
3775 \brief this function is to get a list of the country code current being supported
3776 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
3777 this has the country code list. 3 bytes for each country code. This may be NULL if
3778 caller wants to know the needed byte count.
3779 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
3780 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
3781 \return eHalStatus
3782 -------------------------------------------------------------------------------*/
3783eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
3784{
3785 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3786
3787 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
3788}
3789
3790
3791/* ---------------------------------------------------------------------------
3792 \fn sme_GetCurrentRegulatoryDomain
3793 \brief this function is to get the current regulatory domain. This is a synchronous API.
3794 This function must be called after CFG is downloaded and all the band/mode setting already passed into
3795 SME. The function fails if 11d support is turned off.
3796 \param pDomain - Caller allocated buffer to return the current domain.
3797 \return eHalStatus SUCCESS.
3798
3799 FAILURE or RESOURCES The API finished and failed.
3800 -------------------------------------------------------------------------------*/
3801eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
3802{
3803 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3804 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
3805
3806 if( pDomain )
3807 {
3808 if( csrIs11dSupported( pMac ) )
3809 {
3810 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
3811 status = eHAL_STATUS_SUCCESS;
3812 }
3813 else
3814 {
3815 status = eHAL_STATUS_FAILURE;
3816 }
3817 }
3818
3819 return ( status );
3820}
3821
3822
3823/* ---------------------------------------------------------------------------
3824 \fn sme_SetRegulatoryDomain
3825 \brief this function is to set the current regulatory domain.
3826 This function must be called after CFG is downloaded and all the band/mode setting already passed into
3827 SME. This is a synchronous API.
3828 \param domainId - indicate the domain (defined in the driver) needs to set to.
3829 See v_REGDOMAIN_t for definition
3830 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
3831 a restart is needed to apply the change
3832 \return eHalStatus
3833 -------------------------------------------------------------------------------*/
3834eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
3835{
3836 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3837
3838 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
3839}
3840
3841
3842/* ---------------------------------------------------------------------------
3843
3844 \fn sme_GetRegulatoryDomainForCountry
3845
3846 \brief To return a regulatory domain base on a country code. This is a synchronous API.
3847
3848 \param pCountry - pointer to a caller allocated buffer for input country code.
3849
3850 \param pDomainId Upon successful return, it is the domain that country belongs to.
3851 If it is NULL, returning success means that the country code is known.
3852
3853 \return eHalStatus SUCCESS.
3854
3855 FAILURE or RESOURCES The API finished and failed.
3856
3857 -------------------------------------------------------------------------------*/
3858eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
3859{
3860 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3861
3862 return ( csrGetRegulatoryDomainForCountry( pMac, pCountry, pDomainId ) );
3863}
3864
3865
3866
3867
3868/* ---------------------------------------------------------------------------
3869
3870 \fn sme_GetSupportedRegulatoryDomains
3871
3872 \brief To return a list of supported regulatory domains. This is a synchronous API.
3873
3874 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
3875
3876 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
3877 Upon return, this parameter has the number for supported domains. If pDomains
3878 doesn't have enough space for all the supported domains, this function returns
3879 fail status and this parameter contains the number that is needed.
3880
3881 \return eHalStatus SUCCESS.
3882
3883 FAILURE or RESOURCES The API finished and failed.
3884
3885 -------------------------------------------------------------------------------*/
3886eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
3887{
3888 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
3889
3890 //We support all domains for now
3891 if( pNumDomains )
3892 {
3893 if( NUM_REG_DOMAINS <= *pNumDomains )
3894 {
3895 status = eHAL_STATUS_SUCCESS;
3896 }
3897 *pNumDomains = NUM_REG_DOMAINS;
3898 }
3899 if( HAL_STATUS_SUCCESS( status ) )
3900 {
3901 if( pDomains )
3902 {
3903 pDomains[0] = REGDOMAIN_FCC;
3904 pDomains[1] = REGDOMAIN_ETSI;
3905 pDomains[2] = REGDOMAIN_JAPAN;
3906 pDomains[3] = REGDOMAIN_WORLD;
3907 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
3908 pDomains[5] = REGDOMAIN_APAC;
3909 pDomains[6] = REGDOMAIN_KOREA;
3910 pDomains[7] = REGDOMAIN_HI_5GHZ;
3911 pDomains[8] = REGDOMAIN_NO_5GHZ;
3912 }
3913 else
3914 {
3915 status = eHAL_STATUS_INVALID_PARAMETER;
3916 }
3917 }
3918
3919 return ( status );
3920}
3921
3922
3923//some support functions
3924tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
3925{
3926 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3927
3928 return ( csrIs11dSupported( pMac ) );
3929}
3930
3931
3932tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
3933{
3934 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3935
3936 return ( csrIs11hSupported( pMac ) );
3937}
3938
3939
3940tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
3941{
3942 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3943
3944 return ( csrIsWmmSupported( pMac ) );
3945}
3946
3947//Upper layer to get the list of the base channels to scan for passively 11d info from csr
3948eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
3949{
3950 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3951
3952 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
3953}
3954
3955/* ---------------------------------------------------------------------------
3956
3957 \fn sme_ChangeCountryCode
3958
3959 \brief Change Country code from upperlayer during WLAN driver operation.
3960 This is a synchronous API.
3961
3962 \param hHal - The handle returned by macOpen.
3963
3964 \param pCountry New Country Code String
3965
3966 \return eHalStatus SUCCESS.
3967
3968 FAILURE or RESOURCES The API finished and failed.
3969
3970 -------------------------------------------------------------------------------*/
3971eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
3972 tSmeChangeCountryCallback callback,
3973 tANI_U8 *pCountry,
3974 void *pContext,
3975 void* pVosContext )
3976{
3977 eHalStatus status = eHAL_STATUS_FAILURE;
3978 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3979 vos_msg_t msg;
3980 tAniChangeCountryCodeReq *pMsg;
3981
3982 status = sme_AcquireGlobalLock( &pMac->sme );
3983 if ( HAL_STATUS_SUCCESS( status ) )
3984 {
3985 smsLog(pMac, LOG1, FL(" called\n"));
3986 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniChangeCountryCodeReq));
3987 if ( !HAL_STATUS_SUCCESS(status) )
3988 {
3989 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req \n");
3990 return status;
3991 }
3992
3993 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
3994 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
3995 palCopyMemory(pMac->hHdd, pMsg->countryCode, pCountry, 3);
3996 pMsg->changeCCCallback = callback;
3997 pMsg->pDevContext = pContext;
3998 pMsg->pVosContext = pVosContext;
3999
4000 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4001 msg.bodyptr = pMsg;
4002 msg.reserved = 0;
4003
4004 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
4005 {
4006 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self \n");
4007 palFreeMemory(pMac->hHdd, (void *)pMsg);
4008 status = eHAL_STATUS_FAILURE;
4009 }
4010 smsLog(pMac, LOG1, FL(" returned\n"));
4011 sme_ReleaseGlobalLock( &pMac->sme );
4012 }
4013
4014 return (status);
4015}
4016
4017/* ---------------------------------------------------------------------------
4018 \fn sme_BtcSignalBtEvent
4019 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
4020 BT event type and the current operating mode of Libra (full power,
4021 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
4022 would be employed.
4023 \param hHal - The handle returned by macOpen.
4024 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
4025 Caller owns the memory and is responsible for freeing it.
4026 \return VOS_STATUS
4027 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
4028 if BTC execution mode is set to BTC_WLAN_ONLY
4029 or BTC_PTA_ONLY.
4030 VOS_STATUS_SUCCESS BT Event passed to HAL
4031 ---------------------------------------------------------------------------*/
4032VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
4033{
4034 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4035#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4036 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4037
4038 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4039 {
4040 status = btcSignalBTEvent (hHal, pBtEvent);
4041 sme_ReleaseGlobalLock( &pMac->sme );
4042 }
4043#endif
4044 return (status);
4045}
4046
4047/* ---------------------------------------------------------------------------
4048 \fn sme_BtcSetConfig
4049 \brief API to change the current Bluetooth Coexistence (BTC) configuration
4050 This function should be invoked only after CFG download has completed.
4051 Calling it after sme_HDDReadyInd is recommended.
4052 \param hHal - The handle returned by macOpen.
4053 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
4054 Caller owns the memory and is responsible for freeing it.
4055 \return VOS_STATUS
4056 VOS_STATUS_E_FAILURE Config not passed to HAL.
4057 VOS_STATUS_SUCCESS Config passed to HAL
4058 ---------------------------------------------------------------------------*/
4059VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4060{
4061 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4062#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4063 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4064 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4065 {
4066 status = btcSetConfig (hHal, pSmeBtcConfig);
4067 sme_ReleaseGlobalLock( &pMac->sme );
4068 }
4069#endif
4070 return (status);
4071}
4072
4073/* ---------------------------------------------------------------------------
4074 \fn sme_BtcGetConfig
4075 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
4076 \param hHal - The handle returned by macOpen.
4077 \param pSmeBtcConfig - Pointer to a caller allocated object of type
4078 tSmeBtcConfig. Caller owns the memory and is responsible
4079 for freeing it.
4080 \return VOS_STATUS
4081 VOS_STATUS_E_FAILURE - failure
4082 VOS_STATUS_SUCCESS success
4083 ---------------------------------------------------------------------------*/
4084VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4085{
4086 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4087#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4088 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4089
4090 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4091 {
4092 status = btcGetConfig (hHal, pSmeBtcConfig);
4093 sme_ReleaseGlobalLock( &pMac->sme );
4094 }
4095#endif
4096 return (status);
4097}
4098/* ---------------------------------------------------------------------------
4099 \fn sme_SetCfgPrivacy
4100 \brief API to set configure privacy parameters
4101 \param hHal - The handle returned by macOpen.
4102 \param pProfile - Pointer CSR Roam profile.
4103 \param fPrivacy - This parameter indicates status of privacy
4104
4105 \return void
4106 ---------------------------------------------------------------------------*/
4107void sme_SetCfgPrivacy( tHalHandle hHal,
4108 tCsrRoamProfile *pProfile,
4109 tANI_BOOLEAN fPrivacy
4110 )
4111{
4112 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4113 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4114 {
4115 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
4116 sme_ReleaseGlobalLock( &pMac->sme );
4117 }
4118}
4119
4120#if defined WLAN_FEATURE_VOWIFI
4121/* ---------------------------------------------------------------------------
4122 \fn sme_NeighborReportRequest
4123 \brief API to request neighbor report.
4124 \param hHal - The handle returned by macOpen.
4125 \param pRrmNeighborReq - Pointer to a caller allocated object of type
4126 tRrmNeighborReq. Caller owns the memory and is responsible
4127 for freeing it.
4128 \return VOS_STATUS
4129 VOS_STATUS_E_FAILURE - failure
4130 VOS_STATUS_SUCCESS success
4131 ---------------------------------------------------------------------------*/
4132VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
4133 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
4134{
4135 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4136 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4137
4138 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4139 {
4140 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
4141 sme_ReleaseGlobalLock( &pMac->sme );
4142 }
4143
4144 return (status);
4145}
4146#endif
4147
4148//The following are debug APIs to support direct read/write register/memory
4149//They are placed in SME because HW cannot be access when in LOW_POWER state
4150//AND not connected. The knowledge and synchronization is done in SME
4151
4152//sme_DbgReadRegister
4153//Caller needs to validate the input values
4154VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
4155{
4156 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4157 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4158#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4159 tHddHandle hHdd = pMac->hHdd;
4160#endif
4161 tPmcPowerState PowerState;
4162 tANI_U32 sessionId = 0;
4163
4164 /* 1) To make Quarky work in FTM mode **************************************/
4165
4166 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4167 {
4168#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4169 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue)))
4170#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4171 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
4172#endif
4173 {
4174 return VOS_STATUS_SUCCESS;
4175 }
4176 return VOS_STATUS_E_FAILURE;
4177 }
4178
4179 /* 2) NON FTM mode driver *************************************************/
4180
4181 /* Acquire SME global lock */
4182 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4183 {
4184 return VOS_STATUS_E_FAILURE;
4185 }
4186
4187 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4188 {
4189 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4190 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4191 {
4192#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4193 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue )))
4194#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4195 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
4196#endif
4197 {
4198 status = VOS_STATUS_SUCCESS;
4199 }
4200 else
4201 {
4202 status = VOS_STATUS_E_FAILURE;
4203 }
4204 }
4205 else
4206 {
4207 status = VOS_STATUS_E_FAILURE;
4208 }
4209 }
4210
4211 /* This is a hack for Qualky/pttWniSocket
4212 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4213 if ( VOS_STATUS_SUCCESS != status )
4214 {
4215 *pRegValue = 0xDEADBEEF;
4216 status = VOS_STATUS_SUCCESS;
4217 }
4218
4219 /* Release SME global lock */
4220 sme_ReleaseGlobalLock(&pMac->sme);
4221
4222 return (status);
4223}
4224
4225
4226//sme_DbgWriteRegister
4227//Caller needs to validate the input values
4228VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
4229{
4230 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4231 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4232#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4233 tHddHandle hHdd = pMac->hHdd;
4234#endif
4235 tPmcPowerState PowerState;
4236 tANI_U32 sessionId = 0;
4237
4238 /* 1) To make Quarky work in FTM mode **************************************/
4239
4240 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4241 {
4242#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4243 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4244#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4245 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4246#endif
4247 {
4248 return VOS_STATUS_SUCCESS;
4249 }
4250 return VOS_STATUS_E_FAILURE;
4251 }
4252
4253 /* 2) NON FTM mode driver *************************************************/
4254
4255 /* Acquire SME global lock */
4256 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4257 {
4258 return VOS_STATUS_E_FAILURE;
4259 }
4260
4261 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4262 {
4263 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4264 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4265 {
4266#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4267 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4268#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4269 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4270#endif
4271 {
4272 status = VOS_STATUS_SUCCESS;
4273 }
4274 else
4275 {
4276 status = VOS_STATUS_E_FAILURE;
4277 }
4278 }
4279 else
4280 {
4281 status = VOS_STATUS_E_FAILURE;
4282 }
4283 }
4284
4285 /* Release SME global lock */
4286 sme_ReleaseGlobalLock(&pMac->sme);
4287
4288 return (status);
4289}
4290
4291
4292
4293//sme_DbgReadMemory
4294//Caller needs to validate the input values
4295//pBuf caller allocated buffer has the length of nLen
4296VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4297{
4298 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4299 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4300#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4301 v_PVOID_t pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *)hHal);
4302 tHddHandle hHdd = pMac->hHdd;
4303#endif
4304 tPmcPowerState PowerState;
4305 tANI_U32 sessionId = 0;
4306
4307 /* 1) To make Quarky work in FTM mode **************************************/
4308
4309 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4310 {
4311#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4312 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4313#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4314 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadMemory(memAddr, (void *)pBuf, nLen))
4315#endif
4316 {
4317 return VOS_STATUS_SUCCESS;
4318 }
4319 return VOS_STATUS_E_FAILURE;
4320 }
4321
4322 /* 2) NON FTM mode driver *************************************************/
4323
4324 /* Acquire SME global lock */
4325 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4326 {
4327 return VOS_STATUS_E_FAILURE;
4328 }
4329
4330 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4331 {
4332 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4333 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4334 {
4335#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4336 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(pvosGCTx, memAddr, (void *)pBuf, nLen)))
4337#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4338 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadMemory(memAddr, (void *)pBuf, nLen))
4339#endif
4340 {
4341 status = VOS_STATUS_SUCCESS;
4342 }
4343 else
4344 {
4345 status = VOS_STATUS_E_FAILURE;
4346 }
4347 }
4348 else
4349 {
4350 status = VOS_STATUS_E_FAILURE;
4351 }
4352 }
4353
4354 /* This is a hack for Qualky/pttWniSocket
4355 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4356 if (VOS_STATUS_SUCCESS != status)
4357 {
4358 vos_mem_set(pBuf, nLen, 0xCD);
4359 status = VOS_STATUS_SUCCESS;
4360 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware\n"));
4361 }
4362
4363 /* Release SME lock */
4364 sme_ReleaseGlobalLock(&pMac->sme);
4365
4366 return (status);
4367}
4368
4369
4370//sme_DbgWriteMemory
4371//Caller needs to validate the input values
4372VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4373{
4374 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4375 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4376#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4377 tHddHandle hHdd = pMac->hHdd;
4378#endif
4379 tPmcPowerState PowerState;
4380 tANI_U32 sessionId = 0;
4381
4382 /* 1) To make Quarky work in FTM mode **************************************/
4383
4384 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4385 {
4386#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4387 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4388#elif defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4389 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory( memAddr, (void *)pBuf, nLen))
4390#endif
4391 {
4392 return VOS_STATUS_SUCCESS;
4393 }
4394 return VOS_STATUS_E_FAILURE;
4395 }
4396
4397 /* 2) NON FTM mode driver *************************************************/
4398
4399 /* Acquire SME global lock */
4400 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4401 {
4402 return VOS_STATUS_E_FAILURE;
4403 }
4404
4405 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4406 {
4407 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4408 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4409 {
4410#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4411 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4412#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4413 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
4414#endif
4415 {
4416 status = VOS_STATUS_SUCCESS;
4417 }
4418 else
4419 {
4420 status = VOS_STATUS_E_FAILURE;
4421 }
4422 }
4423 else
4424 {
4425 status = VOS_STATUS_E_FAILURE;
4426 }
4427 }
4428
4429 /* Release Global lock */
4430 sme_ReleaseGlobalLock(&pMac->sme);
4431
4432 return (status);
4433}
4434
4435
4436void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
4437{
4438#ifdef WLAN_DEBUG
4439 // Verify against current log level
4440 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
4441 return;
4442 else
4443 {
4444 va_list marker;
4445
4446 va_start( marker, pString ); /* Initialize variable arguments. */
4447
4448 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
4449
4450 va_end( marker ); /* Reset variable arguments. */
4451 }
4452#endif
4453}
4454#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
4455/* ---------------------------------------------------------------------------
4456 \fn sme_GetFwVersion
4457 \brief This API returns the firmware version.
4458 \param hHal - The handle returned by macOpen.
4459 \param version - Points to the FwVersionInfo structure.
4460 \return VOS_STATUS
4461 VOS_STATUS_E_INVAL - failure
4462 VOS_STATUS_SUCCESS success
4463 ---------------------------------------------------------------------------*/
4464VOS_STATUS sme_GetFwVersion (tHalHandle hHal,FwVersionInfo *pVersion)
4465{
4466 VOS_STATUS status = VOS_STATUS_SUCCESS;
4467 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4468
4469 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4470 {
4471 if( pVersion != NULL ) {
4472 vos_mem_copy((v_VOID_t*)pVersion,(v_VOID_t*)&pMac->hal.FwParam.fwVersion, sizeof(FwVersionInfo));
4473 }
4474 else {
4475 status = VOS_STATUS_E_INVAL;
4476 }
4477 sme_ReleaseGlobalLock( &pMac->sme );
4478 }
4479
4480 return (status);
4481}
4482#endif
4483
4484#ifdef FEATURE_WLAN_INTEGRATED_SOC
4485/* ---------------------------------------------------------------------------
4486 \fn sme_GetWcnssWlanCompiledVersion
4487 \brief This API returns the version of the WCNSS WLAN API with
4488 which the HOST driver was built
4489 \param hHal - The handle returned by macOpen.
4490 \param pVersion - Points to the Version structure to be filled
4491 \return VOS_STATUS
4492 VOS_STATUS_E_INVAL - failure
4493 VOS_STATUS_SUCCESS success
4494 ---------------------------------------------------------------------------*/
4495VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
4496 tSirVersionType *pVersion)
4497{
4498 VOS_STATUS status = VOS_STATUS_SUCCESS;
4499 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4500 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4501
4502 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4503 {
4504 if( pVersion != NULL )
4505 {
4506 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
4507 }
4508 else
4509 {
4510 status = VOS_STATUS_E_INVAL;
4511 }
4512 sme_ReleaseGlobalLock( &pMac->sme );
4513 }
4514
4515 return (status);
4516}
4517
4518
4519/* ---------------------------------------------------------------------------
4520 \fn sme_GetWcnssWlanReportedVersion
4521 \brief This API returns the version of the WCNSS WLAN API with
4522 which the WCNSS driver reports it was built
4523 \param hHal - The handle returned by macOpen.
4524 \param pVersion - Points to the Version structure to be filled
4525 \return VOS_STATUS
4526 VOS_STATUS_E_INVAL - failure
4527 VOS_STATUS_SUCCESS success
4528 ---------------------------------------------------------------------------*/
4529VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
4530 tSirVersionType *pVersion)
4531{
4532 VOS_STATUS status = VOS_STATUS_SUCCESS;
4533 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4534 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4535
4536 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4537 {
4538 if( pVersion != NULL )
4539 {
4540 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
4541 }
4542 else
4543 {
4544 status = VOS_STATUS_E_INVAL;
4545 }
4546 sme_ReleaseGlobalLock( &pMac->sme );
4547 }
4548
4549 return (status);
4550}
4551
4552
4553/* ---------------------------------------------------------------------------
4554 \fn sme_GetWcnssSoftwareVersion
4555 \brief This API returns the version string of the WCNSS driver
4556 \param hHal - The handle returned by macOpen.
4557 \param pVersion - Points to the Version string buffer to be filled
4558 \param versionBufferSize - THe size of the Version string buffer
4559 \return VOS_STATUS
4560 VOS_STATUS_E_INVAL - failure
4561 VOS_STATUS_SUCCESS success
4562 ---------------------------------------------------------------------------*/
4563VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
4564 tANI_U8 *pVersion,
4565 tANI_U32 versionBufferSize)
4566{
4567 VOS_STATUS status = VOS_STATUS_SUCCESS;
4568 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4569 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4570
4571 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4572 {
4573 if( pVersion != NULL )
4574 {
4575 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
4576 versionBufferSize);
4577 }
4578 else
4579 {
4580 status = VOS_STATUS_E_INVAL;
4581 }
4582 sme_ReleaseGlobalLock( &pMac->sme );
4583 }
4584
4585 return (status);
4586}
4587
4588
4589/* ---------------------------------------------------------------------------
4590 \fn sme_GetWcnssHardwareVersion
4591 \brief This API returns the version string of the WCNSS hardware
4592 \param hHal - The handle returned by macOpen.
4593 \param pVersion - Points to the Version string buffer to be filled
4594 \param versionBufferSize - THe size of the Version string buffer
4595 \return VOS_STATUS
4596 VOS_STATUS_E_INVAL - failure
4597 VOS_STATUS_SUCCESS success
4598 ---------------------------------------------------------------------------*/
4599VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
4600 tANI_U8 *pVersion,
4601 tANI_U32 versionBufferSize)
4602{
4603 VOS_STATUS status = VOS_STATUS_SUCCESS;
4604 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4605 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4606
4607 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4608 {
4609 if( pVersion != NULL )
4610 {
4611 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
4612 versionBufferSize);
4613 }
4614 else
4615 {
4616 status = VOS_STATUS_E_INVAL;
4617 }
4618 sme_ReleaseGlobalLock( &pMac->sme );
4619 }
4620
4621 return (status);
4622}
4623#endif
4624
4625#ifdef FEATURE_WLAN_WAPI
4626/* ---------------------------------------------------------------------------
4627 \fn sme_RoamSetBKIDCache
4628 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
4629 candidate list.
4630 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4631 it is opened (by calling halOpen).
4632 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
4633 \param numItems - a variable that has the number of tBkidCacheInfo allocated
4634 when retruning, this is the number of items put into pBKIDCache
4635 \return eHalStatus - when fail, it usually means the buffer allocated is not
4636 big enough and pNumItems has the number of tBkidCacheInfo.
4637 ---------------------------------------------------------------------------*/
4638eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
4639 tANI_U32 numItems )
4640{
4641 eHalStatus status = eHAL_STATUS_FAILURE;
4642 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4643
4644 status = sme_AcquireGlobalLock( &pMac->sme );
4645 if ( HAL_STATUS_SUCCESS( status ) )
4646 {
4647 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
4648 sme_ReleaseGlobalLock( &pMac->sme );
4649 }
4650
4651 return (status);
4652}
4653
4654/* ---------------------------------------------------------------------------
4655 \fn sme_RoamGetBKIDCache
4656 \brief The SME API exposed to HDD to allow HDD to request SME to return its
4657 BKID cache.
4658 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4659 it is opened (by calling halOpen).
4660 \param pNum - caller allocated memory that has the space of the number of
4661 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
4662 in SME cache.
4663 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
4664 upon return
4665 \return eHalStatus - when fail, it usually means the buffer allocated is not
4666 big enough.
4667 ---------------------------------------------------------------------------*/
4668eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
4669 tBkidCacheInfo *pBkidCache)
4670{
4671 eHalStatus status = eHAL_STATUS_FAILURE;
4672 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4673
4674 status = sme_AcquireGlobalLock( &pMac->sme );
4675 if ( HAL_STATUS_SUCCESS( status ) )
4676 {
4677 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded\n"));
4678 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
4679 sme_ReleaseGlobalLock( &pMac->sme );
4680 }
4681
4682 return (status);
4683}
4684
4685/* ---------------------------------------------------------------------------
4686 \fn sme_RoamGetNumBKIDCache
4687 \brief The SME API exposed to HDD to allow HDD to request SME to return the
4688 number of BKID cache entries.
4689 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4690 it is opened (by calling halOpen).
4691 \return tANI_U32 - the number of BKID cache entries.
4692 ---------------------------------------------------------------------------*/
4693tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
4694{
4695 eHalStatus status = eHAL_STATUS_FAILURE;
4696 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4697 tANI_U32 numBkidCache = 0;
4698
4699 status = sme_AcquireGlobalLock( &pMac->sme );
4700 if ( HAL_STATUS_SUCCESS( status ) )
4701 {
4702 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
4703 sme_ReleaseGlobalLock( &pMac->sme );
4704 }
4705
4706 return (numBkidCache);
4707}
4708
4709/* ---------------------------------------------------------------------------
4710 \fn sme_ScanGetBKIDCandidateList
4711 \brief a wrapper function to return the BKID candidate list
4712 \param pBkidList - caller allocated buffer point to an array of
4713 tBkidCandidateInfo
4714 \param pNumItems - pointer to a variable that has the number of
4715 tBkidCandidateInfo allocated when retruning, this is
4716 either the number needed or number of items put into
4717 pPmkidList
4718 \return eHalStatus - when fail, it usually means the buffer allocated is not
4719 big enough and pNumItems
4720 has the number of tBkidCandidateInfo.
4721 \Note: pNumItems is a number of tBkidCandidateInfo,
4722 not sizeof(tBkidCandidateInfo) * something
4723 ---------------------------------------------------------------------------*/
4724eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
4725 tBkidCandidateInfo *pBkidList,
4726 tANI_U32 *pNumItems )
4727{
4728 eHalStatus status = eHAL_STATUS_FAILURE;
4729 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4730
4731 status = sme_AcquireGlobalLock( &pMac->sme );
4732 if ( HAL_STATUS_SUCCESS( status ) )
4733 {
4734 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
4735 sme_ReleaseGlobalLock( &pMac->sme );
4736 }
4737
4738 return (status);
4739}
4740#endif /* FEATURE_WLAN_WAPI */
4741
Jeff Johnsone7245742012-09-05 17:12:55 -07004742#ifdef FEATURE_OEM_DATA_SUPPORT
4743
4744/*****************************************************************************
4745 OEM DATA related modifications and function additions
4746 *****************************************************************************/
4747
4748/* ---------------------------------------------------------------------------
4749 \fn sme_getOemDataRsp
4750 \brief a wrapper function to obtain the OEM DATA RSP
4751 \param pOemDataRsp - A pointer to the response object
4752 \param pContext - a pointer passed in for the callback
4753 \return eHalStatus
4754 ---------------------------------------------------------------------------*/
4755eHalStatus sme_getOemDataRsp(tHalHandle hHal,
4756 tOemDataRsp **pOemDataRsp)
4757{
4758 eHalStatus status = eHAL_STATUS_SUCCESS;
4759 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4760
4761 do
4762 {
4763 //acquire the lock for the sme object
4764 status = sme_AcquireGlobalLock(&pMac->sme);
4765
4766 if(!HAL_STATUS_SUCCESS(status))
4767 {
4768 break;
4769 }
4770
4771 if(pMac->oemData.pOemDataRsp != NULL)
4772 {
4773 *pOemDataRsp = pMac->oemData.pOemDataRsp;
4774 }
4775 else
4776 {
4777 status = eHAL_STATUS_FAILURE;
4778 }
4779
4780 //release the lock for the sme object
4781 sme_ReleaseGlobalLock( &pMac->sme );
4782
4783 } while(0);
4784
4785 return status;
4786}
4787
4788/* ---------------------------------------------------------------------------
4789 \fn sme_OemDataReq
4790 \brief a wrapper function for OEM DATA REQ
4791 \param sessionId - session id to be used.
4792 \param pOemDataReqId - pointer to an object to get back the request ID
4793 \param callback - a callback function that is called upon finish
4794 \param pContext - a pointer passed in for the callback
4795 \return eHalStatus
4796 ---------------------------------------------------------------------------*/
4797eHalStatus sme_OemDataReq(tHalHandle hHal,
4798 tANI_U8 sessionId,
4799 tOemDataReqConfig *pOemDataReqConfig,
4800 tANI_U32 *pOemDataReqID,
4801 oemData_OemDataReqCompleteCallback callback,
4802 void *pContext)
4803{
4804 eHalStatus status = eHAL_STATUS_SUCCESS;
4805 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4806
4807 do
4808 {
4809 //acquire the lock for the sme object
4810 status = sme_AcquireGlobalLock(&pMac->sme);
4811 if(HAL_STATUS_SUCCESS(status))
4812 {
4813 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
4814
4815 if(pOemDataReqID)
4816 {
4817 *pOemDataReqID = lOemDataReqId;
4818 }
4819 else
4820 return eHAL_STATUS_FAILURE;
4821
4822 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
4823
4824 //release the lock for the sme object
4825 sme_ReleaseGlobalLock( &pMac->sme );
4826 }
4827 } while(0);
4828
4829 smsLog(pMac, LOGW, "exiting function %s\n", __FUNCTION__);
4830
4831 return(status);
4832}
4833
4834#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004835
4836/*--------------------------------------------------------------------------
4837
4838 \brief sme_OpenSession() - Open a session for scan/roam operation.
4839
4840 This is a synchronous API.
4841
4842
4843 \param hHal - The handle returned by macOpen.
4844 \param callback - A pointer to the function caller specifies for roam/connect status indication
4845 \param pContext - The context passed with callback
4846 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
4847 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
4848
4849 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
4850
4851 Other status means SME is failed to open the session.
4852 eHAL_STATUS_RESOURCES - no more session available.
4853 \sa
4854
4855 --------------------------------------------------------------------------*/
4856eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback, void *pContext,
4857 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId)
4858{
4859 eHalStatus status;
4860 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4861
4862 if( NULL == pbSessionId )
4863 {
4864 status = eHAL_STATUS_INVALID_PARAMETER;
4865 }
4866 else
4867 {
4868 status = sme_AcquireGlobalLock( &pMac->sme );
4869 if ( HAL_STATUS_SUCCESS( status ) )
4870 {
4871 status = csrRoamOpenSession( pMac, callback, pContext, pSelfMacAddr, pbSessionId );
4872
4873 sme_ReleaseGlobalLock( &pMac->sme );
4874 }
4875 }
4876
4877 return ( status );
4878}
4879
4880
4881/*--------------------------------------------------------------------------
4882
4883 \brief sme_CloseSession() - Open a session for scan/roam operation.
4884
4885 This is a synchronous API.
4886
4887
4888 \param hHal - The handle returned by macOpen.
4889
4890 \param sessionId - A previous opened session's ID.
4891
4892 \return eHAL_STATUS_SUCCESS - session is closed.
4893
4894 Other status means SME is failed to open the session.
4895 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
4896 \sa
4897
4898 --------------------------------------------------------------------------*/
4899eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
4900 csrRoamSessionCloseCallback callback, void *pContext)
4901{
4902 eHalStatus status;
4903 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4904
4905 status = sme_AcquireGlobalLock( &pMac->sme );
4906 if ( HAL_STATUS_SUCCESS( status ) )
4907 {
4908 status = csrRoamCloseSession( pMac, sessionId, FALSE,
4909 callback, pContext );
4910
4911 sme_ReleaseGlobalLock( &pMac->sme );
4912 }
4913
4914 return ( status );
4915}
4916
4917#ifdef WLAN_SOFTAP_FEATURE
4918/* ---------------------------------------------------------------------------
4919
4920 \fn sme_RoamUpdateAPWPSIE
4921
4922 \brief To update AP's WPS IE. This function should be called after SME AP session is created
4923 This is an asynchronous API.
4924
4925 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
4926
4927 \return eHalStatus – SUCCESS –
4928
4929 FAILURE or RESOURCES – The API finished and failed.
4930
4931 -------------------------------------------------------------------------------*/
4932eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
4933{
4934
4935 eHalStatus status = eHAL_STATUS_FAILURE;
4936 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4937
4938 status = sme_AcquireGlobalLock( &pMac->sme );
4939 if ( HAL_STATUS_SUCCESS( status ) )
4940 {
4941
4942 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
4943
4944 sme_ReleaseGlobalLock( &pMac->sme );
4945 }
4946
4947 return (status);
4948}
4949/* ---------------------------------------------------------------------------
4950
4951 \fn sme_RoamUpdateAPWPARSNIEs
4952
4953 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
4954 This is an asynchronous API.
4955
4956 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
4957
4958 \return eHalStatus – SUCCESS –
4959
4960 FAILURE or RESOURCES – The API finished and failed.
4961
4962 -------------------------------------------------------------------------------*/
4963eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
4964{
4965
4966 eHalStatus status = eHAL_STATUS_FAILURE;
4967 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4968
4969 status = sme_AcquireGlobalLock( &pMac->sme );
4970 if ( HAL_STATUS_SUCCESS( status ) )
4971 {
4972
4973 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
4974
4975 sme_ReleaseGlobalLock( &pMac->sme );
4976 }
4977
4978 return (status);
4979}
4980#endif
4981
4982
4983/*-------------------------------------------------------------------------------*
4984
4985 \fn sme_sendBTAmpEvent
4986
4987 \brief to receive the coex priorty request from BT-AMP PAL
4988 and send the BT_AMP link state to HAL
4989
4990 \param btAmpEvent - btAmpEvent
4991
4992 \return eHalStatus: SUCESS : BTAmp event successfully sent to HAL
4993
4994 FAILURE: API failed
4995
4996-------------------------------------------------------------------------------*/
4997
4998eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
4999{
5000 vos_msg_t msg;
5001 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
5002 eHalStatus status = eHAL_STATUS_FAILURE;
5003
5004 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tpSmeBtAmpEvent));
5005 if (NULL == ptrSmeBtAmpEvent)
5006 {
5007 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
5008 "Not able to allocate memory for BTAmp event", __FUNCTION__);
5009 return status;
5010 }
5011
5012 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
5013 msg.type = WDA_SIGNAL_BTAMP_EVENT;
5014 msg.reserved = 0;
5015 msg.bodyptr = ptrSmeBtAmpEvent;
5016
5017 //status = halFW_SendBTAmpEventMesg(pMac, event);
5018
5019 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5020 {
5021 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
5022 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __FUNCTION__);
5023 vos_mem_free(ptrSmeBtAmpEvent);
5024 return status;
5025 }
5026
5027 return eHAL_STATUS_SUCCESS;
5028
5029}
5030
5031/* ---------------------------------------------------------------------------
5032 \fn sme_SetHostOffload
5033 \brief API to set the host offload feature.
5034 \param hHal - The handle returned by macOpen.
5035 \param pRequest - Pointer to the offload request.
5036 \return eHalStatus
5037 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005038eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
5039 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005040{
5041 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07005042 eHalStatus status = eHAL_STATUS_FAILURE;
5043 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5044
5045 if(pSession == NULL )
5046 {
5047 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
5048 "Unable to find the csrSession", __FUNCTION__);
5049 return status;
5050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005051
5052 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5053 {
5054#ifdef WLAN_NS_OFFLOAD
5055 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
5056 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005057 status = pmcSetNSOffload( hHal, pRequest ,pSession->connectedProfile.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 }
5059 else
5060#endif //WLAN_NS_OFFLOAD
5061 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005062 status = pmcSetHostOffload (hHal, pRequest, pSession->connectedProfile.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07005063 }
5064 sme_ReleaseGlobalLock( &pMac->sme );
5065 }
5066
5067 return (status);
5068}
5069
5070#ifdef WLAN_FEATURE_GTK_OFFLOAD
5071/* ---------------------------------------------------------------------------
5072 \fn sme_SetGTKOffload
5073 \brief API to set GTK offload information.
5074 \param hHal - The handle returned by macOpen.
5075 \param pRequest - Pointer to the GTK offload request.
5076 \return eHalStatus
5077 ---------------------------------------------------------------------------*/
5078eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest)
5079{
5080 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5081 eHalStatus status;
5082
5083 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5084 {
5085 status = pmcSetGTKOffload( hHal, pRequest );
5086 sme_ReleaseGlobalLock( &pMac->sme );
5087 }
5088
5089 return (status);
5090}
5091
5092/* ---------------------------------------------------------------------------
5093 \fn sme_GetGTKOffload
5094 \brief API to get GTK offload information.
5095 \param hHal - The handle returned by macOpen.
5096 \param pRequest - Pointer to the GTK offload response.
5097 \return eHalStatus
5098 ---------------------------------------------------------------------------*/
5099eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine, void *callbackContext )
5100{
5101 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5102 eHalStatus status;
5103
5104 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5105 {
5106 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext);
5107 sme_ReleaseGlobalLock( &pMac->sme );
5108 }
5109
5110 return (status);
5111}
5112#endif // WLAN_FEATURE_GTK_OFFLOAD
5113
5114/* ---------------------------------------------------------------------------
5115 \fn sme_SetKeepAlive
5116 \brief API to set the Keep Alive feature.
5117 \param hHal - The handle returned by macOpen.
5118 \param pRequest - Pointer to the Keep Alive request.
5119 \return eHalStatus
5120 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005121eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
5122 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005123{
5124 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5125 eHalStatus status;
Jeff Johnsone7245742012-09-05 17:12:55 -07005126 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005127
5128 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
5129 "setting Keep alive in SME TP %d", __FUNCTION__,pRequest->timePeriod);
5130
Jeff Johnsone7245742012-09-05 17:12:55 -07005131 if(pSession == NULL )
5132 {
5133 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
5134 " Session not Found", __FUNCTION__);
5135 return eHAL_STATUS_FAILURE;
5136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005137
5138 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5139 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005140 status = pmcSetKeepAlive (hHal, pRequest, pSession->connectedProfile.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07005141 sme_ReleaseGlobalLock( &pMac->sme );
5142 }
5143
5144 return (status);
5145}
5146
5147#ifdef FEATURE_WLAN_SCAN_PNO
5148/* ---------------------------------------------------------------------------
5149 \fn sme_SetPreferredNetworkList
5150 \brief API to set the Preferred Network List Offload feature.
5151 \param hHal - The handle returned by macOpen.
5152 \param pRequest - Pointer to the offload request.
5153 \return eHalStatus
5154 ---------------------------------------------------------------------------*/
5155eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
5156{
5157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5158 eHalStatus status;
5159
5160 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5161 {
5162 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
5163 sme_ReleaseGlobalLock( &pMac->sme );
5164 }
5165
5166 return (status);
5167}
5168
5169eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
5170{
5171 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5172 eHalStatus status;
5173
5174 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5175 {
5176 pmcSetRssiFilter(hHal, rssiThreshold);
5177 sme_ReleaseGlobalLock( &pMac->sme );
5178 }
5179
5180 return (status);
5181}
5182
5183#endif // FEATURE_WLAN_SCAN_PNO
5184
5185eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams)
5186{
5187 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5188 eHalStatus status;
5189
5190 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5191 {
5192 pmcSetPowerParams(hHal, pwParams);
5193 sme_ReleaseGlobalLock( &pMac->sme );
5194 }
5195
5196 return (status);
5197}
5198
5199/* ---------------------------------------------------------------------------
5200 \fn sme_AbortMacScan
5201 \brief API to cancel MAC scan.
5202 \param hHal - The handle returned by macOpen.
5203 \return VOS_STATUS
5204 VOS_STATUS_E_FAILURE - failure
5205 VOS_STATUS_SUCCESS success
5206 ---------------------------------------------------------------------------*/
5207eHalStatus sme_AbortMacScan(tHalHandle hHal)
5208{
5209 eHalStatus status;
5210 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5211
5212 status = sme_AcquireGlobalLock( &pMac->sme );
5213 if ( HAL_STATUS_SUCCESS( status ) )
5214 {
5215 status = csrScanAbortMacScan(pMac);
5216
5217 sme_ReleaseGlobalLock( &pMac->sme );
5218 }
5219
5220 return ( status );
5221}
5222
5223/* ----------------------------------------------------------------------------
5224 \fn sme_GetOperationChannel
5225 \brief API to get current channel on which STA is parked
5226 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005227 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 \returns eHAL_STATUS_SUCCESS
5229 eHAL_STATUS_FAILURE
5230-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005231eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005232{
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5234 tCsrRoamSession *pSession;
5235
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005236 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005238 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005239
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005240 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
5241 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
5242#ifdef WLAN_SOFTAP_FEATURE
5243 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
5244#endif
5245 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
5246 {
5247 *pChannel =pSession->connectedProfile.operationChannel;
5248 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 }
5250 }
5251 return eHAL_STATUS_FAILURE;
5252}// sme_GetOperationChannel ends here
5253
5254#ifdef WLAN_FEATURE_P2P
5255/* ---------------------------------------------------------------------------
5256
5257 \fn sme_RegisterMgtFrame
5258
5259 \brief To register managment frame of specified type and subtype.
5260 \param frameType - type of the frame that needs to be passed to HDD.
5261 \param matchData - data which needs to be matched before passing frame
5262 to HDD.
5263 \param matchDataLen - Length of matched data.
5264 \return eHalStatus
5265 -------------------------------------------------------------------------------*/
5266eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5267 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5268{
5269 eHalStatus status = eHAL_STATUS_SUCCESS;
5270 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5271
5272 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5273 {
5274 tSirRegisterMgmtFrame *pMsg;
5275 tANI_U16 len;
5276 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5277
5278 if( !pSession->sessionActive )
5279 {
5280 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
5281 "%s Invalid Sessionid", __FUNCTION__);
5282 sme_ReleaseGlobalLock( &pMac->sme );
5283 return eHAL_STATUS_FAILURE;
5284 }
5285
5286 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5287
5288 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5289 if(HAL_STATUS_SUCCESS(status))
5290 {
5291 palZeroMemory(pMac->hHdd, pMsg, len);
5292 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5293 pMsg->length = len;
5294 pMsg->sessionId = sessionId;
5295 pMsg->registerFrame = VOS_TRUE;
5296 pMsg->frameType = frameType;
5297 pMsg->matchLen = matchLen;
5298 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5299 status = palSendMBMessage(pMac->hHdd, pMsg);
5300 }
5301 sme_ReleaseGlobalLock( &pMac->sme );
5302 }
5303 return status;
5304}
5305
5306/* ---------------------------------------------------------------------------
5307
5308 \fn sme_DeregisterMgtFrame
5309
5310 \brief To De-register managment frame of specified type and subtype.
5311 \param frameType - type of the frame that needs to be passed to HDD.
5312 \param matchData - data which needs to be matched before passing frame
5313 to HDD.
5314 \param matchDataLen - Length of matched data.
5315 \return eHalStatus
5316 -------------------------------------------------------------------------------*/
5317eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5318 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5319{
5320 eHalStatus status = eHAL_STATUS_SUCCESS;
5321 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5322
5323 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5324 {
5325 tSirRegisterMgmtFrame *pMsg;
5326 tANI_U16 len;
5327 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5328
5329 if( !pSession->sessionActive )
5330 {
5331 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
5332 "%s Invalid Sessionid", __FUNCTION__);
5333 sme_ReleaseGlobalLock( &pMac->sme );
5334 return eHAL_STATUS_FAILURE;
5335 }
5336
5337 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5338
5339 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5340 if(HAL_STATUS_SUCCESS(status))
5341 {
5342 palZeroMemory(pMac->hHdd, pMsg, len);
5343 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5344 pMsg->length = len;
5345 pMsg->registerFrame = VOS_FALSE;
5346 pMsg->frameType = frameType;
5347 pMsg->matchLen = matchLen;
5348 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5349 status = palSendMBMessage(pMac->hHdd, pMsg);
5350 }
5351 sme_ReleaseGlobalLock( &pMac->sme );
5352 }
5353 return status;
5354}
5355
5356/* ---------------------------------------------------------------------------
5357 \fn sme_RemainOnChannel
5358 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
5359 \param hHal - The handle returned by macOpen.
5360 \param pRequest - channel
5361 \param duration - duration in ms
5362 \param callback - HDD registered callback to process reaminOnChannelRsp
5363 \param context - HDD Callback param
5364 \return eHalStatus
5365 ---------------------------------------------------------------------------*/
5366
5367eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
5368 tANI_U8 channel, tANI_U32 duration,
5369 remainOnChanCallback callback,
5370 void *pContext)
5371{
5372 eHalStatus status = eHAL_STATUS_SUCCESS;
5373 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5374
5375 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5376 {
5377 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext
5378#ifdef WLAN_FEATURE_P2P_INTERNAL
5379 , eP2PRemainOnChnReasonUnknown
5380#endif
5381 );
5382 sme_ReleaseGlobalLock( &pMac->sme );
5383 }
5384 return(status);
5385}
5386
5387/* ---------------------------------------------------------------------------
5388 \fn sme_ReportProbeReq
5389 \brief API to enable/disable forwarding of probeReq to apps in p2p.
5390 \param hHal - The handle returned by macOpen.
5391 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
5392 \return eHalStatus
5393 ---------------------------------------------------------------------------*/
5394
5395#ifndef WLAN_FEATURE_CONCURRENT_P2P
5396eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
5397{
5398 eHalStatus status = eHAL_STATUS_SUCCESS;
5399 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5400
5401 do
5402 {
5403 //acquire the lock for the sme object
5404 status = sme_AcquireGlobalLock(&pMac->sme);
5405 if(HAL_STATUS_SUCCESS(status))
5406 {
5407 /* call set in context */
5408 pMac->p2pContext.probeReqForwarding = flag;
5409 //release the lock for the sme object
5410 sme_ReleaseGlobalLock( &pMac->sme );
5411 }
5412 } while(0);
5413
5414 smsLog(pMac, LOGW, "exiting function %s\n", __FUNCTION__);
5415
5416 return(status);
5417}
5418
5419/* ---------------------------------------------------------------------------
5420 \fn sme_updateP2pIe
5421 \brief API to set the P2p Ie in p2p context
5422 \param hHal - The handle returned by macOpen.
5423 \param p2pIe - Ptr to p2pIe from HDD.
5424 \param p2pIeLength: length of p2pIe
5425 \return eHalStatus
5426 ---------------------------------------------------------------------------*/
5427
5428eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
5429{
5430 eHalStatus status = eHAL_STATUS_SUCCESS;
5431 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5432
5433 //acquire the lock for the sme object
5434 status = sme_AcquireGlobalLock(&pMac->sme);
5435 if(HAL_STATUS_SUCCESS(status))
5436 {
5437 if(NULL != pMac->p2pContext.probeRspIe){
5438 vos_mem_free(pMac->p2pContext.probeRspIe);
5439 pMac->p2pContext.probeRspIeLength = 0;
5440 }
5441
5442 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
5443 if (NULL == pMac->p2pContext.probeRspIe)
5444 {
5445 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __FUNCTION__);
5446 pMac->p2pContext.probeRspIeLength = 0;
5447 status = eHAL_STATUS_FAILURE;
5448 }
5449 else
5450 {
5451 pMac->p2pContext.probeRspIeLength = p2pIeLength;
5452
5453 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
5454 pMac->p2pContext.probeRspIe,
5455 pMac->p2pContext.probeRspIeLength );
5456 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
5457 p2pIeLength);
5458 }
5459
5460 //release the lock for the sme object
5461 sme_ReleaseGlobalLock( &pMac->sme );
5462 }
5463
5464 smsLog(pMac, LOG2, "exiting function %s\n", __FUNCTION__);
5465
5466 return(status);
5467}
5468#endif
5469
5470/* ---------------------------------------------------------------------------
5471 \fn sme_sendAction
5472 \brief API to send action frame from supplicant.
5473 \param hHal - The handle returned by macOpen.
5474 \return eHalStatus
5475 ---------------------------------------------------------------------------*/
5476
5477eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07005478 const tANI_U8 *pBuf, tANI_U32 len,
5479 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07005480{
5481 eHalStatus status = eHAL_STATUS_SUCCESS;
5482 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5483
5484 //acquire the lock for the sme object
5485 status = sme_AcquireGlobalLock(&pMac->sme);
5486 if(HAL_STATUS_SUCCESS(status))
5487 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005488 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 //release the lock for the sme object
5490 sme_ReleaseGlobalLock( &pMac->sme );
5491 }
5492
5493 smsLog(pMac, LOGW, "exiting function %s\n", __FUNCTION__);
5494
5495 return(status);
5496}
5497
5498eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
5499{
5500 eHalStatus status = eHAL_STATUS_SUCCESS;
5501 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5502
5503 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5504 {
5505 status = p2pCancelRemainOnChannel (hHal, sessionId);
5506 sme_ReleaseGlobalLock( &pMac->sme );
5507 }
5508 return(status);
5509}
5510
5511//Power Save Related
5512eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
5513{
5514 eHalStatus status = eHAL_STATUS_SUCCESS;
5515 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5516
5517 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5518 {
5519 status = p2pSetPs (hHal, data);
5520 sme_ReleaseGlobalLock( &pMac->sme );
5521 }
5522 return(status);
5523}
5524
5525#endif
5526
5527/* ---------------------------------------------------------------------------
5528
5529 \fn sme_ConfigureRxpFilter
5530
5531 \brief
5532 SME will pass this request to lower mac to set/reset the filter on RXP for
5533 multicast & broadcast traffic.
5534
5535 \param
5536
5537 hHal - The handle returned by macOpen.
5538
5539 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
5540 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
5541 on this param. In future we can use this as a mask to set various types of
5542 filters as suggested below:
5543 FILTER_ALL_MULTICAST:
5544 FILTER_ALL_BROADCAST:
5545 FILTER_ALL_MULTICAST_BROADCAST:
5546
5547
5548 \return eHalStatus
5549
5550
5551--------------------------------------------------------------------------- */
5552eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
5553 tpSirWlanSetRxpFilters wlanRxpFilterParam)
5554{
5555 eHalStatus status = eHAL_STATUS_SUCCESS;
5556 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5557 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5558 vos_msg_t vosMessage;
5559
5560 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5561 {
5562 /* serialize the req through MC thread */
5563 vosMessage.bodyptr = wlanRxpFilterParam;
5564 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
5565 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5566 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5567 {
5568 status = eHAL_STATUS_FAILURE;
5569 }
5570 sme_ReleaseGlobalLock( &pMac->sme );
5571 }
5572 return(status);
5573}
5574
5575#ifdef FEATURE_WLAN_INTEGRATED_SOC
5576/* ---------------------------------------------------------------------------
5577
5578 \fn sme_ConfigureSuspendInd
5579
5580 \brief
5581 SME will pass this request to lower mac to Indicate that the wlan needs to
5582 be suspended
5583
5584 \param
5585
5586 hHal - The handle returned by macOpen.
5587
5588 wlanSuspendParam- Depicts the wlan suspend params
5589
5590
5591 \return eHalStatus
5592
5593
5594--------------------------------------------------------------------------- */
5595eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
5596 tpSirWlanSuspendParam wlanSuspendParam)
5597{
5598 eHalStatus status = eHAL_STATUS_SUCCESS;
5599 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5600 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5601 vos_msg_t vosMessage;
5602
5603 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5604 {
5605 /* serialize the req through MC thread */
5606 vosMessage.bodyptr = wlanSuspendParam;
5607 vosMessage.type = WDA_WLAN_SUSPEND_IND;
5608 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5609 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5610 {
5611 status = eHAL_STATUS_FAILURE;
5612 }
5613 sme_ReleaseGlobalLock( &pMac->sme );
5614 }
5615 return(status);
5616}
5617
5618/* ---------------------------------------------------------------------------
5619
5620 \fn sme_ConfigureResumeReq
5621
5622 \brief
5623 SME will pass this request to lower mac to Indicate that the wlan needs to
5624 be Resumed
5625
5626 \param
5627
5628 hHal - The handle returned by macOpen.
5629
5630 wlanResumeParam- Depicts the wlan resume params
5631
5632
5633 \return eHalStatus
5634
5635
5636--------------------------------------------------------------------------- */
5637eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
5638 tpSirWlanResumeParam wlanResumeParam)
5639{
5640 eHalStatus status = eHAL_STATUS_SUCCESS;
5641 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5642 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5643 vos_msg_t vosMessage;
5644
5645 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5646 {
5647 /* serialize the req through MC thread */
5648 vosMessage.bodyptr = wlanResumeParam;
5649 vosMessage.type = WDA_WLAN_RESUME_REQ;
5650 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5651 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5652 {
5653 status = eHAL_STATUS_FAILURE;
5654 }
5655 sme_ReleaseGlobalLock( &pMac->sme );
5656 }
5657 return(status);
5658}
5659
5660#endif
5661/* ---------------------------------------------------------------------------
5662
5663 \fn sme_GetInfraSessionId
5664
5665 \brief To get the session ID for infra session, if connected
5666 This is a synchronous API.
5667
5668 \param hHal - The handle returned by macOpen.
5669
5670 \return sessionid, -1 if infra session is not connected
5671
5672 -------------------------------------------------------------------------------*/
5673tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
5674{
5675 eHalStatus status = eHAL_STATUS_FAILURE;
5676 tANI_S8 sessionid = -1;
5677 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5678
5679 status = sme_AcquireGlobalLock( &pMac->sme );
5680 if ( HAL_STATUS_SUCCESS( status ) )
5681 {
5682
5683 sessionid = csrGetInfraSessionId( pMac);
5684
5685 sme_ReleaseGlobalLock( &pMac->sme );
5686 }
5687
5688 return (sessionid);
5689}
5690
5691/* ---------------------------------------------------------------------------
5692
5693 \fn sme_GetInfraOperationChannel
5694
5695 \brief To get the operating channel for infra session, if connected
5696 This is a synchronous API.
5697
5698 \param hHal - The handle returned by macOpen.
5699 \param sessionId - the sessionId returned by sme_OpenSession.
5700
5701 \return operating channel, 0 if infra session is not connected
5702
5703 -------------------------------------------------------------------------------*/
5704tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
5705{
5706 eHalStatus status = eHAL_STATUS_FAILURE;
5707 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5708 tANI_U8 channel = 0;
5709 status = sme_AcquireGlobalLock( &pMac->sme );
5710 if ( HAL_STATUS_SUCCESS( status ) )
5711 {
5712
5713 channel = csrGetInfraOperationChannel( pMac, sessionId);
5714
5715 sme_ReleaseGlobalLock( &pMac->sme );
5716 }
5717
5718 return (channel);
5719}
5720
5721//This routine will return poerating channel on which other BSS is operating to be used for concurrency mode.
5722//If other BSS is not up or not connected it will return 0
5723tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
5724{
5725 eHalStatus status = eHAL_STATUS_FAILURE;
5726 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5727 tANI_U8 channel = 0;
5728 status = sme_AcquireGlobalLock( &pMac->sme );
5729 if ( HAL_STATUS_SUCCESS( status ) )
5730 {
5731
5732 channel = csrGetConcurrentOperationChannel( pMac );
5733 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
5734 " Other Concurrent Channel = %d", __FUNCTION__,channel);
5735 sme_ReleaseGlobalLock( &pMac->sme );
5736 }
5737
5738 return (channel);
5739}
5740
5741#ifdef FEATURE_WLAN_SCAN_PNO
5742/******************************************************************************
5743*
5744* Name: sme_PreferredNetworkFoundInd
5745*
5746* Description:
5747* Invoke Preferred Network Found Indication
5748*
5749* Parameters:
5750* hHal - HAL handle for device
5751* pMsg - found network description
5752*
5753* Returns: eHalStatus
5754*
5755******************************************************************************/
5756eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
5757{
5758 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5759 eHalStatus status = eHAL_STATUS_SUCCESS;
5760 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
5761
5762 if (NULL == pMsg)
5763 {
5764 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __FUNCTION__);
5765 status = eHAL_STATUS_FAILURE;
5766 }
5767 else
5768 {
5769 if (pPrefNetworkFoundInd->ssId.length > 0)
5770 {
5771 smsLog(pMac, LOG1, "Preferred Network Found Indication in %s(), SSID=%s",
5772 __FUNCTION__, pPrefNetworkFoundInd->ssId.ssId);
5773
5774
5775 /* Call Preferred Netowrk Found Indication callback routine. */
5776 if (pMac->pmc.prefNetwFoundCB != NULL)
5777 {
5778 pMac->pmc.prefNetwFoundCB(pMac->pmc.preferredNetworkFoundIndCallbackContext, pPrefNetworkFoundInd);
5779 }
5780
5781 }
5782 else
5783 {
5784 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL\n", __FUNCTION__);
5785 status = eHAL_STATUS_FAILURE;
5786 }
5787 }
5788
5789
5790 return(status);
5791}
5792
5793#endif // FEATURE_WLAN_SCAN_PNO
5794
5795
5796eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
5797{
5798 eHalStatus status = eHAL_STATUS_FAILURE;
5799 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5800
5801 status = sme_AcquireGlobalLock( &pMac->sme );
5802 if ( HAL_STATUS_SUCCESS( status ) )
5803 {
5804 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
5805 sme_ReleaseGlobalLock( &pMac->sme );
5806 }
5807
5808 return (status);
5809}
5810
5811
5812/* ---------------------------------------------------------------------------
5813
5814 \fn sme_SetTxPerTracking
5815
5816 \brief Set Tx PER tracking configuration parameters
5817
5818 \param hHal - The handle returned by macOpen.
5819 \param pTxPerTrackingConf - Tx PER configuration parameters
5820
5821 \return eHalStatus
5822
5823 -------------------------------------------------------------------------------*/
5824eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
5825 void (*pCallbackfn) (void *pCallbackContext),
5826 void *pCallbackContext,
5827 tpSirTxPerTrackingParam pTxPerTrackingParam)
5828{
5829 vos_msg_t msg;
5830 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
5831 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5832
5833 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5834 {
5835 pMac->sme.pTxPerHitCallback = pCallbackfn;
5836 pMac->sme.pTxPerHitCbContext = pCallbackContext;
5837 sme_ReleaseGlobalLock( &pMac->sme );
5838 }
5839
5840 // free this memory in failure case or WDA request callback function
5841 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
5842 if (NULL == pTxPerTrackingParamReq)
5843 {
5844 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for tSirTxPerTrackingParam", __FUNCTION__);
5845 return eHAL_STATUS_FAILURE;
5846 }
5847
5848 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam, sizeof(tSirTxPerTrackingParam));
5849 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
5850 msg.reserved = 0;
5851 msg.bodyptr = pTxPerTrackingParamReq;
5852
5853 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5854 {
5855 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__);
5856 vos_mem_free(pTxPerTrackingParamReq);
5857 return eHAL_STATUS_FAILURE;
5858 }
5859
5860 return eHAL_STATUS_SUCCESS;
5861}
5862
5863/* ---------------------------------------------------------------------------
5864
5865 \fn sme_HandleChangeCountryCode
5866
5867 \brief Change Country code, Reg Domain and channel list
5868
5869 \details Country Code Priority
5870 0 = 11D > Configured Country > NV
5871 1 = Configured Country > 11D > NV
5872 If Supplicant country code is priority than 11d is disabled.
5873 If 11D is enabled, we update the country code after every scan.
5874 Hence when Supplicant country code is priority, we don't need 11D info.
5875 Country code from Supplicant is set as current courtry code.
5876 User can send reset command XX (instead of country code) to reset the
5877 country code to default values which is read from NV.
5878 In case of reset, 11D is enabled and default NV code is Set as current country code
5879 If 11D is priority,
5880 Than Supplicant country code code is set to default code. But 11D code is set as current country code
5881
5882 \param pMac - The handle returned by macOpen.
5883 \param pMsgBuf - MSG Buffer
5884
5885 \return eHalStatus
5886
5887 -------------------------------------------------------------------------------*/
5888eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
5889{
5890 eHalStatus status = eHAL_STATUS_SUCCESS;
5891 tAniChangeCountryCodeReq *pMsg;
5892 v_REGDOMAIN_t domainIdIoctl;
5893 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5894 static uNvTables nvTables;
5895 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
5896
5897
5898 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
5899 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
5900 {
5901 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
5902
5903 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
5904
5905 /* read the country code from NV and use it */
5906 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
5907 {
5908 palCopyMemory( pMac->hHdd, pMsg->countryCode , nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
5909 }
5910 else
5911 {
5912 status = eHAL_STATUS_FAILURE;
5913 return status;
5914 }
5915 }
5916 else
5917 {
5918 /* if Supplicant country code has priority, disable 11d */
5919 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority)
5920 {
5921 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
5922 }
5923 }
5924
5925 /* WEXT set country code means
5926 * 11D should be supported?
5927 * 11D Channel should be enforced?
5928 * 11D Country code should be matched?
5929 * 11D Reg Domian should be matched?
5930 * Country string changed */
5931 if(pMac->roam.configParam.Is11dSupportEnabled &&
5932 pMac->roam.configParam.fEnforce11dChannels &&
5933 pMac->roam.configParam.fEnforceCountryCodeMatch &&
5934 pMac->roam.configParam.fEnforceDefaultDomain &&
5935 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
5936 {
5937 /* All 11D related options are already enabled
5938 * Country string is not changed
5939 * Do not need do anything for country code change request */
5940 return eHAL_STATUS_SUCCESS;
5941 }
5942
5943 /* Set Current Country code and Current Regulatory domain */
5944 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
5945 if(eHAL_STATUS_SUCCESS != status)
5946 {
5947 /* Supplicant country code failed. So give 11D priority */
5948 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
5949 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
5950 return status;
5951 }
5952
5953 /* purge current scan results
5954 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).
5955 Looks like a bug in current scan sequence.
5956 */
5957 csrScanFlushResult(pMac);
5958
5959 /* overwrite the defualt country code */
5960 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault, pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
5961
5962 /* Get Domain ID from country code */
5963 status = csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent,(v_REGDOMAIN_t *) &domainIdIoctl );
5964 if ( status != eHAL_STATUS_SUCCESS )
5965 {
5966 smsLog( pMac, LOGE, FL(" fail to get regId %d\n"), domainIdIoctl );
5967 return status;
5968 }
5969
5970 status = WDA_SetRegDomain(pMac, domainIdIoctl);
5971
5972 if ( status != eHAL_STATUS_SUCCESS )
5973 {
5974 smsLog( pMac, LOGE, FL(" fail to set regId %d\n"), domainIdIoctl );
5975 return status;
5976 }
5977
5978 /* set to default domain ID */
5979 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
5980
5981 /* get the channels based on new cc */
5982 status = csrInitGetChannels( pMac );
5983
5984 if ( status != eHAL_STATUS_SUCCESS )
5985 {
5986 smsLog( pMac, LOGE, FL(" fail to get Channels \n"));
5987 return status;
5988 }
5989
5990 /* reset info based on new cc, and we are done */
5991 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE);
5992 if( pMsg->changeCCCallback )
5993 {
5994 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
5995 }
5996
5997 return eHAL_STATUS_SUCCESS;
5998}
5999
6000#ifdef WLAN_FEATURE_PACKET_FILTERING
6001eHalStatus sme_8023MulticastList (tHalHandle hHal, tpSirRcvFltMcAddrList pMulticastAddrs)
6002{
6003 tpSirRcvFltMcAddrList pRequestBuf;
6004 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006005 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6006 tANI_U8 sessionId = 0;
6007 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006008
6009 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
6010 "ulMulticastAddrCnt=%d, multicastAddr[0]=%d", __FUNCTION__,
6011 pMulticastAddrs->ulMulticastAddrCnt,
6012 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07006013
6014 /*
6015 *Find the connected Infra / P2P_client connected session
6016 */
6017 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
6018 {
6019 if( CSR_IS_SESSION_VALID( pMac, sessionId ) &&
6020 ( csrIsConnStateInfra( pMac, sessionId )) )
6021 {
6022 pSession = CSR_GET_SESSION( pMac, sessionId );
6023 }
6024 }
6025
6026 if(pSession == NULL )
6027 {
6028 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Unable to find "
6029 "the right session", __FUNCTION__);
6030 return eHAL_STATUS_FAILURE;
6031 }
6032
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6034 if (NULL == pRequestBuf)
6035 {
6036 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
6037 "allocate memory for 8023 Multicast List request", __FUNCTION__);
6038 return eHAL_STATUS_FAILED_ALLOC;
6039 }
6040 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
6041
Jeff Johnsone7245742012-09-05 17:12:55 -07006042 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6043 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
6044 sizeof(tSirMacAddr));
6045
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 msg.type = WDA_8023_MULTICAST_LIST_REQ;
6047 msg.reserved = 0;
6048 msg.bodyptr = pRequestBuf;
6049 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6050 {
6051 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
6052 "post WDA_8023_MULTICAST_LIST message to WDA", __FUNCTION__);
6053 vos_mem_free(pRequestBuf);
6054 return eHAL_STATUS_FAILURE;
6055 }
6056
6057 return eHAL_STATUS_SUCCESS;
6058}
6059
Jeff Johnsone7245742012-09-05 17:12:55 -07006060eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
6061 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006062{
6063 tpSirRcvPktFilterCfgType pRequestBuf;
6064 v_SINT_t allocSize;
6065 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006066 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6067 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 v_U8_t idx=0;
6069
6070 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
6071 "filterId = %d", __FUNCTION__,
6072 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
6073
6074 allocSize = sizeof(tSirRcvPktFilterCfgType) +
6075 ((pRcvPktFilterCfg->numFieldParams - 1) *
6076 sizeof(tSirRcvPktFilterFieldParams));
6077 pRequestBuf = vos_mem_malloc(allocSize);
Jeff Johnsone7245742012-09-05 17:12:55 -07006078 if ((NULL == pRequestBuf) || (NULL == pSession))
Jeff Johnson295189b2012-06-20 16:38:30 -07006079 {
6080 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
6081 "allocate memory for Receive Filter Set Filter request", __FUNCTION__);
6082 return eHAL_STATUS_FAILED_ALLOC;
6083 }
6084 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
6085
Jeff Johnsone7245742012-09-05 17:12:55 -07006086 vos_mem_copy( pRequestBuf->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6087 vos_mem_copy( pRequestBuf->bssId, pSession->connectedProfile.bssid,
6088 sizeof(tSirMacAddr));
6089
Jeff Johnson295189b2012-06-20 16:38:30 -07006090 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
6091 msg.reserved = 0;
6092 msg.bodyptr = pRequestBuf;
6093
6094 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6095 "FT %d FID %d ",
6096 pRequestBuf->filterType, pRequestBuf->filterId);
6097
6098 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6099 "params %d CT %d",
6100 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
6101
6102 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
6103 {
6104
6105 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6106 "Proto %d Comp Flag %d \n",
6107 pRequestBuf->paramsData[idx].protocolLayer,
6108 pRequestBuf->paramsData[idx].cmpFlag);
6109
6110 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6111 "Data Offset %d Data Len %d\n",
6112 pRequestBuf->paramsData[idx].dataOffset,
6113 pRequestBuf->paramsData[idx].dataLength);
6114
6115 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6116 "CData: %d:%d:%d:%d:%d:%d\n",
6117 pRequestBuf->paramsData[idx].compareData[0],
6118 pRequestBuf->paramsData[idx].compareData[1],
6119 pRequestBuf->paramsData[idx].compareData[2],
6120 pRequestBuf->paramsData[idx].compareData[3],
6121 pRequestBuf->paramsData[idx].compareData[4],
6122 pRequestBuf->paramsData[idx].compareData[5]);
6123
6124 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6125 "MData: %d:%d:%d:%d:%d:%d\n",
6126 pRequestBuf->paramsData[idx].dataMask[0],
6127 pRequestBuf->paramsData[idx].dataMask[1],
6128 pRequestBuf->paramsData[idx].dataMask[2],
6129 pRequestBuf->paramsData[idx].dataMask[3],
6130 pRequestBuf->paramsData[idx].dataMask[4],
6131 pRequestBuf->paramsData[idx].dataMask[5]);
6132
6133 }
6134
6135 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6136 {
6137 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
6138 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __FUNCTION__);
6139 vos_mem_free(pRequestBuf);
6140 return eHAL_STATUS_FAILURE;
6141 }
6142
6143 return eHAL_STATUS_SUCCESS;
6144}
6145
6146eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
6147 FilterMatchCountCallback callbackRoutine,
6148 void *callbackContext )
6149{
6150 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6151 eHalStatus status;
6152
6153 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __FUNCTION__);
6154
6155 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
6156 {
6157 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext);
6158 sme_ReleaseGlobalLock( &pMac->sme );
6159 }
6160
6161 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __FUNCTION__);
6162
6163 return (status);
6164}
6165
Jeff Johnsone7245742012-09-05 17:12:55 -07006166eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
6167 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006168{
6169 tpSirRcvFltPktClearParam pRequestBuf;
6170 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006171 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6172 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006173
6174 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __FUNCTION__,
6175 pRcvFltPktClearParam->filterId);
6176
6177 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Jeff Johnsone7245742012-09-05 17:12:55 -07006178 if ((NULL == pRequestBuf) || (NULL == pSession))
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 {
6180 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6181 "%s: Not able to allocate memory for Receive Filter "
6182 "Clear Filter request", __FUNCTION__);
6183 return eHAL_STATUS_FAILED_ALLOC;
6184 }
6185 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
6186
Jeff Johnsone7245742012-09-05 17:12:55 -07006187 vos_mem_copy( pRequestBuf->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6188 vos_mem_copy( pRequestBuf->bssId, pSession->connectedProfile.bssid,
6189 sizeof(tSirMacAddr));
6190
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
6192 msg.reserved = 0;
6193 msg.bodyptr = pRequestBuf;
6194 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6195 {
6196 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
6197 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __FUNCTION__);
6198 vos_mem_free(pRequestBuf);
6199 return eHAL_STATUS_FAILURE;
6200 }
6201
6202 return eHAL_STATUS_SUCCESS;
6203}
6204#endif // WLAN_FEATURE_PACKET_FILTERING
6205
6206/* ---------------------------------------------------------------------------
6207 \fn sme_PreChannelSwitchIndFullPowerCB
6208 \brief call back function for the PMC full power request because of pre
6209 channel switch.
6210 \param callbackContext
6211 \param status
6212 ---------------------------------------------------------------------------*/
6213void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
6214 eHalStatus status)
6215{
6216 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
6217 tSirMbMsg *pMsg;
6218 tANI_U16 msgLen;
6219
6220 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
6221 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
6222 if(HAL_STATUS_SUCCESS(status))
6223 {
6224 palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen);
6225 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
6226 pMsg->msgLen = pal_cpu_to_be16(msgLen);
6227 status = palSendMBMessage(pMac->hHdd, pMsg);
6228 }
6229
6230 return;
6231}
6232
6233/* ---------------------------------------------------------------------------
6234 \fn sme_HandlePreChannelSwitchInd
6235 \brief Processes the indcation from PE for pre-channel switch.
6236 \param hHal
6237 \- The handle returned by macOpen. return eHalStatus
6238 ---------------------------------------------------------------------------*/
6239eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
6240{
6241 eHalStatus status = eHAL_STATUS_FAILURE;
6242 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6243 status = sme_AcquireGlobalLock( &pMac->sme );
6244 if ( HAL_STATUS_SUCCESS( status ) )
6245 {
6246 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
6247 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
6248 sme_ReleaseGlobalLock( &pMac->sme );
6249 }
6250
6251 return (status);
6252}
6253
6254/* ---------------------------------------------------------------------------
6255 \fn sme_HandlePostChannelSwitchInd
6256 \brief Processes the indcation from PE for post-channel switch.
6257 \param hHal
6258 \- The handle returned by macOpen. return eHalStatus
6259 ---------------------------------------------------------------------------*/
6260eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
6261{
6262 eHalStatus status = eHAL_STATUS_FAILURE;
6263 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6264
6265 status = sme_AcquireGlobalLock( &pMac->sme );
6266 if ( HAL_STATUS_SUCCESS( status ) )
6267 {
6268 status = pmcRequestBmps(hHal, NULL, NULL);
6269 sme_ReleaseGlobalLock( &pMac->sme );
6270 }
6271
6272 return (status);
6273}
6274
6275/* ---------------------------------------------------------------------------
6276
6277 \fn sme_IsChannelValid
6278
6279 \brief To check if the channel is valid for currently established domain
6280 This is a synchronous API.
6281
6282 \param hHal - The handle returned by macOpen.
6283 \param channel - channel to verify
6284
6285 \return TRUE/FALSE, TRUE if channel is valid
6286
6287 -------------------------------------------------------------------------------*/
6288tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
6289{
6290 eHalStatus status = eHAL_STATUS_FAILURE;
6291 tANI_BOOLEAN valid = FALSE;
6292 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6293
6294 status = sme_AcquireGlobalLock( &pMac->sme );
6295 if ( HAL_STATUS_SUCCESS( status ) )
6296 {
6297
6298 valid = csrRoamIsChannelValid( pMac, channel);
6299
6300 sme_ReleaseGlobalLock( &pMac->sme );
6301 }
6302
6303 return (valid);
6304}
6305
6306/* ---------------------------------------------------------------------------
6307 \fn sme_SetFreqBand
6308 \brief Used to set frequency band.
6309 \param hHal
6310 \eBand band value to be configured
6311 \- return eHalStatus
6312 -------------------------------------------------------------------------*/
6313eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
6314{
6315 eHalStatus status = eHAL_STATUS_FAILURE;
6316 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6317
6318 status = sme_AcquireGlobalLock( &pMac->sme );
6319 if ( HAL_STATUS_SUCCESS( status ) )
6320 {
6321 status = csrSetBand(hHal, eBand);
6322 sme_ReleaseGlobalLock( &pMac->sme );
6323 }
6324 return status;
6325}
6326
6327/* ---------------------------------------------------------------------------
6328 \fn sme_GetFreqBand
6329 \brief Used to get the current band settings.
6330 \param hHal
6331 \pBand pointer to hold band value
6332 \- return eHalStatus
6333 -------------------------------------------------------------------------*/
6334eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
6335{
6336 eHalStatus status = eHAL_STATUS_FAILURE;
6337 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6338
6339 status = sme_AcquireGlobalLock( &pMac->sme );
6340 if ( HAL_STATUS_SUCCESS( status ) )
6341 {
6342 *pBand = csrGetCurrentBand( hHal );
6343 sme_ReleaseGlobalLock( &pMac->sme );
6344 }
6345 return status;
6346}
6347
6348#ifdef WLAN_WAKEUP_EVENTS
6349/******************************************************************************
6350 \fn sme_WakeReasonIndCallback
6351
6352 \brief
6353 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
6354
6355 \param hHal - HAL handle for device
6356 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
6357
6358 \return eHalStatus
6359******************************************************************************/
6360eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
6361{
6362 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6363 eHalStatus status = eHAL_STATUS_SUCCESS;
6364 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
6365
6366 if (NULL == pMsg)
6367 {
6368 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __FUNCTION__);
6369 status = eHAL_STATUS_FAILURE;
6370 }
6371 else
6372 {
6373 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback\n");
6374
6375 /* Call Wake Reason Indication callback routine. */
6376 if (pMac->pmc.wakeReasonIndCB != NULL)
6377 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
6378
6379 pMac->pmc.wakeReasonIndCB = NULL;
6380 pMac->pmc.wakeReasonIndCBContext = NULL;
6381
6382 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __FUNCTION__, pWakeReasonInd->ulReason);
6383 }
6384
6385 return(status);
6386}
6387#endif // WLAN_WAKEUP_EVENTS
6388
6389
6390/* ---------------------------------------------------------------------------
6391
6392 \fn sme_SetMaxTxPower
6393
6394 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
6395 not persist over reboots.
6396
6397 \param hHal
6398 \param pBssid BSSID to set the power cap for
6399 \param pBssid pSelfMacAddress self MAC Address
6400 \param pBssid power to set in dB
6401 \- return eHalStatus
6402
6403 -------------------------------------------------------------------------------*/
6404eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr pBssid,
6405 tSirMacAddr pSelfMacAddress, v_S7_t dB)
6406{
6407 vos_msg_t msg;
6408 tpMaxTxPowerParams pMaxTxParams = NULL;
6409
6410 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
6411 if (NULL == pMaxTxParams)
6412 {
6413 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for pMaxTxParams", __FUNCTION__);
6414 return eHAL_STATUS_FAILURE;
6415 }
6416
6417 vos_mem_copy(pMaxTxParams->bssId, pBssid, SIR_MAC_ADDR_LENGTH);
6418 vos_mem_copy(pMaxTxParams->selfStaMacAddr , pSelfMacAddress,
6419 SIR_MAC_ADDR_LENGTH);
6420 pMaxTxParams->power = dB;
6421
6422 msg.type = WDA_SET_MAX_TX_POWER_REQ;
6423 msg.reserved = 0;
6424 msg.bodyptr = pMaxTxParams;
6425
6426 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6427 {
6428 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__);
6429 vos_mem_free(pMaxTxParams);
6430 return eHAL_STATUS_FAILURE;
6431 }
6432
6433 return eHAL_STATUS_SUCCESS;
6434}
6435
6436#ifdef WLAN_SOFTAP_FEATURE
6437/* ---------------------------------------------------------------------------
6438
6439 \fn sme_HideSSID
6440
6441 \brief hide/show SSID dynamically. Note: this setting will
6442 not persist over reboots.
6443
6444 \param hHal
6445 \param sessionId
6446 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
6447 \- return eHalStatus
6448
6449 -------------------------------------------------------------------------------*/
6450eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
6451{
6452 eHalStatus status = eHAL_STATUS_SUCCESS;
6453 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6454 tANI_U16 len;
6455
6456 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6457 {
6458 tpSirUpdateParams pMsg;
6459 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6460
6461 if( !pSession->sessionActive )
6462 VOS_ASSERT(0);
6463
6464 /* Create the message and send to lim */
6465 len = sizeof(tSirUpdateParams);
6466 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
6467 if(HAL_STATUS_SUCCESS(status))
6468 {
6469 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirUpdateParams) );
6470 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
6471 pMsg->length = len;
6472 /* Data starts from here */
6473 pMsg->sessionId = sessionId;
6474 pMsg->ssidHidden = ssidHidden;
6475 status = palSendMBMessage(pMac->hHdd, pMsg);
6476 }
6477 sme_ReleaseGlobalLock( &pMac->sme );
6478 }
6479 return status;
6480}
6481#endif
6482
6483/* ---------------------------------------------------------------------------
6484
6485 \fn sme_SetTmLevel
6486 \brief Set Thermal Mitigation Level to RIVA
6487 \param hHal - The handle returned by macOpen.
6488 \param newTMLevel - new Thermal Mitigation Level
6489 \param tmMode - Thermal Mitigation handle mode, default 0
6490 \return eHalStatus
6491 ---------------------------------------------------------------------------*/
6492eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
6493{
6494 eHalStatus status = eHAL_STATUS_SUCCESS;
6495 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6496 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6497 vos_msg_t vosMessage;
6498 tAniSetTmLevelReq *setTmLevelReq = NULL;
6499
6500 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6501 {
6502 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
6503 if(NULL == setTmLevelReq)
6504 {
6505 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6506 "%s: Not able to allocate memory for sme_SetTmLevel", __FUNCTION__);
6507 return eHAL_STATUS_FAILURE;
6508 }
6509
6510 setTmLevelReq->tmMode = tmMode;
6511 setTmLevelReq->newTmLevel = newTMLevel;
6512
6513 /* serialize the req through MC thread */
6514 vosMessage.bodyptr = setTmLevelReq;
6515 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
6516 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6517 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6518 {
6519 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6520 "%s: Post Set TM Level MSG fail", __FUNCTION__);
6521 vos_mem_free(setTmLevelReq);
6522 status = eHAL_STATUS_FAILURE;
6523 }
6524 sme_ReleaseGlobalLock( &pMac->sme );
6525 }
6526 return(status);
6527}
6528
6529/*---------------------------------------------------------------------------
6530
6531 \brief sme_featureCapsExchange() - SME interface to exchange capabilities between
6532 Host and FW.
6533
6534 \param hHal - HAL handle for device
6535
6536 \return NONE
6537
6538---------------------------------------------------------------------------*/
6539void sme_featureCapsExchange( tHalHandle hHal)
6540{
6541 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
6542 WDA_featureCapsExchange(vosContext);
6543}
Jeff Johnsond13512a2012-07-17 11:42:19 -07006544
6545
6546/* ---------------------------------------------------------------------------
6547
6548 \fn sme_GetDefaultCountryCode
6549
6550 \brief Get the default country code from NV
6551
6552 \param hHal
6553 \param pCountry
6554 \- return eHalStatus
6555
6556 -------------------------------------------------------------------------------*/
6557eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
6558{
6559 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6560 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
6561}
6562
6563/* ---------------------------------------------------------------------------
6564
6565 \fn sme_GetCurrentCountryCode
6566
6567 \brief Get the current country code
6568
6569 \param hHal
6570 \param pCountry
6571 \- return eHalStatus
6572
6573 -------------------------------------------------------------------------------*/
6574eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
6575{
6576 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6577 return csrGetCurrentCountryCode(pMac, pCountry);
6578}
6579