blob: ec9fa217b689765bf62d080fa35f989f4883e029 [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
99// TxMB Functions
100extern eHalStatus pmcPrepareCommand( tpAniSirGlobal pMac, eSmeCommandType cmdType, void *pvParam,
101 tANI_U32 size, tSmeCmd **ppCmd );
102extern void pmcReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
103extern void qosReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
104#if defined WLAN_FEATURE_P2P
105extern eHalStatus p2pProcessRemainOnChannelCmd(tpAniSirGlobal pMac, tSmeCmd *p2pRemainonChn);
106extern eHalStatus sme_remainOnChnRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg);
107extern eHalStatus sme_mgmtFrmInd( tHalHandle hHal, tpSirSmeMgmtFrameInd pSmeMgmtFrm);
108extern eHalStatus sme_remainOnChnReady( tHalHandle hHal, tANI_U8* pMsg);
109extern eHalStatus sme_sendActionCnf( tHalHandle hHal, tANI_U8* pMsg);
110extern eHalStatus p2pProcessNoAReq(tpAniSirGlobal pMac, tSmeCmd *pNoACmd);
111#endif
112
113static eHalStatus initSmeCmdList(tpAniSirGlobal pMac);
114static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping );
115
116eCsrPhyMode sme_GetPhyMode(tHalHandle hHal);
117
118eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf);
119
120eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal);
121
122eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal);
123
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -0700124#ifdef FEATURE_WLAN_LFR
125tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac);
126#endif
127
Jeff Johnson295189b2012-06-20 16:38:30 -0700128//Internal SME APIs
129eHalStatus sme_AcquireGlobalLock( tSmeStruct *psSme)
130{
131 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
132
133 if(psSme)
134 {
135 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psSme->lkSmeGlobalLock) ) )
136 {
137 status = eHAL_STATUS_SUCCESS;
138 }
139 }
140
141 return (status);
142}
143
144
145eHalStatus sme_ReleaseGlobalLock( tSmeStruct *psSme)
146{
147 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
148
149 if(psSme)
150 {
151 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psSme->lkSmeGlobalLock) ) )
152 {
153 status = eHAL_STATUS_SUCCESS;
154 }
155 }
156
157 return (status);
158}
159
160
161
162static eHalStatus initSmeCmdList(tpAniSirGlobal pMac)
163{
164 eHalStatus status;
165 tSmeCmd *pCmd;
166
167 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
168 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdActiveList)))
169 {
170 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdPendingList)))
171 {
172 if(HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd, &pMac->sme.smeCmdFreeList)))
173 {
174 status = palAllocateMemory(pMac->hHdd, (void **)&pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
175 if(HAL_STATUS_SUCCESS(status))
176 {
177 tANI_U32 c;
178
179 palZeroMemory(pMac->hHdd, pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
180 pMac->sme.pSmeCmdBufAddr = pCmd;
181 for(c = 0; c < pMac->sme.totalSmeCmd; c++)
182 {
183 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd[c].Link, LL_ACCESS_LOCK);
184 }
185 }
186 }
187 }
188 }
189
190 return (status);
191}
192
193
194void smeReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCmd)
195{
196 pCmd->command = eSmeNoCommand;
197 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd->Link, LL_ACCESS_LOCK);
198}
199
200
201
202static void smeReleaseCmdList(tpAniSirGlobal pMac, tDblLinkList *pList)
203{
204 tListElem *pEntry;
205 tSmeCmd *pCommand;
206
207 while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_LOCK)) != NULL)
208 {
209 //TODO: base on command type to call release functions
210 //reinitialize different command types so they can be reused
211 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
212 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
213 }
214}
215
216static void purgeSmeCmdList(tpAniSirGlobal pMac)
217{
218 //release any out standing commands back to free command list
219 smeReleaseCmdList(pMac, &pMac->sme.smeCmdPendingList);
220 smeReleaseCmdList(pMac, &pMac->sme.smeCmdActiveList);
221}
222
223void purgeSmeSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
224{
225 //release any out standing commands back to free command list
226 tListElem *pEntry, *pNext;
227 tSmeCmd *pCommand;
228 tDblLinkList *pList = &pMac->sme.smeCmdPendingList;
229 tDblLinkList localList;
230
231 vos_mem_zero(&localList, sizeof(tDblLinkList));
232 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
233 {
234 smsLog(pMac, LOGE, FL(" failed to open list"));
235 return;
236 }
237
238 csrLLLock(pList);
239 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
240 while(pEntry != NULL)
241 {
242 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
243 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
244 if(pCommand->sessionId == sessionId)
245 {
246 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
247 {
248 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
249 }
250 }
251 pEntry = pNext;
252 }
253 csrLLUnlock(pList);
254
255 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
256 {
257 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
258 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
259 }
260 csrLLClose(&localList);
261
262}
263
264
265static eHalStatus freeSmeCmdList(tpAniSirGlobal pMac)
266{
267 eHalStatus status = eHAL_STATUS_SUCCESS;
268
269 purgeSmeCmdList(pMac);
270 csrLLClose(&pMac->sme.smeCmdPendingList);
271 csrLLClose(&pMac->sme.smeCmdActiveList);
272 csrLLClose(&pMac->sme.smeCmdFreeList);
273
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800274 status = vos_lock_acquire(&pMac->sme.lkSmeGlobalLock);
275 if(status != eHAL_STATUS_SUCCESS)
276 {
277 smsLog(pMac, LOGE,
278 FL("Failed to acquire the lock status = %d\n"), status);
279 goto done;
280 }
281
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 if(NULL != pMac->sme.pSmeCmdBufAddr)
283 {
284 status = palFreeMemory(pMac->hHdd, pMac->sme.pSmeCmdBufAddr);
285 pMac->sme.pSmeCmdBufAddr = NULL;
286 }
287
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800288 status = vos_lock_release(&pMac->sme.lkSmeGlobalLock);
289 if(status != eHAL_STATUS_SUCCESS)
290 {
291 smsLog(pMac, LOGE,
292 FL("Failed to release the lock status = %d\n"), status);
293 }
294done:
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 return (status);
296}
297
298
299void dumpCsrCommandInfo(tpAniSirGlobal pMac, tSmeCmd *pCmd)
300{
301#ifdef WLAN_DEBUG
302 switch( pCmd->command )
303 {
304 case eSmeCommandScan:
305 smsLog( pMac, LOGE, " scan command reason is %d", pCmd->u.scanCmd.reason );
306 break;
307
308 case eSmeCommandRoam:
309 smsLog( pMac, LOGE, " roam command reason is %d", pCmd->u.roamCmd.roamReason );
310 break;
311
312 case eSmeCommandWmStatusChange:
313 smsLog( pMac, LOGE, " WMStatusChange command type is %d", pCmd->u.wmStatusChangeCmd.Type );
314 break;
315
316 case eSmeCommandSetKey:
317 smsLog( pMac, LOGE, " setKey command auth(%d) enc(%d)",
318 pCmd->u.setKeyCmd.authType, pCmd->u.setKeyCmd.encType );
319 break;
320
321 case eSmeCommandRemoveKey:
322 smsLog( pMac, LOGE, " removeKey command auth(%d) enc(%d)",
323 pCmd->u.removeKeyCmd.authType, pCmd->u.removeKeyCmd.encType );
324 break;
325
326 default:
327 break;
328 }
329#endif //#ifdef WLAN_DEBUG
330}
331
332tSmeCmd *smeGetCommandBuffer( tpAniSirGlobal pMac )
333{
334 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
335 tListElem *pEntry;
336
337 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK );
338
339 // If we can get another MS Msg buffer, then we are ok. Just link
340 // the entry onto the linked list. (We are using the linked list
341 // to keep track of tfhe message buffers).
342 if ( pEntry )
343 {
344 pRetCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
345 }
346 else {
347 int idx = 1;
348
349 //Cannot change pRetCmd here since it needs to return later.
350 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
351 if( pEntry )
352 {
353 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
354 }
355 smsLog( pMac, LOGE, "Out of command buffer.... command (0x%X) stuck\n",
356 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
357 if(pTempCmd)
358 {
359 if( eSmeCsrCommandMask & pTempCmd->command )
360 {
361 //CSR command is stuck. See what the reason code is for that command
362 dumpCsrCommandInfo(pMac, pTempCmd);
363 }
364 } //if(pTempCmd)
365
366 //dump what is in the pending queue
367 csrLLLock(&pMac->sme.smeCmdPendingList);
368 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
369 while(pEntry)
370 {
371 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
372 smsLog( pMac, LOGE, "Out of command buffer.... SME pending command #%d (0x%X)\n",
373 idx++, pTempCmd->command );
374 if( eSmeCsrCommandMask & pTempCmd->command )
375 {
376 //CSR command is stuck. See what the reason code is for that command
377 dumpCsrCommandInfo(pMac, pTempCmd);
378 }
379 pEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
380 }
381 csrLLUnlock(&pMac->sme.smeCmdPendingList);
382
383 //There may be some more command in CSR's own pending queue
384 csrLLLock(&pMac->roam.roamCmdPendingList);
385 pEntry = csrLLPeekHead( &pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK );
386 while(pEntry)
387 {
388 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
389 smsLog( pMac, LOGE, "Out of command buffer.... CSR pending command #%d (0x%X)\n",
390 idx++, pTempCmd->command );
391 dumpCsrCommandInfo(pMac, pTempCmd);
392 pEntry = csrLLNext( &pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
393 }
394 csrLLUnlock(&pMac->roam.roamCmdPendingList);
395 }
396
397 return( pRetCmd );
398}
399
400
401void smePushCommand( tpAniSirGlobal pMac, tSmeCmd *pCmd, tANI_BOOLEAN fHighPriority )
402{
403 if ( fHighPriority )
404 {
405 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
406 }
407 else
408 {
409 csrLLInsertTail( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
410 }
411
412 // process the command queue...
413 smeProcessPendingQueue( pMac );
414
415 return;
416}
417
418
419static eSmeCommandType smeIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand )
420{
421 eSmeCommandType pmcCommand = eSmeNoCommand;
422 tANI_BOOLEAN fFullPowerNeeded = eANI_BOOLEAN_FALSE;
423 tPmcState pmcState;
424 eHalStatus status;
425
426 do
427 {
428 pmcState = pmcGetPmcState(pMac);
429
430 status = csrIsFullPowerNeeded( pMac, pCommand, NULL, &fFullPowerNeeded );
431 if( !HAL_STATUS_SUCCESS(status) )
432 {
433 //PMC state is not right for the command, drop it
434 return ( eSmeDropCommand );
435 }
436 if( fFullPowerNeeded ) break;
437 fFullPowerNeeded = ( ( eSmeCommandAddTs == pCommand->command ) ||
438 ( eSmeCommandDelTs == pCommand->command ) );
439 if( fFullPowerNeeded ) break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700440#ifdef FEATURE_OEM_DATA_SUPPORT
441 fFullPowerNeeded = (pmcState == IMPS &&
442 eSmeCommandOemDataReq == pCommand->command);
443 if(fFullPowerNeeded) break;
444#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700445#ifdef WLAN_FEATURE_P2P
446 fFullPowerNeeded = (pmcState == IMPS &&
447 eSmeCommandRemainOnChannel == pCommand->command);
448 if(fFullPowerNeeded) break;
449#endif
450 } while(0);
451
452 if( fFullPowerNeeded )
453 {
454 switch( pmcState )
455 {
456 case IMPS:
457 case STANDBY:
458 pmcCommand = eSmeCommandExitImps;
459 break;
460
461 case BMPS:
462 pmcCommand = eSmeCommandExitBmps;
463 break;
464
465 case UAPSD:
466 pmcCommand = eSmeCommandExitUapsd;
467 break;
468
469 case WOWL:
470 pmcCommand = eSmeCommandExitWowl;
471 break;
472
473 default:
474 break;
475 }
476 }
477
478 return ( pmcCommand );
479}
480
481
482//For commands that need to do extra cleanup.
483static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
484{
485 if( eSmePmcCommandMask & pCommand->command )
486 {
487 pmcAbortCommand( pMac, pCommand, fStopping );
488 }
489 else if ( eSmeCsrCommandMask & pCommand->command )
490 {
491 csrAbortCommand( pMac, pCommand, fStopping );
492 }
493 else
494 {
495 switch( pCommand->command )
496 {
497#ifdef WLAN_FEATURE_P2P
498 case eSmeCommandRemainOnChannel:
499 if (NULL != pCommand->u.remainChlCmd.callback)
500 {
501 remainOnChanCallback callback =
502 pCommand->u.remainChlCmd.callback;
503 /* process the msg */
504 if( callback )
505 {
506 callback(pMac, pCommand->u.remainChlCmd.callbackCtx,
507 eCSR_SCAN_ABORT );
508 }
509 }
510 smeReleaseCommand( pMac, pCommand );
511 break;
512#endif
513 default:
514 smeReleaseCommand( pMac, pCommand );
515 break;
516 }
517 }
518}
519
520
521
522tANI_BOOLEAN smeProcessCommand( tpAniSirGlobal pMac )
523{
524 tANI_BOOLEAN fContinue = eANI_BOOLEAN_FALSE;
525 eHalStatus status = eHAL_STATUS_SUCCESS;
526 tListElem *pEntry;
527 tSmeCmd *pCommand;
528 eSmeCommandType pmcCommand = eSmeNoCommand;
529
530 // if the ActiveList is empty, then nothing is active so we can process a
531 // pending command...
532 //alwasy lock active list before locking pending list
533 csrLLLock( &pMac->sme.smeCmdActiveList );
534 if ( csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) )
535 {
536 if(!csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK))
537 {
538 //Peek the command
539 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK );
540 if( pEntry )
541 {
542 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
543 //We cannot execute any command in wait-for-key state until setKey is through.
544 if( CSR_IS_WAIT_FOR_KEY( pMac, pCommand->sessionId ) )
545 {
546 if( !CSR_IS_SET_KEY_COMMAND( pCommand ) )
547 {
548 csrLLUnlock( &pMac->sme.smeCmdActiveList );
549 smsLog(pMac, LOGE, " Cannot process command(%d) while waiting for key\n", pCommand->command);
550 return ( eANI_BOOLEAN_FALSE );
551 }
552 }
553 pmcCommand = smeIsFullPowerNeeded( pMac, pCommand );
554 if( eSmeDropCommand == pmcCommand )
555 {
556 //This command is not ok for current PMC state
557 if( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
558 {
559 smeAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE );
560 }
561 csrLLUnlock( &pMac->sme.smeCmdActiveList );
562 //tell caller to continue
563 return (eANI_BOOLEAN_TRUE);
564 }
565 else if( eSmeNoCommand != pmcCommand )
566 {
567 tExitBmpsInfo exitBmpsInfo;
568 void *pv = NULL;
569 tANI_U32 size = 0;
570 tSmeCmd *pPmcCmd = NULL;
571
572 if( eSmeCommandExitBmps == pmcCommand )
573 {
574 exitBmpsInfo.exitBmpsReason = eSME_REASON_OTHER;
575 pv = (void *)&exitBmpsInfo;
576 size = sizeof(tExitBmpsInfo);
577 }
578 //pmcCommand has to be one of the exit power save command
579 status = pmcPrepareCommand( pMac, pmcCommand, pv, size, &pPmcCmd );
580 if( HAL_STATUS_SUCCESS( status ) && pPmcCmd )
581 {
582 //Force this command to wake up the chip
583 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK );
584 csrLLUnlock( &pMac->sme.smeCmdActiveList );
585 fContinue = pmcProcessCommand( pMac, pPmcCmd );
586 if( fContinue )
587 {
588 //The command failed, remove it
589 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK ) )
590 {
591 pmcReleaseCommand( pMac, pPmcCmd );
592 }
593 }
594 }
595 else
596 {
597 csrLLUnlock( &pMac->sme.smeCmdActiveList );
598 smsLog( pMac, LOGE, FL( "Cannot issue command(0x%X) to wake up the chip. Status = %d\n"), pmcCommand, status );
599 //Let it retry
600 fContinue = eANI_BOOLEAN_TRUE;
601 }
602 return fContinue;
603 }
604 if ( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
605 {
606 // we can reuse the pCommand
607
608 // Insert the command onto the ActiveList...
609 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pCommand->Link, LL_ACCESS_NOLOCK );
610
611 // .... and process the command.
612
613 switch ( pCommand->command )
614 {
615
616 case eSmeCommandScan:
617 csrLLUnlock( &pMac->sme.smeCmdActiveList );
618 status = csrProcessScanCommand( pMac, pCommand );
619 break;
620
621 case eSmeCommandRoam:
622 csrLLUnlock( &pMac->sme.smeCmdActiveList );
623 status = csrRoamProcessCommand( pMac, pCommand );
624 break;
625
626 case eSmeCommandWmStatusChange:
627 csrLLUnlock( &pMac->sme.smeCmdActiveList );
628 csrRoamProcessWmStatusChangeCommand(pMac, pCommand);
629 break;
630
631 case eSmeCommandSetKey:
632 csrLLUnlock( &pMac->sme.smeCmdActiveList );
633 status = csrRoamProcessSetKeyCommand( pMac, pCommand );
634 if(!HAL_STATUS_SUCCESS(status))
635 {
636 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
637 &pCommand->Link, LL_ACCESS_LOCK ) )
638 {
639 csrReleaseCommandSetKey( pMac, pCommand );
640 }
641 }
642 break;
643
644 case eSmeCommandRemoveKey:
645 csrLLUnlock( &pMac->sme.smeCmdActiveList );
646 status = csrRoamProcessRemoveKeyCommand( pMac, pCommand );
647 if(!HAL_STATUS_SUCCESS(status))
648 {
649 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
650 &pCommand->Link, LL_ACCESS_LOCK ) )
651 {
652 csrReleaseCommandRemoveKey( pMac, pCommand );
653 }
654 }
655 break;
656
657 case eSmeCommandAddStaSession:
658 csrLLUnlock( &pMac->sme.smeCmdActiveList );
659 csrProcessAddStaSessionCommand( pMac, pCommand );
660 break;
661 case eSmeCommandDelStaSession:
662 csrLLUnlock( &pMac->sme.smeCmdActiveList );
663 csrProcessDelStaSessionCommand( pMac, pCommand );
664 break;
665
Jeff Johnsone7245742012-09-05 17:12:55 -0700666#ifdef FEATURE_OEM_DATA_SUPPORT
667 case eSmeCommandOemDataReq:
668 csrLLUnlock(&pMac->sme.smeCmdActiveList);
669 oemData_ProcessOemDataReqCommand(pMac, pCommand);
670 break;
671#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700672#if defined WLAN_FEATURE_P2P
673 case eSmeCommandRemainOnChannel:
674 csrLLUnlock(&pMac->sme.smeCmdActiveList);
675 p2pProcessRemainOnChannelCmd(pMac, pCommand);
676 break;
677 case eSmeCommandNoAUpdate:
678 csrLLUnlock( &pMac->sme.smeCmdActiveList );
679 p2pProcessNoAReq(pMac,pCommand);
680#endif
681 case eSmeCommandEnterImps:
682 case eSmeCommandExitImps:
683 case eSmeCommandEnterBmps:
684 case eSmeCommandExitBmps:
685 case eSmeCommandEnterUapsd:
686 case eSmeCommandExitUapsd:
687 case eSmeCommandEnterWowl:
688 case eSmeCommandExitWowl:
689 csrLLUnlock( &pMac->sme.smeCmdActiveList );
690 fContinue = pmcProcessCommand( pMac, pCommand );
691 if( fContinue )
692 {
693 //The command failed, remove it
694 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
695 &pCommand->Link, LL_ACCESS_LOCK ) )
696 {
697 pmcReleaseCommand( pMac, pCommand );
698 }
699 }
700 break;
701
702 //Treat standby differently here because caller may not be able to handle
703 //the failure so we do our best here
704 case eSmeCommandEnterStandby:
705 if( csrIsConnStateDisconnected( pMac, pCommand->sessionId ) )
706 {
707 //It can continue
708 csrLLUnlock( &pMac->sme.smeCmdActiveList );
709 fContinue = pmcProcessCommand( pMac, pCommand );
710 if( fContinue )
711 {
712 //The command failed, remove it
713 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
714 &pCommand->Link, LL_ACCESS_LOCK ) )
715 {
716 pmcReleaseCommand( pMac, pCommand );
717 }
718 }
719 }
720 else
721 {
722 //Need to issue a disconnect first before processing this command
723 tSmeCmd *pNewCmd;
724
725 //We need to re-run the command
726 fContinue = eANI_BOOLEAN_TRUE;
727 //Pull off the standby command first
728 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
729 &pCommand->Link, LL_ACCESS_NOLOCK ) )
730 {
731 csrLLUnlock( &pMac->sme.smeCmdActiveList );
732 //Need to call CSR function here because the disconnect command
733 //is handled by CSR
734 pNewCmd = csrGetCommandBuffer( pMac );
735 if( NULL != pNewCmd )
736 {
737 //Put the standby command to the head of the pending list first
738 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCommand->Link,
739 LL_ACCESS_LOCK );
740 pNewCmd->command = eSmeCommandRoam;
741 pNewCmd->u.roamCmd.roamReason = eCsrForcedDisassoc;
742 //Put the disassoc command before the standby command
743 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pNewCmd->Link,
744 LL_ACCESS_LOCK );
745 }
746 else
747 {
748 //Continue the command here
749 fContinue = pmcProcessCommand( pMac, pCommand );
750 if( fContinue )
751 {
752 //The command failed, remove it
753 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
754 &pCommand->Link, LL_ACCESS_LOCK ) )
755 {
756 pmcReleaseCommand( pMac, pCommand );
757 }
758 }
759 }
760 }
761 else
762 {
763 csrLLUnlock( &pMac->sme.smeCmdActiveList );
764 smsLog( pMac, LOGE, FL(" failed to remove standby command\n") );
765 VOS_ASSERT(0);
766 }
767 }
768 break;
769
770 case eSmeCommandAddTs:
771 case eSmeCommandDelTs:
772 csrLLUnlock( &pMac->sme.smeCmdActiveList );
773#ifndef WLAN_MDM_CODE_REDUCTION_OPT
774 fContinue = qosProcessCommand( pMac, pCommand );
775 if( fContinue )
776 {
777 //The command failed, remove it
778 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
779 &pCommand->Link, LL_ACCESS_NOLOCK ) )
780 {
781//#ifndef WLAN_MDM_CODE_REDUCTION_OPT
782 qosReleaseCommand( pMac, pCommand );
783//#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
784 }
785 }
786#endif
787 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800788#ifdef FEATURE_WLAN_TDLS
789 case eSmeCommandTdlsSendMgmt:
790 case eSmeCommandTdlsAddPeer:
791 case eSmeCommandTdlsDelPeer:
792#ifdef FEATURE_WLAN_TDLS_INTERNAL
793 case eSmeCommandTdlsDiscovery:
794 case eSmeCommandTdlsLinkSetup:
795 case eSmeCommandTdlsLinkTear:
796 case eSmeCommandTdlsEnterUapsd:
797 case eSmeCommandTdlsExitUapsd:
798#endif
799 {
800 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
801 "sending TDLS Command 0x%x to PE\n", pCommand->command);
802
803 csrLLUnlock( &pMac->sme.smeCmdActiveList );
804 status = csrTdlsProcessCmd( pMac, pCommand );
805 }
806 break ;
807#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700808
809 default:
810 //something is wrong
811 //remove it from the active list
812 smsLog(pMac, LOGE, " csrProcessCommand processes an unknown command %d\n", pCommand->command);
813 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK );
814 csrLLUnlock( &pMac->sme.smeCmdActiveList );
815 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
816 smeReleaseCommand( pMac, pCommand );
817 status = eHAL_STATUS_FAILURE;
818 break;
819 }
820 if(!HAL_STATUS_SUCCESS(status))
821 {
822 fContinue = eANI_BOOLEAN_TRUE;
823 }
824 }//if(pEntry)
825 else
826 {
827 //This is odd. Some one else pull off the command.
828 csrLLUnlock( &pMac->sme.smeCmdActiveList );
829 }
830 }
831 else
832 {
833 csrLLUnlock( &pMac->sme.smeCmdActiveList );
834 }
835 }
836 else
837 {
838 //No command waiting
839 csrLLUnlock( &pMac->sme.smeCmdActiveList );
840 //This is only used to restart an idle mode scan, it means at least one other idle scan has finished.
841 if(pMac->scan.fRestartIdleScan && eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
842 {
843 tANI_U32 nTime = 0;
844
845 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
846 if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime)))
847 {
848 csrScanStartIdleScanTimer(pMac, nTime);
849 }
850 }
851 }
852 }
853 else {
854 csrLLUnlock( &pMac->sme.smeCmdActiveList );
855 }
856
857 return ( fContinue );
858}
859
860void smeProcessPendingQueue( tpAniSirGlobal pMac )
861{
862 while( smeProcessCommand( pMac ) );
863}
864
865
866tANI_BOOLEAN smeCommandPending(tpAniSirGlobal pMac)
867{
868 return ( !csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) ||
869 !csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK) );
870}
871
872
873
874//Global APIs
875
876/*--------------------------------------------------------------------------
877
878 \brief sme_Open() - Initialze all SME modules and put them at idle state
879
880 The function initializes each module inside SME, PMC, CCM, CSR, etc. . Upon
881 successfully return, all modules are at idle state ready to start.
882
883 smeOpen must be called before any other SME APIs can be involved.
884 smeOpen must be called after macOpen.
885 This is a synchronuous call
886 \param hHal - The handle returned by macOpen.
887
888 \return eHAL_STATUS_SUCCESS - SME is successfully initialized.
889
890 Other status means SME is failed to be initialized
891 \sa
892
893 --------------------------------------------------------------------------*/
894eHalStatus sme_Open(tHalHandle hHal)
895{
896 eHalStatus status = eHAL_STATUS_FAILURE;
897 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
898
899 do {
900 pMac->sme.state = SME_STATE_STOP;
901 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->sme.lkSmeGlobalLock ) ) )
902 {
903 smsLog( pMac, LOGE, "sme_Open failed init lock\n" );
904 status = eHAL_STATUS_FAILURE;
905 break;
906 }
907
908 status = ccmOpen(hHal);
909 if ( ! HAL_STATUS_SUCCESS( status ) ) {
910 smsLog( pMac, LOGE,
911 "ccmOpen failed during initialization with status=%d", status );
912 break;
913 }
914
915 status = csrOpen(pMac);
916 if ( ! HAL_STATUS_SUCCESS( status ) ) {
917 smsLog( pMac, LOGE,
918 "csrOpen failed during initialization with status=%d", status );
919 break;
920 }
921
922 status = pmcOpen(hHal);
923 if ( ! HAL_STATUS_SUCCESS( status ) ) {
924 smsLog( pMac, LOGE,
925 "pmcOpen failed during initialization with status=%d", status );
926 break;
927 }
928
929#ifndef WLAN_MDM_CODE_REDUCTION_OPT
930 status = sme_QosOpen(pMac);
931 if ( ! HAL_STATUS_SUCCESS( status ) ) {
932 smsLog( pMac, LOGE,
933 "Qos open failed during initialization with status=%d", status );
934 break;
935 }
936
937 status = btcOpen(pMac);
938 if ( ! HAL_STATUS_SUCCESS( status ) ) {
939 smsLog( pMac, LOGE,
940 "btcOpen open failed during initialization with status=%d", status );
941 break;
942 }
943#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700944#ifdef FEATURE_OEM_DATA_SUPPORT
945 status = oemData_OemDataReqOpen(pMac);
946 if ( ! HAL_STATUS_SUCCESS( status ) ) {
947 smsLog(pMac, LOGE,
948 "oemData_OemDataReqOpen failed during initialization with status=%d", status );
949 break;
950 }
951#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700952
953 if(!HAL_STATUS_SUCCESS((status = initSmeCmdList(pMac))))
954 break;
955
956#ifdef WLAN_SOFTAP_FEATURE
957 {
958 v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SAP, NULL);
959 if ( NULL == pvosGCtx ){
960 smsLog( pMac, LOGE, "WLANSAP_Open open failed during initialization");
961 status = eHAL_STATUS_FAILURE;
962 break;
963 }
964
965 status = WLANSAP_Open( pvosGCtx );
966 if ( ! HAL_STATUS_SUCCESS( status ) ) {
967 smsLog( pMac, LOGE,
968 "WLANSAP_Open open failed during initialization with status=%d", status );
969 break;
970 }
971 }
972#endif
973#if defined WLAN_FEATURE_VOWIFI
974 status = rrmOpen(pMac);
975 if ( ! HAL_STATUS_SUCCESS( status ) ) {
976 smsLog( pMac, LOGE,
977 "rrmOpen open failed during initialization with status=%d", status );
978 break;
979 }
980#endif
981
982#if defined WLAN_FEATURE_VOWIFI_11R
983 sme_FTOpen(pMac);
984#endif
985#if defined WLAN_FEATURE_P2P
986 sme_p2pOpen(pMac);
987#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800988#ifdef FEATURE_WLAN_TDLS
989 status = csrTdlsOpen(pMac) ;
990 if ( ! HAL_STATUS_SUCCESS( status ) )
991 {
992 smsLog( pMac, LOGE, "Tdlspen open failed during initialization with \
993 status=%d\n", status );
994 break;
995 }
996#endif
997
Jeff Johnson295189b2012-06-20 16:38:30 -0700998
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
1011 This is a synchronuous call
1012
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
1046 This is a synchronuous call
1047
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
1101 This is a synchronuous call
1102
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
1130 This is a synchronuous call
1131
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
1201 This is a synchronuous call
1202
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
1244 This is a synchronuous call
1245 \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.
1337 This is a synchronuous call
1338 \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
1440 This is a synchronuous call
1441 \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:
1714 case eWNI_SME_TDLS_DEL_STA_RSP:
1715#ifdef FEATURE_WLAN_TDLS_INTERNAL
1716 case eWNI_SME_TDLS_DISCOVERY_START_RSP:
1717 case eWNI_SME_TDLS_DISCOVERY_START_IND:
1718 case eWNI_SME_TDLS_LINK_START_RSP:
1719 case eWNI_SME_TDLS_LINK_START_IND:
1720 case eWNI_SME_TDLS_TEARDOWN_RSP:
1721 case eWNI_SME_TDLS_TEARDOWN_IND:
1722 case eWNI_SME_ADD_TDLS_PEER_IND:
1723 case eWNI_SME_DELETE_TDLS_PEER_IND:
1724#endif
1725 {
1726 if (pMsg->bodyptr)
1727 {
1728 status = tdlsMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
1729 vos_mem_free( pMsg->bodyptr );
1730 }
1731 else
1732 {
1733 smsLog( pMac, LOGE, "Empty rsp message for TDLS, \
1734 nothing to process\n");
1735 }
1736 break;
1737 }
1738#endif
1739
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 default:
1741
1742 if ( ( pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN )
1743 && ( pMsg->type <= eWNI_SME_MSG_TYPES_END ) )
1744 {
1745 //CSR
1746 if (pMsg->bodyptr)
1747 {
1748 status = csrMsgProcessor(hHal, pMsg->bodyptr);
1749 vos_mem_free( pMsg->bodyptr );
1750 }
1751 else
1752 {
1753 smsLog( pMac, LOGE, "Empty rsp message for CSR, nothing to process\n");
1754 }
1755 }
1756 else
1757 {
1758 smsLog( pMac, LOGW, "Unknown message type %d, nothing to process\n",
1759 pMsg->type);
1760 if (pMsg->bodyptr)
1761 {
1762 vos_mem_free( pMsg->bodyptr );
1763 }
1764 }
1765 }//switch
1766 } //SME_IS_START
1767 else
1768 {
1769 smsLog( pMac, LOGW, "message type %d in stop state ignored\n", pMsg->type);
1770 if (pMsg->bodyptr)
1771 {
1772 vos_mem_free( pMsg->bodyptr );
1773 }
1774 }
1775 sme_ReleaseGlobalLock( &pMac->sme );
1776 }
1777 else
1778 {
1779 smsLog( pMac, LOGW, "Locking failed, bailing out\n");
1780 if (pMsg->bodyptr)
1781 {
1782 vos_mem_free( pMsg->bodyptr );
1783 }
1784 }
1785
1786 return status;
1787}
1788
1789
1790//No need to hold the global lock here because this function can only be called
1791//after sme_Stop.
1792v_VOID_t sme_FreeMsg( tHalHandle hHal, vos_msg_t* pMsg )
1793{
1794 if( pMsg )
1795 {
1796 if (pMsg->bodyptr)
1797 {
1798 vos_mem_free( pMsg->bodyptr );
1799 }
1800 }
1801
1802}
1803
1804
1805/*--------------------------------------------------------------------------
1806
1807 \brief sme_Stop() - Stop all SME modules and put them at idle state
1808
1809 The function stops each module in SME, PMC, CCM, CSR, etc. . Upon
1810 return, all modules are at idle state ready to start.
1811
1812 This is a synchronuous call
1813 \param hHal - The handle returned by macOpen
1814
1815 \return eHAL_STATUS_SUCCESS - SME is stopped.
1816
1817 Other status means SME is failed to stop but caller should still
1818 consider SME is stopped.
1819 \sa
1820
1821 --------------------------------------------------------------------------*/
1822eHalStatus sme_Stop(tHalHandle hHal, tANI_BOOLEAN pmcFlag)
1823{
1824 eHalStatus status = eHAL_STATUS_FAILURE;
1825 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
1826 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1827
1828#ifdef WLAN_SOFTAP_FEATURE
1829 status = WLANSAP_Stop(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1830 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1831 smsLog( pMac, LOGE, "WLANSAP_Stop failed during smeStop with status=%d\n",
1832 status );
1833 fail_status = status;
1834 }
1835#endif
1836
1837 p2pStop(hHal);
1838
1839 if(pmcFlag)
1840 {
1841 status = pmcStop(hHal);
1842 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1843 smsLog( pMac, LOGE, "pmcStop failed during smeStop with status=%d\n",
1844 status );
1845 fail_status = status;
1846 }
1847 }
1848
1849 status = csrStop(pMac);
1850 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1851 smsLog( pMac, LOGE, "csrStop failed during smeStop with status=%d\n",
1852 status );
1853 fail_status = status;
1854 }
1855
1856 ccmStop(hHal);
1857
1858 purgeSmeCmdList(pMac);
1859
1860 if (!HAL_STATUS_SUCCESS( fail_status )) {
1861 status = fail_status;
1862 }
1863
1864 pMac->sme.state = SME_STATE_STOP;
1865
1866 return status;
1867}
1868
1869/*--------------------------------------------------------------------------
1870
1871 \brief sme_Close() - Release all SME modules and their resources.
1872
1873 The function release each module in SME, PMC, CCM, CSR, etc. . Upon
1874 return, all modules are at closed state.
1875
1876 No SME APIs can be involved after smeClose except smeOpen.
1877 smeClose must be called before macClose.
1878 This is a synchronuous call
1879 \param hHal - The handle returned by macOpen
1880
1881 \return eHAL_STATUS_SUCCESS - SME is successfully close.
1882
1883 Other status means SME is failed to be closed but caller still cannot
1884 call any other SME functions except smeOpen.
1885 \sa
1886
1887 --------------------------------------------------------------------------*/
1888eHalStatus sme_Close(tHalHandle hHal)
1889{
1890 eHalStatus status = eHAL_STATUS_FAILURE;
1891 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
1892 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1893
1894 status = csrClose(pMac);
1895 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1896 smsLog( pMac, LOGE, "csrClose failed during sme close with status=%d\n",
1897 status );
1898 fail_status = status;
1899 }
1900
1901#ifdef WLAN_SOFTAP_FEATURE
1902 status = WLANSAP_Close(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1903 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1904 smsLog( pMac, LOGE, "WLANSAP_close failed during sme close with status=%d\n",
1905 status );
1906 fail_status = status;
1907 }
1908#endif
1909
1910#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1911 status = btcClose(hHal);
1912 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1913 smsLog( pMac, LOGE, "BTC close failed during sme close with status=%d\n",
1914 status );
1915 fail_status = status;
1916 }
1917
1918 status = sme_QosClose(pMac);
1919 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1920 smsLog( pMac, LOGE, "Qos close failed during sme close with status=%d\n",
1921 status );
1922 fail_status = status;
1923 }
1924#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001925#ifdef FEATURE_OEM_DATA_SUPPORT
1926 status = oemData_OemDataReqClose(hHal);
1927 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1928 smsLog( pMac, LOGE, "OEM DATA REQ close failed during sme close with status=%d\n",
1929 status );
1930 fail_status = status;
1931 }
1932#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001933
1934 status = ccmClose(hHal);
1935 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1936 smsLog( pMac, LOGE, "ccmClose failed during sme close with status=%d\n",
1937 status );
1938 fail_status = status;
1939 }
1940
1941 status = pmcClose(hHal);
1942 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1943 smsLog( pMac, LOGE, "pmcClose failed during sme close with status=%d\n",
1944 status );
1945 fail_status = status;
1946 }
1947#if defined WLAN_FEATURE_VOWIFI
1948 status = rrmClose(hHal);
1949 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1950 smsLog( pMac, LOGE, "RRM close failed during sme close with status=%d\n",
1951 status );
1952 fail_status = status;
1953 }
1954#endif
1955
1956#if defined WLAN_FEATURE_VOWIFI_11R
1957 sme_FTClose(hHal);
1958#endif
1959#if defined WLAN_FEATURE_P2P
1960 sme_p2pClose(hHal);
1961#endif
1962
1963 freeSmeCmdList(pMac);
1964
1965 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->sme.lkSmeGlobalLock ) ) )
1966 {
1967 fail_status = eHAL_STATUS_FAILURE;
1968 }
1969
1970 if (!HAL_STATUS_SUCCESS( fail_status )) {
1971 status = fail_status;
1972 }
1973
1974 pMac->sme.state = SME_STATE_STOP;
1975
1976 return status;
1977}
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001978#ifdef FEATURE_WLAN_LFR
1979tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac)
1980{
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07001981#if 0
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001982 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
1983 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1984 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
1985 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
1986 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
1987 return eANI_BOOLEAN_FALSE;
1988 default:
1989 return eANI_BOOLEAN_TRUE;
1990 }
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07001991#else
1992 /*
1993 * TODO: always return TRUE for now until
1994 * we figure out why we could be stuck in
1995 * one of the roaming states forever.
1996 */
1997 return eANI_BOOLEAN_TRUE;
1998#endif
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07001999}
2000#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002001/* ---------------------------------------------------------------------------
2002 \fn sme_ScanRequest
2003 \brief a wrapper function to Request a 11d or full scan from CSR.
2004 This is an asynchronuous call
2005 \param pScanRequestID - pointer to an object to get back the request ID
2006 \param callback - a callback function that scan calls upon finish, will not
2007 be called if csrScanRequest returns error
2008 \param pContext - a pointer passed in for the callback
2009 \return eHalStatus
2010 ---------------------------------------------------------------------------*/
2011eHalStatus sme_ScanRequest(tHalHandle hHal, tANI_U8 sessionId, tCsrScanRequest *pscanReq,
2012 tANI_U32 *pScanRequestID,
2013 csrScanCompleteCallback callback, void *pContext)
2014{
2015 eHalStatus status = eHAL_STATUS_FAILURE;
2016 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2017
2018 smsLog(pMac, LOG2, FL("enter"));
2019 do
2020 {
2021 if(pMac->scan.fScanEnable)
2022 {
2023 status = sme_AcquireGlobalLock( &pMac->sme );
2024 if ( HAL_STATUS_SUCCESS( status ) )
2025 {
2026 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002027#ifdef FEATURE_WLAN_LFR
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002028 if(csrIsScanAllowed(pMac))
2029 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002030#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002031 status = csrScanRequest( hHal, sessionId, pscanReq,
2032 pScanRequestID, callback, pContext );
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002033#ifdef FEATURE_WLAN_LFR
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002034 }
2035 else
2036 {
Madan Mohan Koyyalamudiab4ab0d2012-10-24 14:26:50 -07002037 smsLog(pMac, LOGE, FL("Scan denied in state %d (sub-state %d)"),
2038 pMac->roam.neighborRoamInfo.neighborRoamState,
2039 pMac->roam.curSubState[sessionId]);
2040 /*HandOff is in progress. So schedule this scan later*/
2041 status = eHAL_STATUS_RESOURCES;
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002042 }
2043#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 }
2045
2046 sme_ReleaseGlobalLock( &pMac->sme );
2047 } //sme_AcquireGlobalLock success
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002048 else
2049 {
2050 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
2051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 } //if(pMac->scan.fScanEnable)
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002053 else
2054 {
2055 smsLog(pMac, LOGE, FL("fScanEnable FALSE"));
2056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 } while( 0 );
2058
2059 return (status);
2060
2061
2062}
2063
2064/* ---------------------------------------------------------------------------
2065 \fn sme_ScanGetResult
2066 \brief a wrapper function to request scan results from CSR.
2067 This is a synchronuous call
2068 \param pFilter - If pFilter is NULL, all cached results are returned
2069 \param phResult - an object for the result.
2070 \return eHalStatus
2071 ---------------------------------------------------------------------------*/
2072eHalStatus sme_ScanGetResult(tHalHandle hHal, tANI_U8 sessionId, tCsrScanResultFilter *pFilter,
2073 tScanResultHandle *phResult)
2074{
2075 eHalStatus status = eHAL_STATUS_FAILURE;
2076 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2077
2078 smsLog(pMac, LOG2, FL("enter"));
2079 status = sme_AcquireGlobalLock( &pMac->sme );
2080 if ( HAL_STATUS_SUCCESS( status ) )
2081 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07002082 status = csrScanGetResult( hHal, pFilter, phResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 sme_ReleaseGlobalLock( &pMac->sme );
2084 }
2085 smsLog(pMac, LOG2, FL("exit status %d"), status);
2086
2087 return (status);
2088}
2089
2090
2091/* ---------------------------------------------------------------------------
2092 \fn sme_ScanFlushResult
2093 \brief a wrapper function to request CSR to clear scan results.
2094 This is a synchronuous call
2095 \return eHalStatus
2096 ---------------------------------------------------------------------------*/
2097eHalStatus sme_ScanFlushResult(tHalHandle hHal, tANI_U8 sessionId)
2098{
2099 eHalStatus status = eHAL_STATUS_FAILURE;
2100 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2101
2102 status = sme_AcquireGlobalLock( &pMac->sme );
2103 if ( HAL_STATUS_SUCCESS( status ) )
2104 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07002105 status = csrScanFlushResult( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 sme_ReleaseGlobalLock( &pMac->sme );
2107 }
2108
2109 return (status);
2110}
2111
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002112eHalStatus sme_ScanFlushP2PResult(tHalHandle hHal, tANI_U8 sessionId)
2113{
2114 eHalStatus status = eHAL_STATUS_FAILURE;
2115 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2116
2117 status = sme_AcquireGlobalLock( &pMac->sme );
2118 if ( HAL_STATUS_SUCCESS( status ) )
2119 {
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302120 status = csrScanFlushSelectiveResult( hHal, VOS_TRUE );
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002121 sme_ReleaseGlobalLock( &pMac->sme );
2122 }
2123
2124 return (status);
2125}
Jeff Johnson295189b2012-06-20 16:38:30 -07002126
2127/* ---------------------------------------------------------------------------
2128 \fn sme_ScanResultGetFirst
2129 \brief a wrapper function to request CSR to returns the first element of
2130 scan result.
2131 This is a synchronuous call
2132 \param hScanResult - returned from csrScanGetResult
2133 \return tCsrScanResultInfo * - NULL if no result
2134 ---------------------------------------------------------------------------*/
2135tCsrScanResultInfo *sme_ScanResultGetFirst(tHalHandle hHal,
2136 tScanResultHandle hScanResult)
2137{
2138 eHalStatus status = eHAL_STATUS_FAILURE;
2139 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2140 tCsrScanResultInfo *pRet = NULL;
2141
2142 status = sme_AcquireGlobalLock( &pMac->sme );
2143 if ( HAL_STATUS_SUCCESS( status ) )
2144 {
2145 pRet = csrScanResultGetFirst( pMac, hScanResult );
2146 sme_ReleaseGlobalLock( &pMac->sme );
2147 }
2148
2149 return (pRet);
2150}
2151
2152
2153/* ---------------------------------------------------------------------------
2154 \fn sme_ScanResultGetNext
2155 \brief a wrapper function to request CSR to returns the next element of
2156 scan result. It can be called without calling csrScanResultGetFirst
2157 first
2158 This is a synchronuous call
2159 \param hScanResult - returned from csrScanGetResult
2160 \return Null if no result or reach the end
2161 ---------------------------------------------------------------------------*/
2162tCsrScanResultInfo *sme_ScanResultGetNext(tHalHandle hHal,
2163 tScanResultHandle hScanResult)
2164{
2165 eHalStatus status = eHAL_STATUS_FAILURE;
2166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2167 tCsrScanResultInfo *pRet = NULL;
2168
2169 status = sme_AcquireGlobalLock( &pMac->sme );
2170 if ( HAL_STATUS_SUCCESS( status ) )
2171 {
2172 pRet = csrScanResultGetNext( pMac, hScanResult );
2173 sme_ReleaseGlobalLock( &pMac->sme );
2174 }
2175
2176 return (pRet);
2177}
2178
2179
2180/* ---------------------------------------------------------------------------
2181 \fn sme_ScanSetBGScanparams
2182 \brief a wrapper function to request CSR to set BG scan params in PE
2183 This is a synchronuous call
2184 \param pScanReq - BG scan request structure
2185 \return eHalStatus
2186 ---------------------------------------------------------------------------*/
2187eHalStatus sme_ScanSetBGScanparams(tHalHandle hHal, tANI_U8 sessionId, tCsrBGScanRequest *pScanReq)
2188{
2189 eHalStatus status = eHAL_STATUS_FAILURE;
2190 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2191
2192 if( NULL != pScanReq )
2193 {
2194 status = sme_AcquireGlobalLock( &pMac->sme );
2195 if ( HAL_STATUS_SUCCESS( status ) )
2196 {
2197 status = csrScanSetBGScanparams( hHal, pScanReq );
2198 sme_ReleaseGlobalLock( &pMac->sme );
2199 }
2200 }
2201
2202 return (status);
2203}
2204
2205
2206/* ---------------------------------------------------------------------------
2207 \fn sme_ScanResultPurge
2208 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
2209 in the list and free memory for each item
2210 This is a synchronuous call
2211 \param hScanResult - returned from csrScanGetResult. hScanResult is
2212 considered gone by
2213 calling this function and even before this function reutrns.
2214 \return eHalStatus
2215 ---------------------------------------------------------------------------*/
2216eHalStatus sme_ScanResultPurge(tHalHandle hHal, tScanResultHandle hScanResult)
2217{
2218 eHalStatus status = eHAL_STATUS_FAILURE;
2219 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2220
2221 status = sme_AcquireGlobalLock( &pMac->sme );
2222 if ( HAL_STATUS_SUCCESS( status ) )
2223 {
2224 status = csrScanResultPurge( hHal, hScanResult );
2225 sme_ReleaseGlobalLock( &pMac->sme );
2226 }
2227
2228 return (status);
2229}
2230
2231/* ---------------------------------------------------------------------------
2232 \fn sme_ScanGetPMKIDCandidateList
2233 \brief a wrapper function to return the PMKID candidate list
2234 This is a synchronuous call
2235 \param pPmkidList - caller allocated buffer point to an array of
2236 tPmkidCandidateInfo
2237 \param pNumItems - pointer to a variable that has the number of
2238 tPmkidCandidateInfo allocated when retruning, this is
2239 either the number needed or number of items put into
2240 pPmkidList
2241 \return eHalStatus - when fail, it usually means the buffer allocated is not
2242 big enough and pNumItems
2243 has the number of tPmkidCandidateInfo.
2244 \Note: pNumItems is a number of tPmkidCandidateInfo,
2245 not sizeof(tPmkidCandidateInfo) * something
2246 ---------------------------------------------------------------------------*/
2247eHalStatus sme_ScanGetPMKIDCandidateList(tHalHandle hHal, tANI_U8 sessionId,
2248 tPmkidCandidateInfo *pPmkidList,
2249 tANI_U32 *pNumItems )
2250{
2251 eHalStatus status = eHAL_STATUS_FAILURE;
2252 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2253
2254 status = sme_AcquireGlobalLock( &pMac->sme );
2255 if ( HAL_STATUS_SUCCESS( status ) )
2256 {
2257 status = csrScanGetPMKIDCandidateList( pMac, sessionId, pPmkidList, pNumItems );
2258 sme_ReleaseGlobalLock( &pMac->sme );
2259 }
2260
2261 return (status);
2262}
2263
2264/*----------------------------------------------------------------------------
2265 \fn sme_RoamRegisterLinkQualityIndCallback
2266
2267 \brief
2268 a wrapper function to allow HDD to register a callback handler with CSR for
2269 link quality indications.
2270
2271 Only one callback may be registered at any time.
2272 In order to deregister the callback, a NULL cback may be provided.
2273
2274 Registration happens in the task context of the caller.
2275
2276 \param callback - Call back being registered
2277 \param pContext - user data
2278
2279 DEPENDENCIES: After CSR open
2280
2281 \return eHalStatus
2282-----------------------------------------------------------------------------*/
2283eHalStatus sme_RoamRegisterLinkQualityIndCallback(tHalHandle hHal, tANI_U8 sessionId,
2284 csrRoamLinkQualityIndCallback callback,
2285 void *pContext)
2286{
2287 return(csrRoamRegisterLinkQualityIndCallback((tpAniSirGlobal)hHal, callback, pContext));
2288}
2289
2290/* ---------------------------------------------------------------------------
2291 \fn sme_RoamRegisterCallback
2292 \brief a wrapper function to allow HDD to register a callback with CSR.
2293 Unlike scan, roam has one callback for all the roam requests
2294 \param callback - a callback function that roam calls upon when state changes
2295 \param pContext - a pointer passed in for the callback
2296 \return eHalStatus
2297 ---------------------------------------------------------------------------*/
2298eHalStatus sme_RoamRegisterCallback(tHalHandle hHal,
2299 csrRoamCompleteCallback callback,
2300 void *pContext)
2301{
2302 return(csrRoamRegisterCallback((tpAniSirGlobal)hHal, callback, pContext));
2303}
2304
2305eCsrPhyMode sme_GetPhyMode(tHalHandle hHal)
2306{
2307 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2308 return pMac->roam.configParam.phyMode;
2309}
2310
2311/* ---------------------------------------------------------------------------
2312 \fn sme_RoamConnect
2313 \brief a wrapper function to request CSR to inititiate an association
2314 This is an asynchronuous call.
2315 \param sessionId - the sessionId returned by sme_OpenSession.
2316 \param pProfile - description of the network to which to connect
2317 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
2318 from csrScanGetResult
2319 \param pRoamId - to get back the request ID
2320 \return eHalStatus
2321 ---------------------------------------------------------------------------*/
2322eHalStatus sme_RoamConnect(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2323 tANI_U32 *pRoamId)
2324{
2325 eHalStatus status = eHAL_STATUS_FAILURE;
2326 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2327
2328 smsLog(pMac, LOG2, FL("enter"));
2329 status = sme_AcquireGlobalLock( &pMac->sme );
2330 if ( HAL_STATUS_SUCCESS( status ) )
2331 {
2332 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2333 {
2334 status = csrRoamConnect( pMac, sessionId, pProfile, NULL, pRoamId );
2335 }
2336 else
2337 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002338 smsLog(pMac, LOGE, FL("invalid sessionID %d"), sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002339 status = eHAL_STATUS_INVALID_PARAMETER;
2340 }
2341 sme_ReleaseGlobalLock( &pMac->sme );
2342 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002343 else
2344 {
2345 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
2346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002347
2348 return (status);
2349}
2350
2351/* ---------------------------------------------------------------------------
2352 \fn sme_RoamReassoc
2353 \brief a wrapper function to request CSR to inititiate a re-association
2354 \param pProfile - can be NULL to join the currently connected AP. In that
2355 case modProfileFields should carry the modified field(s) which could trigger
2356 reassoc
2357 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
2358 that might need modification dynamically once STA is up & running and this
2359 could trigger a reassoc
2360 \param pRoamId - to get back the request ID
2361 \return eHalStatus
2362 -------------------------------------------------------------------------------*/
2363eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2364 tCsrRoamModifyProfileFields modProfileFields,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002365 tANI_U32 *pRoamId, v_BOOL_t fForce)
Jeff Johnson295189b2012-06-20 16:38:30 -07002366{
2367 eHalStatus status = eHAL_STATUS_FAILURE;
2368 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2369
2370 smsLog(pMac, LOG2, FL("enter"));
2371 status = sme_AcquireGlobalLock( &pMac->sme );
2372 if ( HAL_STATUS_SUCCESS( status ) )
2373 {
2374 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2375 {
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07002376 if((NULL == pProfile) && (fForce == 1))
2377 {
2378 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2379 /* to force the AP initiate fresh 802.1x authentication need to clear
2380 * the PMKID cache for that set the following boolean. this is needed
2381 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
2382 pSession->fIgnorePMKIDCache = TRUE;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002383 status = csrReassoc( pMac, sessionId, &modProfileFields, pRoamId , fForce);
2384 }
2385 else
2386 {
2387 status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
2388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 }
2390 else
2391 {
2392 status = eHAL_STATUS_INVALID_PARAMETER;
2393 }
2394 sme_ReleaseGlobalLock( &pMac->sme );
2395 }
2396
2397 return (status);
2398}
2399
2400/* ---------------------------------------------------------------------------
2401 \fn sme_RoamConnectToLastProfile
2402 \brief a wrapper function to request CSR to disconnect and reconnect with
2403 the same profile
2404 This is an asynchronuous call.
2405 \return eHalStatus. It returns fail if currently connected
2406 ---------------------------------------------------------------------------*/
2407eHalStatus sme_RoamConnectToLastProfile(tHalHandle hHal, tANI_U8 sessionId)
2408{
2409 eHalStatus status = eHAL_STATUS_FAILURE;
2410 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2411
2412 status = sme_AcquireGlobalLock( &pMac->sme );
2413 if ( HAL_STATUS_SUCCESS( status ) )
2414 {
2415 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2416 {
2417 status = csrRoamConnectToLastProfile( pMac, sessionId );
2418 }
2419 else
2420 {
2421 status = eHAL_STATUS_INVALID_PARAMETER;
2422 }
2423 sme_ReleaseGlobalLock( &pMac->sme );
2424 }
2425
2426 return (status);
2427}
2428
2429/* ---------------------------------------------------------------------------
2430 \fn sme_RoamDisconnect
2431 \brief a wrapper function to request CSR to disconnect from a network
2432 This is an asynchronuous call.
2433 \param reason -- To indicate the reason for disconnecting. Currently, only
2434 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
2435 \return eHalStatus
2436 ---------------------------------------------------------------------------*/
2437eHalStatus sme_RoamDisconnect(tHalHandle hHal, tANI_U8 sessionId, eCsrRoamDisconnectReason reason)
2438{
2439 eHalStatus status = eHAL_STATUS_FAILURE;
2440 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2441
2442 smsLog(pMac, LOG2, FL("enter"));
2443 status = sme_AcquireGlobalLock( &pMac->sme );
2444 if ( HAL_STATUS_SUCCESS( status ) )
2445 {
2446 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2447 {
2448 status = csrRoamDisconnect( pMac, sessionId, reason );
2449 }
2450 else
2451 {
2452 status = eHAL_STATUS_INVALID_PARAMETER;
2453 }
2454 sme_ReleaseGlobalLock( &pMac->sme );
2455 }
2456
2457 return (status);
2458}
2459
2460#ifdef WLAN_SOFTAP_FEATURE
2461/* ---------------------------------------------------------------------------
2462 \fn sme_RoamStopBss
2463 \brief To stop BSS for Soft AP. This is an asynchronous API.
2464 \param hHal - Global structure
2465 \param sessionId - sessionId of SoftAP
2466 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2467 -------------------------------------------------------------------------------*/
2468eHalStatus sme_RoamStopBss(tHalHandle hHal, tANI_U8 sessionId)
2469{
2470 eHalStatus status = eHAL_STATUS_FAILURE;
2471 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2472
2473 smsLog(pMac, LOG2, FL("enter"));
2474 status = sme_AcquireGlobalLock( &pMac->sme );
2475 if ( HAL_STATUS_SUCCESS( status ) )
2476 {
2477 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2478 {
2479 status = csrRoamIssueStopBssCmd( pMac, sessionId, eANI_BOOLEAN_TRUE );
2480 }
2481 else
2482 {
2483 status = eHAL_STATUS_INVALID_PARAMETER;
2484 }
2485 sme_ReleaseGlobalLock( &pMac->sme );
2486 }
2487
2488 return (status);
2489}
2490
2491/* ---------------------------------------------------------------------------
2492 \fn sme_RoamDisconnectSta
2493 \brief To disassociate a station. This is an asynchronous API.
2494 \param hHal - Global structure
2495 \param sessionId - sessionId of SoftAP
2496 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2497 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2498 -------------------------------------------------------------------------------*/
2499eHalStatus sme_RoamDisconnectSta(tHalHandle hHal, tANI_U8 sessionId,
2500 tANI_U8 *pPeerMacAddr)
2501{
2502 eHalStatus status = eHAL_STATUS_FAILURE;
2503 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2504
2505 if ( NULL == pMac )
2506 {
2507 VOS_ASSERT(0);
2508 return status;
2509 }
2510
2511 status = sme_AcquireGlobalLock( &pMac->sme );
2512 if ( HAL_STATUS_SUCCESS( status ) )
2513 {
2514 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2515 {
2516 status = csrRoamIssueDisassociateStaCmd( pMac, sessionId, pPeerMacAddr,
2517 eSIR_MAC_UNSPEC_FAILURE_REASON);
2518 }
2519 else
2520 {
2521 status = eHAL_STATUS_INVALID_PARAMETER;
2522 }
2523 sme_ReleaseGlobalLock( &pMac->sme );
2524 }
2525
2526 return (status);
2527}
2528
2529/* ---------------------------------------------------------------------------
2530 \fn sme_RoamDeauthSta
2531 \brief To disassociate a station. This is an asynchronous API.
2532 \param hHal - Global structure
2533 \param sessionId - sessionId of SoftAP
2534 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2535 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2536 -------------------------------------------------------------------------------*/
2537eHalStatus sme_RoamDeauthSta(tHalHandle hHal, tANI_U8 sessionId,
2538 tANI_U8 *pPeerMacAddr)
2539{
2540 eHalStatus status = eHAL_STATUS_FAILURE;
2541 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2542
2543 if ( NULL == pMac )
2544 {
2545 VOS_ASSERT(0);
2546 return status;
2547 }
2548
2549 status = sme_AcquireGlobalLock( &pMac->sme );
2550 if ( HAL_STATUS_SUCCESS( status ) )
2551 {
2552 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2553 {
2554 status = csrRoamIssueDeauthStaCmd( pMac, sessionId, pPeerMacAddr,
2555 eSIR_MAC_UNSPEC_FAILURE_REASON);
2556 }
2557 else
2558 {
2559 status = eHAL_STATUS_INVALID_PARAMETER;
2560 }
2561 sme_ReleaseGlobalLock( &pMac->sme );
2562 }
2563
2564 return (status);
2565}
2566
2567/* ---------------------------------------------------------------------------
2568 \fn sme_RoamTKIPCounterMeasures
2569 \brief To start or stop TKIP counter measures. This is an asynchronous API.
2570 \param sessionId - sessionId of SoftAP
2571 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2572 \return eHalStatus
2573 -------------------------------------------------------------------------------*/
2574eHalStatus sme_RoamTKIPCounterMeasures(tHalHandle hHal, tANI_U8 sessionId,
2575 tANI_BOOLEAN bEnable)
2576{
2577 eHalStatus status = eHAL_STATUS_FAILURE;
2578 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2579
2580 if ( NULL == pMac )
2581 {
2582 VOS_ASSERT(0);
2583 return status;
2584 }
2585
2586 status = sme_AcquireGlobalLock( &pMac->sme );
2587 if ( HAL_STATUS_SUCCESS( status ) )
2588 {
2589 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2590 {
2591 status = csrRoamIssueTkipCounterMeasures( pMac, sessionId, bEnable);
2592 }
2593 else
2594 {
2595 status = eHAL_STATUS_INVALID_PARAMETER;
2596 }
2597 sme_ReleaseGlobalLock( &pMac->sme );
2598 }
2599
2600 return (status);
2601}
2602
2603/* ---------------------------------------------------------------------------
2604 \fn sme_RoamGetAssociatedStas
2605 \brief To probe the list of associated stations from various modules of CORE stack.
2606 \This is an asynchronous API.
2607 \param sessionId - sessionId of SoftAP
2608 \param modId - Module from whom list of associtated stations is to be probed.
2609 If an invalid module is passed then by default VOS_MODULE_ID_PE will be probed
2610 \param pUsrContext - Opaque HDD context
2611 \param pfnSapEventCallback - Sap event callback in HDD
2612 \param pAssocBuf - Caller allocated memory to be filled with associatd stations info
2613 \return eHalStatus
2614 -------------------------------------------------------------------------------*/
2615eHalStatus sme_RoamGetAssociatedStas(tHalHandle hHal, tANI_U8 sessionId,
2616 VOS_MODULE_ID modId, void *pUsrContext,
2617 void *pfnSapEventCallback, tANI_U8 *pAssocStasBuf)
2618{
2619 eHalStatus status = eHAL_STATUS_FAILURE;
2620 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2621
2622 if ( NULL == pMac )
2623 {
2624 VOS_ASSERT(0);
2625 return status;
2626 }
2627
2628 status = sme_AcquireGlobalLock( &pMac->sme );
2629 if ( HAL_STATUS_SUCCESS( status ) )
2630 {
2631 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2632 {
2633 status = csrRoamGetAssociatedStas( pMac, sessionId, modId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2634 }
2635 else
2636 {
2637 status = eHAL_STATUS_INVALID_PARAMETER;
2638 }
2639 sme_ReleaseGlobalLock( &pMac->sme );
2640 }
2641
2642 return (status);
2643}
2644
2645/* ---------------------------------------------------------------------------
2646 \fn sme_RoamGetWpsSessionOverlap
2647 \brief To get the WPS PBC session overlap information.
2648 \This is an asynchronous API.
2649 \param sessionId - sessionId of SoftAP
2650 \param pUsrContext - Opaque HDD context
2651 \param pfnSapEventCallback - Sap event callback in HDD
2652 \pRemoveMac - pointer to Mac address which needs to be removed from session
2653 \return eHalStatus
2654 -------------------------------------------------------------------------------*/
2655eHalStatus sme_RoamGetWpsSessionOverlap(tHalHandle hHal, tANI_U8 sessionId,
2656 void *pUsrContext, void
2657 *pfnSapEventCallback, v_MACADDR_t pRemoveMac)
2658{
2659 eHalStatus status = eHAL_STATUS_FAILURE;
2660 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2661
2662 if ( NULL == pMac )
2663 {
2664 VOS_ASSERT(0);
2665 return status;
2666 }
2667
2668 status = sme_AcquireGlobalLock( &pMac->sme );
2669 if ( HAL_STATUS_SUCCESS( status ) )
2670 {
2671 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2672 {
2673 status = csrRoamGetWpsSessionOverlap( pMac, sessionId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2674 }
2675 else
2676 {
2677 status = eHAL_STATUS_INVALID_PARAMETER;
2678 }
2679 sme_ReleaseGlobalLock( &pMac->sme );
2680 }
2681
2682 return (status);
2683}
2684
2685#endif
2686
2687/* ---------------------------------------------------------------------------
2688 \fn sme_RoamGetConnectState
2689 \brief a wrapper function to request CSR to return the current connect state
2690 of Roaming
2691 This is a synchronuous call.
2692 \return eHalStatus
2693 ---------------------------------------------------------------------------*/
2694eHalStatus sme_RoamGetConnectState(tHalHandle hHal, tANI_U8 sessionId, eCsrConnectState *pState)
2695{
2696 eHalStatus status = eHAL_STATUS_FAILURE;
2697 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2698
2699 status = sme_AcquireGlobalLock( &pMac->sme );
2700 if ( HAL_STATUS_SUCCESS( status ) )
2701 {
2702 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2703 {
2704 status = csrRoamGetConnectState( pMac, sessionId, pState );
2705 }
2706 else
2707 {
2708 status = eHAL_STATUS_INVALID_PARAMETER;
2709 }
2710 sme_ReleaseGlobalLock( &pMac->sme );
2711 }
2712
2713 return (status);
2714}
2715
2716/* ---------------------------------------------------------------------------
2717 \fn sme_RoamGetConnectProfile
2718 \brief a wrapper function to request CSR to return the current connect
2719 profile. Caller must call csrRoamFreeConnectProfile after it is done
2720 and before reuse for another csrRoamGetConnectProfile call.
2721 This is a synchronuous call.
2722 \param pProfile - pointer to a caller allocated structure
2723 tCsrRoamConnectedProfile
2724 \return eHalStatus. Failure if not connected
2725 ---------------------------------------------------------------------------*/
2726eHalStatus sme_RoamGetConnectProfile(tHalHandle hHal, tANI_U8 sessionId,
2727 tCsrRoamConnectedProfile *pProfile)
2728{
2729 eHalStatus status = eHAL_STATUS_FAILURE;
2730 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2731
2732 status = sme_AcquireGlobalLock( &pMac->sme );
2733 if ( HAL_STATUS_SUCCESS( status ) )
2734 {
2735 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2736 {
2737 status = csrRoamGetConnectProfile( pMac, sessionId, pProfile );
2738 }
2739 else
2740 {
2741 status = eHAL_STATUS_INVALID_PARAMETER;
2742 }
2743 sme_ReleaseGlobalLock( &pMac->sme );
2744 }
2745
2746 return (status);
2747}
2748
2749/* ---------------------------------------------------------------------------
2750 \fn sme_RoamFreeConnectProfile
2751 \brief a wrapper function to request CSR to free and reinitialize the
2752 profile returned previously by csrRoamGetConnectProfile.
2753 This is a synchronuous call.
2754 \param pProfile - pointer to a caller allocated structure
2755 tCsrRoamConnectedProfile
2756 \return eHalStatus.
2757 ---------------------------------------------------------------------------*/
2758eHalStatus sme_RoamFreeConnectProfile(tHalHandle hHal,
2759 tCsrRoamConnectedProfile *pProfile)
2760{
2761 eHalStatus status = eHAL_STATUS_FAILURE;
2762 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2763
2764 status = sme_AcquireGlobalLock( &pMac->sme );
2765 if ( HAL_STATUS_SUCCESS( status ) )
2766 {
2767 status = csrRoamFreeConnectProfile( pMac, pProfile );
2768 sme_ReleaseGlobalLock( &pMac->sme );
2769 }
2770
2771 return (status);
2772}
2773
2774/* ---------------------------------------------------------------------------
2775 \fn sme_RoamSetPMKIDCache
2776 \brief a wrapper function to request CSR to return the PMKID candidate list
2777 This is a synchronuous call.
2778 \param pPMKIDCache - caller allocated buffer point to an array of
2779 tPmkidCacheInfo
2780 \param numItems - a variable that has the number of tPmkidCacheInfo
2781 allocated when retruning, this is either the number needed
2782 or number of items put into pPMKIDCache
2783 \return eHalStatus - when fail, it usually means the buffer allocated is not
2784 big enough and pNumItems has the number of
2785 tPmkidCacheInfo.
2786 \Note: pNumItems is a number of tPmkidCacheInfo,
2787 not sizeof(tPmkidCacheInfo) * something
2788 ---------------------------------------------------------------------------*/
2789eHalStatus sme_RoamSetPMKIDCache( tHalHandle hHal, tANI_U8 sessionId, tPmkidCacheInfo *pPMKIDCache,
2790 tANI_U32 numItems )
2791{
2792 eHalStatus status = eHAL_STATUS_FAILURE;
2793 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2794
2795 status = sme_AcquireGlobalLock( &pMac->sme );
2796 if ( HAL_STATUS_SUCCESS( status ) )
2797 {
2798 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2799 {
2800 status = csrRoamSetPMKIDCache( pMac, sessionId, pPMKIDCache, numItems );
2801 }
2802 else
2803 {
2804 status = eHAL_STATUS_INVALID_PARAMETER;
2805 }
2806 sme_ReleaseGlobalLock( &pMac->sme );
2807 }
2808
2809 return (status);
2810}
2811
2812/* ---------------------------------------------------------------------------
2813 \fn sme_RoamGetSecurityReqIE
2814 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
2815 passes to PE to JOIN request or START_BSS request
2816 This is a synchronuous call.
2817 \param pLen - caller allocated memory that has the length of pBuf as input.
2818 Upon returned, *pLen has the needed or IE length in pBuf.
2819 \param pBuf - Caller allocated memory that contain the IE field, if any,
2820 upon return
2821 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
2822 \return eHalStatus - when fail, it usually means the buffer allocated is not
2823 big enough
2824 ---------------------------------------------------------------------------*/
2825eHalStatus sme_RoamGetSecurityReqIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
2826 tANI_U8 *pBuf, eCsrSecurityType secType)
2827{
2828 eHalStatus status = eHAL_STATUS_FAILURE;
2829 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2830
2831 status = sme_AcquireGlobalLock( &pMac->sme );
2832 if ( HAL_STATUS_SUCCESS( status ) )
2833 {
2834 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2835 {
2836 status = csrRoamGetWpaRsnReqIE( hHal, sessionId, pLen, pBuf );
2837 }
2838 else
2839 {
2840 status = eHAL_STATUS_INVALID_PARAMETER;
2841 }
2842 sme_ReleaseGlobalLock( &pMac->sme );
2843 }
2844
2845 return (status);
2846}
2847
2848/* ---------------------------------------------------------------------------
2849 \fn sme_RoamGetSecurityRspIE
2850 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE from
2851 the beacon or probe rsp if connected
2852 This is a synchronuous call.
2853 \param pLen - caller allocated memory that has the length of pBuf as input.
2854 Upon returned, *pLen has the needed or IE length in pBuf.
2855 \param pBuf - Caller allocated memory that contain the IE field, if any,
2856 upon return
2857 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
2858 \return eHalStatus - when fail, it usually means the buffer allocated is not
2859 big enough
2860 ---------------------------------------------------------------------------*/
2861eHalStatus sme_RoamGetSecurityRspIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
2862 tANI_U8 *pBuf, eCsrSecurityType secType)
2863{
2864 eHalStatus status = eHAL_STATUS_FAILURE;
2865 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2866
2867 status = sme_AcquireGlobalLock( &pMac->sme );
2868 if ( HAL_STATUS_SUCCESS( status ) )
2869 {
2870 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2871 {
2872 status = csrRoamGetWpaRsnRspIE( pMac, sessionId, pLen, pBuf );
2873 }
2874 else
2875 {
2876 status = eHAL_STATUS_INVALID_PARAMETER;
2877 }
2878 sme_ReleaseGlobalLock( &pMac->sme );
2879 }
2880
2881 return (status);
2882
2883}
2884
2885
2886/* ---------------------------------------------------------------------------
2887 \fn sme_RoamGetNumPMKIDCache
2888 \brief a wrapper function to request CSR to return number of PMKID cache
2889 entries
2890 This is a synchronuous call.
2891 \return tANI_U32 - the number of PMKID cache entries
2892 ---------------------------------------------------------------------------*/
2893tANI_U32 sme_RoamGetNumPMKIDCache(tHalHandle hHal, tANI_U8 sessionId)
2894{
2895 eHalStatus status = eHAL_STATUS_FAILURE;
2896 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2897 tANI_U32 numPmkidCache = 0;
2898
2899 status = sme_AcquireGlobalLock( &pMac->sme );
2900 if ( HAL_STATUS_SUCCESS( status ) )
2901 {
2902 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2903 {
2904 numPmkidCache = csrRoamGetNumPMKIDCache( pMac, sessionId );
2905 status = eHAL_STATUS_SUCCESS;
2906 }
2907 else
2908 {
2909 status = eHAL_STATUS_INVALID_PARAMETER;
2910 }
2911 sme_ReleaseGlobalLock( &pMac->sme );
2912 }
2913
2914 return (numPmkidCache);
2915}
2916
2917/* ---------------------------------------------------------------------------
2918 \fn sme_RoamGetPMKIDCache
2919 \brief a wrapper function to request CSR to return PMKID cache from CSR
2920 This is a synchronuous call.
2921 \param pNum - caller allocated memory that has the space of the number of
2922 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
2923 needed or actually number in tPmkidCacheInfo.
2924 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
2925 any, upon return
2926 \return eHalStatus - when fail, it usually means the buffer allocated is not
2927 big enough
2928 ---------------------------------------------------------------------------*/
2929eHalStatus sme_RoamGetPMKIDCache(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pNum,
2930 tPmkidCacheInfo *pPmkidCache)
2931{
2932 eHalStatus status = eHAL_STATUS_FAILURE;
2933 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2934
2935 status = sme_AcquireGlobalLock( &pMac->sme );
2936 if ( HAL_STATUS_SUCCESS( status ) )
2937 {
2938 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2939 {
2940 status = csrRoamGetPMKIDCache( pMac, sessionId, pNum, pPmkidCache );
2941 }
2942 else
2943 {
2944 status = eHAL_STATUS_INVALID_PARAMETER;
2945 }
2946 sme_ReleaseGlobalLock( &pMac->sme );
2947 }
2948
2949 return (status);
2950}
2951
2952
2953/* ---------------------------------------------------------------------------
2954 \fn sme_GetConfigParam
2955 \brief a wrapper function that HDD calls to get the global settings
2956 currently maintained by CSR.
2957 This is a synchronuous call.
2958 \param pParam - caller allocated memory
2959 \return eHalStatus
2960 ---------------------------------------------------------------------------*/
2961eHalStatus sme_GetConfigParam(tHalHandle hHal, tSmeConfigParams *pParam)
2962{
2963 eHalStatus status = eHAL_STATUS_FAILURE;
2964 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2965
2966 status = sme_AcquireGlobalLock( &pMac->sme );
2967 if ( HAL_STATUS_SUCCESS( status ) )
2968 {
2969 status = csrGetConfigParam(pMac, &pParam->csrConfig);
2970 if (status != eHAL_STATUS_SUCCESS)
2971 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002972 smsLog( pMac, LOGE, "%s csrGetConfigParam failed\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 sme_ReleaseGlobalLock( &pMac->sme );
2974 return status;
2975 }
2976#if defined WLAN_FEATURE_P2P_INTERNAL
2977 status = p2pGetConfigParam(pMac, &pParam->p2pConfig);
2978 if (status != eHAL_STATUS_SUCCESS)
2979 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002980 smsLog( pMac, LOGE, "%s p2pGetConfigParam failed\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 sme_ReleaseGlobalLock( &pMac->sme );
2982 return status;
2983 }
2984#endif
2985 sme_ReleaseGlobalLock( &pMac->sme );
2986 }
2987
2988 return (status);
2989}
2990
2991/* ---------------------------------------------------------------------------
2992 \fn sme_CfgSetInt
2993 \brief a wrapper function that HDD calls to set parameters in CFG.
2994 This is a synchronuous call.
2995 \param cfgId - Configuration Parameter ID (type) for STA.
2996 \param ccmValue - The information related to Configuration Parameter ID
2997 which needs to be saved in CFG
2998 \param callback - To be registered by CSR with CCM. Once the CFG done with
2999 saving the information in the database, it notifies CCM &
3000 then the callback will be invoked to notify.
3001 \param toBeSaved - To save the request for future reference
3002 \return eHalStatus
3003 ---------------------------------------------------------------------------*/
3004eHalStatus sme_CfgSetInt(tHalHandle hHal, tANI_U32 cfgId, tANI_U32 ccmValue,
3005 tCcmCfgSetCallback callback, eAniBoolean toBeSaved)
3006{
3007 return(ccmCfgSetInt(hHal, cfgId, ccmValue, callback, toBeSaved));
3008}
3009
3010/* ---------------------------------------------------------------------------
3011 \fn sme_CfgSetStr
3012 \brief a wrapper function that HDD calls to set parameters in CFG.
3013 This is a synchronuous call.
3014 \param cfgId - Configuration Parameter ID (type) for STA.
3015 \param pStr - Pointer to the byte array which carries the information needs
3016 to be saved in CFG
3017 \param length - Length of the data to be saved
3018 \param callback - To be registered by CSR with CCM. Once the CFG done with
3019 saving the information in the database, it notifies CCM &
3020 then the callback will be invoked to notify.
3021 \param toBeSaved - To save the request for future reference
3022 \return eHalStatus
3023 ---------------------------------------------------------------------------*/
3024eHalStatus sme_CfgSetStr(tHalHandle hHal, tANI_U32 cfgId, tANI_U8 *pStr,
3025 tANI_U32 length, tCcmCfgSetCallback callback,
3026 eAniBoolean toBeSaved)
3027{
3028 return(ccmCfgSetStr(hHal, cfgId, pStr, length, callback, toBeSaved));
3029}
3030
3031/* ---------------------------------------------------------------------------
3032 \fn sme_GetModifyProfileFields
3033 \brief HDD or SME - QOS calls this function to get the current values of
3034 connected profile fields, changing which can cause reassoc.
3035 This function must be called after CFG is downloaded and STA is in connected
3036 state. Also, make sure to call this function to get the current profile
3037 fields before calling the reassoc. So that pModifyProfileFields will have
3038 all the latest values plus the one(s) has been updated as part of reassoc
3039 request.
3040 \param pModifyProfileFields - pointer to the connected profile fields
3041 changing which can cause reassoc
3042
3043 \return eHalStatus
3044 -------------------------------------------------------------------------------*/
3045eHalStatus sme_GetModifyProfileFields(tHalHandle hHal, tANI_U8 sessionId,
3046 tCsrRoamModifyProfileFields * pModifyProfileFields)
3047{
3048 eHalStatus status = eHAL_STATUS_FAILURE;
3049 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3050
3051 status = sme_AcquireGlobalLock( &pMac->sme );
3052 if ( HAL_STATUS_SUCCESS( status ) )
3053 {
3054 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3055 {
3056 status = csrGetModifyProfileFields(pMac, sessionId, pModifyProfileFields);
3057 }
3058 else
3059 {
3060 status = eHAL_STATUS_INVALID_PARAMETER;
3061 }
3062 sme_ReleaseGlobalLock( &pMac->sme );
3063 }
3064
3065 return (status);
3066}
3067
3068/*--------------------------------------------------------------------------
3069 \fn sme_SetConfigPowerSave
3070 \brief Wrapper fn to change power save configuration in SME (PMC) module.
3071 For BMPS related configuration, this function also updates the CFG
3072 and sends a message to FW to pick up the new values. Note: Calling
3073 this function only updates the configuration and does not enable
3074 the specified power save mode.
3075 \param hHal - The handle returned by macOpen.
3076 \param psMode - Power Saving mode being modified
3077 \param pConfigParams - a pointer to a caller allocated object of type
3078 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
3079 \return eHalStatus
3080 --------------------------------------------------------------------------*/
3081eHalStatus sme_SetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
3082 void *pConfigParams)
3083{
3084 eHalStatus status = eHAL_STATUS_FAILURE;
3085 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3086
3087 if (NULL == pConfigParams ) {
3088 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3089 "nothing to update");
3090 return eHAL_STATUS_FAILURE;
3091 }
3092
3093 status = sme_AcquireGlobalLock( &pMac->sme );
3094 if ( HAL_STATUS_SUCCESS( status ) )
3095 {
3096 status = pmcSetConfigPowerSave(hHal, psMode, pConfigParams);
3097 sme_ReleaseGlobalLock( &pMac->sme );
3098 }
3099
3100 return (status);
3101}
3102
3103/*--------------------------------------------------------------------------
3104 \fn sme_GetConfigPowerSave
3105 \brief Wrapper fn to retrieve power save configuration in SME (PMC) module
3106 \param hHal - The handle returned by macOpen.
3107 \param psMode - Power Saving mode
3108 \param pConfigParams - a pointer to a caller allocated object of type
3109 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
3110 \return eHalStatus
3111 --------------------------------------------------------------------------*/
3112eHalStatus sme_GetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
3113 void *pConfigParams)
3114{
3115 eHalStatus status = eHAL_STATUS_FAILURE;
3116 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3117
3118 if (NULL == pConfigParams ) {
3119 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3120 "nothing to update");
3121 return eHAL_STATUS_FAILURE;
3122 }
3123
3124 status = sme_AcquireGlobalLock( &pMac->sme );
3125 if ( HAL_STATUS_SUCCESS( status ) )
3126 {
3127 status = pmcGetConfigPowerSave(hHal, psMode, pConfigParams);
3128 sme_ReleaseGlobalLock( &pMac->sme );
3129 }
3130
3131 return (status);
3132}
3133
3134/* ---------------------------------------------------------------------------
3135 \fn sme_SignalPowerEvent
3136 \brief Signals to PMC that a power event has occurred. Used for putting
3137 the chip into deep sleep mode.
3138 \param hHal - The handle returned by macOpen.
3139 \param event - the event that has occurred
3140 \return eHalStatus
3141 ---------------------------------------------------------------------------*/
3142eHalStatus sme_SignalPowerEvent (tHalHandle hHal, tPmcPowerEvent event)
3143{
3144 eHalStatus status = eHAL_STATUS_FAILURE;
3145 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3146
3147 status = sme_AcquireGlobalLock( &pMac->sme );
3148 if ( HAL_STATUS_SUCCESS( status ) )
3149 {
3150 status = pmcSignalPowerEvent(hHal, event);
3151 sme_ReleaseGlobalLock( &pMac->sme );
3152 }
3153
3154 return (status);
3155}
3156
3157/* ---------------------------------------------------------------------------
3158 \fn sme_EnablePowerSave
3159 \brief Enables one of the power saving modes.
3160 \param hHal - The handle returned by macOpen.
3161 \param psMode - The power saving mode to enable. If BMPS mode is enabled
3162 while the chip is operating in Full Power, PMC will start
3163 a timer that will try to put the chip in BMPS mode after
3164 expiry.
3165 \return eHalStatus
3166 ---------------------------------------------------------------------------*/
3167eHalStatus sme_EnablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3168{
3169 eHalStatus status = eHAL_STATUS_FAILURE;
3170 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3171
3172 status = sme_AcquireGlobalLock( &pMac->sme );
3173 if ( HAL_STATUS_SUCCESS( status ) )
3174 {
3175 status = pmcEnablePowerSave(hHal, psMode);
3176 sme_ReleaseGlobalLock( &pMac->sme );
3177 }
3178
3179 return (status);
3180}
3181
3182/* ---------------------------------------------------------------------------
3183 \fn sme_DisablePowerSave
3184 \brief Disables one of the power saving modes.
3185 \param hHal - The handle returned by macOpen.
3186 \param psMode - The power saving mode to disable. Disabling does not imply
3187 that device will be brought out of the current PS mode. This
3188 is purely a configuration API.
3189 \return eHalStatus
3190 ---------------------------------------------------------------------------*/
3191eHalStatus sme_DisablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3192{
3193 eHalStatus status = eHAL_STATUS_FAILURE;
3194 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3195
3196 status = sme_AcquireGlobalLock( &pMac->sme );
3197 if ( HAL_STATUS_SUCCESS( status ) )
3198 {
3199 status = pmcDisablePowerSave(hHal, psMode);
3200 sme_ReleaseGlobalLock( &pMac->sme );
3201 }
3202
3203 return (status);
3204 }
3205
3206/* ---------------------------------------------------------------------------
3207 \fn sme_StartAutoBmpsTimer
3208 \brief Starts a timer that periodically polls all the registered
3209 module for entry into Bmps mode. This timer is started only if BMPS is
3210 enabled and whenever the device is in full power.
3211 \param hHal - The handle returned by macOpen.
3212 \return eHalStatus
3213 ---------------------------------------------------------------------------*/
3214eHalStatus sme_StartAutoBmpsTimer ( tHalHandle hHal)
3215{
3216 eHalStatus status = eHAL_STATUS_FAILURE;
3217 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3218
3219 status = sme_AcquireGlobalLock( &pMac->sme );
3220 if ( HAL_STATUS_SUCCESS( status ) )
3221 {
3222 status = pmcStartAutoBmpsTimer(hHal);
3223 sme_ReleaseGlobalLock( &pMac->sme );
3224 }
3225
3226 return (status);
3227}
3228/* ---------------------------------------------------------------------------
3229 \fn sme_StopAutoBmpsTimer
3230 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
3231 Stopping the timer does not cause a device state change. Only the timer
3232 is stopped. If "Full Power" is desired, use the sme_RequestFullPower API
3233 \param hHal - The handle returned by macOpen.
3234 \return eHalStatus
3235 ---------------------------------------------------------------------------*/
3236eHalStatus sme_StopAutoBmpsTimer ( 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 = pmcStopAutoBmpsTimer(hHal);
3245 sme_ReleaseGlobalLock( &pMac->sme );
3246 }
3247
3248 return (status);
3249}
3250/* ---------------------------------------------------------------------------
3251 \fn sme_QueryPowerState
3252 \brief Returns the current power state of the device.
3253 \param hHal - The handle returned by macOpen.
3254 \param pPowerState - pointer to location to return power state (LOW or HIGH)
3255 \param pSwWlanSwitchState - ptr to location to return SW WLAN Switch state
3256 \return eHalStatus
3257 ---------------------------------------------------------------------------*/
3258eHalStatus sme_QueryPowerState (
3259 tHalHandle hHal,
3260 tPmcPowerState *pPowerState,
3261 tPmcSwitchState *pSwWlanSwitchState)
3262{
3263 eHalStatus status = eHAL_STATUS_FAILURE;
3264 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3265
3266 status = sme_AcquireGlobalLock( &pMac->sme );
3267 if ( HAL_STATUS_SUCCESS( status ) )
3268 {
3269 status = pmcQueryPowerState (hHal, pPowerState, NULL, pSwWlanSwitchState);
3270 sme_ReleaseGlobalLock( &pMac->sme );
3271 }
3272
3273 return (status);
3274}
3275
3276/* ---------------------------------------------------------------------------
3277 \fn sme_IsPowerSaveEnabled
3278 \brief Checks if the device is able to enter a particular power save mode
3279 This does not imply that the device is in a particular PS mode
3280 \param hHal - The handle returned by macOpen.
3281 \param psMode - the power saving mode
3282 \return eHalStatus
3283 ---------------------------------------------------------------------------*/
3284tANI_BOOLEAN sme_IsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
3285{
3286 eHalStatus status = eHAL_STATUS_FAILURE;
3287 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3288 tANI_BOOLEAN result = false;
3289
3290 status = sme_AcquireGlobalLock( &pMac->sme );
3291 if ( HAL_STATUS_SUCCESS( status ) )
3292 {
3293 result = pmcIsPowerSaveEnabled(hHal, psMode);
3294 sme_ReleaseGlobalLock( &pMac->sme );
3295 return result;
3296 }
3297
3298 return false;
3299}
3300
3301/* ---------------------------------------------------------------------------
3302 \fn sme_RequestFullPower
3303 \brief Request that the device be brought to full power state. When the
3304 device enters Full Power PMC will start a BMPS timer if BMPS PS mode
3305 is enabled. On timer expiry PMC will attempt to put the device in
3306 BMPS mode if following holds true:
3307 - BMPS mode is enabled
3308 - Polling of all modules through the Power Save Check routine passes
3309 - STA is associated to an access point
3310 \param hHal - The handle returned by macOpen.
3311 \param - callbackRoutine Callback routine invoked in case of success/failure
3312 \return eHalStatus - status
3313 eHAL_STATUS_SUCCESS - device brought to full power state
3314 eHAL_STATUS_FAILURE - device cannot be brought to full power state
3315 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
3316 ---------------------------------------------------------------------------*/
3317eHalStatus sme_RequestFullPower (
3318 tHalHandle hHal,
3319 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3320 void *callbackContext,
3321 tRequestFullPowerReason fullPowerReason)
3322{
3323 eHalStatus status = eHAL_STATUS_FAILURE;
3324 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3325
3326 status = sme_AcquireGlobalLock( &pMac->sme );
3327 if ( HAL_STATUS_SUCCESS( status ) )
3328 {
3329 status = pmcRequestFullPower(hHal, callbackRoutine, callbackContext, fullPowerReason);
3330 sme_ReleaseGlobalLock( &pMac->sme );
3331 }
3332
3333 return (status);
3334}
3335
3336/* ---------------------------------------------------------------------------
3337 \fn sme_RequestBmps
3338 \brief Request that the device be put in BMPS state. Request will be
3339 accepted only if BMPS mode is enabled and power save check routine
3340 passes.
3341 \param hHal - The handle returned by macOpen.
3342 \param - callbackRoutine Callback routine invoked in case of success/failure
3343 \return eHalStatus
3344 eHAL_STATUS_SUCCESS - device is in BMPS state
3345 eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
3346 eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state
3347 ---------------------------------------------------------------------------*/
3348eHalStatus sme_RequestBmps (
3349 tHalHandle hHal,
3350 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3351 void *callbackContext)
3352{
3353 eHalStatus status = eHAL_STATUS_FAILURE;
3354 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3355
3356 status = sme_AcquireGlobalLock( &pMac->sme );
3357 if ( HAL_STATUS_SUCCESS( status ) )
3358 {
3359 status = pmcRequestBmps(hHal, callbackRoutine, callbackContext);
3360 sme_ReleaseGlobalLock( &pMac->sme );
3361 }
3362
3363 return (status);
3364}
3365
3366
3367/* ---------------------------------------------------------------------------
3368 \fn sme_SetDHCPTillPowerActiveFlag
3369 \brief Sets/Clears DHCP related flag in PMC to disable/enable auto BMPS
3370 entry by PMC
3371 \param hHal - The handle returned by macOpen.
3372 ---------------------------------------------------------------------------*/
3373void sme_SetDHCPTillPowerActiveFlag(tHalHandle hHal, tANI_U8 flag)
3374{
3375 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3376
3377 // Set/Clear the DHCP flag which will disable/enable auto BMPS entery by PMC
3378 pMac->pmc.remainInPowerActiveTillDHCP = flag;
3379}
3380
3381
3382/* ---------------------------------------------------------------------------
3383 \fn sme_StartUapsd
3384 \brief Request that the device be put in UAPSD state. If the device is in
3385 Full Power it will be put in BMPS mode first and then into UAPSD
3386 mode.
3387 \param hHal - The handle returned by macOpen.
3388 \param - callbackRoutine Callback routine invoked in case of success/failure
3389 eHAL_STATUS_SUCCESS - device is in UAPSD state
3390 eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
3391 eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
3392 eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
3393 \return eHalStatus
3394 ---------------------------------------------------------------------------*/
3395eHalStatus sme_StartUapsd (
3396 tHalHandle hHal,
3397 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3398 void *callbackContext)
3399{
3400 eHalStatus status = eHAL_STATUS_FAILURE;
3401 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3402
3403 status = sme_AcquireGlobalLock( &pMac->sme );
3404 if ( HAL_STATUS_SUCCESS( status ) )
3405 {
3406 status = pmcStartUapsd(hHal, callbackRoutine, callbackContext);
3407 sme_ReleaseGlobalLock( &pMac->sme );
3408 }
3409
3410 return (status);
3411 }
3412
3413/* ---------------------------------------------------------------------------
3414 \fn sme_StopUapsd
3415 \brief Request that the device be put out of UAPSD state. Device will be
3416 put in in BMPS state after stop UAPSD completes.
3417 \param hHal - The handle returned by macOpen.
3418 \return eHalStatus
3419 eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
3420 eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
3421 ---------------------------------------------------------------------------*/
3422eHalStatus sme_StopUapsd (tHalHandle hHal)
3423{
3424 eHalStatus status = eHAL_STATUS_FAILURE;
3425 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3426
3427 status = sme_AcquireGlobalLock( &pMac->sme );
3428 if ( HAL_STATUS_SUCCESS( status ) )
3429 {
3430 status = pmcStopUapsd(hHal);
3431 sme_ReleaseGlobalLock( &pMac->sme );
3432 }
3433
3434 return (status);
3435}
3436
3437/* ---------------------------------------------------------------------------
3438 \fn sme_RequestStandby
3439 \brief Request that the device be put in standby. It is HDD's responsibility
3440 to bring the chip to full power and do a disassoc before calling
3441 this API.
3442 \param hHal - The handle returned by macOpen.
3443 \param - callbackRoutine Callback routine invoked in case of success/failure
3444 \return eHalStatus
3445 eHAL_STATUS_SUCCESS - device is in Standby mode
3446 eHAL_STATUS_FAILURE - device cannot be put in standby mode
3447 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
3448 ---------------------------------------------------------------------------*/
3449eHalStatus sme_RequestStandby (
3450 tHalHandle hHal,
3451 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3452 void *callbackContext)
3453{
3454 eHalStatus status = eHAL_STATUS_FAILURE;
3455 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3456
3457 smsLog( pMac, LOG1, FL("") );
3458 status = sme_AcquireGlobalLock( &pMac->sme );
3459 if ( HAL_STATUS_SUCCESS( status ) )
3460 {
3461 status = pmcRequestStandby(hHal, callbackRoutine, callbackContext);
3462 sme_ReleaseGlobalLock( &pMac->sme );
3463 }
3464
3465 return (status);
3466}
3467
3468/* ---------------------------------------------------------------------------
3469 \fn sme_RegisterPowerSaveCheck
3470 \brief Register a power save check routine that is called whenever
3471 the device is about to enter one of the power save modes.
3472 \param hHal - The handle returned by macOpen.
3473 \param checkRoutine - Power save check routine to be registered
3474 \return eHalStatus
3475 eHAL_STATUS_SUCCESS - successfully registered
3476 eHAL_STATUS_FAILURE - not successfully registered
3477 ---------------------------------------------------------------------------*/
3478eHalStatus sme_RegisterPowerSaveCheck (
3479 tHalHandle hHal,
3480 tANI_BOOLEAN (*checkRoutine) (void *checkContext), void *checkContext)
3481{
3482 eHalStatus status = eHAL_STATUS_FAILURE;
3483 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3484
3485 status = sme_AcquireGlobalLock( &pMac->sme );
3486 if ( HAL_STATUS_SUCCESS( status ) )
3487 {
3488 status = pmcRegisterPowerSaveCheck (hHal, checkRoutine, checkContext);
3489 sme_ReleaseGlobalLock( &pMac->sme );
3490 }
3491
3492 return (status);
3493}
3494
3495/* ---------------------------------------------------------------------------
3496 \fn sme_DeregisterPowerSaveCheck
3497 \brief Deregister a power save check routine
3498 \param hHal - The handle returned by macOpen.
3499 \param checkRoutine - Power save check routine to be deregistered
3500 \return eHalStatus
3501 eHAL_STATUS_SUCCESS - successfully deregistered
3502 eHAL_STATUS_FAILURE - not successfully deregistered
3503 ---------------------------------------------------------------------------*/
3504eHalStatus sme_DeregisterPowerSaveCheck (
3505 tHalHandle hHal,
3506 tANI_BOOLEAN (*checkRoutine) (void *checkContext))
3507{
3508 eHalStatus status = eHAL_STATUS_FAILURE;
3509 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3510
3511 status = sme_AcquireGlobalLock( &pMac->sme );
3512 if ( HAL_STATUS_SUCCESS( status ) )
3513 {
3514 status = pmcDeregisterPowerSaveCheck (hHal, checkRoutine);
3515 sme_ReleaseGlobalLock( &pMac->sme );
3516 }
3517
3518 return (status);
3519}
3520
3521/* ---------------------------------------------------------------------------
3522 \fn sme_RegisterDeviceStateUpdateInd
3523 \brief Register a callback routine that is called whenever
3524 the device enters a new device state (Full Power, BMPS, UAPSD)
3525 \param hHal - The handle returned by macOpen.
3526 \param callbackRoutine - Callback routine to be registered
3527 \param callbackContext - Cookie to be passed back during callback
3528 \return eHalStatus
3529 eHAL_STATUS_SUCCESS - successfully registered
3530 eHAL_STATUS_FAILURE - not successfully registered
3531 ---------------------------------------------------------------------------*/
3532eHalStatus sme_RegisterDeviceStateUpdateInd (
3533 tHalHandle hHal,
3534 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
3535 void *callbackContext)
3536{
3537 eHalStatus status = eHAL_STATUS_FAILURE;
3538 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3539
3540 status = sme_AcquireGlobalLock( &pMac->sme );
3541 if ( HAL_STATUS_SUCCESS( status ) )
3542 {
3543 status = pmcRegisterDeviceStateUpdateInd (hHal, callbackRoutine, callbackContext);
3544 sme_ReleaseGlobalLock( &pMac->sme );
3545 }
3546
3547 return (status);
3548}
3549
3550/* ---------------------------------------------------------------------------
3551 \fn sme_DeregisterDeviceStateUpdateInd
3552 \brief Deregister a routine that was registered for device state changes
3553 \param hHal - The handle returned by macOpen.
3554 \param callbackRoutine - Callback routine to be deregistered
3555 \return eHalStatus
3556 eHAL_STATUS_SUCCESS - successfully deregistered
3557 eHAL_STATUS_FAILURE - not successfully deregistered
3558 ---------------------------------------------------------------------------*/
3559eHalStatus sme_DeregisterDeviceStateUpdateInd (
3560 tHalHandle hHal,
3561 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
3562{
3563 eHalStatus status = eHAL_STATUS_FAILURE;
3564 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3565
3566 status = sme_AcquireGlobalLock( &pMac->sme );
3567 if ( HAL_STATUS_SUCCESS( status ) )
3568 {
3569 status = pmcDeregisterDeviceStateUpdateInd (hHal, callbackRoutine);
3570 sme_ReleaseGlobalLock( &pMac->sme );
3571 }
3572
3573 return (status);
3574}
3575
3576/* ---------------------------------------------------------------------------
3577 \fn sme_WowlAddBcastPattern
3578 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
3579 do a pattern match on these patterns when Wowl is enabled during BMPS
3580 mode. Note that Firmware performs the pattern matching only on
3581 broadcast frames and while Libra is in BMPS mode.
3582 \param hHal - The handle returned by macOpen.
3583 \param pattern - Pattern to be added
3584 \return eHalStatus
3585 eHAL_STATUS_FAILURE Cannot add pattern
3586 eHAL_STATUS_SUCCESS Request accepted.
3587 ---------------------------------------------------------------------------*/
3588eHalStatus sme_WowlAddBcastPattern (
3589 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003590 tpSirWowlAddBcastPtrn pattern,
3591 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003592{
3593 eHalStatus status = eHAL_STATUS_FAILURE;
3594 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3595 status = sme_AcquireGlobalLock( &pMac->sme );
3596 if ( HAL_STATUS_SUCCESS( status ) )
3597 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003598 status = pmcWowlAddBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 sme_ReleaseGlobalLock( &pMac->sme );
3600 }
3601
3602 return (status);
3603}
3604
3605/* ---------------------------------------------------------------------------
3606 \fn sme_WowlDelBcastPattern
3607 \brief Delete a pattern that was added for Pattern Byte Matching.
3608 \param hHal - The handle returned by macOpen.
3609 \param pattern - Pattern to be deleted
3610 \return eHalStatus
3611 eHAL_STATUS_FAILURE Cannot delete pattern
3612 eHAL_STATUS_SUCCESS Request accepted.
3613 ---------------------------------------------------------------------------*/
3614eHalStatus sme_WowlDelBcastPattern (
3615 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003616 tpSirWowlDelBcastPtrn pattern,
3617 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003618{
3619 eHalStatus status = eHAL_STATUS_FAILURE;
3620 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3621 status = sme_AcquireGlobalLock( &pMac->sme );
3622 if ( HAL_STATUS_SUCCESS( status ) )
3623 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003624 status = pmcWowlDelBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 sme_ReleaseGlobalLock( &pMac->sme );
3626 }
3627
3628 return (status);
3629}
3630
3631/* ---------------------------------------------------------------------------
3632 \fn sme_EnterWowl
3633 \brief This is the SME API exposed to HDD to request enabling of WOWL mode.
3634 WoWLAN works on top of BMPS mode. If the device is not in BMPS mode,
3635 SME will will cache the information that WOWL has been enabled and
3636 attempt to put the device in BMPS. On entry into BMPS, SME will
3637 enable the WOWL mode.
3638 Note 1: If we exit BMPS mode (someone requests full power), we
3639 will NOT resume WOWL when we go back to BMPS again. Request for full
3640 power (while in WOWL mode) means disable WOWL and go to full power.
3641 Note 2: Both UAPSD and WOWL work on top of BMPS. On entry into BMPS, SME
3642 will give priority to UAPSD and enable only UAPSD if both UAPSD and WOWL
3643 are required. Currently there is no requirement or use case to support
3644 UAPSD and WOWL at the same time.
3645
3646 \param hHal - The handle returned by macOpen.
3647 \param enterWowlCallbackRoutine - Callback routine provided by HDD.
3648 Used for success/failure notification by SME
3649 \param enterWowlCallbackContext - A cookie passed by HDD, that is passed back to HDD
3650 at the time of callback.
3651 \param wakeReasonIndCB - Callback routine provided by HDD.
3652 Used for Wake Reason Indication by SME
3653 \param wakeReasonIndCBContext - A cookie passed by HDD, that is passed back to HDD
3654 at the time of callback.
3655 \return eHalStatus
3656 eHAL_STATUS_SUCCESS Device is already in WoWLAN mode
3657 eHAL_STATUS_FAILURE Device cannot enter WoWLAN mode.
3658 eHAL_STATUS_PMC_PENDING Request accepted. SME will enable WOWL after
3659 BMPS mode is entered.
3660 ---------------------------------------------------------------------------*/
3661eHalStatus sme_EnterWowl (
3662 tHalHandle hHal,
3663 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
3664 void *enterWowlCallbackContext,
3665#ifdef WLAN_WAKEUP_EVENTS
3666 void (*wakeIndicationCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
3667 void *wakeIndicationCBContext,
3668#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003669 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003670{
3671 eHalStatus status = eHAL_STATUS_FAILURE;
3672 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3673 status = sme_AcquireGlobalLock( &pMac->sme );
3674 if ( HAL_STATUS_SUCCESS( status ) )
3675 {
3676 status = pmcEnterWowl (hHal, enterWowlCallbackRoutine, enterWowlCallbackContext,
3677#ifdef WLAN_WAKEUP_EVENTS
3678 wakeIndicationCB, wakeIndicationCBContext,
3679#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003680 wowlEnterParams, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 sme_ReleaseGlobalLock( &pMac->sme );
3682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 return (status);
3684}
3685/* ---------------------------------------------------------------------------
3686 \fn sme_ExitWowl
3687 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
3688 SME will initiate exit from WoWLAN mode and device will be put in BMPS
3689 mode.
3690 \param hHal - The handle returned by macOpen.
3691 \return eHalStatus
3692 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
3693 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
3694 ---------------------------------------------------------------------------*/
3695eHalStatus sme_ExitWowl (tHalHandle hHal)
3696{
3697 eHalStatus status = eHAL_STATUS_FAILURE;
3698 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3699 status = sme_AcquireGlobalLock( &pMac->sme );
3700 if ( HAL_STATUS_SUCCESS( status ) )
3701 {
3702 status = pmcExitWowl (hHal);
3703 sme_ReleaseGlobalLock( &pMac->sme );
3704 }
3705
3706 return (status);
3707}
3708
3709/* ---------------------------------------------------------------------------
3710
3711 \fn sme_RoamSetKey
3712
3713 \brief To set encryption key. This function should be called only when connected
3714 This is an asynchronous API.
3715
3716 \param pSetKeyInfo - pointer to a caller allocated object of tCsrSetContextInfo
3717
3718 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3719
3720 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3721
3722 FAILURE or RESOURCES The API finished and failed.
3723
3724 -------------------------------------------------------------------------------*/
3725eHalStatus sme_RoamSetKey(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 *pRoamId)
3726{
3727 eHalStatus status = eHAL_STATUS_FAILURE;
3728 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3729 tANI_U32 roamId;
3730#ifdef WLAN_SOFTAP_FEATURE
3731 tANI_U32 i;
3732 tCsrRoamSession *pSession = NULL;
3733#endif
3734
3735 status = sme_AcquireGlobalLock( &pMac->sme );
3736 if ( HAL_STATUS_SUCCESS( status ) )
3737 {
3738 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3739 if(pRoamId)
3740 {
3741 *pRoamId = roamId;
3742 }
3743
3744#ifdef WLAN_SOFTAP_FEATURE
3745 smsLog(pMac, LOG2, FL("keyLength\n"), pSetKey->keyLength);
3746
3747 for(i=0; i<pSetKey->keyLength; i++)
3748 smsLog(pMac, LOG2, FL("%02x"), pSetKey->Key[i]);
3749
3750 smsLog(pMac, LOG2, "\n sessionId=%d roamId=%d\n", sessionId, roamId);
3751
3752 pSession = CSR_GET_SESSION(pMac, sessionId);
3753
Jeff Johnson32d95a32012-09-10 13:15:23 -07003754 if(!pSession)
3755 {
3756 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3757 return eHAL_STATUS_FAILURE;
3758 }
3759
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
3761 {
3762 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
3763 {
3764 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
3765 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
3766 {
3767 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3768 }
3769 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
3770 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
3771 {
3772 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3773 }
3774 }
3775 }
3776#endif
3777
3778 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
3779 sme_ReleaseGlobalLock( &pMac->sme );
3780 }
3781
3782 return (status);
3783}
3784
3785
3786/* ---------------------------------------------------------------------------
3787
3788 \fn sme_RoamRemoveKey
3789
3790 \brief To set encryption key. This is an asynchronous API.
3791
3792 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
3793
3794 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3795
3796 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3797
3798 FAILURE or RESOURCES The API finished and failed.
3799
3800 -------------------------------------------------------------------------------*/
3801eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
3802 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
3803{
3804 eHalStatus status = eHAL_STATUS_FAILURE;
3805 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3806 tANI_U32 roamId;
3807
3808 status = sme_AcquireGlobalLock( &pMac->sme );
3809 if ( HAL_STATUS_SUCCESS( status ) )
3810 {
3811 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3812 if(pRoamId)
3813 {
3814 *pRoamId = roamId;
3815 }
3816 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
3817 sme_ReleaseGlobalLock( &pMac->sme );
3818 }
3819
3820 return (status);
3821}
3822
3823/* ---------------------------------------------------------------------------
3824 \fn sme_GetRssi
3825 \brief a wrapper function that client calls to register a callback to get RSSI
3826
3827 \param callback - SME sends back the requested stats using the callback
3828 \param staId - The station ID for which the stats is requested for
3829 \param pContext - user context to be passed back along with the callback
3830 \param pVosContext - vos context
3831 \return eHalStatus
3832 ---------------------------------------------------------------------------*/
3833eHalStatus sme_GetRssi(tHalHandle hHal,
3834 tCsrRssiCallback callback,
3835 tANI_U8 staId, tCsrBssid bssId,
3836 void *pContext, void* pVosContext)
3837{
3838 eHalStatus status = eHAL_STATUS_FAILURE;
3839 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3840
3841 status = sme_AcquireGlobalLock( &pMac->sme );
3842 if ( HAL_STATUS_SUCCESS( status ) )
3843 {
3844 status = csrGetRssi( pMac, callback,
3845 staId, bssId, pContext, pVosContext);
3846 sme_ReleaseGlobalLock( &pMac->sme );
3847 }
3848 return (status);
3849}
3850
3851/* ---------------------------------------------------------------------------
3852 \fn sme_GetStatistics
3853 \brief a wrapper function that client calls to register a callback to get
3854 different PHY level statistics from CSR.
3855
3856 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
3857 \param statsMask - The different category/categories of stats requester is looking for
3858 \param callback - SME sends back the requested stats using the callback
3859 \param periodicity - If requester needs periodic update in millisec, 0 means
3860 it's an one time request
3861 \param cache - If requester is happy with cached stats
3862 \param staId - The station ID for which the stats is requested for
3863 \param pContext - user context to be passed back along with the callback
3864 \return eHalStatus
3865 ---------------------------------------------------------------------------*/
3866eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
3867 tANI_U32 statsMask,
3868 tCsrStatsCallback callback,
3869 tANI_U32 periodicity, tANI_BOOLEAN cache,
3870 tANI_U8 staId, void *pContext)
3871{
3872 eHalStatus status = eHAL_STATUS_FAILURE;
3873 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3874
3875 status = sme_AcquireGlobalLock( &pMac->sme );
3876 if ( HAL_STATUS_SUCCESS( status ) )
3877 {
3878 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
3879 periodicity, cache, staId, pContext);
3880 sme_ReleaseGlobalLock( &pMac->sme );
3881 }
3882
3883 return (status);
3884
3885}
3886
3887/* ---------------------------------------------------------------------------
3888
3889 \fn sme_GetCountryCode
3890
3891 \brief To return the current country code. If no country code is applied, default country code is
3892 used to fill the buffer.
3893 If 11d supported is turned off, an error is return and the last applied/default country code is used.
3894 This is a synchronous API.
3895
3896 \param pBuf - pointer to a caller allocated buffer for returned country code.
3897
3898 \param pbLen For input, this parameter indicates how big is the buffer.
3899 Upon return, this parameter has the number of bytes for country. If pBuf
3900 doesn't have enough space, this function returns
3901 fail status and this parameter contains the number that is needed.
3902
3903 \return eHalStatus SUCCESS.
3904
3905 FAILURE or RESOURCES The API finished and failed.
3906
3907 -------------------------------------------------------------------------------*/
3908eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
3909{
3910 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3911
3912 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
3913}
3914
3915
3916/* ---------------------------------------------------------------------------
3917
3918 \fn sme_SetCountryCode
3919
3920 \brief To change the current/default country code.
3921 If 11d supported is turned off, an error is return.
3922 This is a synchronous API.
3923
3924 \param pCountry - pointer to a caller allocated buffer for the country code.
3925
3926 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
3927 whether a reset is required.
3928
3929 \return eHalStatus SUCCESS.
3930
3931 FAILURE or RESOURCES The API finished and failed.
3932
3933 -------------------------------------------------------------------------------*/
3934eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
3935{
3936 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3937
3938 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
3939}
3940
3941
3942/* ---------------------------------------------------------------------------
3943 \fn sme_ResetCountryCodeInformation
3944 \brief this function is to reset the country code current being used back to EEPROM default
3945 this includes channel list and power setting. This is a synchronous API.
3946 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
3947 a restart is needed to apply the change
3948 \return eHalStatus
3949 -------------------------------------------------------------------------------*/
3950eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
3951{
3952 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3953
3954 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
3955}
3956
3957
3958/* ---------------------------------------------------------------------------
3959 \fn sme_GetSupportedCountryCode
3960 \brief this function is to get a list of the country code current being supported
3961 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
3962 this has the country code list. 3 bytes for each country code. This may be NULL if
3963 caller wants to know the needed byte count.
3964 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
3965 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
3966 \return eHalStatus
3967 -------------------------------------------------------------------------------*/
3968eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
3969{
3970 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3971
3972 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
3973}
3974
3975
3976/* ---------------------------------------------------------------------------
3977 \fn sme_GetCurrentRegulatoryDomain
3978 \brief this function is to get the current regulatory domain. This is a synchronous API.
3979 This function must be called after CFG is downloaded and all the band/mode setting already passed into
3980 SME. The function fails if 11d support is turned off.
3981 \param pDomain - Caller allocated buffer to return the current domain.
3982 \return eHalStatus SUCCESS.
3983
3984 FAILURE or RESOURCES The API finished and failed.
3985 -------------------------------------------------------------------------------*/
3986eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
3987{
3988 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3989 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
3990
3991 if( pDomain )
3992 {
3993 if( csrIs11dSupported( pMac ) )
3994 {
3995 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
3996 status = eHAL_STATUS_SUCCESS;
3997 }
3998 else
3999 {
4000 status = eHAL_STATUS_FAILURE;
4001 }
4002 }
4003
4004 return ( status );
4005}
4006
4007
4008/* ---------------------------------------------------------------------------
4009 \fn sme_SetRegulatoryDomain
4010 \brief this function is to set the current regulatory domain.
4011 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4012 SME. This is a synchronous API.
4013 \param domainId - indicate the domain (defined in the driver) needs to set to.
4014 See v_REGDOMAIN_t for definition
4015 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
4016 a restart is needed to apply the change
4017 \return eHalStatus
4018 -------------------------------------------------------------------------------*/
4019eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
4020{
4021 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4022
4023 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
4024}
4025
4026
4027/* ---------------------------------------------------------------------------
4028
4029 \fn sme_GetRegulatoryDomainForCountry
4030
4031 \brief To return a regulatory domain base on a country code. This is a synchronous API.
4032
4033 \param pCountry - pointer to a caller allocated buffer for input country code.
4034
4035 \param pDomainId Upon successful return, it is the domain that country belongs to.
4036 If it is NULL, returning success means that the country code is known.
4037
4038 \return eHalStatus SUCCESS.
4039
4040 FAILURE or RESOURCES The API finished and failed.
4041
4042 -------------------------------------------------------------------------------*/
4043eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
4044{
4045 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4046
4047 return ( csrGetRegulatoryDomainForCountry( pMac, pCountry, pDomainId ) );
4048}
4049
4050
4051
4052
4053/* ---------------------------------------------------------------------------
4054
4055 \fn sme_GetSupportedRegulatoryDomains
4056
4057 \brief To return a list of supported regulatory domains. This is a synchronous API.
4058
4059 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
4060
4061 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
4062 Upon return, this parameter has the number for supported domains. If pDomains
4063 doesn't have enough space for all the supported domains, this function returns
4064 fail status and this parameter contains the number that is needed.
4065
4066 \return eHalStatus SUCCESS.
4067
4068 FAILURE or RESOURCES The API finished and failed.
4069
4070 -------------------------------------------------------------------------------*/
4071eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
4072{
4073 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4074
4075 //We support all domains for now
4076 if( pNumDomains )
4077 {
4078 if( NUM_REG_DOMAINS <= *pNumDomains )
4079 {
4080 status = eHAL_STATUS_SUCCESS;
4081 }
4082 *pNumDomains = NUM_REG_DOMAINS;
4083 }
4084 if( HAL_STATUS_SUCCESS( status ) )
4085 {
4086 if( pDomains )
4087 {
4088 pDomains[0] = REGDOMAIN_FCC;
4089 pDomains[1] = REGDOMAIN_ETSI;
4090 pDomains[2] = REGDOMAIN_JAPAN;
4091 pDomains[3] = REGDOMAIN_WORLD;
4092 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
4093 pDomains[5] = REGDOMAIN_APAC;
4094 pDomains[6] = REGDOMAIN_KOREA;
4095 pDomains[7] = REGDOMAIN_HI_5GHZ;
4096 pDomains[8] = REGDOMAIN_NO_5GHZ;
4097 }
4098 else
4099 {
4100 status = eHAL_STATUS_INVALID_PARAMETER;
4101 }
4102 }
4103
4104 return ( status );
4105}
4106
4107
4108//some support functions
4109tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
4110{
4111 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4112
4113 return ( csrIs11dSupported( pMac ) );
4114}
4115
4116
4117tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
4118{
4119 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4120
4121 return ( csrIs11hSupported( pMac ) );
4122}
4123
4124
4125tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
4126{
4127 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4128
4129 return ( csrIsWmmSupported( pMac ) );
4130}
4131
4132//Upper layer to get the list of the base channels to scan for passively 11d info from csr
4133eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
4134{
4135 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4136
4137 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
4138}
4139
4140/* ---------------------------------------------------------------------------
4141
4142 \fn sme_ChangeCountryCode
4143
4144 \brief Change Country code from upperlayer during WLAN driver operation.
4145 This is a synchronous API.
4146
4147 \param hHal - The handle returned by macOpen.
4148
4149 \param pCountry New Country Code String
4150
4151 \return eHalStatus SUCCESS.
4152
4153 FAILURE or RESOURCES The API finished and failed.
4154
4155 -------------------------------------------------------------------------------*/
4156eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
4157 tSmeChangeCountryCallback callback,
4158 tANI_U8 *pCountry,
4159 void *pContext,
4160 void* pVosContext )
4161{
4162 eHalStatus status = eHAL_STATUS_FAILURE;
4163 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4164 vos_msg_t msg;
4165 tAniChangeCountryCodeReq *pMsg;
4166
4167 status = sme_AcquireGlobalLock( &pMac->sme );
4168 if ( HAL_STATUS_SUCCESS( status ) )
4169 {
4170 smsLog(pMac, LOG1, FL(" called\n"));
4171 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniChangeCountryCodeReq));
4172 if ( !HAL_STATUS_SUCCESS(status) )
4173 {
4174 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req \n");
4175 return status;
4176 }
4177
4178 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
4179 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
4180 palCopyMemory(pMac->hHdd, pMsg->countryCode, pCountry, 3);
4181 pMsg->changeCCCallback = callback;
4182 pMsg->pDevContext = pContext;
4183 pMsg->pVosContext = pVosContext;
4184
4185 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4186 msg.bodyptr = pMsg;
4187 msg.reserved = 0;
4188
4189 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
4190 {
4191 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self \n");
4192 palFreeMemory(pMac->hHdd, (void *)pMsg);
4193 status = eHAL_STATUS_FAILURE;
4194 }
4195 smsLog(pMac, LOG1, FL(" returned\n"));
4196 sme_ReleaseGlobalLock( &pMac->sme );
4197 }
4198
4199 return (status);
4200}
4201
4202/* ---------------------------------------------------------------------------
4203 \fn sme_BtcSignalBtEvent
4204 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
4205 BT event type and the current operating mode of Libra (full power,
4206 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
4207 would be employed.
4208 \param hHal - The handle returned by macOpen.
4209 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
4210 Caller owns the memory and is responsible for freeing it.
4211 \return VOS_STATUS
4212 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
4213 if BTC execution mode is set to BTC_WLAN_ONLY
4214 or BTC_PTA_ONLY.
4215 VOS_STATUS_SUCCESS BT Event passed to HAL
4216 ---------------------------------------------------------------------------*/
4217VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
4218{
4219 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4220#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4221 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4222
4223 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4224 {
4225 status = btcSignalBTEvent (hHal, pBtEvent);
4226 sme_ReleaseGlobalLock( &pMac->sme );
4227 }
4228#endif
4229 return (status);
4230}
4231
4232/* ---------------------------------------------------------------------------
4233 \fn sme_BtcSetConfig
4234 \brief API to change the current Bluetooth Coexistence (BTC) configuration
4235 This function should be invoked only after CFG download has completed.
4236 Calling it after sme_HDDReadyInd is recommended.
4237 \param hHal - The handle returned by macOpen.
4238 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
4239 Caller owns the memory and is responsible for freeing it.
4240 \return VOS_STATUS
4241 VOS_STATUS_E_FAILURE Config not passed to HAL.
4242 VOS_STATUS_SUCCESS Config passed to HAL
4243 ---------------------------------------------------------------------------*/
4244VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4245{
4246 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4247#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4248 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4249 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4250 {
4251 status = btcSetConfig (hHal, pSmeBtcConfig);
4252 sme_ReleaseGlobalLock( &pMac->sme );
4253 }
4254#endif
4255 return (status);
4256}
4257
4258/* ---------------------------------------------------------------------------
4259 \fn sme_BtcGetConfig
4260 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
4261 \param hHal - The handle returned by macOpen.
4262 \param pSmeBtcConfig - Pointer to a caller allocated object of type
4263 tSmeBtcConfig. Caller owns the memory and is responsible
4264 for freeing it.
4265 \return VOS_STATUS
4266 VOS_STATUS_E_FAILURE - failure
4267 VOS_STATUS_SUCCESS success
4268 ---------------------------------------------------------------------------*/
4269VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4270{
4271 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4272#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4273 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4274
4275 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4276 {
4277 status = btcGetConfig (hHal, pSmeBtcConfig);
4278 sme_ReleaseGlobalLock( &pMac->sme );
4279 }
4280#endif
4281 return (status);
4282}
4283/* ---------------------------------------------------------------------------
4284 \fn sme_SetCfgPrivacy
4285 \brief API to set configure privacy parameters
4286 \param hHal - The handle returned by macOpen.
4287 \param pProfile - Pointer CSR Roam profile.
4288 \param fPrivacy - This parameter indicates status of privacy
4289
4290 \return void
4291 ---------------------------------------------------------------------------*/
4292void sme_SetCfgPrivacy( tHalHandle hHal,
4293 tCsrRoamProfile *pProfile,
4294 tANI_BOOLEAN fPrivacy
4295 )
4296{
4297 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4298 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4299 {
4300 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
4301 sme_ReleaseGlobalLock( &pMac->sme );
4302 }
4303}
4304
4305#if defined WLAN_FEATURE_VOWIFI
4306/* ---------------------------------------------------------------------------
4307 \fn sme_NeighborReportRequest
4308 \brief API to request neighbor report.
4309 \param hHal - The handle returned by macOpen.
4310 \param pRrmNeighborReq - Pointer to a caller allocated object of type
4311 tRrmNeighborReq. Caller owns the memory and is responsible
4312 for freeing it.
4313 \return VOS_STATUS
4314 VOS_STATUS_E_FAILURE - failure
4315 VOS_STATUS_SUCCESS success
4316 ---------------------------------------------------------------------------*/
4317VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
4318 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
4319{
4320 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4321 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4322
4323 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4324 {
4325 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
4326 sme_ReleaseGlobalLock( &pMac->sme );
4327 }
4328
4329 return (status);
4330}
4331#endif
4332
4333//The following are debug APIs to support direct read/write register/memory
4334//They are placed in SME because HW cannot be access when in LOW_POWER state
4335//AND not connected. The knowledge and synchronization is done in SME
4336
4337//sme_DbgReadRegister
4338//Caller needs to validate the input values
4339VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
4340{
4341 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4342 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4343#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4344 tHddHandle hHdd = pMac->hHdd;
4345#endif
4346 tPmcPowerState PowerState;
4347 tANI_U32 sessionId = 0;
4348
4349 /* 1) To make Quarky work in FTM mode **************************************/
4350
4351 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4352 {
4353#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4354 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue)))
4355#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4356 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
4357#endif
4358 {
4359 return VOS_STATUS_SUCCESS;
4360 }
4361 return VOS_STATUS_E_FAILURE;
4362 }
4363
4364 /* 2) NON FTM mode driver *************************************************/
4365
4366 /* Acquire SME global lock */
4367 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4368 {
4369 return VOS_STATUS_E_FAILURE;
4370 }
4371
4372 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4373 {
4374 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4375 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4376 {
4377#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4378 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue )))
4379#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4380 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
4381#endif
4382 {
4383 status = VOS_STATUS_SUCCESS;
4384 }
4385 else
4386 {
4387 status = VOS_STATUS_E_FAILURE;
4388 }
4389 }
4390 else
4391 {
4392 status = VOS_STATUS_E_FAILURE;
4393 }
4394 }
4395
4396 /* This is a hack for Qualky/pttWniSocket
4397 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4398 if ( VOS_STATUS_SUCCESS != status )
4399 {
4400 *pRegValue = 0xDEADBEEF;
4401 status = VOS_STATUS_SUCCESS;
4402 }
4403
4404 /* Release SME global lock */
4405 sme_ReleaseGlobalLock(&pMac->sme);
4406
4407 return (status);
4408}
4409
4410
4411//sme_DbgWriteRegister
4412//Caller needs to validate the input values
4413VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
4414{
4415 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4416 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4417#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4418 tHddHandle hHdd = pMac->hHdd;
4419#endif
4420 tPmcPowerState PowerState;
4421 tANI_U32 sessionId = 0;
4422
4423 /* 1) To make Quarky work in FTM mode **************************************/
4424
4425 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4426 {
4427#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4428 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4429#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4430 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4431#endif
4432 {
4433 return VOS_STATUS_SUCCESS;
4434 }
4435 return VOS_STATUS_E_FAILURE;
4436 }
4437
4438 /* 2) NON FTM mode driver *************************************************/
4439
4440 /* Acquire SME global lock */
4441 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4442 {
4443 return VOS_STATUS_E_FAILURE;
4444 }
4445
4446 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4447 {
4448 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4449 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4450 {
4451#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4452 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4453#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4454 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4455#endif
4456 {
4457 status = VOS_STATUS_SUCCESS;
4458 }
4459 else
4460 {
4461 status = VOS_STATUS_E_FAILURE;
4462 }
4463 }
4464 else
4465 {
4466 status = VOS_STATUS_E_FAILURE;
4467 }
4468 }
4469
4470 /* Release SME global lock */
4471 sme_ReleaseGlobalLock(&pMac->sme);
4472
4473 return (status);
4474}
4475
4476
4477
4478//sme_DbgReadMemory
4479//Caller needs to validate the input values
4480//pBuf caller allocated buffer has the length of nLen
4481VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4482{
4483 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4484 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4485#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4486 v_PVOID_t pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *)hHal);
4487 tHddHandle hHdd = pMac->hHdd;
4488#endif
4489 tPmcPowerState PowerState;
4490 tANI_U32 sessionId = 0;
4491
4492 /* 1) To make Quarky work in FTM mode **************************************/
4493
4494 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4495 {
4496#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4497 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4498#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4499 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadMemory(memAddr, (void *)pBuf, nLen))
4500#endif
4501 {
4502 return VOS_STATUS_SUCCESS;
4503 }
4504 return VOS_STATUS_E_FAILURE;
4505 }
4506
4507 /* 2) NON FTM mode driver *************************************************/
4508
4509 /* Acquire SME global lock */
4510 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4511 {
4512 return VOS_STATUS_E_FAILURE;
4513 }
4514
4515 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4516 {
4517 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4518 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4519 {
4520#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4521 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(pvosGCTx, memAddr, (void *)pBuf, nLen)))
4522#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4523 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadMemory(memAddr, (void *)pBuf, nLen))
4524#endif
4525 {
4526 status = VOS_STATUS_SUCCESS;
4527 }
4528 else
4529 {
4530 status = VOS_STATUS_E_FAILURE;
4531 }
4532 }
4533 else
4534 {
4535 status = VOS_STATUS_E_FAILURE;
4536 }
4537 }
4538
4539 /* This is a hack for Qualky/pttWniSocket
4540 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4541 if (VOS_STATUS_SUCCESS != status)
4542 {
4543 vos_mem_set(pBuf, nLen, 0xCD);
4544 status = VOS_STATUS_SUCCESS;
4545 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware\n"));
4546 }
4547
4548 /* Release SME lock */
4549 sme_ReleaseGlobalLock(&pMac->sme);
4550
4551 return (status);
4552}
4553
4554
4555//sme_DbgWriteMemory
4556//Caller needs to validate the input values
4557VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4558{
4559 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4560 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4561#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4562 tHddHandle hHdd = pMac->hHdd;
4563#endif
4564 tPmcPowerState PowerState;
4565 tANI_U32 sessionId = 0;
4566
4567 /* 1) To make Quarky work in FTM mode **************************************/
4568
4569 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4570 {
4571#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4572 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4573#elif defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4574 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory( memAddr, (void *)pBuf, nLen))
4575#endif
4576 {
4577 return VOS_STATUS_SUCCESS;
4578 }
4579 return VOS_STATUS_E_FAILURE;
4580 }
4581
4582 /* 2) NON FTM mode driver *************************************************/
4583
4584 /* Acquire SME global lock */
4585 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4586 {
4587 return VOS_STATUS_E_FAILURE;
4588 }
4589
4590 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4591 {
4592 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4593 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4594 {
4595#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4596 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4597#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4598 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
4599#endif
4600 {
4601 status = VOS_STATUS_SUCCESS;
4602 }
4603 else
4604 {
4605 status = VOS_STATUS_E_FAILURE;
4606 }
4607 }
4608 else
4609 {
4610 status = VOS_STATUS_E_FAILURE;
4611 }
4612 }
4613
4614 /* Release Global lock */
4615 sme_ReleaseGlobalLock(&pMac->sme);
4616
4617 return (status);
4618}
4619
4620
4621void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
4622{
4623#ifdef WLAN_DEBUG
4624 // Verify against current log level
4625 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
4626 return;
4627 else
4628 {
4629 va_list marker;
4630
4631 va_start( marker, pString ); /* Initialize variable arguments. */
4632
4633 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
4634
4635 va_end( marker ); /* Reset variable arguments. */
4636 }
4637#endif
4638}
4639#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
4640/* ---------------------------------------------------------------------------
4641 \fn sme_GetFwVersion
4642 \brief This API returns the firmware version.
4643 \param hHal - The handle returned by macOpen.
4644 \param version - Points to the FwVersionInfo structure.
4645 \return VOS_STATUS
4646 VOS_STATUS_E_INVAL - failure
4647 VOS_STATUS_SUCCESS success
4648 ---------------------------------------------------------------------------*/
4649VOS_STATUS sme_GetFwVersion (tHalHandle hHal,FwVersionInfo *pVersion)
4650{
4651 VOS_STATUS status = VOS_STATUS_SUCCESS;
4652 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4653
4654 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4655 {
4656 if( pVersion != NULL ) {
4657 vos_mem_copy((v_VOID_t*)pVersion,(v_VOID_t*)&pMac->hal.FwParam.fwVersion, sizeof(FwVersionInfo));
4658 }
4659 else {
4660 status = VOS_STATUS_E_INVAL;
4661 }
4662 sme_ReleaseGlobalLock( &pMac->sme );
4663 }
4664
4665 return (status);
4666}
4667#endif
4668
4669#ifdef FEATURE_WLAN_INTEGRATED_SOC
4670/* ---------------------------------------------------------------------------
4671 \fn sme_GetWcnssWlanCompiledVersion
4672 \brief This API returns the version of the WCNSS WLAN API with
4673 which the HOST driver was built
4674 \param hHal - The handle returned by macOpen.
4675 \param pVersion - Points to the Version structure to be filled
4676 \return VOS_STATUS
4677 VOS_STATUS_E_INVAL - failure
4678 VOS_STATUS_SUCCESS success
4679 ---------------------------------------------------------------------------*/
4680VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
4681 tSirVersionType *pVersion)
4682{
4683 VOS_STATUS status = VOS_STATUS_SUCCESS;
4684 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4685 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4686
4687 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4688 {
4689 if( pVersion != NULL )
4690 {
4691 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
4692 }
4693 else
4694 {
4695 status = VOS_STATUS_E_INVAL;
4696 }
4697 sme_ReleaseGlobalLock( &pMac->sme );
4698 }
4699
4700 return (status);
4701}
4702
4703
4704/* ---------------------------------------------------------------------------
4705 \fn sme_GetWcnssWlanReportedVersion
4706 \brief This API returns the version of the WCNSS WLAN API with
4707 which the WCNSS driver reports it was built
4708 \param hHal - The handle returned by macOpen.
4709 \param pVersion - Points to the Version structure to be filled
4710 \return VOS_STATUS
4711 VOS_STATUS_E_INVAL - failure
4712 VOS_STATUS_SUCCESS success
4713 ---------------------------------------------------------------------------*/
4714VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
4715 tSirVersionType *pVersion)
4716{
4717 VOS_STATUS status = VOS_STATUS_SUCCESS;
4718 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4719 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4720
4721 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4722 {
4723 if( pVersion != NULL )
4724 {
4725 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
4726 }
4727 else
4728 {
4729 status = VOS_STATUS_E_INVAL;
4730 }
4731 sme_ReleaseGlobalLock( &pMac->sme );
4732 }
4733
4734 return (status);
4735}
4736
4737
4738/* ---------------------------------------------------------------------------
4739 \fn sme_GetWcnssSoftwareVersion
4740 \brief This API returns the version string of the WCNSS driver
4741 \param hHal - The handle returned by macOpen.
4742 \param pVersion - Points to the Version string buffer to be filled
4743 \param versionBufferSize - THe size of the Version string buffer
4744 \return VOS_STATUS
4745 VOS_STATUS_E_INVAL - failure
4746 VOS_STATUS_SUCCESS success
4747 ---------------------------------------------------------------------------*/
4748VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
4749 tANI_U8 *pVersion,
4750 tANI_U32 versionBufferSize)
4751{
4752 VOS_STATUS status = VOS_STATUS_SUCCESS;
4753 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4754 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4755
4756 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4757 {
4758 if( pVersion != NULL )
4759 {
4760 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
4761 versionBufferSize);
4762 }
4763 else
4764 {
4765 status = VOS_STATUS_E_INVAL;
4766 }
4767 sme_ReleaseGlobalLock( &pMac->sme );
4768 }
4769
4770 return (status);
4771}
4772
4773
4774/* ---------------------------------------------------------------------------
4775 \fn sme_GetWcnssHardwareVersion
4776 \brief This API returns the version string of the WCNSS hardware
4777 \param hHal - The handle returned by macOpen.
4778 \param pVersion - Points to the Version string buffer to be filled
4779 \param versionBufferSize - THe size of the Version string buffer
4780 \return VOS_STATUS
4781 VOS_STATUS_E_INVAL - failure
4782 VOS_STATUS_SUCCESS success
4783 ---------------------------------------------------------------------------*/
4784VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
4785 tANI_U8 *pVersion,
4786 tANI_U32 versionBufferSize)
4787{
4788 VOS_STATUS status = VOS_STATUS_SUCCESS;
4789 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4790 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4791
4792 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4793 {
4794 if( pVersion != NULL )
4795 {
4796 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
4797 versionBufferSize);
4798 }
4799 else
4800 {
4801 status = VOS_STATUS_E_INVAL;
4802 }
4803 sme_ReleaseGlobalLock( &pMac->sme );
4804 }
4805
4806 return (status);
4807}
4808#endif
4809
4810#ifdef FEATURE_WLAN_WAPI
4811/* ---------------------------------------------------------------------------
4812 \fn sme_RoamSetBKIDCache
4813 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
4814 candidate list.
4815 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4816 it is opened (by calling halOpen).
4817 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
4818 \param numItems - a variable that has the number of tBkidCacheInfo allocated
4819 when retruning, this is the number of items put into pBKIDCache
4820 \return eHalStatus - when fail, it usually means the buffer allocated is not
4821 big enough and pNumItems has the number of tBkidCacheInfo.
4822 ---------------------------------------------------------------------------*/
4823eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
4824 tANI_U32 numItems )
4825{
4826 eHalStatus status = eHAL_STATUS_FAILURE;
4827 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4828
4829 status = sme_AcquireGlobalLock( &pMac->sme );
4830 if ( HAL_STATUS_SUCCESS( status ) )
4831 {
4832 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
4833 sme_ReleaseGlobalLock( &pMac->sme );
4834 }
4835
4836 return (status);
4837}
4838
4839/* ---------------------------------------------------------------------------
4840 \fn sme_RoamGetBKIDCache
4841 \brief The SME API exposed to HDD to allow HDD to request SME to return its
4842 BKID cache.
4843 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4844 it is opened (by calling halOpen).
4845 \param pNum - caller allocated memory that has the space of the number of
4846 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
4847 in SME cache.
4848 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
4849 upon return
4850 \return eHalStatus - when fail, it usually means the buffer allocated is not
4851 big enough.
4852 ---------------------------------------------------------------------------*/
4853eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
4854 tBkidCacheInfo *pBkidCache)
4855{
4856 eHalStatus status = eHAL_STATUS_FAILURE;
4857 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4858
4859 status = sme_AcquireGlobalLock( &pMac->sme );
4860 if ( HAL_STATUS_SUCCESS( status ) )
4861 {
4862 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded\n"));
4863 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
4864 sme_ReleaseGlobalLock( &pMac->sme );
4865 }
4866
4867 return (status);
4868}
4869
4870/* ---------------------------------------------------------------------------
4871 \fn sme_RoamGetNumBKIDCache
4872 \brief The SME API exposed to HDD to allow HDD to request SME to return the
4873 number of BKID cache entries.
4874 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4875 it is opened (by calling halOpen).
4876 \return tANI_U32 - the number of BKID cache entries.
4877 ---------------------------------------------------------------------------*/
4878tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
4879{
4880 eHalStatus status = eHAL_STATUS_FAILURE;
4881 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4882 tANI_U32 numBkidCache = 0;
4883
4884 status = sme_AcquireGlobalLock( &pMac->sme );
4885 if ( HAL_STATUS_SUCCESS( status ) )
4886 {
4887 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
4888 sme_ReleaseGlobalLock( &pMac->sme );
4889 }
4890
4891 return (numBkidCache);
4892}
4893
4894/* ---------------------------------------------------------------------------
4895 \fn sme_ScanGetBKIDCandidateList
4896 \brief a wrapper function to return the BKID candidate list
4897 \param pBkidList - caller allocated buffer point to an array of
4898 tBkidCandidateInfo
4899 \param pNumItems - pointer to a variable that has the number of
4900 tBkidCandidateInfo allocated when retruning, this is
4901 either the number needed or number of items put into
4902 pPmkidList
4903 \return eHalStatus - when fail, it usually means the buffer allocated is not
4904 big enough and pNumItems
4905 has the number of tBkidCandidateInfo.
4906 \Note: pNumItems is a number of tBkidCandidateInfo,
4907 not sizeof(tBkidCandidateInfo) * something
4908 ---------------------------------------------------------------------------*/
4909eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
4910 tBkidCandidateInfo *pBkidList,
4911 tANI_U32 *pNumItems )
4912{
4913 eHalStatus status = eHAL_STATUS_FAILURE;
4914 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4915
4916 status = sme_AcquireGlobalLock( &pMac->sme );
4917 if ( HAL_STATUS_SUCCESS( status ) )
4918 {
4919 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
4920 sme_ReleaseGlobalLock( &pMac->sme );
4921 }
4922
4923 return (status);
4924}
4925#endif /* FEATURE_WLAN_WAPI */
4926
Jeff Johnsone7245742012-09-05 17:12:55 -07004927#ifdef FEATURE_OEM_DATA_SUPPORT
4928
4929/*****************************************************************************
4930 OEM DATA related modifications and function additions
4931 *****************************************************************************/
4932
4933/* ---------------------------------------------------------------------------
4934 \fn sme_getOemDataRsp
4935 \brief a wrapper function to obtain the OEM DATA RSP
4936 \param pOemDataRsp - A pointer to the response object
4937 \param pContext - a pointer passed in for the callback
4938 \return eHalStatus
4939 ---------------------------------------------------------------------------*/
4940eHalStatus sme_getOemDataRsp(tHalHandle hHal,
4941 tOemDataRsp **pOemDataRsp)
4942{
4943 eHalStatus status = eHAL_STATUS_SUCCESS;
4944 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4945
4946 do
4947 {
4948 //acquire the lock for the sme object
4949 status = sme_AcquireGlobalLock(&pMac->sme);
4950
4951 if(!HAL_STATUS_SUCCESS(status))
4952 {
4953 break;
4954 }
4955
4956 if(pMac->oemData.pOemDataRsp != NULL)
4957 {
4958 *pOemDataRsp = pMac->oemData.pOemDataRsp;
4959 }
4960 else
4961 {
4962 status = eHAL_STATUS_FAILURE;
4963 }
4964
4965 //release the lock for the sme object
4966 sme_ReleaseGlobalLock( &pMac->sme );
4967
4968 } while(0);
4969
4970 return status;
4971}
4972
4973/* ---------------------------------------------------------------------------
4974 \fn sme_OemDataReq
4975 \brief a wrapper function for OEM DATA REQ
4976 \param sessionId - session id to be used.
4977 \param pOemDataReqId - pointer to an object to get back the request ID
4978 \param callback - a callback function that is called upon finish
4979 \param pContext - a pointer passed in for the callback
4980 \return eHalStatus
4981 ---------------------------------------------------------------------------*/
4982eHalStatus sme_OemDataReq(tHalHandle hHal,
4983 tANI_U8 sessionId,
4984 tOemDataReqConfig *pOemDataReqConfig,
4985 tANI_U32 *pOemDataReqID,
4986 oemData_OemDataReqCompleteCallback callback,
4987 void *pContext)
4988{
4989 eHalStatus status = eHAL_STATUS_SUCCESS;
4990 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4991
4992 do
4993 {
4994 //acquire the lock for the sme object
4995 status = sme_AcquireGlobalLock(&pMac->sme);
4996 if(HAL_STATUS_SUCCESS(status))
4997 {
4998 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
4999
5000 if(pOemDataReqID)
5001 {
5002 *pOemDataReqID = lOemDataReqId;
5003 }
5004 else
5005 return eHAL_STATUS_FAILURE;
5006
5007 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
5008
5009 //release the lock for the sme object
5010 sme_ReleaseGlobalLock( &pMac->sme );
5011 }
5012 } while(0);
5013
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005014 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07005015
5016 return(status);
5017}
5018
5019#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005020
5021/*--------------------------------------------------------------------------
5022
5023 \brief sme_OpenSession() - Open a session for scan/roam operation.
5024
5025 This is a synchronous API.
5026
5027
5028 \param hHal - The handle returned by macOpen.
5029 \param callback - A pointer to the function caller specifies for roam/connect status indication
5030 \param pContext - The context passed with callback
5031 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
5032 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
5033
5034 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
5035
5036 Other status means SME is failed to open the session.
5037 eHAL_STATUS_RESOURCES - no more session available.
5038 \sa
5039
5040 --------------------------------------------------------------------------*/
5041eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback, void *pContext,
5042 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId)
5043{
5044 eHalStatus status;
5045 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5046
5047 if( NULL == pbSessionId )
5048 {
5049 status = eHAL_STATUS_INVALID_PARAMETER;
5050 }
5051 else
5052 {
5053 status = sme_AcquireGlobalLock( &pMac->sme );
5054 if ( HAL_STATUS_SUCCESS( status ) )
5055 {
5056 status = csrRoamOpenSession( pMac, callback, pContext, pSelfMacAddr, pbSessionId );
5057
5058 sme_ReleaseGlobalLock( &pMac->sme );
5059 }
5060 }
5061
5062 return ( status );
5063}
5064
5065
5066/*--------------------------------------------------------------------------
5067
5068 \brief sme_CloseSession() - Open a session for scan/roam operation.
5069
5070 This is a synchronous API.
5071
5072
5073 \param hHal - The handle returned by macOpen.
5074
5075 \param sessionId - A previous opened session's ID.
5076
5077 \return eHAL_STATUS_SUCCESS - session is closed.
5078
5079 Other status means SME is failed to open the session.
5080 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
5081 \sa
5082
5083 --------------------------------------------------------------------------*/
5084eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
5085 csrRoamSessionCloseCallback callback, void *pContext)
5086{
5087 eHalStatus status;
5088 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5089
5090 status = sme_AcquireGlobalLock( &pMac->sme );
5091 if ( HAL_STATUS_SUCCESS( status ) )
5092 {
5093 status = csrRoamCloseSession( pMac, sessionId, FALSE,
5094 callback, pContext );
5095
5096 sme_ReleaseGlobalLock( &pMac->sme );
5097 }
5098
5099 return ( status );
5100}
5101
5102#ifdef WLAN_SOFTAP_FEATURE
5103/* ---------------------------------------------------------------------------
5104
5105 \fn sme_RoamUpdateAPWPSIE
5106
5107 \brief To update AP's WPS IE. This function should be called after SME AP session is created
5108 This is an asynchronous API.
5109
5110 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
5111
5112 \return eHalStatus – SUCCESS –
5113
5114 FAILURE or RESOURCES – The API finished and failed.
5115
5116 -------------------------------------------------------------------------------*/
5117eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
5118{
5119
5120 eHalStatus status = eHAL_STATUS_FAILURE;
5121 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5122
5123 status = sme_AcquireGlobalLock( &pMac->sme );
5124 if ( HAL_STATUS_SUCCESS( status ) )
5125 {
5126
5127 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
5128
5129 sme_ReleaseGlobalLock( &pMac->sme );
5130 }
5131
5132 return (status);
5133}
5134/* ---------------------------------------------------------------------------
5135
5136 \fn sme_RoamUpdateAPWPARSNIEs
5137
5138 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
5139 This is an asynchronous API.
5140
5141 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
5142
5143 \return eHalStatus – SUCCESS –
5144
5145 FAILURE or RESOURCES – The API finished and failed.
5146
5147 -------------------------------------------------------------------------------*/
5148eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
5149{
5150
5151 eHalStatus status = eHAL_STATUS_FAILURE;
5152 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5153
5154 status = sme_AcquireGlobalLock( &pMac->sme );
5155 if ( HAL_STATUS_SUCCESS( status ) )
5156 {
5157
5158 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
5159
5160 sme_ReleaseGlobalLock( &pMac->sme );
5161 }
5162
5163 return (status);
5164}
5165#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005166/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07005167
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005168 \fn sme_ChangeMCCBeaconInterval
5169
5170 \brief To update P2P-GO beaconInterval. This function should be called after
5171 disassociating all the station is done
5172 This is an asynchronous API.
5173
5174 \param
5175
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005176 \return eHalStatus SUCCESS
5177 FAILURE or RESOURCES
5178 The API finished and failed.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005179
5180 -------------------------------------------------------------------------------*/
5181eHalStatus sme_ChangeMCCBeaconInterval(tHalHandle hHal, tANI_U8 sessionId)
5182{
5183 eHalStatus status = eHAL_STATUS_FAILURE;
5184 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5185
5186 smsLog(pMac, LOG1, FL("Update Beacon PARAMS \n"));
5187 status = sme_AcquireGlobalLock( &pMac->sme );
5188 if ( HAL_STATUS_SUCCESS( status ) )
5189 {
5190 status = csrSendChngMCCBeaconInterval( pMac, sessionId);
5191 sme_ReleaseGlobalLock( &pMac->sme );
5192 }
5193 return (status);
5194}
Jeff Johnson295189b2012-06-20 16:38:30 -07005195
5196/*-------------------------------------------------------------------------------*
5197
5198 \fn sme_sendBTAmpEvent
5199
5200 \brief to receive the coex priorty request from BT-AMP PAL
5201 and send the BT_AMP link state to HAL
5202
5203 \param btAmpEvent - btAmpEvent
5204
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005205 \return eHalStatus: SUCCESS : BTAmp event successfully sent to HAL
Jeff Johnson295189b2012-06-20 16:38:30 -07005206
5207 FAILURE: API failed
5208
5209-------------------------------------------------------------------------------*/
5210
5211eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
5212{
5213 vos_msg_t msg;
5214 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
5215 eHalStatus status = eHAL_STATUS_FAILURE;
5216
5217 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tpSmeBtAmpEvent));
5218 if (NULL == ptrSmeBtAmpEvent)
5219 {
5220 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005221 "Not able to allocate memory for BTAmp event", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 return status;
5223 }
5224
5225 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
5226 msg.type = WDA_SIGNAL_BTAMP_EVENT;
5227 msg.reserved = 0;
5228 msg.bodyptr = ptrSmeBtAmpEvent;
5229
5230 //status = halFW_SendBTAmpEventMesg(pMac, event);
5231
5232 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5233 {
5234 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005235 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 vos_mem_free(ptrSmeBtAmpEvent);
5237 return status;
5238 }
5239
5240 return eHAL_STATUS_SUCCESS;
5241
5242}
5243
5244/* ---------------------------------------------------------------------------
5245 \fn sme_SetHostOffload
5246 \brief API to set the host offload feature.
5247 \param hHal - The handle returned by macOpen.
5248 \param pRequest - Pointer to the offload request.
5249 \return eHalStatus
5250 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005251eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
5252 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005253{
5254 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07005255 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005256
5257 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5258 {
5259#ifdef WLAN_NS_OFFLOAD
5260 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
5261 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005262 status = pmcSetNSOffload( hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 }
5264 else
5265#endif //WLAN_NS_OFFLOAD
5266 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005267 status = pmcSetHostOffload (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 }
5269 sme_ReleaseGlobalLock( &pMac->sme );
5270 }
5271
5272 return (status);
5273}
5274
5275#ifdef WLAN_FEATURE_GTK_OFFLOAD
5276/* ---------------------------------------------------------------------------
5277 \fn sme_SetGTKOffload
5278 \brief API to set GTK offload information.
5279 \param hHal - The handle returned by macOpen.
5280 \param pRequest - Pointer to the GTK offload request.
5281 \return eHalStatus
5282 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005283eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest,
5284 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005285{
5286 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5287 eHalStatus status;
5288
5289 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5290 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005291 status = pmcSetGTKOffload( hHal, pRequest, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005292 sme_ReleaseGlobalLock( &pMac->sme );
5293 }
5294
5295 return (status);
5296}
5297
5298/* ---------------------------------------------------------------------------
5299 \fn sme_GetGTKOffload
5300 \brief API to get GTK offload information.
5301 \param hHal - The handle returned by macOpen.
5302 \param pRequest - Pointer to the GTK offload response.
5303 \return eHalStatus
5304 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005305eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
5306 void *callbackContext, tANI_U8 sessionId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005307{
5308 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5309 eHalStatus status;
5310
5311 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5312 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005313 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 sme_ReleaseGlobalLock( &pMac->sme );
5315 }
5316
5317 return (status);
5318}
5319#endif // WLAN_FEATURE_GTK_OFFLOAD
5320
5321/* ---------------------------------------------------------------------------
5322 \fn sme_SetKeepAlive
5323 \brief API to set the Keep Alive feature.
5324 \param hHal - The handle returned by macOpen.
5325 \param pRequest - Pointer to the Keep Alive request.
5326 \return eHalStatus
5327 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005328eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
5329 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005330{
5331 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5332 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5334 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005335 status = pmcSetKeepAlive (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 sme_ReleaseGlobalLock( &pMac->sme );
5337 }
5338
5339 return (status);
5340}
5341
5342#ifdef FEATURE_WLAN_SCAN_PNO
5343/* ---------------------------------------------------------------------------
5344 \fn sme_SetPreferredNetworkList
5345 \brief API to set the Preferred Network List Offload feature.
5346 \param hHal - The handle returned by macOpen.
5347 \param pRequest - Pointer to the offload request.
5348 \return eHalStatus
5349 ---------------------------------------------------------------------------*/
5350eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
5351{
5352 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5353 eHalStatus status;
5354
5355 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5356 {
5357 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
5358 sme_ReleaseGlobalLock( &pMac->sme );
5359 }
5360
5361 return (status);
5362}
5363
5364eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
5365{
5366 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5367 eHalStatus status;
5368
5369 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5370 {
5371 pmcSetRssiFilter(hHal, rssiThreshold);
5372 sme_ReleaseGlobalLock( &pMac->sme );
5373 }
5374
5375 return (status);
5376}
5377
5378#endif // FEATURE_WLAN_SCAN_PNO
5379
5380eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams)
5381{
5382 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5383 eHalStatus status;
5384
5385 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5386 {
5387 pmcSetPowerParams(hHal, pwParams);
5388 sme_ReleaseGlobalLock( &pMac->sme );
5389 }
5390
5391 return (status);
5392}
5393
5394/* ---------------------------------------------------------------------------
5395 \fn sme_AbortMacScan
5396 \brief API to cancel MAC scan.
5397 \param hHal - The handle returned by macOpen.
5398 \return VOS_STATUS
5399 VOS_STATUS_E_FAILURE - failure
5400 VOS_STATUS_SUCCESS success
5401 ---------------------------------------------------------------------------*/
5402eHalStatus sme_AbortMacScan(tHalHandle hHal)
5403{
5404 eHalStatus status;
5405 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5406
5407 status = sme_AcquireGlobalLock( &pMac->sme );
5408 if ( HAL_STATUS_SUCCESS( status ) )
5409 {
5410 status = csrScanAbortMacScan(pMac);
5411
5412 sme_ReleaseGlobalLock( &pMac->sme );
5413 }
5414
5415 return ( status );
5416}
5417
5418/* ----------------------------------------------------------------------------
5419 \fn sme_GetOperationChannel
5420 \brief API to get current channel on which STA is parked
5421 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005422 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 \returns eHAL_STATUS_SUCCESS
5424 eHAL_STATUS_FAILURE
5425-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005426eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005427{
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5429 tCsrRoamSession *pSession;
5430
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005431 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005433 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005434
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005435 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
5436 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005437#ifdef WLAN_SOFTAP_FEATURE
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005438 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
5439#endif
5440 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
5441 {
5442 *pChannel =pSession->connectedProfile.operationChannel;
5443 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 }
5445 }
5446 return eHAL_STATUS_FAILURE;
5447}// sme_GetOperationChannel ends here
5448
5449#ifdef WLAN_FEATURE_P2P
5450/* ---------------------------------------------------------------------------
5451
5452 \fn sme_RegisterMgtFrame
5453
5454 \brief To register managment frame of specified type and subtype.
5455 \param frameType - type of the frame that needs to be passed to HDD.
5456 \param matchData - data which needs to be matched before passing frame
5457 to HDD.
5458 \param matchDataLen - Length of matched data.
5459 \return eHalStatus
5460 -------------------------------------------------------------------------------*/
5461eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5462 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5463{
5464 eHalStatus status = eHAL_STATUS_SUCCESS;
5465 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5466
5467 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5468 {
5469 tSirRegisterMgmtFrame *pMsg;
5470 tANI_U16 len;
5471 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005472
5473 if(!pSession)
5474 {
5475 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5476 return eHAL_STATUS_FAILURE;
5477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005478
5479 if( !pSession->sessionActive )
5480 {
5481 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005482 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 sme_ReleaseGlobalLock( &pMac->sme );
5484 return eHAL_STATUS_FAILURE;
5485 }
5486
5487 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5488
5489 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5490 if(HAL_STATUS_SUCCESS(status))
5491 {
5492 palZeroMemory(pMac->hHdd, pMsg, len);
5493 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5494 pMsg->length = len;
5495 pMsg->sessionId = sessionId;
5496 pMsg->registerFrame = VOS_TRUE;
5497 pMsg->frameType = frameType;
5498 pMsg->matchLen = matchLen;
5499 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5500 status = palSendMBMessage(pMac->hHdd, pMsg);
5501 }
5502 sme_ReleaseGlobalLock( &pMac->sme );
5503 }
5504 return status;
5505}
5506
5507/* ---------------------------------------------------------------------------
5508
5509 \fn sme_DeregisterMgtFrame
5510
5511 \brief To De-register managment frame of specified type and subtype.
5512 \param frameType - type of the frame that needs to be passed to HDD.
5513 \param matchData - data which needs to be matched before passing frame
5514 to HDD.
5515 \param matchDataLen - Length of matched data.
5516 \return eHalStatus
5517 -------------------------------------------------------------------------------*/
5518eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5519 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5520{
5521 eHalStatus status = eHAL_STATUS_SUCCESS;
5522 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5523
5524 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5525 {
5526 tSirRegisterMgmtFrame *pMsg;
5527 tANI_U16 len;
5528 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005529
5530 if(!pSession)
5531 {
5532 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5533 return eHAL_STATUS_FAILURE;
5534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005535
5536 if( !pSession->sessionActive )
5537 {
5538 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005539 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 sme_ReleaseGlobalLock( &pMac->sme );
5541 return eHAL_STATUS_FAILURE;
5542 }
5543
5544 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5545
5546 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5547 if(HAL_STATUS_SUCCESS(status))
5548 {
5549 palZeroMemory(pMac->hHdd, pMsg, len);
5550 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5551 pMsg->length = len;
5552 pMsg->registerFrame = VOS_FALSE;
5553 pMsg->frameType = frameType;
5554 pMsg->matchLen = matchLen;
5555 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5556 status = palSendMBMessage(pMac->hHdd, pMsg);
5557 }
5558 sme_ReleaseGlobalLock( &pMac->sme );
5559 }
5560 return status;
5561}
5562
5563/* ---------------------------------------------------------------------------
5564 \fn sme_RemainOnChannel
5565 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
5566 \param hHal - The handle returned by macOpen.
5567 \param pRequest - channel
5568 \param duration - duration in ms
5569 \param callback - HDD registered callback to process reaminOnChannelRsp
5570 \param context - HDD Callback param
5571 \return eHalStatus
5572 ---------------------------------------------------------------------------*/
5573
5574eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
5575 tANI_U8 channel, tANI_U32 duration,
5576 remainOnChanCallback callback,
5577 void *pContext)
5578{
5579 eHalStatus status = eHAL_STATUS_SUCCESS;
5580 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5581
5582 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5583 {
5584 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext
5585#ifdef WLAN_FEATURE_P2P_INTERNAL
5586 , eP2PRemainOnChnReasonUnknown
5587#endif
5588 );
5589 sme_ReleaseGlobalLock( &pMac->sme );
5590 }
5591 return(status);
5592}
5593
5594/* ---------------------------------------------------------------------------
5595 \fn sme_ReportProbeReq
5596 \brief API to enable/disable forwarding of probeReq to apps in p2p.
5597 \param hHal - The handle returned by macOpen.
5598 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
5599 \return eHalStatus
5600 ---------------------------------------------------------------------------*/
5601
5602#ifndef WLAN_FEATURE_CONCURRENT_P2P
5603eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
5604{
5605 eHalStatus status = eHAL_STATUS_SUCCESS;
5606 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5607
5608 do
5609 {
5610 //acquire the lock for the sme object
5611 status = sme_AcquireGlobalLock(&pMac->sme);
5612 if(HAL_STATUS_SUCCESS(status))
5613 {
5614 /* call set in context */
5615 pMac->p2pContext.probeReqForwarding = flag;
5616 //release the lock for the sme object
5617 sme_ReleaseGlobalLock( &pMac->sme );
5618 }
5619 } while(0);
5620
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005621 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005622
5623 return(status);
5624}
5625
5626/* ---------------------------------------------------------------------------
5627 \fn sme_updateP2pIe
5628 \brief API to set the P2p Ie in p2p context
5629 \param hHal - The handle returned by macOpen.
5630 \param p2pIe - Ptr to p2pIe from HDD.
5631 \param p2pIeLength: length of p2pIe
5632 \return eHalStatus
5633 ---------------------------------------------------------------------------*/
5634
5635eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
5636{
5637 eHalStatus status = eHAL_STATUS_SUCCESS;
5638 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5639
5640 //acquire the lock for the sme object
5641 status = sme_AcquireGlobalLock(&pMac->sme);
5642 if(HAL_STATUS_SUCCESS(status))
5643 {
5644 if(NULL != pMac->p2pContext.probeRspIe){
5645 vos_mem_free(pMac->p2pContext.probeRspIe);
5646 pMac->p2pContext.probeRspIeLength = 0;
5647 }
5648
5649 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
5650 if (NULL == pMac->p2pContext.probeRspIe)
5651 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005652 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 pMac->p2pContext.probeRspIeLength = 0;
5654 status = eHAL_STATUS_FAILURE;
5655 }
5656 else
5657 {
5658 pMac->p2pContext.probeRspIeLength = p2pIeLength;
5659
5660 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
5661 pMac->p2pContext.probeRspIe,
5662 pMac->p2pContext.probeRspIeLength );
5663 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
5664 p2pIeLength);
5665 }
5666
5667 //release the lock for the sme object
5668 sme_ReleaseGlobalLock( &pMac->sme );
5669 }
5670
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005671 smsLog(pMac, LOG2, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005672
5673 return(status);
5674}
5675#endif
5676
5677/* ---------------------------------------------------------------------------
5678 \fn sme_sendAction
5679 \brief API to send action frame from supplicant.
5680 \param hHal - The handle returned by macOpen.
5681 \return eHalStatus
5682 ---------------------------------------------------------------------------*/
5683
5684eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07005685 const tANI_U8 *pBuf, tANI_U32 len,
5686 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07005687{
5688 eHalStatus status = eHAL_STATUS_SUCCESS;
5689 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5690
5691 //acquire the lock for the sme object
5692 status = sme_AcquireGlobalLock(&pMac->sme);
5693 if(HAL_STATUS_SUCCESS(status))
5694 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005695 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 //release the lock for the sme object
5697 sme_ReleaseGlobalLock( &pMac->sme );
5698 }
5699
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005700 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005701
5702 return(status);
5703}
5704
5705eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
5706{
5707 eHalStatus status = eHAL_STATUS_SUCCESS;
5708 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5709
5710 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5711 {
5712 status = p2pCancelRemainOnChannel (hHal, sessionId);
5713 sme_ReleaseGlobalLock( &pMac->sme );
5714 }
5715 return(status);
5716}
5717
5718//Power Save Related
5719eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
5720{
5721 eHalStatus status = eHAL_STATUS_SUCCESS;
5722 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5723
5724 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5725 {
5726 status = p2pSetPs (hHal, data);
5727 sme_ReleaseGlobalLock( &pMac->sme );
5728 }
5729 return(status);
5730}
5731
5732#endif
5733
5734/* ---------------------------------------------------------------------------
5735
5736 \fn sme_ConfigureRxpFilter
5737
5738 \brief
5739 SME will pass this request to lower mac to set/reset the filter on RXP for
5740 multicast & broadcast traffic.
5741
5742 \param
5743
5744 hHal - The handle returned by macOpen.
5745
5746 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
5747 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
5748 on this param. In future we can use this as a mask to set various types of
5749 filters as suggested below:
5750 FILTER_ALL_MULTICAST:
5751 FILTER_ALL_BROADCAST:
5752 FILTER_ALL_MULTICAST_BROADCAST:
5753
5754
5755 \return eHalStatus
5756
5757
5758--------------------------------------------------------------------------- */
5759eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
5760 tpSirWlanSetRxpFilters wlanRxpFilterParam)
5761{
5762 eHalStatus status = eHAL_STATUS_SUCCESS;
5763 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5764 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5765 vos_msg_t vosMessage;
5766
5767 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5768 {
5769 /* serialize the req through MC thread */
5770 vosMessage.bodyptr = wlanRxpFilterParam;
5771 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
5772 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5773 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5774 {
5775 status = eHAL_STATUS_FAILURE;
5776 }
5777 sme_ReleaseGlobalLock( &pMac->sme );
5778 }
5779 return(status);
5780}
5781
5782#ifdef FEATURE_WLAN_INTEGRATED_SOC
5783/* ---------------------------------------------------------------------------
5784
5785 \fn sme_ConfigureSuspendInd
5786
5787 \brief
5788 SME will pass this request to lower mac to Indicate that the wlan needs to
5789 be suspended
5790
5791 \param
5792
5793 hHal - The handle returned by macOpen.
5794
5795 wlanSuspendParam- Depicts the wlan suspend params
5796
5797
5798 \return eHalStatus
5799
5800
5801--------------------------------------------------------------------------- */
5802eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
5803 tpSirWlanSuspendParam wlanSuspendParam)
5804{
5805 eHalStatus status = eHAL_STATUS_SUCCESS;
5806 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5807 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5808 vos_msg_t vosMessage;
5809
5810 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5811 {
5812 /* serialize the req through MC thread */
5813 vosMessage.bodyptr = wlanSuspendParam;
5814 vosMessage.type = WDA_WLAN_SUSPEND_IND;
5815 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5816 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5817 {
5818 status = eHAL_STATUS_FAILURE;
5819 }
5820 sme_ReleaseGlobalLock( &pMac->sme );
5821 }
5822 return(status);
5823}
5824
5825/* ---------------------------------------------------------------------------
5826
5827 \fn sme_ConfigureResumeReq
5828
5829 \brief
5830 SME will pass this request to lower mac to Indicate that the wlan needs to
5831 be Resumed
5832
5833 \param
5834
5835 hHal - The handle returned by macOpen.
5836
5837 wlanResumeParam- Depicts the wlan resume params
5838
5839
5840 \return eHalStatus
5841
5842
5843--------------------------------------------------------------------------- */
5844eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
5845 tpSirWlanResumeParam wlanResumeParam)
5846{
5847 eHalStatus status = eHAL_STATUS_SUCCESS;
5848 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5849 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5850 vos_msg_t vosMessage;
5851
5852 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5853 {
5854 /* serialize the req through MC thread */
5855 vosMessage.bodyptr = wlanResumeParam;
5856 vosMessage.type = WDA_WLAN_RESUME_REQ;
5857 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5858 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5859 {
5860 status = eHAL_STATUS_FAILURE;
5861 }
5862 sme_ReleaseGlobalLock( &pMac->sme );
5863 }
5864 return(status);
5865}
5866
5867#endif
5868/* ---------------------------------------------------------------------------
5869
5870 \fn sme_GetInfraSessionId
5871
5872 \brief To get the session ID for infra session, if connected
5873 This is a synchronous API.
5874
5875 \param hHal - The handle returned by macOpen.
5876
5877 \return sessionid, -1 if infra session is not connected
5878
5879 -------------------------------------------------------------------------------*/
5880tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
5881{
5882 eHalStatus status = eHAL_STATUS_FAILURE;
5883 tANI_S8 sessionid = -1;
5884 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5885
5886 status = sme_AcquireGlobalLock( &pMac->sme );
5887 if ( HAL_STATUS_SUCCESS( status ) )
5888 {
5889
5890 sessionid = csrGetInfraSessionId( pMac);
5891
5892 sme_ReleaseGlobalLock( &pMac->sme );
5893 }
5894
5895 return (sessionid);
5896}
5897
5898/* ---------------------------------------------------------------------------
5899
5900 \fn sme_GetInfraOperationChannel
5901
5902 \brief To get the operating channel for infra session, if connected
5903 This is a synchronous API.
5904
5905 \param hHal - The handle returned by macOpen.
5906 \param sessionId - the sessionId returned by sme_OpenSession.
5907
5908 \return operating channel, 0 if infra session is not connected
5909
5910 -------------------------------------------------------------------------------*/
5911tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
5912{
5913 eHalStatus status = eHAL_STATUS_FAILURE;
5914 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5915 tANI_U8 channel = 0;
5916 status = sme_AcquireGlobalLock( &pMac->sme );
5917 if ( HAL_STATUS_SUCCESS( status ) )
5918 {
5919
5920 channel = csrGetInfraOperationChannel( pMac, sessionId);
5921
5922 sme_ReleaseGlobalLock( &pMac->sme );
5923 }
5924
5925 return (channel);
5926}
5927
5928//This routine will return poerating channel on which other BSS is operating to be used for concurrency mode.
5929//If other BSS is not up or not connected it will return 0
5930tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
5931{
5932 eHalStatus status = eHAL_STATUS_FAILURE;
5933 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5934 tANI_U8 channel = 0;
5935 status = sme_AcquireGlobalLock( &pMac->sme );
5936 if ( HAL_STATUS_SUCCESS( status ) )
5937 {
5938
5939 channel = csrGetConcurrentOperationChannel( pMac );
5940 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005941 " Other Concurrent Channel = %d", __func__,channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 sme_ReleaseGlobalLock( &pMac->sme );
5943 }
5944
5945 return (channel);
5946}
5947
5948#ifdef FEATURE_WLAN_SCAN_PNO
5949/******************************************************************************
5950*
5951* Name: sme_PreferredNetworkFoundInd
5952*
5953* Description:
5954* Invoke Preferred Network Found Indication
5955*
5956* Parameters:
5957* hHal - HAL handle for device
5958* pMsg - found network description
5959*
5960* Returns: eHalStatus
5961*
5962******************************************************************************/
5963eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
5964{
5965 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5966 eHalStatus status = eHAL_STATUS_SUCCESS;
5967 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
5968
5969 if (NULL == pMsg)
5970 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005971 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 status = eHAL_STATUS_FAILURE;
5973 }
5974 else
5975 {
5976 if (pPrefNetworkFoundInd->ssId.length > 0)
5977 {
5978 smsLog(pMac, LOG1, "Preferred Network Found Indication in %s(), SSID=%s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005979 __func__, pPrefNetworkFoundInd->ssId.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005980
5981
5982 /* Call Preferred Netowrk Found Indication callback routine. */
5983 if (pMac->pmc.prefNetwFoundCB != NULL)
5984 {
5985 pMac->pmc.prefNetwFoundCB(pMac->pmc.preferredNetworkFoundIndCallbackContext, pPrefNetworkFoundInd);
5986 }
5987
5988 }
5989 else
5990 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005991 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 status = eHAL_STATUS_FAILURE;
5993 }
5994 }
5995
5996
5997 return(status);
5998}
5999
6000#endif // FEATURE_WLAN_SCAN_PNO
6001
6002
6003eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
6004{
6005 eHalStatus status = eHAL_STATUS_FAILURE;
6006 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6007
6008 status = sme_AcquireGlobalLock( &pMac->sme );
6009 if ( HAL_STATUS_SUCCESS( status ) )
6010 {
6011 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
6012 sme_ReleaseGlobalLock( &pMac->sme );
6013 }
6014
6015 return (status);
6016}
6017
6018
6019/* ---------------------------------------------------------------------------
6020
6021 \fn sme_SetTxPerTracking
6022
6023 \brief Set Tx PER tracking configuration parameters
6024
6025 \param hHal - The handle returned by macOpen.
6026 \param pTxPerTrackingConf - Tx PER configuration parameters
6027
6028 \return eHalStatus
6029
6030 -------------------------------------------------------------------------------*/
6031eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
6032 void (*pCallbackfn) (void *pCallbackContext),
6033 void *pCallbackContext,
6034 tpSirTxPerTrackingParam pTxPerTrackingParam)
6035{
6036 vos_msg_t msg;
6037 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
6038 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6039
6040 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6041 {
6042 pMac->sme.pTxPerHitCallback = pCallbackfn;
6043 pMac->sme.pTxPerHitCbContext = pCallbackContext;
6044 sme_ReleaseGlobalLock( &pMac->sme );
6045 }
6046
6047 // free this memory in failure case or WDA request callback function
6048 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
6049 if (NULL == pTxPerTrackingParamReq)
6050 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006051 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 -07006052 return eHAL_STATUS_FAILURE;
6053 }
6054
6055 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam, sizeof(tSirTxPerTrackingParam));
6056 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
6057 msg.reserved = 0;
6058 msg.bodyptr = pTxPerTrackingParamReq;
6059
6060 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6061 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006062 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 -07006063 vos_mem_free(pTxPerTrackingParamReq);
6064 return eHAL_STATUS_FAILURE;
6065 }
6066
6067 return eHAL_STATUS_SUCCESS;
6068}
6069
6070/* ---------------------------------------------------------------------------
6071
6072 \fn sme_HandleChangeCountryCode
6073
6074 \brief Change Country code, Reg Domain and channel list
6075
6076 \details Country Code Priority
6077 0 = 11D > Configured Country > NV
6078 1 = Configured Country > 11D > NV
6079 If Supplicant country code is priority than 11d is disabled.
6080 If 11D is enabled, we update the country code after every scan.
6081 Hence when Supplicant country code is priority, we don't need 11D info.
6082 Country code from Supplicant is set as current courtry code.
6083 User can send reset command XX (instead of country code) to reset the
6084 country code to default values which is read from NV.
6085 In case of reset, 11D is enabled and default NV code is Set as current country code
6086 If 11D is priority,
6087 Than Supplicant country code code is set to default code. But 11D code is set as current country code
6088
6089 \param pMac - The handle returned by macOpen.
6090 \param pMsgBuf - MSG Buffer
6091
6092 \return eHalStatus
6093
6094 -------------------------------------------------------------------------------*/
6095eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
6096{
6097 eHalStatus status = eHAL_STATUS_SUCCESS;
6098 tAniChangeCountryCodeReq *pMsg;
6099 v_REGDOMAIN_t domainIdIoctl;
6100 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6101 static uNvTables nvTables;
6102 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
6103
6104
6105 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
6106 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
6107 {
6108 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6109
6110 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
6111
6112 /* read the country code from NV and use it */
6113 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
6114 {
6115 palCopyMemory( pMac->hHdd, pMsg->countryCode , nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
6116 }
6117 else
6118 {
6119 status = eHAL_STATUS_FAILURE;
6120 return status;
6121 }
6122 }
6123 else
6124 {
6125 /* if Supplicant country code has priority, disable 11d */
6126 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority)
6127 {
6128 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
6129 }
6130 }
6131
6132 /* WEXT set country code means
6133 * 11D should be supported?
6134 * 11D Channel should be enforced?
6135 * 11D Country code should be matched?
6136 * 11D Reg Domian should be matched?
6137 * Country string changed */
6138 if(pMac->roam.configParam.Is11dSupportEnabled &&
6139 pMac->roam.configParam.fEnforce11dChannels &&
6140 pMac->roam.configParam.fEnforceCountryCodeMatch &&
6141 pMac->roam.configParam.fEnforceDefaultDomain &&
6142 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
6143 {
6144 /* All 11D related options are already enabled
6145 * Country string is not changed
6146 * Do not need do anything for country code change request */
6147 return eHAL_STATUS_SUCCESS;
6148 }
6149
6150 /* Set Current Country code and Current Regulatory domain */
6151 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
6152 if(eHAL_STATUS_SUCCESS != status)
6153 {
6154 /* Supplicant country code failed. So give 11D priority */
6155 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6156 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
6157 return status;
6158 }
6159
6160 /* purge current scan results
6161 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).
6162 Looks like a bug in current scan sequence.
6163 */
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07006164 csrScanFlushResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006165
6166 /* overwrite the defualt country code */
6167 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault, pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
6168
6169 /* Get Domain ID from country code */
6170 status = csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent,(v_REGDOMAIN_t *) &domainIdIoctl );
6171 if ( status != eHAL_STATUS_SUCCESS )
6172 {
6173 smsLog( pMac, LOGE, FL(" fail to get regId %d\n"), domainIdIoctl );
6174 return status;
6175 }
6176
6177 status = WDA_SetRegDomain(pMac, domainIdIoctl);
6178
6179 if ( status != eHAL_STATUS_SUCCESS )
6180 {
6181 smsLog( pMac, LOGE, FL(" fail to set regId %d\n"), domainIdIoctl );
6182 return status;
6183 }
6184
6185 /* set to default domain ID */
6186 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
6187
6188 /* get the channels based on new cc */
6189 status = csrInitGetChannels( pMac );
6190
6191 if ( status != eHAL_STATUS_SUCCESS )
6192 {
6193 smsLog( pMac, LOGE, FL(" fail to get Channels \n"));
6194 return status;
6195 }
6196
6197 /* reset info based on new cc, and we are done */
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08006198 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 if( pMsg->changeCCCallback )
6200 {
6201 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
6202 }
6203
6204 return eHAL_STATUS_SUCCESS;
6205}
6206
6207#ifdef WLAN_FEATURE_PACKET_FILTERING
6208eHalStatus sme_8023MulticastList (tHalHandle hHal, tpSirRcvFltMcAddrList pMulticastAddrs)
6209{
6210 tpSirRcvFltMcAddrList pRequestBuf;
6211 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006212 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6213 tANI_U8 sessionId = 0;
6214 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006215
6216 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006217 "ulMulticastAddrCnt=%d, multicastAddr[0]=%d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 pMulticastAddrs->ulMulticastAddrCnt,
6219 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07006220
6221 /*
6222 *Find the connected Infra / P2P_client connected session
6223 */
6224 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
6225 {
6226 if( CSR_IS_SESSION_VALID( pMac, sessionId ) &&
6227 ( csrIsConnStateInfra( pMac, sessionId )) )
6228 {
6229 pSession = CSR_GET_SESSION( pMac, sessionId );
6230 }
6231 }
6232
6233 if(pSession == NULL )
6234 {
6235 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Unable to find "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006236 "the right session", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07006237 return eHAL_STATUS_FAILURE;
6238 }
6239
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6241 if (NULL == pRequestBuf)
6242 {
6243 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006244 "allocate memory for 8023 Multicast List request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 return eHAL_STATUS_FAILED_ALLOC;
6246 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006247
6248 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6249 {
6250 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006251 "indication as we are not connected", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006252 vos_mem_free(pRequestBuf);
6253 return eHAL_STATUS_FAILURE;
6254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
6256
Jeff Johnsone7245742012-09-05 17:12:55 -07006257 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6258 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
6259 sizeof(tSirMacAddr));
6260
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 msg.type = WDA_8023_MULTICAST_LIST_REQ;
6262 msg.reserved = 0;
6263 msg.bodyptr = pRequestBuf;
6264 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6265 {
6266 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006267 "post WDA_8023_MULTICAST_LIST message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 vos_mem_free(pRequestBuf);
6269 return eHAL_STATUS_FAILURE;
6270 }
6271
6272 return eHAL_STATUS_SUCCESS;
6273}
6274
Jeff Johnsone7245742012-09-05 17:12:55 -07006275eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
6276 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006277{
6278 tpSirRcvPktFilterCfgType pRequestBuf;
6279 v_SINT_t allocSize;
6280 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006281 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6282 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006283 v_U8_t idx=0;
6284
6285 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006286 "filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006287 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
6288
Madan Mohan Koyyalamudid4029622012-10-18 20:30:17 -07006289 allocSize = sizeof(tSirRcvPktFilterCfgType);
6290
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 pRequestBuf = vos_mem_malloc(allocSize);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006292
6293 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 {
6295 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006296 "allocate memory for Receive Filter Set Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 return eHAL_STATUS_FAILED_ALLOC;
6298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006299
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006300 if( NULL == pSession )
6301 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006302 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Session Not found ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006303 vos_mem_free(pRequestBuf);
6304 return eHAL_STATUS_FAILURE;
6305 }
6306
6307 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6308 {
6309 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006310 "indication as we are not connected", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006311 vos_mem_free(pRequestBuf);
6312 return eHAL_STATUS_FAILURE;
6313 }
6314
6315 vos_mem_copy( pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6316 vos_mem_copy( pRcvPktFilterCfg->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006317 sizeof(tSirMacAddr));
6318
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006319 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
6320
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
6322 msg.reserved = 0;
6323 msg.bodyptr = pRequestBuf;
6324
6325 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6326 "FT %d FID %d ",
6327 pRequestBuf->filterType, pRequestBuf->filterId);
6328
6329 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6330 "params %d CT %d",
6331 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
6332
6333 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
6334 {
6335
6336 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6337 "Proto %d Comp Flag %d \n",
6338 pRequestBuf->paramsData[idx].protocolLayer,
6339 pRequestBuf->paramsData[idx].cmpFlag);
6340
6341 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6342 "Data Offset %d Data Len %d\n",
6343 pRequestBuf->paramsData[idx].dataOffset,
6344 pRequestBuf->paramsData[idx].dataLength);
6345
6346 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6347 "CData: %d:%d:%d:%d:%d:%d\n",
6348 pRequestBuf->paramsData[idx].compareData[0],
6349 pRequestBuf->paramsData[idx].compareData[1],
6350 pRequestBuf->paramsData[idx].compareData[2],
6351 pRequestBuf->paramsData[idx].compareData[3],
6352 pRequestBuf->paramsData[idx].compareData[4],
6353 pRequestBuf->paramsData[idx].compareData[5]);
6354
6355 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6356 "MData: %d:%d:%d:%d:%d:%d\n",
6357 pRequestBuf->paramsData[idx].dataMask[0],
6358 pRequestBuf->paramsData[idx].dataMask[1],
6359 pRequestBuf->paramsData[idx].dataMask[2],
6360 pRequestBuf->paramsData[idx].dataMask[3],
6361 pRequestBuf->paramsData[idx].dataMask[4],
6362 pRequestBuf->paramsData[idx].dataMask[5]);
6363
6364 }
6365
6366 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6367 {
6368 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006369 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 vos_mem_free(pRequestBuf);
6371 return eHAL_STATUS_FAILURE;
6372 }
6373
6374 return eHAL_STATUS_SUCCESS;
6375}
6376
6377eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
6378 FilterMatchCountCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006379 void *callbackContext,
6380 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006381{
6382 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6383 eHalStatus status;
6384
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006385 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006386
6387 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
6388 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006389 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 sme_ReleaseGlobalLock( &pMac->sme );
6391 }
6392
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006393 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006394
6395 return (status);
6396}
6397
Jeff Johnsone7245742012-09-05 17:12:55 -07006398eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
6399 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006400{
6401 tpSirRcvFltPktClearParam pRequestBuf;
6402 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006403 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6404 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006405
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006406 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 pRcvFltPktClearParam->filterId);
6408
6409 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006410 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 {
6412 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6413 "%s: Not able to allocate memory for Receive Filter "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006414 "Clear Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 return eHAL_STATUS_FAILED_ALLOC;
6416 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006417 if( NULL == pSession )
6418 {
6419 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006420 "%s: Session Not find ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006421 vos_mem_free(pRequestBuf);
6422 return eHAL_STATUS_FAILURE;
6423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006424
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006425 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6426 {
6427 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006428 "indication as we are not connected", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006429 vos_mem_free(pRequestBuf);
6430 return eHAL_STATUS_FAILURE;
6431 }
6432
6433 vos_mem_copy( pRcvFltPktClearParam->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6434 vos_mem_copy( pRcvFltPktClearParam->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006435 sizeof(tSirMacAddr));
6436
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006437 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
6438
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
6440 msg.reserved = 0;
6441 msg.bodyptr = pRequestBuf;
6442 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6443 {
6444 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006445 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 vos_mem_free(pRequestBuf);
6447 return eHAL_STATUS_FAILURE;
6448 }
6449
6450 return eHAL_STATUS_SUCCESS;
6451}
6452#endif // WLAN_FEATURE_PACKET_FILTERING
6453
6454/* ---------------------------------------------------------------------------
6455 \fn sme_PreChannelSwitchIndFullPowerCB
6456 \brief call back function for the PMC full power request because of pre
6457 channel switch.
6458 \param callbackContext
6459 \param status
6460 ---------------------------------------------------------------------------*/
6461void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
6462 eHalStatus status)
6463{
6464 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
6465 tSirMbMsg *pMsg;
6466 tANI_U16 msgLen;
6467
6468 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
6469 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
6470 if(HAL_STATUS_SUCCESS(status))
6471 {
6472 palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen);
6473 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
6474 pMsg->msgLen = pal_cpu_to_be16(msgLen);
6475 status = palSendMBMessage(pMac->hHdd, pMsg);
6476 }
6477
6478 return;
6479}
6480
6481/* ---------------------------------------------------------------------------
6482 \fn sme_HandlePreChannelSwitchInd
6483 \brief Processes the indcation from PE for pre-channel switch.
6484 \param hHal
6485 \- The handle returned by macOpen. return eHalStatus
6486 ---------------------------------------------------------------------------*/
6487eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
6488{
6489 eHalStatus status = eHAL_STATUS_FAILURE;
6490 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6491 status = sme_AcquireGlobalLock( &pMac->sme );
6492 if ( HAL_STATUS_SUCCESS( status ) )
6493 {
6494 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
6495 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
6496 sme_ReleaseGlobalLock( &pMac->sme );
6497 }
6498
6499 return (status);
6500}
6501
6502/* ---------------------------------------------------------------------------
6503 \fn sme_HandlePostChannelSwitchInd
6504 \brief Processes the indcation from PE for post-channel switch.
6505 \param hHal
6506 \- The handle returned by macOpen. return eHalStatus
6507 ---------------------------------------------------------------------------*/
6508eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
6509{
6510 eHalStatus status = eHAL_STATUS_FAILURE;
6511 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6512
6513 status = sme_AcquireGlobalLock( &pMac->sme );
6514 if ( HAL_STATUS_SUCCESS( status ) )
6515 {
6516 status = pmcRequestBmps(hHal, NULL, NULL);
6517 sme_ReleaseGlobalLock( &pMac->sme );
6518 }
6519
6520 return (status);
6521}
6522
6523/* ---------------------------------------------------------------------------
6524
6525 \fn sme_IsChannelValid
6526
6527 \brief To check if the channel is valid for currently established domain
6528 This is a synchronous API.
6529
6530 \param hHal - The handle returned by macOpen.
6531 \param channel - channel to verify
6532
6533 \return TRUE/FALSE, TRUE if channel is valid
6534
6535 -------------------------------------------------------------------------------*/
6536tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
6537{
6538 eHalStatus status = eHAL_STATUS_FAILURE;
6539 tANI_BOOLEAN valid = FALSE;
6540 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6541
6542 status = sme_AcquireGlobalLock( &pMac->sme );
6543 if ( HAL_STATUS_SUCCESS( status ) )
6544 {
6545
6546 valid = csrRoamIsChannelValid( pMac, channel);
6547
6548 sme_ReleaseGlobalLock( &pMac->sme );
6549 }
6550
6551 return (valid);
6552}
6553
6554/* ---------------------------------------------------------------------------
6555 \fn sme_SetFreqBand
6556 \brief Used to set frequency band.
6557 \param hHal
6558 \eBand band value to be configured
6559 \- return eHalStatus
6560 -------------------------------------------------------------------------*/
6561eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
6562{
6563 eHalStatus status = eHAL_STATUS_FAILURE;
6564 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6565
6566 status = sme_AcquireGlobalLock( &pMac->sme );
6567 if ( HAL_STATUS_SUCCESS( status ) )
6568 {
6569 status = csrSetBand(hHal, eBand);
6570 sme_ReleaseGlobalLock( &pMac->sme );
6571 }
6572 return status;
6573}
6574
6575/* ---------------------------------------------------------------------------
6576 \fn sme_GetFreqBand
6577 \brief Used to get the current band settings.
6578 \param hHal
6579 \pBand pointer to hold band value
6580 \- return eHalStatus
6581 -------------------------------------------------------------------------*/
6582eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
6583{
6584 eHalStatus status = eHAL_STATUS_FAILURE;
6585 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6586
6587 status = sme_AcquireGlobalLock( &pMac->sme );
6588 if ( HAL_STATUS_SUCCESS( status ) )
6589 {
6590 *pBand = csrGetCurrentBand( hHal );
6591 sme_ReleaseGlobalLock( &pMac->sme );
6592 }
6593 return status;
6594}
6595
6596#ifdef WLAN_WAKEUP_EVENTS
6597/******************************************************************************
6598 \fn sme_WakeReasonIndCallback
6599
6600 \brief
6601 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
6602
6603 \param hHal - HAL handle for device
6604 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
6605
6606 \return eHalStatus
6607******************************************************************************/
6608eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
6609{
6610 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6611 eHalStatus status = eHAL_STATUS_SUCCESS;
6612 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
6613
6614 if (NULL == pMsg)
6615 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006616 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 status = eHAL_STATUS_FAILURE;
6618 }
6619 else
6620 {
6621 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback\n");
6622
6623 /* Call Wake Reason Indication callback routine. */
6624 if (pMac->pmc.wakeReasonIndCB != NULL)
6625 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
6626
6627 pMac->pmc.wakeReasonIndCB = NULL;
6628 pMac->pmc.wakeReasonIndCBContext = NULL;
6629
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006630 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __func__, pWakeReasonInd->ulReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 }
6632
6633 return(status);
6634}
6635#endif // WLAN_WAKEUP_EVENTS
6636
6637
6638/* ---------------------------------------------------------------------------
6639
6640 \fn sme_SetMaxTxPower
6641
6642 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
6643 not persist over reboots.
6644
6645 \param hHal
6646 \param pBssid BSSID to set the power cap for
6647 \param pBssid pSelfMacAddress self MAC Address
6648 \param pBssid power to set in dB
6649 \- return eHalStatus
6650
6651 -------------------------------------------------------------------------------*/
6652eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr pBssid,
6653 tSirMacAddr pSelfMacAddress, v_S7_t dB)
6654{
6655 vos_msg_t msg;
6656 tpMaxTxPowerParams pMaxTxParams = NULL;
6657
6658 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
6659 if (NULL == pMaxTxParams)
6660 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006661 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 -07006662 return eHAL_STATUS_FAILURE;
6663 }
6664
6665 vos_mem_copy(pMaxTxParams->bssId, pBssid, SIR_MAC_ADDR_LENGTH);
6666 vos_mem_copy(pMaxTxParams->selfStaMacAddr , pSelfMacAddress,
6667 SIR_MAC_ADDR_LENGTH);
6668 pMaxTxParams->power = dB;
6669
6670 msg.type = WDA_SET_MAX_TX_POWER_REQ;
6671 msg.reserved = 0;
6672 msg.bodyptr = pMaxTxParams;
6673
6674 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6675 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006676 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 -07006677 vos_mem_free(pMaxTxParams);
6678 return eHAL_STATUS_FAILURE;
6679 }
6680
6681 return eHAL_STATUS_SUCCESS;
6682}
6683
6684#ifdef WLAN_SOFTAP_FEATURE
6685/* ---------------------------------------------------------------------------
6686
6687 \fn sme_HideSSID
6688
6689 \brief hide/show SSID dynamically. Note: this setting will
6690 not persist over reboots.
6691
6692 \param hHal
6693 \param sessionId
6694 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
6695 \- return eHalStatus
6696
6697 -------------------------------------------------------------------------------*/
6698eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
6699{
6700 eHalStatus status = eHAL_STATUS_SUCCESS;
6701 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6702 tANI_U16 len;
6703
6704 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6705 {
6706 tpSirUpdateParams pMsg;
6707 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006708
6709 if(!pSession)
6710 {
6711 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6712 return eHAL_STATUS_FAILURE;
6713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006714
6715 if( !pSession->sessionActive )
6716 VOS_ASSERT(0);
6717
6718 /* Create the message and send to lim */
6719 len = sizeof(tSirUpdateParams);
6720 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
6721 if(HAL_STATUS_SUCCESS(status))
6722 {
6723 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirUpdateParams) );
6724 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
6725 pMsg->length = len;
6726 /* Data starts from here */
6727 pMsg->sessionId = sessionId;
6728 pMsg->ssidHidden = ssidHidden;
6729 status = palSendMBMessage(pMac->hHdd, pMsg);
6730 }
6731 sme_ReleaseGlobalLock( &pMac->sme );
6732 }
6733 return status;
6734}
6735#endif
6736
6737/* ---------------------------------------------------------------------------
6738
6739 \fn sme_SetTmLevel
6740 \brief Set Thermal Mitigation Level to RIVA
6741 \param hHal - The handle returned by macOpen.
6742 \param newTMLevel - new Thermal Mitigation Level
6743 \param tmMode - Thermal Mitigation handle mode, default 0
6744 \return eHalStatus
6745 ---------------------------------------------------------------------------*/
6746eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
6747{
6748 eHalStatus status = eHAL_STATUS_SUCCESS;
6749 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6750 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6751 vos_msg_t vosMessage;
6752 tAniSetTmLevelReq *setTmLevelReq = NULL;
6753
6754 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6755 {
6756 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
6757 if(NULL == setTmLevelReq)
6758 {
6759 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006760 "%s: Not able to allocate memory for sme_SetTmLevel", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 return eHAL_STATUS_FAILURE;
6762 }
6763
6764 setTmLevelReq->tmMode = tmMode;
6765 setTmLevelReq->newTmLevel = newTMLevel;
6766
6767 /* serialize the req through MC thread */
6768 vosMessage.bodyptr = setTmLevelReq;
6769 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
6770 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6771 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6772 {
6773 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006774 "%s: Post Set TM Level MSG fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 vos_mem_free(setTmLevelReq);
6776 status = eHAL_STATUS_FAILURE;
6777 }
6778 sme_ReleaseGlobalLock( &pMac->sme );
6779 }
6780 return(status);
6781}
6782
6783/*---------------------------------------------------------------------------
6784
6785 \brief sme_featureCapsExchange() - SME interface to exchange capabilities between
6786 Host and FW.
6787
6788 \param hHal - HAL handle for device
6789
6790 \return NONE
6791
6792---------------------------------------------------------------------------*/
6793void sme_featureCapsExchange( tHalHandle hHal)
6794{
6795 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
6796 WDA_featureCapsExchange(vosContext);
6797}
Jeff Johnsond13512a2012-07-17 11:42:19 -07006798
Yathish9f22e662012-12-10 14:21:35 -08006799/*---------------------------------------------------------------------------
6800
6801 \brief sme_disableFeatureCapablity() - SME interface to disable Active mode offload capablity
6802 in Host.
6803
6804 \param hHal - HAL handle for device
6805
6806 \return NONE
6807
6808---------------------------------------------------------------------------*/
6809void sme_disableFeatureCapablity(tANI_U8 feature_index)
6810{
6811 WDA_disableCapablityFeature(feature_index);
6812}
6813
6814
Jeff Johnsond13512a2012-07-17 11:42:19 -07006815
6816/* ---------------------------------------------------------------------------
6817
6818 \fn sme_GetDefaultCountryCode
6819
6820 \brief Get the default country code from NV
6821
6822 \param hHal
6823 \param pCountry
6824 \- return eHalStatus
6825
6826 -------------------------------------------------------------------------------*/
6827eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
6828{
6829 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6830 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
6831}
6832
6833/* ---------------------------------------------------------------------------
6834
6835 \fn sme_GetCurrentCountryCode
6836
6837 \brief Get the current country code
6838
6839 \param hHal
6840 \param pCountry
6841 \- return eHalStatus
6842
6843 -------------------------------------------------------------------------------*/
6844eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
6845{
6846 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6847 return csrGetCurrentCountryCode(pMac, pCountry);
6848}
6849
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006850/* ---------------------------------------------------------------------------
6851 \fn sme_transportDebug
6852 \brief Dynamically monitoring Transport channels
6853 Private IOCTL will querry transport channel status if driver loaded
Jeff Johnsonb88db982012-12-10 13:34:59 -08006854 \param displaySnapshot Display transport channel snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006855 \param toggleStallDetect Enable stall detect feature
6856 This feature will take effect to data performance
6857 Not integrate till fully verification
6858 \- return NONE
6859 -------------------------------------------------------------------------*/
6860void sme_transportDebug
6861(
6862 v_BOOL_t displaySnapshot,
6863 v_BOOL_t toggleStallDetect
6864)
6865{
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07006866 WDA_TransportChannelDebug(displaySnapshot, toggleStallDetect);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07006867}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08006868
6869#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
6870/* ---------------------------------------------------------------------------
6871 \fn sme_UpdateRoamPrefer5GHz
6872 \brief enable/disable Roam prefer 5G runtime option
6873 This function is called through dynamic setConfig callback function
6874 to configure the Roam prefer 5G runtime option
6875 \param hHal - HAL handle for device
6876 \param nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6877 \- return Success or failure
6878 -------------------------------------------------------------------------*/
6879
6880eHalStatus sme_UpdateRoamPrefer5GHz(tHalHandle hHal, v_BOOL_t nRoamPrefer5GHz)
6881{
6882 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6883 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6884 return(eHAL_STATUS_SUCCESS);
6885}
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08006886
6887/* ---------------------------------------------------------------------------
6888 \fn sme_UpdateImmediateRoamRssiDiff
6889 \brief Update nImmediateRoamRssiDiff
6890 This function is called through dynamic setConfig callback function
6891 to configure nImmediateRoamRssiDiff
6892 Usage: adb shell iwpriv wlan0 setConfig gImmediateRoamRssiDiff=[0 .. 125]
6893 \param hHal - HAL handle for device
6894 \param nImmediateRoamRssiDiff - minimum rssi difference between potential
6895 candidate and current AP.
6896 \- return Success or failure
6897 -------------------------------------------------------------------------*/
6898
6899eHalStatus sme_UpdateImmediateRoamRssiDiff(tHalHandle hHal, v_U8_t nImmediateRoamRssiDiff)
6900{
6901 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6902 pMac->roam.configParam.nImmediateRoamRssiDiff = nImmediateRoamRssiDiff;
6903 return(eHAL_STATUS_SUCCESS);
6904}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08006905
6906/*--------------------------------------------------------------------------
6907 \brief sme_UpdateFastTransitionEnabled() - enable/disable Fast Transition support at runtime
6908 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6909 isFastTransitionEnabled.
6910 This is a synchronuous call
6911 \param hHal - The handle returned by macOpen.
6912 \return eHAL_STATUS_SUCCESS - SME update isFastTransitionEnabled config successfully.
6913 Other status means SME is failed to update isFastTransitionEnabled.
6914 \sa
6915 --------------------------------------------------------------------------*/
6916eHalStatus sme_UpdateFastTransitionEnabled(tHalHandle hHal,
6917 v_BOOL_t isFastTransitionEnabled)
6918{
6919 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6920
6921 pMac->roam.configParam.isFastTransitionEnabled = isFastTransitionEnabled;
6922 return eHAL_STATUS_SUCCESS;
6923}
6924#endif /* (WLAN_FEATURE_VOWIFI_11R) || (FEATURE_WLAN_CCX) || (FEATURE_WLAN_LFR) */
6925
6926#ifdef FEATURE_WLAN_LFR
6927/*--------------------------------------------------------------------------
6928 \brief sme_UpdateIsFastRoamIniFeatureEnabled() - enable/disable LFR support at runtime
6929 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6930 isFastRoamIniFeatureEnabled.
6931 This is a synchronuous call
6932 \param hHal - The handle returned by macOpen.
6933 \return eHAL_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config successfully.
6934 Other status means SME is failed to update isFastRoamIniFeatureEnabled.
6935 \sa
6936 --------------------------------------------------------------------------*/
6937eHalStatus sme_UpdateIsFastRoamIniFeatureEnabled(tHalHandle hHal,
6938 v_BOOL_t isFastRoamIniFeatureEnabled)
6939{
6940 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6941
6942 pMac->roam.configParam.isFastRoamIniFeatureEnabled = isFastRoamIniFeatureEnabled;
6943
6944 if(TRUE == isFastRoamIniFeatureEnabled)
6945 {
6946 sme_UpdateFastTransitionEnabled(hHal, TRUE);
6947 sme_UpdateConfigFwRssiMonitoring(hHal, TRUE);
6948 }
6949 else
6950 {
6951 /* CCX also depend on FW Monitoring/FastTransition.
6952 Hence Disabling LFR should check for CCX enable before disabling FW Monitoring and Fast Transition */
6953#ifdef FEATURE_WLAN_CCX
6954 if(FALSE == pMac->roam.configParam.isCcxIniFeatureEnabled)
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08006955#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08006956 {
6957 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6958 "%s: Turn off FW Monitoring/Fast Transition", __func__);
6959 sme_UpdateFastTransitionEnabled(hHal, FALSE);
6960 sme_UpdateConfigFwRssiMonitoring(hHal, FALSE);
6961 }
6962 }
6963
6964 return eHAL_STATUS_SUCCESS;
6965}
6966#endif /* FEATURE_WLAN_LFR */
6967
6968#ifdef FEATURE_WLAN_CCX
6969/*--------------------------------------------------------------------------
6970 \brief sme_UpdateIsCcxFeatureEnabled() - enable/disable CCX support at runtime
6971 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6972 isCcxIniFeatureEnabled.
6973 This is a synchronuous call
6974 \param hHal - The handle returned by macOpen.
6975 \return eHAL_STATUS_SUCCESS - SME update isCcxIniFeatureEnabled config successfully.
6976 Other status means SME is failed to update isCcxIniFeatureEnabled.
6977 \sa
6978 --------------------------------------------------------------------------*/
6979
6980eHalStatus sme_UpdateIsCcxFeatureEnabled(tHalHandle hHal,
6981 v_BOOL_t isCcxIniFeatureEnabled)
6982{
6983 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6984
6985 pMac->roam.configParam.isCcxIniFeatureEnabled = isCcxIniFeatureEnabled;
6986
6987 if(TRUE == isCcxIniFeatureEnabled)
6988 {
6989 sme_UpdateFastTransitionEnabled(hHal, TRUE);
6990 sme_UpdateConfigFwRssiMonitoring(hHal, TRUE);
6991 }
6992 else
6993 {
6994 /* LFR also depend on FW Monitoring/FastTransition.
6995 Hence Disabling CCX should check for LFR enable before disabling FW Monitoring and Fast Transition */
6996#ifdef FEATURE_WLAN_LFR
6997 if(FALSE == pMac->roam.configParam.isFastRoamIniFeatureEnabled)
6998#endif
6999 {
7000 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7001 "%s: Turn off FW Monitoring/Fast Transition", __func__);
7002 sme_UpdateFastTransitionEnabled(hHal, FALSE);
7003 sme_UpdateConfigFwRssiMonitoring(hHal, FALSE);
7004 }
7005 }
7006 return eHAL_STATUS_SUCCESS;
7007}
7008#endif /* FEATURE_WLAN_CCX */
7009
7010/*--------------------------------------------------------------------------
7011 \brief sme_UpdateConfigFwRssiMonitoring() - enable/disable firmware RSSI Monitoring at runtime
7012 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7013 fEnableFwRssiMonitoring.
7014 This is a synchronuous call
7015 \param hHal - The handle returned by macOpen.
7016 \return eHAL_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring. config successfully.
7017 Other status means SME is failed to update fEnableFwRssiMonitoring.
7018 \sa
7019 --------------------------------------------------------------------------*/
7020
7021eHalStatus sme_UpdateConfigFwRssiMonitoring(tHalHandle hHal,
7022 v_BOOL_t fEnableFwRssiMonitoring)
7023{
7024 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
7025
7026
7027 if (ccmCfgSetInt(hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR, fEnableFwRssiMonitoring,
7028 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
7029 {
7030 halStatus = eHAL_STATUS_FAILURE;
7031 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7032 "Failure: Could not pass on WNI_CFG_PS_RSSI_MONITOR configuration info to CCM\n");
7033 }
7034
7035 return (halStatus);
7036}
7037
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007038
7039
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007040/* ---------------------------------------------------------------------------
7041 \fn sme_IsFeatureSupportedByFW
7042 \brief Check if an feature is enabled by FW
7043
7044 \param feattEnumValue - Enumeration value from placeHolderInCapBitmap
7045 \- return 1/0 (TRUE/FALSE)
7046 -------------------------------------------------------------------------*/
7047tANI_U8 sme_IsFeatureSupportedByFW(tANI_U8 featEnumValue)
7048{
7049 return IS_FEATURE_SUPPORTED_BY_FW(featEnumValue);
7050}
7051#ifdef FEATURE_WLAN_TDLS
7052/* ---------------------------------------------------------------------------
7053 \fn sme_SendTdlsMgmtFrame
7054 \brief API to send TDLS management frames.
7055
7056 \param peerMac - peer's Mac Adress.
7057 \param frame_type - Type of TDLS mgmt frame to be sent.
7058 \param dialog - dialog token used in the frame.
7059 \param status - status to be incuded in the frame.
7060 \param buf - additional IEs to be included
7061 \param len - lenght of additional Ies
7062 \- return VOS_STATUS_SUCCES
7063 -------------------------------------------------------------------------*/
7064VOS_STATUS sme_SendTdlsMgmtFrame(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac,
7065 tANI_U8 frame_type, tANI_U8 dialog, tANI_U16 statusCode, tANI_U8 *buf, tANI_U8 len)
7066{
7067 eHalStatus status = eHAL_STATUS_SUCCESS;
7068 tCsrTdlsSendMgmt sendTdlsReq = {{0}} ;
7069 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7070
7071 status = sme_AcquireGlobalLock( &pMac->sme );
7072 if ( HAL_STATUS_SUCCESS( status ) )
7073 {
7074 vos_mem_copy(sendTdlsReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7075 sendTdlsReq.frameType = frame_type;
7076 sendTdlsReq.buf = buf;
7077 sendTdlsReq.len = len;
7078 sendTdlsReq.dialog = dialog;
7079 sendTdlsReq.statusCode = statusCode;
7080
7081 status = csrTdlsSendMgmtReq(hHal, sessionId, &sendTdlsReq) ;
7082
7083 sme_ReleaseGlobalLock( &pMac->sme );
7084 }
7085
7086 return status ;
7087
7088}
7089/* ---------------------------------------------------------------------------
7090 \fn sme_AddTdlsPeerSta
7091 \brief API to Add TDLS peer sta entry.
7092
7093 \param peerMac - peer's Mac Adress.
7094 \- return VOS_STATUS_SUCCES
7095 -------------------------------------------------------------------------*/
7096VOS_STATUS sme_AddTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7097{
7098 eHalStatus status = eHAL_STATUS_SUCCESS;
7099 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7100
7101 status = sme_AcquireGlobalLock( &pMac->sme );
7102 if ( HAL_STATUS_SUCCESS( status ) )
7103 {
7104 status = csrTdlsAddPeerSta(hHal, sessionId, peerMac);
7105
7106 sme_ReleaseGlobalLock( &pMac->sme );
7107 }
7108
7109 return status ;
7110
7111}
7112/* ---------------------------------------------------------------------------
7113 \fn sme_DeleteTdlsPeerSta
7114 \brief API to Delete TDLS peer sta entry.
7115
7116 \param peerMac - peer's Mac Adress.
7117 \- return VOS_STATUS_SUCCES
7118 -------------------------------------------------------------------------*/
7119VOS_STATUS sme_DeleteTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7120{
7121 eHalStatus status = eHAL_STATUS_SUCCESS;
7122 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7123
7124 status = sme_AcquireGlobalLock( &pMac->sme );
7125 if ( HAL_STATUS_SUCCESS( status ) )
7126 {
7127 status = csrTdlsDelPeerSta(hHal, sessionId, peerMac) ;
7128
7129 sme_ReleaseGlobalLock( &pMac->sme );
7130 }
7131
7132 return status ;
7133
7134}
7135#endif
7136#ifdef FEATURE_WLAN_TDLS_INTERNAL
7137/*
7138 * SME API to start TDLS discovery Procedure
7139 */
7140VOS_STATUS sme_StartTdlsDiscoveryReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7141{
7142 VOS_STATUS status = VOS_STATUS_SUCCESS;
7143 tCsrTdlsDisRequest disReq = {{0}} ;
7144 vos_mem_copy(disReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7145 status = csrTdlsDiscoveryReq(hHal, sessionId, &disReq) ;
7146
7147 return status ;
7148
7149}
7150
7151/*
7152 * Process TDLS discovery results
7153 */
7154v_U8_t sme_GetTdlsDiscoveryResult(tHalHandle hHal,
7155 tSmeTdlsDisResult *disResult, v_U8_t listType)
7156{
7157 tCsrTdlsPeerLinkinfo *peerLinkInfo = NULL ;
7158 tSirTdlsPeerInfo *peerInfo = NULL ;
7159 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7160 tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
7161 tDblLinkList *peerList = &disInfo->tdlsPotentialPeerList ;
7162 tListElem *pEntry = NULL ;
7163 v_U8_t peerCnt = 0 ;
7164
7165 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7166 ("TDLS peer count = %d\n"),disInfo->tdlsPeerCount ) ;
7167 pEntry = csrLLPeekHead( peerList, LL_ACCESS_LOCK );
7168 while(pEntry)
7169 {
7170 peerLinkInfo = GET_BASE_ADDR( pEntry, tCsrTdlsPeerLinkinfo,
7171 tdlsPeerStaLink) ;
7172 peerInfo = &peerLinkInfo->tdlsDisPeerInfo ;
7173
7174 switch(listType)
7175 {
7176 case TDLS_SETUP_LIST:
7177 {
7178 if(TDLS_LINK_SETUP_STATE == peerInfo->tdlsPeerState)
7179 {
7180 palCopyMemory(pMac->hHdd, disResult[peerCnt].tdlsPeerMac,
7181 peerInfo->peerMac, sizeof(tSirMacAddr)) ;
7182 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
7183 peerCnt++ ;
7184 }
7185 break ;
7186 }
7187 case TDLS_DIS_LIST:
7188 {
7189 palCopyMemory(pMac->hHdd, disResult[peerCnt].tdlsPeerMac,
7190 peerInfo->peerMac, sizeof(tSirMacAddr)) ;
7191 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
7192 peerCnt++ ;
7193 break ;
7194 }
7195 default:
7196 {
7197 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7198 ("unknown list type \n")) ;
7199 break ;
7200 }
7201 }
7202
7203 pEntry = csrLLNext( peerList, pEntry, LL_ACCESS_LOCK) ;
7204 }
7205
7206 return peerCnt ;
7207
7208}
7209
7210/*
7211 * SME API to start TDLS link setup Procedure.
7212 */
7213VOS_STATUS sme_StartTdlsLinkSetupReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7214{
7215 VOS_STATUS status = VOS_STATUS_SUCCESS;
7216 tCsrTdlsSetupRequest setupReq = {{0}} ;
7217 vos_mem_copy(setupReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7218 status = csrTdlsSetupReq(hHal, sessionId, &setupReq) ;
7219 return status ;
7220
7221}
7222
7223/*
7224 * SME API to start TDLS link Teardown Procedure.
7225 */
7226VOS_STATUS sme_StartTdlsLinkTeardownReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7227{
7228 VOS_STATUS status = VOS_STATUS_SUCCESS;
7229 tCsrTdlsTeardownRequest teardownReq = {{0}} ;
7230 vos_mem_copy(teardownReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7231 status = csrTdlsTeardownReq(hHal, sessionId, &teardownReq) ;
7232 return status ;
7233
7234}
7235
7236#endif /* FEATURE_WLAN_TDLS */
7237