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