blob: 176f68ca74f052440c2f3ec3d78d910ef03546f4 [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 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800811 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800812 "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,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302528 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 }
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,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302566 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 }
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/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +05303218+ \fn sme_SetHostPowerSave
3219+ \brief Enables BMPS logic to be controlled by User level apps
3220+ \param hHal - The handle returned by macOpen.
3221+ \param psMode - The power saving mode to disable. Disabling does not imply
3222+ that device will be brought out of the current PS mode. This
3223+ is purely a configuration API.
3224+ \return eHalStatus
3225+ ---------------------------------------------------------------------------*/
3226eHalStatus sme_SetHostPowerSave (tHalHandle hHal, v_BOOL_t psMode)
3227{
3228 eHalStatus status = eHAL_STATUS_FAILURE;
3229 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3230
3231 pMac->pmc.isHostPsEn = psMode;
3232
3233 return (status);
3234}
3235
3236/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 \fn sme_StartAutoBmpsTimer
3238 \brief Starts a timer that periodically polls all the registered
3239 module for entry into Bmps mode. This timer is started only if BMPS is
3240 enabled and whenever the device is in full power.
3241 \param hHal - The handle returned by macOpen.
3242 \return eHalStatus
3243 ---------------------------------------------------------------------------*/
3244eHalStatus sme_StartAutoBmpsTimer ( tHalHandle hHal)
3245{
3246 eHalStatus status = eHAL_STATUS_FAILURE;
3247 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3248
3249 status = sme_AcquireGlobalLock( &pMac->sme );
3250 if ( HAL_STATUS_SUCCESS( status ) )
3251 {
3252 status = pmcStartAutoBmpsTimer(hHal);
3253 sme_ReleaseGlobalLock( &pMac->sme );
3254 }
3255
3256 return (status);
3257}
3258/* ---------------------------------------------------------------------------
3259 \fn sme_StopAutoBmpsTimer
3260 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
3261 Stopping the timer does not cause a device state change. Only the timer
3262 is stopped. If "Full Power" is desired, use the sme_RequestFullPower API
3263 \param hHal - The handle returned by macOpen.
3264 \return eHalStatus
3265 ---------------------------------------------------------------------------*/
3266eHalStatus sme_StopAutoBmpsTimer ( tHalHandle hHal)
3267{
3268 eHalStatus status = eHAL_STATUS_FAILURE;
3269 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3270
3271 status = sme_AcquireGlobalLock( &pMac->sme );
3272 if ( HAL_STATUS_SUCCESS( status ) )
3273 {
3274 status = pmcStopAutoBmpsTimer(hHal);
3275 sme_ReleaseGlobalLock( &pMac->sme );
3276 }
3277
3278 return (status);
3279}
3280/* ---------------------------------------------------------------------------
3281 \fn sme_QueryPowerState
3282 \brief Returns the current power state of the device.
3283 \param hHal - The handle returned by macOpen.
3284 \param pPowerState - pointer to location to return power state (LOW or HIGH)
3285 \param pSwWlanSwitchState - ptr to location to return SW WLAN Switch state
3286 \return eHalStatus
3287 ---------------------------------------------------------------------------*/
3288eHalStatus sme_QueryPowerState (
3289 tHalHandle hHal,
3290 tPmcPowerState *pPowerState,
3291 tPmcSwitchState *pSwWlanSwitchState)
3292{
3293 eHalStatus status = eHAL_STATUS_FAILURE;
3294 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3295
3296 status = sme_AcquireGlobalLock( &pMac->sme );
3297 if ( HAL_STATUS_SUCCESS( status ) )
3298 {
3299 status = pmcQueryPowerState (hHal, pPowerState, NULL, pSwWlanSwitchState);
3300 sme_ReleaseGlobalLock( &pMac->sme );
3301 }
3302
3303 return (status);
3304}
3305
3306/* ---------------------------------------------------------------------------
3307 \fn sme_IsPowerSaveEnabled
3308 \brief Checks if the device is able to enter a particular power save mode
3309 This does not imply that the device is in a particular PS mode
3310 \param hHal - The handle returned by macOpen.
3311 \param psMode - the power saving mode
3312 \return eHalStatus
3313 ---------------------------------------------------------------------------*/
3314tANI_BOOLEAN sme_IsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
3315{
3316 eHalStatus status = eHAL_STATUS_FAILURE;
3317 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3318 tANI_BOOLEAN result = false;
3319
3320 status = sme_AcquireGlobalLock( &pMac->sme );
3321 if ( HAL_STATUS_SUCCESS( status ) )
3322 {
3323 result = pmcIsPowerSaveEnabled(hHal, psMode);
3324 sme_ReleaseGlobalLock( &pMac->sme );
3325 return result;
3326 }
3327
3328 return false;
3329}
3330
3331/* ---------------------------------------------------------------------------
3332 \fn sme_RequestFullPower
3333 \brief Request that the device be brought to full power state. When the
3334 device enters Full Power PMC will start a BMPS timer if BMPS PS mode
3335 is enabled. On timer expiry PMC will attempt to put the device in
3336 BMPS mode if following holds true:
3337 - BMPS mode is enabled
3338 - Polling of all modules through the Power Save Check routine passes
3339 - STA is associated to an access point
3340 \param hHal - The handle returned by macOpen.
3341 \param - callbackRoutine Callback routine invoked in case of success/failure
3342 \return eHalStatus - status
3343 eHAL_STATUS_SUCCESS - device brought to full power state
3344 eHAL_STATUS_FAILURE - device cannot be brought to full power state
3345 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
3346 ---------------------------------------------------------------------------*/
3347eHalStatus sme_RequestFullPower (
3348 tHalHandle hHal,
3349 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3350 void *callbackContext,
3351 tRequestFullPowerReason fullPowerReason)
3352{
3353 eHalStatus status = eHAL_STATUS_FAILURE;
3354 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3355
3356 status = sme_AcquireGlobalLock( &pMac->sme );
3357 if ( HAL_STATUS_SUCCESS( status ) )
3358 {
3359 status = pmcRequestFullPower(hHal, callbackRoutine, callbackContext, fullPowerReason);
3360 sme_ReleaseGlobalLock( &pMac->sme );
3361 }
3362
3363 return (status);
3364}
3365
3366/* ---------------------------------------------------------------------------
3367 \fn sme_RequestBmps
3368 \brief Request that the device be put in BMPS state. Request will be
3369 accepted only if BMPS mode is enabled and power save check routine
3370 passes.
3371 \param hHal - The handle returned by macOpen.
3372 \param - callbackRoutine Callback routine invoked in case of success/failure
3373 \return eHalStatus
3374 eHAL_STATUS_SUCCESS - device is in BMPS state
3375 eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
3376 eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state
3377 ---------------------------------------------------------------------------*/
3378eHalStatus sme_RequestBmps (
3379 tHalHandle hHal,
3380 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3381 void *callbackContext)
3382{
3383 eHalStatus status = eHAL_STATUS_FAILURE;
3384 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3385
3386 status = sme_AcquireGlobalLock( &pMac->sme );
3387 if ( HAL_STATUS_SUCCESS( status ) )
3388 {
3389 status = pmcRequestBmps(hHal, callbackRoutine, callbackContext);
3390 sme_ReleaseGlobalLock( &pMac->sme );
3391 }
3392
3393 return (status);
3394}
3395
3396
3397/* ---------------------------------------------------------------------------
3398 \fn sme_SetDHCPTillPowerActiveFlag
3399 \brief Sets/Clears DHCP related flag in PMC to disable/enable auto BMPS
3400 entry by PMC
3401 \param hHal - The handle returned by macOpen.
3402 ---------------------------------------------------------------------------*/
3403void sme_SetDHCPTillPowerActiveFlag(tHalHandle hHal, tANI_U8 flag)
3404{
3405 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3406
3407 // Set/Clear the DHCP flag which will disable/enable auto BMPS entery by PMC
3408 pMac->pmc.remainInPowerActiveTillDHCP = flag;
3409}
3410
3411
3412/* ---------------------------------------------------------------------------
3413 \fn sme_StartUapsd
3414 \brief Request that the device be put in UAPSD state. If the device is in
3415 Full Power it will be put in BMPS mode first and then into UAPSD
3416 mode.
3417 \param hHal - The handle returned by macOpen.
3418 \param - callbackRoutine Callback routine invoked in case of success/failure
3419 eHAL_STATUS_SUCCESS - device is in UAPSD state
3420 eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
3421 eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
3422 eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
3423 \return eHalStatus
3424 ---------------------------------------------------------------------------*/
3425eHalStatus sme_StartUapsd (
3426 tHalHandle hHal,
3427 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3428 void *callbackContext)
3429{
3430 eHalStatus status = eHAL_STATUS_FAILURE;
3431 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3432
3433 status = sme_AcquireGlobalLock( &pMac->sme );
3434 if ( HAL_STATUS_SUCCESS( status ) )
3435 {
3436 status = pmcStartUapsd(hHal, callbackRoutine, callbackContext);
3437 sme_ReleaseGlobalLock( &pMac->sme );
3438 }
3439
3440 return (status);
3441 }
3442
3443/* ---------------------------------------------------------------------------
3444 \fn sme_StopUapsd
3445 \brief Request that the device be put out of UAPSD state. Device will be
3446 put in in BMPS state after stop UAPSD completes.
3447 \param hHal - The handle returned by macOpen.
3448 \return eHalStatus
3449 eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
3450 eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
3451 ---------------------------------------------------------------------------*/
3452eHalStatus sme_StopUapsd (tHalHandle hHal)
3453{
3454 eHalStatus status = eHAL_STATUS_FAILURE;
3455 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3456
3457 status = sme_AcquireGlobalLock( &pMac->sme );
3458 if ( HAL_STATUS_SUCCESS( status ) )
3459 {
3460 status = pmcStopUapsd(hHal);
3461 sme_ReleaseGlobalLock( &pMac->sme );
3462 }
3463
3464 return (status);
3465}
3466
3467/* ---------------------------------------------------------------------------
3468 \fn sme_RequestStandby
3469 \brief Request that the device be put in standby. It is HDD's responsibility
3470 to bring the chip to full power and do a disassoc before calling
3471 this API.
3472 \param hHal - The handle returned by macOpen.
3473 \param - callbackRoutine Callback routine invoked in case of success/failure
3474 \return eHalStatus
3475 eHAL_STATUS_SUCCESS - device is in Standby mode
3476 eHAL_STATUS_FAILURE - device cannot be put in standby mode
3477 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
3478 ---------------------------------------------------------------------------*/
3479eHalStatus sme_RequestStandby (
3480 tHalHandle hHal,
3481 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3482 void *callbackContext)
3483{
3484 eHalStatus status = eHAL_STATUS_FAILURE;
3485 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3486
3487 smsLog( pMac, LOG1, FL("") );
3488 status = sme_AcquireGlobalLock( &pMac->sme );
3489 if ( HAL_STATUS_SUCCESS( status ) )
3490 {
3491 status = pmcRequestStandby(hHal, callbackRoutine, callbackContext);
3492 sme_ReleaseGlobalLock( &pMac->sme );
3493 }
3494
3495 return (status);
3496}
3497
3498/* ---------------------------------------------------------------------------
3499 \fn sme_RegisterPowerSaveCheck
3500 \brief Register a power save check routine that is called whenever
3501 the device is about to enter one of the power save modes.
3502 \param hHal - The handle returned by macOpen.
3503 \param checkRoutine - Power save check routine to be registered
3504 \return eHalStatus
3505 eHAL_STATUS_SUCCESS - successfully registered
3506 eHAL_STATUS_FAILURE - not successfully registered
3507 ---------------------------------------------------------------------------*/
3508eHalStatus sme_RegisterPowerSaveCheck (
3509 tHalHandle hHal,
3510 tANI_BOOLEAN (*checkRoutine) (void *checkContext), void *checkContext)
3511{
3512 eHalStatus status = eHAL_STATUS_FAILURE;
3513 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3514
3515 status = sme_AcquireGlobalLock( &pMac->sme );
3516 if ( HAL_STATUS_SUCCESS( status ) )
3517 {
3518 status = pmcRegisterPowerSaveCheck (hHal, checkRoutine, checkContext);
3519 sme_ReleaseGlobalLock( &pMac->sme );
3520 }
3521
3522 return (status);
3523}
3524
3525/* ---------------------------------------------------------------------------
3526 \fn sme_DeregisterPowerSaveCheck
3527 \brief Deregister a power save check routine
3528 \param hHal - The handle returned by macOpen.
3529 \param checkRoutine - Power save check routine to be deregistered
3530 \return eHalStatus
3531 eHAL_STATUS_SUCCESS - successfully deregistered
3532 eHAL_STATUS_FAILURE - not successfully deregistered
3533 ---------------------------------------------------------------------------*/
3534eHalStatus sme_DeregisterPowerSaveCheck (
3535 tHalHandle hHal,
3536 tANI_BOOLEAN (*checkRoutine) (void *checkContext))
3537{
3538 eHalStatus status = eHAL_STATUS_FAILURE;
3539 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3540
3541 status = sme_AcquireGlobalLock( &pMac->sme );
3542 if ( HAL_STATUS_SUCCESS( status ) )
3543 {
3544 status = pmcDeregisterPowerSaveCheck (hHal, checkRoutine);
3545 sme_ReleaseGlobalLock( &pMac->sme );
3546 }
3547
3548 return (status);
3549}
3550
3551/* ---------------------------------------------------------------------------
3552 \fn sme_RegisterDeviceStateUpdateInd
3553 \brief Register a callback routine that is called whenever
3554 the device enters a new device state (Full Power, BMPS, UAPSD)
3555 \param hHal - The handle returned by macOpen.
3556 \param callbackRoutine - Callback routine to be registered
3557 \param callbackContext - Cookie to be passed back during callback
3558 \return eHalStatus
3559 eHAL_STATUS_SUCCESS - successfully registered
3560 eHAL_STATUS_FAILURE - not successfully registered
3561 ---------------------------------------------------------------------------*/
3562eHalStatus sme_RegisterDeviceStateUpdateInd (
3563 tHalHandle hHal,
3564 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
3565 void *callbackContext)
3566{
3567 eHalStatus status = eHAL_STATUS_FAILURE;
3568 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3569
3570 status = sme_AcquireGlobalLock( &pMac->sme );
3571 if ( HAL_STATUS_SUCCESS( status ) )
3572 {
3573 status = pmcRegisterDeviceStateUpdateInd (hHal, callbackRoutine, callbackContext);
3574 sme_ReleaseGlobalLock( &pMac->sme );
3575 }
3576
3577 return (status);
3578}
3579
3580/* ---------------------------------------------------------------------------
3581 \fn sme_DeregisterDeviceStateUpdateInd
3582 \brief Deregister a routine that was registered for device state changes
3583 \param hHal - The handle returned by macOpen.
3584 \param callbackRoutine - Callback routine to be deregistered
3585 \return eHalStatus
3586 eHAL_STATUS_SUCCESS - successfully deregistered
3587 eHAL_STATUS_FAILURE - not successfully deregistered
3588 ---------------------------------------------------------------------------*/
3589eHalStatus sme_DeregisterDeviceStateUpdateInd (
3590 tHalHandle hHal,
3591 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
3592{
3593 eHalStatus status = eHAL_STATUS_FAILURE;
3594 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3595
3596 status = sme_AcquireGlobalLock( &pMac->sme );
3597 if ( HAL_STATUS_SUCCESS( status ) )
3598 {
3599 status = pmcDeregisterDeviceStateUpdateInd (hHal, callbackRoutine);
3600 sme_ReleaseGlobalLock( &pMac->sme );
3601 }
3602
3603 return (status);
3604}
3605
3606/* ---------------------------------------------------------------------------
3607 \fn sme_WowlAddBcastPattern
3608 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
3609 do a pattern match on these patterns when Wowl is enabled during BMPS
3610 mode. Note that Firmware performs the pattern matching only on
3611 broadcast frames and while Libra is in BMPS mode.
3612 \param hHal - The handle returned by macOpen.
3613 \param pattern - Pattern to be added
3614 \return eHalStatus
3615 eHAL_STATUS_FAILURE Cannot add pattern
3616 eHAL_STATUS_SUCCESS Request accepted.
3617 ---------------------------------------------------------------------------*/
3618eHalStatus sme_WowlAddBcastPattern (
3619 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003620 tpSirWowlAddBcastPtrn pattern,
3621 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003622{
3623 eHalStatus status = eHAL_STATUS_FAILURE;
3624 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3625 status = sme_AcquireGlobalLock( &pMac->sme );
3626 if ( HAL_STATUS_SUCCESS( status ) )
3627 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003628 status = pmcWowlAddBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 sme_ReleaseGlobalLock( &pMac->sme );
3630 }
3631
3632 return (status);
3633}
3634
3635/* ---------------------------------------------------------------------------
3636 \fn sme_WowlDelBcastPattern
3637 \brief Delete a pattern that was added for Pattern Byte Matching.
3638 \param hHal - The handle returned by macOpen.
3639 \param pattern - Pattern to be deleted
3640 \return eHalStatus
3641 eHAL_STATUS_FAILURE Cannot delete pattern
3642 eHAL_STATUS_SUCCESS Request accepted.
3643 ---------------------------------------------------------------------------*/
3644eHalStatus sme_WowlDelBcastPattern (
3645 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003646 tpSirWowlDelBcastPtrn pattern,
3647 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003648{
3649 eHalStatus status = eHAL_STATUS_FAILURE;
3650 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3651 status = sme_AcquireGlobalLock( &pMac->sme );
3652 if ( HAL_STATUS_SUCCESS( status ) )
3653 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003654 status = pmcWowlDelBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 sme_ReleaseGlobalLock( &pMac->sme );
3656 }
3657
3658 return (status);
3659}
3660
3661/* ---------------------------------------------------------------------------
3662 \fn sme_EnterWowl
3663 \brief This is the SME API exposed to HDD to request enabling of WOWL mode.
3664 WoWLAN works on top of BMPS mode. If the device is not in BMPS mode,
3665 SME will will cache the information that WOWL has been enabled and
3666 attempt to put the device in BMPS. On entry into BMPS, SME will
3667 enable the WOWL mode.
3668 Note 1: If we exit BMPS mode (someone requests full power), we
3669 will NOT resume WOWL when we go back to BMPS again. Request for full
3670 power (while in WOWL mode) means disable WOWL and go to full power.
3671 Note 2: Both UAPSD and WOWL work on top of BMPS. On entry into BMPS, SME
3672 will give priority to UAPSD and enable only UAPSD if both UAPSD and WOWL
3673 are required. Currently there is no requirement or use case to support
3674 UAPSD and WOWL at the same time.
3675
3676 \param hHal - The handle returned by macOpen.
3677 \param enterWowlCallbackRoutine - Callback routine provided by HDD.
3678 Used for success/failure notification by SME
3679 \param enterWowlCallbackContext - A cookie passed by HDD, that is passed back to HDD
3680 at the time of callback.
3681 \param wakeReasonIndCB - Callback routine provided by HDD.
3682 Used for Wake Reason Indication by SME
3683 \param wakeReasonIndCBContext - A cookie passed by HDD, that is passed back to HDD
3684 at the time of callback.
3685 \return eHalStatus
3686 eHAL_STATUS_SUCCESS Device is already in WoWLAN mode
3687 eHAL_STATUS_FAILURE Device cannot enter WoWLAN mode.
3688 eHAL_STATUS_PMC_PENDING Request accepted. SME will enable WOWL after
3689 BMPS mode is entered.
3690 ---------------------------------------------------------------------------*/
3691eHalStatus sme_EnterWowl (
3692 tHalHandle hHal,
3693 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
3694 void *enterWowlCallbackContext,
3695#ifdef WLAN_WAKEUP_EVENTS
3696 void (*wakeIndicationCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
3697 void *wakeIndicationCBContext,
3698#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003699 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003700{
3701 eHalStatus status = eHAL_STATUS_FAILURE;
3702 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3703 status = sme_AcquireGlobalLock( &pMac->sme );
3704 if ( HAL_STATUS_SUCCESS( status ) )
3705 {
3706 status = pmcEnterWowl (hHal, enterWowlCallbackRoutine, enterWowlCallbackContext,
3707#ifdef WLAN_WAKEUP_EVENTS
3708 wakeIndicationCB, wakeIndicationCBContext,
3709#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003710 wowlEnterParams, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 sme_ReleaseGlobalLock( &pMac->sme );
3712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 return (status);
3714}
3715/* ---------------------------------------------------------------------------
3716 \fn sme_ExitWowl
3717 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
3718 SME will initiate exit from WoWLAN mode and device will be put in BMPS
3719 mode.
3720 \param hHal - The handle returned by macOpen.
3721 \return eHalStatus
3722 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
3723 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
3724 ---------------------------------------------------------------------------*/
3725eHalStatus sme_ExitWowl (tHalHandle hHal)
3726{
3727 eHalStatus status = eHAL_STATUS_FAILURE;
3728 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3729 status = sme_AcquireGlobalLock( &pMac->sme );
3730 if ( HAL_STATUS_SUCCESS( status ) )
3731 {
3732 status = pmcExitWowl (hHal);
3733 sme_ReleaseGlobalLock( &pMac->sme );
3734 }
3735
3736 return (status);
3737}
3738
3739/* ---------------------------------------------------------------------------
3740
3741 \fn sme_RoamSetKey
3742
3743 \brief To set encryption key. This function should be called only when connected
3744 This is an asynchronous API.
3745
3746 \param pSetKeyInfo - pointer to a caller allocated object of tCsrSetContextInfo
3747
3748 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3749
3750 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3751
3752 FAILURE or RESOURCES The API finished and failed.
3753
3754 -------------------------------------------------------------------------------*/
3755eHalStatus sme_RoamSetKey(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 *pRoamId)
3756{
3757 eHalStatus status = eHAL_STATUS_FAILURE;
3758 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3759 tANI_U32 roamId;
3760#ifdef WLAN_SOFTAP_FEATURE
3761 tANI_U32 i;
3762 tCsrRoamSession *pSession = NULL;
3763#endif
3764
3765 status = sme_AcquireGlobalLock( &pMac->sme );
3766 if ( HAL_STATUS_SUCCESS( status ) )
3767 {
3768 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3769 if(pRoamId)
3770 {
3771 *pRoamId = roamId;
3772 }
3773
3774#ifdef WLAN_SOFTAP_FEATURE
3775 smsLog(pMac, LOG2, FL("keyLength\n"), pSetKey->keyLength);
3776
3777 for(i=0; i<pSetKey->keyLength; i++)
3778 smsLog(pMac, LOG2, FL("%02x"), pSetKey->Key[i]);
3779
3780 smsLog(pMac, LOG2, "\n sessionId=%d roamId=%d\n", sessionId, roamId);
3781
3782 pSession = CSR_GET_SESSION(pMac, sessionId);
3783
Jeff Johnson32d95a32012-09-10 13:15:23 -07003784 if(!pSession)
3785 {
3786 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3787 return eHAL_STATUS_FAILURE;
3788 }
3789
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
3791 {
3792 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
3793 {
3794 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
3795 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
3796 {
3797 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3798 }
3799 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
3800 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
3801 {
3802 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3803 }
3804 }
3805 }
3806#endif
3807
3808 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
3809 sme_ReleaseGlobalLock( &pMac->sme );
3810 }
3811
3812 return (status);
3813}
3814
3815
3816/* ---------------------------------------------------------------------------
3817
3818 \fn sme_RoamRemoveKey
3819
3820 \brief To set encryption key. This is an asynchronous API.
3821
3822 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
3823
3824 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
3825
3826 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
3827
3828 FAILURE or RESOURCES The API finished and failed.
3829
3830 -------------------------------------------------------------------------------*/
3831eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
3832 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
3833{
3834 eHalStatus status = eHAL_STATUS_FAILURE;
3835 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3836 tANI_U32 roamId;
3837
3838 status = sme_AcquireGlobalLock( &pMac->sme );
3839 if ( HAL_STATUS_SUCCESS( status ) )
3840 {
3841 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
3842 if(pRoamId)
3843 {
3844 *pRoamId = roamId;
3845 }
3846 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
3847 sme_ReleaseGlobalLock( &pMac->sme );
3848 }
3849
3850 return (status);
3851}
3852
3853/* ---------------------------------------------------------------------------
3854 \fn sme_GetRssi
3855 \brief a wrapper function that client calls to register a callback to get RSSI
3856
3857 \param callback - SME sends back the requested stats using the callback
3858 \param staId - The station ID for which the stats is requested for
3859 \param pContext - user context to be passed back along with the callback
3860 \param pVosContext - vos context
3861 \return eHalStatus
3862 ---------------------------------------------------------------------------*/
3863eHalStatus sme_GetRssi(tHalHandle hHal,
3864 tCsrRssiCallback callback,
3865 tANI_U8 staId, tCsrBssid bssId,
3866 void *pContext, void* pVosContext)
3867{
3868 eHalStatus status = eHAL_STATUS_FAILURE;
3869 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3870
3871 status = sme_AcquireGlobalLock( &pMac->sme );
3872 if ( HAL_STATUS_SUCCESS( status ) )
3873 {
3874 status = csrGetRssi( pMac, callback,
3875 staId, bssId, pContext, pVosContext);
3876 sme_ReleaseGlobalLock( &pMac->sme );
3877 }
3878 return (status);
3879}
3880
3881/* ---------------------------------------------------------------------------
3882 \fn sme_GetStatistics
3883 \brief a wrapper function that client calls to register a callback to get
3884 different PHY level statistics from CSR.
3885
3886 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
3887 \param statsMask - The different category/categories of stats requester is looking for
3888 \param callback - SME sends back the requested stats using the callback
3889 \param periodicity - If requester needs periodic update in millisec, 0 means
3890 it's an one time request
3891 \param cache - If requester is happy with cached stats
3892 \param staId - The station ID for which the stats is requested for
3893 \param pContext - user context to be passed back along with the callback
3894 \return eHalStatus
3895 ---------------------------------------------------------------------------*/
3896eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
3897 tANI_U32 statsMask,
3898 tCsrStatsCallback callback,
3899 tANI_U32 periodicity, tANI_BOOLEAN cache,
3900 tANI_U8 staId, void *pContext)
3901{
3902 eHalStatus status = eHAL_STATUS_FAILURE;
3903 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3904
3905 status = sme_AcquireGlobalLock( &pMac->sme );
3906 if ( HAL_STATUS_SUCCESS( status ) )
3907 {
3908 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
3909 periodicity, cache, staId, pContext);
3910 sme_ReleaseGlobalLock( &pMac->sme );
3911 }
3912
3913 return (status);
3914
3915}
3916
3917/* ---------------------------------------------------------------------------
3918
3919 \fn sme_GetCountryCode
3920
3921 \brief To return the current country code. If no country code is applied, default country code is
3922 used to fill the buffer.
3923 If 11d supported is turned off, an error is return and the last applied/default country code is used.
3924 This is a synchronous API.
3925
3926 \param pBuf - pointer to a caller allocated buffer for returned country code.
3927
3928 \param pbLen For input, this parameter indicates how big is the buffer.
3929 Upon return, this parameter has the number of bytes for country. If pBuf
3930 doesn't have enough space, this function returns
3931 fail status and this parameter contains the number that is needed.
3932
3933 \return eHalStatus SUCCESS.
3934
3935 FAILURE or RESOURCES The API finished and failed.
3936
3937 -------------------------------------------------------------------------------*/
3938eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
3939{
3940 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3941
3942 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
3943}
3944
3945
3946/* ---------------------------------------------------------------------------
3947
3948 \fn sme_SetCountryCode
3949
3950 \brief To change the current/default country code.
3951 If 11d supported is turned off, an error is return.
3952 This is a synchronous API.
3953
3954 \param pCountry - pointer to a caller allocated buffer for the country code.
3955
3956 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
3957 whether a reset is required.
3958
3959 \return eHalStatus SUCCESS.
3960
3961 FAILURE or RESOURCES The API finished and failed.
3962
3963 -------------------------------------------------------------------------------*/
3964eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
3965{
3966 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3967
3968 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
3969}
3970
3971
3972/* ---------------------------------------------------------------------------
3973 \fn sme_ResetCountryCodeInformation
3974 \brief this function is to reset the country code current being used back to EEPROM default
3975 this includes channel list and power setting. This is a synchronous API.
3976 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
3977 a restart is needed to apply the change
3978 \return eHalStatus
3979 -------------------------------------------------------------------------------*/
3980eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
3981{
3982 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3983
3984 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
3985}
3986
3987
3988/* ---------------------------------------------------------------------------
3989 \fn sme_GetSupportedCountryCode
3990 \brief this function is to get a list of the country code current being supported
3991 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
3992 this has the country code list. 3 bytes for each country code. This may be NULL if
3993 caller wants to know the needed byte count.
3994 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
3995 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
3996 \return eHalStatus
3997 -------------------------------------------------------------------------------*/
3998eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
3999{
4000 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4001
4002 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
4003}
4004
4005
4006/* ---------------------------------------------------------------------------
4007 \fn sme_GetCurrentRegulatoryDomain
4008 \brief this function is to get the current regulatory domain. This is a synchronous API.
4009 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4010 SME. The function fails if 11d support is turned off.
4011 \param pDomain - Caller allocated buffer to return the current domain.
4012 \return eHalStatus SUCCESS.
4013
4014 FAILURE or RESOURCES The API finished and failed.
4015 -------------------------------------------------------------------------------*/
4016eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
4017{
4018 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4019 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4020
4021 if( pDomain )
4022 {
4023 if( csrIs11dSupported( pMac ) )
4024 {
4025 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
4026 status = eHAL_STATUS_SUCCESS;
4027 }
4028 else
4029 {
4030 status = eHAL_STATUS_FAILURE;
4031 }
4032 }
4033
4034 return ( status );
4035}
4036
4037
4038/* ---------------------------------------------------------------------------
4039 \fn sme_SetRegulatoryDomain
4040 \brief this function is to set the current regulatory domain.
4041 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4042 SME. This is a synchronous API.
4043 \param domainId - indicate the domain (defined in the driver) needs to set to.
4044 See v_REGDOMAIN_t for definition
4045 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
4046 a restart is needed to apply the change
4047 \return eHalStatus
4048 -------------------------------------------------------------------------------*/
4049eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
4050{
4051 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4052
4053 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
4054}
4055
4056
4057/* ---------------------------------------------------------------------------
4058
4059 \fn sme_GetRegulatoryDomainForCountry
4060
4061 \brief To return a regulatory domain base on a country code. This is a synchronous API.
4062
4063 \param pCountry - pointer to a caller allocated buffer for input country code.
4064
4065 \param pDomainId Upon successful return, it is the domain that country belongs to.
4066 If it is NULL, returning success means that the country code is known.
4067
4068 \return eHalStatus SUCCESS.
4069
4070 FAILURE or RESOURCES The API finished and failed.
4071
4072 -------------------------------------------------------------------------------*/
4073eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
4074{
4075 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4076
4077 return ( csrGetRegulatoryDomainForCountry( pMac, pCountry, pDomainId ) );
4078}
4079
4080
4081
4082
4083/* ---------------------------------------------------------------------------
4084
4085 \fn sme_GetSupportedRegulatoryDomains
4086
4087 \brief To return a list of supported regulatory domains. This is a synchronous API.
4088
4089 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
4090
4091 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
4092 Upon return, this parameter has the number for supported domains. If pDomains
4093 doesn't have enough space for all the supported domains, this function returns
4094 fail status and this parameter contains the number that is needed.
4095
4096 \return eHalStatus SUCCESS.
4097
4098 FAILURE or RESOURCES The API finished and failed.
4099
4100 -------------------------------------------------------------------------------*/
4101eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
4102{
4103 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4104
4105 //We support all domains for now
4106 if( pNumDomains )
4107 {
4108 if( NUM_REG_DOMAINS <= *pNumDomains )
4109 {
4110 status = eHAL_STATUS_SUCCESS;
4111 }
4112 *pNumDomains = NUM_REG_DOMAINS;
4113 }
4114 if( HAL_STATUS_SUCCESS( status ) )
4115 {
4116 if( pDomains )
4117 {
4118 pDomains[0] = REGDOMAIN_FCC;
4119 pDomains[1] = REGDOMAIN_ETSI;
4120 pDomains[2] = REGDOMAIN_JAPAN;
4121 pDomains[3] = REGDOMAIN_WORLD;
4122 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
4123 pDomains[5] = REGDOMAIN_APAC;
4124 pDomains[6] = REGDOMAIN_KOREA;
4125 pDomains[7] = REGDOMAIN_HI_5GHZ;
4126 pDomains[8] = REGDOMAIN_NO_5GHZ;
4127 }
4128 else
4129 {
4130 status = eHAL_STATUS_INVALID_PARAMETER;
4131 }
4132 }
4133
4134 return ( status );
4135}
4136
4137
4138//some support functions
4139tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
4140{
4141 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4142
4143 return ( csrIs11dSupported( pMac ) );
4144}
4145
4146
4147tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
4148{
4149 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4150
4151 return ( csrIs11hSupported( pMac ) );
4152}
4153
4154
4155tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
4156{
4157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4158
4159 return ( csrIsWmmSupported( pMac ) );
4160}
4161
4162//Upper layer to get the list of the base channels to scan for passively 11d info from csr
4163eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
4164{
4165 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4166
4167 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
4168}
4169
4170/* ---------------------------------------------------------------------------
4171
4172 \fn sme_ChangeCountryCode
4173
4174 \brief Change Country code from upperlayer during WLAN driver operation.
4175 This is a synchronous API.
4176
4177 \param hHal - The handle returned by macOpen.
4178
4179 \param pCountry New Country Code String
4180
4181 \return eHalStatus SUCCESS.
4182
4183 FAILURE or RESOURCES The API finished and failed.
4184
4185 -------------------------------------------------------------------------------*/
4186eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
4187 tSmeChangeCountryCallback callback,
4188 tANI_U8 *pCountry,
4189 void *pContext,
4190 void* pVosContext )
4191{
4192 eHalStatus status = eHAL_STATUS_FAILURE;
4193 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4194 vos_msg_t msg;
4195 tAniChangeCountryCodeReq *pMsg;
4196
4197 status = sme_AcquireGlobalLock( &pMac->sme );
4198 if ( HAL_STATUS_SUCCESS( status ) )
4199 {
4200 smsLog(pMac, LOG1, FL(" called\n"));
4201 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniChangeCountryCodeReq));
4202 if ( !HAL_STATUS_SUCCESS(status) )
4203 {
4204 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req \n");
4205 return status;
4206 }
4207
4208 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
4209 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
4210 palCopyMemory(pMac->hHdd, pMsg->countryCode, pCountry, 3);
4211 pMsg->changeCCCallback = callback;
4212 pMsg->pDevContext = pContext;
4213 pMsg->pVosContext = pVosContext;
4214
4215 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4216 msg.bodyptr = pMsg;
4217 msg.reserved = 0;
4218
4219 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
4220 {
4221 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self \n");
4222 palFreeMemory(pMac->hHdd, (void *)pMsg);
4223 status = eHAL_STATUS_FAILURE;
4224 }
4225 smsLog(pMac, LOG1, FL(" returned\n"));
4226 sme_ReleaseGlobalLock( &pMac->sme );
4227 }
4228
4229 return (status);
4230}
4231
4232/* ---------------------------------------------------------------------------
4233 \fn sme_BtcSignalBtEvent
4234 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
4235 BT event type and the current operating mode of Libra (full power,
4236 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
4237 would be employed.
4238 \param hHal - The handle returned by macOpen.
4239 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
4240 Caller owns the memory and is responsible for freeing it.
4241 \return VOS_STATUS
4242 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
4243 if BTC execution mode is set to BTC_WLAN_ONLY
4244 or BTC_PTA_ONLY.
4245 VOS_STATUS_SUCCESS BT Event passed to HAL
4246 ---------------------------------------------------------------------------*/
4247VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
4248{
4249 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4250#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4251 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4252
4253 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4254 {
4255 status = btcSignalBTEvent (hHal, pBtEvent);
4256 sme_ReleaseGlobalLock( &pMac->sme );
4257 }
4258#endif
4259 return (status);
4260}
4261
4262/* ---------------------------------------------------------------------------
4263 \fn sme_BtcSetConfig
4264 \brief API to change the current Bluetooth Coexistence (BTC) configuration
4265 This function should be invoked only after CFG download has completed.
4266 Calling it after sme_HDDReadyInd is recommended.
4267 \param hHal - The handle returned by macOpen.
4268 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
4269 Caller owns the memory and is responsible for freeing it.
4270 \return VOS_STATUS
4271 VOS_STATUS_E_FAILURE Config not passed to HAL.
4272 VOS_STATUS_SUCCESS Config passed to HAL
4273 ---------------------------------------------------------------------------*/
4274VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4275{
4276 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4277#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4278 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4279 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4280 {
4281 status = btcSetConfig (hHal, pSmeBtcConfig);
4282 sme_ReleaseGlobalLock( &pMac->sme );
4283 }
4284#endif
4285 return (status);
4286}
4287
4288/* ---------------------------------------------------------------------------
4289 \fn sme_BtcGetConfig
4290 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
4291 \param hHal - The handle returned by macOpen.
4292 \param pSmeBtcConfig - Pointer to a caller allocated object of type
4293 tSmeBtcConfig. Caller owns the memory and is responsible
4294 for freeing it.
4295 \return VOS_STATUS
4296 VOS_STATUS_E_FAILURE - failure
4297 VOS_STATUS_SUCCESS success
4298 ---------------------------------------------------------------------------*/
4299VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4300{
4301 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4302#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4303 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4304
4305 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4306 {
4307 status = btcGetConfig (hHal, pSmeBtcConfig);
4308 sme_ReleaseGlobalLock( &pMac->sme );
4309 }
4310#endif
4311 return (status);
4312}
4313/* ---------------------------------------------------------------------------
4314 \fn sme_SetCfgPrivacy
4315 \brief API to set configure privacy parameters
4316 \param hHal - The handle returned by macOpen.
4317 \param pProfile - Pointer CSR Roam profile.
4318 \param fPrivacy - This parameter indicates status of privacy
4319
4320 \return void
4321 ---------------------------------------------------------------------------*/
4322void sme_SetCfgPrivacy( tHalHandle hHal,
4323 tCsrRoamProfile *pProfile,
4324 tANI_BOOLEAN fPrivacy
4325 )
4326{
4327 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4328 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4329 {
4330 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
4331 sme_ReleaseGlobalLock( &pMac->sme );
4332 }
4333}
4334
4335#if defined WLAN_FEATURE_VOWIFI
4336/* ---------------------------------------------------------------------------
4337 \fn sme_NeighborReportRequest
4338 \brief API to request neighbor report.
4339 \param hHal - The handle returned by macOpen.
4340 \param pRrmNeighborReq - Pointer to a caller allocated object of type
4341 tRrmNeighborReq. Caller owns the memory and is responsible
4342 for freeing it.
4343 \return VOS_STATUS
4344 VOS_STATUS_E_FAILURE - failure
4345 VOS_STATUS_SUCCESS success
4346 ---------------------------------------------------------------------------*/
4347VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
4348 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
4349{
4350 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4351 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4352
4353 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4354 {
4355 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
4356 sme_ReleaseGlobalLock( &pMac->sme );
4357 }
4358
4359 return (status);
4360}
4361#endif
4362
4363//The following are debug APIs to support direct read/write register/memory
4364//They are placed in SME because HW cannot be access when in LOW_POWER state
4365//AND not connected. The knowledge and synchronization is done in SME
4366
4367//sme_DbgReadRegister
4368//Caller needs to validate the input values
4369VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
4370{
4371 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4372 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4373#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4374 tHddHandle hHdd = pMac->hHdd;
4375#endif
4376 tPmcPowerState PowerState;
4377 tANI_U32 sessionId = 0;
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004378 tANI_U32 cmd = READ_REG_DUMP_CMD;
4379 tANI_U32 arg1 = regAddr;
4380 tANI_U32 arg2 = 0;
4381 tANI_U32 arg3 = 0;
4382 tANI_U32 arg4 = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004383
4384 /* 1) To make Quarky work in FTM mode **************************************/
4385
4386 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4387 {
4388#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4389 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue)))
4390#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004391 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8 *)pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004392#endif
4393 {
4394 return VOS_STATUS_SUCCESS;
4395 }
4396 return VOS_STATUS_E_FAILURE;
4397 }
4398
4399 /* 2) NON FTM mode driver *************************************************/
4400
4401 /* Acquire SME global lock */
4402 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4403 {
4404 return VOS_STATUS_E_FAILURE;
4405 }
4406
4407 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4408 {
4409 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4410 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4411 {
4412#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4413 if (HAL_STATUS_SUCCESS(palReadRegister(hHdd, regAddr, pRegValue )))
4414#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004415 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8 *)pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004416#endif
4417 {
4418 status = VOS_STATUS_SUCCESS;
4419 }
4420 else
4421 {
4422 status = VOS_STATUS_E_FAILURE;
4423 }
4424 }
4425 else
4426 {
4427 status = VOS_STATUS_E_FAILURE;
4428 }
4429 }
4430
4431 /* This is a hack for Qualky/pttWniSocket
4432 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4433 if ( VOS_STATUS_SUCCESS != status )
4434 {
4435 *pRegValue = 0xDEADBEEF;
4436 status = VOS_STATUS_SUCCESS;
4437 }
4438
4439 /* Release SME global lock */
4440 sme_ReleaseGlobalLock(&pMac->sme);
4441
4442 return (status);
4443}
4444
4445
4446//sme_DbgWriteRegister
4447//Caller needs to validate the input values
4448VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
4449{
4450 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4451 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4452#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4453 tHddHandle hHdd = pMac->hHdd;
4454#endif
4455 tPmcPowerState PowerState;
4456 tANI_U32 sessionId = 0;
4457
4458 /* 1) To make Quarky work in FTM mode **************************************/
4459
4460 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4461 {
4462#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4463 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4464#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4465 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4466#endif
4467 {
4468 return VOS_STATUS_SUCCESS;
4469 }
4470 return VOS_STATUS_E_FAILURE;
4471 }
4472
4473 /* 2) NON FTM mode driver *************************************************/
4474
4475 /* Acquire SME global lock */
4476 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4477 {
4478 return VOS_STATUS_E_FAILURE;
4479 }
4480
4481 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4482 {
4483 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4484 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4485 {
4486#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4487 if (HAL_STATUS_SUCCESS(palWriteRegister(hHdd, regAddr, regValue)))
4488#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4489 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
4490#endif
4491 {
4492 status = VOS_STATUS_SUCCESS;
4493 }
4494 else
4495 {
4496 status = VOS_STATUS_E_FAILURE;
4497 }
4498 }
4499 else
4500 {
4501 status = VOS_STATUS_E_FAILURE;
4502 }
4503 }
4504
4505 /* Release SME global lock */
4506 sme_ReleaseGlobalLock(&pMac->sme);
4507
4508 return (status);
4509}
4510
4511
4512
4513//sme_DbgReadMemory
4514//Caller needs to validate the input values
4515//pBuf caller allocated buffer has the length of nLen
4516VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4517{
4518 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4519 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4520#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4521 v_PVOID_t pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *)hHal);
4522 tHddHandle hHdd = pMac->hHdd;
4523#endif
4524 tPmcPowerState PowerState;
4525 tANI_U32 sessionId = 0;
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004526 tANI_U32 cmd = READ_MEMORY_DUMP_CMD;
4527 tANI_U32 arg1 = memAddr;
4528 tANI_U32 arg2 = nLen/4;
4529 tANI_U32 arg3 = 4;
4530 tANI_U32 arg4 = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 /* 1) To make Quarky work in FTM mode **************************************/
4532
4533 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4534 {
4535#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4536 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4537#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004538 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8*)pBuf))
Jeff Johnson295189b2012-06-20 16:38:30 -07004539#endif
4540 {
4541 return VOS_STATUS_SUCCESS;
4542 }
4543 return VOS_STATUS_E_FAILURE;
4544 }
4545
4546 /* 2) NON FTM mode driver *************************************************/
4547
4548 /* Acquire SME global lock */
4549 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4550 {
4551 return VOS_STATUS_E_FAILURE;
4552 }
4553
4554 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4555 {
4556 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4557 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4558 {
4559#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4560 if (HAL_STATUS_SUCCESS(palReadDeviceMemory(pvosGCTx, memAddr, (void *)pBuf, nLen)))
4561#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004562 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8 *)pBuf))
Jeff Johnson295189b2012-06-20 16:38:30 -07004563#endif
4564 {
4565 status = VOS_STATUS_SUCCESS;
4566 }
4567 else
4568 {
4569 status = VOS_STATUS_E_FAILURE;
4570 }
4571 }
4572 else
4573 {
4574 status = VOS_STATUS_E_FAILURE;
4575 }
4576 }
4577
4578 /* This is a hack for Qualky/pttWniSocket
4579 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4580 if (VOS_STATUS_SUCCESS != status)
4581 {
4582 vos_mem_set(pBuf, nLen, 0xCD);
4583 status = VOS_STATUS_SUCCESS;
4584 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware\n"));
4585 }
4586
4587 /* Release SME lock */
4588 sme_ReleaseGlobalLock(&pMac->sme);
4589
4590 return (status);
4591}
4592
4593
4594//sme_DbgWriteMemory
4595//Caller needs to validate the input values
4596VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4597{
4598 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4599 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4600#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4601 tHddHandle hHdd = pMac->hHdd;
4602#endif
4603 tPmcPowerState PowerState;
4604 tANI_U32 sessionId = 0;
4605
4606 /* 1) To make Quarky work in FTM mode **************************************/
4607
4608 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4609 {
4610#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4611 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4612#elif defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4613 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory( memAddr, (void *)pBuf, nLen))
4614#endif
4615 {
4616 return VOS_STATUS_SUCCESS;
4617 }
4618 return VOS_STATUS_E_FAILURE;
4619 }
4620
4621 /* 2) NON FTM mode driver *************************************************/
4622
4623 /* Acquire SME global lock */
4624 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4625 {
4626 return VOS_STATUS_E_FAILURE;
4627 }
4628
4629 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4630 {
4631 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4632 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4633 {
4634#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
4635 if (HAL_STATUS_SUCCESS(palWriteDeviceMemory(hHdd, memAddr, (void *)pBuf, nLen)))
4636#elif defined(FEATURE_WLAN_INTEGRATED_SOC)
4637 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
4638#endif
4639 {
4640 status = VOS_STATUS_SUCCESS;
4641 }
4642 else
4643 {
4644 status = VOS_STATUS_E_FAILURE;
4645 }
4646 }
4647 else
4648 {
4649 status = VOS_STATUS_E_FAILURE;
4650 }
4651 }
4652
4653 /* Release Global lock */
4654 sme_ReleaseGlobalLock(&pMac->sme);
4655
4656 return (status);
4657}
4658
4659
4660void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
4661{
4662#ifdef WLAN_DEBUG
4663 // Verify against current log level
4664 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
4665 return;
4666 else
4667 {
4668 va_list marker;
4669
4670 va_start( marker, pString ); /* Initialize variable arguments. */
4671
4672 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
4673
4674 va_end( marker ); /* Reset variable arguments. */
4675 }
4676#endif
4677}
4678#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
4679/* ---------------------------------------------------------------------------
4680 \fn sme_GetFwVersion
4681 \brief This API returns the firmware version.
4682 \param hHal - The handle returned by macOpen.
4683 \param version - Points to the FwVersionInfo structure.
4684 \return VOS_STATUS
4685 VOS_STATUS_E_INVAL - failure
4686 VOS_STATUS_SUCCESS success
4687 ---------------------------------------------------------------------------*/
4688VOS_STATUS sme_GetFwVersion (tHalHandle hHal,FwVersionInfo *pVersion)
4689{
4690 VOS_STATUS status = VOS_STATUS_SUCCESS;
4691 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4692
4693 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4694 {
4695 if( pVersion != NULL ) {
4696 vos_mem_copy((v_VOID_t*)pVersion,(v_VOID_t*)&pMac->hal.FwParam.fwVersion, sizeof(FwVersionInfo));
4697 }
4698 else {
4699 status = VOS_STATUS_E_INVAL;
4700 }
4701 sme_ReleaseGlobalLock( &pMac->sme );
4702 }
4703
4704 return (status);
4705}
4706#endif
4707
4708#ifdef FEATURE_WLAN_INTEGRATED_SOC
4709/* ---------------------------------------------------------------------------
4710 \fn sme_GetWcnssWlanCompiledVersion
4711 \brief This API returns the version of the WCNSS WLAN API with
4712 which the HOST driver was built
4713 \param hHal - The handle returned by macOpen.
4714 \param pVersion - Points to the Version structure to be filled
4715 \return VOS_STATUS
4716 VOS_STATUS_E_INVAL - failure
4717 VOS_STATUS_SUCCESS success
4718 ---------------------------------------------------------------------------*/
4719VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
4720 tSirVersionType *pVersion)
4721{
4722 VOS_STATUS status = VOS_STATUS_SUCCESS;
4723 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4724 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4725
4726 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4727 {
4728 if( pVersion != NULL )
4729 {
4730 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
4731 }
4732 else
4733 {
4734 status = VOS_STATUS_E_INVAL;
4735 }
4736 sme_ReleaseGlobalLock( &pMac->sme );
4737 }
4738
4739 return (status);
4740}
4741
4742
4743/* ---------------------------------------------------------------------------
4744 \fn sme_GetWcnssWlanReportedVersion
4745 \brief This API returns the version of the WCNSS WLAN API with
4746 which the WCNSS driver reports it was built
4747 \param hHal - The handle returned by macOpen.
4748 \param pVersion - Points to the Version structure to be filled
4749 \return VOS_STATUS
4750 VOS_STATUS_E_INVAL - failure
4751 VOS_STATUS_SUCCESS success
4752 ---------------------------------------------------------------------------*/
4753VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
4754 tSirVersionType *pVersion)
4755{
4756 VOS_STATUS status = VOS_STATUS_SUCCESS;
4757 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4758 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4759
4760 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4761 {
4762 if( pVersion != NULL )
4763 {
4764 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
4765 }
4766 else
4767 {
4768 status = VOS_STATUS_E_INVAL;
4769 }
4770 sme_ReleaseGlobalLock( &pMac->sme );
4771 }
4772
4773 return (status);
4774}
4775
4776
4777/* ---------------------------------------------------------------------------
4778 \fn sme_GetWcnssSoftwareVersion
4779 \brief This API returns the version string of the WCNSS driver
4780 \param hHal - The handle returned by macOpen.
4781 \param pVersion - Points to the Version string buffer to be filled
4782 \param versionBufferSize - THe size of the Version string buffer
4783 \return VOS_STATUS
4784 VOS_STATUS_E_INVAL - failure
4785 VOS_STATUS_SUCCESS success
4786 ---------------------------------------------------------------------------*/
4787VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
4788 tANI_U8 *pVersion,
4789 tANI_U32 versionBufferSize)
4790{
4791 VOS_STATUS status = VOS_STATUS_SUCCESS;
4792 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4793 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4794
4795 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4796 {
4797 if( pVersion != NULL )
4798 {
4799 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
4800 versionBufferSize);
4801 }
4802 else
4803 {
4804 status = VOS_STATUS_E_INVAL;
4805 }
4806 sme_ReleaseGlobalLock( &pMac->sme );
4807 }
4808
4809 return (status);
4810}
4811
4812
4813/* ---------------------------------------------------------------------------
4814 \fn sme_GetWcnssHardwareVersion
4815 \brief This API returns the version string of the WCNSS hardware
4816 \param hHal - The handle returned by macOpen.
4817 \param pVersion - Points to the Version string buffer to be filled
4818 \param versionBufferSize - THe size of the Version string buffer
4819 \return VOS_STATUS
4820 VOS_STATUS_E_INVAL - failure
4821 VOS_STATUS_SUCCESS success
4822 ---------------------------------------------------------------------------*/
4823VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
4824 tANI_U8 *pVersion,
4825 tANI_U32 versionBufferSize)
4826{
4827 VOS_STATUS status = VOS_STATUS_SUCCESS;
4828 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4829 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
4830
4831 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4832 {
4833 if( pVersion != NULL )
4834 {
4835 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
4836 versionBufferSize);
4837 }
4838 else
4839 {
4840 status = VOS_STATUS_E_INVAL;
4841 }
4842 sme_ReleaseGlobalLock( &pMac->sme );
4843 }
4844
4845 return (status);
4846}
4847#endif
4848
4849#ifdef FEATURE_WLAN_WAPI
4850/* ---------------------------------------------------------------------------
4851 \fn sme_RoamSetBKIDCache
4852 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
4853 candidate list.
4854 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4855 it is opened (by calling halOpen).
4856 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
4857 \param numItems - a variable that has the number of tBkidCacheInfo allocated
4858 when retruning, this is the number of items put into pBKIDCache
4859 \return eHalStatus - when fail, it usually means the buffer allocated is not
4860 big enough and pNumItems has the number of tBkidCacheInfo.
4861 ---------------------------------------------------------------------------*/
4862eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
4863 tANI_U32 numItems )
4864{
4865 eHalStatus status = eHAL_STATUS_FAILURE;
4866 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4867
4868 status = sme_AcquireGlobalLock( &pMac->sme );
4869 if ( HAL_STATUS_SUCCESS( status ) )
4870 {
4871 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
4872 sme_ReleaseGlobalLock( &pMac->sme );
4873 }
4874
4875 return (status);
4876}
4877
4878/* ---------------------------------------------------------------------------
4879 \fn sme_RoamGetBKIDCache
4880 \brief The SME API exposed to HDD to allow HDD to request SME to return its
4881 BKID cache.
4882 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4883 it is opened (by calling halOpen).
4884 \param pNum - caller allocated memory that has the space of the number of
4885 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
4886 in SME cache.
4887 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
4888 upon return
4889 \return eHalStatus - when fail, it usually means the buffer allocated is not
4890 big enough.
4891 ---------------------------------------------------------------------------*/
4892eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
4893 tBkidCacheInfo *pBkidCache)
4894{
4895 eHalStatus status = eHAL_STATUS_FAILURE;
4896 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4897
4898 status = sme_AcquireGlobalLock( &pMac->sme );
4899 if ( HAL_STATUS_SUCCESS( status ) )
4900 {
4901 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded\n"));
4902 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
4903 sme_ReleaseGlobalLock( &pMac->sme );
4904 }
4905
4906 return (status);
4907}
4908
4909/* ---------------------------------------------------------------------------
4910 \fn sme_RoamGetNumBKIDCache
4911 \brief The SME API exposed to HDD to allow HDD to request SME to return the
4912 number of BKID cache entries.
4913 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
4914 it is opened (by calling halOpen).
4915 \return tANI_U32 - the number of BKID cache entries.
4916 ---------------------------------------------------------------------------*/
4917tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
4918{
4919 eHalStatus status = eHAL_STATUS_FAILURE;
4920 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4921 tANI_U32 numBkidCache = 0;
4922
4923 status = sme_AcquireGlobalLock( &pMac->sme );
4924 if ( HAL_STATUS_SUCCESS( status ) )
4925 {
4926 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
4927 sme_ReleaseGlobalLock( &pMac->sme );
4928 }
4929
4930 return (numBkidCache);
4931}
4932
4933/* ---------------------------------------------------------------------------
4934 \fn sme_ScanGetBKIDCandidateList
4935 \brief a wrapper function to return the BKID candidate list
4936 \param pBkidList - caller allocated buffer point to an array of
4937 tBkidCandidateInfo
4938 \param pNumItems - pointer to a variable that has the number of
4939 tBkidCandidateInfo allocated when retruning, this is
4940 either the number needed or number of items put into
4941 pPmkidList
4942 \return eHalStatus - when fail, it usually means the buffer allocated is not
4943 big enough and pNumItems
4944 has the number of tBkidCandidateInfo.
4945 \Note: pNumItems is a number of tBkidCandidateInfo,
4946 not sizeof(tBkidCandidateInfo) * something
4947 ---------------------------------------------------------------------------*/
4948eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
4949 tBkidCandidateInfo *pBkidList,
4950 tANI_U32 *pNumItems )
4951{
4952 eHalStatus status = eHAL_STATUS_FAILURE;
4953 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4954
4955 status = sme_AcquireGlobalLock( &pMac->sme );
4956 if ( HAL_STATUS_SUCCESS( status ) )
4957 {
4958 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
4959 sme_ReleaseGlobalLock( &pMac->sme );
4960 }
4961
4962 return (status);
4963}
4964#endif /* FEATURE_WLAN_WAPI */
4965
Jeff Johnsone7245742012-09-05 17:12:55 -07004966#ifdef FEATURE_OEM_DATA_SUPPORT
4967
4968/*****************************************************************************
4969 OEM DATA related modifications and function additions
4970 *****************************************************************************/
4971
4972/* ---------------------------------------------------------------------------
4973 \fn sme_getOemDataRsp
4974 \brief a wrapper function to obtain the OEM DATA RSP
4975 \param pOemDataRsp - A pointer to the response object
4976 \param pContext - a pointer passed in for the callback
4977 \return eHalStatus
4978 ---------------------------------------------------------------------------*/
4979eHalStatus sme_getOemDataRsp(tHalHandle hHal,
4980 tOemDataRsp **pOemDataRsp)
4981{
4982 eHalStatus status = eHAL_STATUS_SUCCESS;
4983 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4984
4985 do
4986 {
4987 //acquire the lock for the sme object
4988 status = sme_AcquireGlobalLock(&pMac->sme);
4989
4990 if(!HAL_STATUS_SUCCESS(status))
4991 {
4992 break;
4993 }
4994
4995 if(pMac->oemData.pOemDataRsp != NULL)
4996 {
4997 *pOemDataRsp = pMac->oemData.pOemDataRsp;
4998 }
4999 else
5000 {
5001 status = eHAL_STATUS_FAILURE;
5002 }
5003
5004 //release the lock for the sme object
5005 sme_ReleaseGlobalLock( &pMac->sme );
5006
5007 } while(0);
5008
5009 return status;
5010}
5011
5012/* ---------------------------------------------------------------------------
5013 \fn sme_OemDataReq
5014 \brief a wrapper function for OEM DATA REQ
5015 \param sessionId - session id to be used.
5016 \param pOemDataReqId - pointer to an object to get back the request ID
5017 \param callback - a callback function that is called upon finish
5018 \param pContext - a pointer passed in for the callback
5019 \return eHalStatus
5020 ---------------------------------------------------------------------------*/
5021eHalStatus sme_OemDataReq(tHalHandle hHal,
5022 tANI_U8 sessionId,
5023 tOemDataReqConfig *pOemDataReqConfig,
5024 tANI_U32 *pOemDataReqID,
5025 oemData_OemDataReqCompleteCallback callback,
5026 void *pContext)
5027{
5028 eHalStatus status = eHAL_STATUS_SUCCESS;
5029 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5030
5031 do
5032 {
5033 //acquire the lock for the sme object
5034 status = sme_AcquireGlobalLock(&pMac->sme);
5035 if(HAL_STATUS_SUCCESS(status))
5036 {
5037 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
5038
5039 if(pOemDataReqID)
5040 {
5041 *pOemDataReqID = lOemDataReqId;
5042 }
5043 else
5044 return eHAL_STATUS_FAILURE;
5045
5046 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
5047
5048 //release the lock for the sme object
5049 sme_ReleaseGlobalLock( &pMac->sme );
5050 }
5051 } while(0);
5052
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005053 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07005054
5055 return(status);
5056}
5057
5058#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005059
5060/*--------------------------------------------------------------------------
5061
5062 \brief sme_OpenSession() - Open a session for scan/roam operation.
5063
5064 This is a synchronous API.
5065
5066
5067 \param hHal - The handle returned by macOpen.
5068 \param callback - A pointer to the function caller specifies for roam/connect status indication
5069 \param pContext - The context passed with callback
5070 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
5071 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
5072
5073 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
5074
5075 Other status means SME is failed to open the session.
5076 eHAL_STATUS_RESOURCES - no more session available.
5077 \sa
5078
5079 --------------------------------------------------------------------------*/
5080eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback, void *pContext,
5081 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId)
5082{
5083 eHalStatus status;
5084 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5085
5086 if( NULL == pbSessionId )
5087 {
5088 status = eHAL_STATUS_INVALID_PARAMETER;
5089 }
5090 else
5091 {
5092 status = sme_AcquireGlobalLock( &pMac->sme );
5093 if ( HAL_STATUS_SUCCESS( status ) )
5094 {
5095 status = csrRoamOpenSession( pMac, callback, pContext, pSelfMacAddr, pbSessionId );
5096
5097 sme_ReleaseGlobalLock( &pMac->sme );
5098 }
5099 }
5100
5101 return ( status );
5102}
5103
5104
5105/*--------------------------------------------------------------------------
5106
5107 \brief sme_CloseSession() - Open a session for scan/roam operation.
5108
5109 This is a synchronous API.
5110
5111
5112 \param hHal - The handle returned by macOpen.
5113
5114 \param sessionId - A previous opened session's ID.
5115
5116 \return eHAL_STATUS_SUCCESS - session is closed.
5117
5118 Other status means SME is failed to open the session.
5119 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
5120 \sa
5121
5122 --------------------------------------------------------------------------*/
5123eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
5124 csrRoamSessionCloseCallback callback, void *pContext)
5125{
5126 eHalStatus status;
5127 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5128
5129 status = sme_AcquireGlobalLock( &pMac->sme );
5130 if ( HAL_STATUS_SUCCESS( status ) )
5131 {
5132 status = csrRoamCloseSession( pMac, sessionId, FALSE,
5133 callback, pContext );
5134
5135 sme_ReleaseGlobalLock( &pMac->sme );
5136 }
5137
5138 return ( status );
5139}
5140
5141#ifdef WLAN_SOFTAP_FEATURE
5142/* ---------------------------------------------------------------------------
5143
5144 \fn sme_RoamUpdateAPWPSIE
5145
5146 \brief To update AP's WPS IE. This function should be called after SME AP session is created
5147 This is an asynchronous API.
5148
5149 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
5150
5151 \return eHalStatus – SUCCESS –
5152
5153 FAILURE or RESOURCES – The API finished and failed.
5154
5155 -------------------------------------------------------------------------------*/
5156eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
5157{
5158
5159 eHalStatus status = eHAL_STATUS_FAILURE;
5160 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5161
5162 status = sme_AcquireGlobalLock( &pMac->sme );
5163 if ( HAL_STATUS_SUCCESS( status ) )
5164 {
5165
5166 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
5167
5168 sme_ReleaseGlobalLock( &pMac->sme );
5169 }
5170
5171 return (status);
5172}
5173/* ---------------------------------------------------------------------------
5174
5175 \fn sme_RoamUpdateAPWPARSNIEs
5176
5177 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
5178 This is an asynchronous API.
5179
5180 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
5181
5182 \return eHalStatus – SUCCESS –
5183
5184 FAILURE or RESOURCES – The API finished and failed.
5185
5186 -------------------------------------------------------------------------------*/
5187eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
5188{
5189
5190 eHalStatus status = eHAL_STATUS_FAILURE;
5191 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5192
5193 status = sme_AcquireGlobalLock( &pMac->sme );
5194 if ( HAL_STATUS_SUCCESS( status ) )
5195 {
5196
5197 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
5198
5199 sme_ReleaseGlobalLock( &pMac->sme );
5200 }
5201
5202 return (status);
5203}
5204#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005205/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07005206
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005207 \fn sme_ChangeMCCBeaconInterval
5208
5209 \brief To update P2P-GO beaconInterval. This function should be called after
5210 disassociating all the station is done
5211 This is an asynchronous API.
5212
5213 \param
5214
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005215 \return eHalStatus SUCCESS
5216 FAILURE or RESOURCES
5217 The API finished and failed.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005218
5219 -------------------------------------------------------------------------------*/
5220eHalStatus sme_ChangeMCCBeaconInterval(tHalHandle hHal, tANI_U8 sessionId)
5221{
5222 eHalStatus status = eHAL_STATUS_FAILURE;
5223 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5224
5225 smsLog(pMac, LOG1, FL("Update Beacon PARAMS \n"));
5226 status = sme_AcquireGlobalLock( &pMac->sme );
5227 if ( HAL_STATUS_SUCCESS( status ) )
5228 {
5229 status = csrSendChngMCCBeaconInterval( pMac, sessionId);
5230 sme_ReleaseGlobalLock( &pMac->sme );
5231 }
5232 return (status);
5233}
Jeff Johnson295189b2012-06-20 16:38:30 -07005234
5235/*-------------------------------------------------------------------------------*
5236
5237 \fn sme_sendBTAmpEvent
5238
5239 \brief to receive the coex priorty request from BT-AMP PAL
5240 and send the BT_AMP link state to HAL
5241
5242 \param btAmpEvent - btAmpEvent
5243
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005244 \return eHalStatus: SUCCESS : BTAmp event successfully sent to HAL
Jeff Johnson295189b2012-06-20 16:38:30 -07005245
5246 FAILURE: API failed
5247
5248-------------------------------------------------------------------------------*/
5249
5250eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
5251{
5252 vos_msg_t msg;
5253 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
5254 eHalStatus status = eHAL_STATUS_FAILURE;
5255
5256 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tpSmeBtAmpEvent));
5257 if (NULL == ptrSmeBtAmpEvent)
5258 {
5259 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005260 "Not able to allocate memory for BTAmp event", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 return status;
5262 }
5263
5264 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
5265 msg.type = WDA_SIGNAL_BTAMP_EVENT;
5266 msg.reserved = 0;
5267 msg.bodyptr = ptrSmeBtAmpEvent;
5268
5269 //status = halFW_SendBTAmpEventMesg(pMac, event);
5270
5271 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5272 {
5273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005274 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 vos_mem_free(ptrSmeBtAmpEvent);
5276 return status;
5277 }
5278
5279 return eHAL_STATUS_SUCCESS;
5280
5281}
5282
5283/* ---------------------------------------------------------------------------
5284 \fn sme_SetHostOffload
5285 \brief API to set the host offload feature.
5286 \param hHal - The handle returned by macOpen.
5287 \param pRequest - Pointer to the offload request.
5288 \return eHalStatus
5289 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005290eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
5291 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005292{
5293 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07005294 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005295
5296 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5297 {
5298#ifdef WLAN_NS_OFFLOAD
5299 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
5300 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005301 status = pmcSetNSOffload( hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 }
5303 else
5304#endif //WLAN_NS_OFFLOAD
5305 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005306 status = pmcSetHostOffload (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 }
5308 sme_ReleaseGlobalLock( &pMac->sme );
5309 }
5310
5311 return (status);
5312}
5313
5314#ifdef WLAN_FEATURE_GTK_OFFLOAD
5315/* ---------------------------------------------------------------------------
5316 \fn sme_SetGTKOffload
5317 \brief API to set GTK offload information.
5318 \param hHal - The handle returned by macOpen.
5319 \param pRequest - Pointer to the GTK offload request.
5320 \return eHalStatus
5321 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005322eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest,
5323 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005324{
5325 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5326 eHalStatus status;
5327
5328 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5329 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005330 status = pmcSetGTKOffload( hHal, pRequest, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 sme_ReleaseGlobalLock( &pMac->sme );
5332 }
5333
5334 return (status);
5335}
5336
5337/* ---------------------------------------------------------------------------
5338 \fn sme_GetGTKOffload
5339 \brief API to get GTK offload information.
5340 \param hHal - The handle returned by macOpen.
5341 \param pRequest - Pointer to the GTK offload response.
5342 \return eHalStatus
5343 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005344eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
5345 void *callbackContext, tANI_U8 sessionId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005346{
5347 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5348 eHalStatus status;
5349
5350 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5351 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005352 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 sme_ReleaseGlobalLock( &pMac->sme );
5354 }
5355
5356 return (status);
5357}
5358#endif // WLAN_FEATURE_GTK_OFFLOAD
5359
5360/* ---------------------------------------------------------------------------
5361 \fn sme_SetKeepAlive
5362 \brief API to set the Keep Alive feature.
5363 \param hHal - The handle returned by macOpen.
5364 \param pRequest - Pointer to the Keep Alive request.
5365 \return eHalStatus
5366 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005367eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
5368 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005369{
5370 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5371 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5373 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005374 status = pmcSetKeepAlive (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 sme_ReleaseGlobalLock( &pMac->sme );
5376 }
5377
5378 return (status);
5379}
5380
5381#ifdef FEATURE_WLAN_SCAN_PNO
5382/* ---------------------------------------------------------------------------
5383 \fn sme_SetPreferredNetworkList
5384 \brief API to set the Preferred Network List Offload feature.
5385 \param hHal - The handle returned by macOpen.
5386 \param pRequest - Pointer to the offload request.
5387 \return eHalStatus
5388 ---------------------------------------------------------------------------*/
5389eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
5390{
5391 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5392 eHalStatus status;
5393
5394 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5395 {
5396 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
5397 sme_ReleaseGlobalLock( &pMac->sme );
5398 }
5399
5400 return (status);
5401}
5402
5403eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
5404{
5405 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5406 eHalStatus status;
5407
5408 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5409 {
5410 pmcSetRssiFilter(hHal, rssiThreshold);
5411 sme_ReleaseGlobalLock( &pMac->sme );
5412 }
5413
5414 return (status);
5415}
5416
5417#endif // FEATURE_WLAN_SCAN_PNO
5418
5419eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams)
5420{
5421 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5422 eHalStatus status;
5423
5424 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5425 {
5426 pmcSetPowerParams(hHal, pwParams);
5427 sme_ReleaseGlobalLock( &pMac->sme );
5428 }
5429
5430 return (status);
5431}
5432
5433/* ---------------------------------------------------------------------------
5434 \fn sme_AbortMacScan
5435 \brief API to cancel MAC scan.
5436 \param hHal - The handle returned by macOpen.
5437 \return VOS_STATUS
5438 VOS_STATUS_E_FAILURE - failure
5439 VOS_STATUS_SUCCESS success
5440 ---------------------------------------------------------------------------*/
5441eHalStatus sme_AbortMacScan(tHalHandle hHal)
5442{
5443 eHalStatus status;
5444 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5445
5446 status = sme_AcquireGlobalLock( &pMac->sme );
5447 if ( HAL_STATUS_SUCCESS( status ) )
5448 {
5449 status = csrScanAbortMacScan(pMac);
5450
5451 sme_ReleaseGlobalLock( &pMac->sme );
5452 }
5453
5454 return ( status );
5455}
5456
5457/* ----------------------------------------------------------------------------
5458 \fn sme_GetOperationChannel
5459 \brief API to get current channel on which STA is parked
5460 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005461 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 \returns eHAL_STATUS_SUCCESS
5463 eHAL_STATUS_FAILURE
5464-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005465eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005466{
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5468 tCsrRoamSession *pSession;
5469
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005470 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005472 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005473
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005474 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
5475 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005476#ifdef WLAN_SOFTAP_FEATURE
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005477 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
5478#endif
5479 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
5480 {
5481 *pChannel =pSession->connectedProfile.operationChannel;
5482 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 }
5484 }
5485 return eHAL_STATUS_FAILURE;
5486}// sme_GetOperationChannel ends here
5487
5488#ifdef WLAN_FEATURE_P2P
5489/* ---------------------------------------------------------------------------
5490
5491 \fn sme_RegisterMgtFrame
5492
5493 \brief To register managment frame of specified type and subtype.
5494 \param frameType - type of the frame that needs to be passed to HDD.
5495 \param matchData - data which needs to be matched before passing frame
5496 to HDD.
5497 \param matchDataLen - Length of matched data.
5498 \return eHalStatus
5499 -------------------------------------------------------------------------------*/
5500eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5501 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5502{
5503 eHalStatus status = eHAL_STATUS_SUCCESS;
5504 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5505
5506 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5507 {
5508 tSirRegisterMgmtFrame *pMsg;
5509 tANI_U16 len;
5510 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005511
5512 if(!pSession)
5513 {
5514 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5515 return eHAL_STATUS_FAILURE;
5516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005517
5518 if( !pSession->sessionActive )
5519 {
5520 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005521 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005522 sme_ReleaseGlobalLock( &pMac->sme );
5523 return eHAL_STATUS_FAILURE;
5524 }
5525
5526 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5527
5528 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5529 if(HAL_STATUS_SUCCESS(status))
5530 {
5531 palZeroMemory(pMac->hHdd, pMsg, len);
5532 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5533 pMsg->length = len;
5534 pMsg->sessionId = sessionId;
5535 pMsg->registerFrame = VOS_TRUE;
5536 pMsg->frameType = frameType;
5537 pMsg->matchLen = matchLen;
5538 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5539 status = palSendMBMessage(pMac->hHdd, pMsg);
5540 }
5541 sme_ReleaseGlobalLock( &pMac->sme );
5542 }
5543 return status;
5544}
5545
5546/* ---------------------------------------------------------------------------
5547
5548 \fn sme_DeregisterMgtFrame
5549
5550 \brief To De-register managment frame of specified type and subtype.
5551 \param frameType - type of the frame that needs to be passed to HDD.
5552 \param matchData - data which needs to be matched before passing frame
5553 to HDD.
5554 \param matchDataLen - Length of matched data.
5555 \return eHalStatus
5556 -------------------------------------------------------------------------------*/
5557eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
5558 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
5559{
5560 eHalStatus status = eHAL_STATUS_SUCCESS;
5561 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5562
5563 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5564 {
5565 tSirRegisterMgmtFrame *pMsg;
5566 tANI_U16 len;
5567 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005568
5569 if(!pSession)
5570 {
5571 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5572 return eHAL_STATUS_FAILURE;
5573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005574
5575 if( !pSession->sessionActive )
5576 {
5577 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005578 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 sme_ReleaseGlobalLock( &pMac->sme );
5580 return eHAL_STATUS_FAILURE;
5581 }
5582
5583 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5584
5585 status = palAllocateMemory(pMac->hHdd, (void**)&pMsg, len );
5586 if(HAL_STATUS_SUCCESS(status))
5587 {
5588 palZeroMemory(pMac->hHdd, pMsg, len);
5589 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5590 pMsg->length = len;
5591 pMsg->registerFrame = VOS_FALSE;
5592 pMsg->frameType = frameType;
5593 pMsg->matchLen = matchLen;
5594 palCopyMemory( pMac, pMsg->matchData, matchData, matchLen);
5595 status = palSendMBMessage(pMac->hHdd, pMsg);
5596 }
5597 sme_ReleaseGlobalLock( &pMac->sme );
5598 }
5599 return status;
5600}
5601
5602/* ---------------------------------------------------------------------------
5603 \fn sme_RemainOnChannel
5604 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
5605 \param hHal - The handle returned by macOpen.
5606 \param pRequest - channel
5607 \param duration - duration in ms
5608 \param callback - HDD registered callback to process reaminOnChannelRsp
5609 \param context - HDD Callback param
5610 \return eHalStatus
5611 ---------------------------------------------------------------------------*/
5612
5613eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
5614 tANI_U8 channel, tANI_U32 duration,
5615 remainOnChanCallback callback,
5616 void *pContext)
5617{
5618 eHalStatus status = eHAL_STATUS_SUCCESS;
5619 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5620
5621 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5622 {
5623 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext
5624#ifdef WLAN_FEATURE_P2P_INTERNAL
5625 , eP2PRemainOnChnReasonUnknown
5626#endif
5627 );
5628 sme_ReleaseGlobalLock( &pMac->sme );
5629 }
5630 return(status);
5631}
5632
5633/* ---------------------------------------------------------------------------
5634 \fn sme_ReportProbeReq
5635 \brief API to enable/disable forwarding of probeReq to apps in p2p.
5636 \param hHal - The handle returned by macOpen.
5637 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
5638 \return eHalStatus
5639 ---------------------------------------------------------------------------*/
5640
5641#ifndef WLAN_FEATURE_CONCURRENT_P2P
5642eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
5643{
5644 eHalStatus status = eHAL_STATUS_SUCCESS;
5645 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5646
5647 do
5648 {
5649 //acquire the lock for the sme object
5650 status = sme_AcquireGlobalLock(&pMac->sme);
5651 if(HAL_STATUS_SUCCESS(status))
5652 {
5653 /* call set in context */
5654 pMac->p2pContext.probeReqForwarding = flag;
5655 //release the lock for the sme object
5656 sme_ReleaseGlobalLock( &pMac->sme );
5657 }
5658 } while(0);
5659
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005660 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005661
5662 return(status);
5663}
5664
5665/* ---------------------------------------------------------------------------
5666 \fn sme_updateP2pIe
5667 \brief API to set the P2p Ie in p2p context
5668 \param hHal - The handle returned by macOpen.
5669 \param p2pIe - Ptr to p2pIe from HDD.
5670 \param p2pIeLength: length of p2pIe
5671 \return eHalStatus
5672 ---------------------------------------------------------------------------*/
5673
5674eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
5675{
5676 eHalStatus status = eHAL_STATUS_SUCCESS;
5677 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5678
5679 //acquire the lock for the sme object
5680 status = sme_AcquireGlobalLock(&pMac->sme);
5681 if(HAL_STATUS_SUCCESS(status))
5682 {
5683 if(NULL != pMac->p2pContext.probeRspIe){
5684 vos_mem_free(pMac->p2pContext.probeRspIe);
5685 pMac->p2pContext.probeRspIeLength = 0;
5686 }
5687
5688 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
5689 if (NULL == pMac->p2pContext.probeRspIe)
5690 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005691 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 pMac->p2pContext.probeRspIeLength = 0;
5693 status = eHAL_STATUS_FAILURE;
5694 }
5695 else
5696 {
5697 pMac->p2pContext.probeRspIeLength = p2pIeLength;
5698
5699 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
5700 pMac->p2pContext.probeRspIe,
5701 pMac->p2pContext.probeRspIeLength );
5702 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
5703 p2pIeLength);
5704 }
5705
5706 //release the lock for the sme object
5707 sme_ReleaseGlobalLock( &pMac->sme );
5708 }
5709
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005710 smsLog(pMac, LOG2, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005711
5712 return(status);
5713}
5714#endif
5715
5716/* ---------------------------------------------------------------------------
5717 \fn sme_sendAction
5718 \brief API to send action frame from supplicant.
5719 \param hHal - The handle returned by macOpen.
5720 \return eHalStatus
5721 ---------------------------------------------------------------------------*/
5722
5723eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07005724 const tANI_U8 *pBuf, tANI_U32 len,
5725 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07005726{
5727 eHalStatus status = eHAL_STATUS_SUCCESS;
5728 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5729
5730 //acquire the lock for the sme object
5731 status = sme_AcquireGlobalLock(&pMac->sme);
5732 if(HAL_STATUS_SUCCESS(status))
5733 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005734 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 //release the lock for the sme object
5736 sme_ReleaseGlobalLock( &pMac->sme );
5737 }
5738
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005739 smsLog(pMac, LOGW, "exiting function %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005740
5741 return(status);
5742}
5743
5744eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
5745{
5746 eHalStatus status = eHAL_STATUS_SUCCESS;
5747 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5748
5749 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5750 {
5751 status = p2pCancelRemainOnChannel (hHal, sessionId);
5752 sme_ReleaseGlobalLock( &pMac->sme );
5753 }
5754 return(status);
5755}
5756
5757//Power Save Related
5758eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
5759{
5760 eHalStatus status = eHAL_STATUS_SUCCESS;
5761 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5762
5763 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5764 {
5765 status = p2pSetPs (hHal, data);
5766 sme_ReleaseGlobalLock( &pMac->sme );
5767 }
5768 return(status);
5769}
5770
5771#endif
5772
5773/* ---------------------------------------------------------------------------
5774
5775 \fn sme_ConfigureRxpFilter
5776
5777 \brief
5778 SME will pass this request to lower mac to set/reset the filter on RXP for
5779 multicast & broadcast traffic.
5780
5781 \param
5782
5783 hHal - The handle returned by macOpen.
5784
5785 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
5786 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
5787 on this param. In future we can use this as a mask to set various types of
5788 filters as suggested below:
5789 FILTER_ALL_MULTICAST:
5790 FILTER_ALL_BROADCAST:
5791 FILTER_ALL_MULTICAST_BROADCAST:
5792
5793
5794 \return eHalStatus
5795
5796
5797--------------------------------------------------------------------------- */
5798eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
5799 tpSirWlanSetRxpFilters wlanRxpFilterParam)
5800{
5801 eHalStatus status = eHAL_STATUS_SUCCESS;
5802 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5803 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5804 vos_msg_t vosMessage;
5805
5806 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5807 {
5808 /* serialize the req through MC thread */
5809 vosMessage.bodyptr = wlanRxpFilterParam;
5810 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
5811 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5812 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5813 {
5814 status = eHAL_STATUS_FAILURE;
5815 }
5816 sme_ReleaseGlobalLock( &pMac->sme );
5817 }
5818 return(status);
5819}
5820
5821#ifdef FEATURE_WLAN_INTEGRATED_SOC
5822/* ---------------------------------------------------------------------------
5823
5824 \fn sme_ConfigureSuspendInd
5825
5826 \brief
5827 SME will pass this request to lower mac to Indicate that the wlan needs to
5828 be suspended
5829
5830 \param
5831
5832 hHal - The handle returned by macOpen.
5833
5834 wlanSuspendParam- Depicts the wlan suspend params
5835
5836
5837 \return eHalStatus
5838
5839
5840--------------------------------------------------------------------------- */
5841eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
5842 tpSirWlanSuspendParam wlanSuspendParam)
5843{
5844 eHalStatus status = eHAL_STATUS_SUCCESS;
5845 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5846 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5847 vos_msg_t vosMessage;
5848
5849 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5850 {
5851 /* serialize the req through MC thread */
5852 vosMessage.bodyptr = wlanSuspendParam;
5853 vosMessage.type = WDA_WLAN_SUSPEND_IND;
5854 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5855 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5856 {
5857 status = eHAL_STATUS_FAILURE;
5858 }
5859 sme_ReleaseGlobalLock( &pMac->sme );
5860 }
5861 return(status);
5862}
5863
5864/* ---------------------------------------------------------------------------
5865
5866 \fn sme_ConfigureResumeReq
5867
5868 \brief
5869 SME will pass this request to lower mac to Indicate that the wlan needs to
5870 be Resumed
5871
5872 \param
5873
5874 hHal - The handle returned by macOpen.
5875
5876 wlanResumeParam- Depicts the wlan resume params
5877
5878
5879 \return eHalStatus
5880
5881
5882--------------------------------------------------------------------------- */
5883eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
5884 tpSirWlanResumeParam wlanResumeParam)
5885{
5886 eHalStatus status = eHAL_STATUS_SUCCESS;
5887 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5888 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5889 vos_msg_t vosMessage;
5890
5891 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5892 {
5893 /* serialize the req through MC thread */
5894 vosMessage.bodyptr = wlanResumeParam;
5895 vosMessage.type = WDA_WLAN_RESUME_REQ;
5896 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5897 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5898 {
5899 status = eHAL_STATUS_FAILURE;
5900 }
5901 sme_ReleaseGlobalLock( &pMac->sme );
5902 }
5903 return(status);
5904}
5905
5906#endif
5907/* ---------------------------------------------------------------------------
5908
5909 \fn sme_GetInfraSessionId
5910
5911 \brief To get the session ID for infra session, if connected
5912 This is a synchronous API.
5913
5914 \param hHal - The handle returned by macOpen.
5915
5916 \return sessionid, -1 if infra session is not connected
5917
5918 -------------------------------------------------------------------------------*/
5919tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
5920{
5921 eHalStatus status = eHAL_STATUS_FAILURE;
5922 tANI_S8 sessionid = -1;
5923 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5924
5925 status = sme_AcquireGlobalLock( &pMac->sme );
5926 if ( HAL_STATUS_SUCCESS( status ) )
5927 {
5928
5929 sessionid = csrGetInfraSessionId( pMac);
5930
5931 sme_ReleaseGlobalLock( &pMac->sme );
5932 }
5933
5934 return (sessionid);
5935}
5936
5937/* ---------------------------------------------------------------------------
5938
5939 \fn sme_GetInfraOperationChannel
5940
5941 \brief To get the operating channel for infra session, if connected
5942 This is a synchronous API.
5943
5944 \param hHal - The handle returned by macOpen.
5945 \param sessionId - the sessionId returned by sme_OpenSession.
5946
5947 \return operating channel, 0 if infra session is not connected
5948
5949 -------------------------------------------------------------------------------*/
5950tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
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 = csrGetInfraOperationChannel( pMac, sessionId);
5960
5961 sme_ReleaseGlobalLock( &pMac->sme );
5962 }
5963
5964 return (channel);
5965}
5966
5967//This routine will return poerating channel on which other BSS is operating to be used for concurrency mode.
5968//If other BSS is not up or not connected it will return 0
5969tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
5970{
5971 eHalStatus status = eHAL_STATUS_FAILURE;
5972 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5973 tANI_U8 channel = 0;
5974 status = sme_AcquireGlobalLock( &pMac->sme );
5975 if ( HAL_STATUS_SUCCESS( status ) )
5976 {
5977
5978 channel = csrGetConcurrentOperationChannel( pMac );
5979 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005980 " Other Concurrent Channel = %d", __func__,channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 sme_ReleaseGlobalLock( &pMac->sme );
5982 }
5983
5984 return (channel);
5985}
5986
5987#ifdef FEATURE_WLAN_SCAN_PNO
5988/******************************************************************************
5989*
5990* Name: sme_PreferredNetworkFoundInd
5991*
5992* Description:
5993* Invoke Preferred Network Found Indication
5994*
5995* Parameters:
5996* hHal - HAL handle for device
5997* pMsg - found network description
5998*
5999* Returns: eHalStatus
6000*
6001******************************************************************************/
6002eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
6003{
6004 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6005 eHalStatus status = eHAL_STATUS_SUCCESS;
6006 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
6007
6008 if (NULL == pMsg)
6009 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006010 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 status = eHAL_STATUS_FAILURE;
6012 }
6013 else
6014 {
6015 if (pPrefNetworkFoundInd->ssId.length > 0)
6016 {
6017 smsLog(pMac, LOG1, "Preferred Network Found Indication in %s(), SSID=%s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006018 __func__, pPrefNetworkFoundInd->ssId.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006019
6020
6021 /* Call Preferred Netowrk Found Indication callback routine. */
6022 if (pMac->pmc.prefNetwFoundCB != NULL)
6023 {
6024 pMac->pmc.prefNetwFoundCB(pMac->pmc.preferredNetworkFoundIndCallbackContext, pPrefNetworkFoundInd);
6025 }
6026
6027 }
6028 else
6029 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006030 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 status = eHAL_STATUS_FAILURE;
6032 }
6033 }
6034
6035
6036 return(status);
6037}
6038
6039#endif // FEATURE_WLAN_SCAN_PNO
6040
6041
6042eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
6043{
6044 eHalStatus status = eHAL_STATUS_FAILURE;
6045 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6046
6047 status = sme_AcquireGlobalLock( &pMac->sme );
6048 if ( HAL_STATUS_SUCCESS( status ) )
6049 {
6050 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
6051 sme_ReleaseGlobalLock( &pMac->sme );
6052 }
6053
6054 return (status);
6055}
6056
6057
6058/* ---------------------------------------------------------------------------
6059
6060 \fn sme_SetTxPerTracking
6061
6062 \brief Set Tx PER tracking configuration parameters
6063
6064 \param hHal - The handle returned by macOpen.
6065 \param pTxPerTrackingConf - Tx PER configuration parameters
6066
6067 \return eHalStatus
6068
6069 -------------------------------------------------------------------------------*/
6070eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
6071 void (*pCallbackfn) (void *pCallbackContext),
6072 void *pCallbackContext,
6073 tpSirTxPerTrackingParam pTxPerTrackingParam)
6074{
6075 vos_msg_t msg;
6076 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
6077 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6078
6079 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6080 {
6081 pMac->sme.pTxPerHitCallback = pCallbackfn;
6082 pMac->sme.pTxPerHitCbContext = pCallbackContext;
6083 sme_ReleaseGlobalLock( &pMac->sme );
6084 }
6085
6086 // free this memory in failure case or WDA request callback function
6087 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
6088 if (NULL == pTxPerTrackingParamReq)
6089 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006090 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 -07006091 return eHAL_STATUS_FAILURE;
6092 }
6093
6094 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam, sizeof(tSirTxPerTrackingParam));
6095 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
6096 msg.reserved = 0;
6097 msg.bodyptr = pTxPerTrackingParamReq;
6098
6099 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6100 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006101 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 -07006102 vos_mem_free(pTxPerTrackingParamReq);
6103 return eHAL_STATUS_FAILURE;
6104 }
6105
6106 return eHAL_STATUS_SUCCESS;
6107}
6108
6109/* ---------------------------------------------------------------------------
6110
6111 \fn sme_HandleChangeCountryCode
6112
6113 \brief Change Country code, Reg Domain and channel list
6114
6115 \details Country Code Priority
6116 0 = 11D > Configured Country > NV
6117 1 = Configured Country > 11D > NV
6118 If Supplicant country code is priority than 11d is disabled.
6119 If 11D is enabled, we update the country code after every scan.
6120 Hence when Supplicant country code is priority, we don't need 11D info.
6121 Country code from Supplicant is set as current courtry code.
6122 User can send reset command XX (instead of country code) to reset the
6123 country code to default values which is read from NV.
6124 In case of reset, 11D is enabled and default NV code is Set as current country code
6125 If 11D is priority,
6126 Than Supplicant country code code is set to default code. But 11D code is set as current country code
6127
6128 \param pMac - The handle returned by macOpen.
6129 \param pMsgBuf - MSG Buffer
6130
6131 \return eHalStatus
6132
6133 -------------------------------------------------------------------------------*/
6134eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
6135{
6136 eHalStatus status = eHAL_STATUS_SUCCESS;
6137 tAniChangeCountryCodeReq *pMsg;
6138 v_REGDOMAIN_t domainIdIoctl;
6139 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6140 static uNvTables nvTables;
6141 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
6142
6143
6144 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
6145 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
6146 {
6147 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6148
6149 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
6150
6151 /* read the country code from NV and use it */
6152 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
6153 {
6154 palCopyMemory( pMac->hHdd, pMsg->countryCode , nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
6155 }
6156 else
6157 {
6158 status = eHAL_STATUS_FAILURE;
6159 return status;
6160 }
6161 }
6162 else
6163 {
6164 /* if Supplicant country code has priority, disable 11d */
6165 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority)
6166 {
6167 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
6168 }
6169 }
6170
6171 /* WEXT set country code means
6172 * 11D should be supported?
6173 * 11D Channel should be enforced?
6174 * 11D Country code should be matched?
6175 * 11D Reg Domian should be matched?
6176 * Country string changed */
6177 if(pMac->roam.configParam.Is11dSupportEnabled &&
6178 pMac->roam.configParam.fEnforce11dChannels &&
6179 pMac->roam.configParam.fEnforceCountryCodeMatch &&
6180 pMac->roam.configParam.fEnforceDefaultDomain &&
6181 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
6182 {
6183 /* All 11D related options are already enabled
6184 * Country string is not changed
6185 * Do not need do anything for country code change request */
6186 return eHAL_STATUS_SUCCESS;
6187 }
6188
6189 /* Set Current Country code and Current Regulatory domain */
6190 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
6191 if(eHAL_STATUS_SUCCESS != status)
6192 {
6193 /* Supplicant country code failed. So give 11D priority */
6194 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6195 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
6196 return status;
6197 }
6198
6199 /* purge current scan results
6200 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).
6201 Looks like a bug in current scan sequence.
6202 */
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07006203 csrScanFlushResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006204
6205 /* overwrite the defualt country code */
6206 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault, pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
6207
6208 /* Get Domain ID from country code */
6209 status = csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent,(v_REGDOMAIN_t *) &domainIdIoctl );
6210 if ( status != eHAL_STATUS_SUCCESS )
6211 {
6212 smsLog( pMac, LOGE, FL(" fail to get regId %d\n"), domainIdIoctl );
6213 return status;
6214 }
6215
6216 status = WDA_SetRegDomain(pMac, domainIdIoctl);
6217
6218 if ( status != eHAL_STATUS_SUCCESS )
6219 {
6220 smsLog( pMac, LOGE, FL(" fail to set regId %d\n"), domainIdIoctl );
6221 return status;
6222 }
6223
6224 /* set to default domain ID */
6225 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
6226
6227 /* get the channels based on new cc */
6228 status = csrInitGetChannels( pMac );
6229
6230 if ( status != eHAL_STATUS_SUCCESS )
6231 {
6232 smsLog( pMac, LOGE, FL(" fail to get Channels \n"));
6233 return status;
6234 }
6235
6236 /* reset info based on new cc, and we are done */
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08006237 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 if( pMsg->changeCCCallback )
6239 {
6240 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
6241 }
6242
6243 return eHAL_STATUS_SUCCESS;
6244}
6245
6246#ifdef WLAN_FEATURE_PACKET_FILTERING
6247eHalStatus sme_8023MulticastList (tHalHandle hHal, tpSirRcvFltMcAddrList pMulticastAddrs)
6248{
6249 tpSirRcvFltMcAddrList pRequestBuf;
6250 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006251 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6252 tANI_U8 sessionId = 0;
6253 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006254
6255 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006256 "ulMulticastAddrCnt=%d, multicastAddr[0]=%d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 pMulticastAddrs->ulMulticastAddrCnt,
6258 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07006259
6260 /*
6261 *Find the connected Infra / P2P_client connected session
6262 */
6263 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
6264 {
6265 if( CSR_IS_SESSION_VALID( pMac, sessionId ) &&
6266 ( csrIsConnStateInfra( pMac, sessionId )) )
6267 {
6268 pSession = CSR_GET_SESSION( pMac, sessionId );
6269 }
6270 }
6271
6272 if(pSession == NULL )
6273 {
6274 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Unable to find "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006275 "the right session", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07006276 return eHAL_STATUS_FAILURE;
6277 }
6278
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6280 if (NULL == pRequestBuf)
6281 {
6282 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006283 "allocate memory for 8023 Multicast List request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 return eHAL_STATUS_FAILED_ALLOC;
6285 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006286
6287 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6288 {
6289 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006290 "indication as we are not connected", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006291 vos_mem_free(pRequestBuf);
6292 return eHAL_STATUS_FAILURE;
6293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
6295
Jeff Johnsone7245742012-09-05 17:12:55 -07006296 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6297 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
6298 sizeof(tSirMacAddr));
6299
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 msg.type = WDA_8023_MULTICAST_LIST_REQ;
6301 msg.reserved = 0;
6302 msg.bodyptr = pRequestBuf;
6303 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6304 {
6305 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006306 "post WDA_8023_MULTICAST_LIST message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 vos_mem_free(pRequestBuf);
6308 return eHAL_STATUS_FAILURE;
6309 }
6310
6311 return eHAL_STATUS_SUCCESS;
6312}
6313
Jeff Johnsone7245742012-09-05 17:12:55 -07006314eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
6315 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006316{
6317 tpSirRcvPktFilterCfgType pRequestBuf;
6318 v_SINT_t allocSize;
6319 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006320 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6321 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 v_U8_t idx=0;
6323
6324 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006325 "filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
6327
Madan Mohan Koyyalamudid4029622012-10-18 20:30:17 -07006328 allocSize = sizeof(tSirRcvPktFilterCfgType);
6329
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 pRequestBuf = vos_mem_malloc(allocSize);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006331
6332 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 {
6334 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006335 "allocate memory for Receive Filter Set Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 return eHAL_STATUS_FAILED_ALLOC;
6337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006338
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006339 if( NULL == pSession )
6340 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006341 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Session Not found ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006342 vos_mem_free(pRequestBuf);
6343 return eHAL_STATUS_FAILURE;
6344 }
6345
6346 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6347 {
6348 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006349 "indication as we are not connected", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006350 vos_mem_free(pRequestBuf);
6351 return eHAL_STATUS_FAILURE;
6352 }
6353
6354 vos_mem_copy( pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6355 vos_mem_copy( pRcvPktFilterCfg->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006356 sizeof(tSirMacAddr));
6357
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006358 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
6359
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
6361 msg.reserved = 0;
6362 msg.bodyptr = pRequestBuf;
6363
6364 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6365 "FT %d FID %d ",
6366 pRequestBuf->filterType, pRequestBuf->filterId);
6367
6368 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6369 "params %d CT %d",
6370 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
6371
6372 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
6373 {
6374
6375 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6376 "Proto %d Comp Flag %d \n",
6377 pRequestBuf->paramsData[idx].protocolLayer,
6378 pRequestBuf->paramsData[idx].cmpFlag);
6379
6380 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6381 "Data Offset %d Data Len %d\n",
6382 pRequestBuf->paramsData[idx].dataOffset,
6383 pRequestBuf->paramsData[idx].dataLength);
6384
6385 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6386 "CData: %d:%d:%d:%d:%d:%d\n",
6387 pRequestBuf->paramsData[idx].compareData[0],
6388 pRequestBuf->paramsData[idx].compareData[1],
6389 pRequestBuf->paramsData[idx].compareData[2],
6390 pRequestBuf->paramsData[idx].compareData[3],
6391 pRequestBuf->paramsData[idx].compareData[4],
6392 pRequestBuf->paramsData[idx].compareData[5]);
6393
6394 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6395 "MData: %d:%d:%d:%d:%d:%d\n",
6396 pRequestBuf->paramsData[idx].dataMask[0],
6397 pRequestBuf->paramsData[idx].dataMask[1],
6398 pRequestBuf->paramsData[idx].dataMask[2],
6399 pRequestBuf->paramsData[idx].dataMask[3],
6400 pRequestBuf->paramsData[idx].dataMask[4],
6401 pRequestBuf->paramsData[idx].dataMask[5]);
6402
6403 }
6404
6405 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6406 {
6407 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006408 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 vos_mem_free(pRequestBuf);
6410 return eHAL_STATUS_FAILURE;
6411 }
6412
6413 return eHAL_STATUS_SUCCESS;
6414}
6415
6416eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
6417 FilterMatchCountCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006418 void *callbackContext,
6419 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006420{
6421 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6422 eHalStatus status;
6423
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006424 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006425
6426 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
6427 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006428 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 sme_ReleaseGlobalLock( &pMac->sme );
6430 }
6431
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006432 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006433
6434 return (status);
6435}
6436
Jeff Johnsone7245742012-09-05 17:12:55 -07006437eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
6438 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006439{
6440 tpSirRcvFltPktClearParam pRequestBuf;
6441 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006442 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6443 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006444
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006445 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 pRcvFltPktClearParam->filterId);
6447
6448 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006449 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 {
6451 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6452 "%s: Not able to allocate memory for Receive Filter "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006453 "Clear Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 return eHAL_STATUS_FAILED_ALLOC;
6455 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006456 if( NULL == pSession )
6457 {
6458 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006459 "%s: Session Not find ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006460 vos_mem_free(pRequestBuf);
6461 return eHAL_STATUS_FAILURE;
6462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006463
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006464 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6465 {
6466 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006467 "indication as we are not connected", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006468 vos_mem_free(pRequestBuf);
6469 return eHAL_STATUS_FAILURE;
6470 }
6471
6472 vos_mem_copy( pRcvFltPktClearParam->selfMacAddr, pSession->selfMacAddr, sizeof(tSirMacAddr));
6473 vos_mem_copy( pRcvFltPktClearParam->bssId, pSession->connectedProfile.bssid,
Jeff Johnsone7245742012-09-05 17:12:55 -07006474 sizeof(tSirMacAddr));
6475
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006476 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
6477
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
6479 msg.reserved = 0;
6480 msg.bodyptr = pRequestBuf;
6481 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6482 {
6483 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006484 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 vos_mem_free(pRequestBuf);
6486 return eHAL_STATUS_FAILURE;
6487 }
6488
6489 return eHAL_STATUS_SUCCESS;
6490}
6491#endif // WLAN_FEATURE_PACKET_FILTERING
6492
6493/* ---------------------------------------------------------------------------
6494 \fn sme_PreChannelSwitchIndFullPowerCB
6495 \brief call back function for the PMC full power request because of pre
6496 channel switch.
6497 \param callbackContext
6498 \param status
6499 ---------------------------------------------------------------------------*/
6500void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
6501 eHalStatus status)
6502{
6503 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
6504 tSirMbMsg *pMsg;
6505 tANI_U16 msgLen;
6506
6507 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
6508 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
6509 if(HAL_STATUS_SUCCESS(status))
6510 {
6511 palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen);
6512 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
6513 pMsg->msgLen = pal_cpu_to_be16(msgLen);
6514 status = palSendMBMessage(pMac->hHdd, pMsg);
6515 }
6516
6517 return;
6518}
6519
6520/* ---------------------------------------------------------------------------
6521 \fn sme_HandlePreChannelSwitchInd
6522 \brief Processes the indcation from PE for pre-channel switch.
6523 \param hHal
6524 \- The handle returned by macOpen. return eHalStatus
6525 ---------------------------------------------------------------------------*/
6526eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
6527{
6528 eHalStatus status = eHAL_STATUS_FAILURE;
6529 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6530 status = sme_AcquireGlobalLock( &pMac->sme );
6531 if ( HAL_STATUS_SUCCESS( status ) )
6532 {
6533 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
6534 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
6535 sme_ReleaseGlobalLock( &pMac->sme );
6536 }
6537
6538 return (status);
6539}
6540
6541/* ---------------------------------------------------------------------------
6542 \fn sme_HandlePostChannelSwitchInd
6543 \brief Processes the indcation from PE for post-channel switch.
6544 \param hHal
6545 \- The handle returned by macOpen. return eHalStatus
6546 ---------------------------------------------------------------------------*/
6547eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
6548{
6549 eHalStatus status = eHAL_STATUS_FAILURE;
6550 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6551
6552 status = sme_AcquireGlobalLock( &pMac->sme );
6553 if ( HAL_STATUS_SUCCESS( status ) )
6554 {
6555 status = pmcRequestBmps(hHal, NULL, NULL);
6556 sme_ReleaseGlobalLock( &pMac->sme );
6557 }
6558
6559 return (status);
6560}
6561
6562/* ---------------------------------------------------------------------------
6563
6564 \fn sme_IsChannelValid
6565
6566 \brief To check if the channel is valid for currently established domain
6567 This is a synchronous API.
6568
6569 \param hHal - The handle returned by macOpen.
6570 \param channel - channel to verify
6571
6572 \return TRUE/FALSE, TRUE if channel is valid
6573
6574 -------------------------------------------------------------------------------*/
6575tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
6576{
6577 eHalStatus status = eHAL_STATUS_FAILURE;
6578 tANI_BOOLEAN valid = FALSE;
6579 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6580
6581 status = sme_AcquireGlobalLock( &pMac->sme );
6582 if ( HAL_STATUS_SUCCESS( status ) )
6583 {
6584
6585 valid = csrRoamIsChannelValid( pMac, channel);
6586
6587 sme_ReleaseGlobalLock( &pMac->sme );
6588 }
6589
6590 return (valid);
6591}
6592
6593/* ---------------------------------------------------------------------------
6594 \fn sme_SetFreqBand
6595 \brief Used to set frequency band.
6596 \param hHal
6597 \eBand band value to be configured
6598 \- return eHalStatus
6599 -------------------------------------------------------------------------*/
6600eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
6601{
6602 eHalStatus status = eHAL_STATUS_FAILURE;
6603 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6604
6605 status = sme_AcquireGlobalLock( &pMac->sme );
6606 if ( HAL_STATUS_SUCCESS( status ) )
6607 {
6608 status = csrSetBand(hHal, eBand);
6609 sme_ReleaseGlobalLock( &pMac->sme );
6610 }
6611 return status;
6612}
6613
6614/* ---------------------------------------------------------------------------
6615 \fn sme_GetFreqBand
6616 \brief Used to get the current band settings.
6617 \param hHal
6618 \pBand pointer to hold band value
6619 \- return eHalStatus
6620 -------------------------------------------------------------------------*/
6621eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
6622{
6623 eHalStatus status = eHAL_STATUS_FAILURE;
6624 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6625
6626 status = sme_AcquireGlobalLock( &pMac->sme );
6627 if ( HAL_STATUS_SUCCESS( status ) )
6628 {
6629 *pBand = csrGetCurrentBand( hHal );
6630 sme_ReleaseGlobalLock( &pMac->sme );
6631 }
6632 return status;
6633}
6634
6635#ifdef WLAN_WAKEUP_EVENTS
6636/******************************************************************************
6637 \fn sme_WakeReasonIndCallback
6638
6639 \brief
6640 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
6641
6642 \param hHal - HAL handle for device
6643 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
6644
6645 \return eHalStatus
6646******************************************************************************/
6647eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
6648{
6649 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6650 eHalStatus status = eHAL_STATUS_SUCCESS;
6651 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
6652
6653 if (NULL == pMsg)
6654 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006655 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 status = eHAL_STATUS_FAILURE;
6657 }
6658 else
6659 {
6660 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback\n");
6661
6662 /* Call Wake Reason Indication callback routine. */
6663 if (pMac->pmc.wakeReasonIndCB != NULL)
6664 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
6665
6666 pMac->pmc.wakeReasonIndCB = NULL;
6667 pMac->pmc.wakeReasonIndCBContext = NULL;
6668
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006669 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __func__, pWakeReasonInd->ulReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 }
6671
6672 return(status);
6673}
6674#endif // WLAN_WAKEUP_EVENTS
6675
6676
6677/* ---------------------------------------------------------------------------
6678
6679 \fn sme_SetMaxTxPower
6680
6681 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
6682 not persist over reboots.
6683
6684 \param hHal
6685 \param pBssid BSSID to set the power cap for
6686 \param pBssid pSelfMacAddress self MAC Address
6687 \param pBssid power to set in dB
6688 \- return eHalStatus
6689
6690 -------------------------------------------------------------------------------*/
6691eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr pBssid,
6692 tSirMacAddr pSelfMacAddress, v_S7_t dB)
6693{
6694 vos_msg_t msg;
6695 tpMaxTxPowerParams pMaxTxParams = NULL;
6696
6697 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
6698 if (NULL == pMaxTxParams)
6699 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006700 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 -07006701 return eHAL_STATUS_FAILURE;
6702 }
6703
6704 vos_mem_copy(pMaxTxParams->bssId, pBssid, SIR_MAC_ADDR_LENGTH);
6705 vos_mem_copy(pMaxTxParams->selfStaMacAddr , pSelfMacAddress,
6706 SIR_MAC_ADDR_LENGTH);
6707 pMaxTxParams->power = dB;
6708
6709 msg.type = WDA_SET_MAX_TX_POWER_REQ;
6710 msg.reserved = 0;
6711 msg.bodyptr = pMaxTxParams;
6712
6713 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6714 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006715 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 -07006716 vos_mem_free(pMaxTxParams);
6717 return eHAL_STATUS_FAILURE;
6718 }
6719
6720 return eHAL_STATUS_SUCCESS;
6721}
6722
6723#ifdef WLAN_SOFTAP_FEATURE
6724/* ---------------------------------------------------------------------------
6725
6726 \fn sme_HideSSID
6727
6728 \brief hide/show SSID dynamically. Note: this setting will
6729 not persist over reboots.
6730
6731 \param hHal
6732 \param sessionId
6733 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
6734 \- return eHalStatus
6735
6736 -------------------------------------------------------------------------------*/
6737eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
6738{
6739 eHalStatus status = eHAL_STATUS_SUCCESS;
6740 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6741 tANI_U16 len;
6742
6743 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6744 {
6745 tpSirUpdateParams pMsg;
6746 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006747
6748 if(!pSession)
6749 {
6750 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6751 return eHAL_STATUS_FAILURE;
6752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006753
6754 if( !pSession->sessionActive )
6755 VOS_ASSERT(0);
6756
6757 /* Create the message and send to lim */
6758 len = sizeof(tSirUpdateParams);
6759 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
6760 if(HAL_STATUS_SUCCESS(status))
6761 {
6762 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirUpdateParams) );
6763 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
6764 pMsg->length = len;
6765 /* Data starts from here */
6766 pMsg->sessionId = sessionId;
6767 pMsg->ssidHidden = ssidHidden;
6768 status = palSendMBMessage(pMac->hHdd, pMsg);
6769 }
6770 sme_ReleaseGlobalLock( &pMac->sme );
6771 }
6772 return status;
6773}
6774#endif
6775
6776/* ---------------------------------------------------------------------------
6777
6778 \fn sme_SetTmLevel
6779 \brief Set Thermal Mitigation Level to RIVA
6780 \param hHal - The handle returned by macOpen.
6781 \param newTMLevel - new Thermal Mitigation Level
6782 \param tmMode - Thermal Mitigation handle mode, default 0
6783 \return eHalStatus
6784 ---------------------------------------------------------------------------*/
6785eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
6786{
6787 eHalStatus status = eHAL_STATUS_SUCCESS;
6788 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6789 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6790 vos_msg_t vosMessage;
6791 tAniSetTmLevelReq *setTmLevelReq = NULL;
6792
6793 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6794 {
6795 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
6796 if(NULL == setTmLevelReq)
6797 {
6798 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006799 "%s: Not able to allocate memory for sme_SetTmLevel", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 return eHAL_STATUS_FAILURE;
6801 }
6802
6803 setTmLevelReq->tmMode = tmMode;
6804 setTmLevelReq->newTmLevel = newTMLevel;
6805
6806 /* serialize the req through MC thread */
6807 vosMessage.bodyptr = setTmLevelReq;
6808 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
6809 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6810 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6811 {
6812 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006813 "%s: Post Set TM Level MSG fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 vos_mem_free(setTmLevelReq);
6815 status = eHAL_STATUS_FAILURE;
6816 }
6817 sme_ReleaseGlobalLock( &pMac->sme );
6818 }
6819 return(status);
6820}
6821
6822/*---------------------------------------------------------------------------
6823
6824 \brief sme_featureCapsExchange() - SME interface to exchange capabilities between
6825 Host and FW.
6826
6827 \param hHal - HAL handle for device
6828
6829 \return NONE
6830
6831---------------------------------------------------------------------------*/
6832void sme_featureCapsExchange( tHalHandle hHal)
6833{
6834 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
6835 WDA_featureCapsExchange(vosContext);
6836}
Jeff Johnsond13512a2012-07-17 11:42:19 -07006837
Yathish9f22e662012-12-10 14:21:35 -08006838/*---------------------------------------------------------------------------
6839
6840 \brief sme_disableFeatureCapablity() - SME interface to disable Active mode offload capablity
6841 in Host.
6842
6843 \param hHal - HAL handle for device
6844
6845 \return NONE
6846
6847---------------------------------------------------------------------------*/
6848void sme_disableFeatureCapablity(tANI_U8 feature_index)
6849{
6850 WDA_disableCapablityFeature(feature_index);
6851}
6852
6853
Jeff Johnsond13512a2012-07-17 11:42:19 -07006854
6855/* ---------------------------------------------------------------------------
6856
6857 \fn sme_GetDefaultCountryCode
6858
6859 \brief Get the default country code from NV
6860
6861 \param hHal
6862 \param pCountry
6863 \- return eHalStatus
6864
6865 -------------------------------------------------------------------------------*/
6866eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
6867{
6868 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6869 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
6870}
6871
6872/* ---------------------------------------------------------------------------
6873
6874 \fn sme_GetCurrentCountryCode
6875
6876 \brief Get the current country code
6877
6878 \param hHal
6879 \param pCountry
6880 \- return eHalStatus
6881
6882 -------------------------------------------------------------------------------*/
6883eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
6884{
6885 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6886 return csrGetCurrentCountryCode(pMac, pCountry);
6887}
6888
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006889/* ---------------------------------------------------------------------------
6890 \fn sme_transportDebug
6891 \brief Dynamically monitoring Transport channels
6892 Private IOCTL will querry transport channel status if driver loaded
Jeff Johnsonb88db982012-12-10 13:34:59 -08006893 \param displaySnapshot Display transport channel snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006894 \param toggleStallDetect Enable stall detect feature
6895 This feature will take effect to data performance
6896 Not integrate till fully verification
6897 \- return NONE
6898 -------------------------------------------------------------------------*/
6899void sme_transportDebug
6900(
6901 v_BOOL_t displaySnapshot,
6902 v_BOOL_t toggleStallDetect
6903)
6904{
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07006905 WDA_TransportChannelDebug(displaySnapshot, toggleStallDetect);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07006906}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08006907
Kiran4a17ebe2013-01-31 10:43:43 -08006908/* ---------------------------------------------------------------------------
6909 \fn sme_ResetPowerValuesFor5G
6910 \brief Reset the power values for 5G band with NV power values.
6911 \param hHal - HAL handle for device
6912 \- return NONE
6913 -------------------------------------------------------------------------*/
6914void sme_ResetPowerValuesFor5G (tHalHandle hHal)
6915{
6916 tpAniSirGlobal pMac = PMAC_STRUCT (hHal);
6917 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
6918 csrApplyPower2Current(pMac); // Store the channel+power info in the global place: Cfg
6919}
6920
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08006921#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
6922/* ---------------------------------------------------------------------------
6923 \fn sme_UpdateRoamPrefer5GHz
6924 \brief enable/disable Roam prefer 5G runtime option
6925 This function is called through dynamic setConfig callback function
6926 to configure the Roam prefer 5G runtime option
6927 \param hHal - HAL handle for device
6928 \param nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6929 \- return Success or failure
6930 -------------------------------------------------------------------------*/
6931
6932eHalStatus sme_UpdateRoamPrefer5GHz(tHalHandle hHal, v_BOOL_t nRoamPrefer5GHz)
6933{
6934 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6935 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6936 return(eHAL_STATUS_SUCCESS);
6937}
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08006938
6939/* ---------------------------------------------------------------------------
6940 \fn sme_UpdateImmediateRoamRssiDiff
6941 \brief Update nImmediateRoamRssiDiff
6942 This function is called through dynamic setConfig callback function
6943 to configure nImmediateRoamRssiDiff
6944 Usage: adb shell iwpriv wlan0 setConfig gImmediateRoamRssiDiff=[0 .. 125]
6945 \param hHal - HAL handle for device
6946 \param nImmediateRoamRssiDiff - minimum rssi difference between potential
6947 candidate and current AP.
6948 \- return Success or failure
6949 -------------------------------------------------------------------------*/
6950
6951eHalStatus sme_UpdateImmediateRoamRssiDiff(tHalHandle hHal, v_U8_t nImmediateRoamRssiDiff)
6952{
6953 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6954 pMac->roam.configParam.nImmediateRoamRssiDiff = nImmediateRoamRssiDiff;
6955 return(eHAL_STATUS_SUCCESS);
6956}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08006957
6958/*--------------------------------------------------------------------------
6959 \brief sme_UpdateFastTransitionEnabled() - enable/disable Fast Transition support at runtime
6960 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6961 isFastTransitionEnabled.
6962 This is a synchronuous call
6963 \param hHal - The handle returned by macOpen.
6964 \return eHAL_STATUS_SUCCESS - SME update isFastTransitionEnabled config successfully.
6965 Other status means SME is failed to update isFastTransitionEnabled.
6966 \sa
6967 --------------------------------------------------------------------------*/
6968eHalStatus sme_UpdateFastTransitionEnabled(tHalHandle hHal,
6969 v_BOOL_t isFastTransitionEnabled)
6970{
6971 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6972
6973 pMac->roam.configParam.isFastTransitionEnabled = isFastTransitionEnabled;
6974 return eHAL_STATUS_SUCCESS;
6975}
6976#endif /* (WLAN_FEATURE_VOWIFI_11R) || (FEATURE_WLAN_CCX) || (FEATURE_WLAN_LFR) */
6977
6978#ifdef FEATURE_WLAN_LFR
6979/*--------------------------------------------------------------------------
6980 \brief sme_UpdateIsFastRoamIniFeatureEnabled() - enable/disable LFR support at runtime
6981 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6982 isFastRoamIniFeatureEnabled.
6983 This is a synchronuous call
6984 \param hHal - The handle returned by macOpen.
6985 \return eHAL_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config successfully.
6986 Other status means SME is failed to update isFastRoamIniFeatureEnabled.
6987 \sa
6988 --------------------------------------------------------------------------*/
6989eHalStatus sme_UpdateIsFastRoamIniFeatureEnabled(tHalHandle hHal,
6990 v_BOOL_t isFastRoamIniFeatureEnabled)
6991{
6992 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6993
6994 pMac->roam.configParam.isFastRoamIniFeatureEnabled = isFastRoamIniFeatureEnabled;
6995
6996 if(TRUE == isFastRoamIniFeatureEnabled)
6997 {
6998 sme_UpdateFastTransitionEnabled(hHal, TRUE);
6999 sme_UpdateConfigFwRssiMonitoring(hHal, TRUE);
7000 }
7001 else
7002 {
7003 /* CCX also depend on FW Monitoring/FastTransition.
7004 Hence Disabling LFR should check for CCX enable before disabling FW Monitoring and Fast Transition */
7005#ifdef FEATURE_WLAN_CCX
7006 if(FALSE == pMac->roam.configParam.isCcxIniFeatureEnabled)
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007007#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007008 {
7009 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7010 "%s: Turn off FW Monitoring/Fast Transition", __func__);
7011 sme_UpdateFastTransitionEnabled(hHal, FALSE);
7012 sme_UpdateConfigFwRssiMonitoring(hHal, FALSE);
7013 }
7014 }
7015
7016 return eHAL_STATUS_SUCCESS;
7017}
7018#endif /* FEATURE_WLAN_LFR */
7019
7020#ifdef FEATURE_WLAN_CCX
7021/*--------------------------------------------------------------------------
7022 \brief sme_UpdateIsCcxFeatureEnabled() - enable/disable CCX support at runtime
7023 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7024 isCcxIniFeatureEnabled.
7025 This is a synchronuous call
7026 \param hHal - The handle returned by macOpen.
7027 \return eHAL_STATUS_SUCCESS - SME update isCcxIniFeatureEnabled config successfully.
7028 Other status means SME is failed to update isCcxIniFeatureEnabled.
7029 \sa
7030 --------------------------------------------------------------------------*/
7031
7032eHalStatus sme_UpdateIsCcxFeatureEnabled(tHalHandle hHal,
7033 v_BOOL_t isCcxIniFeatureEnabled)
7034{
7035 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7036
7037 pMac->roam.configParam.isCcxIniFeatureEnabled = isCcxIniFeatureEnabled;
7038
7039 if(TRUE == isCcxIniFeatureEnabled)
7040 {
7041 sme_UpdateFastTransitionEnabled(hHal, TRUE);
7042 sme_UpdateConfigFwRssiMonitoring(hHal, TRUE);
7043 }
7044 else
7045 {
7046 /* LFR also depend on FW Monitoring/FastTransition.
7047 Hence Disabling CCX should check for LFR enable before disabling FW Monitoring and Fast Transition */
7048#ifdef FEATURE_WLAN_LFR
7049 if(FALSE == pMac->roam.configParam.isFastRoamIniFeatureEnabled)
7050#endif
7051 {
7052 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7053 "%s: Turn off FW Monitoring/Fast Transition", __func__);
7054 sme_UpdateFastTransitionEnabled(hHal, FALSE);
7055 sme_UpdateConfigFwRssiMonitoring(hHal, FALSE);
7056 }
7057 }
7058 return eHAL_STATUS_SUCCESS;
7059}
7060#endif /* FEATURE_WLAN_CCX */
7061
7062/*--------------------------------------------------------------------------
7063 \brief sme_UpdateConfigFwRssiMonitoring() - enable/disable firmware RSSI Monitoring at runtime
7064 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7065 fEnableFwRssiMonitoring.
7066 This is a synchronuous call
7067 \param hHal - The handle returned by macOpen.
7068 \return eHAL_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring. config successfully.
7069 Other status means SME is failed to update fEnableFwRssiMonitoring.
7070 \sa
7071 --------------------------------------------------------------------------*/
7072
7073eHalStatus sme_UpdateConfigFwRssiMonitoring(tHalHandle hHal,
7074 v_BOOL_t fEnableFwRssiMonitoring)
7075{
7076 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
7077
7078
7079 if (ccmCfgSetInt(hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR, fEnableFwRssiMonitoring,
7080 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
7081 {
7082 halStatus = eHAL_STATUS_FAILURE;
7083 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7084 "Failure: Could not pass on WNI_CFG_PS_RSSI_MONITOR configuration info to CCM\n");
7085 }
7086
7087 return (halStatus);
7088}
7089
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007090
7091
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007092/* ---------------------------------------------------------------------------
7093 \fn sme_IsFeatureSupportedByFW
7094 \brief Check if an feature is enabled by FW
7095
7096 \param feattEnumValue - Enumeration value from placeHolderInCapBitmap
7097 \- return 1/0 (TRUE/FALSE)
7098 -------------------------------------------------------------------------*/
7099tANI_U8 sme_IsFeatureSupportedByFW(tANI_U8 featEnumValue)
7100{
7101 return IS_FEATURE_SUPPORTED_BY_FW(featEnumValue);
7102}
7103#ifdef FEATURE_WLAN_TDLS
7104/* ---------------------------------------------------------------------------
7105 \fn sme_SendTdlsMgmtFrame
7106 \brief API to send TDLS management frames.
7107
7108 \param peerMac - peer's Mac Adress.
7109 \param frame_type - Type of TDLS mgmt frame to be sent.
7110 \param dialog - dialog token used in the frame.
7111 \param status - status to be incuded in the frame.
7112 \param buf - additional IEs to be included
7113 \param len - lenght of additional Ies
7114 \- return VOS_STATUS_SUCCES
7115 -------------------------------------------------------------------------*/
7116VOS_STATUS sme_SendTdlsMgmtFrame(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac,
7117 tANI_U8 frame_type, tANI_U8 dialog, tANI_U16 statusCode, tANI_U8 *buf, tANI_U8 len)
7118{
7119 eHalStatus status = eHAL_STATUS_SUCCESS;
7120 tCsrTdlsSendMgmt sendTdlsReq = {{0}} ;
7121 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7122
7123 status = sme_AcquireGlobalLock( &pMac->sme );
7124 if ( HAL_STATUS_SUCCESS( status ) )
7125 {
7126 vos_mem_copy(sendTdlsReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7127 sendTdlsReq.frameType = frame_type;
7128 sendTdlsReq.buf = buf;
7129 sendTdlsReq.len = len;
7130 sendTdlsReq.dialog = dialog;
7131 sendTdlsReq.statusCode = statusCode;
7132
7133 status = csrTdlsSendMgmtReq(hHal, sessionId, &sendTdlsReq) ;
7134
7135 sme_ReleaseGlobalLock( &pMac->sme );
7136 }
7137
7138 return status ;
7139
7140}
7141/* ---------------------------------------------------------------------------
7142 \fn sme_AddTdlsPeerSta
7143 \brief API to Add TDLS peer sta entry.
7144
7145 \param peerMac - peer's Mac Adress.
7146 \- return VOS_STATUS_SUCCES
7147 -------------------------------------------------------------------------*/
7148VOS_STATUS sme_AddTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7149{
7150 eHalStatus status = eHAL_STATUS_SUCCESS;
7151 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7152
7153 status = sme_AcquireGlobalLock( &pMac->sme );
7154 if ( HAL_STATUS_SUCCESS( status ) )
7155 {
7156 status = csrTdlsAddPeerSta(hHal, sessionId, peerMac);
7157
7158 sme_ReleaseGlobalLock( &pMac->sme );
7159 }
7160
7161 return status ;
7162
7163}
7164/* ---------------------------------------------------------------------------
7165 \fn sme_DeleteTdlsPeerSta
7166 \brief API to Delete TDLS peer sta entry.
7167
7168 \param peerMac - peer's Mac Adress.
7169 \- return VOS_STATUS_SUCCES
7170 -------------------------------------------------------------------------*/
7171VOS_STATUS sme_DeleteTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7172{
7173 eHalStatus status = eHAL_STATUS_SUCCESS;
7174 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7175
7176 status = sme_AcquireGlobalLock( &pMac->sme );
7177 if ( HAL_STATUS_SUCCESS( status ) )
7178 {
7179 status = csrTdlsDelPeerSta(hHal, sessionId, peerMac) ;
7180
7181 sme_ReleaseGlobalLock( &pMac->sme );
7182 }
7183
7184 return status ;
7185
7186}
7187#endif
7188#ifdef FEATURE_WLAN_TDLS_INTERNAL
7189/*
7190 * SME API to start TDLS discovery Procedure
7191 */
7192VOS_STATUS sme_StartTdlsDiscoveryReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7193{
7194 VOS_STATUS status = VOS_STATUS_SUCCESS;
7195 tCsrTdlsDisRequest disReq = {{0}} ;
7196 vos_mem_copy(disReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7197 status = csrTdlsDiscoveryReq(hHal, sessionId, &disReq) ;
7198
7199 return status ;
7200
7201}
7202
7203/*
7204 * Process TDLS discovery results
7205 */
7206v_U8_t sme_GetTdlsDiscoveryResult(tHalHandle hHal,
7207 tSmeTdlsDisResult *disResult, v_U8_t listType)
7208{
7209 tCsrTdlsPeerLinkinfo *peerLinkInfo = NULL ;
7210 tSirTdlsPeerInfo *peerInfo = NULL ;
7211 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7212 tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
7213 tDblLinkList *peerList = &disInfo->tdlsPotentialPeerList ;
7214 tListElem *pEntry = NULL ;
7215 v_U8_t peerCnt = 0 ;
7216
7217 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7218 ("TDLS peer count = %d\n"),disInfo->tdlsPeerCount ) ;
7219 pEntry = csrLLPeekHead( peerList, LL_ACCESS_LOCK );
7220 while(pEntry)
7221 {
7222 peerLinkInfo = GET_BASE_ADDR( pEntry, tCsrTdlsPeerLinkinfo,
7223 tdlsPeerStaLink) ;
7224 peerInfo = &peerLinkInfo->tdlsDisPeerInfo ;
7225
7226 switch(listType)
7227 {
7228 case TDLS_SETUP_LIST:
7229 {
7230 if(TDLS_LINK_SETUP_STATE == peerInfo->tdlsPeerState)
7231 {
7232 palCopyMemory(pMac->hHdd, disResult[peerCnt].tdlsPeerMac,
7233 peerInfo->peerMac, sizeof(tSirMacAddr)) ;
7234 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
7235 peerCnt++ ;
7236 }
7237 break ;
7238 }
7239 case TDLS_DIS_LIST:
7240 {
7241 palCopyMemory(pMac->hHdd, disResult[peerCnt].tdlsPeerMac,
7242 peerInfo->peerMac, sizeof(tSirMacAddr)) ;
7243 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
7244 peerCnt++ ;
7245 break ;
7246 }
7247 default:
7248 {
7249 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7250 ("unknown list type \n")) ;
7251 break ;
7252 }
7253 }
7254
7255 pEntry = csrLLNext( peerList, pEntry, LL_ACCESS_LOCK) ;
7256 }
7257
7258 return peerCnt ;
7259
7260}
7261
7262/*
7263 * SME API to start TDLS link setup Procedure.
7264 */
7265VOS_STATUS sme_StartTdlsLinkSetupReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7266{
7267 VOS_STATUS status = VOS_STATUS_SUCCESS;
7268 tCsrTdlsSetupRequest setupReq = {{0}} ;
7269 vos_mem_copy(setupReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7270 status = csrTdlsSetupReq(hHal, sessionId, &setupReq) ;
7271 return status ;
7272
7273}
7274
7275/*
7276 * SME API to start TDLS link Teardown Procedure.
7277 */
7278VOS_STATUS sme_StartTdlsLinkTeardownReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
7279{
7280 VOS_STATUS status = VOS_STATUS_SUCCESS;
7281 tCsrTdlsTeardownRequest teardownReq = {{0}} ;
7282 vos_mem_copy(teardownReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
7283 status = csrTdlsTeardownReq(hHal, sessionId, &teardownReq) ;
7284 return status ;
7285
7286}
7287
7288#endif /* FEATURE_WLAN_TDLS */
7289