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