blob: f47a7f1ab0d9c2704a5733fa61504cdf123ea201 [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
Jeff Johnson295189b2012-06-20 16:38:30 -070075
76#include "smsDebug.h"
77#include "sme_Api.h"
78#include "csrInsideApi.h"
79#include "smeInside.h"
80#include "csrInternal.h"
81#include "wlan_qct_wda.h"
82#include "halMsgApi.h"
Katya Nigam70d68332013-09-16 16:49:45 +053083#include "vos_trace.h"
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -070084#include "sme_Trace.h"
85#include "limTrace.h"
86
Jeff Johnson295189b2012-06-20 16:38:30 -070087#include "sapApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070088
89
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091extern tSirRetStatus uMacPostCtrlMsg(void* pSirGlobal, tSirMbMsg* pMb);
92
93#include <wlan_qct_pal_api.h>
Katya Nigam70d68332013-09-16 16:49:45 +053094#define LOG_SIZE 256
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -080095#define READ_MEMORY_DUMP_CMD 9
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053096#define TL_INIT_STATE 0
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -080097
Jeff Johnson295189b2012-06-20 16:38:30 -070098// TxMB Functions
99extern eHalStatus pmcPrepareCommand( tpAniSirGlobal pMac, eSmeCommandType cmdType, void *pvParam,
100 tANI_U32 size, tSmeCmd **ppCmd );
101extern void pmcReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
102extern void qosReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700103extern eHalStatus p2pProcessRemainOnChannelCmd(tpAniSirGlobal pMac, tSmeCmd *p2pRemainonChn);
104extern eHalStatus sme_remainOnChnRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg);
105extern eHalStatus sme_mgmtFrmInd( tHalHandle hHal, tpSirSmeMgmtFrameInd pSmeMgmtFrm);
106extern eHalStatus sme_remainOnChnReady( tHalHandle hHal, tANI_U8* pMsg);
107extern eHalStatus sme_sendActionCnf( tHalHandle hHal, tANI_U8* pMsg);
108extern eHalStatus p2pProcessNoAReq(tpAniSirGlobal pMac, tSmeCmd *pNoACmd);
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
110static eHalStatus initSmeCmdList(tpAniSirGlobal pMac);
111static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping );
112
113eCsrPhyMode sme_GetPhyMode(tHalHandle hHal);
114
115eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf);
116
Amar Singhal0d15bd52013-10-12 23:13:13 -0700117eHalStatus sme_HandleGenericChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf);
118
Jeff Johnson295189b2012-06-20 16:38:30 -0700119eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal);
120
121eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal);
122
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -0700123#ifdef FEATURE_WLAN_LFR
124tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac);
125#endif
126
Chet Lanctot186b5732013-03-18 10:26:30 -0700127#ifdef WLAN_FEATURE_11W
128eHalStatus sme_UnprotectedMgmtFrmInd( tHalHandle hHal,
129 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm );
130#endif
131
Jeff Johnson295189b2012-06-20 16:38:30 -0700132//Internal SME APIs
133eHalStatus sme_AcquireGlobalLock( tSmeStruct *psSme)
134{
135 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
136
137 if(psSme)
138 {
139 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psSme->lkSmeGlobalLock) ) )
140 {
141 status = eHAL_STATUS_SUCCESS;
142 }
143 }
144
145 return (status);
146}
147
148
149eHalStatus sme_ReleaseGlobalLock( tSmeStruct *psSme)
150{
151 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
152
153 if(psSme)
154 {
155 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psSme->lkSmeGlobalLock) ) )
156 {
157 status = eHAL_STATUS_SUCCESS;
158 }
159 }
160
161 return (status);
162}
163
164
165
166static eHalStatus initSmeCmdList(tpAniSirGlobal pMac)
167{
168 eHalStatus status;
169 tSmeCmd *pCmd;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530170 tANI_U32 cmd_idx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700171
172 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530173 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
174 &pMac->sme.smeCmdActiveList)))
175 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -0700176
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530177 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
178 &pMac->sme.smeCmdPendingList)))
179 goto end;
180
181 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
182 &pMac->sme.smeScanCmdActiveList)))
183 goto end;
184
185 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
186 &pMac->sme.smeScanCmdPendingList)))
187 goto end;
188
189 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
190 &pMac->sme.smeCmdFreeList)))
191 goto end;
192
Kiet Lam64c1b492013-07-12 13:56:44 +0530193 pCmd = vos_mem_malloc(sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
194 if ( NULL == pCmd )
195 status = eHAL_STATUS_FAILURE;
196 else
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530197 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530198 status = eHAL_STATUS_SUCCESS;
199
200 vos_mem_set(pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd, 0);
201 pMac->sme.pSmeCmdBufAddr = pCmd;
202
203 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++)
204 {
205 csrLLInsertTail(&pMac->sme.smeCmdFreeList,
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530206 &pCmd[cmd_idx].Link, LL_ACCESS_LOCK);
Kiet Lam64c1b492013-07-12 13:56:44 +0530207 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700208 }
209
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530210end:
211 if (!HAL_STATUS_SUCCESS(status))
212 smsLog(pMac, LOGE, "failed to initialize sme command list:%d\n",
213 status);
214
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 return (status);
216}
217
218
219void smeReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCmd)
220{
221 pCmd->command = eSmeNoCommand;
222 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd->Link, LL_ACCESS_LOCK);
223}
224
225
226
227static void smeReleaseCmdList(tpAniSirGlobal pMac, tDblLinkList *pList)
228{
229 tListElem *pEntry;
230 tSmeCmd *pCommand;
231
232 while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_LOCK)) != NULL)
233 {
234 //TODO: base on command type to call release functions
235 //reinitialize different command types so they can be reused
236 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
237 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
238 }
239}
240
241static void purgeSmeCmdList(tpAniSirGlobal pMac)
242{
243 //release any out standing commands back to free command list
244 smeReleaseCmdList(pMac, &pMac->sme.smeCmdPendingList);
245 smeReleaseCmdList(pMac, &pMac->sme.smeCmdActiveList);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530246 smeReleaseCmdList(pMac, &pMac->sme.smeScanCmdPendingList);
247 smeReleaseCmdList(pMac, &pMac->sme.smeScanCmdActiveList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700248}
249
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +0530250void purgeSmeSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
251 tDblLinkList *pList)
Jeff Johnson295189b2012-06-20 16:38:30 -0700252{
253 //release any out standing commands back to free command list
254 tListElem *pEntry, *pNext;
255 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 tDblLinkList localList;
257
258 vos_mem_zero(&localList, sizeof(tDblLinkList));
259 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
260 {
261 smsLog(pMac, LOGE, FL(" failed to open list"));
262 return;
263 }
264
265 csrLLLock(pList);
266 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
267 while(pEntry != NULL)
268 {
269 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
270 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
271 if(pCommand->sessionId == sessionId)
272 {
273 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
274 {
275 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
276 }
277 }
278 pEntry = pNext;
279 }
280 csrLLUnlock(pList);
281
282 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
283 {
284 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
285 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
286 }
287 csrLLClose(&localList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700288}
289
290
291static eHalStatus freeSmeCmdList(tpAniSirGlobal pMac)
292{
293 eHalStatus status = eHAL_STATUS_SUCCESS;
294
295 purgeSmeCmdList(pMac);
296 csrLLClose(&pMac->sme.smeCmdPendingList);
297 csrLLClose(&pMac->sme.smeCmdActiveList);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530298 csrLLClose(&pMac->sme.smeScanCmdPendingList);
299 csrLLClose(&pMac->sme.smeScanCmdActiveList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 csrLLClose(&pMac->sme.smeCmdFreeList);
301
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800302 status = vos_lock_acquire(&pMac->sme.lkSmeGlobalLock);
303 if(status != eHAL_STATUS_SUCCESS)
304 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800305 smsLog(pMac, LOGE,
306 FL("Failed to acquire the lock status = %d"), status);
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800307 goto done;
308 }
309
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 if(NULL != pMac->sme.pSmeCmdBufAddr)
311 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530312 vos_mem_free(pMac->sme.pSmeCmdBufAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 pMac->sme.pSmeCmdBufAddr = NULL;
314 }
315
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800316 status = vos_lock_release(&pMac->sme.lkSmeGlobalLock);
317 if(status != eHAL_STATUS_SUCCESS)
318 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800319 smsLog(pMac, LOGE,
320 FL("Failed to release the lock status = %d"), status);
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800321 }
322done:
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 return (status);
324}
325
326
327void dumpCsrCommandInfo(tpAniSirGlobal pMac, tSmeCmd *pCmd)
328{
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 switch( pCmd->command )
330 {
331 case eSmeCommandScan:
332 smsLog( pMac, LOGE, " scan command reason is %d", pCmd->u.scanCmd.reason );
333 break;
334
335 case eSmeCommandRoam:
336 smsLog( pMac, LOGE, " roam command reason is %d", pCmd->u.roamCmd.roamReason );
337 break;
338
339 case eSmeCommandWmStatusChange:
340 smsLog( pMac, LOGE, " WMStatusChange command type is %d", pCmd->u.wmStatusChangeCmd.Type );
341 break;
342
343 case eSmeCommandSetKey:
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800344 smsLog( pMac, LOGE, " setKey command auth(%d) enc(%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 pCmd->u.setKeyCmd.authType, pCmd->u.setKeyCmd.encType );
346 break;
347
348 case eSmeCommandRemoveKey:
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800349 smsLog( pMac, LOGE, " removeKey command auth(%d) enc(%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 pCmd->u.removeKeyCmd.authType, pCmd->u.removeKeyCmd.encType );
351 break;
352
353 default:
354 break;
355 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700356}
357
358tSmeCmd *smeGetCommandBuffer( tpAniSirGlobal pMac )
359{
360 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
361 tListElem *pEntry;
362
363 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK );
364
365 // If we can get another MS Msg buffer, then we are ok. Just link
366 // the entry onto the linked list. (We are using the linked list
367 // to keep track of tfhe message buffers).
368 if ( pEntry )
369 {
370 pRetCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
371 }
372 else {
373 int idx = 1;
374
375 //Cannot change pRetCmd here since it needs to return later.
376 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
377 if( pEntry )
378 {
379 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
380 }
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800381 smsLog( pMac, LOGE, "Out of command buffer.... command (0x%X) stuck",
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
383 if(pTempCmd)
384 {
385 if( eSmeCsrCommandMask & pTempCmd->command )
386 {
387 //CSR command is stuck. See what the reason code is for that command
388 dumpCsrCommandInfo(pMac, pTempCmd);
389 }
390 } //if(pTempCmd)
391
392 //dump what is in the pending queue
393 csrLLLock(&pMac->sme.smeCmdPendingList);
394 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
395 while(pEntry)
396 {
397 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800398 smsLog( pMac, LOGE, "Out of command buffer.... SME pending command #%d (0x%X)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 idx++, pTempCmd->command );
400 if( eSmeCsrCommandMask & pTempCmd->command )
401 {
402 //CSR command is stuck. See what the reason code is for that command
403 dumpCsrCommandInfo(pMac, pTempCmd);
404 }
405 pEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
406 }
407 csrLLUnlock(&pMac->sme.smeCmdPendingList);
408
409 //There may be some more command in CSR's own pending queue
410 csrLLLock(&pMac->roam.roamCmdPendingList);
411 pEntry = csrLLPeekHead( &pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK );
412 while(pEntry)
413 {
414 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800415 smsLog( pMac, LOGE, "Out of command buffer.... CSR pending command #%d (0x%X)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 idx++, pTempCmd->command );
417 dumpCsrCommandInfo(pMac, pTempCmd);
418 pEntry = csrLLNext( &pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
419 }
420 csrLLUnlock(&pMac->roam.roamCmdPendingList);
421 }
422
423 return( pRetCmd );
424}
425
426
427void smePushCommand( tpAniSirGlobal pMac, tSmeCmd *pCmd, tANI_BOOLEAN fHighPriority )
428{
429 if ( fHighPriority )
430 {
431 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
432 }
433 else
434 {
435 csrLLInsertTail( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
436 }
437
438 // process the command queue...
439 smeProcessPendingQueue( pMac );
440
441 return;
442}
443
444
445static eSmeCommandType smeIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand )
446{
447 eSmeCommandType pmcCommand = eSmeNoCommand;
448 tANI_BOOLEAN fFullPowerNeeded = eANI_BOOLEAN_FALSE;
449 tPmcState pmcState;
450 eHalStatus status;
451
452 do
453 {
454 pmcState = pmcGetPmcState(pMac);
455
456 status = csrIsFullPowerNeeded( pMac, pCommand, NULL, &fFullPowerNeeded );
457 if( !HAL_STATUS_SUCCESS(status) )
458 {
459 //PMC state is not right for the command, drop it
460 return ( eSmeDropCommand );
461 }
462 if( fFullPowerNeeded ) break;
463 fFullPowerNeeded = ( ( eSmeCommandAddTs == pCommand->command ) ||
464 ( eSmeCommandDelTs == pCommand->command ) );
465 if( fFullPowerNeeded ) break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700466#ifdef FEATURE_OEM_DATA_SUPPORT
467 fFullPowerNeeded = (pmcState == IMPS &&
468 eSmeCommandOemDataReq == pCommand->command);
469 if(fFullPowerNeeded) break;
470#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 fFullPowerNeeded = (pmcState == IMPS &&
472 eSmeCommandRemainOnChannel == pCommand->command);
473 if(fFullPowerNeeded) break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700474 } while(0);
475
476 if( fFullPowerNeeded )
477 {
478 switch( pmcState )
479 {
480 case IMPS:
481 case STANDBY:
482 pmcCommand = eSmeCommandExitImps;
483 break;
484
485 case BMPS:
486 pmcCommand = eSmeCommandExitBmps;
487 break;
488
489 case UAPSD:
490 pmcCommand = eSmeCommandExitUapsd;
491 break;
492
493 case WOWL:
494 pmcCommand = eSmeCommandExitWowl;
495 break;
496
497 default:
498 break;
499 }
500 }
501
502 return ( pmcCommand );
503}
504
505
506//For commands that need to do extra cleanup.
507static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
508{
509 if( eSmePmcCommandMask & pCommand->command )
510 {
511 pmcAbortCommand( pMac, pCommand, fStopping );
512 }
513 else if ( eSmeCsrCommandMask & pCommand->command )
514 {
515 csrAbortCommand( pMac, pCommand, fStopping );
516 }
517 else
518 {
519 switch( pCommand->command )
520 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 case eSmeCommandRemainOnChannel:
522 if (NULL != pCommand->u.remainChlCmd.callback)
523 {
524 remainOnChanCallback callback =
525 pCommand->u.remainChlCmd.callback;
526 /* process the msg */
527 if( callback )
528 {
529 callback(pMac, pCommand->u.remainChlCmd.callbackCtx,
530 eCSR_SCAN_ABORT );
531 }
532 }
533 smeReleaseCommand( pMac, pCommand );
534 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 default:
536 smeReleaseCommand( pMac, pCommand );
537 break;
538 }
539 }
540}
541
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530542tListElem *csrGetCmdToProcess(tpAniSirGlobal pMac, tDblLinkList *pList,
543 tANI_U8 sessionId, tANI_BOOLEAN fInterlocked)
544{
545 tListElem *pCurEntry = NULL;
546 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -0700547
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530548 /* Go through the list and return the command whose session id is not
549 * matching with the current ongoing scan cmd sessionId */
550 pCurEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK );
551 while (pCurEntry)
552 {
553 pCommand = GET_BASE_ADDR(pCurEntry, tSmeCmd, Link);
554 if (pCommand->sessionId != sessionId)
555 {
556 smsLog(pMac, LOG1, "selected the command with different sessionId");
557 return pCurEntry;
558 }
559
560 pCurEntry = csrLLNext(pList, pCurEntry, fInterlocked);
561 }
562
563 smsLog(pMac, LOG1, "No command pending with different sessionId");
564 return NULL;
565}
566
567tANI_BOOLEAN smeProcessScanQueue(tpAniSirGlobal pMac)
568{
569 tListElem *pEntry;
570 tSmeCmd *pCommand;
571 tListElem *pSmeEntry;
572 tSmeCmd *pSmeCommand;
573 tANI_BOOLEAN status = eANI_BOOLEAN_TRUE;
574
575 csrLLLock( &pMac->sme.smeScanCmdActiveList );
576 if (csrLLIsListEmpty( &pMac->sme.smeScanCmdActiveList,
577 LL_ACCESS_NOLOCK ))
578 {
579 if (!csrLLIsListEmpty(&pMac->sme.smeScanCmdPendingList,
580 LL_ACCESS_LOCK))
581 {
582 pEntry = csrLLPeekHead( &pMac->sme.smeScanCmdPendingList,
583 LL_ACCESS_LOCK );
584 if (pEntry)
585 {
586 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
587 //We cannot execute any command in wait-for-key state until setKey is through.
588 if (CSR_IS_WAIT_FOR_KEY( pMac, pCommand->sessionId))
589 {
590 if (!CSR_IS_SET_KEY_COMMAND(pCommand))
591 {
592 smsLog(pMac, LOGE,
593 " Cannot process command(%d) while waiting for key",
594 pCommand->command);
595 status = eANI_BOOLEAN_FALSE;
596 goto end;
597 }
598 }
599
600 if ((!csrLLIsListEmpty(&pMac->sme.smeCmdActiveList,
601 LL_ACCESS_LOCK )))
602 {
603 pSmeEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList,
604 LL_ACCESS_LOCK);
605 if (pEntry)
606 {
607 pSmeCommand = GET_BASE_ADDR(pEntry, tSmeCmd,
608 Link) ;
609
610 /* if scan is running on one interface and SME recei
611 ves the next command on the same interface then
612 dont the allow the command to be queued to
613 smeCmdPendingList. If next scan is allowed on
614 the same interface the CSR state machine will
615 get screwed up. */
616 if (pSmeCommand->sessionId == pCommand->sessionId)
617 {
618 status = eANI_BOOLEAN_FALSE;
619 goto end;
620 }
621 }
622 }
623 if ( csrLLRemoveEntry( &pMac->sme.smeScanCmdPendingList,
624 pEntry, LL_ACCESS_LOCK ) )
625 {
626 csrLLInsertHead( &pMac->sme.smeScanCmdActiveList,
627 &pCommand->Link, LL_ACCESS_NOLOCK );
628
629 switch (pCommand->command)
630 {
631 case eSmeCommandScan:
632 smsLog(pMac, LOG1,
633 " Processing scan offload command ");
634 csrProcessScanCommand( pMac, pCommand );
635 break;
636 default:
637 smsLog(pMac, LOGE,
638 " Something wrong, wrong command enqueued"
639 " to smeScanCmdPendingList");
640 pEntry = csrLLRemoveHead(
641 &pMac->sme.smeScanCmdActiveList,
642 LL_ACCESS_NOLOCK );
643 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
644 smeReleaseCommand( pMac, pCommand );
645 break;
646 }
647 }
648 }
649 }
650 }
651end:
652 csrLLUnlock(&pMac->sme.smeScanCmdActiveList);
653 return status;
654}
Jeff Johnson295189b2012-06-20 16:38:30 -0700655
656tANI_BOOLEAN smeProcessCommand( tpAniSirGlobal pMac )
657{
658 tANI_BOOLEAN fContinue = eANI_BOOLEAN_FALSE;
659 eHalStatus status = eHAL_STATUS_SUCCESS;
660 tListElem *pEntry;
661 tSmeCmd *pCommand;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530662 tListElem *pSmeEntry;
663 tSmeCmd *pSmeCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 eSmeCommandType pmcCommand = eSmeNoCommand;
665
666 // if the ActiveList is empty, then nothing is active so we can process a
667 // pending command...
668 //alwasy lock active list before locking pending list
669 csrLLLock( &pMac->sme.smeCmdActiveList );
670 if ( csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) )
671 {
672 if(!csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK))
673 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530674 /* If scan command is pending in the smeScanCmdActive list
675 * then pick the command from smeCmdPendingList which is
676 * not matching with the scan command session id.
677 * At any point of time only one command will be allowed
678 * on a single session. */
679 if ((pMac->fScanOffload) &&
680 (!csrLLIsListEmpty(&pMac->sme.smeScanCmdActiveList,
681 LL_ACCESS_LOCK)))
682 {
683 pSmeEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList,
684 LL_ACCESS_LOCK);
685 if (pSmeEntry)
686 {
687 pSmeCommand = GET_BASE_ADDR(pSmeEntry, tSmeCmd, Link);
688
689 pEntry = csrGetCmdToProcess(pMac,
690 &pMac->sme.smeCmdPendingList,
691 pSmeCommand->sessionId,
692 LL_ACCESS_LOCK);
693 goto sme_process_cmd;
694 }
695 }
696
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 //Peek the command
698 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK );
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530699sme_process_cmd:
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 if( pEntry )
701 {
702 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530703
Jeff Johnson295189b2012-06-20 16:38:30 -0700704 //We cannot execute any command in wait-for-key state until setKey is through.
705 if( CSR_IS_WAIT_FOR_KEY( pMac, pCommand->sessionId ) )
706 {
707 if( !CSR_IS_SET_KEY_COMMAND( pCommand ) )
708 {
709 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800710 smsLog(pMac, LOGE, " Cannot process command(%d) while waiting for key", pCommand->command);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530711 fContinue = eANI_BOOLEAN_FALSE;
712 goto sme_process_scan_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 }
714 }
715 pmcCommand = smeIsFullPowerNeeded( pMac, pCommand );
716 if( eSmeDropCommand == pmcCommand )
717 {
718 //This command is not ok for current PMC state
719 if( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
720 {
721 smeAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE );
722 }
723 csrLLUnlock( &pMac->sme.smeCmdActiveList );
724 //tell caller to continue
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530725 fContinue = eANI_BOOLEAN_TRUE;
726 goto sme_process_scan_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 }
728 else if( eSmeNoCommand != pmcCommand )
729 {
730 tExitBmpsInfo exitBmpsInfo;
731 void *pv = NULL;
732 tANI_U32 size = 0;
733 tSmeCmd *pPmcCmd = NULL;
734
735 if( eSmeCommandExitBmps == pmcCommand )
736 {
737 exitBmpsInfo.exitBmpsReason = eSME_REASON_OTHER;
738 pv = (void *)&exitBmpsInfo;
739 size = sizeof(tExitBmpsInfo);
740 }
741 //pmcCommand has to be one of the exit power save command
742 status = pmcPrepareCommand( pMac, pmcCommand, pv, size, &pPmcCmd );
743 if( HAL_STATUS_SUCCESS( status ) && pPmcCmd )
744 {
745 //Force this command to wake up the chip
746 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK );
747 csrLLUnlock( &pMac->sme.smeCmdActiveList );
748 fContinue = pmcProcessCommand( pMac, pPmcCmd );
749 if( fContinue )
750 {
751 //The command failed, remove it
752 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK ) )
753 {
754 pmcReleaseCommand( pMac, pPmcCmd );
755 }
756 }
757 }
758 else
759 {
760 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800761 smsLog( pMac, LOGE, FL( "Cannot issue command(0x%X) to wake up the chip. Status = %d"), pmcCommand, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 //Let it retry
763 fContinue = eANI_BOOLEAN_TRUE;
764 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530765 goto sme_process_scan_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700766 }
767 if ( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
768 {
769 // we can reuse the pCommand
770
771 // Insert the command onto the ActiveList...
772 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pCommand->Link, LL_ACCESS_NOLOCK );
773
774 // .... and process the command.
775
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -0700776 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
777 TRACE_CODE_SME_COMMAND, pCommand->sessionId, pCommand->command));
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 switch ( pCommand->command )
779 {
780
781 case eSmeCommandScan:
782 csrLLUnlock( &pMac->sme.smeCmdActiveList );
783 status = csrProcessScanCommand( pMac, pCommand );
784 break;
785
786 case eSmeCommandRoam:
787 csrLLUnlock( &pMac->sme.smeCmdActiveList );
788 status = csrRoamProcessCommand( pMac, pCommand );
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800789 if(!HAL_STATUS_SUCCESS(status))
790 {
791 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
792 &pCommand->Link, LL_ACCESS_LOCK ) )
793 {
794 csrReleaseCommandRoam( pMac, pCommand );
795 }
796 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 break;
798
799 case eSmeCommandWmStatusChange:
800 csrLLUnlock( &pMac->sme.smeCmdActiveList );
801 csrRoamProcessWmStatusChangeCommand(pMac, pCommand);
802 break;
803
804 case eSmeCommandSetKey:
805 csrLLUnlock( &pMac->sme.smeCmdActiveList );
806 status = csrRoamProcessSetKeyCommand( pMac, pCommand );
807 if(!HAL_STATUS_SUCCESS(status))
808 {
809 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
810 &pCommand->Link, LL_ACCESS_LOCK ) )
811 {
812 csrReleaseCommandSetKey( pMac, pCommand );
813 }
814 }
815 break;
816
817 case eSmeCommandRemoveKey:
818 csrLLUnlock( &pMac->sme.smeCmdActiveList );
819 status = csrRoamProcessRemoveKeyCommand( pMac, pCommand );
820 if(!HAL_STATUS_SUCCESS(status))
821 {
822 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
823 &pCommand->Link, LL_ACCESS_LOCK ) )
824 {
825 csrReleaseCommandRemoveKey( pMac, pCommand );
826 }
827 }
828 break;
829
830 case eSmeCommandAddStaSession:
831 csrLLUnlock( &pMac->sme.smeCmdActiveList );
832 csrProcessAddStaSessionCommand( pMac, pCommand );
833 break;
834 case eSmeCommandDelStaSession:
835 csrLLUnlock( &pMac->sme.smeCmdActiveList );
836 csrProcessDelStaSessionCommand( pMac, pCommand );
837 break;
838
Jeff Johnsone7245742012-09-05 17:12:55 -0700839#ifdef FEATURE_OEM_DATA_SUPPORT
840 case eSmeCommandOemDataReq:
841 csrLLUnlock(&pMac->sme.smeCmdActiveList);
842 oemData_ProcessOemDataReqCommand(pMac, pCommand);
843 break;
844#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 case eSmeCommandRemainOnChannel:
846 csrLLUnlock(&pMac->sme.smeCmdActiveList);
847 p2pProcessRemainOnChannelCmd(pMac, pCommand);
848 break;
849 case eSmeCommandNoAUpdate:
850 csrLLUnlock( &pMac->sme.smeCmdActiveList );
851 p2pProcessNoAReq(pMac,pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 case eSmeCommandEnterImps:
853 case eSmeCommandExitImps:
854 case eSmeCommandEnterBmps:
855 case eSmeCommandExitBmps:
856 case eSmeCommandEnterUapsd:
857 case eSmeCommandExitUapsd:
858 case eSmeCommandEnterWowl:
859 case eSmeCommandExitWowl:
860 csrLLUnlock( &pMac->sme.smeCmdActiveList );
861 fContinue = pmcProcessCommand( pMac, pCommand );
862 if( fContinue )
863 {
864 //The command failed, remove it
865 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
866 &pCommand->Link, LL_ACCESS_LOCK ) )
867 {
868 pmcReleaseCommand( pMac, pCommand );
869 }
870 }
871 break;
872
873 //Treat standby differently here because caller may not be able to handle
874 //the failure so we do our best here
875 case eSmeCommandEnterStandby:
876 if( csrIsConnStateDisconnected( pMac, pCommand->sessionId ) )
877 {
878 //It can continue
879 csrLLUnlock( &pMac->sme.smeCmdActiveList );
880 fContinue = pmcProcessCommand( pMac, pCommand );
881 if( fContinue )
882 {
883 //The command failed, remove it
884 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
885 &pCommand->Link, LL_ACCESS_LOCK ) )
886 {
887 pmcReleaseCommand( pMac, pCommand );
888 }
889 }
890 }
891 else
892 {
893 //Need to issue a disconnect first before processing this command
894 tSmeCmd *pNewCmd;
895
896 //We need to re-run the command
897 fContinue = eANI_BOOLEAN_TRUE;
898 //Pull off the standby command first
899 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
900 &pCommand->Link, LL_ACCESS_NOLOCK ) )
901 {
902 csrLLUnlock( &pMac->sme.smeCmdActiveList );
903 //Need to call CSR function here because the disconnect command
904 //is handled by CSR
905 pNewCmd = csrGetCommandBuffer( pMac );
906 if( NULL != pNewCmd )
907 {
908 //Put the standby command to the head of the pending list first
909 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCommand->Link,
910 LL_ACCESS_LOCK );
911 pNewCmd->command = eSmeCommandRoam;
912 pNewCmd->u.roamCmd.roamReason = eCsrForcedDisassoc;
913 //Put the disassoc command before the standby command
914 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pNewCmd->Link,
915 LL_ACCESS_LOCK );
916 }
917 else
918 {
919 //Continue the command here
920 fContinue = pmcProcessCommand( pMac, pCommand );
921 if( fContinue )
922 {
923 //The command failed, remove it
924 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
925 &pCommand->Link, LL_ACCESS_LOCK ) )
926 {
927 pmcReleaseCommand( pMac, pCommand );
928 }
929 }
930 }
931 }
932 else
933 {
934 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800935 smsLog( pMac, LOGE, FL(" failed to remove standby command") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 VOS_ASSERT(0);
937 }
938 }
939 break;
940
941 case eSmeCommandAddTs:
942 case eSmeCommandDelTs:
943 csrLLUnlock( &pMac->sme.smeCmdActiveList );
944#ifndef WLAN_MDM_CODE_REDUCTION_OPT
945 fContinue = qosProcessCommand( pMac, pCommand );
946 if( fContinue )
947 {
948 //The command failed, remove it
949 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
950 &pCommand->Link, LL_ACCESS_NOLOCK ) )
951 {
952//#ifndef WLAN_MDM_CODE_REDUCTION_OPT
953 qosReleaseCommand( pMac, pCommand );
954//#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
955 }
956 }
957#endif
958 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800959#ifdef FEATURE_WLAN_TDLS
960 case eSmeCommandTdlsSendMgmt:
961 case eSmeCommandTdlsAddPeer:
962 case eSmeCommandTdlsDelPeer:
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530963 case eSmeCommandTdlsLinkEstablish:
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800964#ifdef FEATURE_WLAN_TDLS_INTERNAL
965 case eSmeCommandTdlsDiscovery:
966 case eSmeCommandTdlsLinkSetup:
967 case eSmeCommandTdlsLinkTear:
968 case eSmeCommandTdlsEnterUapsd:
969 case eSmeCommandTdlsExitUapsd:
970#endif
971 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800972 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800973 "sending TDLS Command 0x%x to PE", pCommand->command);
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800974
975 csrLLUnlock( &pMac->sme.smeCmdActiveList );
976 status = csrTdlsProcessCmd( pMac, pCommand );
977 }
978 break ;
979#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700980
981 default:
982 //something is wrong
983 //remove it from the active list
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800984 smsLog(pMac, LOGE, " csrProcessCommand processes an unknown command %d", pCommand->command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK );
986 csrLLUnlock( &pMac->sme.smeCmdActiveList );
987 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
988 smeReleaseCommand( pMac, pCommand );
989 status = eHAL_STATUS_FAILURE;
990 break;
991 }
992 if(!HAL_STATUS_SUCCESS(status))
993 {
994 fContinue = eANI_BOOLEAN_TRUE;
995 }
996 }//if(pEntry)
997 else
998 {
999 //This is odd. Some one else pull off the command.
1000 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1001 }
1002 }
1003 else
1004 {
1005 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1006 }
1007 }
1008 else
1009 {
1010 //No command waiting
1011 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1012 //This is only used to restart an idle mode scan, it means at least one other idle scan has finished.
1013 if(pMac->scan.fRestartIdleScan && eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
1014 {
1015 tANI_U32 nTime = 0;
1016
1017 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
1018 if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime)))
1019 {
1020 csrScanStartIdleScanTimer(pMac, nTime);
1021 }
1022 }
1023 }
1024 }
1025 else {
1026 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1027 }
1028
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05301029sme_process_scan_queue:
1030 if (pMac->fScanOffload && !(smeProcessScanQueue(pMac)))
1031 fContinue = eANI_BOOLEAN_FALSE;
1032
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 return ( fContinue );
1034}
1035
1036void smeProcessPendingQueue( tpAniSirGlobal pMac )
1037{
1038 while( smeProcessCommand( pMac ) );
1039}
1040
1041
1042tANI_BOOLEAN smeCommandPending(tpAniSirGlobal pMac)
1043{
1044 return ( !csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) ||
1045 !csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK) );
1046}
1047
1048
1049
1050//Global APIs
1051
1052/*--------------------------------------------------------------------------
1053
1054 \brief sme_Open() - Initialze all SME modules and put them at idle state
1055
1056 The function initializes each module inside SME, PMC, CCM, CSR, etc. . Upon
1057 successfully return, all modules are at idle state ready to start.
1058
1059 smeOpen must be called before any other SME APIs can be involved.
1060 smeOpen must be called after macOpen.
Srinivas Girigowdade697412013-02-14 16:31:48 -08001061 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 \param hHal - The handle returned by macOpen.
1063
1064 \return eHAL_STATUS_SUCCESS - SME is successfully initialized.
1065
1066 Other status means SME is failed to be initialized
1067 \sa
1068
1069 --------------------------------------------------------------------------*/
1070eHalStatus sme_Open(tHalHandle hHal)
1071{
1072 eHalStatus status = eHAL_STATUS_FAILURE;
1073 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1074
1075 do {
1076 pMac->sme.state = SME_STATE_STOP;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07001077 pMac->sme.currDeviceMode = VOS_STA_MODE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->sme.lkSmeGlobalLock ) ) )
1079 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001080 smsLog( pMac, LOGE, "sme_Open failed init lock" );
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 status = eHAL_STATUS_FAILURE;
1082 break;
1083 }
1084
1085 status = ccmOpen(hHal);
1086 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1087 smsLog( pMac, LOGE,
1088 "ccmOpen failed during initialization with status=%d", status );
1089 break;
1090 }
1091
1092 status = csrOpen(pMac);
1093 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1094 smsLog( pMac, LOGE,
1095 "csrOpen failed during initialization with status=%d", status );
1096 break;
1097 }
1098
1099 status = pmcOpen(hHal);
1100 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1101 smsLog( pMac, LOGE,
1102 "pmcOpen failed during initialization with status=%d", status );
1103 break;
1104 }
1105
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07001106#ifdef FEATURE_WLAN_TDLS
1107 pMac->isTdlsPowerSaveProhibited = 0;
1108#endif
1109
Jeff Johnson295189b2012-06-20 16:38:30 -07001110#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1111 status = sme_QosOpen(pMac);
1112 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1113 smsLog( pMac, LOGE,
1114 "Qos open failed during initialization with status=%d", status );
1115 break;
1116 }
1117
1118 status = btcOpen(pMac);
1119 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1120 smsLog( pMac, LOGE,
1121 "btcOpen open failed during initialization with status=%d", status );
1122 break;
1123 }
1124#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001125#ifdef FEATURE_OEM_DATA_SUPPORT
1126 status = oemData_OemDataReqOpen(pMac);
1127 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1128 smsLog(pMac, LOGE,
1129 "oemData_OemDataReqOpen failed during initialization with status=%d", status );
1130 break;
1131 }
1132#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001133
1134 if(!HAL_STATUS_SUCCESS((status = initSmeCmdList(pMac))))
1135 break;
1136
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 {
1138 v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SAP, NULL);
1139 if ( NULL == pvosGCtx ){
1140 smsLog( pMac, LOGE, "WLANSAP_Open open failed during initialization");
1141 status = eHAL_STATUS_FAILURE;
1142 break;
1143 }
1144
1145 status = WLANSAP_Open( pvosGCtx );
1146 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1147 smsLog( pMac, LOGE,
1148 "WLANSAP_Open open failed during initialization with status=%d", status );
1149 break;
1150 }
1151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001152#if defined WLAN_FEATURE_VOWIFI
1153 status = rrmOpen(pMac);
1154 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1155 smsLog( pMac, LOGE,
1156 "rrmOpen open failed during initialization with status=%d", status );
1157 break;
1158 }
1159#endif
1160
1161#if defined WLAN_FEATURE_VOWIFI_11R
1162 sme_FTOpen(pMac);
1163#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 sme_p2pOpen(pMac);
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07001165 smeTraceInit(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001166
1167 }while (0);
1168
1169 return status;
1170}
1171
Jeff Johnson295189b2012-06-20 16:38:30 -07001172/*--------------------------------------------------------------------------
1173
1174 \brief sme_set11dinfo() - Set the 11d information about valid channels
1175 and there power using information from nvRAM
1176 This function is called only for AP.
1177
Srinivas Girigowdade697412013-02-14 16:31:48 -08001178 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001179
1180 \param hHal - The handle returned by macOpen.
1181 \Param pSmeConfigParams - a pointer to a caller allocated object of
1182 typedef struct _smeConfigParams.
1183
1184 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1185
1186 Other status means SME is failed to update the config parameters.
1187 \sa
1188--------------------------------------------------------------------------*/
1189
1190eHalStatus sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1191{
1192 eHalStatus status = eHAL_STATUS_FAILURE;
1193 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1194
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07001195 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
1196 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 if (NULL == pSmeConfigParams ) {
1198 smsLog( pMac, LOGE,
1199 "Empty config param structure for SME, nothing to update");
1200 return status;
1201 }
1202
1203 status = csrSetChannels(hHal, &pSmeConfigParams->csrConfig );
1204 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001205 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001206 status );
1207 }
1208 return status;
1209}
1210
1211/*--------------------------------------------------------------------------
1212
1213 \brief sme_getSoftApDomain() - Get the current regulatory domain of softAp.
1214
Srinivas Girigowdade697412013-02-14 16:31:48 -08001215 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001216
1217 \param hHal - The handle returned by HostapdAdapter.
1218 \Param v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
1219
1220 \return eHAL_STATUS_SUCCESS - SME successfully completed the request.
1221
1222 Other status means, failed to get the current regulatory domain.
1223 \sa
1224--------------------------------------------------------------------------*/
1225
1226eHalStatus sme_getSoftApDomain(tHalHandle hHal, v_REGDOMAIN_t *domainIdSoftAp)
1227{
1228 eHalStatus status = eHAL_STATUS_FAILURE;
1229 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1230
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07001231 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
1232 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 if (NULL == domainIdSoftAp ) {
1234 smsLog( pMac, LOGE, "Uninitialized domain Id");
1235 return status;
1236 }
1237
1238 *domainIdSoftAp = pMac->scan.domainIdCurrent;
1239 status = eHAL_STATUS_SUCCESS;
1240
1241 return status;
1242}
1243
1244
1245eHalStatus sme_setRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
1246{
1247 eHalStatus status = eHAL_STATUS_FAILURE;
1248 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1249
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07001250 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
1251 TRACE_CODE_SME_RX_HDD_MSG_SET_REGINFO, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 if (NULL == apCntryCode ) {
1253 smsLog( pMac, LOGE, "Empty Country Code, nothing to update");
1254 return status;
1255 }
1256
1257 status = csrSetRegInfo(hHal, apCntryCode );
1258 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001259 smsLog( pMac, LOGE, "csrSetRegInfo failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 status );
1261 }
1262 return status;
1263}
1264
Jeff Johnson295189b2012-06-20 16:38:30 -07001265#ifdef FEATURE_WLAN_SCAN_PNO
1266/*--------------------------------------------------------------------------
1267
1268 \brief sme_UpdateChannelConfig() - Update channel configuration in RIVA.
1269
1270 It is used at driver start up to inform RIVA of the default channel
1271 configuration.
1272
Srinivas Girigowdade697412013-02-14 16:31:48 -08001273 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001274
1275 \param hHal - The handle returned by macOpen.
1276
1277 \return eHAL_STATUS_SUCCESS - SME update the channel config successfully.
1278
1279 Other status means SME is failed to update the channel config.
1280 \sa
1281
1282 --------------------------------------------------------------------------*/
1283eHalStatus sme_UpdateChannelConfig(tHalHandle hHal)
1284{
1285 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1286
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07001287 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
1288 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CHANNEL_CONFIG, NO_SESSION, 0));
1289 pmcUpdateScanParams( pMac, &(pMac->roam.configParam),
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 &pMac->scan.base20MHzChannels, FALSE);
1291 return eHAL_STATUS_SUCCESS;
1292}
1293#endif // FEATURE_WLAN_SCAN_PNLO
1294
1295/*--------------------------------------------------------------------------
1296
1297 \brief sme_UpdateConfig() - Change configurations for all SME moduels
1298
1299 The function updates some configuration for modules in SME, CCM, CSR, etc
1300 during SMEs close open sequence.
1301
1302 Modules inside SME apply the new configuration at the next transaction.
1303
Srinivas Girigowdade697412013-02-14 16:31:48 -08001304 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001305
1306 \param hHal - The handle returned by macOpen.
1307 \Param pSmeConfigParams - a pointer to a caller allocated object of
1308 typedef struct _smeConfigParams.
1309
1310 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1311
1312 Other status means SME is failed to update the config parameters.
1313 \sa
1314
1315 --------------------------------------------------------------------------*/
1316eHalStatus sme_UpdateConfig(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1317{
1318 eHalStatus status = eHAL_STATUS_FAILURE;
1319 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1320
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07001321 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
1322 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 if (NULL == pSmeConfigParams ) {
1324 smsLog( pMac, LOGE,
1325 "Empty config param structure for SME, nothing to update");
1326 return status;
1327 }
1328
1329 status = csrChangeDefaultConfigParam(pMac, &pSmeConfigParams->csrConfig);
1330
1331 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001332 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 status );
1334 }
1335#if defined WLAN_FEATURE_P2P_INTERNAL
1336 status = p2pChangeDefaultConfigParam(pMac, &pSmeConfigParams->p2pConfig);
1337
1338 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001339 smsLog( pMac, LOGE, "p2pChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 status );
1341 }
1342#endif
1343#if defined WLAN_FEATURE_VOWIFI
1344 status = rrmChangeDefaultConfigParam(hHal, &pSmeConfigParams->rrmConfig);
1345
1346 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001347 smsLog( pMac, LOGE, "rrmChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 status );
1349 }
1350#endif
1351 //For SOC, CFG is set before start
1352 //We don't want to apply global CFG in connect state because that may cause some side affect
1353 if(
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 csrIsAllSessionDisconnected( pMac) )
1355 {
1356 csrSetGlobalCfgs(pMac);
1357 }
1358
Gopichand Nakkala86e42662013-06-11 17:44:11 +05301359 /* update the directed scan offload setting */
1360 pMac->fScanOffload = pSmeConfigParams->fScanOffload;
1361
Madan Mohan Koyyalamudid89feb72013-07-31 15:47:12 +05301362 if (pMac->fScanOffload)
1363 {
1364 /* If scan offload is enabled then lim has allow the sending of
1365 scan request to firmware even in powersave mode. The firmware has
1366 to take care of exiting from power save mode */
1367 status = ccmCfgSetInt(hHal, WNI_CFG_SCAN_IN_POWERSAVE,
1368 eANI_BOOLEAN_TRUE, NULL, eANI_BOOLEAN_FALSE);
1369
1370 if (eHAL_STATUS_SUCCESS != status)
1371 {
1372 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1373 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CCM");
1374 }
1375 }
krunal sonie9002db2013-11-25 14:24:17 -08001376 pMac->isCoalesingInIBSSAllowed =
1377 pSmeConfigParams->csrConfig.isCoalesingInIBSSAllowed;
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 return status;
1379}
1380
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301381#ifdef WLAN_FEATURE_GTK_OFFLOAD
1382void sme_ProcessGetGtkInfoRsp( tHalHandle hHal,
1383 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
1384{
1385 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1386
1387 if (NULL == pMac)
1388 {
1389 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1390 "%s: pMac is null", __func__);
1391 return ;
1392 }
1393 if (pMac->pmc.GtkOffloadGetInfoCB == NULL)
1394 {
1395 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1396 "%s: HDD callback is null", __func__);
1397 return ;
1398 }
1399 pMac->pmc.GtkOffloadGetInfoCB(pMac->pmc.GtkOffloadGetInfoCBContext,
1400 pGtkOffloadGetInfoRsp);
1401}
1402#endif
1403
Jeff Johnson295189b2012-06-20 16:38:30 -07001404/* ---------------------------------------------------------------------------
1405 \fn sme_ChangeConfigParams
1406 \brief The SME API exposed for HDD to provide config params to SME during
1407 SMEs stop -> start sequence.
1408
1409 If HDD changed the domain that will cause a reset. This function will
1410 provide the new set of 11d information for the new domain. Currrently this
1411 API provides info regarding 11d only at reset but we can extend this for
1412 other params (PMC, QoS) which needs to be initialized again at reset.
1413
Srinivas Girigowdade697412013-02-14 16:31:48 -08001414 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001415
1416 \param hHal - The handle returned by macOpen.
1417
1418 \Param
1419 pUpdateConfigParam - a pointer to a structure (tCsrUpdateConfigParam) that
1420 currently provides 11d related information like Country code,
1421 Regulatory domain, valid channel list, Tx power per channel, a
1422 list with active/passive scan allowed per valid channel.
1423
1424 \return eHalStatus
1425 ---------------------------------------------------------------------------*/
1426eHalStatus sme_ChangeConfigParams(tHalHandle hHal,
1427 tCsrUpdateConfigParam *pUpdateConfigParam)
1428{
1429 eHalStatus status = eHAL_STATUS_FAILURE;
1430 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1431
1432 if (NULL == pUpdateConfigParam ) {
1433 smsLog( pMac, LOGE,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001434 "Empty config param structure for SME, nothing to reset");
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 return status;
1436 }
1437
1438 status = csrChangeConfigParams(pMac, pUpdateConfigParam);
1439
1440 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001441 smsLog( pMac, LOGE, "csrUpdateConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 status );
1443 }
1444
1445 return status;
1446
1447}
1448
1449/*--------------------------------------------------------------------------
1450
1451 \brief sme_HDDReadyInd() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1452 that the NIC is ready tio run.
1453
1454 The function is called by HDD at the end of initialization stage so PE/HAL can
1455 enable the NIC to running state.
1456
Srinivas Girigowdade697412013-02-14 16:31:48 -08001457 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 \param hHal - The handle returned by macOpen.
1459
1460 \return eHAL_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1461 successfully.
1462
1463 Other status means SME failed to send the message to PE.
1464 \sa
1465
1466 --------------------------------------------------------------------------*/
1467eHalStatus sme_HDDReadyInd(tHalHandle hHal)
1468{
1469 tSirSmeReadyReq Msg;
1470 eHalStatus status = eHAL_STATUS_FAILURE;
1471 tPmcPowerState powerState;
1472 tPmcSwitchState hwWlanSwitchState;
1473 tPmcSwitchState swWlanSwitchState;
1474 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1475
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07001476 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
1477 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 do
1479 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001480
1481 Msg.messageType = eWNI_SME_SYS_READY_IND;
1482 Msg.length = sizeof( tSirSmeReadyReq );
1483
1484 if (eSIR_FAILURE != uMacPostCtrlMsg( hHal, (tSirMbMsg*)&Msg ))
1485 {
1486 status = eHAL_STATUS_SUCCESS;
1487 }
1488 else
1489 {
1490 smsLog( pMac, LOGE,
1491 "uMacPostCtrlMsg failed to send eWNI_SME_SYS_READY_IND");
1492 break;
1493 }
1494
1495 status = pmcQueryPowerState( hHal, &powerState,
1496 &hwWlanSwitchState, &swWlanSwitchState );
1497 if ( ! HAL_STATUS_SUCCESS( status ) )
1498 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001499 smsLog( pMac, LOGE, "pmcQueryPowerState failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 status );
1501 break;
1502 }
1503
1504 if ( (ePMC_SWITCH_OFF != hwWlanSwitchState) &&
1505 (ePMC_SWITCH_OFF != swWlanSwitchState) )
1506 {
1507 status = csrReady(pMac);
1508 if ( ! HAL_STATUS_SUCCESS( status ) )
1509 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001510 smsLog( pMac, LOGE, "csrReady failed with status=%d", status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 break;
1512 }
1513 status = pmcReady(hHal);
1514 if ( ! HAL_STATUS_SUCCESS( status ) )
1515 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001516 smsLog( pMac, LOGE, "pmcReady failed with status=%d", status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 break;
1518 }
1519#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1520 if(VOS_STATUS_SUCCESS != btcReady(hHal))
1521 {
1522 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001523 smsLog( pMac, LOGE, "btcReady failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001524 break;
1525 }
1526#endif
1527
1528#if defined WLAN_FEATURE_VOWIFI
1529 if(VOS_STATUS_SUCCESS != rrmReady(hHal))
1530 {
1531 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001532 smsLog( pMac, LOGE, "rrmReady failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 break;
1534 }
1535#endif
1536 }
1537 pMac->sme.state = SME_STATE_READY;
1538 } while( 0 );
1539
1540 return status;
1541}
1542
1543/*--------------------------------------------------------------------------
1544
1545 \brief sme_Start() - Put all SME modules at ready state.
1546
1547 The function starts each module in SME, PMC, CCM, CSR, etc. . Upon
1548 successfully return, all modules are ready to run.
Srinivas Girigowdade697412013-02-14 16:31:48 -08001549 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 \param hHal - The handle returned by macOpen.
1551
1552 \return eHAL_STATUS_SUCCESS - SME is ready.
1553
1554 Other status means SME is failed to start
1555 \sa
1556
1557 --------------------------------------------------------------------------*/
1558eHalStatus sme_Start(tHalHandle hHal)
1559{
1560 eHalStatus status = eHAL_STATUS_FAILURE;
1561 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1562
1563 do
1564 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 status = csrStart(pMac);
1566 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001567 smsLog( pMac, LOGE, "csrStart failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 status );
1569 break;
1570 }
1571
1572 status = pmcStart(hHal);
1573 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001574 smsLog( pMac, LOGE, "pmcStart failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 status );
1576 break;
1577 }
1578
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 status = WLANSAP_Start(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1580 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001581 smsLog( pMac, LOGE, "WLANSAP_Start failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 status );
1583 break;
1584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 pMac->sme.state = SME_STATE_START;
1586 }while (0);
1587
1588 return status;
1589}
1590
1591
1592#ifdef WLAN_FEATURE_PACKET_FILTERING
1593/******************************************************************************
1594*
1595* Name: sme_PCFilterMatchCountResponseHandler
1596*
1597* Description:
1598* Invoke Packet Coalescing Filter Match Count callback routine
1599*
1600* Parameters:
1601* hHal - HAL handle for device
1602* pMsg - Pointer to tRcvFltPktMatchRsp structure
1603*
1604* Returns: eHalStatus
1605*
1606******************************************************************************/
1607eHalStatus sme_PCFilterMatchCountResponseHandler(tHalHandle hHal, void* pMsg)
1608{
1609 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1610 eHalStatus status = eHAL_STATUS_SUCCESS;
1611 tpSirRcvFltPktMatchRsp pRcvFltPktMatchRsp = (tpSirRcvFltPktMatchRsp)pMsg;
1612
1613 if (NULL == pMsg)
1614 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001615 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 status = eHAL_STATUS_FAILURE;
1617 }
1618 else
1619 {
1620 smsLog(pMac, LOG2, "SME: entering "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001621 "sme_FilterMatchCountResponseHandler");
Jeff Johnson295189b2012-06-20 16:38:30 -07001622
1623 /* Call Packet Coalescing Filter Match Count callback routine. */
1624 if (pMac->pmc.FilterMatchCountCB != NULL)
1625 pMac->pmc.FilterMatchCountCB(pMac->pmc.FilterMatchCountCBContext,
1626 pRcvFltPktMatchRsp);
1627
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001628 smsLog(pMac, LOG1, "%s: status=0x%x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 pRcvFltPktMatchRsp->status);
1630
1631 pMac->pmc.FilterMatchCountCB = NULL;
1632 pMac->pmc.FilterMatchCountCBContext = NULL;
1633 }
1634
1635 return(status);
1636}
1637#endif // WLAN_FEATURE_PACKET_FILTERING
1638
1639
Chet Lanctot186b5732013-03-18 10:26:30 -07001640#ifdef WLAN_FEATURE_11W
1641/*------------------------------------------------------------------
1642 *
1643 * Handle the unprotected management frame indication from LIM and
1644 * forward it to HDD.
1645 *
1646 *------------------------------------------------------------------*/
1647
1648eHalStatus sme_UnprotectedMgmtFrmInd( tHalHandle hHal,
1649 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1650{
1651 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1652 eHalStatus status = eHAL_STATUS_SUCCESS;
1653 tCsrRoamInfo pRoamInfo = {0};
1654 tANI_U32 SessionId = pSmeMgmtFrm->sessionId;
1655
1656 pRoamInfo.nFrameLength = pSmeMgmtFrm->frameLen;
1657 pRoamInfo.pbFrames = pSmeMgmtFrm->frameBuf;
1658 pRoamInfo.frameType = pSmeMgmtFrm->frameType;
1659
1660 /* forward the mgmt frame to HDD */
1661 csrRoamCallCallback(pMac, SessionId, &pRoamInfo, 0, eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1662
1663 return status;
1664}
1665#endif
1666
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001667#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
1668/*------------------------------------------------------------------
1669 *
1670 * Handle the tsm ie indication from LIM and forward it to HDD.
1671 *
1672 *------------------------------------------------------------------*/
1673
1674eHalStatus sme_TsmIeInd(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
1675{
1676 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1677 eHalStatus status = eHAL_STATUS_SUCCESS;
1678 tCsrRoamInfo pRoamInfo = {0};
1679 tANI_U32 SessionId = pSmeTsmIeInd->sessionId;
1680
1681 pRoamInfo.tsmIe.tsid= pSmeTsmIeInd->tsmIe.tsid;
1682 pRoamInfo.tsmIe.state= pSmeTsmIeInd->tsmIe.state;
1683 pRoamInfo.tsmIe.msmt_interval= pSmeTsmIeInd->tsmIe.msmt_interval;
1684
1685 /* forward the tsm ie information to HDD */
1686 csrRoamCallCallback(pMac, SessionId, &pRoamInfo, 0, eCSR_ROAM_TSM_IE_IND, 0);
1687
1688 return status;
1689}
1690
1691/* ---------------------------------------------------------------------------
1692 \fn sme_SetCCKMIe
1693 \brief function to store the CCKM IE passed from supplicant and use it while packing
1694 reassociation request
1695 \param hHal - HAL handle for device
1696 \param pCckmIe - pointer to CCKM IE data
1697 \param pCckmIeLen - length of the CCKM IE
1698 \- return Success or failure
1699 -------------------------------------------------------------------------*/
1700eHalStatus sme_SetCCKMIe(tHalHandle hHal, tANI_U8 sessionId,
1701 tANI_U8 *pCckmIe, tANI_U8 cckmIeLen)
1702{
1703 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1704 eHalStatus status = eHAL_STATUS_SUCCESS;
1705
1706 status = sme_AcquireGlobalLock( &pMac->sme );
1707 if ( HAL_STATUS_SUCCESS( status ) )
1708 {
1709 csrSetCCKMIe(pMac, sessionId, pCckmIe, cckmIeLen);
1710 sme_ReleaseGlobalLock( &pMac->sme );
1711 }
1712 return status;
1713}
1714
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08001715/* ---------------------------------------------------------------------------
1716 \fn sme_SetCcxBeaconRequest
1717 \brief function to set CCX beacon request parameters
1718 \param hHal - HAL handle for device
1719 \param sessionId - Session id
1720 \param pCcxBcnReq - pointer to CCX beacon request
1721 \- return Success or failure
1722 -------------------------------------------------------------------------*/
1723eHalStatus sme_SetCcxBeaconRequest(tHalHandle hHal, const tANI_U8 sessionId,
1724 const tCsrCcxBeaconReq* pCcxBcnReq)
1725{
1726 eHalStatus status = eSIR_SUCCESS;
1727 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1728 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1729 tCsrCcxBeaconReqParams *pBeaconReq = NULL;
1730 tANI_U8 counter = 0;
1731 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
1732 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1733
1734 /* Store the info in RRM context */
1735 vos_mem_copy(&pSmeRrmContext->ccxBcnReqInfo, pCcxBcnReq, sizeof(tCsrCcxBeaconReq));
1736
1737 //Prepare the request to send to SME.
1738 pSmeBcnReportReq = vos_mem_malloc(sizeof( tSirBeaconReportReqInd ));
1739 if(NULL == pSmeBcnReportReq)
1740 {
1741 smsLog(pMac, LOGP, "Memory Allocation Failure!!! CCX BcnReq Ind to SME");
1742 return eSIR_FAILURE;
1743 }
1744
1745 smsLog(pMac, LOGE, "Sending Beacon Report Req to SME");
1746 vos_mem_zero( pSmeBcnReportReq, sizeof( tSirBeaconReportReqInd ));
1747
1748 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1749 pSmeBcnReportReq->length = sizeof( tSirBeaconReportReqInd );
1750 vos_mem_copy( pSmeBcnReportReq->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
1751 pSmeBcnReportReq->channelInfo.channelNum = 255;
1752 pSmeBcnReportReq->channelList.numChannels = pCcxBcnReq->numBcnReqIe;
1753
1754 for (counter = 0; counter < pCcxBcnReq->numBcnReqIe; counter++)
1755 {
1756 pBeaconReq = (tCsrCcxBeaconReqParams *)&pCcxBcnReq->bcnReq[counter];
1757 pSmeBcnReportReq->fMeasurementtype[counter] = pBeaconReq->scanMode;
1758 pSmeBcnReportReq->measurementDuration[counter] = SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1759 pSmeBcnReportReq->channelList.channelNumber[counter] = pBeaconReq->channel;
1760 }
1761
1762 sme_RrmProcessBeaconReportReqInd(pMac, pSmeBcnReportReq);
1763 return status;
1764}
1765
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001766#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
1767
Chet Lanctot186b5732013-03-18 10:26:30 -07001768
Jeff Johnson295189b2012-06-20 16:38:30 -07001769/*--------------------------------------------------------------------------
1770
1771 \brief sme_ProcessMsg() - The main message processor for SME.
1772
1773 The function is called by a message dispatcher when to process a message
1774 targeted for SME.
1775
Srinivas Girigowdade697412013-02-14 16:31:48 -08001776 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 \param hHal - The handle returned by macOpen.
1778 \param pMsg - A pointer to a caller allocated object of tSirMsgQ.
1779
1780 \return eHAL_STATUS_SUCCESS - SME successfully process the message.
1781
1782 Other status means SME failed to process the message to HAL.
1783 \sa
1784
1785 --------------------------------------------------------------------------*/
1786eHalStatus sme_ProcessMsg(tHalHandle hHal, vos_msg_t* pMsg)
1787{
1788 eHalStatus status = eHAL_STATUS_FAILURE;
1789 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1790
1791 if (pMsg == NULL) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001792 smsLog( pMac, LOGE, "Empty message for SME, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 return status;
1794 }
1795
1796 status = sme_AcquireGlobalLock( &pMac->sme );
1797 if ( HAL_STATUS_SUCCESS( status ) )
1798 {
1799 if( SME_IS_START(pMac) )
1800 {
1801 switch (pMsg->type) { // TODO: Will be modified to do a range check for msgs instead of having cases for each msgs
1802 case eWNI_PMC_ENTER_BMPS_RSP:
1803 case eWNI_PMC_EXIT_BMPS_RSP:
1804 case eWNI_PMC_EXIT_BMPS_IND:
1805 case eWNI_PMC_ENTER_IMPS_RSP:
1806 case eWNI_PMC_EXIT_IMPS_RSP:
1807 case eWNI_PMC_SMPS_STATE_IND:
1808 case eWNI_PMC_ENTER_UAPSD_RSP:
1809 case eWNI_PMC_EXIT_UAPSD_RSP:
1810 case eWNI_PMC_ENTER_WOWL_RSP:
1811 case eWNI_PMC_EXIT_WOWL_RSP:
1812 //PMC
1813 if (pMsg->bodyptr)
1814 {
1815 pmcMessageProcessor(hHal, pMsg->bodyptr);
1816 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +05301817 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001819 smsLog( pMac, LOGE, "Empty rsp message for PMC, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 }
1821 break;
1822
1823 case WNI_CFG_SET_CNF:
1824 case WNI_CFG_DNLD_CNF:
1825 case WNI_CFG_GET_RSP:
1826 case WNI_CFG_ADD_GRP_ADDR_CNF:
1827 case WNI_CFG_DEL_GRP_ADDR_CNF:
1828 //CCM
1829 if (pMsg->bodyptr)
1830 {
1831 ccmCfgCnfMsgHandler(hHal, pMsg->bodyptr);
1832 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +05301833 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001835 smsLog( pMac, LOGE, "Empty rsp message for CCM, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 }
1837 break;
1838
1839 case eWNI_SME_ADDTS_RSP:
1840 case eWNI_SME_DELTS_RSP:
1841 case eWNI_SME_DELTS_IND:
1842#ifdef WLAN_FEATURE_VOWIFI_11R
1843 case eWNI_SME_FT_AGGR_QOS_RSP:
1844#endif
1845 //QoS
1846 if (pMsg->bodyptr)
1847 {
1848#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1849 status = sme_QosMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05301850 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07001851#endif
1852 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001853 smsLog( pMac, LOGE, "Empty rsp message for QoS, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001854 }
1855 break;
1856#if defined WLAN_FEATURE_VOWIFI
1857 case eWNI_SME_NEIGHBOR_REPORT_IND:
1858 case eWNI_SME_BEACON_REPORT_REQ_IND:
1859#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001860 smsLog( pMac, LOGE, "Received RRM message. Message Id = %d", pMsg->type );
Jeff Johnson295189b2012-06-20 16:38:30 -07001861#endif
1862 if ( pMsg->bodyptr )
1863 {
1864 status = sme_RrmMsgProcessor( pMac, pMsg->type, pMsg->bodyptr );
Kiet Lam64c1b492013-07-12 13:56:44 +05301865 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 }
1867 else
1868 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001869 smsLog( pMac, LOGE, "Empty message for RRM, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 }
1871 break;
1872#endif
1873
Jeff Johnsone7245742012-09-05 17:12:55 -07001874#ifdef FEATURE_OEM_DATA_SUPPORT
1875 //Handle the eWNI_SME_OEM_DATA_RSP:
1876 case eWNI_SME_OEM_DATA_RSP:
1877 if(pMsg->bodyptr)
1878 {
1879 status = sme_HandleOemDataRsp(pMac, pMsg->bodyptr);
1880 vos_mem_free(pMsg->bodyptr);
1881 }
1882 else
1883 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001884 smsLog( pMac, LOGE, "Empty rsp message for oemData_ (eWNI_SME_OEM_DATA_RSP), nothing to process");
Jeff Johnsone7245742012-09-05 17:12:55 -07001885 }
1886 smeProcessPendingQueue( pMac );
1887 break;
1888#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001889
1890 case eWNI_SME_ADD_STA_SELF_RSP:
1891 if(pMsg->bodyptr)
1892 {
1893 status = csrProcessAddStaSessionRsp(pMac, pMsg->bodyptr);
1894 vos_mem_free(pMsg->bodyptr);
1895 }
1896 else
1897 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001898 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ADD_STA_SELF_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 }
1900 break;
1901 case eWNI_SME_DEL_STA_SELF_RSP:
1902 if(pMsg->bodyptr)
1903 {
1904 status = csrProcessDelStaSessionRsp(pMac, pMsg->bodyptr);
1905 vos_mem_free(pMsg->bodyptr);
1906 }
1907 else
1908 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001909 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_DEL_STA_SELF_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 }
1911 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 case eWNI_SME_REMAIN_ON_CHN_RSP:
1913 if(pMsg->bodyptr)
1914 {
1915 status = sme_remainOnChnRsp(pMac, pMsg->bodyptr);
1916 vos_mem_free(pMsg->bodyptr);
1917 }
1918 else
1919 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001920 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 }
1922 break;
1923 case eWNI_SME_REMAIN_ON_CHN_RDY_IND:
1924 if(pMsg->bodyptr)
1925 {
1926 status = sme_remainOnChnReady(pMac, pMsg->bodyptr);
1927 vos_mem_free(pMsg->bodyptr);
1928 }
1929 else
1930 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001931 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RDY_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 }
1933 break;
1934 case eWNI_SME_MGMT_FRM_IND:
1935 if(pMsg->bodyptr)
1936 {
1937 sme_mgmtFrmInd(pMac, pMsg->bodyptr);
1938 vos_mem_free(pMsg->bodyptr);
1939 }
1940 else
1941 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001942 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_MGMT_FRM_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 }
1944 break;
1945 case eWNI_SME_ACTION_FRAME_SEND_CNF:
1946 if(pMsg->bodyptr)
1947 {
1948 status = sme_sendActionCnf(pMac, pMsg->bodyptr);
1949 vos_mem_free(pMsg->bodyptr);
1950 }
1951 else
1952 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001953 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ACTION_FRAME_SEND_CNF), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 }
1955 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 case eWNI_SME_COEX_IND:
1957 if(pMsg->bodyptr)
1958 {
1959 status = btcHandleCoexInd((void *)pMac, pMsg->bodyptr);
1960 vos_mem_free(pMsg->bodyptr);
1961 }
1962 else
1963 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001964 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 }
1966 break;
1967
1968#ifdef FEATURE_WLAN_SCAN_PNO
1969 case eWNI_SME_PREF_NETWORK_FOUND_IND:
1970 if(pMsg->bodyptr)
1971 {
1972 status = sme_PreferredNetworkFoundInd((void *)pMac, pMsg->bodyptr);
1973 vos_mem_free(pMsg->bodyptr);
1974 }
1975 else
1976 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001977 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_PREF_NETWORK_FOUND_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 }
1979 break;
1980#endif // FEATURE_WLAN_SCAN_PNO
1981
1982 case eWNI_SME_TX_PER_HIT_IND:
1983 if (pMac->sme.pTxPerHitCallback)
1984 {
1985 pMac->sme.pTxPerHitCallback(pMac->sme.pTxPerHitCbContext);
1986 }
1987 break;
1988
1989 case eWNI_SME_CHANGE_COUNTRY_CODE:
Amar Singhal0d15bd52013-10-12 23:13:13 -07001990 if(pMsg->bodyptr)
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 {
1992 status = sme_HandleChangeCountryCode((void *)pMac, pMsg->bodyptr);
1993 vos_mem_free(pMsg->bodyptr);
1994 }
1995 else
1996 {
Amar Singhal0d15bd52013-10-12 23:13:13 -07001997 smsLog(pMac, LOGE, "Empty rsp message for message (eWNI_SME_CHANGE_COUNTRY_CODE), nothing to process");
1998 }
1999 break;
2000
2001 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2002 if (pMsg->bodyptr)
2003 {
2004 status = sme_HandleGenericChangeCountryCode((void *)pMac, pMsg->bodyptr);
2005 vos_mem_free(pMsg->bodyptr);
2006 }
2007 else
2008 {
2009 smsLog(pMac, LOGE, "Empty rsp message for message (eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 }
2011 break;
2012
2013#ifdef WLAN_FEATURE_PACKET_FILTERING
2014 case eWNI_PMC_PACKET_COALESCING_FILTER_MATCH_COUNT_RSP:
2015 if(pMsg->bodyptr)
2016 {
2017 status = sme_PCFilterMatchCountResponseHandler((void *)pMac, pMsg->bodyptr);
2018 vos_mem_free(pMsg->bodyptr);
2019 }
2020 else
2021 {
2022 smsLog(pMac, LOGE, "Empty rsp message for meas "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002023 "(PACKET_COALESCING_FILTER_MATCH_COUNT_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 }
2025 break;
2026#endif // WLAN_FEATURE_PACKET_FILTERING
2027 case eWNI_SME_PRE_SWITCH_CHL_IND:
2028 {
2029 status = sme_HandlePreChannelSwitchInd(pMac);
2030 break;
2031 }
2032
2033 case eWNI_SME_POST_SWITCH_CHL_IND:
2034 {
2035 status = sme_HandlePostChannelSwitchInd(pMac);
2036 break;
2037 }
2038
2039#ifdef WLAN_WAKEUP_EVENTS
2040 case eWNI_SME_WAKE_REASON_IND:
2041 if(pMsg->bodyptr)
2042 {
2043 status = sme_WakeReasonIndCallback((void *)pMac, pMsg->bodyptr);
2044 vos_mem_free(pMsg->bodyptr);
2045 }
2046 else
2047 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002048 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_WAKE_REASON_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 }
2050 break;
2051#endif // WLAN_WAKEUP_EVENTS
2052
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002053#ifdef FEATURE_WLAN_TDLS
2054 /*
2055 * command rescived from PE, SME tdls msg processor shall be called
2056 * to process commands recieved from PE
2057 */
2058 case eWNI_SME_TDLS_SEND_MGMT_RSP:
2059 case eWNI_SME_TDLS_ADD_STA_RSP:
Hoonki Leee6bfe942013-02-05 15:01:19 -08002060 case eWNI_SME_TDLS_DEL_STA_RSP:
2061 case eWNI_SME_TDLS_DEL_STA_IND:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002062 case eWNI_SME_TDLS_DEL_ALL_PEER_IND:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002063 case eWNI_SME_MGMT_FRM_TX_COMPLETION_IND:
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302064 case eWNI_SME_TDLS_LINK_ESTABLISH_RSP:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002065#ifdef FEATURE_WLAN_TDLS_INTERNAL
2066 case eWNI_SME_TDLS_DISCOVERY_START_RSP:
2067 case eWNI_SME_TDLS_DISCOVERY_START_IND:
2068 case eWNI_SME_TDLS_LINK_START_RSP:
2069 case eWNI_SME_TDLS_LINK_START_IND:
2070 case eWNI_SME_TDLS_TEARDOWN_RSP:
2071 case eWNI_SME_TDLS_TEARDOWN_IND:
2072 case eWNI_SME_ADD_TDLS_PEER_IND:
2073 case eWNI_SME_DELETE_TDLS_PEER_IND:
2074#endif
2075 {
2076 if (pMsg->bodyptr)
2077 {
2078 status = tdlsMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05302079 vos_mem_free(pMsg->bodyptr);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002080 }
2081 else
2082 {
2083 smsLog( pMac, LOGE, "Empty rsp message for TDLS, \
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002084 nothing to process");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002085 }
2086 break;
2087 }
2088#endif
2089
Chet Lanctot186b5732013-03-18 10:26:30 -07002090#ifdef WLAN_FEATURE_11W
2091 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2092 if (pMsg->bodyptr)
2093 {
2094 sme_UnprotectedMgmtFrmInd(pMac, pMsg->bodyptr);
2095 vos_mem_free(pMsg->bodyptr);
2096 }
2097 else
2098 {
2099 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_UNPROT_MGMT_FRM_IND), nothing to process");
2100 }
2101 break;
2102#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002103#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
2104 case eWNI_SME_TSM_IE_IND:
2105 {
2106 if (pMsg->bodyptr)
2107 {
2108 sme_TsmIeInd(pMac, pMsg->bodyptr);
2109 vos_mem_free(pMsg->bodyptr);
2110 }
2111 else
2112 {
2113 smsLog(pMac, LOGE, "Empty rsp message for (eWNI_SME_TSM_IE_IND), nothing to process");
2114 }
2115 break;
2116 }
2117#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07002118#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2119 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2120 status = csrRoamOffloadScanRspHdlr((void *)pMac, pMsg->bodyval);
2121 break;
2122#endif // WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Chet Lanctot186b5732013-03-18 10:26:30 -07002123
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05302124#ifdef WLAN_FEATURE_GTK_OFFLOAD
2125 case eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP:
2126 if (pMsg->bodyptr)
2127 {
2128 sme_ProcessGetGtkInfoRsp(pMac, pMsg->bodyptr);
2129 vos_mem_free(pMsg->bodyptr);
2130 }
2131 else
2132 {
2133 smsLog(pMac, LOGE, "Empty rsp message for (eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP), nothing to process");
2134 }
2135 break ;
2136#endif
Leo Chang9056f462013-08-01 19:21:11 -07002137
2138#ifdef FEATURE_WLAN_LPHB
2139 /* LPHB timeout indication arrived, send IND to client */
Leo Changd9df8aa2013-09-26 13:32:26 -07002140 case eWNI_SME_LPHB_IND:
2141 if (pMac->sme.pLphbIndCb)
Leo Chang9056f462013-08-01 19:21:11 -07002142 {
Leo Changd9df8aa2013-09-26 13:32:26 -07002143 pMac->sme.pLphbIndCb(pMac->pAdapter, pMsg->bodyptr);
Leo Chang9056f462013-08-01 19:21:11 -07002144 }
2145 vos_mem_free(pMsg->bodyptr);
2146
2147 break;
2148#endif /* FEATURE_WLAN_LPHB */
2149
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 default:
2151
2152 if ( ( pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN )
2153 && ( pMsg->type <= eWNI_SME_MSG_TYPES_END ) )
2154 {
2155 //CSR
2156 if (pMsg->bodyptr)
2157 {
2158 status = csrMsgProcessor(hHal, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05302159 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 }
2161 else
2162 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002163 smsLog( pMac, LOGE, "Empty rsp message for CSR, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 }
2165 }
2166 else
2167 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002168 smsLog( pMac, LOGW, "Unknown message type %d, nothing to process",
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 pMsg->type);
2170 if (pMsg->bodyptr)
2171 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302172 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 }
2174 }
2175 }//switch
2176 } //SME_IS_START
2177 else
2178 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002179 smsLog( pMac, LOGW, "message type %d in stop state ignored", pMsg->type);
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 if (pMsg->bodyptr)
2181 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302182 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 }
2184 }
2185 sme_ReleaseGlobalLock( &pMac->sme );
2186 }
2187 else
2188 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002189 smsLog( pMac, LOGW, "Locking failed, bailing out");
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 if (pMsg->bodyptr)
2191 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302192 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 }
2194 }
2195
2196 return status;
2197}
2198
2199
2200//No need to hold the global lock here because this function can only be called
2201//after sme_Stop.
2202v_VOID_t sme_FreeMsg( tHalHandle hHal, vos_msg_t* pMsg )
2203{
2204 if( pMsg )
2205 {
2206 if (pMsg->bodyptr)
2207 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302208 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 }
2210 }
2211
2212}
2213
2214
2215/*--------------------------------------------------------------------------
2216
2217 \brief sme_Stop() - Stop all SME modules and put them at idle state
2218
2219 The function stops each module in SME, PMC, CCM, CSR, etc. . Upon
2220 return, all modules are at idle state ready to start.
2221
Srinivas Girigowdade697412013-02-14 16:31:48 -08002222 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 \param hHal - The handle returned by macOpen
Kiet Lama72a2322013-11-15 11:18:11 +05302224 \param tHalStopType - reason for stopping
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
2226 \return eHAL_STATUS_SUCCESS - SME is stopped.
2227
2228 Other status means SME is failed to stop but caller should still
2229 consider SME is stopped.
2230 \sa
2231
2232 --------------------------------------------------------------------------*/
Kiet Lama72a2322013-11-15 11:18:11 +05302233eHalStatus sme_Stop(tHalHandle hHal, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -07002234{
2235 eHalStatus status = eHAL_STATUS_FAILURE;
2236 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
2237 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2238
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 status = WLANSAP_Stop(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
2240 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002241 smsLog( pMac, LOGE, "WLANSAP_Stop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 status );
2243 fail_status = status;
2244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002245
2246 p2pStop(hHal);
2247
Kiet Lama72a2322013-11-15 11:18:11 +05302248 status = pmcStop(hHal);
2249 if ( ! HAL_STATUS_SUCCESS( status ) ) {
2250 smsLog( pMac, LOGE, "pmcStop failed during smeStop with status=%d",
2251 status );
2252 fail_status = status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 }
2254
Kiet Lama72a2322013-11-15 11:18:11 +05302255 status = csrStop(pMac, stopType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002257 smsLog( pMac, LOGE, "csrStop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 status );
2259 fail_status = status;
2260 }
2261
2262 ccmStop(hHal);
2263
2264 purgeSmeCmdList(pMac);
2265
2266 if (!HAL_STATUS_SUCCESS( fail_status )) {
2267 status = fail_status;
2268 }
2269
2270 pMac->sme.state = SME_STATE_STOP;
2271
2272 return status;
2273}
2274
2275/*--------------------------------------------------------------------------
2276
2277 \brief sme_Close() - Release all SME modules and their resources.
2278
2279 The function release each module in SME, PMC, CCM, CSR, etc. . Upon
2280 return, all modules are at closed state.
2281
2282 No SME APIs can be involved after smeClose except smeOpen.
2283 smeClose must be called before macClose.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002284 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 \param hHal - The handle returned by macOpen
2286
2287 \return eHAL_STATUS_SUCCESS - SME is successfully close.
2288
2289 Other status means SME is failed to be closed but caller still cannot
2290 call any other SME functions except smeOpen.
2291 \sa
2292
2293 --------------------------------------------------------------------------*/
2294eHalStatus sme_Close(tHalHandle hHal)
2295{
2296 eHalStatus status = eHAL_STATUS_FAILURE;
2297 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
2298 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2299
2300 status = csrClose(pMac);
2301 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002302 smsLog( pMac, LOGE, "csrClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 status );
2304 fail_status = status;
2305 }
2306
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 status = WLANSAP_Close(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
2308 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002309 smsLog( pMac, LOGE, "WLANSAP_close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 status );
2311 fail_status = status;
2312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002313
2314#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2315 status = btcClose(hHal);
2316 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002317 smsLog( pMac, LOGE, "BTC close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002318 status );
2319 fail_status = status;
2320 }
2321
2322 status = sme_QosClose(pMac);
2323 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002324 smsLog( pMac, LOGE, "Qos close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 status );
2326 fail_status = status;
2327 }
2328#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002329#ifdef FEATURE_OEM_DATA_SUPPORT
2330 status = oemData_OemDataReqClose(hHal);
2331 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002332 smsLog( pMac, LOGE, "OEM DATA REQ close failed during sme close with status=%d",
Jeff Johnsone7245742012-09-05 17:12:55 -07002333 status );
2334 fail_status = status;
2335 }
2336#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002337
2338 status = ccmClose(hHal);
2339 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002340 smsLog( pMac, LOGE, "ccmClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 status );
2342 fail_status = status;
2343 }
2344
2345 status = pmcClose(hHal);
2346 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002347 smsLog( pMac, LOGE, "pmcClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 status );
2349 fail_status = status;
2350 }
2351#if defined WLAN_FEATURE_VOWIFI
2352 status = rrmClose(hHal);
2353 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002354 smsLog( pMac, LOGE, "RRM close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 status );
2356 fail_status = status;
2357 }
2358#endif
2359
2360#if defined WLAN_FEATURE_VOWIFI_11R
2361 sme_FTClose(hHal);
2362#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 sme_p2pClose(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002364
2365 freeSmeCmdList(pMac);
2366
2367 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->sme.lkSmeGlobalLock ) ) )
2368 {
2369 fail_status = eHAL_STATUS_FAILURE;
2370 }
2371
2372 if (!HAL_STATUS_SUCCESS( fail_status )) {
2373 status = fail_status;
2374 }
2375
2376 pMac->sme.state = SME_STATE_STOP;
2377
2378 return status;
2379}
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002380#ifdef FEATURE_WLAN_LFR
2381tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac)
2382{
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07002383#if 0
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002384 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
2385 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2386 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
2387 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
2388 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
2389 return eANI_BOOLEAN_FALSE;
2390 default:
2391 return eANI_BOOLEAN_TRUE;
2392 }
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07002393#else
2394 /*
2395 * TODO: always return TRUE for now until
2396 * we figure out why we could be stuck in
2397 * one of the roaming states forever.
2398 */
2399 return eANI_BOOLEAN_TRUE;
2400#endif
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002401}
2402#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002403/* ---------------------------------------------------------------------------
2404 \fn sme_ScanRequest
2405 \brief a wrapper function to Request a 11d or full scan from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002406 This is an asynchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 \param pScanRequestID - pointer to an object to get back the request ID
2408 \param callback - a callback function that scan calls upon finish, will not
2409 be called if csrScanRequest returns error
2410 \param pContext - a pointer passed in for the callback
2411 \return eHalStatus
2412 ---------------------------------------------------------------------------*/
2413eHalStatus sme_ScanRequest(tHalHandle hHal, tANI_U8 sessionId, tCsrScanRequest *pscanReq,
2414 tANI_U32 *pScanRequestID,
2415 csrScanCompleteCallback callback, void *pContext)
2416{
2417 eHalStatus status = eHAL_STATUS_FAILURE;
2418 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07002419 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
2420 TRACE_CODE_SME_RX_HDD_MSG_SCAN_REQ, sessionId, pscanReq->scanType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 smsLog(pMac, LOG2, FL("enter"));
2422 do
2423 {
2424 if(pMac->scan.fScanEnable)
2425 {
2426 status = sme_AcquireGlobalLock( &pMac->sme );
2427 if ( HAL_STATUS_SUCCESS( status ) )
2428 {
2429 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002430#ifdef FEATURE_WLAN_LFR
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002431 if(csrIsScanAllowed(pMac))
2432 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002433#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002434 status = csrScanRequest( hHal, sessionId, pscanReq,
2435 pScanRequestID, callback, pContext );
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002436#ifdef FEATURE_WLAN_LFR
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002437 }
2438 else
2439 {
Madan Mohan Koyyalamudiab4ab0d2012-10-24 14:26:50 -07002440 smsLog(pMac, LOGE, FL("Scan denied in state %d (sub-state %d)"),
2441 pMac->roam.neighborRoamInfo.neighborRoamState,
2442 pMac->roam.curSubState[sessionId]);
2443 /*HandOff is in progress. So schedule this scan later*/
2444 status = eHAL_STATUS_RESOURCES;
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002445 }
2446#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 }
2448
2449 sme_ReleaseGlobalLock( &pMac->sme );
2450 } //sme_AcquireGlobalLock success
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002451 else
2452 {
2453 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
2454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 } //if(pMac->scan.fScanEnable)
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002456 else
2457 {
2458 smsLog(pMac, LOGE, FL("fScanEnable FALSE"));
2459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 } while( 0 );
2461
2462 return (status);
2463
2464
2465}
2466
2467/* ---------------------------------------------------------------------------
2468 \fn sme_ScanGetResult
2469 \brief a wrapper function to request scan results from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002470 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002471 \param pFilter - If pFilter is NULL, all cached results are returned
2472 \param phResult - an object for the result.
2473 \return eHalStatus
2474 ---------------------------------------------------------------------------*/
2475eHalStatus sme_ScanGetResult(tHalHandle hHal, tANI_U8 sessionId, tCsrScanResultFilter *pFilter,
2476 tScanResultHandle *phResult)
2477{
2478 eHalStatus status = eHAL_STATUS_FAILURE;
2479 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2480
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07002481 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
2482 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 smsLog(pMac, LOG2, FL("enter"));
2484 status = sme_AcquireGlobalLock( &pMac->sme );
2485 if ( HAL_STATUS_SUCCESS( status ) )
2486 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07002487 status = csrScanGetResult( hHal, pFilter, phResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002488 sme_ReleaseGlobalLock( &pMac->sme );
2489 }
2490 smsLog(pMac, LOG2, FL("exit status %d"), status);
2491
2492 return (status);
2493}
2494
2495
2496/* ---------------------------------------------------------------------------
2497 \fn sme_ScanFlushResult
2498 \brief a wrapper function to request CSR to clear scan results.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002499 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 \return eHalStatus
2501 ---------------------------------------------------------------------------*/
2502eHalStatus sme_ScanFlushResult(tHalHandle hHal, tANI_U8 sessionId)
2503{
2504 eHalStatus status = eHAL_STATUS_FAILURE;
2505 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2506
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07002507 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
2508 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS, sessionId,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 status = sme_AcquireGlobalLock( &pMac->sme );
2510 if ( HAL_STATUS_SUCCESS( status ) )
2511 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07002512 status = csrScanFlushResult( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 sme_ReleaseGlobalLock( &pMac->sme );
2514 }
2515
2516 return (status);
2517}
2518
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002519eHalStatus sme_ScanFlushP2PResult(tHalHandle hHal, tANI_U8 sessionId)
2520{
2521 eHalStatus status = eHAL_STATUS_FAILURE;
2522 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2523
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07002524 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
2525 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS, sessionId,0 ));
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002526 status = sme_AcquireGlobalLock( &pMac->sme );
2527 if ( HAL_STATUS_SUCCESS( status ) )
2528 {
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302529 status = csrScanFlushSelectiveResult( hHal, VOS_TRUE );
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002530 sme_ReleaseGlobalLock( &pMac->sme );
2531 }
2532
2533 return (status);
2534}
Jeff Johnson295189b2012-06-20 16:38:30 -07002535
2536/* ---------------------------------------------------------------------------
2537 \fn sme_ScanResultGetFirst
2538 \brief a wrapper function to request CSR to returns the first element of
2539 scan result.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002540 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 \param hScanResult - returned from csrScanGetResult
2542 \return tCsrScanResultInfo * - NULL if no result
2543 ---------------------------------------------------------------------------*/
2544tCsrScanResultInfo *sme_ScanResultGetFirst(tHalHandle hHal,
2545 tScanResultHandle hScanResult)
2546{
2547 eHalStatus status = eHAL_STATUS_FAILURE;
2548 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2549 tCsrScanResultInfo *pRet = NULL;
2550
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07002551 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
2552 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST, NO_SESSION,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 status = sme_AcquireGlobalLock( &pMac->sme );
2554 if ( HAL_STATUS_SUCCESS( status ) )
2555 {
2556 pRet = csrScanResultGetFirst( pMac, hScanResult );
2557 sme_ReleaseGlobalLock( &pMac->sme );
2558 }
2559
2560 return (pRet);
2561}
2562
2563
2564/* ---------------------------------------------------------------------------
2565 \fn sme_ScanResultGetNext
2566 \brief a wrapper function to request CSR to returns the next element of
2567 scan result. It can be called without calling csrScanResultGetFirst
2568 first
Srinivas Girigowdade697412013-02-14 16:31:48 -08002569 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 \param hScanResult - returned from csrScanGetResult
2571 \return Null if no result or reach the end
2572 ---------------------------------------------------------------------------*/
2573tCsrScanResultInfo *sme_ScanResultGetNext(tHalHandle hHal,
2574 tScanResultHandle hScanResult)
2575{
2576 eHalStatus status = eHAL_STATUS_FAILURE;
2577 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2578 tCsrScanResultInfo *pRet = NULL;
2579
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07002580 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME ,
2581 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETNEXT, NO_SESSION,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 status = sme_AcquireGlobalLock( &pMac->sme );
2583 if ( HAL_STATUS_SUCCESS( status ) )
2584 {
2585 pRet = csrScanResultGetNext( pMac, hScanResult );
2586 sme_ReleaseGlobalLock( &pMac->sme );
2587 }
2588
2589 return (pRet);
2590}
2591
2592
2593/* ---------------------------------------------------------------------------
2594 \fn sme_ScanSetBGScanparams
2595 \brief a wrapper function to request CSR to set BG scan params in PE
Srinivas Girigowdade697412013-02-14 16:31:48 -08002596 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 \param pScanReq - BG scan request structure
2598 \return eHalStatus
2599 ---------------------------------------------------------------------------*/
2600eHalStatus sme_ScanSetBGScanparams(tHalHandle hHal, tANI_U8 sessionId, tCsrBGScanRequest *pScanReq)
2601{
2602 eHalStatus status = eHAL_STATUS_FAILURE;
2603 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2604
2605 if( NULL != pScanReq )
2606 {
2607 status = sme_AcquireGlobalLock( &pMac->sme );
2608 if ( HAL_STATUS_SUCCESS( status ) )
2609 {
2610 status = csrScanSetBGScanparams( hHal, pScanReq );
2611 sme_ReleaseGlobalLock( &pMac->sme );
2612 }
2613 }
2614
2615 return (status);
2616}
2617
2618
2619/* ---------------------------------------------------------------------------
2620 \fn sme_ScanResultPurge
2621 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
2622 in the list and free memory for each item
Srinivas Girigowdade697412013-02-14 16:31:48 -08002623 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 \param hScanResult - returned from csrScanGetResult. hScanResult is
2625 considered gone by
2626 calling this function and even before this function reutrns.
2627 \return eHalStatus
2628 ---------------------------------------------------------------------------*/
2629eHalStatus sme_ScanResultPurge(tHalHandle hHal, tScanResultHandle hScanResult)
2630{
2631 eHalStatus status = eHAL_STATUS_FAILURE;
2632 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2633
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07002634 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
2635 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE, NO_SESSION,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 status = sme_AcquireGlobalLock( &pMac->sme );
2637 if ( HAL_STATUS_SUCCESS( status ) )
2638 {
2639 status = csrScanResultPurge( hHal, hScanResult );
2640 sme_ReleaseGlobalLock( &pMac->sme );
2641 }
2642
2643 return (status);
2644}
2645
2646/* ---------------------------------------------------------------------------
2647 \fn sme_ScanGetPMKIDCandidateList
2648 \brief a wrapper function to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08002649 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 \param pPmkidList - caller allocated buffer point to an array of
2651 tPmkidCandidateInfo
2652 \param pNumItems - pointer to a variable that has the number of
2653 tPmkidCandidateInfo allocated when retruning, this is
2654 either the number needed or number of items put into
2655 pPmkidList
2656 \return eHalStatus - when fail, it usually means the buffer allocated is not
2657 big enough and pNumItems
2658 has the number of tPmkidCandidateInfo.
2659 \Note: pNumItems is a number of tPmkidCandidateInfo,
2660 not sizeof(tPmkidCandidateInfo) * something
2661 ---------------------------------------------------------------------------*/
2662eHalStatus sme_ScanGetPMKIDCandidateList(tHalHandle hHal, tANI_U8 sessionId,
2663 tPmkidCandidateInfo *pPmkidList,
2664 tANI_U32 *pNumItems )
2665{
2666 eHalStatus status = eHAL_STATUS_FAILURE;
2667 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2668
2669 status = sme_AcquireGlobalLock( &pMac->sme );
2670 if ( HAL_STATUS_SUCCESS( status ) )
2671 {
2672 status = csrScanGetPMKIDCandidateList( pMac, sessionId, pPmkidList, pNumItems );
2673 sme_ReleaseGlobalLock( &pMac->sme );
2674 }
2675
2676 return (status);
2677}
2678
2679/*----------------------------------------------------------------------------
2680 \fn sme_RoamRegisterLinkQualityIndCallback
2681
2682 \brief
2683 a wrapper function to allow HDD to register a callback handler with CSR for
2684 link quality indications.
2685
2686 Only one callback may be registered at any time.
2687 In order to deregister the callback, a NULL cback may be provided.
2688
2689 Registration happens in the task context of the caller.
2690
2691 \param callback - Call back being registered
2692 \param pContext - user data
2693
2694 DEPENDENCIES: After CSR open
2695
2696 \return eHalStatus
2697-----------------------------------------------------------------------------*/
2698eHalStatus sme_RoamRegisterLinkQualityIndCallback(tHalHandle hHal, tANI_U8 sessionId,
2699 csrRoamLinkQualityIndCallback callback,
2700 void *pContext)
2701{
2702 return(csrRoamRegisterLinkQualityIndCallback((tpAniSirGlobal)hHal, callback, pContext));
2703}
2704
2705/* ---------------------------------------------------------------------------
2706 \fn sme_RoamRegisterCallback
2707 \brief a wrapper function to allow HDD to register a callback with CSR.
2708 Unlike scan, roam has one callback for all the roam requests
2709 \param callback - a callback function that roam calls upon when state changes
2710 \param pContext - a pointer passed in for the callback
2711 \return eHalStatus
2712 ---------------------------------------------------------------------------*/
2713eHalStatus sme_RoamRegisterCallback(tHalHandle hHal,
2714 csrRoamCompleteCallback callback,
2715 void *pContext)
2716{
2717 return(csrRoamRegisterCallback((tpAniSirGlobal)hHal, callback, pContext));
2718}
2719
2720eCsrPhyMode sme_GetPhyMode(tHalHandle hHal)
2721{
2722 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2723 return pMac->roam.configParam.phyMode;
2724}
2725
2726/* ---------------------------------------------------------------------------
2727 \fn sme_RoamConnect
2728 \brief a wrapper function to request CSR to inititiate an association
Srinivas Girigowdade697412013-02-14 16:31:48 -08002729 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 \param sessionId - the sessionId returned by sme_OpenSession.
2731 \param pProfile - description of the network to which to connect
2732 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
2733 from csrScanGetResult
2734 \param pRoamId - to get back the request ID
2735 \return eHalStatus
2736 ---------------------------------------------------------------------------*/
2737eHalStatus sme_RoamConnect(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2738 tANI_U32 *pRoamId)
2739{
2740 eHalStatus status = eHAL_STATUS_FAILURE;
2741 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2742
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07002743 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
2744 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 smsLog(pMac, LOG2, FL("enter"));
2746 status = sme_AcquireGlobalLock( &pMac->sme );
2747 if ( HAL_STATUS_SUCCESS( status ) )
2748 {
2749 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2750 {
2751 status = csrRoamConnect( pMac, sessionId, pProfile, NULL, pRoamId );
2752 }
2753 else
2754 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002755 smsLog(pMac, LOGE, FL("invalid sessionID %d"), sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 status = eHAL_STATUS_INVALID_PARAMETER;
2757 }
2758 sme_ReleaseGlobalLock( &pMac->sme );
2759 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002760 else
2761 {
2762 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
2763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002764
2765 return (status);
2766}
2767
2768/* ---------------------------------------------------------------------------
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05302769
2770 \fn sme_SetPhyMode
2771
2772 \brief Changes the PhyMode.
2773
2774 \param hHal - The handle returned by macOpen.
2775
2776 \param phyMode new phyMode which is to set
2777
2778 \return eHalStatus SUCCESS.
2779
2780 -------------------------------------------------------------------------------*/
2781eHalStatus sme_SetPhyMode(tHalHandle hHal, eCsrPhyMode phyMode)
2782{
2783 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2784
2785 if (NULL == pMac)
2786 {
2787 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2788 "%s: invalid context", __func__);
2789 return eHAL_STATUS_FAILURE;
2790 }
2791
2792 pMac->roam.configParam.phyMode = phyMode;
2793 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL,
2794 pMac->roam.configParam.phyMode,
2795 pMac->roam.configParam.ProprietaryRatesEnabled);
2796
2797 return eHAL_STATUS_SUCCESS;
2798}
2799
2800/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 \fn sme_RoamReassoc
2802 \brief a wrapper function to request CSR to inititiate a re-association
2803 \param pProfile - can be NULL to join the currently connected AP. In that
2804 case modProfileFields should carry the modified field(s) which could trigger
2805 reassoc
2806 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
2807 that might need modification dynamically once STA is up & running and this
2808 could trigger a reassoc
2809 \param pRoamId - to get back the request ID
2810 \return eHalStatus
2811 -------------------------------------------------------------------------------*/
2812eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2813 tCsrRoamModifyProfileFields modProfileFields,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002814 tANI_U32 *pRoamId, v_BOOL_t fForce)
Jeff Johnson295189b2012-06-20 16:38:30 -07002815{
2816 eHalStatus status = eHAL_STATUS_FAILURE;
2817 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2818
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07002819 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
2820 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 smsLog(pMac, LOG2, FL("enter"));
2822 status = sme_AcquireGlobalLock( &pMac->sme );
2823 if ( HAL_STATUS_SUCCESS( status ) )
2824 {
2825 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2826 {
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07002827 if((NULL == pProfile) && (fForce == 1))
2828 {
2829 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2830 /* to force the AP initiate fresh 802.1x authentication need to clear
2831 * the PMKID cache for that set the following boolean. this is needed
2832 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
2833 pSession->fIgnorePMKIDCache = TRUE;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002834 status = csrReassoc( pMac, sessionId, &modProfileFields, pRoamId , fForce);
2835 }
2836 else
2837 {
2838 status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
2839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 }
2841 else
2842 {
2843 status = eHAL_STATUS_INVALID_PARAMETER;
2844 }
2845 sme_ReleaseGlobalLock( &pMac->sme );
2846 }
2847
2848 return (status);
2849}
2850
2851/* ---------------------------------------------------------------------------
2852 \fn sme_RoamConnectToLastProfile
2853 \brief a wrapper function to request CSR to disconnect and reconnect with
2854 the same profile
Srinivas Girigowdade697412013-02-14 16:31:48 -08002855 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 \return eHalStatus. It returns fail if currently connected
2857 ---------------------------------------------------------------------------*/
2858eHalStatus sme_RoamConnectToLastProfile(tHalHandle hHal, tANI_U8 sessionId)
2859{
2860 eHalStatus status = eHAL_STATUS_FAILURE;
2861 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2862
2863 status = sme_AcquireGlobalLock( &pMac->sme );
2864 if ( HAL_STATUS_SUCCESS( status ) )
2865 {
2866 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2867 {
2868 status = csrRoamConnectToLastProfile( pMac, sessionId );
2869 }
2870 else
2871 {
2872 status = eHAL_STATUS_INVALID_PARAMETER;
2873 }
2874 sme_ReleaseGlobalLock( &pMac->sme );
2875 }
2876
2877 return (status);
2878}
2879
2880/* ---------------------------------------------------------------------------
2881 \fn sme_RoamDisconnect
2882 \brief a wrapper function to request CSR to disconnect from a network
Srinivas Girigowdade697412013-02-14 16:31:48 -08002883 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 \param reason -- To indicate the reason for disconnecting. Currently, only
2885 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
2886 \return eHalStatus
2887 ---------------------------------------------------------------------------*/
2888eHalStatus sme_RoamDisconnect(tHalHandle hHal, tANI_U8 sessionId, eCsrRoamDisconnectReason reason)
2889{
2890 eHalStatus status = eHAL_STATUS_FAILURE;
2891 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2892
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07002893 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
2894 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId, reason));
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 smsLog(pMac, LOG2, FL("enter"));
2896 status = sme_AcquireGlobalLock( &pMac->sme );
2897 if ( HAL_STATUS_SUCCESS( status ) )
2898 {
2899 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2900 {
2901 status = csrRoamDisconnect( pMac, sessionId, reason );
2902 }
2903 else
2904 {
2905 status = eHAL_STATUS_INVALID_PARAMETER;
2906 }
2907 sme_ReleaseGlobalLock( &pMac->sme );
2908 }
2909
2910 return (status);
2911}
2912
Jeff Johnson295189b2012-06-20 16:38:30 -07002913/* ---------------------------------------------------------------------------
2914 \fn sme_RoamStopBss
2915 \brief To stop BSS for Soft AP. This is an asynchronous API.
2916 \param hHal - Global structure
2917 \param sessionId - sessionId of SoftAP
2918 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2919 -------------------------------------------------------------------------------*/
2920eHalStatus sme_RoamStopBss(tHalHandle hHal, tANI_U8 sessionId)
2921{
2922 eHalStatus status = eHAL_STATUS_FAILURE;
2923 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2924
2925 smsLog(pMac, LOG2, FL("enter"));
2926 status = sme_AcquireGlobalLock( &pMac->sme );
2927 if ( HAL_STATUS_SUCCESS( status ) )
2928 {
2929 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2930 {
Gopichand Nakkalaf44bdc52013-02-16 00:54:45 +05302931 status = csrRoamIssueStopBssCmd( pMac, sessionId, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 }
2933 else
2934 {
2935 status = eHAL_STATUS_INVALID_PARAMETER;
2936 }
2937 sme_ReleaseGlobalLock( &pMac->sme );
2938 }
2939
2940 return (status);
2941}
2942
2943/* ---------------------------------------------------------------------------
2944 \fn sme_RoamDisconnectSta
2945 \brief To disassociate a station. This is an asynchronous API.
2946 \param hHal - Global structure
2947 \param sessionId - sessionId of SoftAP
2948 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2949 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2950 -------------------------------------------------------------------------------*/
2951eHalStatus sme_RoamDisconnectSta(tHalHandle hHal, tANI_U8 sessionId,
2952 tANI_U8 *pPeerMacAddr)
2953{
2954 eHalStatus status = eHAL_STATUS_FAILURE;
2955 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2956
2957 if ( NULL == pMac )
2958 {
2959 VOS_ASSERT(0);
2960 return status;
2961 }
2962
2963 status = sme_AcquireGlobalLock( &pMac->sme );
2964 if ( HAL_STATUS_SUCCESS( status ) )
2965 {
2966 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2967 {
2968 status = csrRoamIssueDisassociateStaCmd( pMac, sessionId, pPeerMacAddr,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302969 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 }
2971 else
2972 {
2973 status = eHAL_STATUS_INVALID_PARAMETER;
2974 }
2975 sme_ReleaseGlobalLock( &pMac->sme );
2976 }
2977
2978 return (status);
2979}
2980
2981/* ---------------------------------------------------------------------------
2982 \fn sme_RoamDeauthSta
2983 \brief To disassociate a station. This is an asynchronous API.
2984 \param hHal - Global structure
2985 \param sessionId - sessionId of SoftAP
2986 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2987 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2988 -------------------------------------------------------------------------------*/
2989eHalStatus sme_RoamDeauthSta(tHalHandle hHal, tANI_U8 sessionId,
2990 tANI_U8 *pPeerMacAddr)
2991{
2992 eHalStatus status = eHAL_STATUS_FAILURE;
2993 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2994
2995 if ( NULL == pMac )
2996 {
2997 VOS_ASSERT(0);
2998 return status;
2999 }
3000
3001 status = sme_AcquireGlobalLock( &pMac->sme );
3002 if ( HAL_STATUS_SUCCESS( status ) )
3003 {
3004 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3005 {
3006 status = csrRoamIssueDeauthStaCmd( pMac, sessionId, pPeerMacAddr,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303007 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 }
3009 else
3010 {
3011 status = eHAL_STATUS_INVALID_PARAMETER;
3012 }
3013 sme_ReleaseGlobalLock( &pMac->sme );
3014 }
3015
3016 return (status);
3017}
3018
3019/* ---------------------------------------------------------------------------
3020 \fn sme_RoamTKIPCounterMeasures
3021 \brief To start or stop TKIP counter measures. This is an asynchronous API.
3022 \param sessionId - sessionId of SoftAP
3023 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
3024 \return eHalStatus
3025 -------------------------------------------------------------------------------*/
3026eHalStatus sme_RoamTKIPCounterMeasures(tHalHandle hHal, tANI_U8 sessionId,
3027 tANI_BOOLEAN bEnable)
3028{
3029 eHalStatus status = eHAL_STATUS_FAILURE;
3030 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3031
3032 if ( NULL == pMac )
3033 {
3034 VOS_ASSERT(0);
3035 return status;
3036 }
3037
3038 status = sme_AcquireGlobalLock( &pMac->sme );
3039 if ( HAL_STATUS_SUCCESS( status ) )
3040 {
3041 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3042 {
3043 status = csrRoamIssueTkipCounterMeasures( pMac, sessionId, bEnable);
3044 }
3045 else
3046 {
3047 status = eHAL_STATUS_INVALID_PARAMETER;
3048 }
3049 sme_ReleaseGlobalLock( &pMac->sme );
3050 }
3051
3052 return (status);
3053}
3054
3055/* ---------------------------------------------------------------------------
3056 \fn sme_RoamGetAssociatedStas
3057 \brief To probe the list of associated stations from various modules of CORE stack.
3058 \This is an asynchronous API.
3059 \param sessionId - sessionId of SoftAP
3060 \param modId - Module from whom list of associtated stations is to be probed.
3061 If an invalid module is passed then by default VOS_MODULE_ID_PE will be probed
3062 \param pUsrContext - Opaque HDD context
3063 \param pfnSapEventCallback - Sap event callback in HDD
3064 \param pAssocBuf - Caller allocated memory to be filled with associatd stations info
3065 \return eHalStatus
3066 -------------------------------------------------------------------------------*/
3067eHalStatus sme_RoamGetAssociatedStas(tHalHandle hHal, tANI_U8 sessionId,
3068 VOS_MODULE_ID modId, void *pUsrContext,
3069 void *pfnSapEventCallback, tANI_U8 *pAssocStasBuf)
3070{
3071 eHalStatus status = eHAL_STATUS_FAILURE;
3072 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3073
3074 if ( NULL == pMac )
3075 {
3076 VOS_ASSERT(0);
3077 return status;
3078 }
3079
3080 status = sme_AcquireGlobalLock( &pMac->sme );
3081 if ( HAL_STATUS_SUCCESS( status ) )
3082 {
3083 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3084 {
3085 status = csrRoamGetAssociatedStas( pMac, sessionId, modId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
3086 }
3087 else
3088 {
3089 status = eHAL_STATUS_INVALID_PARAMETER;
3090 }
3091 sme_ReleaseGlobalLock( &pMac->sme );
3092 }
3093
3094 return (status);
3095}
3096
3097/* ---------------------------------------------------------------------------
3098 \fn sme_RoamGetWpsSessionOverlap
3099 \brief To get the WPS PBC session overlap information.
3100 \This is an asynchronous API.
3101 \param sessionId - sessionId of SoftAP
3102 \param pUsrContext - Opaque HDD context
3103 \param pfnSapEventCallback - Sap event callback in HDD
3104 \pRemoveMac - pointer to Mac address which needs to be removed from session
3105 \return eHalStatus
3106 -------------------------------------------------------------------------------*/
3107eHalStatus sme_RoamGetWpsSessionOverlap(tHalHandle hHal, tANI_U8 sessionId,
3108 void *pUsrContext, void
3109 *pfnSapEventCallback, v_MACADDR_t pRemoveMac)
3110{
3111 eHalStatus status = eHAL_STATUS_FAILURE;
3112 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3113
3114 if ( NULL == pMac )
3115 {
3116 VOS_ASSERT(0);
3117 return status;
3118 }
3119
3120 status = sme_AcquireGlobalLock( &pMac->sme );
3121 if ( HAL_STATUS_SUCCESS( status ) )
3122 {
3123 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3124 {
3125 status = csrRoamGetWpsSessionOverlap( pMac, sessionId, pUsrContext, pfnSapEventCallback, pRemoveMac);
3126 }
3127 else
3128 {
3129 status = eHAL_STATUS_INVALID_PARAMETER;
3130 }
3131 sme_ReleaseGlobalLock( &pMac->sme );
3132 }
3133
3134 return (status);
3135}
3136
Jeff Johnson295189b2012-06-20 16:38:30 -07003137
3138/* ---------------------------------------------------------------------------
3139 \fn sme_RoamGetConnectState
3140 \brief a wrapper function to request CSR to return the current connect state
3141 of Roaming
Srinivas Girigowdade697412013-02-14 16:31:48 -08003142 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 \return eHalStatus
3144 ---------------------------------------------------------------------------*/
3145eHalStatus sme_RoamGetConnectState(tHalHandle hHal, tANI_U8 sessionId, eCsrConnectState *pState)
3146{
3147 eHalStatus status = eHAL_STATUS_FAILURE;
3148 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3149
3150 status = sme_AcquireGlobalLock( &pMac->sme );
3151 if ( HAL_STATUS_SUCCESS( status ) )
3152 {
3153 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3154 {
3155 status = csrRoamGetConnectState( pMac, sessionId, pState );
3156 }
3157 else
3158 {
3159 status = eHAL_STATUS_INVALID_PARAMETER;
3160 }
3161 sme_ReleaseGlobalLock( &pMac->sme );
3162 }
3163
3164 return (status);
3165}
3166
3167/* ---------------------------------------------------------------------------
3168 \fn sme_RoamGetConnectProfile
3169 \brief a wrapper function to request CSR to return the current connect
3170 profile. Caller must call csrRoamFreeConnectProfile after it is done
3171 and before reuse for another csrRoamGetConnectProfile call.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003172 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 \param pProfile - pointer to a caller allocated structure
3174 tCsrRoamConnectedProfile
3175 \return eHalStatus. Failure if not connected
3176 ---------------------------------------------------------------------------*/
3177eHalStatus sme_RoamGetConnectProfile(tHalHandle hHal, tANI_U8 sessionId,
3178 tCsrRoamConnectedProfile *pProfile)
3179{
3180 eHalStatus status = eHAL_STATUS_FAILURE;
3181 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3182
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003183 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3184 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 status = sme_AcquireGlobalLock( &pMac->sme );
3186 if ( HAL_STATUS_SUCCESS( status ) )
3187 {
3188 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3189 {
3190 status = csrRoamGetConnectProfile( pMac, sessionId, pProfile );
3191 }
3192 else
3193 {
3194 status = eHAL_STATUS_INVALID_PARAMETER;
3195 }
3196 sme_ReleaseGlobalLock( &pMac->sme );
3197 }
3198
3199 return (status);
3200}
3201
3202/* ---------------------------------------------------------------------------
3203 \fn sme_RoamFreeConnectProfile
3204 \brief a wrapper function to request CSR to free and reinitialize the
3205 profile returned previously by csrRoamGetConnectProfile.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003206 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 \param pProfile - pointer to a caller allocated structure
3208 tCsrRoamConnectedProfile
3209 \return eHalStatus.
3210 ---------------------------------------------------------------------------*/
3211eHalStatus sme_RoamFreeConnectProfile(tHalHandle hHal,
3212 tCsrRoamConnectedProfile *pProfile)
3213{
3214 eHalStatus status = eHAL_STATUS_FAILURE;
3215 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3216
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003217 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3218 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 status = sme_AcquireGlobalLock( &pMac->sme );
3220 if ( HAL_STATUS_SUCCESS( status ) )
3221 {
3222 status = csrRoamFreeConnectProfile( pMac, pProfile );
3223 sme_ReleaseGlobalLock( &pMac->sme );
3224 }
3225
3226 return (status);
3227}
3228
3229/* ---------------------------------------------------------------------------
3230 \fn sme_RoamSetPMKIDCache
3231 \brief a wrapper function to request CSR to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08003232 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 \param pPMKIDCache - caller allocated buffer point to an array of
3234 tPmkidCacheInfo
3235 \param numItems - a variable that has the number of tPmkidCacheInfo
3236 allocated when retruning, this is either the number needed
3237 or number of items put into pPMKIDCache
3238 \return eHalStatus - when fail, it usually means the buffer allocated is not
3239 big enough and pNumItems has the number of
3240 tPmkidCacheInfo.
3241 \Note: pNumItems is a number of tPmkidCacheInfo,
3242 not sizeof(tPmkidCacheInfo) * something
3243 ---------------------------------------------------------------------------*/
3244eHalStatus sme_RoamSetPMKIDCache( tHalHandle hHal, tANI_U8 sessionId, tPmkidCacheInfo *pPMKIDCache,
3245 tANI_U32 numItems )
3246{
3247 eHalStatus status = eHAL_STATUS_FAILURE;
3248 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3249
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003250 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3251 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId, numItems));
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 status = sme_AcquireGlobalLock( &pMac->sme );
3253 if ( HAL_STATUS_SUCCESS( status ) )
3254 {
3255 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3256 {
3257 status = csrRoamSetPMKIDCache( pMac, sessionId, pPMKIDCache, numItems );
3258 }
3259 else
3260 {
3261 status = eHAL_STATUS_INVALID_PARAMETER;
3262 }
3263 sme_ReleaseGlobalLock( &pMac->sme );
3264 }
3265
3266 return (status);
3267}
3268
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -07003269eHalStatus sme_RoamDelPMKIDfromCache( tHalHandle hHal, tANI_U8 sessionId, tANI_U8 *pBSSId )
3270{
3271 eHalStatus status = eHAL_STATUS_FAILURE;
3272 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3273 status = sme_AcquireGlobalLock( &pMac->sme );
3274 if ( HAL_STATUS_SUCCESS( status ) )
3275 {
3276 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3277 {
3278 status = csrRoamDelPMKIDfromCache( pMac, sessionId, pBSSId );
3279 }
3280 else
3281 {
3282 status = eHAL_STATUS_INVALID_PARAMETER;
3283 }
3284 sme_ReleaseGlobalLock( &pMac->sme );
3285 }
3286 return (status);
3287}
Jeff Johnson295189b2012-06-20 16:38:30 -07003288/* ---------------------------------------------------------------------------
3289 \fn sme_RoamGetSecurityReqIE
3290 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
3291 passes to PE to JOIN request or START_BSS request
Srinivas Girigowdade697412013-02-14 16:31:48 -08003292 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 \param pLen - caller allocated memory that has the length of pBuf as input.
3294 Upon returned, *pLen has the needed or IE length in pBuf.
3295 \param pBuf - Caller allocated memory that contain the IE field, if any,
3296 upon return
3297 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
3298 \return eHalStatus - when fail, it usually means the buffer allocated is not
3299 big enough
3300 ---------------------------------------------------------------------------*/
3301eHalStatus sme_RoamGetSecurityReqIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
3302 tANI_U8 *pBuf, eCsrSecurityType secType)
3303{
3304 eHalStatus status = eHAL_STATUS_FAILURE;
3305 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3306
3307 status = sme_AcquireGlobalLock( &pMac->sme );
3308 if ( HAL_STATUS_SUCCESS( status ) )
3309 {
3310 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3311 {
3312 status = csrRoamGetWpaRsnReqIE( hHal, sessionId, pLen, pBuf );
3313 }
3314 else
3315 {
3316 status = eHAL_STATUS_INVALID_PARAMETER;
3317 }
3318 sme_ReleaseGlobalLock( &pMac->sme );
3319 }
3320
3321 return (status);
3322}
3323
3324/* ---------------------------------------------------------------------------
3325 \fn sme_RoamGetSecurityRspIE
3326 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE from
3327 the beacon or probe rsp if connected
Srinivas Girigowdade697412013-02-14 16:31:48 -08003328 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 \param pLen - caller allocated memory that has the length of pBuf as input.
3330 Upon returned, *pLen has the needed or IE length in pBuf.
3331 \param pBuf - Caller allocated memory that contain the IE field, if any,
3332 upon return
3333 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
3334 \return eHalStatus - when fail, it usually means the buffer allocated is not
3335 big enough
3336 ---------------------------------------------------------------------------*/
3337eHalStatus sme_RoamGetSecurityRspIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
3338 tANI_U8 *pBuf, eCsrSecurityType secType)
3339{
3340 eHalStatus status = eHAL_STATUS_FAILURE;
3341 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3342
3343 status = sme_AcquireGlobalLock( &pMac->sme );
3344 if ( HAL_STATUS_SUCCESS( status ) )
3345 {
3346 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3347 {
3348 status = csrRoamGetWpaRsnRspIE( pMac, sessionId, pLen, pBuf );
3349 }
3350 else
3351 {
3352 status = eHAL_STATUS_INVALID_PARAMETER;
3353 }
3354 sme_ReleaseGlobalLock( &pMac->sme );
3355 }
3356
3357 return (status);
3358
3359}
3360
3361
3362/* ---------------------------------------------------------------------------
3363 \fn sme_RoamGetNumPMKIDCache
3364 \brief a wrapper function to request CSR to return number of PMKID cache
3365 entries
Srinivas Girigowdade697412013-02-14 16:31:48 -08003366 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 \return tANI_U32 - the number of PMKID cache entries
3368 ---------------------------------------------------------------------------*/
3369tANI_U32 sme_RoamGetNumPMKIDCache(tHalHandle hHal, tANI_U8 sessionId)
3370{
3371 eHalStatus status = eHAL_STATUS_FAILURE;
3372 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3373 tANI_U32 numPmkidCache = 0;
3374
3375 status = sme_AcquireGlobalLock( &pMac->sme );
3376 if ( HAL_STATUS_SUCCESS( status ) )
3377 {
3378 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3379 {
3380 numPmkidCache = csrRoamGetNumPMKIDCache( pMac, sessionId );
3381 status = eHAL_STATUS_SUCCESS;
3382 }
3383 else
3384 {
3385 status = eHAL_STATUS_INVALID_PARAMETER;
3386 }
3387 sme_ReleaseGlobalLock( &pMac->sme );
3388 }
3389
3390 return (numPmkidCache);
3391}
3392
3393/* ---------------------------------------------------------------------------
3394 \fn sme_RoamGetPMKIDCache
3395 \brief a wrapper function to request CSR to return PMKID cache from CSR
Srinivas Girigowdade697412013-02-14 16:31:48 -08003396 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 \param pNum - caller allocated memory that has the space of the number of
3398 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3399 needed or actually number in tPmkidCacheInfo.
3400 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
3401 any, upon return
3402 \return eHalStatus - when fail, it usually means the buffer allocated is not
3403 big enough
3404 ---------------------------------------------------------------------------*/
3405eHalStatus sme_RoamGetPMKIDCache(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pNum,
3406 tPmkidCacheInfo *pPmkidCache)
3407{
3408 eHalStatus status = eHAL_STATUS_FAILURE;
3409 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3410
3411 status = sme_AcquireGlobalLock( &pMac->sme );
3412 if ( HAL_STATUS_SUCCESS( status ) )
3413 {
3414 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3415 {
3416 status = csrRoamGetPMKIDCache( pMac, sessionId, pNum, pPmkidCache );
3417 }
3418 else
3419 {
3420 status = eHAL_STATUS_INVALID_PARAMETER;
3421 }
3422 sme_ReleaseGlobalLock( &pMac->sme );
3423 }
3424
3425 return (status);
3426}
3427
3428
3429/* ---------------------------------------------------------------------------
3430 \fn sme_GetConfigParam
3431 \brief a wrapper function that HDD calls to get the global settings
3432 currently maintained by CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003433 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 \param pParam - caller allocated memory
3435 \return eHalStatus
3436 ---------------------------------------------------------------------------*/
3437eHalStatus sme_GetConfigParam(tHalHandle hHal, tSmeConfigParams *pParam)
3438{
3439 eHalStatus status = eHAL_STATUS_FAILURE;
3440 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3441
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003442 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3443 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 status = sme_AcquireGlobalLock( &pMac->sme );
3445 if ( HAL_STATUS_SUCCESS( status ) )
3446 {
3447 status = csrGetConfigParam(pMac, &pParam->csrConfig);
3448 if (status != eHAL_STATUS_SUCCESS)
3449 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003450 smsLog( pMac, LOGE, "%s csrGetConfigParam failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 sme_ReleaseGlobalLock( &pMac->sme );
3452 return status;
3453 }
3454#if defined WLAN_FEATURE_P2P_INTERNAL
3455 status = p2pGetConfigParam(pMac, &pParam->p2pConfig);
3456 if (status != eHAL_STATUS_SUCCESS)
3457 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003458 smsLog( pMac, LOGE, "%s p2pGetConfigParam failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 sme_ReleaseGlobalLock( &pMac->sme );
3460 return status;
3461 }
3462#endif
3463 sme_ReleaseGlobalLock( &pMac->sme );
3464 }
3465
3466 return (status);
3467}
3468
3469/* ---------------------------------------------------------------------------
3470 \fn sme_CfgSetInt
3471 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003472 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 \param cfgId - Configuration Parameter ID (type) for STA.
3474 \param ccmValue - The information related to Configuration Parameter ID
3475 which needs to be saved in CFG
3476 \param callback - To be registered by CSR with CCM. Once the CFG done with
3477 saving the information in the database, it notifies CCM &
3478 then the callback will be invoked to notify.
3479 \param toBeSaved - To save the request for future reference
3480 \return eHalStatus
3481 ---------------------------------------------------------------------------*/
3482eHalStatus sme_CfgSetInt(tHalHandle hHal, tANI_U32 cfgId, tANI_U32 ccmValue,
3483 tCcmCfgSetCallback callback, eAniBoolean toBeSaved)
3484{
3485 return(ccmCfgSetInt(hHal, cfgId, ccmValue, callback, toBeSaved));
3486}
3487
3488/* ---------------------------------------------------------------------------
3489 \fn sme_CfgSetStr
3490 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003491 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 \param cfgId - Configuration Parameter ID (type) for STA.
3493 \param pStr - Pointer to the byte array which carries the information needs
3494 to be saved in CFG
3495 \param length - Length of the data to be saved
3496 \param callback - To be registered by CSR with CCM. Once the CFG done with
3497 saving the information in the database, it notifies CCM &
3498 then the callback will be invoked to notify.
3499 \param toBeSaved - To save the request for future reference
3500 \return eHalStatus
3501 ---------------------------------------------------------------------------*/
3502eHalStatus sme_CfgSetStr(tHalHandle hHal, tANI_U32 cfgId, tANI_U8 *pStr,
3503 tANI_U32 length, tCcmCfgSetCallback callback,
3504 eAniBoolean toBeSaved)
3505{
3506 return(ccmCfgSetStr(hHal, cfgId, pStr, length, callback, toBeSaved));
3507}
3508
3509/* ---------------------------------------------------------------------------
3510 \fn sme_GetModifyProfileFields
3511 \brief HDD or SME - QOS calls this function to get the current values of
3512 connected profile fields, changing which can cause reassoc.
3513 This function must be called after CFG is downloaded and STA is in connected
3514 state. Also, make sure to call this function to get the current profile
3515 fields before calling the reassoc. So that pModifyProfileFields will have
3516 all the latest values plus the one(s) has been updated as part of reassoc
3517 request.
3518 \param pModifyProfileFields - pointer to the connected profile fields
3519 changing which can cause reassoc
3520
3521 \return eHalStatus
3522 -------------------------------------------------------------------------------*/
3523eHalStatus sme_GetModifyProfileFields(tHalHandle hHal, tANI_U8 sessionId,
3524 tCsrRoamModifyProfileFields * pModifyProfileFields)
3525{
3526 eHalStatus status = eHAL_STATUS_FAILURE;
3527 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3528
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003529 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3530 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 status = sme_AcquireGlobalLock( &pMac->sme );
3532 if ( HAL_STATUS_SUCCESS( status ) )
3533 {
3534 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3535 {
3536 status = csrGetModifyProfileFields(pMac, sessionId, pModifyProfileFields);
3537 }
3538 else
3539 {
3540 status = eHAL_STATUS_INVALID_PARAMETER;
3541 }
3542 sme_ReleaseGlobalLock( &pMac->sme );
3543 }
3544
3545 return (status);
3546}
3547
3548/*--------------------------------------------------------------------------
3549 \fn sme_SetConfigPowerSave
3550 \brief Wrapper fn to change power save configuration in SME (PMC) module.
3551 For BMPS related configuration, this function also updates the CFG
3552 and sends a message to FW to pick up the new values. Note: Calling
3553 this function only updates the configuration and does not enable
3554 the specified power save mode.
3555 \param hHal - The handle returned by macOpen.
3556 \param psMode - Power Saving mode being modified
3557 \param pConfigParams - a pointer to a caller allocated object of type
3558 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
3559 \return eHalStatus
3560 --------------------------------------------------------------------------*/
3561eHalStatus sme_SetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
3562 void *pConfigParams)
3563{
3564 eHalStatus status = eHAL_STATUS_FAILURE;
3565 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3566
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003567 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3568 TRACE_CODE_SME_RX_HDD_SET_CONFIG_PWRSAVE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 if (NULL == pConfigParams ) {
3570 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3571 "nothing to update");
3572 return eHAL_STATUS_FAILURE;
3573 }
3574
3575 status = sme_AcquireGlobalLock( &pMac->sme );
3576 if ( HAL_STATUS_SUCCESS( status ) )
3577 {
3578 status = pmcSetConfigPowerSave(hHal, psMode, pConfigParams);
3579 sme_ReleaseGlobalLock( &pMac->sme );
3580 }
3581
3582 return (status);
3583}
3584
3585/*--------------------------------------------------------------------------
3586 \fn sme_GetConfigPowerSave
3587 \brief Wrapper fn to retrieve power save configuration in SME (PMC) module
3588 \param hHal - The handle returned by macOpen.
3589 \param psMode - Power Saving mode
3590 \param pConfigParams - a pointer to a caller allocated object of type
3591 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
3592 \return eHalStatus
3593 --------------------------------------------------------------------------*/
3594eHalStatus sme_GetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
3595 void *pConfigParams)
3596{
3597 eHalStatus status = eHAL_STATUS_FAILURE;
3598 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3599
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003600 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3601 TRACE_CODE_SME_RX_HDD_GET_CONFIG_PWRSAVE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 if (NULL == pConfigParams ) {
3603 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3604 "nothing to update");
3605 return eHAL_STATUS_FAILURE;
3606 }
3607
3608 status = sme_AcquireGlobalLock( &pMac->sme );
3609 if ( HAL_STATUS_SUCCESS( status ) )
3610 {
3611 status = pmcGetConfigPowerSave(hHal, psMode, pConfigParams);
3612 sme_ReleaseGlobalLock( &pMac->sme );
3613 }
3614
3615 return (status);
3616}
3617
3618/* ---------------------------------------------------------------------------
3619 \fn sme_SignalPowerEvent
3620 \brief Signals to PMC that a power event has occurred. Used for putting
3621 the chip into deep sleep mode.
3622 \param hHal - The handle returned by macOpen.
3623 \param event - the event that has occurred
3624 \return eHalStatus
3625 ---------------------------------------------------------------------------*/
3626eHalStatus sme_SignalPowerEvent (tHalHandle hHal, tPmcPowerEvent event)
3627{
3628 eHalStatus status = eHAL_STATUS_FAILURE;
3629 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3630
3631 status = sme_AcquireGlobalLock( &pMac->sme );
3632 if ( HAL_STATUS_SUCCESS( status ) )
3633 {
3634 status = pmcSignalPowerEvent(hHal, event);
3635 sme_ReleaseGlobalLock( &pMac->sme );
3636 }
3637
3638 return (status);
3639}
3640
3641/* ---------------------------------------------------------------------------
3642 \fn sme_EnablePowerSave
3643 \brief Enables one of the power saving modes.
3644 \param hHal - The handle returned by macOpen.
3645 \param psMode - The power saving mode to enable. If BMPS mode is enabled
3646 while the chip is operating in Full Power, PMC will start
3647 a timer that will try to put the chip in BMPS mode after
3648 expiry.
3649 \return eHalStatus
3650 ---------------------------------------------------------------------------*/
3651eHalStatus sme_EnablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3652{
3653 eHalStatus status = eHAL_STATUS_FAILURE;
3654 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3655
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003656 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3657 TRACE_CODE_SME_RX_HDD_ENABLE_PWRSAVE, NO_SESSION, psMode));
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 status = sme_AcquireGlobalLock( &pMac->sme );
3659 if ( HAL_STATUS_SUCCESS( status ) )
3660 {
3661 status = pmcEnablePowerSave(hHal, psMode);
3662 sme_ReleaseGlobalLock( &pMac->sme );
3663 }
3664
3665 return (status);
3666}
3667
3668/* ---------------------------------------------------------------------------
3669 \fn sme_DisablePowerSave
3670 \brief Disables one of the power saving modes.
3671 \param hHal - The handle returned by macOpen.
3672 \param psMode - The power saving mode to disable. Disabling does not imply
3673 that device will be brought out of the current PS mode. This
3674 is purely a configuration API.
3675 \return eHalStatus
3676 ---------------------------------------------------------------------------*/
3677eHalStatus sme_DisablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3678{
3679 eHalStatus status = eHAL_STATUS_FAILURE;
3680 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3681
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003682 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3683 TRACE_CODE_SME_RX_HDD_DISABLE_PWRSAVE, NO_SESSION, psMode));
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 status = sme_AcquireGlobalLock( &pMac->sme );
3685 if ( HAL_STATUS_SUCCESS( status ) )
3686 {
3687 status = pmcDisablePowerSave(hHal, psMode);
3688 sme_ReleaseGlobalLock( &pMac->sme );
3689 }
3690
3691 return (status);
3692 }
3693
3694/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +05303695+ \fn sme_SetHostPowerSave
3696+ \brief Enables BMPS logic to be controlled by User level apps
3697+ \param hHal - The handle returned by macOpen.
3698+ \param psMode - The power saving mode to disable. Disabling does not imply
3699+ that device will be brought out of the current PS mode. This
3700+ is purely a configuration API.
3701+ \return eHalStatus
3702+ ---------------------------------------------------------------------------*/
3703eHalStatus sme_SetHostPowerSave (tHalHandle hHal, v_BOOL_t psMode)
3704{
3705 eHalStatus status = eHAL_STATUS_FAILURE;
3706 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3707
3708 pMac->pmc.isHostPsEn = psMode;
3709
3710 return (status);
3711}
3712
3713/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 \fn sme_StartAutoBmpsTimer
3715 \brief Starts a timer that periodically polls all the registered
3716 module for entry into Bmps mode. This timer is started only if BMPS is
3717 enabled and whenever the device is in full power.
3718 \param hHal - The handle returned by macOpen.
3719 \return eHalStatus
3720 ---------------------------------------------------------------------------*/
3721eHalStatus sme_StartAutoBmpsTimer ( tHalHandle hHal)
3722{
3723 eHalStatus status = eHAL_STATUS_FAILURE;
3724 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3725
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003726 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3727 TRACE_CODE_SME_RX_HDD_START_AUTO_BMPSTIMER, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 status = sme_AcquireGlobalLock( &pMac->sme );
3729 if ( HAL_STATUS_SUCCESS( status ) )
3730 {
3731 status = pmcStartAutoBmpsTimer(hHal);
3732 sme_ReleaseGlobalLock( &pMac->sme );
3733 }
3734
3735 return (status);
3736}
3737/* ---------------------------------------------------------------------------
3738 \fn sme_StopAutoBmpsTimer
3739 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
3740 Stopping the timer does not cause a device state change. Only the timer
3741 is stopped. If "Full Power" is desired, use the sme_RequestFullPower API
3742 \param hHal - The handle returned by macOpen.
3743 \return eHalStatus
3744 ---------------------------------------------------------------------------*/
3745eHalStatus sme_StopAutoBmpsTimer ( tHalHandle hHal)
3746{
3747 eHalStatus status = eHAL_STATUS_FAILURE;
3748 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3749
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003750 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3751 TRACE_CODE_SME_RX_HDD_STOP_AUTO_BMPSTIMER, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 status = sme_AcquireGlobalLock( &pMac->sme );
3753 if ( HAL_STATUS_SUCCESS( status ) )
3754 {
3755 status = pmcStopAutoBmpsTimer(hHal);
3756 sme_ReleaseGlobalLock( &pMac->sme );
3757 }
3758
3759 return (status);
3760}
3761/* ---------------------------------------------------------------------------
3762 \fn sme_QueryPowerState
3763 \brief Returns the current power state of the device.
3764 \param hHal - The handle returned by macOpen.
3765 \param pPowerState - pointer to location to return power state (LOW or HIGH)
3766 \param pSwWlanSwitchState - ptr to location to return SW WLAN Switch state
3767 \return eHalStatus
3768 ---------------------------------------------------------------------------*/
3769eHalStatus sme_QueryPowerState (
3770 tHalHandle hHal,
3771 tPmcPowerState *pPowerState,
3772 tPmcSwitchState *pSwWlanSwitchState)
3773{
3774 eHalStatus status = eHAL_STATUS_FAILURE;
3775 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3776
3777 status = sme_AcquireGlobalLock( &pMac->sme );
3778 if ( HAL_STATUS_SUCCESS( status ) )
3779 {
3780 status = pmcQueryPowerState (hHal, pPowerState, NULL, pSwWlanSwitchState);
3781 sme_ReleaseGlobalLock( &pMac->sme );
3782 }
3783
3784 return (status);
3785}
3786
3787/* ---------------------------------------------------------------------------
3788 \fn sme_IsPowerSaveEnabled
3789 \brief Checks if the device is able to enter a particular power save mode
3790 This does not imply that the device is in a particular PS mode
3791 \param hHal - The handle returned by macOpen.
3792 \param psMode - the power saving mode
3793 \return eHalStatus
3794 ---------------------------------------------------------------------------*/
3795tANI_BOOLEAN sme_IsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
3796{
3797 eHalStatus status = eHAL_STATUS_FAILURE;
3798 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3799 tANI_BOOLEAN result = false;
3800
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003801 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3802 TRACE_CODE_SME_RX_HDD_IS_PWRSAVE_ENABLED, NO_SESSION, psMode));
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 status = sme_AcquireGlobalLock( &pMac->sme );
3804 if ( HAL_STATUS_SUCCESS( status ) )
3805 {
3806 result = pmcIsPowerSaveEnabled(hHal, psMode);
3807 sme_ReleaseGlobalLock( &pMac->sme );
3808 return result;
3809 }
3810
3811 return false;
3812}
3813
3814/* ---------------------------------------------------------------------------
3815 \fn sme_RequestFullPower
3816 \brief Request that the device be brought to full power state. When the
3817 device enters Full Power PMC will start a BMPS timer if BMPS PS mode
3818 is enabled. On timer expiry PMC will attempt to put the device in
3819 BMPS mode if following holds true:
3820 - BMPS mode is enabled
3821 - Polling of all modules through the Power Save Check routine passes
3822 - STA is associated to an access point
3823 \param hHal - The handle returned by macOpen.
3824 \param - callbackRoutine Callback routine invoked in case of success/failure
3825 \return eHalStatus - status
3826 eHAL_STATUS_SUCCESS - device brought to full power state
3827 eHAL_STATUS_FAILURE - device cannot be brought to full power state
3828 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
3829 ---------------------------------------------------------------------------*/
3830eHalStatus sme_RequestFullPower (
3831 tHalHandle hHal,
3832 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3833 void *callbackContext,
3834 tRequestFullPowerReason fullPowerReason)
3835{
3836 eHalStatus status = eHAL_STATUS_FAILURE;
3837 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3838
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003839 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3840 TRACE_CODE_SME_RX_HDD_REQUEST_FULLPOWER, NO_SESSION, fullPowerReason));
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 status = sme_AcquireGlobalLock( &pMac->sme );
3842 if ( HAL_STATUS_SUCCESS( status ) )
3843 {
3844 status = pmcRequestFullPower(hHal, callbackRoutine, callbackContext, fullPowerReason);
3845 sme_ReleaseGlobalLock( &pMac->sme );
3846 }
3847
3848 return (status);
3849}
3850
3851/* ---------------------------------------------------------------------------
3852 \fn sme_RequestBmps
3853 \brief Request that the device be put in BMPS state. Request will be
3854 accepted only if BMPS mode is enabled and power save check routine
3855 passes.
3856 \param hHal - The handle returned by macOpen.
3857 \param - callbackRoutine Callback routine invoked in case of success/failure
3858 \return eHalStatus
3859 eHAL_STATUS_SUCCESS - device is in BMPS state
3860 eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
3861 eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state
3862 ---------------------------------------------------------------------------*/
3863eHalStatus sme_RequestBmps (
3864 tHalHandle hHal,
3865 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3866 void *callbackContext)
3867{
3868 eHalStatus status = eHAL_STATUS_FAILURE;
3869 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3870
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003871 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3872 TRACE_CODE_SME_RX_HDD_REQUEST_BMPS, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 status = sme_AcquireGlobalLock( &pMac->sme );
3874 if ( HAL_STATUS_SUCCESS( status ) )
3875 {
3876 status = pmcRequestBmps(hHal, callbackRoutine, callbackContext);
3877 sme_ReleaseGlobalLock( &pMac->sme );
3878 }
3879
3880 return (status);
3881}
3882
3883
3884/* ---------------------------------------------------------------------------
3885 \fn sme_SetDHCPTillPowerActiveFlag
3886 \brief Sets/Clears DHCP related flag in PMC to disable/enable auto BMPS
3887 entry by PMC
3888 \param hHal - The handle returned by macOpen.
3889 ---------------------------------------------------------------------------*/
3890void sme_SetDHCPTillPowerActiveFlag(tHalHandle hHal, tANI_U8 flag)
3891{
3892 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3893
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003894 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3895 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION, flag));
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 // Set/Clear the DHCP flag which will disable/enable auto BMPS entery by PMC
3897 pMac->pmc.remainInPowerActiveTillDHCP = flag;
3898}
3899
3900
3901/* ---------------------------------------------------------------------------
3902 \fn sme_StartUapsd
3903 \brief Request that the device be put in UAPSD state. If the device is in
3904 Full Power it will be put in BMPS mode first and then into UAPSD
3905 mode.
3906 \param hHal - The handle returned by macOpen.
3907 \param - callbackRoutine Callback routine invoked in case of success/failure
3908 eHAL_STATUS_SUCCESS - device is in UAPSD state
3909 eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
3910 eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
3911 eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
3912 \return eHalStatus
3913 ---------------------------------------------------------------------------*/
3914eHalStatus sme_StartUapsd (
3915 tHalHandle hHal,
3916 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3917 void *callbackContext)
3918{
3919 eHalStatus status = eHAL_STATUS_FAILURE;
3920 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3921
3922 status = sme_AcquireGlobalLock( &pMac->sme );
3923 if ( HAL_STATUS_SUCCESS( status ) )
3924 {
3925 status = pmcStartUapsd(hHal, callbackRoutine, callbackContext);
3926 sme_ReleaseGlobalLock( &pMac->sme );
3927 }
3928
3929 return (status);
3930 }
3931
3932/* ---------------------------------------------------------------------------
3933 \fn sme_StopUapsd
3934 \brief Request that the device be put out of UAPSD state. Device will be
3935 put in in BMPS state after stop UAPSD completes.
3936 \param hHal - The handle returned by macOpen.
3937 \return eHalStatus
3938 eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
3939 eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
3940 ---------------------------------------------------------------------------*/
3941eHalStatus sme_StopUapsd (tHalHandle hHal)
3942{
3943 eHalStatus status = eHAL_STATUS_FAILURE;
3944 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3945
3946 status = sme_AcquireGlobalLock( &pMac->sme );
3947 if ( HAL_STATUS_SUCCESS( status ) )
3948 {
3949 status = pmcStopUapsd(hHal);
3950 sme_ReleaseGlobalLock( &pMac->sme );
3951 }
3952
3953 return (status);
3954}
3955
3956/* ---------------------------------------------------------------------------
3957 \fn sme_RequestStandby
3958 \brief Request that the device be put in standby. It is HDD's responsibility
3959 to bring the chip to full power and do a disassoc before calling
3960 this API.
3961 \param hHal - The handle returned by macOpen.
3962 \param - callbackRoutine Callback routine invoked in case of success/failure
3963 \return eHalStatus
3964 eHAL_STATUS_SUCCESS - device is in Standby mode
3965 eHAL_STATUS_FAILURE - device cannot be put in standby mode
3966 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
3967 ---------------------------------------------------------------------------*/
3968eHalStatus sme_RequestStandby (
3969 tHalHandle hHal,
3970 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3971 void *callbackContext)
3972{
3973 eHalStatus status = eHAL_STATUS_FAILURE;
3974 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3975
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07003976 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3977 TRACE_CODE_SME_RX_HDD_REQUEST_STANDBY, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 smsLog( pMac, LOG1, FL("") );
3979 status = sme_AcquireGlobalLock( &pMac->sme );
3980 if ( HAL_STATUS_SUCCESS( status ) )
3981 {
3982 status = pmcRequestStandby(hHal, callbackRoutine, callbackContext);
3983 sme_ReleaseGlobalLock( &pMac->sme );
3984 }
3985
3986 return (status);
3987}
3988
3989/* ---------------------------------------------------------------------------
3990 \fn sme_RegisterPowerSaveCheck
3991 \brief Register a power save check routine that is called whenever
3992 the device is about to enter one of the power save modes.
3993 \param hHal - The handle returned by macOpen.
3994 \param checkRoutine - Power save check routine to be registered
3995 \return eHalStatus
3996 eHAL_STATUS_SUCCESS - successfully registered
3997 eHAL_STATUS_FAILURE - not successfully registered
3998 ---------------------------------------------------------------------------*/
3999eHalStatus sme_RegisterPowerSaveCheck (
4000 tHalHandle hHal,
4001 tANI_BOOLEAN (*checkRoutine) (void *checkContext), void *checkContext)
4002{
4003 eHalStatus status = eHAL_STATUS_FAILURE;
4004 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4005
4006 status = sme_AcquireGlobalLock( &pMac->sme );
4007 if ( HAL_STATUS_SUCCESS( status ) )
4008 {
4009 status = pmcRegisterPowerSaveCheck (hHal, checkRoutine, checkContext);
4010 sme_ReleaseGlobalLock( &pMac->sme );
4011 }
4012
4013 return (status);
4014}
4015
4016/* ---------------------------------------------------------------------------
4017 \fn sme_DeregisterPowerSaveCheck
4018 \brief Deregister a power save check routine
4019 \param hHal - The handle returned by macOpen.
4020 \param checkRoutine - Power save check routine to be deregistered
4021 \return eHalStatus
4022 eHAL_STATUS_SUCCESS - successfully deregistered
4023 eHAL_STATUS_FAILURE - not successfully deregistered
4024 ---------------------------------------------------------------------------*/
4025eHalStatus sme_DeregisterPowerSaveCheck (
4026 tHalHandle hHal,
4027 tANI_BOOLEAN (*checkRoutine) (void *checkContext))
4028{
4029 eHalStatus status = eHAL_STATUS_FAILURE;
4030 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4031
4032 status = sme_AcquireGlobalLock( &pMac->sme );
4033 if ( HAL_STATUS_SUCCESS( status ) )
4034 {
4035 status = pmcDeregisterPowerSaveCheck (hHal, checkRoutine);
4036 sme_ReleaseGlobalLock( &pMac->sme );
4037 }
4038
4039 return (status);
4040}
4041
4042/* ---------------------------------------------------------------------------
4043 \fn sme_RegisterDeviceStateUpdateInd
4044 \brief Register a callback routine that is called whenever
4045 the device enters a new device state (Full Power, BMPS, UAPSD)
4046 \param hHal - The handle returned by macOpen.
4047 \param callbackRoutine - Callback routine to be registered
4048 \param callbackContext - Cookie to be passed back during callback
4049 \return eHalStatus
4050 eHAL_STATUS_SUCCESS - successfully registered
4051 eHAL_STATUS_FAILURE - not successfully registered
4052 ---------------------------------------------------------------------------*/
4053eHalStatus sme_RegisterDeviceStateUpdateInd (
4054 tHalHandle hHal,
4055 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
4056 void *callbackContext)
4057{
4058 eHalStatus status = eHAL_STATUS_FAILURE;
4059 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4060
4061 status = sme_AcquireGlobalLock( &pMac->sme );
4062 if ( HAL_STATUS_SUCCESS( status ) )
4063 {
4064 status = pmcRegisterDeviceStateUpdateInd (hHal, callbackRoutine, callbackContext);
4065 sme_ReleaseGlobalLock( &pMac->sme );
4066 }
4067
4068 return (status);
4069}
4070
4071/* ---------------------------------------------------------------------------
4072 \fn sme_DeregisterDeviceStateUpdateInd
4073 \brief Deregister a routine that was registered for device state changes
4074 \param hHal - The handle returned by macOpen.
4075 \param callbackRoutine - Callback routine to be deregistered
4076 \return eHalStatus
4077 eHAL_STATUS_SUCCESS - successfully deregistered
4078 eHAL_STATUS_FAILURE - not successfully deregistered
4079 ---------------------------------------------------------------------------*/
4080eHalStatus sme_DeregisterDeviceStateUpdateInd (
4081 tHalHandle hHal,
4082 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
4083{
4084 eHalStatus status = eHAL_STATUS_FAILURE;
4085 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4086
4087 status = sme_AcquireGlobalLock( &pMac->sme );
4088 if ( HAL_STATUS_SUCCESS( status ) )
4089 {
4090 status = pmcDeregisterDeviceStateUpdateInd (hHal, callbackRoutine);
4091 sme_ReleaseGlobalLock( &pMac->sme );
4092 }
4093
4094 return (status);
4095}
4096
4097/* ---------------------------------------------------------------------------
4098 \fn sme_WowlAddBcastPattern
4099 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
4100 do a pattern match on these patterns when Wowl is enabled during BMPS
4101 mode. Note that Firmware performs the pattern matching only on
4102 broadcast frames and while Libra is in BMPS mode.
4103 \param hHal - The handle returned by macOpen.
4104 \param pattern - Pattern to be added
4105 \return eHalStatus
4106 eHAL_STATUS_FAILURE Cannot add pattern
4107 eHAL_STATUS_SUCCESS Request accepted.
4108 ---------------------------------------------------------------------------*/
4109eHalStatus sme_WowlAddBcastPattern (
4110 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004111 tpSirWowlAddBcastPtrn pattern,
4112 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004113{
4114 eHalStatus status = eHAL_STATUS_FAILURE;
4115 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07004116 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
4117 TRACE_CODE_SME_RX_HDD_WOWL_ADDBCAST_PATTERN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 status = sme_AcquireGlobalLock( &pMac->sme );
4119 if ( HAL_STATUS_SUCCESS( status ) )
4120 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004121 status = pmcWowlAddBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 sme_ReleaseGlobalLock( &pMac->sme );
4123 }
4124
4125 return (status);
4126}
4127
4128/* ---------------------------------------------------------------------------
4129 \fn sme_WowlDelBcastPattern
4130 \brief Delete a pattern that was added for Pattern Byte Matching.
4131 \param hHal - The handle returned by macOpen.
4132 \param pattern - Pattern to be deleted
4133 \return eHalStatus
4134 eHAL_STATUS_FAILURE Cannot delete pattern
4135 eHAL_STATUS_SUCCESS Request accepted.
4136 ---------------------------------------------------------------------------*/
4137eHalStatus sme_WowlDelBcastPattern (
4138 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004139 tpSirWowlDelBcastPtrn pattern,
4140 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004141{
4142 eHalStatus status = eHAL_STATUS_FAILURE;
4143 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07004144 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
4145 TRACE_CODE_SME_RX_HDD_WOWL_DELBCAST_PATTERN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 status = sme_AcquireGlobalLock( &pMac->sme );
4147 if ( HAL_STATUS_SUCCESS( status ) )
4148 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004149 status = pmcWowlDelBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 sme_ReleaseGlobalLock( &pMac->sme );
4151 }
4152
4153 return (status);
4154}
4155
4156/* ---------------------------------------------------------------------------
4157 \fn sme_EnterWowl
4158 \brief This is the SME API exposed to HDD to request enabling of WOWL mode.
4159 WoWLAN works on top of BMPS mode. If the device is not in BMPS mode,
4160 SME will will cache the information that WOWL has been enabled and
4161 attempt to put the device in BMPS. On entry into BMPS, SME will
4162 enable the WOWL mode.
4163 Note 1: If we exit BMPS mode (someone requests full power), we
4164 will NOT resume WOWL when we go back to BMPS again. Request for full
4165 power (while in WOWL mode) means disable WOWL and go to full power.
4166 Note 2: Both UAPSD and WOWL work on top of BMPS. On entry into BMPS, SME
4167 will give priority to UAPSD and enable only UAPSD if both UAPSD and WOWL
4168 are required. Currently there is no requirement or use case to support
4169 UAPSD and WOWL at the same time.
4170
4171 \param hHal - The handle returned by macOpen.
4172 \param enterWowlCallbackRoutine - Callback routine provided by HDD.
4173 Used for success/failure notification by SME
4174 \param enterWowlCallbackContext - A cookie passed by HDD, that is passed back to HDD
4175 at the time of callback.
4176 \param wakeReasonIndCB - Callback routine provided by HDD.
4177 Used for Wake Reason Indication by SME
4178 \param wakeReasonIndCBContext - A cookie passed by HDD, that is passed back to HDD
4179 at the time of callback.
4180 \return eHalStatus
4181 eHAL_STATUS_SUCCESS Device is already in WoWLAN mode
4182 eHAL_STATUS_FAILURE Device cannot enter WoWLAN mode.
4183 eHAL_STATUS_PMC_PENDING Request accepted. SME will enable WOWL after
4184 BMPS mode is entered.
4185 ---------------------------------------------------------------------------*/
4186eHalStatus sme_EnterWowl (
4187 tHalHandle hHal,
4188 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
4189 void *enterWowlCallbackContext,
4190#ifdef WLAN_WAKEUP_EVENTS
4191 void (*wakeIndicationCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
4192 void *wakeIndicationCBContext,
4193#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004194 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004195{
4196 eHalStatus status = eHAL_STATUS_FAILURE;
4197 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07004198 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
4199 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 status = sme_AcquireGlobalLock( &pMac->sme );
4201 if ( HAL_STATUS_SUCCESS( status ) )
4202 {
4203 status = pmcEnterWowl (hHal, enterWowlCallbackRoutine, enterWowlCallbackContext,
4204#ifdef WLAN_WAKEUP_EVENTS
4205 wakeIndicationCB, wakeIndicationCBContext,
4206#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004207 wowlEnterParams, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 sme_ReleaseGlobalLock( &pMac->sme );
4209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 return (status);
4211}
4212/* ---------------------------------------------------------------------------
4213 \fn sme_ExitWowl
4214 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
4215 SME will initiate exit from WoWLAN mode and device will be put in BMPS
4216 mode.
4217 \param hHal - The handle returned by macOpen.
4218 \return eHalStatus
4219 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
4220 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
4221 ---------------------------------------------------------------------------*/
4222eHalStatus sme_ExitWowl (tHalHandle hHal)
4223{
4224 eHalStatus status = eHAL_STATUS_FAILURE;
4225 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07004226 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
4227 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 status = sme_AcquireGlobalLock( &pMac->sme );
4229 if ( HAL_STATUS_SUCCESS( status ) )
4230 {
4231 status = pmcExitWowl (hHal);
4232 sme_ReleaseGlobalLock( &pMac->sme );
4233 }
4234
4235 return (status);
4236}
4237
4238/* ---------------------------------------------------------------------------
4239
4240 \fn sme_RoamSetKey
4241
4242 \brief To set encryption key. This function should be called only when connected
4243 This is an asynchronous API.
4244
4245 \param pSetKeyInfo - pointer to a caller allocated object of tCsrSetContextInfo
4246
4247 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
4248
4249 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
4250
4251 FAILURE or RESOURCES The API finished and failed.
4252
4253 -------------------------------------------------------------------------------*/
4254eHalStatus sme_RoamSetKey(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 *pRoamId)
4255{
4256 eHalStatus status = eHAL_STATUS_FAILURE;
4257 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4258 tANI_U32 roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 tANI_U32 i;
4260 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004261
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07004262 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
4263 TRACE_CODE_SME_RX_HDD_SET_KEY, sessionId, 0));
Jeff Johnsonf89f4b52013-03-27 10:32:44 -07004264 if (pSetKey->keyLength > CSR_MAX_KEY_LEN)
4265 {
4266 smsLog(pMac, LOGE, FL("Invalid key length %d"), pSetKey->keyLength);
4267 return eHAL_STATUS_FAILURE;
4268 }
4269
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 status = sme_AcquireGlobalLock( &pMac->sme );
4271 if ( HAL_STATUS_SUCCESS( status ) )
4272 {
4273 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
4274 if(pRoamId)
4275 {
4276 *pRoamId = roamId;
4277 }
4278
Jeff Johnsonf89f4b52013-03-27 10:32:44 -07004279 smsLog(pMac, LOG2, FL("keyLength %d"), pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004280
4281 for(i=0; i<pSetKey->keyLength; i++)
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004282 smsLog(pMac, LOG2, FL("%02x"), pSetKey->Key[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004283
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004284 smsLog(pMac, LOG2, "\n sessionId=%d roamId=%d", sessionId, roamId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004285
4286 pSession = CSR_GET_SESSION(pMac, sessionId);
4287
Jeff Johnson32d95a32012-09-10 13:15:23 -07004288 if(!pSession)
4289 {
4290 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08004291 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004292 return eHAL_STATUS_FAILURE;
4293 }
4294
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
4296 {
4297 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
4298 {
4299 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
4300 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
4301 {
4302 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4303 }
4304 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
4305 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
4306 {
4307 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4308 }
4309 }
4310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004311
4312 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
4313 sme_ReleaseGlobalLock( &pMac->sme );
4314 }
4315
4316 return (status);
4317}
4318
4319
4320/* ---------------------------------------------------------------------------
4321
4322 \fn sme_RoamRemoveKey
4323
4324 \brief To set encryption key. This is an asynchronous API.
4325
4326 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
4327
4328 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
4329
4330 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
4331
4332 FAILURE or RESOURCES The API finished and failed.
4333
4334 -------------------------------------------------------------------------------*/
4335eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
4336 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
4337{
4338 eHalStatus status = eHAL_STATUS_FAILURE;
4339 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4340 tANI_U32 roamId;
4341
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07004342 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
4343 TRACE_CODE_SME_RX_HDD_REMOVE_KEY, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 status = sme_AcquireGlobalLock( &pMac->sme );
4345 if ( HAL_STATUS_SUCCESS( status ) )
4346 {
4347 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
4348 if(pRoamId)
4349 {
4350 *pRoamId = roamId;
4351 }
4352 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
4353 sme_ReleaseGlobalLock( &pMac->sme );
4354 }
4355
4356 return (status);
4357}
4358
4359/* ---------------------------------------------------------------------------
4360 \fn sme_GetRssi
4361 \brief a wrapper function that client calls to register a callback to get RSSI
4362
4363 \param callback - SME sends back the requested stats using the callback
4364 \param staId - The station ID for which the stats is requested for
4365 \param pContext - user context to be passed back along with the callback
4366 \param pVosContext - vos context
4367 \return eHalStatus
4368 ---------------------------------------------------------------------------*/
4369eHalStatus sme_GetRssi(tHalHandle hHal,
4370 tCsrRssiCallback callback,
4371 tANI_U8 staId, tCsrBssid bssId,
4372 void *pContext, void* pVosContext)
4373{
4374 eHalStatus status = eHAL_STATUS_FAILURE;
4375 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4376
4377 status = sme_AcquireGlobalLock( &pMac->sme );
4378 if ( HAL_STATUS_SUCCESS( status ) )
4379 {
4380 status = csrGetRssi( pMac, callback,
4381 staId, bssId, pContext, pVosContext);
4382 sme_ReleaseGlobalLock( &pMac->sme );
4383 }
4384 return (status);
4385}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05304386
4387/* ---------------------------------------------------------------------------
4388 \fn sme_GetSnr
4389 \brief a wrapper function that client calls to register a callback to
4390 get SNR
4391
4392 \param callback - SME sends back the requested stats using the callback
4393 \param staId - The station ID for which the stats is requested for
4394 \param pContext - user context to be passed back along with the callback
4395 \param pVosContext - vos context
4396 \return eHalStatus
4397 ---------------------------------------------------------------------------*/
4398eHalStatus sme_GetSnr(tHalHandle hHal,
4399 tCsrSnrCallback callback,
4400 tANI_U8 staId, tCsrBssid bssId,
4401 void *pContext)
4402{
4403 eHalStatus status = eHAL_STATUS_FAILURE;
4404 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4405
4406 status = sme_AcquireGlobalLock( &pMac->sme );
4407 if ( HAL_STATUS_SUCCESS( status ) )
4408 {
4409 status = csrGetSnr(pMac, callback,
4410 staId, bssId, pContext);
4411 sme_ReleaseGlobalLock( &pMac->sme );
4412 }
4413 return status;
4414}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004415#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4416/* ---------------------------------------------------------------------------
4417 \fn sme_GetRoamRssi
4418 \brief a wrapper function that client calls to register a callback to get Roam RSSI
4419
4420 \param callback - SME sends back the requested stats using the callback
4421 \param staId - The station ID for which the stats is requested for
4422 \param pContext - user context to be passed back along with the callback
4423 \param pVosContext - vos context
4424 \return eHalStatus
4425 ---------------------------------------------------------------------------*/
4426eHalStatus sme_GetRoamRssi(tHalHandle hHal,
4427 tCsrRssiCallback callback,
4428 tANI_U8 staId, tCsrBssid bssId,
4429 void *pContext, void* pVosContext)
4430{
4431 eHalStatus status = eHAL_STATUS_FAILURE;
4432 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4433
4434 status = sme_AcquireGlobalLock( &pMac->sme );
4435 if ( HAL_STATUS_SUCCESS( status ) )
4436 {
4437 status = csrGetRoamRssi( pMac, callback,
4438 staId, bssId, pContext, pVosContext);
4439 sme_ReleaseGlobalLock( &pMac->sme );
4440 }
4441 return (status);
4442}
4443#endif
4444
Jeff Johnson295189b2012-06-20 16:38:30 -07004445
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004446#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
4447/* ---------------------------------------------------------------------------
4448 \fn sme_GetTsmStats
4449 \brief a wrapper function that client calls to register a callback to get TSM Stats
4450
4451 \param callback - SME sends back the requested stats using the callback
4452 \param staId - The station ID for which the stats is requested for
4453 \param pContext - user context to be passed back along with the callback
4454 \param pVosContext - vos context
4455 \return eHalStatus
4456 ---------------------------------------------------------------------------*/
4457eHalStatus sme_GetTsmStats(tHalHandle hHal,
4458 tCsrTsmStatsCallback callback,
4459 tANI_U8 staId, tCsrBssid bssId,
4460 void *pContext, void* pVosContext, tANI_U8 tid)
4461{
4462 eHalStatus status = eHAL_STATUS_FAILURE;
4463 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4464
4465 status = sme_AcquireGlobalLock( &pMac->sme );
4466 if ( HAL_STATUS_SUCCESS( status ) )
4467 {
4468 status = csrGetTsmStats( pMac, callback,
4469 staId, bssId, pContext, pVosContext, tid);
4470 sme_ReleaseGlobalLock( &pMac->sme );
4471 }
4472 return (status);
4473}
4474#endif
4475
4476
Jeff Johnson295189b2012-06-20 16:38:30 -07004477/* ---------------------------------------------------------------------------
4478 \fn sme_GetStatistics
4479 \brief a wrapper function that client calls to register a callback to get
4480 different PHY level statistics from CSR.
4481
4482 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
4483 \param statsMask - The different category/categories of stats requester is looking for
4484 \param callback - SME sends back the requested stats using the callback
4485 \param periodicity - If requester needs periodic update in millisec, 0 means
4486 it's an one time request
4487 \param cache - If requester is happy with cached stats
4488 \param staId - The station ID for which the stats is requested for
4489 \param pContext - user context to be passed back along with the callback
4490 \return eHalStatus
4491 ---------------------------------------------------------------------------*/
4492eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
4493 tANI_U32 statsMask,
4494 tCsrStatsCallback callback,
4495 tANI_U32 periodicity, tANI_BOOLEAN cache,
4496 tANI_U8 staId, void *pContext)
4497{
4498 eHalStatus status = eHAL_STATUS_FAILURE;
4499 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4500
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07004501 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
4502 TRACE_CODE_SME_RX_HDD_GET_STATS, NO_SESSION, periodicity));
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 status = sme_AcquireGlobalLock( &pMac->sme );
4504 if ( HAL_STATUS_SUCCESS( status ) )
4505 {
4506 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
4507 periodicity, cache, staId, pContext);
4508 sme_ReleaseGlobalLock( &pMac->sme );
4509 }
4510
4511 return (status);
4512
4513}
4514
4515/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304516 \fn smeGetTLSTAState
4517 \helper function to get the TL STA State whenever the function is called.
4518
4519 \param staId - The staID to be passed to the TL
4520 to get the relevant TL STA State
4521 \return the state as tANI_U16
4522 ---------------------------------------------------------------------------*/
4523tANI_U16 smeGetTLSTAState(tHalHandle hHal, tANI_U8 staId)
4524{
4525 tANI_U16 tlSTAState = TL_INIT_STATE;
4526 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4527 eHalStatus status = eHAL_STATUS_FAILURE;
4528
4529 status = sme_AcquireGlobalLock( &pMac->sme );
4530 if ( HAL_STATUS_SUCCESS( status ) )
4531 {
4532 tlSTAState = csrGetTLSTAState( pMac, staId);
4533 sme_ReleaseGlobalLock( &pMac->sme );
4534 }
4535
4536 return tlSTAState;
4537}
4538
4539/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07004540
4541 \fn sme_GetCountryCode
4542
4543 \brief To return the current country code. If no country code is applied, default country code is
4544 used to fill the buffer.
4545 If 11d supported is turned off, an error is return and the last applied/default country code is used.
4546 This is a synchronous API.
4547
4548 \param pBuf - pointer to a caller allocated buffer for returned country code.
4549
4550 \param pbLen For input, this parameter indicates how big is the buffer.
4551 Upon return, this parameter has the number of bytes for country. If pBuf
4552 doesn't have enough space, this function returns
4553 fail status and this parameter contains the number that is needed.
4554
4555 \return eHalStatus SUCCESS.
4556
4557 FAILURE or RESOURCES The API finished and failed.
4558
4559 -------------------------------------------------------------------------------*/
4560eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
4561{
4562 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4563
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07004564 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
4565 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4566
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
4568}
4569
4570
4571/* ---------------------------------------------------------------------------
4572
4573 \fn sme_SetCountryCode
4574
4575 \brief To change the current/default country code.
4576 If 11d supported is turned off, an error is return.
4577 This is a synchronous API.
4578
4579 \param pCountry - pointer to a caller allocated buffer for the country code.
4580
4581 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
4582 whether a reset is required.
4583
4584 \return eHalStatus SUCCESS.
4585
4586 FAILURE or RESOURCES The API finished and failed.
4587
4588 -------------------------------------------------------------------------------*/
4589eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
4590{
4591 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4592
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07004593 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
4594 TRACE_CODE_SME_RX_HDD_SET_CNTRYCODE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
4596}
4597
4598
4599/* ---------------------------------------------------------------------------
4600 \fn sme_ResetCountryCodeInformation
4601 \brief this function is to reset the country code current being used back to EEPROM default
4602 this includes channel list and power setting. This is a synchronous API.
4603 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
4604 a restart is needed to apply the change
4605 \return eHalStatus
4606 -------------------------------------------------------------------------------*/
4607eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
4608{
4609 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4610
4611 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
4612}
4613
4614
4615/* ---------------------------------------------------------------------------
4616 \fn sme_GetSupportedCountryCode
4617 \brief this function is to get a list of the country code current being supported
4618 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
4619 this has the country code list. 3 bytes for each country code. This may be NULL if
4620 caller wants to know the needed byte count.
4621 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
4622 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
4623 \return eHalStatus
4624 -------------------------------------------------------------------------------*/
4625eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
4626{
4627 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4628
4629 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
4630}
4631
4632
4633/* ---------------------------------------------------------------------------
4634 \fn sme_GetCurrentRegulatoryDomain
4635 \brief this function is to get the current regulatory domain. This is a synchronous API.
4636 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4637 SME. The function fails if 11d support is turned off.
4638 \param pDomain - Caller allocated buffer to return the current domain.
4639 \return eHalStatus SUCCESS.
4640
4641 FAILURE or RESOURCES The API finished and failed.
4642 -------------------------------------------------------------------------------*/
4643eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
4644{
4645 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4646 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4647
4648 if( pDomain )
4649 {
4650 if( csrIs11dSupported( pMac ) )
4651 {
4652 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
4653 status = eHAL_STATUS_SUCCESS;
4654 }
4655 else
4656 {
4657 status = eHAL_STATUS_FAILURE;
4658 }
4659 }
4660
4661 return ( status );
4662}
4663
4664
4665/* ---------------------------------------------------------------------------
4666 \fn sme_SetRegulatoryDomain
4667 \brief this function is to set the current regulatory domain.
4668 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4669 SME. This is a synchronous API.
4670 \param domainId - indicate the domain (defined in the driver) needs to set to.
4671 See v_REGDOMAIN_t for definition
4672 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
4673 a restart is needed to apply the change
4674 \return eHalStatus
4675 -------------------------------------------------------------------------------*/
4676eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
4677{
4678 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4679
4680 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
4681}
4682
4683
4684/* ---------------------------------------------------------------------------
4685
4686 \fn sme_GetRegulatoryDomainForCountry
4687
4688 \brief To return a regulatory domain base on a country code. This is a synchronous API.
4689
4690 \param pCountry - pointer to a caller allocated buffer for input country code.
4691
4692 \param pDomainId Upon successful return, it is the domain that country belongs to.
4693 If it is NULL, returning success means that the country code is known.
4694
4695 \return eHalStatus SUCCESS.
4696
4697 FAILURE or RESOURCES The API finished and failed.
4698
4699 -------------------------------------------------------------------------------*/
4700eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
4701{
4702 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4703
Kiet Lam6c583332013-10-14 05:37:09 +05304704 return csrGetRegulatoryDomainForCountry(pMac, pCountry, pDomainId,
4705 COUNTRY_QUERY);
Jeff Johnson295189b2012-06-20 16:38:30 -07004706}
4707
4708
4709
4710
4711/* ---------------------------------------------------------------------------
4712
4713 \fn sme_GetSupportedRegulatoryDomains
4714
4715 \brief To return a list of supported regulatory domains. This is a synchronous API.
4716
4717 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
4718
4719 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
4720 Upon return, this parameter has the number for supported domains. If pDomains
4721 doesn't have enough space for all the supported domains, this function returns
4722 fail status and this parameter contains the number that is needed.
4723
4724 \return eHalStatus SUCCESS.
4725
4726 FAILURE or RESOURCES The API finished and failed.
4727
4728 -------------------------------------------------------------------------------*/
4729eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
4730{
4731 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4732
4733 //We support all domains for now
4734 if( pNumDomains )
4735 {
4736 if( NUM_REG_DOMAINS <= *pNumDomains )
4737 {
4738 status = eHAL_STATUS_SUCCESS;
4739 }
4740 *pNumDomains = NUM_REG_DOMAINS;
4741 }
4742 if( HAL_STATUS_SUCCESS( status ) )
4743 {
4744 if( pDomains )
4745 {
4746 pDomains[0] = REGDOMAIN_FCC;
4747 pDomains[1] = REGDOMAIN_ETSI;
4748 pDomains[2] = REGDOMAIN_JAPAN;
4749 pDomains[3] = REGDOMAIN_WORLD;
4750 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
4751 pDomains[5] = REGDOMAIN_APAC;
4752 pDomains[6] = REGDOMAIN_KOREA;
4753 pDomains[7] = REGDOMAIN_HI_5GHZ;
4754 pDomains[8] = REGDOMAIN_NO_5GHZ;
4755 }
4756 else
4757 {
4758 status = eHAL_STATUS_INVALID_PARAMETER;
4759 }
4760 }
4761
4762 return ( status );
4763}
4764
4765
4766//some support functions
4767tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
4768{
4769 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4770
4771 return ( csrIs11dSupported( pMac ) );
4772}
4773
4774
4775tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
4776{
4777 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4778
4779 return ( csrIs11hSupported( pMac ) );
4780}
4781
4782
4783tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
4784{
4785 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4786
4787 return ( csrIsWmmSupported( pMac ) );
4788}
4789
4790//Upper layer to get the list of the base channels to scan for passively 11d info from csr
4791eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
4792{
4793 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4794
4795 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
4796}
4797
4798/* ---------------------------------------------------------------------------
4799
4800 \fn sme_ChangeCountryCode
4801
4802 \brief Change Country code from upperlayer during WLAN driver operation.
4803 This is a synchronous API.
4804
4805 \param hHal - The handle returned by macOpen.
4806
4807 \param pCountry New Country Code String
4808
4809 \return eHalStatus SUCCESS.
4810
4811 FAILURE or RESOURCES The API finished and failed.
4812
4813 -------------------------------------------------------------------------------*/
4814eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
4815 tSmeChangeCountryCallback callback,
4816 tANI_U8 *pCountry,
4817 void *pContext,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304818 void* pVosContext,
4819 tAniBool countryFromUserSpace )
Jeff Johnson295189b2012-06-20 16:38:30 -07004820{
4821 eHalStatus status = eHAL_STATUS_FAILURE;
4822 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4823 vos_msg_t msg;
4824 tAniChangeCountryCodeReq *pMsg;
4825
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07004826 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
4827 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 status = sme_AcquireGlobalLock( &pMac->sme );
4829 if ( HAL_STATUS_SUCCESS( status ) )
4830 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004831 smsLog(pMac, LOG1, FL(" called"));
Amar Singhal97a2d992013-11-19 10:58:07 -08004832
4833 if ((csrGetInfraSessionId(pMac) != -1) &&
4834 (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
4835 {
4836
4837 smsLog(pMac, LOGW, "Set Country Code Fail since the STA is associated and userspace does not have priority ");
4838
4839 sme_ReleaseGlobalLock( &pMac->sme );
4840 status = eHAL_STATUS_FAILURE;
4841 return status;
4842 }
4843
Kiet Lam64c1b492013-07-12 13:56:44 +05304844 pMsg = vos_mem_malloc(sizeof(tAniChangeCountryCodeReq));
4845 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004847 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req");
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08004848 sme_ReleaseGlobalLock( &pMac->sme );
Kiet Lam64c1b492013-07-12 13:56:44 +05304849 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004850 }
4851
4852 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
4853 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
Kiet Lam64c1b492013-07-12 13:56:44 +05304854 vos_mem_copy(pMsg->countryCode, pCountry, 3);
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304855 pMsg->countryFromUserSpace = countryFromUserSpace;
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 pMsg->changeCCCallback = callback;
4857 pMsg->pDevContext = pContext;
4858 pMsg->pVosContext = pVosContext;
4859
4860 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4861 msg.bodyptr = pMsg;
4862 msg.reserved = 0;
4863
4864 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
4865 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004866 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +05304867 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 status = eHAL_STATUS_FAILURE;
4869 }
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004870 smsLog(pMac, LOG1, FL(" returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 sme_ReleaseGlobalLock( &pMac->sme );
4872 }
4873
4874 return (status);
4875}
Amar Singhal0d15bd52013-10-12 23:13:13 -07004876
4877/*--------------------------------------------------------------------------
4878
4879 \fn sme_GenericChangeCountryCode
4880
4881 \brief Change Country code from upperlayer during WLAN driver operation.
4882 This is a synchronous API.
4883
4884 \param hHal - The handle returned by macOpen.
4885
4886 \param pCountry New Country Code String
4887
4888 \param reg_domain regulatory domain
4889
4890 \return eHalStatus SUCCESS.
4891
4892 FAILURE or RESOURCES The API finished and failed.
4893
4894-----------------------------------------------------------------------------*/
4895eHalStatus sme_GenericChangeCountryCode( tHalHandle hHal,
4896 tANI_U8 *pCountry,
4897 v_REGDOMAIN_t reg_domain)
4898{
4899 eHalStatus status = eHAL_STATUS_FAILURE;
4900 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4901 vos_msg_t msg;
4902 tAniGenericChangeCountryCodeReq *pMsg;
4903
Kiet Lamcffc5862013-10-30 16:28:45 +05304904 if (NULL == pMac)
4905 {
4906 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
4907 "%s: pMac is null", __func__);
4908 return status;
4909 }
4910
Amar Singhal0d15bd52013-10-12 23:13:13 -07004911 status = sme_AcquireGlobalLock( &pMac->sme );
4912 if ( HAL_STATUS_SUCCESS( status ) )
4913 {
4914 smsLog(pMac, LOG1, FL(" called"));
4915 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg,
4916 sizeof(tAniGenericChangeCountryCodeReq));
4917
4918 if (!HAL_STATUS_SUCCESS(status))
4919 {
4920 smsLog(pMac, LOGE, " sme_GenericChangeCountryCode: failed to allocate mem for req");
4921 sme_ReleaseGlobalLock( &pMac->sme );
4922 return status;
4923 }
4924
4925 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE);
4926 pMsg->msgLen = (tANI_U16)sizeof(tAniGenericChangeCountryCodeReq);
4927 palCopyMemory(pMac->hHdd, pMsg->countryCode, pCountry, 3);
4928 pMsg->domain_index = reg_domain;
4929
4930 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4931 msg.bodyptr = pMsg;
4932 msg.reserved = 0;
4933
4934 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
4935 {
4936 smsLog(pMac, LOGE, "sme_GenericChangeCountryCode failed to post msg to self");
4937 palFreeMemory(pMac->hHdd, (void *)pMsg);
4938 status = eHAL_STATUS_FAILURE;
4939 }
4940 smsLog(pMac, LOG1, FL(" returned"));
4941 sme_ReleaseGlobalLock( &pMac->sme );
4942 }
4943
4944 return (status);
4945}
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05304946/* ---------------------------------------------------------------------------
4947
4948 \fn sme_DHCPStartInd
4949
4950 \brief API to signal the FW about the DHCP Start event.
4951
4952 \param hHal - HAL handle for device.
4953
4954 \param device_mode - mode(AP,SAP etc) of the device.
4955
4956 \param macAddr - MAC address of the device.
4957
4958 \return eHalStatus SUCCESS.
4959
4960 FAILURE or RESOURCES The API finished and failed.
4961 --------------------------------------------------------------------------*/
4962eHalStatus sme_DHCPStartInd( tHalHandle hHal,
4963 tANI_U8 device_mode,
4964 tANI_U8 *macAddr )
4965{
4966 eHalStatus status;
4967 VOS_STATUS vosStatus;
4968 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4969 vos_msg_t vosMessage;
4970 tAniDHCPInd *pMsg;
4971
4972 status = sme_AcquireGlobalLock(&pMac->sme);
4973 if ( eHAL_STATUS_SUCCESS == status)
4974 {
4975 pMsg = (tAniDHCPInd*)vos_mem_malloc(sizeof(tAniDHCPInd));
4976 if (NULL == pMsg)
4977 {
4978 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4979 "%s: Not able to allocate memory for dhcp start", __func__);
4980 sme_ReleaseGlobalLock( &pMac->sme );
4981 return eHAL_STATUS_FAILURE;
4982 }
4983 pMsg->msgType = WDA_DHCP_START_IND;
4984 pMsg->msgLen = (tANI_U16)sizeof(tAniDHCPInd);
4985 pMsg->device_mode = device_mode;
4986 vos_mem_copy( pMsg->macAddr, macAddr, sizeof(tSirMacAddr));
4987
4988 vosMessage.type = WDA_DHCP_START_IND;
4989 vosMessage.bodyptr = pMsg;
4990 vosMessage.reserved = 0;
4991
4992 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
4993 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
4994 {
4995 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4996 "%s: Post DHCP Start MSG fail", __func__);
4997 vos_mem_free(pMsg);
4998 status = eHAL_STATUS_FAILURE;
4999 }
5000 sme_ReleaseGlobalLock( &pMac->sme );
5001 }
5002 return (status);
5003}
5004/* ---------------------------------------------------------------------------
5005 \fn sme_DHCPStopInd
5006
5007 \brief API to signal the FW about the DHCP complete event.
5008
5009 \param hHal - HAL handle for device.
5010
5011 \param device_mode - mode(AP, SAP etc) of the device.
5012
5013 \param macAddr - MAC address of the device.
5014
5015 \return eHalStatus SUCCESS.
5016 FAILURE or RESOURCES The API finished and failed.
5017 --------------------------------------------------------------------------*/
5018eHalStatus sme_DHCPStopInd( tHalHandle hHal,
5019 tANI_U8 device_mode,
5020 tANI_U8 *macAddr )
5021{
5022 eHalStatus status;
5023 VOS_STATUS vosStatus;
5024 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5025 vos_msg_t vosMessage;
5026 tAniDHCPInd *pMsg;
5027
5028 status = sme_AcquireGlobalLock(&pMac->sme);
5029 if ( eHAL_STATUS_SUCCESS == status)
5030 {
5031 pMsg = (tAniDHCPInd*)vos_mem_malloc(sizeof(tAniDHCPInd));
5032 if (NULL == pMsg)
5033 {
5034 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
5035 "%s: Not able to allocate memory for dhcp stop", __func__);
5036 sme_ReleaseGlobalLock( &pMac->sme );
5037 return eHAL_STATUS_FAILURE;
5038 }
5039
5040 pMsg->msgType = WDA_DHCP_STOP_IND;
5041 pMsg->msgLen = (tANI_U16)sizeof(tAniDHCPInd);
5042 pMsg->device_mode = device_mode;
5043 vos_mem_copy( pMsg->macAddr, macAddr, sizeof(tSirMacAddr));
5044
5045 vosMessage.type = WDA_DHCP_STOP_IND;
5046 vosMessage.bodyptr = pMsg;
5047 vosMessage.reserved = 0;
5048
5049 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
5050 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
5051 {
5052 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
5053 "%s: Post DHCP Stop MSG fail", __func__);
5054 vos_mem_free(pMsg);
5055 status = eHAL_STATUS_FAILURE;
5056 }
5057
5058 sme_ReleaseGlobalLock( &pMac->sme );
5059 }
5060 return (status);
5061}
5062
Jeff Johnson295189b2012-06-20 16:38:30 -07005063
5064/* ---------------------------------------------------------------------------
5065 \fn sme_BtcSignalBtEvent
5066 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
5067 BT event type and the current operating mode of Libra (full power,
5068 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
5069 would be employed.
5070 \param hHal - The handle returned by macOpen.
5071 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
5072 Caller owns the memory and is responsible for freeing it.
5073 \return VOS_STATUS
5074 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
5075 if BTC execution mode is set to BTC_WLAN_ONLY
5076 or BTC_PTA_ONLY.
5077 VOS_STATUS_SUCCESS BT Event passed to HAL
5078 ---------------------------------------------------------------------------*/
5079VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
5080{
5081 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005082
Jeff Johnson295189b2012-06-20 16:38:30 -07005083#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5084 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5085
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005086 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5087 TRACE_CODE_SME_RX_HDD_BTC_SIGNALEVENT, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5089 {
5090 status = btcSignalBTEvent (hHal, pBtEvent);
5091 sme_ReleaseGlobalLock( &pMac->sme );
5092 }
5093#endif
5094 return (status);
5095}
5096
5097/* ---------------------------------------------------------------------------
5098 \fn sme_BtcSetConfig
5099 \brief API to change the current Bluetooth Coexistence (BTC) configuration
5100 This function should be invoked only after CFG download has completed.
5101 Calling it after sme_HDDReadyInd is recommended.
5102 \param hHal - The handle returned by macOpen.
5103 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
5104 Caller owns the memory and is responsible for freeing it.
5105 \return VOS_STATUS
5106 VOS_STATUS_E_FAILURE Config not passed to HAL.
5107 VOS_STATUS_SUCCESS Config passed to HAL
5108 ---------------------------------------------------------------------------*/
5109VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
5110{
5111 VOS_STATUS status = VOS_STATUS_E_FAILURE;
5112#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5113 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005114 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5115 TRACE_CODE_SME_RX_HDD_BTC_SETCONFIG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5117 {
5118 status = btcSetConfig (hHal, pSmeBtcConfig);
5119 sme_ReleaseGlobalLock( &pMac->sme );
5120 }
5121#endif
5122 return (status);
5123}
5124
5125/* ---------------------------------------------------------------------------
5126 \fn sme_BtcGetConfig
5127 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
5128 \param hHal - The handle returned by macOpen.
5129 \param pSmeBtcConfig - Pointer to a caller allocated object of type
5130 tSmeBtcConfig. Caller owns the memory and is responsible
5131 for freeing it.
5132 \return VOS_STATUS
5133 VOS_STATUS_E_FAILURE - failure
5134 VOS_STATUS_SUCCESS success
5135 ---------------------------------------------------------------------------*/
5136VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
5137{
5138 VOS_STATUS status = VOS_STATUS_E_FAILURE;
5139#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5140 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5141
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005142 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5143 TRACE_CODE_SME_RX_HDD_BTC_GETCONFIG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005144 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5145 {
5146 status = btcGetConfig (hHal, pSmeBtcConfig);
5147 sme_ReleaseGlobalLock( &pMac->sme );
5148 }
5149#endif
5150 return (status);
5151}
5152/* ---------------------------------------------------------------------------
5153 \fn sme_SetCfgPrivacy
5154 \brief API to set configure privacy parameters
5155 \param hHal - The handle returned by macOpen.
5156 \param pProfile - Pointer CSR Roam profile.
5157 \param fPrivacy - This parameter indicates status of privacy
5158
5159 \return void
5160 ---------------------------------------------------------------------------*/
5161void sme_SetCfgPrivacy( tHalHandle hHal,
5162 tCsrRoamProfile *pProfile,
5163 tANI_BOOLEAN fPrivacy
5164 )
5165{
5166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005167 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5168 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5170 {
5171 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
5172 sme_ReleaseGlobalLock( &pMac->sme );
5173 }
5174}
5175
5176#if defined WLAN_FEATURE_VOWIFI
5177/* ---------------------------------------------------------------------------
5178 \fn sme_NeighborReportRequest
5179 \brief API to request neighbor report.
5180 \param hHal - The handle returned by macOpen.
5181 \param pRrmNeighborReq - Pointer to a caller allocated object of type
5182 tRrmNeighborReq. Caller owns the memory and is responsible
5183 for freeing it.
5184 \return VOS_STATUS
5185 VOS_STATUS_E_FAILURE - failure
5186 VOS_STATUS_SUCCESS success
5187 ---------------------------------------------------------------------------*/
5188VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
5189 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
5190{
5191 VOS_STATUS status = VOS_STATUS_E_FAILURE;
5192 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005193 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5194 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005195
5196 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5197 {
5198 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
5199 sme_ReleaseGlobalLock( &pMac->sme );
5200 }
5201
5202 return (status);
5203}
5204#endif
5205
5206//The following are debug APIs to support direct read/write register/memory
5207//They are placed in SME because HW cannot be access when in LOW_POWER state
5208//AND not connected. The knowledge and synchronization is done in SME
5209
5210//sme_DbgReadRegister
5211//Caller needs to validate the input values
5212VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
5213{
5214 VOS_STATUS status = VOS_STATUS_E_FAILURE;
5215 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 tPmcPowerState PowerState;
5217 tANI_U32 sessionId = 0;
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005218 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5219 TRACE_CODE_SME_RX_HDD_DBG_READREG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005220
5221 /* 1) To make Quarky work in FTM mode **************************************/
5222
5223 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
5224 {
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08005225 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 {
5227 return VOS_STATUS_SUCCESS;
5228 }
5229 return VOS_STATUS_E_FAILURE;
5230 }
5231
5232 /* 2) NON FTM mode driver *************************************************/
5233
5234 /* Acquire SME global lock */
5235 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
5236 {
5237 return VOS_STATUS_E_FAILURE;
5238 }
5239
5240 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
5241 {
5242 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
5243 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
5244 {
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08005245 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 {
5247 status = VOS_STATUS_SUCCESS;
5248 }
5249 else
5250 {
5251 status = VOS_STATUS_E_FAILURE;
5252 }
5253 }
5254 else
5255 {
5256 status = VOS_STATUS_E_FAILURE;
5257 }
5258 }
5259
5260 /* This is a hack for Qualky/pttWniSocket
5261 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
5262 if ( VOS_STATUS_SUCCESS != status )
5263 {
5264 *pRegValue = 0xDEADBEEF;
5265 status = VOS_STATUS_SUCCESS;
5266 }
5267
5268 /* Release SME global lock */
5269 sme_ReleaseGlobalLock(&pMac->sme);
5270
5271 return (status);
5272}
5273
5274
5275//sme_DbgWriteRegister
5276//Caller needs to validate the input values
5277VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
5278{
5279 VOS_STATUS status = VOS_STATUS_E_FAILURE;
5280 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 tPmcPowerState PowerState;
5282 tANI_U32 sessionId = 0;
5283
5284 /* 1) To make Quarky work in FTM mode **************************************/
5285
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005286 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5287 TRACE_CODE_SME_RX_HDD_DBG_WRITEREG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
5289 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 {
5292 return VOS_STATUS_SUCCESS;
5293 }
5294 return VOS_STATUS_E_FAILURE;
5295 }
5296
5297 /* 2) NON FTM mode driver *************************************************/
5298
5299 /* Acquire SME global lock */
5300 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
5301 {
5302 return VOS_STATUS_E_FAILURE;
5303 }
5304
5305 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
5306 {
5307 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
5308 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
5309 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 {
5312 status = VOS_STATUS_SUCCESS;
5313 }
5314 else
5315 {
5316 status = VOS_STATUS_E_FAILURE;
5317 }
5318 }
5319 else
5320 {
5321 status = VOS_STATUS_E_FAILURE;
5322 }
5323 }
5324
5325 /* Release SME global lock */
5326 sme_ReleaseGlobalLock(&pMac->sme);
5327
5328 return (status);
5329}
5330
5331
5332
5333//sme_DbgReadMemory
5334//Caller needs to validate the input values
5335//pBuf caller allocated buffer has the length of nLen
5336VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
5337{
5338 VOS_STATUS status = VOS_STATUS_E_FAILURE;
5339 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 tPmcPowerState PowerState;
5341 tANI_U32 sessionId = 0;
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08005342 tANI_U32 cmd = READ_MEMORY_DUMP_CMD;
5343 tANI_U32 arg1 = memAddr;
5344 tANI_U32 arg2 = nLen/4;
5345 tANI_U32 arg3 = 4;
5346 tANI_U32 arg4 = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 /* 1) To make Quarky work in FTM mode **************************************/
5348
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005349 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5350 TRACE_CODE_SME_RX_HDD_DBG_READMEM, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
5352 {
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08005353 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8*)pBuf))
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 {
5355 return VOS_STATUS_SUCCESS;
5356 }
5357 return VOS_STATUS_E_FAILURE;
5358 }
5359
5360 /* 2) NON FTM mode driver *************************************************/
5361
5362 /* Acquire SME global lock */
5363 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
5364 {
5365 return VOS_STATUS_E_FAILURE;
5366 }
5367
5368 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
5369 {
5370 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
5371 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
5372 {
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08005373 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8 *)pBuf))
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 {
5375 status = VOS_STATUS_SUCCESS;
5376 }
5377 else
5378 {
5379 status = VOS_STATUS_E_FAILURE;
5380 }
5381 }
5382 else
5383 {
5384 status = VOS_STATUS_E_FAILURE;
5385 }
5386 }
5387
5388 /* This is a hack for Qualky/pttWniSocket
5389 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
5390 if (VOS_STATUS_SUCCESS != status)
5391 {
5392 vos_mem_set(pBuf, nLen, 0xCD);
5393 status = VOS_STATUS_SUCCESS;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005394 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 }
5396
5397 /* Release SME lock */
5398 sme_ReleaseGlobalLock(&pMac->sme);
5399
5400 return (status);
5401}
5402
5403
5404//sme_DbgWriteMemory
5405//Caller needs to validate the input values
5406VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
5407{
5408 VOS_STATUS status = VOS_STATUS_E_FAILURE;
5409 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 tPmcPowerState PowerState;
5411 tANI_U32 sessionId = 0;
5412
5413 /* 1) To make Quarky work in FTM mode **************************************/
5414
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005415 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5416 TRACE_CODE_SME_RX_HDD_DBG_WRITEMEM, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
5418 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 {
5420 return VOS_STATUS_SUCCESS;
5421 }
5422 return VOS_STATUS_E_FAILURE;
5423 }
5424
5425 /* 2) NON FTM mode driver *************************************************/
5426
5427 /* Acquire SME global lock */
5428 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
5429 {
5430 return VOS_STATUS_E_FAILURE;
5431 }
5432
5433 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
5434 {
5435 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
5436 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
5437 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 {
5440 status = VOS_STATUS_SUCCESS;
5441 }
5442 else
5443 {
5444 status = VOS_STATUS_E_FAILURE;
5445 }
5446 }
5447 else
5448 {
5449 status = VOS_STATUS_E_FAILURE;
5450 }
5451 }
5452
5453 /* Release Global lock */
5454 sme_ReleaseGlobalLock(&pMac->sme);
5455
5456 return (status);
5457}
5458
5459
Katya Nigam70d68332013-09-16 16:49:45 +05305460void pmcLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString, ...)
5461{
5462 VOS_TRACE_LEVEL vosDebugLevel;
5463 char logBuffer[LOG_SIZE];
5464 va_list marker;
5465
5466 /* getting proper Debug level */
5467 vosDebugLevel = getVosDebugLevel(loglevel);
5468
5469 /* extracting arguments from pstring */
5470 va_start( marker, pString );
5471 vsnprintf(logBuffer, LOG_SIZE, pString, marker);
5472
5473 VOS_TRACE(VOS_MODULE_ID_PMC, vosDebugLevel, "%s", logBuffer);
5474 va_end( marker );
5475}
5476
5477
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005478void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
Jeff Johnson295189b2012-06-20 16:38:30 -07005479{
5480#ifdef WLAN_DEBUG
5481 // Verify against current log level
5482 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
5483 return;
5484 else
5485 {
5486 va_list marker;
5487
5488 va_start( marker, pString ); /* Initialize variable arguments. */
5489
5490 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
5491
5492 va_end( marker ); /* Reset variable arguments. */
5493 }
5494#endif
5495}
Jeff Johnson295189b2012-06-20 16:38:30 -07005496
Jeff Johnson295189b2012-06-20 16:38:30 -07005497/* ---------------------------------------------------------------------------
5498 \fn sme_GetWcnssWlanCompiledVersion
5499 \brief This API returns the version of the WCNSS WLAN API with
5500 which the HOST driver was built
5501 \param hHal - The handle returned by macOpen.
5502 \param pVersion - Points to the Version structure to be filled
5503 \return VOS_STATUS
5504 VOS_STATUS_E_INVAL - failure
5505 VOS_STATUS_SUCCESS success
5506 ---------------------------------------------------------------------------*/
5507VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
5508 tSirVersionType *pVersion)
5509{
5510 VOS_STATUS status = VOS_STATUS_SUCCESS;
5511 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5512 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
5513
5514 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5515 {
5516 if( pVersion != NULL )
5517 {
5518 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
5519 }
5520 else
5521 {
5522 status = VOS_STATUS_E_INVAL;
5523 }
5524 sme_ReleaseGlobalLock( &pMac->sme );
5525 }
5526
5527 return (status);
5528}
5529
5530
5531/* ---------------------------------------------------------------------------
5532 \fn sme_GetWcnssWlanReportedVersion
5533 \brief This API returns the version of the WCNSS WLAN API with
5534 which the WCNSS driver reports it was built
5535 \param hHal - The handle returned by macOpen.
5536 \param pVersion - Points to the Version structure to be filled
5537 \return VOS_STATUS
5538 VOS_STATUS_E_INVAL - failure
5539 VOS_STATUS_SUCCESS success
5540 ---------------------------------------------------------------------------*/
5541VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
5542 tSirVersionType *pVersion)
5543{
5544 VOS_STATUS status = VOS_STATUS_SUCCESS;
5545 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5546 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
5547
5548 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5549 {
5550 if( pVersion != NULL )
5551 {
5552 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
5553 }
5554 else
5555 {
5556 status = VOS_STATUS_E_INVAL;
5557 }
5558 sme_ReleaseGlobalLock( &pMac->sme );
5559 }
5560
5561 return (status);
5562}
5563
5564
5565/* ---------------------------------------------------------------------------
5566 \fn sme_GetWcnssSoftwareVersion
5567 \brief This API returns the version string of the WCNSS driver
5568 \param hHal - The handle returned by macOpen.
5569 \param pVersion - Points to the Version string buffer to be filled
5570 \param versionBufferSize - THe size of the Version string buffer
5571 \return VOS_STATUS
5572 VOS_STATUS_E_INVAL - failure
5573 VOS_STATUS_SUCCESS success
5574 ---------------------------------------------------------------------------*/
5575VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
5576 tANI_U8 *pVersion,
5577 tANI_U32 versionBufferSize)
5578{
5579 VOS_STATUS status = VOS_STATUS_SUCCESS;
5580 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5581 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
5582
5583 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5584 {
5585 if( pVersion != NULL )
5586 {
5587 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
5588 versionBufferSize);
5589 }
5590 else
5591 {
5592 status = VOS_STATUS_E_INVAL;
5593 }
5594 sme_ReleaseGlobalLock( &pMac->sme );
5595 }
5596
5597 return (status);
5598}
5599
5600
5601/* ---------------------------------------------------------------------------
5602 \fn sme_GetWcnssHardwareVersion
5603 \brief This API returns the version string of the WCNSS hardware
5604 \param hHal - The handle returned by macOpen.
5605 \param pVersion - Points to the Version string buffer to be filled
5606 \param versionBufferSize - THe size of the Version string buffer
5607 \return VOS_STATUS
5608 VOS_STATUS_E_INVAL - failure
5609 VOS_STATUS_SUCCESS success
5610 ---------------------------------------------------------------------------*/
5611VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
5612 tANI_U8 *pVersion,
5613 tANI_U32 versionBufferSize)
5614{
5615 VOS_STATUS status = VOS_STATUS_SUCCESS;
5616 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5617 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
5618
5619 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5620 {
5621 if( pVersion != NULL )
5622 {
5623 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
5624 versionBufferSize);
5625 }
5626 else
5627 {
5628 status = VOS_STATUS_E_INVAL;
5629 }
5630 sme_ReleaseGlobalLock( &pMac->sme );
5631 }
5632
5633 return (status);
5634}
Jeff Johnson4824d4c2013-02-12 14:23:57 -08005635
Jeff Johnson295189b2012-06-20 16:38:30 -07005636
5637#ifdef FEATURE_WLAN_WAPI
5638/* ---------------------------------------------------------------------------
5639 \fn sme_RoamSetBKIDCache
5640 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
5641 candidate list.
5642 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
5643 it is opened (by calling halOpen).
5644 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
5645 \param numItems - a variable that has the number of tBkidCacheInfo allocated
5646 when retruning, this is the number of items put into pBKIDCache
5647 \return eHalStatus - when fail, it usually means the buffer allocated is not
5648 big enough and pNumItems has the number of tBkidCacheInfo.
5649 ---------------------------------------------------------------------------*/
5650eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
5651 tANI_U32 numItems )
5652{
5653 eHalStatus status = eHAL_STATUS_FAILURE;
5654 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5655
5656 status = sme_AcquireGlobalLock( &pMac->sme );
5657 if ( HAL_STATUS_SUCCESS( status ) )
5658 {
5659 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
5660 sme_ReleaseGlobalLock( &pMac->sme );
5661 }
5662
5663 return (status);
5664}
5665
5666/* ---------------------------------------------------------------------------
5667 \fn sme_RoamGetBKIDCache
5668 \brief The SME API exposed to HDD to allow HDD to request SME to return its
5669 BKID cache.
5670 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
5671 it is opened (by calling halOpen).
5672 \param pNum - caller allocated memory that has the space of the number of
5673 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
5674 in SME cache.
5675 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
5676 upon return
5677 \return eHalStatus - when fail, it usually means the buffer allocated is not
5678 big enough.
5679 ---------------------------------------------------------------------------*/
5680eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
5681 tBkidCacheInfo *pBkidCache)
5682{
5683 eHalStatus status = eHAL_STATUS_FAILURE;
5684 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5685
5686 status = sme_AcquireGlobalLock( &pMac->sme );
5687 if ( HAL_STATUS_SUCCESS( status ) )
5688 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005689 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
5691 sme_ReleaseGlobalLock( &pMac->sme );
5692 }
5693
5694 return (status);
5695}
5696
5697/* ---------------------------------------------------------------------------
5698 \fn sme_RoamGetNumBKIDCache
5699 \brief The SME API exposed to HDD to allow HDD to request SME to return the
5700 number of BKID cache entries.
5701 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
5702 it is opened (by calling halOpen).
5703 \return tANI_U32 - the number of BKID cache entries.
5704 ---------------------------------------------------------------------------*/
5705tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
5706{
5707 eHalStatus status = eHAL_STATUS_FAILURE;
5708 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5709 tANI_U32 numBkidCache = 0;
5710
5711 status = sme_AcquireGlobalLock( &pMac->sme );
5712 if ( HAL_STATUS_SUCCESS( status ) )
5713 {
5714 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
5715 sme_ReleaseGlobalLock( &pMac->sme );
5716 }
5717
5718 return (numBkidCache);
5719}
5720
5721/* ---------------------------------------------------------------------------
5722 \fn sme_ScanGetBKIDCandidateList
5723 \brief a wrapper function to return the BKID candidate list
5724 \param pBkidList - caller allocated buffer point to an array of
5725 tBkidCandidateInfo
5726 \param pNumItems - pointer to a variable that has the number of
5727 tBkidCandidateInfo allocated when retruning, this is
5728 either the number needed or number of items put into
5729 pPmkidList
5730 \return eHalStatus - when fail, it usually means the buffer allocated is not
5731 big enough and pNumItems
5732 has the number of tBkidCandidateInfo.
5733 \Note: pNumItems is a number of tBkidCandidateInfo,
5734 not sizeof(tBkidCandidateInfo) * something
5735 ---------------------------------------------------------------------------*/
5736eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
5737 tBkidCandidateInfo *pBkidList,
5738 tANI_U32 *pNumItems )
5739{
5740 eHalStatus status = eHAL_STATUS_FAILURE;
5741 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5742
5743 status = sme_AcquireGlobalLock( &pMac->sme );
5744 if ( HAL_STATUS_SUCCESS( status ) )
5745 {
5746 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
5747 sme_ReleaseGlobalLock( &pMac->sme );
5748 }
5749
5750 return (status);
5751}
5752#endif /* FEATURE_WLAN_WAPI */
5753
Jeff Johnsone7245742012-09-05 17:12:55 -07005754#ifdef FEATURE_OEM_DATA_SUPPORT
5755
5756/*****************************************************************************
5757 OEM DATA related modifications and function additions
5758 *****************************************************************************/
5759
5760/* ---------------------------------------------------------------------------
5761 \fn sme_getOemDataRsp
5762 \brief a wrapper function to obtain the OEM DATA RSP
5763 \param pOemDataRsp - A pointer to the response object
5764 \param pContext - a pointer passed in for the callback
5765 \return eHalStatus
5766 ---------------------------------------------------------------------------*/
5767eHalStatus sme_getOemDataRsp(tHalHandle hHal,
5768 tOemDataRsp **pOemDataRsp)
5769{
5770 eHalStatus status = eHAL_STATUS_SUCCESS;
5771 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5772
5773 do
5774 {
5775 //acquire the lock for the sme object
5776 status = sme_AcquireGlobalLock(&pMac->sme);
5777
5778 if(!HAL_STATUS_SUCCESS(status))
5779 {
5780 break;
5781 }
5782
5783 if(pMac->oemData.pOemDataRsp != NULL)
5784 {
5785 *pOemDataRsp = pMac->oemData.pOemDataRsp;
5786 }
5787 else
5788 {
5789 status = eHAL_STATUS_FAILURE;
5790 }
5791
5792 //release the lock for the sme object
5793 sme_ReleaseGlobalLock( &pMac->sme );
5794
5795 } while(0);
5796
5797 return status;
5798}
5799
5800/* ---------------------------------------------------------------------------
5801 \fn sme_OemDataReq
5802 \brief a wrapper function for OEM DATA REQ
5803 \param sessionId - session id to be used.
5804 \param pOemDataReqId - pointer to an object to get back the request ID
5805 \param callback - a callback function that is called upon finish
5806 \param pContext - a pointer passed in for the callback
5807 \return eHalStatus
5808 ---------------------------------------------------------------------------*/
5809eHalStatus sme_OemDataReq(tHalHandle hHal,
5810 tANI_U8 sessionId,
5811 tOemDataReqConfig *pOemDataReqConfig,
5812 tANI_U32 *pOemDataReqID,
5813 oemData_OemDataReqCompleteCallback callback,
5814 void *pContext)
5815{
5816 eHalStatus status = eHAL_STATUS_SUCCESS;
5817 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5818
5819 do
5820 {
5821 //acquire the lock for the sme object
5822 status = sme_AcquireGlobalLock(&pMac->sme);
5823 if(HAL_STATUS_SUCCESS(status))
5824 {
5825 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
5826
5827 if(pOemDataReqID)
5828 {
5829 *pOemDataReqID = lOemDataReqId;
5830 }
5831 else
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08005832 {
5833 sme_ReleaseGlobalLock( &pMac->sme );
5834 return eHAL_STATUS_FAILURE;
5835 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005836
5837 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
5838
5839 //release the lock for the sme object
5840 sme_ReleaseGlobalLock( &pMac->sme );
5841 }
5842 } while(0);
5843
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005844 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07005845
5846 return(status);
5847}
5848
5849#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005850
5851/*--------------------------------------------------------------------------
5852
5853 \brief sme_OpenSession() - Open a session for scan/roam operation.
5854
5855 This is a synchronous API.
5856
5857
5858 \param hHal - The handle returned by macOpen.
5859 \param callback - A pointer to the function caller specifies for roam/connect status indication
5860 \param pContext - The context passed with callback
5861 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
5862 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
5863
5864 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
5865
5866 Other status means SME is failed to open the session.
5867 eHAL_STATUS_RESOURCES - no more session available.
5868 \sa
5869
5870 --------------------------------------------------------------------------*/
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005871eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback,
5872 void *pContext, tANI_U8 *pSelfMacAddr,
5873 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005874{
5875 eHalStatus status;
5876 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5877
5878 if( NULL == pbSessionId )
5879 {
5880 status = eHAL_STATUS_INVALID_PARAMETER;
5881 }
5882 else
5883 {
5884 status = sme_AcquireGlobalLock( &pMac->sme );
5885 if ( HAL_STATUS_SUCCESS( status ) )
5886 {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005887 status = csrRoamOpenSession(pMac, callback, pContext,
5888 pSelfMacAddr, pbSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005889
5890 sme_ReleaseGlobalLock( &pMac->sme );
5891 }
5892 }
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005893 if( NULL != pbSessionId )
5894 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5895 TRACE_CODE_SME_RX_HDD_OPEN_SESSION,*pbSessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005896
5897 return ( status );
5898}
5899
5900
5901/*--------------------------------------------------------------------------
5902
5903 \brief sme_CloseSession() - Open a session for scan/roam operation.
5904
5905 This is a synchronous API.
5906
5907
5908 \param hHal - The handle returned by macOpen.
5909
5910 \param sessionId - A previous opened session's ID.
5911
5912 \return eHAL_STATUS_SUCCESS - session is closed.
5913
5914 Other status means SME is failed to open the session.
5915 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
5916 \sa
5917
5918 --------------------------------------------------------------------------*/
5919eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
5920 csrRoamSessionCloseCallback callback, void *pContext)
5921{
5922 eHalStatus status;
5923 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5924
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07005925 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
5926 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 status = sme_AcquireGlobalLock( &pMac->sme );
5928 if ( HAL_STATUS_SUCCESS( status ) )
5929 {
5930 status = csrRoamCloseSession( pMac, sessionId, FALSE,
5931 callback, pContext );
5932
5933 sme_ReleaseGlobalLock( &pMac->sme );
5934 }
5935
5936 return ( status );
5937}
5938
Jeff Johnson295189b2012-06-20 16:38:30 -07005939/* ---------------------------------------------------------------------------
5940
5941 \fn sme_RoamUpdateAPWPSIE
5942
5943 \brief To update AP's WPS IE. This function should be called after SME AP session is created
5944 This is an asynchronous API.
5945
5946 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
5947
5948 \return eHalStatus – SUCCESS –
5949
5950 FAILURE or RESOURCES – The API finished and failed.
5951
5952 -------------------------------------------------------------------------------*/
5953eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
5954{
5955
5956 eHalStatus status = eHAL_STATUS_FAILURE;
5957 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5958
5959 status = sme_AcquireGlobalLock( &pMac->sme );
5960 if ( HAL_STATUS_SUCCESS( status ) )
5961 {
5962
5963 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
5964
5965 sme_ReleaseGlobalLock( &pMac->sme );
5966 }
5967
5968 return (status);
5969}
5970/* ---------------------------------------------------------------------------
5971
5972 \fn sme_RoamUpdateAPWPARSNIEs
5973
5974 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
5975 This is an asynchronous API.
5976
5977 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
5978
5979 \return eHalStatus – SUCCESS –
5980
5981 FAILURE or RESOURCES – The API finished and failed.
5982
5983 -------------------------------------------------------------------------------*/
5984eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
5985{
5986
5987 eHalStatus status = eHAL_STATUS_FAILURE;
5988 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5989
5990 status = sme_AcquireGlobalLock( &pMac->sme );
5991 if ( HAL_STATUS_SUCCESS( status ) )
5992 {
5993
5994 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
5995
5996 sme_ReleaseGlobalLock( &pMac->sme );
5997 }
5998
5999 return (status);
6000}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08006001/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07006002
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08006003 \fn sme_ChangeMCCBeaconInterval
6004
6005 \brief To update P2P-GO beaconInterval. This function should be called after
6006 disassociating all the station is done
6007 This is an asynchronous API.
6008
6009 \param
6010
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006011 \return eHalStatus SUCCESS
6012 FAILURE or RESOURCES
6013 The API finished and failed.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08006014
6015 -------------------------------------------------------------------------------*/
6016eHalStatus sme_ChangeMCCBeaconInterval(tHalHandle hHal, tANI_U8 sessionId)
6017{
6018 eHalStatus status = eHAL_STATUS_FAILURE;
6019 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6020
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006021 smsLog(pMac, LOG1, FL("Update Beacon PARAMS "));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08006022 status = sme_AcquireGlobalLock( &pMac->sme );
6023 if ( HAL_STATUS_SUCCESS( status ) )
6024 {
6025 status = csrSendChngMCCBeaconInterval( pMac, sessionId);
6026 sme_ReleaseGlobalLock( &pMac->sme );
6027 }
6028 return (status);
6029}
Jeff Johnson295189b2012-06-20 16:38:30 -07006030
6031/*-------------------------------------------------------------------------------*
6032
6033 \fn sme_sendBTAmpEvent
6034
6035 \brief to receive the coex priorty request from BT-AMP PAL
6036 and send the BT_AMP link state to HAL
6037
6038 \param btAmpEvent - btAmpEvent
6039
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006040 \return eHalStatus: SUCCESS : BTAmp event successfully sent to HAL
Jeff Johnson295189b2012-06-20 16:38:30 -07006041
6042 FAILURE: API failed
6043
6044-------------------------------------------------------------------------------*/
6045
6046eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
6047{
6048 vos_msg_t msg;
6049 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
6050 eHalStatus status = eHAL_STATUS_FAILURE;
6051
6052 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tpSmeBtAmpEvent));
6053 if (NULL == ptrSmeBtAmpEvent)
6054 {
6055 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006056 "Not able to allocate memory for BTAmp event", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 return status;
6058 }
6059
6060 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
6061 msg.type = WDA_SIGNAL_BTAMP_EVENT;
6062 msg.reserved = 0;
6063 msg.bodyptr = ptrSmeBtAmpEvent;
6064
6065 //status = halFW_SendBTAmpEventMesg(pMac, event);
6066
6067 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6068 {
6069 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006070 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 vos_mem_free(ptrSmeBtAmpEvent);
6072 return status;
6073 }
6074
6075 return eHAL_STATUS_SUCCESS;
6076
6077}
6078
6079/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05306080 \fn smeIssueFastRoamNeighborAPEvent
6081 \brief API to trigger fast BSS roam independent of RSSI triggers
6082 \param hHal - The handle returned by macOpen.
6083 \param bssid - Pointer to the BSSID to roam to.
6084 \param fastRoamTrig - Trigger to Scan or roam
6085 \return eHalStatus
6086 ---------------------------------------------------------------------------*/
6087eHalStatus smeIssueFastRoamNeighborAPEvent (tHalHandle hHal,
6088 tANI_U8 *bssid,
6089 tSmeFastRoamTrigger fastRoamTrig)
6090{
6091 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6092 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
6093 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6094 eHalStatus status = eHAL_STATUS_SUCCESS;
6095
6096 status = sme_AcquireGlobalLock( &pMac->sme );
6097 if ( HAL_STATUS_SUCCESS( status ) )
6098 {
6099 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6100 "%s: invoked", __func__);
6101
6102 if (eSME_ROAM_TRIGGER_SCAN == fastRoamTrig)
6103 {
6104 smsLog(pMac, LOG1, FL("CFG Channel list scan... "));
6105 pNeighborRoamInfo->cfgRoamEn = eSME_ROAM_TRIGGER_SCAN;
6106 vos_mem_copy((void *)(&pNeighborRoamInfo->cfgRoambssId),
6107 (void *)bssid, sizeof(tSirMacAddr));
6108 smsLog(pMac, LOG1, "Calling Roam Look Up down Event BSSID %x %x %x %x %x %x",
6109 pNeighborRoamInfo->cfgRoambssId[0], pNeighborRoamInfo->cfgRoambssId[1],
6110 pNeighborRoamInfo->cfgRoambssId[2], pNeighborRoamInfo->cfgRoambssId[3],
6111 pNeighborRoamInfo->cfgRoambssId[4], pNeighborRoamInfo->cfgRoambssId[5]);
6112
6113 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
6114 if (VOS_STATUS_SUCCESS != vosStatus)
6115 {
6116 smsLog(pMac, LOGE,
6117 FL("CFG Channel list scan state failed with status %d "),
6118 vosStatus);
6119 }
6120 }
6121 else if (eSME_ROAM_TRIGGER_FAST_ROAM == fastRoamTrig)
6122 {
6123 vos_mem_copy((void *)(&pNeighborRoamInfo->cfgRoambssId),
6124 (void *)bssid, sizeof(tSirMacAddr));
6125 pNeighborRoamInfo->cfgRoamEn = eSME_ROAM_TRIGGER_FAST_ROAM;
6126 smsLog(pMac, LOG1, "Roam to BSSID %x-%x-%x-%x-%x-%x",
6127 pNeighborRoamInfo->cfgRoambssId[0], pNeighborRoamInfo->cfgRoambssId[1],
6128 pNeighborRoamInfo->cfgRoambssId[2], pNeighborRoamInfo->cfgRoambssId[3],
6129 pNeighborRoamInfo->cfgRoambssId[4], pNeighborRoamInfo->cfgRoambssId[5]);
6130
6131 vosStatus = csrNeighborRoamReassocIndCallback(pMac->roam.gVosContext,
6132 0,
6133 pMac,
6134 0);
6135
6136 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6137 {
6138 smsLog(pMac,
6139 LOGE,
6140 FL(" Call to csrNeighborRoamReassocIndCallback failed, status = %d"),
6141 vosStatus);
6142 }
6143 }
6144 sme_ReleaseGlobalLock( &pMac->sme );
6145 }
6146 return vosStatus;
6147}
6148/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 \fn sme_SetHostOffload
6150 \brief API to set the host offload feature.
6151 \param hHal - The handle returned by macOpen.
6152 \param pRequest - Pointer to the offload request.
6153 \return eHalStatus
6154 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07006155eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
6156 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07006157{
6158 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07006159 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006160
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006161 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6162 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6164 {
6165#ifdef WLAN_NS_OFFLOAD
6166 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
6167 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006168 status = pmcSetNSOffload( hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 }
6170 else
6171#endif //WLAN_NS_OFFLOAD
6172 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006173 status = pmcSetHostOffload (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 }
6175 sme_ReleaseGlobalLock( &pMac->sme );
6176 }
6177
6178 return (status);
6179}
6180
6181#ifdef WLAN_FEATURE_GTK_OFFLOAD
6182/* ---------------------------------------------------------------------------
6183 \fn sme_SetGTKOffload
6184 \brief API to set GTK offload information.
6185 \param hHal - The handle returned by macOpen.
6186 \param pRequest - Pointer to the GTK offload request.
6187 \return eHalStatus
6188 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006189eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest,
6190 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006191{
6192 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6193 eHalStatus status;
6194
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006195 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6196 TRACE_CODE_SME_RX_HDD_SET_GTKOFFLOAD, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6198 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006199 status = pmcSetGTKOffload( hHal, pRequest, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 sme_ReleaseGlobalLock( &pMac->sme );
6201 }
6202
6203 return (status);
6204}
6205
6206/* ---------------------------------------------------------------------------
6207 \fn sme_GetGTKOffload
6208 \brief API to get GTK offload information.
6209 \param hHal - The handle returned by macOpen.
6210 \param pRequest - Pointer to the GTK offload response.
6211 \return eHalStatus
6212 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006213eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
6214 void *callbackContext, tANI_U8 sessionId )
Jeff Johnson295189b2012-06-20 16:38:30 -07006215{
6216 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6217 eHalStatus status;
6218
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006219 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6220 TRACE_CODE_SME_RX_HDD_GET_GTKOFFLOAD, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6222 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006223 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 sme_ReleaseGlobalLock( &pMac->sme );
6225 }
6226
6227 return (status);
6228}
6229#endif // WLAN_FEATURE_GTK_OFFLOAD
6230
6231/* ---------------------------------------------------------------------------
6232 \fn sme_SetKeepAlive
6233 \brief API to set the Keep Alive feature.
6234 \param hHal - The handle returned by macOpen.
6235 \param pRequest - Pointer to the Keep Alive request.
6236 \return eHalStatus
6237 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07006238eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
6239 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07006240{
6241 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6242 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6244 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006245 status = pmcSetKeepAlive (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 sme_ReleaseGlobalLock( &pMac->sme );
6247 }
6248
6249 return (status);
6250}
6251
6252#ifdef FEATURE_WLAN_SCAN_PNO
6253/* ---------------------------------------------------------------------------
6254 \fn sme_SetPreferredNetworkList
6255 \brief API to set the Preferred Network List Offload feature.
6256 \param hHal - The handle returned by macOpen.
6257 \param pRequest - Pointer to the offload request.
6258 \return eHalStatus
6259 ---------------------------------------------------------------------------*/
6260eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
6261{
6262 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6263 eHalStatus status;
6264
6265 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6266 {
6267 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
6268 sme_ReleaseGlobalLock( &pMac->sme );
6269 }
6270
6271 return (status);
6272}
6273
6274eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
6275{
6276 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6277 eHalStatus status;
6278
6279 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6280 {
6281 pmcSetRssiFilter(hHal, rssiThreshold);
6282 sme_ReleaseGlobalLock( &pMac->sme );
6283 }
6284
6285 return (status);
6286}
6287
6288#endif // FEATURE_WLAN_SCAN_PNO
6289
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006290eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams, tANI_BOOLEAN forced)
Jeff Johnson295189b2012-06-20 16:38:30 -07006291{
6292 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6293 eHalStatus status;
6294
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006295 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6296 TRACE_CODE_SME_RX_HDD_SET_POWERPARAMS, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6298 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006299 pmcSetPowerParams(hHal, pwParams, forced);
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 sme_ReleaseGlobalLock( &pMac->sme );
6301 }
6302
6303 return (status);
6304}
6305
6306/* ---------------------------------------------------------------------------
6307 \fn sme_AbortMacScan
6308 \brief API to cancel MAC scan.
6309 \param hHal - The handle returned by macOpen.
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306310 \param sessionId - sessionId on which we need to abort scan.
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 \return VOS_STATUS
6312 VOS_STATUS_E_FAILURE - failure
6313 VOS_STATUS_SUCCESS success
6314 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306315eHalStatus sme_AbortMacScan(tHalHandle hHal, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006316{
6317 eHalStatus status;
6318 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6319
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006320 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6321 TRACE_CODE_SME_RX_HDD_ABORT_MACSCAN, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 status = sme_AcquireGlobalLock( &pMac->sme );
6323 if ( HAL_STATUS_SUCCESS( status ) )
6324 {
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306325 status = csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006326
6327 sme_ReleaseGlobalLock( &pMac->sme );
6328 }
6329
6330 return ( status );
6331}
6332
6333/* ----------------------------------------------------------------------------
6334 \fn sme_GetOperationChannel
6335 \brief API to get current channel on which STA is parked
6336 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006337 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 \returns eHAL_STATUS_SUCCESS
6339 eHAL_STATUS_FAILURE
6340-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006341eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006342{
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6344 tCsrRoamSession *pSession;
6345
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006346 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006348 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006349
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006350 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
6351 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006352 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006353 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
6354 {
6355 *pChannel =pSession->connectedProfile.operationChannel;
6356 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 }
6358 }
6359 return eHAL_STATUS_FAILURE;
6360}// sme_GetOperationChannel ends here
6361
Jeff Johnson295189b2012-06-20 16:38:30 -07006362/* ---------------------------------------------------------------------------
6363
6364 \fn sme_RegisterMgtFrame
6365
6366 \brief To register managment frame of specified type and subtype.
6367 \param frameType - type of the frame that needs to be passed to HDD.
6368 \param matchData - data which needs to be matched before passing frame
6369 to HDD.
6370 \param matchDataLen - Length of matched data.
6371 \return eHalStatus
6372 -------------------------------------------------------------------------------*/
6373eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
6374 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
6375{
6376 eHalStatus status = eHAL_STATUS_SUCCESS;
6377 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6378
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006379 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6380 TRACE_CODE_SME_RX_HDD_REGISTER_MGMTFR, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6382 {
6383 tSirRegisterMgmtFrame *pMsg;
6384 tANI_U16 len;
6385 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006386
6387 if(!pSession)
6388 {
6389 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08006390 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006391 return eHAL_STATUS_FAILURE;
6392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006393
6394 if( !pSession->sessionActive )
6395 {
6396 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006397 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 sme_ReleaseGlobalLock( &pMac->sme );
6399 return eHAL_STATUS_FAILURE;
6400 }
6401
6402 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
6403
Kiet Lam64c1b492013-07-12 13:56:44 +05306404 pMsg = vos_mem_malloc(len);
6405 if ( NULL == pMsg )
6406 status = eHAL_STATUS_FAILURE;
6407 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306409 vos_mem_set(pMsg, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
6411 pMsg->length = len;
6412 pMsg->sessionId = sessionId;
6413 pMsg->registerFrame = VOS_TRUE;
6414 pMsg->frameType = frameType;
6415 pMsg->matchLen = matchLen;
Kiet Lam64c1b492013-07-12 13:56:44 +05306416 vos_mem_copy(pMsg->matchData, matchData, matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 status = palSendMBMessage(pMac->hHdd, pMsg);
6418 }
6419 sme_ReleaseGlobalLock( &pMac->sme );
6420 }
6421 return status;
6422}
6423
6424/* ---------------------------------------------------------------------------
6425
6426 \fn sme_DeregisterMgtFrame
6427
6428 \brief To De-register managment frame of specified type and subtype.
6429 \param frameType - type of the frame that needs to be passed to HDD.
6430 \param matchData - data which needs to be matched before passing frame
6431 to HDD.
6432 \param matchDataLen - Length of matched data.
6433 \return eHalStatus
6434 -------------------------------------------------------------------------------*/
6435eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
6436 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
6437{
6438 eHalStatus status = eHAL_STATUS_SUCCESS;
6439 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6440
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006441 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6442 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6444 {
6445 tSirRegisterMgmtFrame *pMsg;
6446 tANI_U16 len;
6447 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006448
6449 if(!pSession)
6450 {
6451 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08006452 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006453 return eHAL_STATUS_FAILURE;
6454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006455
6456 if( !pSession->sessionActive )
6457 {
6458 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006459 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 sme_ReleaseGlobalLock( &pMac->sme );
6461 return eHAL_STATUS_FAILURE;
6462 }
6463
6464 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
6465
Kiet Lam64c1b492013-07-12 13:56:44 +05306466 pMsg = vos_mem_malloc(len);
6467 if ( NULL == pMsg )
6468 status = eHAL_STATUS_FAILURE;
6469 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306471 vos_mem_set(pMsg, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
6473 pMsg->length = len;
6474 pMsg->registerFrame = VOS_FALSE;
6475 pMsg->frameType = frameType;
6476 pMsg->matchLen = matchLen;
Kiet Lam64c1b492013-07-12 13:56:44 +05306477 vos_mem_copy(pMsg->matchData, matchData, matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 status = palSendMBMessage(pMac->hHdd, pMsg);
6479 }
6480 sme_ReleaseGlobalLock( &pMac->sme );
6481 }
6482 return status;
6483}
6484
6485/* ---------------------------------------------------------------------------
6486 \fn sme_RemainOnChannel
6487 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
6488 \param hHal - The handle returned by macOpen.
6489 \param pRequest - channel
6490 \param duration - duration in ms
6491 \param callback - HDD registered callback to process reaminOnChannelRsp
6492 \param context - HDD Callback param
6493 \return eHalStatus
6494 ---------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07006495eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
6496 tANI_U8 channel, tANI_U32 duration,
Gopichand Nakkala924e4552013-05-08 19:18:14 +05306497 remainOnChanCallback callback,
6498 void *pContext,
6499 tANI_U8 isP2PProbeReqAllowed)
Jeff Johnson295189b2012-06-20 16:38:30 -07006500{
6501 eHalStatus status = eHAL_STATUS_SUCCESS;
6502 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6503
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006504 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6505 TRACE_CODE_SME_RX_HDD_REMAIN_ONCHAN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6507 {
Gopichand Nakkala924e4552013-05-08 19:18:14 +05306508 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext,
6509 isP2PProbeReqAllowed
Jeff Johnson295189b2012-06-20 16:38:30 -07006510#ifdef WLAN_FEATURE_P2P_INTERNAL
6511 , eP2PRemainOnChnReasonUnknown
6512#endif
6513 );
6514 sme_ReleaseGlobalLock( &pMac->sme );
6515 }
6516 return(status);
6517}
6518
6519/* ---------------------------------------------------------------------------
6520 \fn sme_ReportProbeReq
6521 \brief API to enable/disable forwarding of probeReq to apps in p2p.
6522 \param hHal - The handle returned by macOpen.
6523 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
6524 \return eHalStatus
6525 ---------------------------------------------------------------------------*/
6526
6527#ifndef WLAN_FEATURE_CONCURRENT_P2P
6528eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
6529{
6530 eHalStatus status = eHAL_STATUS_SUCCESS;
6531 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6532
6533 do
6534 {
6535 //acquire the lock for the sme object
6536 status = sme_AcquireGlobalLock(&pMac->sme);
6537 if(HAL_STATUS_SUCCESS(status))
6538 {
6539 /* call set in context */
6540 pMac->p2pContext.probeReqForwarding = flag;
6541 //release the lock for the sme object
6542 sme_ReleaseGlobalLock( &pMac->sme );
6543 }
6544 } while(0);
6545
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006546 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006547
6548 return(status);
6549}
6550
6551/* ---------------------------------------------------------------------------
6552 \fn sme_updateP2pIe
6553 \brief API to set the P2p Ie in p2p context
6554 \param hHal - The handle returned by macOpen.
6555 \param p2pIe - Ptr to p2pIe from HDD.
6556 \param p2pIeLength: length of p2pIe
6557 \return eHalStatus
6558 ---------------------------------------------------------------------------*/
6559
6560eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
6561{
6562 eHalStatus status = eHAL_STATUS_SUCCESS;
6563 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6564
6565 //acquire the lock for the sme object
6566 status = sme_AcquireGlobalLock(&pMac->sme);
6567 if(HAL_STATUS_SUCCESS(status))
6568 {
6569 if(NULL != pMac->p2pContext.probeRspIe){
6570 vos_mem_free(pMac->p2pContext.probeRspIe);
6571 pMac->p2pContext.probeRspIeLength = 0;
6572 }
6573
6574 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
6575 if (NULL == pMac->p2pContext.probeRspIe)
6576 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006577 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 pMac->p2pContext.probeRspIeLength = 0;
6579 status = eHAL_STATUS_FAILURE;
6580 }
6581 else
6582 {
6583 pMac->p2pContext.probeRspIeLength = p2pIeLength;
6584
6585 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
6586 pMac->p2pContext.probeRspIe,
6587 pMac->p2pContext.probeRspIeLength );
6588 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
6589 p2pIeLength);
6590 }
6591
6592 //release the lock for the sme object
6593 sme_ReleaseGlobalLock( &pMac->sme );
6594 }
6595
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006596 smsLog(pMac, LOG2, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006597
6598 return(status);
6599}
6600#endif
6601
6602/* ---------------------------------------------------------------------------
6603 \fn sme_sendAction
6604 \brief API to send action frame from supplicant.
6605 \param hHal - The handle returned by macOpen.
6606 \return eHalStatus
6607 ---------------------------------------------------------------------------*/
6608
6609eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07006610 const tANI_U8 *pBuf, tANI_U32 len,
6611 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07006612{
6613 eHalStatus status = eHAL_STATUS_SUCCESS;
6614 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6615
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006616 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6617 TRACE_CODE_SME_RX_HDD_SEND_ACTION, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 //acquire the lock for the sme object
6619 status = sme_AcquireGlobalLock(&pMac->sme);
6620 if(HAL_STATUS_SUCCESS(status))
6621 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006622 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07006623 //release the lock for the sme object
6624 sme_ReleaseGlobalLock( &pMac->sme );
6625 }
6626
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006627 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006628
6629 return(status);
6630}
6631
6632eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
6633{
6634 eHalStatus status = eHAL_STATUS_SUCCESS;
6635 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6636
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006637 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6638 TRACE_CODE_SME_RX_HDD_CANCEL_REMAIN_ONCHAN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6640 {
6641 status = p2pCancelRemainOnChannel (hHal, sessionId);
6642 sme_ReleaseGlobalLock( &pMac->sme );
6643 }
6644 return(status);
6645}
6646
6647//Power Save Related
6648eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
6649{
6650 eHalStatus status = eHAL_STATUS_SUCCESS;
6651 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6652
6653 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6654 {
6655 status = p2pSetPs (hHal, data);
6656 sme_ReleaseGlobalLock( &pMac->sme );
6657 }
6658 return(status);
6659}
6660
Jeff Johnson295189b2012-06-20 16:38:30 -07006661
6662/* ---------------------------------------------------------------------------
6663
6664 \fn sme_ConfigureRxpFilter
6665
6666 \brief
6667 SME will pass this request to lower mac to set/reset the filter on RXP for
6668 multicast & broadcast traffic.
6669
6670 \param
6671
6672 hHal - The handle returned by macOpen.
6673
6674 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
6675 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
6676 on this param. In future we can use this as a mask to set various types of
6677 filters as suggested below:
6678 FILTER_ALL_MULTICAST:
6679 FILTER_ALL_BROADCAST:
6680 FILTER_ALL_MULTICAST_BROADCAST:
6681
6682
6683 \return eHalStatus
6684
6685
6686--------------------------------------------------------------------------- */
6687eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
6688 tpSirWlanSetRxpFilters wlanRxpFilterParam)
6689{
6690 eHalStatus status = eHAL_STATUS_SUCCESS;
6691 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6692 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6693 vos_msg_t vosMessage;
6694
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006695 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6696 TRACE_CODE_SME_RX_HDD_CONFIG_RXPFIL, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006697 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6698 {
6699 /* serialize the req through MC thread */
6700 vosMessage.bodyptr = wlanRxpFilterParam;
6701 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
6702 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6703 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6704 {
6705 status = eHAL_STATUS_FAILURE;
6706 }
6707 sme_ReleaseGlobalLock( &pMac->sme );
6708 }
6709 return(status);
6710}
6711
Jeff Johnson295189b2012-06-20 16:38:30 -07006712/* ---------------------------------------------------------------------------
6713
6714 \fn sme_ConfigureSuspendInd
6715
6716 \brief
6717 SME will pass this request to lower mac to Indicate that the wlan needs to
6718 be suspended
6719
6720 \param
6721
6722 hHal - The handle returned by macOpen.
6723
6724 wlanSuspendParam- Depicts the wlan suspend params
6725
6726
6727 \return eHalStatus
6728
6729
6730--------------------------------------------------------------------------- */
6731eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
6732 tpSirWlanSuspendParam wlanSuspendParam)
6733{
6734 eHalStatus status = eHAL_STATUS_SUCCESS;
6735 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6736 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6737 vos_msg_t vosMessage;
6738
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006739 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6740 TRACE_CODE_SME_RX_HDD_CONFIG_SUSPENDIND, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6742 {
6743 /* serialize the req through MC thread */
6744 vosMessage.bodyptr = wlanSuspendParam;
6745 vosMessage.type = WDA_WLAN_SUSPEND_IND;
6746 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6747 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6748 {
6749 status = eHAL_STATUS_FAILURE;
6750 }
6751 sme_ReleaseGlobalLock( &pMac->sme );
6752 }
6753 return(status);
6754}
6755
6756/* ---------------------------------------------------------------------------
6757
6758 \fn sme_ConfigureResumeReq
6759
6760 \brief
6761 SME will pass this request to lower mac to Indicate that the wlan needs to
6762 be Resumed
6763
6764 \param
6765
6766 hHal - The handle returned by macOpen.
6767
6768 wlanResumeParam- Depicts the wlan resume params
6769
6770
6771 \return eHalStatus
6772
6773
6774--------------------------------------------------------------------------- */
6775eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
6776 tpSirWlanResumeParam wlanResumeParam)
6777{
6778 eHalStatus status = eHAL_STATUS_SUCCESS;
6779 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6780 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6781 vos_msg_t vosMessage;
6782
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07006783 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
6784 TRACE_CODE_SME_RX_HDD_CONFIG_RESUMEREQ, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6786 {
6787 /* serialize the req through MC thread */
6788 vosMessage.bodyptr = wlanResumeParam;
6789 vosMessage.type = WDA_WLAN_RESUME_REQ;
6790 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6791 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6792 {
6793 status = eHAL_STATUS_FAILURE;
6794 }
6795 sme_ReleaseGlobalLock( &pMac->sme );
6796 }
6797 return(status);
6798}
6799
Jeff Johnson295189b2012-06-20 16:38:30 -07006800/* ---------------------------------------------------------------------------
6801
6802 \fn sme_GetInfraSessionId
6803
6804 \brief To get the session ID for infra session, if connected
6805 This is a synchronous API.
6806
6807 \param hHal - The handle returned by macOpen.
6808
6809 \return sessionid, -1 if infra session is not connected
6810
6811 -------------------------------------------------------------------------------*/
6812tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
6813{
6814 eHalStatus status = eHAL_STATUS_FAILURE;
6815 tANI_S8 sessionid = -1;
6816 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6817
6818 status = sme_AcquireGlobalLock( &pMac->sme );
6819 if ( HAL_STATUS_SUCCESS( status ) )
6820 {
6821
6822 sessionid = csrGetInfraSessionId( pMac);
6823
6824 sme_ReleaseGlobalLock( &pMac->sme );
6825 }
6826
6827 return (sessionid);
6828}
6829
6830/* ---------------------------------------------------------------------------
6831
6832 \fn sme_GetInfraOperationChannel
6833
6834 \brief To get the operating channel for infra session, if connected
6835 This is a synchronous API.
6836
6837 \param hHal - The handle returned by macOpen.
6838 \param sessionId - the sessionId returned by sme_OpenSession.
6839
6840 \return operating channel, 0 if infra session is not connected
6841
6842 -------------------------------------------------------------------------------*/
6843tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
6844{
6845 eHalStatus status = eHAL_STATUS_FAILURE;
6846 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6847 tANI_U8 channel = 0;
6848 status = sme_AcquireGlobalLock( &pMac->sme );
6849 if ( HAL_STATUS_SUCCESS( status ) )
6850 {
6851
6852 channel = csrGetInfraOperationChannel( pMac, sessionId);
6853
6854 sme_ReleaseGlobalLock( &pMac->sme );
6855 }
6856
6857 return (channel);
6858}
6859
6860//This routine will return poerating channel on which other BSS is operating to be used for concurrency mode.
6861//If other BSS is not up or not connected it will return 0
6862tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
6863{
6864 eHalStatus status = eHAL_STATUS_FAILURE;
6865 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6866 tANI_U8 channel = 0;
6867 status = sme_AcquireGlobalLock( &pMac->sme );
6868 if ( HAL_STATUS_SUCCESS( status ) )
6869 {
6870
6871 channel = csrGetConcurrentOperationChannel( pMac );
6872 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006873 " Other Concurrent Channel = %d", __func__,channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006874 sme_ReleaseGlobalLock( &pMac->sme );
6875 }
6876
6877 return (channel);
6878}
6879
6880#ifdef FEATURE_WLAN_SCAN_PNO
6881/******************************************************************************
6882*
6883* Name: sme_PreferredNetworkFoundInd
6884*
6885* Description:
6886* Invoke Preferred Network Found Indication
6887*
6888* Parameters:
6889* hHal - HAL handle for device
6890* pMsg - found network description
6891*
6892* Returns: eHalStatus
6893*
6894******************************************************************************/
6895eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
6896{
6897 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6898 eHalStatus status = eHAL_STATUS_SUCCESS;
6899 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
Srikant Kuppa066904f2013-05-07 13:56:02 -07006900 v_U8_t dumpSsId[SIR_MAC_MAX_SSID_LENGTH + 1];
6901 tANI_U8 ssIdLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006902
6903 if (NULL == pMsg)
6904 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006905 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 status = eHAL_STATUS_FAILURE;
6907 }
6908 else
6909 {
6910 if (pPrefNetworkFoundInd->ssId.length > 0)
6911 {
Srikant Kuppa066904f2013-05-07 13:56:02 -07006912 ssIdLength = CSR_MIN(SIR_MAC_MAX_SSID_LENGTH,
6913 pPrefNetworkFoundInd->ssId.length);
6914 vos_mem_copy(dumpSsId, pPrefNetworkFoundInd->ssId.ssId, ssIdLength);
6915 dumpSsId[ssIdLength] = 0;
6916 smsLog(pMac, LOG2, "%s:SSID=%s frame length %d",
6917 __func__, dumpSsId, pPrefNetworkFoundInd->frameLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006918
Srikant Kuppa066904f2013-05-07 13:56:02 -07006919 //Save the frame to scan result
6920 if (pPrefNetworkFoundInd->mesgLen > sizeof(tSirPrefNetworkFoundInd))
6921 {
6922 //we may have a frame
6923 status = csrScanSavePreferredNetworkFound(pMac,
6924 pPrefNetworkFoundInd);
6925 if (!HAL_STATUS_SUCCESS(status))
6926 {
6927 smsLog(pMac, LOGE, FL(" fail to save preferred network"));
6928 }
6929 }
6930 else
6931 {
6932 smsLog(pMac, LOGE, FL(" not enough data length %d needed %d"),
6933 pPrefNetworkFoundInd->mesgLen, sizeof(tSirPrefNetworkFoundInd));
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 }
6935
Srikant Kuppa066904f2013-05-07 13:56:02 -07006936 /* Call Preferred Netowrk Found Indication callback routine. */
6937 if (HAL_STATUS_SUCCESS(status) && (pMac->pmc.prefNetwFoundCB != NULL))
6938 {
6939 pMac->pmc.prefNetwFoundCB(
6940 pMac->pmc.preferredNetworkFoundIndCallbackContext,
6941 pPrefNetworkFoundInd);
6942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006943 }
6944 else
6945 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006946 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 status = eHAL_STATUS_FAILURE;
6948 }
6949 }
6950
6951
6952 return(status);
6953}
6954
6955#endif // FEATURE_WLAN_SCAN_PNO
6956
6957
6958eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
6959{
6960 eHalStatus status = eHAL_STATUS_FAILURE;
6961 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6962
6963 status = sme_AcquireGlobalLock( &pMac->sme );
6964 if ( HAL_STATUS_SUCCESS( status ) )
6965 {
6966 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
6967 sme_ReleaseGlobalLock( &pMac->sme );
6968 }
6969
6970 return (status);
6971}
6972
6973
6974/* ---------------------------------------------------------------------------
6975
6976 \fn sme_SetTxPerTracking
6977
6978 \brief Set Tx PER tracking configuration parameters
6979
6980 \param hHal - The handle returned by macOpen.
6981 \param pTxPerTrackingConf - Tx PER configuration parameters
6982
6983 \return eHalStatus
6984
6985 -------------------------------------------------------------------------------*/
6986eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
6987 void (*pCallbackfn) (void *pCallbackContext),
6988 void *pCallbackContext,
6989 tpSirTxPerTrackingParam pTxPerTrackingParam)
6990{
6991 vos_msg_t msg;
6992 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
6993 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6994
6995 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6996 {
6997 pMac->sme.pTxPerHitCallback = pCallbackfn;
6998 pMac->sme.pTxPerHitCbContext = pCallbackContext;
6999 sme_ReleaseGlobalLock( &pMac->sme );
7000 }
7001
7002 // free this memory in failure case or WDA request callback function
7003 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
7004 if (NULL == pTxPerTrackingParamReq)
7005 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007006 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 -07007007 return eHAL_STATUS_FAILURE;
7008 }
7009
Kiet Lam64c1b492013-07-12 13:56:44 +05307010 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam,
7011 sizeof(tSirTxPerTrackingParam));
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
7013 msg.reserved = 0;
7014 msg.bodyptr = pTxPerTrackingParamReq;
7015
7016 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
7017 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007018 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 -07007019 vos_mem_free(pTxPerTrackingParamReq);
7020 return eHAL_STATUS_FAILURE;
7021 }
7022
7023 return eHAL_STATUS_SUCCESS;
7024}
7025
7026/* ---------------------------------------------------------------------------
7027
7028 \fn sme_HandleChangeCountryCode
7029
7030 \brief Change Country code, Reg Domain and channel list
7031
7032 \details Country Code Priority
7033 0 = 11D > Configured Country > NV
7034 1 = Configured Country > 11D > NV
7035 If Supplicant country code is priority than 11d is disabled.
7036 If 11D is enabled, we update the country code after every scan.
7037 Hence when Supplicant country code is priority, we don't need 11D info.
7038 Country code from Supplicant is set as current courtry code.
7039 User can send reset command XX (instead of country code) to reset the
7040 country code to default values which is read from NV.
7041 In case of reset, 11D is enabled and default NV code is Set as current country code
7042 If 11D is priority,
7043 Than Supplicant country code code is set to default code. But 11D code is set as current country code
7044
7045 \param pMac - The handle returned by macOpen.
7046 \param pMsgBuf - MSG Buffer
7047
7048 \return eHalStatus
7049
7050 -------------------------------------------------------------------------------*/
7051eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
7052{
7053 eHalStatus status = eHAL_STATUS_SUCCESS;
7054 tAniChangeCountryCodeReq *pMsg;
Amar Singhal0d15bd52013-10-12 23:13:13 -07007055 v_REGDOMAIN_t domainIdIoctl;
Jeff Johnson295189b2012-06-20 16:38:30 -07007056 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7057 static uNvTables nvTables;
7058 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
7059
7060
7061 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
7062 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
7063 {
7064 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
7065
7066 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
7067
7068 /* read the country code from NV and use it */
7069 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
7070 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307071 vos_mem_copy(pMsg->countryCode,
7072 nvTables.defaultCountryTable.countryCode,
7073 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07007074 }
7075 else
7076 {
7077 status = eHAL_STATUS_FAILURE;
7078 return status;
7079 }
7080 }
7081 else
7082 {
7083 /* if Supplicant country code has priority, disable 11d */
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05307084 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
7085 pMsg->countryFromUserSpace)
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 {
7087 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
7088 }
7089 }
7090
7091 /* WEXT set country code means
7092 * 11D should be supported?
7093 * 11D Channel should be enforced?
7094 * 11D Country code should be matched?
7095 * 11D Reg Domian should be matched?
7096 * Country string changed */
7097 if(pMac->roam.configParam.Is11dSupportEnabled &&
7098 pMac->roam.configParam.fEnforce11dChannels &&
7099 pMac->roam.configParam.fEnforceCountryCodeMatch &&
7100 pMac->roam.configParam.fEnforceDefaultDomain &&
7101 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
7102 {
7103 /* All 11D related options are already enabled
7104 * Country string is not changed
7105 * Do not need do anything for country code change request */
7106 return eHAL_STATUS_SUCCESS;
7107 }
7108
7109 /* Set Current Country code and Current Regulatory domain */
7110 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
7111 if(eHAL_STATUS_SUCCESS != status)
7112 {
7113 /* Supplicant country code failed. So give 11D priority */
7114 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
7115 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
7116 return status;
7117 }
7118
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 /* overwrite the defualt country code */
Kiet Lam64c1b492013-07-12 13:56:44 +05307120 vos_mem_copy(pMac->scan.countryCodeDefault,
7121 pMac->scan.countryCodeCurrent,
7122 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07007123
7124 /* Get Domain ID from country code */
Kiet Lam6c583332013-10-14 05:37:09 +05307125 status = csrGetRegulatoryDomainForCountry(pMac,
7126 pMac->scan.countryCodeCurrent,
7127 (v_REGDOMAIN_t *) &domainIdIoctl,
7128 COUNTRY_QUERY);
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 if ( status != eHAL_STATUS_SUCCESS )
7130 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007131 smsLog( pMac, LOGE, FL(" fail to get regId %d"), domainIdIoctl );
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 return status;
7133 }
Tushnim Bhattacharyya796ffe82013-11-05 16:31:36 -08007134 else if (REGDOMAIN_WORLD == domainIdIoctl)
7135 {
7136 /* Supplicant country code is invalid, so we are on world mode now. So
7137 give 11D chance to update */
7138 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
7139 smsLog(pMac, LOG1, FL("Country Code unrecognized by driver"));
7140 }
7141
Jeff Johnson295189b2012-06-20 16:38:30 -07007142
7143 status = WDA_SetRegDomain(pMac, domainIdIoctl);
7144
7145 if ( status != eHAL_STATUS_SUCCESS )
7146 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007147 smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainIdIoctl );
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 return status;
7149 }
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07007150 else
7151 {
7152 //if 11d has priority, clear currentCountryBssid & countryCode11d to get
7153 //set again if we find AP with 11d info during scan
7154 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority)
7155 {
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007156 smsLog( pMac, LOGW, FL("Clearing currentCountryBssid, countryCode11d"));
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07007157 vos_mem_zero(&pMac->scan.currentCountryBssid, sizeof(tCsrBssid));
7158 vos_mem_zero( pMac->scan.countryCode11d, sizeof( pMac->scan.countryCode11d ) );
7159 }
7160 }
Kiet Lam6c583332013-10-14 05:37:09 +05307161#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 /* set to default domain ID */
7163 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
7164
7165 /* get the channels based on new cc */
7166 status = csrInitGetChannels( pMac );
7167
7168 if ( status != eHAL_STATUS_SUCCESS )
7169 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007170 smsLog( pMac, LOGE, FL(" fail to get Channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 return status;
7172 }
7173
7174 /* reset info based on new cc, and we are done */
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08007175 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Kiet Lam6c583332013-10-14 05:37:09 +05307176#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 if( pMsg->changeCCCallback )
7178 {
7179 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
7180 }
7181
7182 return eHAL_STATUS_SUCCESS;
7183}
7184
Amar Singhal0d15bd52013-10-12 23:13:13 -07007185/* ---------------------------------------------------------------------------
7186
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007187 \fn sme_HandleChangeCountryCodeByUser
Amar Singhal0d15bd52013-10-12 23:13:13 -07007188
7189 \brief Change Country code, Reg Domain and channel list
7190
7191 If Supplicant country code is priority than 11d is disabled.
7192 If 11D is enabled, we update the country code after every scan.
7193 Hence when Supplicant country code is priority, we don't need 11D info.
7194 Country code from Supplicant is set as current country code.
7195
7196 \param pMac - The handle returned by macOpen.
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007197 \param pMsg - Carrying new CC & domain set in kernel by user
Amar Singhal0d15bd52013-10-12 23:13:13 -07007198
7199 \return eHalStatus
7200
7201 -------------------------------------------------------------------------------*/
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007202eHalStatus sme_HandleChangeCountryCodeByUser(tpAniSirGlobal pMac,
7203 tAniGenericChangeCountryCodeReq *pMsg)
Amar Singhal0d15bd52013-10-12 23:13:13 -07007204{
7205 eHalStatus status = eHAL_STATUS_SUCCESS;
Amar Singhal0d15bd52013-10-12 23:13:13 -07007206 v_REGDOMAIN_t reg_domain_id;
Kiet Lam6c583332013-10-14 05:37:09 +05307207 v_BOOL_t is11dCountry = VOS_FALSE;
Amar Singhal0d15bd52013-10-12 23:13:13 -07007208
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007209 smsLog(pMac, LOG1, FL(" called"));
Amar Singhal0d15bd52013-10-12 23:13:13 -07007210 reg_domain_id = (v_REGDOMAIN_t)pMsg->domain_index;
7211
Kiet Lam6c583332013-10-14 05:37:09 +05307212 if (memcmp(pMsg->countryCode, pMac->scan.countryCode11d,
7213 VOS_COUNTRY_CODE_LEN) == 0)
7214 {
7215 is11dCountry = VOS_TRUE;
7216 }
Amar Singhal0d15bd52013-10-12 23:13:13 -07007217
Amar Singhal97a2d992013-11-19 10:58:07 -08007218 if ((!is11dCountry) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) &&
7219 (csrGetInfraSessionId(pMac) != -1 ))
7220 {
7221
7222 smsLog( pMac, LOGW, FL(" incorrect country being set, nullify this request"));
7223
7224 /* we have got a request for a country that should not have been added since the
7225 STA is associated; nullify this request */
7226 status = csrGetRegulatoryDomainForCountry(pMac,
7227 pMac->scan.countryCode11d,
7228 (v_REGDOMAIN_t *) &reg_domain_id,
7229 COUNTRY_IE);
7230
7231 return eHAL_STATUS_FAILURE;
7232 }
7233
Amar Singhal0d15bd52013-10-12 23:13:13 -07007234 /* if Supplicant country code has priority, disable 11d */
Kiet Lam6c583332013-10-14 05:37:09 +05307235 if (!is11dCountry && pMac->roam.configParam.fSupplicantCountryCodeHasPriority)
Amar Singhal0d15bd52013-10-12 23:13:13 -07007236 {
7237 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
7238 }
7239
7240 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent, pMsg->countryCode,
7241 WNI_CFG_COUNTRY_CODE_LEN);
7242
Amar Singhal0d15bd52013-10-12 23:13:13 -07007243 status = WDA_SetRegDomain(pMac, reg_domain_id);
7244
Kiet Lam6c583332013-10-14 05:37:09 +05307245 if (VOS_FALSE == is11dCountry )
7246 {
7247 /* overwrite the defualt country code */
7248 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
7249 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
7250 /* set to default domain ID */
7251 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
7252 }
7253
Amar Singhal0d15bd52013-10-12 23:13:13 -07007254 if ( status != eHAL_STATUS_SUCCESS )
7255 {
7256 smsLog( pMac, LOGE, FL(" fail to set regId %d"), reg_domain_id );
Kiet Lam6c583332013-10-14 05:37:09 +05307257 return status;
Amar Singhal0d15bd52013-10-12 23:13:13 -07007258 }
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07007259 else
7260 {
7261 //if 11d has priority, clear currentCountryBssid & countryCode11d to get
7262 //set again if we find AP with 11d info during scan
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007263 if((!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) &&
7264 (VOS_FALSE == is11dCountry ))
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07007265 {
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007266 smsLog( pMac, LOGW, FL("Clearing currentCountryBssid, countryCode11d"));
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07007267 vos_mem_zero(&pMac->scan.currentCountryBssid, sizeof(tCsrBssid));
7268 vos_mem_zero( pMac->scan.countryCode11d, sizeof( pMac->scan.countryCode11d ) );
7269 }
7270 }
Amar Singhal0d15bd52013-10-12 23:13:13 -07007271
Amar Singhal0d15bd52013-10-12 23:13:13 -07007272 /* get the channels based on new cc */
7273 status = csrInitGetChannels(pMac);
7274
7275 if ( status != eHAL_STATUS_SUCCESS )
7276 {
7277 smsLog( pMac, LOGE, FL(" fail to get Channels "));
7278 return status;
7279 }
7280
7281 /* reset info based on new cc, and we are done */
7282 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Kiet Lam6c583332013-10-14 05:37:09 +05307283 if (VOS_TRUE == is11dCountry)
7284 {
Kiet Lam6c583332013-10-14 05:37:09 +05307285 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_TRUE;
7286 pMac->scan.f11dInfoReset = eANI_BOOLEAN_FALSE;
7287 }
Amar Singhal0d15bd52013-10-12 23:13:13 -07007288
Kiet Lambd5cd9b2013-11-11 19:01:45 +05307289 // Do active scans after the country is set by User hints or Country IE
7290 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
7291
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007292 smsLog(pMac, LOG1, FL(" returned"));
7293 return eHAL_STATUS_SUCCESS;
7294}
7295
7296/* ---------------------------------------------------------------------------
7297
Kiet Lamcffc5862013-10-30 16:28:45 +05307298 \fn sme_HandleChangeCountryCodeByCore
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007299
7300 \brief Update Country code in the driver if set by kernel as world
7301
7302 If 11D is enabled, we update the country code after every scan & notify kernel.
7303 This is to make sure kernel & driver are in sync in case of CC found in
7304 driver but not in kernel database
7305
7306 \param pMac - The handle returned by macOpen.
7307 \param pMsg - Carrying new CC set in kernel
7308
7309 \return eHalStatus
7310
7311 -------------------------------------------------------------------------------*/
Kiet Lamcffc5862013-10-30 16:28:45 +05307312eHalStatus sme_HandleChangeCountryCodeByCore(tpAniSirGlobal pMac, tAniGenericChangeCountryCodeReq *pMsg)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007313{
Kiet Lamcffc5862013-10-30 16:28:45 +05307314 eHalStatus status;
7315
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007316 smsLog(pMac, LOG1, FL(" called"));
7317
7318 //this is to make sure kernel & driver are in sync in case of CC found in
7319 //driver but not in kernel database
7320 if (('0' == pMsg->countryCode[0]) && ('0' == pMsg->countryCode[1]))
7321 {
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08007322 smsLog( pMac, LOGW, FL("Setting countryCode11d & countryCodeCurrent to world CC"));
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007323 palCopyMemory(pMac->hHdd, pMac->scan.countryCode11d, pMsg->countryCode,
7324 WNI_CFG_COUNTRY_CODE_LEN);
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08007325 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent, pMsg->countryCode,
7326 WNI_CFG_COUNTRY_CODE_LEN);
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007327 }
Kiet Lamcffc5862013-10-30 16:28:45 +05307328
7329 status = WDA_SetRegDomain(pMac, REGDOMAIN_WORLD);
7330
7331 if ( status != eHAL_STATUS_SUCCESS )
7332 {
7333 smsLog( pMac, LOGE, FL(" fail to set regId") );
7334 return status;
7335 }
7336 else
7337 {
7338 status = csrInitGetChannels(pMac);
7339 if ( status != eHAL_STATUS_SUCCESS )
7340 {
7341 smsLog( pMac, LOGE, FL(" fail to get Channels "));
7342 }
7343 else
7344 {
7345 csrInitChannelList(pMac);
7346 }
7347 }
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007348 smsLog(pMac, LOG1, FL(" returned"));
7349 return eHAL_STATUS_SUCCESS;
7350}
7351
7352/* ---------------------------------------------------------------------------
7353
7354 \fn sme_HandleGenericChangeCountryCode
7355
7356 \brief Change Country code, Reg Domain and channel list
7357
7358 If Supplicant country code is priority than 11d is disabled.
7359 If 11D is enabled, we update the country code after every scan.
7360 Hence when Supplicant country code is priority, we don't need 11D info.
7361 Country code from kernel is set as current country code.
7362
7363 \param pMac - The handle returned by macOpen.
7364 \param pMsgBuf - message buffer
7365
7366 \return eHalStatus
7367
7368 -------------------------------------------------------------------------------*/
7369eHalStatus sme_HandleGenericChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
7370{
7371 tAniGenericChangeCountryCodeReq *pMsg;
7372 v_REGDOMAIN_t reg_domain_id;
7373
7374 smsLog(pMac, LOG1, FL(" called"));
7375 pMsg = (tAniGenericChangeCountryCodeReq *)pMsgBuf;
7376 reg_domain_id = (v_REGDOMAIN_t)pMsg->domain_index;
7377
7378 if (REGDOMAIN_COUNT == reg_domain_id)
7379 {
Kiet Lamcffc5862013-10-30 16:28:45 +05307380 sme_HandleChangeCountryCodeByCore(pMac, pMsg);
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07007381 }
7382 else
7383 {
7384 sme_HandleChangeCountryCodeByUser(pMac, pMsg);
7385 }
7386 smsLog(pMac, LOG1, FL(" returned"));
Amar Singhal0d15bd52013-10-12 23:13:13 -07007387 return eHAL_STATUS_SUCCESS;
7388}
7389
Jeff Johnson295189b2012-06-20 16:38:30 -07007390#ifdef WLAN_FEATURE_PACKET_FILTERING
Amar Singhalf3a6e762013-02-19 15:06:50 -08007391eHalStatus sme_8023MulticastList (tHalHandle hHal, tANI_U8 sessionId, tpSirRcvFltMcAddrList pMulticastAddrs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007392{
7393 tpSirRcvFltMcAddrList pRequestBuf;
7394 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07007395 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnsone7245742012-09-05 17:12:55 -07007396 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007397
7398 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307399 "ulMulticastAddrCnt=%d, multicastAddr[0]=%p", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 pMulticastAddrs->ulMulticastAddrCnt,
7401 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07007402
7403 /*
7404 *Find the connected Infra / P2P_client connected session
Amar Singhalf3a6e762013-02-19 15:06:50 -08007405 */
7406 if (CSR_IS_SESSION_VALID(pMac, sessionId) &&
7407 csrIsConnStateInfra(pMac, sessionId))
7408 {
7409 pSession = CSR_GET_SESSION( pMac, sessionId );
7410 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007411
7412 if(pSession == NULL )
7413 {
7414 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Unable to find "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007415 "the right session", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07007416 return eHAL_STATUS_FAILURE;
7417 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007418
Jeff Johnson295189b2012-06-20 16:38:30 -07007419 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7420 if (NULL == pRequestBuf)
7421 {
7422 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007423 "allocate memory for 8023 Multicast List request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 return eHAL_STATUS_FAILED_ALLOC;
7425 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007426
7427 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
7428 {
7429 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
7430 "indication as we are not connected", __func__);
7431 vos_mem_free(pRequestBuf);
7432 return eHAL_STATUS_FAILURE;
7433 }
7434
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
7436
Kiet Lam64c1b492013-07-12 13:56:44 +05307437 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr,
7438 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07007439 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
7440 sizeof(tSirMacAddr));
7441
Jeff Johnson295189b2012-06-20 16:38:30 -07007442 msg.type = WDA_8023_MULTICAST_LIST_REQ;
7443 msg.reserved = 0;
7444 msg.bodyptr = pRequestBuf;
7445 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
7446 {
7447 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007448 "post WDA_8023_MULTICAST_LIST message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 vos_mem_free(pRequestBuf);
7450 return eHAL_STATUS_FAILURE;
7451 }
7452
7453 return eHAL_STATUS_SUCCESS;
7454}
7455
Jeff Johnsone7245742012-09-05 17:12:55 -07007456eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
7457 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007458{
7459 tpSirRcvPktFilterCfgType pRequestBuf;
7460 v_SINT_t allocSize;
7461 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07007462 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7463 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007464 v_U8_t idx=0;
7465
7466 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007467 "filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007468 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
7469
Madan Mohan Koyyalamudid4029622012-10-18 20:30:17 -07007470 allocSize = sizeof(tSirRcvPktFilterCfgType);
7471
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 pRequestBuf = vos_mem_malloc(allocSize);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007473
7474 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 {
7476 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007477 "allocate memory for Receive Filter Set Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 return eHAL_STATUS_FAILED_ALLOC;
7479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007480
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007481 if( NULL == pSession )
7482 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007483 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Session Not found ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007484 vos_mem_free(pRequestBuf);
7485 return eHAL_STATUS_FAILURE;
7486 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007487
Kiet Lam64c1b492013-07-12 13:56:44 +05307488 vos_mem_copy(pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr,
7489 sizeof(tSirMacAddr));
7490 vos_mem_copy(pRcvPktFilterCfg->bssId, pSession->connectedProfile.bssid,
7491 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007492 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
7493
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
7495 msg.reserved = 0;
7496 msg.bodyptr = pRequestBuf;
7497
7498 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
7499 "FT %d FID %d ",
7500 pRequestBuf->filterType, pRequestBuf->filterId);
7501
7502 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
7503 "params %d CT %d",
7504 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
7505
7506 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
7507 {
7508
7509 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007510 "Proto %d Comp Flag %d ",
Jeff Johnson295189b2012-06-20 16:38:30 -07007511 pRequestBuf->paramsData[idx].protocolLayer,
7512 pRequestBuf->paramsData[idx].cmpFlag);
7513
7514 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007515 "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007516 pRequestBuf->paramsData[idx].dataOffset,
7517 pRequestBuf->paramsData[idx].dataLength);
7518
7519 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007520 "CData: %d:%d:%d:%d:%d:%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 pRequestBuf->paramsData[idx].compareData[0],
7522 pRequestBuf->paramsData[idx].compareData[1],
7523 pRequestBuf->paramsData[idx].compareData[2],
7524 pRequestBuf->paramsData[idx].compareData[3],
7525 pRequestBuf->paramsData[idx].compareData[4],
7526 pRequestBuf->paramsData[idx].compareData[5]);
7527
7528 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007529 "MData: %d:%d:%d:%d:%d:%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007530 pRequestBuf->paramsData[idx].dataMask[0],
7531 pRequestBuf->paramsData[idx].dataMask[1],
7532 pRequestBuf->paramsData[idx].dataMask[2],
7533 pRequestBuf->paramsData[idx].dataMask[3],
7534 pRequestBuf->paramsData[idx].dataMask[4],
7535 pRequestBuf->paramsData[idx].dataMask[5]);
7536
7537 }
7538
7539 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
7540 {
7541 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007542 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007543 vos_mem_free(pRequestBuf);
7544 return eHAL_STATUS_FAILURE;
7545 }
7546
7547 return eHAL_STATUS_SUCCESS;
7548}
7549
7550eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
7551 FilterMatchCountCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007552 void *callbackContext,
7553 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007554{
7555 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7556 eHalStatus status;
7557
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007558 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007559
7560 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
7561 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007562 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 sme_ReleaseGlobalLock( &pMac->sme );
7564 }
7565
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007566 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007567
7568 return (status);
7569}
7570
Jeff Johnsone7245742012-09-05 17:12:55 -07007571eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
7572 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007573{
7574 tpSirRcvFltPktClearParam pRequestBuf;
7575 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07007576 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7577 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007578
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007579 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 pRcvFltPktClearParam->filterId);
7581
7582 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007583 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 {
7585 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7586 "%s: Not able to allocate memory for Receive Filter "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007587 "Clear Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 return eHAL_STATUS_FAILED_ALLOC;
7589 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007590 if( NULL == pSession )
7591 {
7592 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007593 "%s: Session Not find ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007594 vos_mem_free(pRequestBuf);
7595 return eHAL_STATUS_FAILURE;
7596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007597
Kiet Lam64c1b492013-07-12 13:56:44 +05307598 vos_mem_copy(pRcvFltPktClearParam->selfMacAddr, pSession->selfMacAddr,
7599 sizeof(tSirMacAddr));
7600 vos_mem_copy(pRcvFltPktClearParam->bssId, pSession->connectedProfile.bssid,
7601 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07007602
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007603 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
7604
Jeff Johnson295189b2012-06-20 16:38:30 -07007605 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
7606 msg.reserved = 0;
7607 msg.bodyptr = pRequestBuf;
7608 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
7609 {
7610 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007611 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 vos_mem_free(pRequestBuf);
7613 return eHAL_STATUS_FAILURE;
7614 }
7615
7616 return eHAL_STATUS_SUCCESS;
7617}
7618#endif // WLAN_FEATURE_PACKET_FILTERING
7619
7620/* ---------------------------------------------------------------------------
7621 \fn sme_PreChannelSwitchIndFullPowerCB
7622 \brief call back function for the PMC full power request because of pre
7623 channel switch.
7624 \param callbackContext
7625 \param status
7626 ---------------------------------------------------------------------------*/
7627void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
7628 eHalStatus status)
7629{
7630 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
7631 tSirMbMsg *pMsg;
7632 tANI_U16 msgLen;
7633
7634 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
Kiet Lam64c1b492013-07-12 13:56:44 +05307635 pMsg = vos_mem_malloc(msgLen);
7636 if ( NULL != pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307638 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007639 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
7640 pMsg->msgLen = pal_cpu_to_be16(msgLen);
7641 status = palSendMBMessage(pMac->hHdd, pMsg);
7642 }
7643
7644 return;
7645}
7646
7647/* ---------------------------------------------------------------------------
7648 \fn sme_HandlePreChannelSwitchInd
7649 \brief Processes the indcation from PE for pre-channel switch.
7650 \param hHal
7651 \- The handle returned by macOpen. return eHalStatus
7652 ---------------------------------------------------------------------------*/
7653eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
7654{
7655 eHalStatus status = eHAL_STATUS_FAILURE;
7656 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7657 status = sme_AcquireGlobalLock( &pMac->sme );
7658 if ( HAL_STATUS_SUCCESS( status ) )
7659 {
7660 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
7661 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
7662 sme_ReleaseGlobalLock( &pMac->sme );
7663 }
7664
7665 return (status);
7666}
7667
7668/* ---------------------------------------------------------------------------
7669 \fn sme_HandlePostChannelSwitchInd
7670 \brief Processes the indcation from PE for post-channel switch.
7671 \param hHal
7672 \- The handle returned by macOpen. return eHalStatus
7673 ---------------------------------------------------------------------------*/
7674eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
7675{
7676 eHalStatus status = eHAL_STATUS_FAILURE;
7677 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7678
7679 status = sme_AcquireGlobalLock( &pMac->sme );
7680 if ( HAL_STATUS_SUCCESS( status ) )
7681 {
7682 status = pmcRequestBmps(hHal, NULL, NULL);
7683 sme_ReleaseGlobalLock( &pMac->sme );
7684 }
7685
7686 return (status);
7687}
7688
7689/* ---------------------------------------------------------------------------
7690
7691 \fn sme_IsChannelValid
7692
7693 \brief To check if the channel is valid for currently established domain
7694 This is a synchronous API.
7695
7696 \param hHal - The handle returned by macOpen.
7697 \param channel - channel to verify
7698
7699 \return TRUE/FALSE, TRUE if channel is valid
7700
7701 -------------------------------------------------------------------------------*/
7702tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
7703{
7704 eHalStatus status = eHAL_STATUS_FAILURE;
7705 tANI_BOOLEAN valid = FALSE;
7706 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7707
7708 status = sme_AcquireGlobalLock( &pMac->sme );
7709 if ( HAL_STATUS_SUCCESS( status ) )
7710 {
7711
7712 valid = csrRoamIsChannelValid( pMac, channel);
7713
7714 sme_ReleaseGlobalLock( &pMac->sme );
7715 }
7716
7717 return (valid);
7718}
7719
7720/* ---------------------------------------------------------------------------
7721 \fn sme_SetFreqBand
7722 \brief Used to set frequency band.
7723 \param hHal
7724 \eBand band value to be configured
7725 \- return eHalStatus
7726 -------------------------------------------------------------------------*/
7727eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
7728{
7729 eHalStatus status = eHAL_STATUS_FAILURE;
7730 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7731
7732 status = sme_AcquireGlobalLock( &pMac->sme );
7733 if ( HAL_STATUS_SUCCESS( status ) )
7734 {
7735 status = csrSetBand(hHal, eBand);
7736 sme_ReleaseGlobalLock( &pMac->sme );
7737 }
7738 return status;
7739}
7740
7741/* ---------------------------------------------------------------------------
7742 \fn sme_GetFreqBand
7743 \brief Used to get the current band settings.
7744 \param hHal
7745 \pBand pointer to hold band value
7746 \- return eHalStatus
7747 -------------------------------------------------------------------------*/
7748eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
7749{
7750 eHalStatus status = eHAL_STATUS_FAILURE;
7751 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7752
7753 status = sme_AcquireGlobalLock( &pMac->sme );
7754 if ( HAL_STATUS_SUCCESS( status ) )
7755 {
7756 *pBand = csrGetCurrentBand( hHal );
7757 sme_ReleaseGlobalLock( &pMac->sme );
7758 }
7759 return status;
7760}
7761
7762#ifdef WLAN_WAKEUP_EVENTS
7763/******************************************************************************
7764 \fn sme_WakeReasonIndCallback
7765
7766 \brief
7767 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
7768
7769 \param hHal - HAL handle for device
7770 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
7771
7772 \return eHalStatus
7773******************************************************************************/
7774eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
7775{
7776 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7777 eHalStatus status = eHAL_STATUS_SUCCESS;
7778 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
7779
7780 if (NULL == pMsg)
7781 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007782 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 status = eHAL_STATUS_FAILURE;
7784 }
7785 else
7786 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007787 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback");
Jeff Johnson295189b2012-06-20 16:38:30 -07007788
7789 /* Call Wake Reason Indication callback routine. */
7790 if (pMac->pmc.wakeReasonIndCB != NULL)
7791 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
7792
7793 pMac->pmc.wakeReasonIndCB = NULL;
7794 pMac->pmc.wakeReasonIndCBContext = NULL;
7795
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007796 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __func__, pWakeReasonInd->ulReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 }
7798
7799 return(status);
7800}
7801#endif // WLAN_WAKEUP_EVENTS
7802
7803
7804/* ---------------------------------------------------------------------------
7805
7806 \fn sme_SetMaxTxPower
7807
7808 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
7809 not persist over reboots.
7810
7811 \param hHal
7812 \param pBssid BSSID to set the power cap for
7813 \param pBssid pSelfMacAddress self MAC Address
7814 \param pBssid power to set in dB
7815 \- return eHalStatus
7816
7817 -------------------------------------------------------------------------------*/
7818eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr pBssid,
7819 tSirMacAddr pSelfMacAddress, v_S7_t dB)
7820{
7821 vos_msg_t msg;
7822 tpMaxTxPowerParams pMaxTxParams = NULL;
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07007823#ifdef LIM_TRACE_RECORD
7824 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7825#endif
7826 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
7827 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007828 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
7829 if (NULL == pMaxTxParams)
7830 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007831 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 -07007832 return eHAL_STATUS_FAILURE;
7833 }
7834
7835 vos_mem_copy(pMaxTxParams->bssId, pBssid, SIR_MAC_ADDR_LENGTH);
Kiet Lam64c1b492013-07-12 13:56:44 +05307836 vos_mem_copy(pMaxTxParams->selfStaMacAddr, pSelfMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007837 SIR_MAC_ADDR_LENGTH);
7838 pMaxTxParams->power = dB;
7839
7840 msg.type = WDA_SET_MAX_TX_POWER_REQ;
7841 msg.reserved = 0;
7842 msg.bodyptr = pMaxTxParams;
7843
7844 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
7845 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007846 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 -07007847 vos_mem_free(pMaxTxParams);
7848 return eHAL_STATUS_FAILURE;
7849 }
7850
7851 return eHAL_STATUS_SUCCESS;
7852}
7853
Jeff Johnson295189b2012-06-20 16:38:30 -07007854/* ---------------------------------------------------------------------------
7855
Arif Hussaina5ebce02013-08-09 15:09:58 -07007856 \fn sme_SetMaxTxPowerPerBand
7857
7858 \brief Set the Maximum Transmit Power specific to band dynamically.
7859 Note: this setting will not persist over reboots.
7860
7861 \param band
7862 \param power to set in dB
7863 \- return eHalStatus
7864
7865 ----------------------------------------------------------------------------*/
7866eHalStatus sme_SetMaxTxPowerPerBand(eCsrBand band, v_S7_t dB)
7867{
7868 vos_msg_t msg;
7869 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
7870
7871 pMaxTxPowerPerBandParams = vos_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
7872 if (NULL == pMaxTxPowerPerBandParams)
7873 {
7874 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7875 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
7876 __func__);
7877 return eHAL_STATUS_FAILURE;
7878 }
7879
7880 pMaxTxPowerPerBandParams->power = dB;
7881 pMaxTxPowerPerBandParams->bandInfo = band;
7882
7883 msg.type = WDA_SET_MAX_TX_POWER_PER_BAND_REQ;
7884 msg.reserved = 0;
7885 msg.bodyptr = pMaxTxPowerPerBandParams;
7886
7887 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
7888 {
7889 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7890 "%s:Not able to post WDA_SET_MAX_TX_POWER_PER_BAND_REQ",
7891 __func__);
7892 vos_mem_free(pMaxTxPowerPerBandParams);
7893 return eHAL_STATUS_FAILURE;
7894 }
7895
7896 return eHAL_STATUS_SUCCESS;
7897}
7898
7899/* ---------------------------------------------------------------------------
7900
schang86c22c42013-03-13 18:41:24 -07007901 \fn sme_SetTxPower
7902
7903 \brief Set Transmit Power dynamically. Note: this setting will
7904 not persist over reboots.
7905
7906 \param hHal
7907 \param sessionId Target Session ID
7908 \param mW power to set in mW
7909 \- return eHalStatus
7910
7911 -------------------------------------------------------------------------------*/
7912eHalStatus sme_SetTxPower(tHalHandle hHal, v_U8_t sessionId, v_U8_t mW)
7913{
7914
7915 eHalStatus status = eHAL_STATUS_FAILURE;
7916 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7917
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07007918 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
7919 TRACE_CODE_SME_RX_HDD_SET_TXPOW, NO_SESSION, 0));
schang86c22c42013-03-13 18:41:24 -07007920 smsLog(pMac, LOG1, FL("set tx power %dmW"), mW);
7921 status = sme_AcquireGlobalLock(&pMac->sme);
7922 if (HAL_STATUS_SUCCESS(status))
7923 {
7924 status = csrSetTxPower(pMac, sessionId, mW);
7925 sme_ReleaseGlobalLock(&pMac->sme);
7926 }
7927 return status;
7928}
7929
7930/* ---------------------------------------------------------------------------
7931
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 \fn sme_HideSSID
7933
7934 \brief hide/show SSID dynamically. Note: this setting will
7935 not persist over reboots.
7936
7937 \param hHal
7938 \param sessionId
7939 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
7940 \- return eHalStatus
7941
7942 -------------------------------------------------------------------------------*/
7943eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
7944{
7945 eHalStatus status = eHAL_STATUS_SUCCESS;
7946 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7947 tANI_U16 len;
7948
7949 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7950 {
7951 tpSirUpdateParams pMsg;
7952 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007953
7954 if(!pSession)
7955 {
7956 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08007957 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007958 return eHAL_STATUS_FAILURE;
7959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007960
7961 if( !pSession->sessionActive )
7962 VOS_ASSERT(0);
7963
7964 /* Create the message and send to lim */
7965 len = sizeof(tSirUpdateParams);
Kiet Lam64c1b492013-07-12 13:56:44 +05307966 pMsg = vos_mem_malloc(len);
7967 if ( NULL == pMsg )
7968 status = eHAL_STATUS_FAILURE;
7969 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007970 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307971 vos_mem_set(pMsg, sizeof(tSirUpdateParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007972 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
7973 pMsg->length = len;
7974 /* Data starts from here */
7975 pMsg->sessionId = sessionId;
7976 pMsg->ssidHidden = ssidHidden;
7977 status = palSendMBMessage(pMac->hHdd, pMsg);
7978 }
7979 sme_ReleaseGlobalLock( &pMac->sme );
7980 }
7981 return status;
7982}
Jeff Johnson295189b2012-06-20 16:38:30 -07007983
7984/* ---------------------------------------------------------------------------
7985
7986 \fn sme_SetTmLevel
7987 \brief Set Thermal Mitigation Level to RIVA
7988 \param hHal - The handle returned by macOpen.
7989 \param newTMLevel - new Thermal Mitigation Level
7990 \param tmMode - Thermal Mitigation handle mode, default 0
7991 \return eHalStatus
7992 ---------------------------------------------------------------------------*/
7993eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
7994{
7995 eHalStatus status = eHAL_STATUS_SUCCESS;
7996 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7997 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7998 vos_msg_t vosMessage;
7999 tAniSetTmLevelReq *setTmLevelReq = NULL;
8000
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008001 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8002 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008003 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8004 {
8005 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
Kiet Lam64c1b492013-07-12 13:56:44 +05308006 if (NULL == setTmLevelReq)
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 {
8008 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008009 "%s: Not able to allocate memory for sme_SetTmLevel", __func__);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08008010 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson295189b2012-06-20 16:38:30 -07008011 return eHAL_STATUS_FAILURE;
8012 }
8013
8014 setTmLevelReq->tmMode = tmMode;
8015 setTmLevelReq->newTmLevel = newTMLevel;
8016
8017 /* serialize the req through MC thread */
8018 vosMessage.bodyptr = setTmLevelReq;
8019 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
8020 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8021 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8022 {
8023 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008024 "%s: Post Set TM Level MSG fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 vos_mem_free(setTmLevelReq);
8026 status = eHAL_STATUS_FAILURE;
8027 }
8028 sme_ReleaseGlobalLock( &pMac->sme );
8029 }
8030 return(status);
8031}
8032
8033/*---------------------------------------------------------------------------
8034
8035 \brief sme_featureCapsExchange() - SME interface to exchange capabilities between
8036 Host and FW.
8037
8038 \param hHal - HAL handle for device
8039
8040 \return NONE
8041
8042---------------------------------------------------------------------------*/
8043void sme_featureCapsExchange( tHalHandle hHal)
8044{
8045 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008046#ifdef LIM_TRACE_RECORD
8047 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8048#endif
8049 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8050 TRACE_CODE_SME_RX_HDD_CAPS_EXCH, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008051 WDA_featureCapsExchange(vosContext);
8052}
Jeff Johnsond13512a2012-07-17 11:42:19 -07008053
Yathish9f22e662012-12-10 14:21:35 -08008054/*---------------------------------------------------------------------------
8055
8056 \brief sme_disableFeatureCapablity() - SME interface to disable Active mode offload capablity
8057 in Host.
8058
8059 \param hHal - HAL handle for device
8060
8061 \return NONE
8062
8063---------------------------------------------------------------------------*/
8064void sme_disableFeatureCapablity(tANI_U8 feature_index)
8065{
8066 WDA_disableCapablityFeature(feature_index);
8067}
8068
Jeff Johnsond13512a2012-07-17 11:42:19 -07008069/* ---------------------------------------------------------------------------
8070
8071 \fn sme_GetDefaultCountryCode
8072
8073 \brief Get the default country code from NV
8074
8075 \param hHal
8076 \param pCountry
8077 \- return eHalStatus
8078
8079 -------------------------------------------------------------------------------*/
8080eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
8081{
8082 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008083 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8084 TRACE_CODE_SME_RX_HDD_GET_DEFCCNV, NO_SESSION, 0));
Jeff Johnsond13512a2012-07-17 11:42:19 -07008085 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
8086}
8087
8088/* ---------------------------------------------------------------------------
8089
8090 \fn sme_GetCurrentCountryCode
8091
8092 \brief Get the current country code
8093
8094 \param hHal
8095 \param pCountry
8096 \- return eHalStatus
8097
8098 -------------------------------------------------------------------------------*/
8099eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
8100{
8101 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008102 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8103 TRACE_CODE_SME_RX_HDD_GET_CURCC, NO_SESSION, 0));
Jeff Johnsond13512a2012-07-17 11:42:19 -07008104 return csrGetCurrentCountryCode(pMac, pCountry);
8105}
8106
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07008107/* ---------------------------------------------------------------------------
8108 \fn sme_transportDebug
8109 \brief Dynamically monitoring Transport channels
8110 Private IOCTL will querry transport channel status if driver loaded
schang6295e542013-03-12 15:31:23 -07008111 \param hHal Upper MAC context
Jeff Johnsonb88db982012-12-10 13:34:59 -08008112 \param displaySnapshot Display transport channel snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07008113 \param toggleStallDetect Enable stall detect feature
8114 This feature will take effect to data performance
8115 Not integrate till fully verification
8116 \- return NONE
8117 -------------------------------------------------------------------------*/
schang6295e542013-03-12 15:31:23 -07008118void sme_transportDebug(tHalHandle hHal, v_BOOL_t displaySnapshot, v_BOOL_t toggleStallDetect)
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07008119{
schang6295e542013-03-12 15:31:23 -07008120 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8121
8122 if (NULL == pMac)
8123 {
8124 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8125 "%s: invalid context", __func__);
8126 return;
8127 }
8128 WDA_TransportChannelDebug(pMac, displaySnapshot, toggleStallDetect);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07008129}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08008130
Kiran4a17ebe2013-01-31 10:43:43 -08008131/* ---------------------------------------------------------------------------
8132 \fn sme_ResetPowerValuesFor5G
8133 \brief Reset the power values for 5G band with NV power values.
8134 \param hHal - HAL handle for device
8135 \- return NONE
8136 -------------------------------------------------------------------------*/
8137void sme_ResetPowerValuesFor5G (tHalHandle hHal)
8138{
8139 tpAniSirGlobal pMac = PMAC_STRUCT (hHal);
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008140 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8141 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
Kiran4a17ebe2013-01-31 10:43:43 -08008142 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
8143 csrApplyPower2Current(pMac); // Store the channel+power info in the global place: Cfg
8144}
8145
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08008146#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
8147/* ---------------------------------------------------------------------------
8148 \fn sme_UpdateRoamPrefer5GHz
8149 \brief enable/disable Roam prefer 5G runtime option
8150 This function is called through dynamic setConfig callback function
8151 to configure the Roam prefer 5G runtime option
8152 \param hHal - HAL handle for device
8153 \param nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
8154 \- return Success or failure
8155 -------------------------------------------------------------------------*/
8156
8157eHalStatus sme_UpdateRoamPrefer5GHz(tHalHandle hHal, v_BOOL_t nRoamPrefer5GHz)
8158{
8159 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08008160 eHalStatus status = eHAL_STATUS_SUCCESS;
8161
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008162 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8163 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -08008164 status = sme_AcquireGlobalLock( &pMac->sme );
8165 if ( HAL_STATUS_SUCCESS( status ) )
8166 {
8167 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8168 "%s: gRoamPrefer5GHz is changed from %d to %d", __func__,
8169 pMac->roam.configParam.nRoamPrefer5GHz,
8170 nRoamPrefer5GHz);
8171 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
8172 sme_ReleaseGlobalLock( &pMac->sme );
8173 }
8174
8175 return status ;
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08008176}
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08008177
8178/* ---------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008179 \fn sme_setRoamIntraBand
8180 \brief enable/disable Intra band roaming
8181 This function is called through dynamic setConfig callback function
8182 to configure the intra band roaming
8183 \param hHal - HAL handle for device
8184 \param nRoamIntraBand Enable/Disable Intra band roaming
8185 \- return Success or failure
8186 -------------------------------------------------------------------------*/
8187eHalStatus sme_setRoamIntraBand(tHalHandle hHal, const v_BOOL_t nRoamIntraBand)
8188{
8189 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8190 eHalStatus status = eHAL_STATUS_SUCCESS;
8191
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008192 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8193 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008194 status = sme_AcquireGlobalLock( &pMac->sme );
8195 if ( HAL_STATUS_SUCCESS( status ) )
8196 {
8197 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8198 "%s: gRoamIntraBand is changed from %d to %d", __func__,
8199 pMac->roam.configParam.nRoamIntraBand,
8200 nRoamIntraBand);
8201 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
8202 sme_ReleaseGlobalLock( &pMac->sme );
8203 }
8204
8205 return status ;
8206}
8207
8208/* ---------------------------------------------------------------------------
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008209 \fn sme_UpdateRoamScanNProbes
8210 \brief function to update roam scan N probes
8211 This function is called through dynamic setConfig callback function
8212 to update roam scan N probes
8213 \param hHal - HAL handle for device
8214 \param nProbes number of probe requests to be sent out
8215 \- return Success or failure
8216 -------------------------------------------------------------------------*/
8217eHalStatus sme_UpdateRoamScanNProbes(tHalHandle hHal, const v_U8_t nProbes)
8218{
8219 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8220 eHalStatus status = eHAL_STATUS_SUCCESS;
8221
8222 status = sme_AcquireGlobalLock( &pMac->sme );
8223 if ( HAL_STATUS_SUCCESS( status ) )
8224 {
8225 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8226 "%s: gRoamScanNProbes is changed from %d to %d", __func__,
8227 pMac->roam.configParam.nProbes,
8228 nProbes);
8229 pMac->roam.configParam.nProbes = nProbes;
8230 sme_ReleaseGlobalLock( &pMac->sme );
8231 }
8232#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8233 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8234 {
8235 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8236 REASON_NPROBES_CHANGED);
8237 }
8238#endif
8239 return status ;
8240}
8241
8242/* ---------------------------------------------------------------------------
8243 \fn sme_UpdateRoamScanHomeAwayTime
8244 \brief function to update roam scan Home away time
8245 This function is called through dynamic setConfig callback function
8246 to update roam scan home away time
8247 \param hHal - HAL handle for device
8248 \param nRoamScanAwayTime Scan home away time
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07008249 \param bSendOffloadCmd If TRUE then send offload command to firmware
8250 If FALSE then command is not sent to firmware
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008251 \- return Success or failure
8252 -------------------------------------------------------------------------*/
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07008253eHalStatus sme_UpdateRoamScanHomeAwayTime(tHalHandle hHal, const v_U16_t nRoamScanHomeAwayTime,
8254 const eAniBoolean bSendOffloadCmd)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008255{
8256 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8257 eHalStatus status = eHAL_STATUS_SUCCESS;
8258
8259 status = sme_AcquireGlobalLock( &pMac->sme );
8260 if ( HAL_STATUS_SUCCESS( status ) )
8261 {
8262 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8263 "%s: gRoamScanHomeAwayTime is changed from %d to %d", __func__,
8264 pMac->roam.configParam.nRoamScanHomeAwayTime,
8265 nRoamScanHomeAwayTime);
8266 pMac->roam.configParam.nRoamScanHomeAwayTime = nRoamScanHomeAwayTime;
8267 sme_ReleaseGlobalLock( &pMac->sme );
8268 }
8269
8270#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07008271 if (pMac->roam.configParam.isRoamOffloadScanEnabled && bSendOffloadCmd)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008272 {
8273 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8274 REASON_HOME_AWAY_TIME_CHANGED);
8275 }
8276#endif
8277 return status;
8278}
8279
8280
8281/* ---------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008282 \fn sme_getRoamIntraBand
8283 \brief get Intra band roaming
8284 \param hHal - HAL handle for device
8285 \- return Success or failure
8286 -------------------------------------------------------------------------*/
8287v_BOOL_t sme_getRoamIntraBand(tHalHandle hHal)
8288{
8289 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008290 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8291 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008292 return pMac->roam.configParam.nRoamIntraBand;
8293}
8294
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008295/* ---------------------------------------------------------------------------
8296 \fn sme_getRoamScanNProbes
8297 \brief get N Probes
8298 \param hHal - HAL handle for device
8299 \- return Success or failure
8300 -------------------------------------------------------------------------*/
8301v_U8_t sme_getRoamScanNProbes(tHalHandle hHal)
8302{
8303 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8304 return pMac->roam.configParam.nProbes;
8305}
8306
8307/* ---------------------------------------------------------------------------
8308 \fn sme_getRoamScanHomeAwayTime
8309 \brief get Roam scan home away time
8310 \param hHal - HAL handle for device
8311 \- return Success or failure
8312 -------------------------------------------------------------------------*/
8313v_U16_t sme_getRoamScanHomeAwayTime(tHalHandle hHal)
8314{
8315 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8316 return pMac->roam.configParam.nRoamScanHomeAwayTime;
8317}
8318
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008319
8320/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08008321 \fn sme_UpdateImmediateRoamRssiDiff
8322 \brief Update nImmediateRoamRssiDiff
8323 This function is called through dynamic setConfig callback function
8324 to configure nImmediateRoamRssiDiff
8325 Usage: adb shell iwpriv wlan0 setConfig gImmediateRoamRssiDiff=[0 .. 125]
8326 \param hHal - HAL handle for device
8327 \param nImmediateRoamRssiDiff - minimum rssi difference between potential
8328 candidate and current AP.
8329 \- return Success or failure
8330 -------------------------------------------------------------------------*/
8331
8332eHalStatus sme_UpdateImmediateRoamRssiDiff(tHalHandle hHal, v_U8_t nImmediateRoamRssiDiff)
8333{
8334 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08008335 eHalStatus status = eHAL_STATUS_SUCCESS;
8336
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008337 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8338 TRACE_CODE_SME_RX_HDD_UPDATE_IMMRSSIDIFF, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -08008339 status = sme_AcquireGlobalLock( &pMac->sme );
8340 if ( HAL_STATUS_SUCCESS( status ) )
8341 {
8342 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8343 "LFR runtime successfully set immediate roam rssi diff to %d - old value is %d - roam state is %d",
8344 nImmediateRoamRssiDiff,
8345 pMac->roam.configParam.nImmediateRoamRssiDiff,
8346 pMac->roam.neighborRoamInfo.neighborRoamState);
8347 pMac->roam.configParam.nImmediateRoamRssiDiff = nImmediateRoamRssiDiff;
8348 sme_ReleaseGlobalLock( &pMac->sme );
8349 }
8350
8351 return status ;
8352}
8353
8354/* ---------------------------------------------------------------------------
8355 \fn sme_UpdateRoamRssiDiff
8356 \brief Update RoamRssiDiff
8357 This function is called through dynamic setConfig callback function
8358 to configure RoamRssiDiff
8359 Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
8360 \param hHal - HAL handle for device
8361 \param RoamRssiDiff - minimum rssi difference between potential
8362 candidate and current AP.
8363 \- return Success or failure
8364 -------------------------------------------------------------------------*/
8365
8366eHalStatus sme_UpdateRoamRssiDiff(tHalHandle hHal, v_U8_t RoamRssiDiff)
8367{
8368 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8369 eHalStatus status = eHAL_STATUS_SUCCESS;
8370
8371 status = sme_AcquireGlobalLock( &pMac->sme );
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008372 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8373 TRACE_CODE_SME_RX_HDD_UPDATE_RSSIDIFF, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -08008374 if ( HAL_STATUS_SUCCESS( status ) )
8375 {
8376 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8377 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %d",
8378 RoamRssiDiff,
8379 pMac->roam.configParam.RoamRssiDiff,
8380 pMac->roam.neighborRoamInfo.neighborRoamState);
8381 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
8382 sme_ReleaseGlobalLock( &pMac->sme );
8383 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07008384#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8385 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8386 {
8387 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_RSSI_DIFF_CHANGED);
8388 }
8389#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08008390 return status ;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08008391}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008392
8393/*--------------------------------------------------------------------------
8394 \brief sme_UpdateFastTransitionEnabled() - enable/disable Fast Transition support at runtime
8395 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8396 isFastTransitionEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08008397 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008398 \param hHal - The handle returned by macOpen.
8399 \return eHAL_STATUS_SUCCESS - SME update isFastTransitionEnabled config successfully.
8400 Other status means SME is failed to update isFastTransitionEnabled.
8401 \sa
8402 --------------------------------------------------------------------------*/
8403eHalStatus sme_UpdateFastTransitionEnabled(tHalHandle hHal,
8404 v_BOOL_t isFastTransitionEnabled)
8405{
8406 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08008407 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008408
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008409 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8410 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -08008411 status = sme_AcquireGlobalLock( &pMac->sme );
8412 if ( HAL_STATUS_SUCCESS( status ) )
8413 {
8414 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8415 "%s: FastTransitionEnabled is changed from %d to %d", __func__,
8416 pMac->roam.configParam.isFastTransitionEnabled,
8417 isFastTransitionEnabled);
8418 pMac->roam.configParam.isFastTransitionEnabled = isFastTransitionEnabled;
8419 sme_ReleaseGlobalLock( &pMac->sme );
8420 }
8421
8422 return status ;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008423}
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008424
8425/* ---------------------------------------------------------------------------
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07008426 \fn sme_UpdateWESMode
8427 \brief Update WES Mode
8428 This function is called through dynamic setConfig callback function
8429 to configure isWESModeEnabled
8430 \param hHal - HAL handle for device
8431 \return eHAL_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
8432 Other status means SME is failed to update isWESModeEnabled.
8433 -------------------------------------------------------------------------*/
8434
8435eHalStatus sme_UpdateWESMode(tHalHandle hHal, v_BOOL_t isWESModeEnabled)
8436{
8437 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8438 eHalStatus status = eHAL_STATUS_SUCCESS;
8439
8440 status = sme_AcquireGlobalLock( &pMac->sme );
8441 if ( HAL_STATUS_SUCCESS( status ) )
8442 {
8443 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8444 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %d",
8445 isWESModeEnabled,
8446 pMac->roam.configParam.isWESModeEnabled,
8447 pMac->roam.neighborRoamInfo.neighborRoamState);
8448 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
8449 sme_ReleaseGlobalLock( &pMac->sme );
8450 }
8451
8452 return status ;
8453}
8454
8455/* ---------------------------------------------------------------------------
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008456 \fn sme_SetRoamScanControl
8457 \brief Set roam scan control
8458 This function is called to set roam scan control
8459 if roam scan control is set to 0, roaming scan cache is cleared
8460 any value other than 0 is treated as invalid value
8461 \param hHal - HAL handle for device
8462 \return eHAL_STATUS_SUCCESS - SME update config successfully.
8463 Other status means SME failure to update
8464 -------------------------------------------------------------------------*/
8465eHalStatus sme_SetRoamScanControl(tHalHandle hHal, v_BOOL_t roamScanControl)
8466{
8467 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8468 eHalStatus status = eHAL_STATUS_SUCCESS;
8469
Leela Venkata Kiran Kumar Reddy Chiralace438362013-04-10 22:39:51 -07008470 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
8471 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008472 status = sme_AcquireGlobalLock( &pMac->sme );
8473 if ( HAL_STATUS_SUCCESS( status ) )
8474 {
8475 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8476 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %d",
8477 roamScanControl,
8478 pMac->roam.configParam.nRoamScanControl,
8479 pMac->roam.neighborRoamInfo.neighborRoamState);
8480 pMac->roam.configParam.nRoamScanControl = roamScanControl;
8481 if ( 0 == roamScanControl)
8482 {
8483 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8484 "LFR runtime successfully cleared roam scan cache");
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008485 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008486#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8487 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8488 {
8489 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_FLUSH_CHANNEL_LIST);
8490 }
8491#endif
8492 }
8493 sme_ReleaseGlobalLock( &pMac->sme );
8494 }
8495 return status ;
8496}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008497#endif /* (WLAN_FEATURE_VOWIFI_11R) || (FEATURE_WLAN_CCX) || (FEATURE_WLAN_LFR) */
8498
8499#ifdef FEATURE_WLAN_LFR
8500/*--------------------------------------------------------------------------
8501 \brief sme_UpdateIsFastRoamIniFeatureEnabled() - enable/disable LFR support at runtime
8502 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8503 isFastRoamIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08008504 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008505 \param hHal - The handle returned by macOpen.
8506 \return eHAL_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config successfully.
8507 Other status means SME is failed to update isFastRoamIniFeatureEnabled.
8508 \sa
8509 --------------------------------------------------------------------------*/
8510eHalStatus sme_UpdateIsFastRoamIniFeatureEnabled(tHalHandle hHal,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008511 const v_BOOL_t isFastRoamIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008512{
8513 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8514
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008515 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled == isFastRoamIniFeatureEnabled)
8516 {
8517 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8518 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)", __func__,
8519 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
8520 isFastRoamIniFeatureEnabled);
8521 return eHAL_STATUS_SUCCESS;
8522 }
8523
Srinivas Girigowdade697412013-02-14 16:31:48 -08008524 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8525 "%s: FastRoamEnabled is changed from %d to %d", __func__,
8526 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
8527 isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008528 pMac->roam.configParam.isFastRoamIniFeatureEnabled = isFastRoamIniFeatureEnabled;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008529 csrNeighborRoamUpdateFastRoamingEnabled(pMac, isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008530
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008531 return eHAL_STATUS_SUCCESS;
8532}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07008533
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08008534/*--------------------------------------------------------------------------
8535 \brief sme_UpdateIsMAWCIniFeatureEnabled() -
8536 Enable/disable LFR MAWC support at runtime
8537 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8538 isMAWCIniFeatureEnabled.
8539 This is a synchronous call
8540 \param hHal - The handle returned by macOpen.
8541 \return eHAL_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
8542 Other status means SME is failed to update MAWCEnabled.
8543 \sa
8544 --------------------------------------------------------------------------*/
8545eHalStatus sme_UpdateIsMAWCIniFeatureEnabled(tHalHandle hHal,
8546 const v_BOOL_t MAWCEnabled)
8547{
8548 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8549 eHalStatus status = eHAL_STATUS_SUCCESS;
8550
8551 status = sme_AcquireGlobalLock( &pMac->sme );
8552 if ( HAL_STATUS_SUCCESS( status ) )
8553 {
8554 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8555 "%s: MAWCEnabled is changed from %d to %d", __func__,
8556 pMac->roam.configParam.MAWCEnabled,
8557 MAWCEnabled);
8558 pMac->roam.configParam.MAWCEnabled = MAWCEnabled;
8559 sme_ReleaseGlobalLock( &pMac->sme );
8560 }
8561
8562 return status ;
8563
8564}
8565
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07008566#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8567/*--------------------------------------------------------------------------
8568 \brief sme_UpdateEnableFastRoamInConcurrency() - enable/disable LFR if Concurrent session exists
8569 This is a synchronuous call
8570 \param hHal - The handle returned by macOpen.
8571 \return eHAL_STATUS_SUCCESS
8572 Other status means SME is failed
8573 \sa
8574 --------------------------------------------------------------------------*/
8575
8576eHalStatus sme_UpdateEnableFastRoamInConcurrency(tHalHandle hHal,
8577 v_BOOL_t bFastRoamInConIniFeatureEnabled)
8578{
8579
8580 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8581 eHalStatus status = eHAL_STATUS_SUCCESS;
8582
8583 status = sme_AcquireGlobalLock( &pMac->sme );
8584 if ( HAL_STATUS_SUCCESS( status ) )
8585 {
8586 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = bFastRoamInConIniFeatureEnabled;
8587 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled)
8588 {
8589 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = 0;
8590 }
8591 sme_ReleaseGlobalLock( &pMac->sme );
8592 }
8593
8594 return status;
8595}
8596#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008597#endif /* FEATURE_WLAN_LFR */
8598
8599#ifdef FEATURE_WLAN_CCX
8600/*--------------------------------------------------------------------------
8601 \brief sme_UpdateIsCcxFeatureEnabled() - enable/disable CCX support at runtime
8602 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8603 isCcxIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08008604 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008605 \param hHal - The handle returned by macOpen.
8606 \return eHAL_STATUS_SUCCESS - SME update isCcxIniFeatureEnabled config successfully.
8607 Other status means SME is failed to update isCcxIniFeatureEnabled.
8608 \sa
8609 --------------------------------------------------------------------------*/
8610
8611eHalStatus sme_UpdateIsCcxFeatureEnabled(tHalHandle hHal,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008612 const v_BOOL_t isCcxIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008613{
8614 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8615
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008616 if (pMac->roam.configParam.isCcxIniFeatureEnabled == isCcxIniFeatureEnabled)
8617 {
8618 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8619 "%s: CCX Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)", __func__,
8620 pMac->roam.configParam.isCcxIniFeatureEnabled,
8621 isCcxIniFeatureEnabled);
8622 return eHAL_STATUS_SUCCESS;
8623 }
8624
Srinivas Girigowdade697412013-02-14 16:31:48 -08008625 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8626 "%s: CcxEnabled is changed from %d to %d", __func__,
8627 pMac->roam.configParam.isCcxIniFeatureEnabled,
8628 isCcxIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008629 pMac->roam.configParam.isCcxIniFeatureEnabled = isCcxIniFeatureEnabled;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008630 csrNeighborRoamUpdateCcxModeEnabled(pMac, isCcxIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008631
8632 if(TRUE == isCcxIniFeatureEnabled)
8633 {
8634 sme_UpdateFastTransitionEnabled(hHal, TRUE);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008635 }
Srinivas Girigowdaba173692013-08-07 11:55:38 -07008636
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07008637#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8638 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8639 {
8640 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CCX_INI_CFG_CHANGED);
8641 }
8642#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008643 return eHAL_STATUS_SUCCESS;
8644}
8645#endif /* FEATURE_WLAN_CCX */
8646
8647/*--------------------------------------------------------------------------
8648 \brief sme_UpdateConfigFwRssiMonitoring() - enable/disable firmware RSSI Monitoring at runtime
8649 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8650 fEnableFwRssiMonitoring.
Srinivas Girigowdade697412013-02-14 16:31:48 -08008651 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008652 \param hHal - The handle returned by macOpen.
8653 \return eHAL_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring. config successfully.
8654 Other status means SME is failed to update fEnableFwRssiMonitoring.
8655 \sa
8656 --------------------------------------------------------------------------*/
8657
8658eHalStatus sme_UpdateConfigFwRssiMonitoring(tHalHandle hHal,
8659 v_BOOL_t fEnableFwRssiMonitoring)
8660{
8661 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
8662
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008663 if (ccmCfgSetInt(hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR, fEnableFwRssiMonitoring,
8664 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8665 {
8666 halStatus = eHAL_STATUS_FAILURE;
8667 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008668 "Failure: Could not pass on WNI_CFG_PS_RSSI_MONITOR configuration info to CCM");
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08008669 }
8670
8671 return (halStatus);
8672}
8673
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008674#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srinivas Girigowdade697412013-02-14 16:31:48 -08008675/*--------------------------------------------------------------------------
8676 \brief sme_setNeighborLookupRssiThreshold() - update neighbor lookup rssi threshold
8677 This is a synchronous call
8678 \param hHal - The handle returned by macOpen.
8679 \return eHAL_STATUS_SUCCESS - SME update config successful.
8680 Other status means SME is failed to update
8681 \sa
8682 --------------------------------------------------------------------------*/
8683eHalStatus sme_setNeighborLookupRssiThreshold(tHalHandle hHal,
8684 v_U8_t neighborLookupRssiThreshold)
8685{
8686 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8687 eHalStatus status = eHAL_STATUS_SUCCESS;
8688
8689 status = sme_AcquireGlobalLock( &pMac->sme );
8690 if ( HAL_STATUS_SUCCESS( status ) )
8691 {
8692 status = csrNeighborRoamSetLookupRssiThreshold(pMac, neighborLookupRssiThreshold);
8693 if (HAL_STATUS_SUCCESS(status))
8694 {
8695 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8696 "LFR runtime successfully set Lookup threshold to %d - old value is %d - roam state is %d",
8697 neighborLookupRssiThreshold,
8698 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold,
8699 pMac->roam.neighborRoamInfo.neighborRoamState);
8700 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
8701 neighborLookupRssiThreshold;
8702 }
8703 sme_ReleaseGlobalLock( &pMac->sme );
8704 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08008705 return status;
8706}
8707
8708/*--------------------------------------------------------------------------
8709 \brief sme_setNeighborReassocRssiThreshold() - update neighbor reassoc rssi threshold
8710 This is a synchronous call
8711 \param hHal - The handle returned by macOpen.
8712 \return eHAL_STATUS_SUCCESS - SME update config successful.
8713 Other status means SME is failed to update
8714 \sa
8715 --------------------------------------------------------------------------*/
8716eHalStatus sme_setNeighborReassocRssiThreshold(tHalHandle hHal,
8717 v_U8_t neighborReassocRssiThreshold)
8718{
8719 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8720 eHalStatus status = eHAL_STATUS_SUCCESS;
8721
8722 status = sme_AcquireGlobalLock( &pMac->sme );
8723 if ( HAL_STATUS_SUCCESS( status ) )
8724 {
8725 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8726 "LFR runtime successfully set Reassoc threshold to %d - old value is %d - roam state is %d",
8727 neighborReassocRssiThreshold,
8728 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold,
8729 pMac->roam.neighborRoamInfo.neighborRoamState);
8730 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold =
8731 neighborReassocRssiThreshold;
8732 pMac->roam.neighborRoamInfo.cfgParams.neighborReassocThreshold =
8733 neighborReassocRssiThreshold;
8734 sme_ReleaseGlobalLock( &pMac->sme );
8735 }
8736
8737 return status ;
8738}
8739
8740
8741/*--------------------------------------------------------------------------
8742 \brief sme_getNeighborLookupRssiThreshold() - get neighbor lookup rssi threshold
8743 This is a synchronous call
8744 \param hHal - The handle returned by macOpen.
8745 \return eHAL_STATUS_SUCCESS - SME update config successful.
8746 Other status means SME is failed to update
8747 \sa
8748 --------------------------------------------------------------------------*/
8749v_U8_t sme_getNeighborLookupRssiThreshold(tHalHandle hHal)
8750{
8751 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8752 return pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
8753}
8754
8755/*--------------------------------------------------------------------------
8756 \brief sme_setNeighborScanRefreshPeriod() - set neighbor scan results refresh period
8757 This is a synchronous call
8758 \param hHal - The handle returned by macOpen.
8759 \return eHAL_STATUS_SUCCESS - SME update config successful.
8760 Other status means SME is failed to update
8761 \sa
8762 --------------------------------------------------------------------------*/
8763eHalStatus sme_setNeighborScanRefreshPeriod(tHalHandle hHal,
8764 v_U16_t neighborScanResultsRefreshPeriod)
8765{
8766 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8767 eHalStatus status = eHAL_STATUS_SUCCESS;
8768
8769 status = sme_AcquireGlobalLock( &pMac->sme );
8770 if ( HAL_STATUS_SUCCESS( status ) )
8771 {
8772 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8773 "LFR runtime successfully set roam scan refresh period to %d - old value is %d - roam state is %d",
8774 neighborScanResultsRefreshPeriod,
8775 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod,
8776 pMac->roam.neighborRoamInfo.neighborRoamState);
8777 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod =
8778 neighborScanResultsRefreshPeriod;
8779 pMac->roam.neighborRoamInfo.cfgParams.neighborResultsRefreshPeriod =
8780 neighborScanResultsRefreshPeriod;
8781
8782 sme_ReleaseGlobalLock( &pMac->sme );
8783 }
8784
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07008785#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8786 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8787 {
8788 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8789 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
8790 }
8791#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08008792 return status ;
8793}
8794
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07008795#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8796/*--------------------------------------------------------------------------
8797 \brief sme_UpdateRoamScanOffloadEnabled() - enable/disable roam scan offload feaure
8798 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8799 gRoamScanOffloadEnabled.
8800 This is a synchronous call
8801 \param hHal - The handle returned by macOpen.
8802 \return eHAL_STATUS_SUCCESS - SME update config successfully.
8803 Other status means SME is failed to update.
8804 \sa
8805 --------------------------------------------------------------------------*/
8806
8807eHalStatus sme_UpdateRoamScanOffloadEnabled(tHalHandle hHal,
8808 v_BOOL_t nRoamScanOffloadEnabled)
8809{
8810 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8811 eHalStatus status = eHAL_STATUS_SUCCESS;
8812
8813 status = sme_AcquireGlobalLock( &pMac->sme );
8814 if ( HAL_STATUS_SUCCESS( status ) )
8815 {
8816 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8817 "%s: gRoamScanOffloadEnabled is changed from %d to %d", __func__,
8818 pMac->roam.configParam.isRoamOffloadScanEnabled,
8819 nRoamScanOffloadEnabled);
8820 pMac->roam.configParam.isRoamOffloadScanEnabled = nRoamScanOffloadEnabled;
8821 sme_ReleaseGlobalLock( &pMac->sme );
8822 }
8823
8824 return status ;
8825}
8826#endif
8827
Srinivas Girigowdade697412013-02-14 16:31:48 -08008828/*--------------------------------------------------------------------------
8829 \brief sme_getNeighborScanRefreshPeriod() - get neighbor scan results refresh period
8830 This is a synchronous call
8831 \param hHal - The handle returned by macOpen.
8832 \return v_U16_t - Neighbor scan results refresh period value
8833 \sa
8834 --------------------------------------------------------------------------*/
8835v_U16_t sme_getNeighborScanRefreshPeriod(tHalHandle hHal)
8836{
8837 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8838 return pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
8839}
8840
8841/*--------------------------------------------------------------------------
8842 \brief sme_getEmptyScanRefreshPeriod() - get empty scan refresh period
8843 This is a synchronuous call
8844 \param hHal - The handle returned by macOpen.
8845 \return eHAL_STATUS_SUCCESS - SME update config successful.
8846 Other status means SME is failed to update
8847 \sa
8848 --------------------------------------------------------------------------*/
8849v_U16_t sme_getEmptyScanRefreshPeriod(tHalHandle hHal)
8850{
8851 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8852 return pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
8853}
8854
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008855/* ---------------------------------------------------------------------------
8856 \fn sme_UpdateEmptyScanRefreshPeriod
8857 \brief Update nEmptyScanRefreshPeriod
8858 This function is called through dynamic setConfig callback function
8859 to configure nEmptyScanRefreshPeriod
8860 Usage: adb shell iwpriv wlan0 setConfig nEmptyScanRefreshPeriod=[0 .. 60]
8861 \param hHal - HAL handle for device
8862 \param nEmptyScanRefreshPeriod - scan period following empty scan results.
8863 \- return Success or failure
8864 -------------------------------------------------------------------------*/
8865
8866eHalStatus sme_UpdateEmptyScanRefreshPeriod(tHalHandle hHal, v_U16_t nEmptyScanRefreshPeriod)
8867{
8868 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8869 eHalStatus status = eHAL_STATUS_SUCCESS;
8870
8871 status = sme_AcquireGlobalLock( &pMac->sme );
8872 if ( HAL_STATUS_SUCCESS( status ) )
8873 {
8874 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8875 "LFR runtime successfully set roam scan period to %d - old value is %d - roam state is %d",
8876 nEmptyScanRefreshPeriod,
8877 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod,
8878 pMac->roam.neighborRoamInfo.neighborRoamState);
8879 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
8880 pMac->roam.neighborRoamInfo.cfgParams.emptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
8881 sme_ReleaseGlobalLock( &pMac->sme );
8882 }
8883
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07008884#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8885 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8886 {
8887 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8888 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
8889 }
8890#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008891 return status ;
8892}
8893
8894/* ---------------------------------------------------------------------------
8895 \fn sme_setNeighborScanMinChanTime
8896 \brief Update nNeighborScanMinChanTime
8897 This function is called through dynamic setConfig callback function
8898 to configure gNeighborScanChannelMinTime
8899 Usage: adb shell iwpriv wlan0 setConfig gNeighborScanChannelMinTime=[0 .. 60]
8900 \param hHal - HAL handle for device
8901 \param nNeighborScanMinChanTime - Channel minimum dwell time
8902 \- return Success or failure
8903 -------------------------------------------------------------------------*/
8904eHalStatus sme_setNeighborScanMinChanTime(tHalHandle hHal, const v_U16_t nNeighborScanMinChanTime)
8905{
8906 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8907 eHalStatus status = eHAL_STATUS_SUCCESS;
8908
8909 status = sme_AcquireGlobalLock( &pMac->sme );
8910 if ( HAL_STATUS_SUCCESS( status ) )
8911 {
8912 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8913 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %d",
8914 nNeighborScanMinChanTime,
8915 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime,
8916 pMac->roam.neighborRoamInfo.neighborRoamState);
8917 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = nNeighborScanMinChanTime;
8918 pMac->roam.neighborRoamInfo.cfgParams.minChannelScanTime = nNeighborScanMinChanTime;
8919 sme_ReleaseGlobalLock( &pMac->sme );
8920 }
8921
8922 return status ;
8923}
8924
8925/* ---------------------------------------------------------------------------
8926 \fn sme_setNeighborScanMaxChanTime
8927 \brief Update nNeighborScanMaxChanTime
8928 This function is called through dynamic setConfig callback function
8929 to configure gNeighborScanChannelMaxTime
8930 Usage: adb shell iwpriv wlan0 setConfig gNeighborScanChannelMaxTime=[0 .. 60]
8931 \param hHal - HAL handle for device
8932 \param nNeighborScanMinChanTime - Channel maximum dwell time
8933 \- return Success or failure
8934 -------------------------------------------------------------------------*/
8935eHalStatus sme_setNeighborScanMaxChanTime(tHalHandle hHal, const v_U16_t nNeighborScanMaxChanTime)
8936{
8937 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8938 eHalStatus status = eHAL_STATUS_SUCCESS;
8939
8940 status = sme_AcquireGlobalLock( &pMac->sme );
8941 if ( HAL_STATUS_SUCCESS( status ) )
8942 {
8943 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8944 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %d",
8945 nNeighborScanMaxChanTime,
8946 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime,
8947 pMac->roam.neighborRoamInfo.neighborRoamState);
8948 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = nNeighborScanMaxChanTime;
8949 pMac->roam.neighborRoamInfo.cfgParams.maxChannelScanTime = nNeighborScanMaxChanTime;
8950 sme_ReleaseGlobalLock( &pMac->sme );
8951 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07008952#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8953 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8954 {
8955 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8956 REASON_SCAN_CH_TIME_CHANGED);
8957 }
8958#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008959
8960 return status ;
8961}
8962
8963/* ---------------------------------------------------------------------------
8964 \fn sme_getNeighborScanMinChanTime
8965 \brief get neighbor scan min channel time
8966 \param hHal - The handle returned by macOpen.
8967 \return v_U16_t - channel min time value
8968 -------------------------------------------------------------------------*/
8969v_U16_t sme_getNeighborScanMinChanTime(tHalHandle hHal)
8970{
8971 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8972 return pMac->roam.neighborRoamInfo.cfgParams.minChannelScanTime;
8973}
8974
8975/* ---------------------------------------------------------------------------
8976 \fn sme_getNeighborScanMaxChanTime
8977 \brief get neighbor scan max channel time
8978 \param hHal - The handle returned by macOpen.
8979 \return v_U16_t - channel max time value
8980 -------------------------------------------------------------------------*/
8981v_U16_t sme_getNeighborScanMaxChanTime(tHalHandle hHal)
8982{
8983 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8984 return pMac->roam.neighborRoamInfo.cfgParams.maxChannelScanTime;
8985}
8986
8987/* ---------------------------------------------------------------------------
8988 \fn sme_setNeighborScanPeriod
8989 \brief Update nNeighborScanPeriod
8990 This function is called through dynamic setConfig callback function
8991 to configure nNeighborScanPeriod
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07008992 Usage: adb shell iwpriv wlan0 setConfig nNeighborScanPeriod=[0 .. 1000]
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008993 \param hHal - HAL handle for device
8994 \param nNeighborScanPeriod - neighbor scan period
8995 \- return Success or failure
8996 -------------------------------------------------------------------------*/
8997eHalStatus sme_setNeighborScanPeriod(tHalHandle hHal, const v_U16_t nNeighborScanPeriod)
8998{
8999 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9000 eHalStatus status = eHAL_STATUS_SUCCESS;
9001
9002 status = sme_AcquireGlobalLock( &pMac->sme );
9003 if ( HAL_STATUS_SUCCESS( status ) )
9004 {
9005 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
9006 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %d",
9007 nNeighborScanPeriod,
9008 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod,
9009 pMac->roam.neighborRoamInfo.neighborRoamState);
9010 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = nNeighborScanPeriod;
9011 pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod = nNeighborScanPeriod;
9012 sme_ReleaseGlobalLock( &pMac->sme );
9013 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07009014#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9015 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9016 {
9017 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9018 REASON_SCAN_HOME_TIME_CHANGED);
9019 }
9020#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009021
9022 return status ;
9023}
9024
9025/* ---------------------------------------------------------------------------
9026 \fn sme_getNeighborScanPeriod
9027 \brief get neighbor scan period
9028 \param hHal - The handle returned by macOpen.
9029 \return v_U16_t - neighbor scan period
9030 -------------------------------------------------------------------------*/
9031v_U16_t sme_getNeighborScanPeriod(tHalHandle hHal)
9032{
9033 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9034 return pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
9035}
9036
9037#endif
9038
Srinivas Girigowdade697412013-02-14 16:31:48 -08009039#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009040
Srinivas Girigowdade697412013-02-14 16:31:48 -08009041/*--------------------------------------------------------------------------
9042 \brief sme_getRoamRssiDiff() - get Roam rssi diff
9043 This is a synchronous call
9044 \param hHal - The handle returned by macOpen.
9045 \return v_U16_t - Rssi diff value
9046 \sa
9047 --------------------------------------------------------------------------*/
9048v_U8_t sme_getRoamRssiDiff(tHalHandle hHal)
9049{
9050 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9051 return pMac->roam.configParam.RoamRssiDiff;
9052}
9053
9054/*--------------------------------------------------------------------------
9055 \brief sme_ChangeRoamScanChannelList() - Change roam scan channel list
9056 This is a synchronous call
9057 \param hHal - The handle returned by macOpen.
9058 \return eHAL_STATUS_SUCCESS - SME update config successful.
9059 Other status means SME is failed to update
9060 \sa
9061 --------------------------------------------------------------------------*/
9062eHalStatus sme_ChangeRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
9063 tANI_U8 numChannels)
9064{
9065 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9066 eHalStatus status = eHAL_STATUS_SUCCESS;
9067 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07009068 tANI_U8 oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
Kiet Lam600d3ca2013-08-31 16:33:32 +05309069 tANI_U8 newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
Srinivas Girigowdade697412013-02-14 16:31:48 -08009070 tANI_U8 i = 0, j = 0;
9071
9072 status = sme_AcquireGlobalLock( &pMac->sme );
9073 if ( HAL_STATUS_SUCCESS( status ) )
9074 {
9075 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
9076 {
9077 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
9078 {
9079 j += snprintf(oldChannelList + j, sizeof(oldChannelList) - j," %d",
9080 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
9081 }
9082 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009083 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07009084 csrCreateBgScanRoamChannelList(pMac, pChannelList, numChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08009085 status = csrUpdateBgScanConfigIniChannelList(pMac, csrGetCurrentBand(hHal));
9086
Srinivas Girigowda100eb322013-03-15 16:48:20 -07009087 if ( HAL_STATUS_SUCCESS( status ))
Srinivas Girigowdade697412013-02-14 16:31:48 -08009088 {
Srinivas Girigowda100eb322013-03-15 16:48:20 -07009089 sme_SetRoamScanControl(hHal, 1);
9090 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -08009091 {
Srinivas Girigowda100eb322013-03-15 16:48:20 -07009092 j = 0;
9093 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
9094 {
9095 j += snprintf(newChannelList + j, sizeof(newChannelList) - j," %d",
9096 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
9097 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08009098 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08009099
Srinivas Girigowda100eb322013-03-15 16:48:20 -07009100 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
9101 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
9102 newChannelList, oldChannelList,
9103 pMac->roam.neighborRoamInfo.neighborRoamState);
9104 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08009105 sme_ReleaseGlobalLock( &pMac->sme );
9106 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009107#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9108 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9109 {
9110 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
9111 }
9112#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08009113
9114 return status ;
9115}
9116
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009117
9118#ifdef FEATURE_WLAN_CCX_UPLOAD
9119/*--------------------------------------------------------------------------
9120 \brief sme_SetCcxRoamScanChannelList() - set ccx roam scan channel list
9121 This is a synchronuous call
9122 \param hHal - The handle returned by macOpen.
9123 \return eHAL_STATUS_SUCCESS - SME update config successful.
9124 Other status means SME is failed to update
9125 \sa
9126 --------------------------------------------------------------------------*/
9127eHalStatus sme_SetCcxRoamScanChannelList(tHalHandle hHal,
9128 tANI_U8 *pChannelList,
9129 tANI_U8 numChannels)
9130{
9131 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9132 eHalStatus status = eHAL_STATUS_SUCCESS;
9133 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
9134 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
9135 tANI_U8 oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
9136 tANI_U8 newChannelList[128] = {0};
9137 tANI_U8 i = 0, j = 0;
9138
9139 status = sme_AcquireGlobalLock( &pMac->sme );
9140 if ( HAL_STATUS_SUCCESS( status ) )
9141 {
9142 if (NULL != currChannelListInfo->ChannelList)
9143 {
9144 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
9145 {
9146 j += snprintf(oldChannelList + j, sizeof(oldChannelList) - j," %d",
9147 currChannelListInfo->ChannelList[i]);
9148 }
9149 }
9150 status = csrCreateRoamScanChannelList(pMac, pChannelList, numChannels, csrGetCurrentBand(hHal));
9151
9152 if ( HAL_STATUS_SUCCESS( status ))
9153 {
9154 if (NULL != currChannelListInfo->ChannelList)
9155 {
9156 j = 0;
9157 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
9158 {
9159 j += snprintf(newChannelList + j, sizeof(newChannelList) - j," %d",
9160 currChannelListInfo->ChannelList[i]);
9161 }
9162 }
9163
9164 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
9165 "CCX roam scan channel list successfully set to %s - old value is %s - roam state is %d",
9166 newChannelList, oldChannelList,
9167 pMac->roam.neighborRoamInfo.neighborRoamState);
9168 }
9169 sme_ReleaseGlobalLock( &pMac->sme );
9170 }
9171#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9172 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9173 {
9174 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
9175 }
9176#endif
9177
9178 return status ;
9179}
9180#endif
9181
Srinivas Girigowdade697412013-02-14 16:31:48 -08009182/*--------------------------------------------------------------------------
Srinivas Girigowdade697412013-02-14 16:31:48 -08009183 \brief csrUpdateBgScanConfigIniChannelList() - Update bgscan roam cache
9184 This is a synchronous call
9185 \param hHal - The handle returned by macOpen.
9186 \return eHAL_STATUS_SUCCESS - SME update config successful.
9187 Other status means SME is failed to update
9188 \sa
9189 --------------------------------------------------------------------------*/
9190eHalStatus sme_UpdateBgScanConfigIniChannelList(tHalHandle hHal,
9191 eCsrBand eBand)
9192{
9193 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9194 return csrUpdateBgScanConfigIniChannelList(pMac, eBand);
9195}
9196
9197/*--------------------------------------------------------------------------
9198 \brief sme_getRoamScanChannelList() - get roam scan channel list
9199 This is a synchronous call
9200 \param hHal - The handle returned by macOpen.
9201 \return eHAL_STATUS_SUCCESS - SME update config successful.
9202 Other status means SME is failed to update
9203 \sa
9204 --------------------------------------------------------------------------*/
9205eHalStatus sme_getRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
9206 tANI_U8 *pNumChannels)
9207{
9208 int i = 0;
9209 tANI_U8 *pOutPtr = pChannelList;
9210 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9211 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
9212 eHalStatus status = eHAL_STATUS_SUCCESS;
9213
9214 status = sme_AcquireGlobalLock( &pMac->sme );
9215 if ( HAL_STATUS_SUCCESS( status ) )
9216 {
9217 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
9218 {
9219 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
9220 "Roam Scan channel list is NOT yet initialized");
Srinivas Girigowda100eb322013-03-15 16:48:20 -07009221 *pNumChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08009222 sme_ReleaseGlobalLock( &pMac->sme );
Srinivas Girigowda100eb322013-03-15 16:48:20 -07009223 return status;
Srinivas Girigowdade697412013-02-14 16:31:48 -08009224 }
9225
9226 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
9227 for (i = 0; i < (*pNumChannels); i++)
9228 {
9229 pOutPtr[i] = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
9230 }
9231 pOutPtr[i] = '\0';
9232 sme_ReleaseGlobalLock( &pMac->sme );
9233 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08009234 return status ;
9235}
9236
9237/*--------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009238 \brief sme_getIsCcxFeatureEnabled() - get CCX feature enabled or not
9239 This is a synchronuous call
9240 \param hHal - The handle returned by macOpen.
9241 \return TRUE (1) - if the CCX feature is enabled
9242 FALSE (0) - if feature is disabled (compile or runtime)
9243 \sa
9244 --------------------------------------------------------------------------*/
9245tANI_BOOLEAN sme_getIsCcxFeatureEnabled(tHalHandle hHal)
Srinivas Girigowdade697412013-02-14 16:31:48 -08009246{
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009247#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdade697412013-02-14 16:31:48 -08009248 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009249 return csrRoamIsCcxIniFeatureEnabled(pMac);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009250#else
9251 return eANI_BOOLEAN_FALSE;
9252#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08009253}
9254
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009255/*--------------------------------------------------------------------------
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07009256 \brief sme_GetWESMode() - get WES Mode
9257 This is a synchronous call
9258 \param hHal - The handle returned by macOpen
9259 \return v_U8_t - WES Mode Enabled(1)/Disabled(0)
9260 \sa
9261 --------------------------------------------------------------------------*/
9262v_BOOL_t sme_GetWESMode(tHalHandle hHal)
9263{
9264 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9265 return pMac->roam.configParam.isWESModeEnabled;
9266}
9267
9268/*--------------------------------------------------------------------------
Srinivas Girigowda100eb322013-03-15 16:48:20 -07009269 \brief sme_GetRoamScanControl() - get scan control
9270 This is a synchronous call
9271 \param hHal - The handle returned by macOpen.
9272 \return v_BOOL_t - Enabled(1)/Disabled(0)
9273 \sa
9274 --------------------------------------------------------------------------*/
9275v_BOOL_t sme_GetRoamScanControl(tHalHandle hHal)
9276{
9277 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9278 return pMac->roam.configParam.nRoamScanControl;
9279}
9280#endif
9281
9282/*--------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009283 \brief sme_getIsLfrFeatureEnabled() - get LFR feature enabled or not
9284 This is a synchronuous call
9285 \param hHal - The handle returned by macOpen.
9286 \return TRUE (1) - if the feature is enabled
9287 FALSE (0) - if feature is disabled (compile or runtime)
9288 \sa
9289 --------------------------------------------------------------------------*/
9290tANI_BOOLEAN sme_getIsLfrFeatureEnabled(tHalHandle hHal)
9291{
9292#ifdef FEATURE_WLAN_LFR
9293 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9294 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
9295#else
9296 return eANI_BOOLEAN_FALSE;
9297#endif
9298}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08009299
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009300/*--------------------------------------------------------------------------
9301 \brief sme_getIsFtFeatureEnabled() - get FT feature enabled or not
9302 This is a synchronuous call
9303 \param hHal - The handle returned by macOpen.
9304 \return TRUE (1) - if the feature is enabled
9305 FALSE (0) - if feature is disabled (compile or runtime)
9306 \sa
9307 --------------------------------------------------------------------------*/
9308tANI_BOOLEAN sme_getIsFtFeatureEnabled(tHalHandle hHal)
9309{
9310#ifdef WLAN_FEATURE_VOWIFI_11R
9311 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9312 return pMac->roam.configParam.isFastTransitionEnabled;
9313#else
9314 return eANI_BOOLEAN_FALSE;
9315#endif
9316}
9317
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009318/* ---------------------------------------------------------------------------
9319 \fn sme_IsFeatureSupportedByFW
Kiet Lam0f320422013-11-21 19:29:17 +05309320 \brief Check if a feature is enabled by FW
9321
9322 \param featEnumValue - Enumeration value from placeHolderInCapBitmap
9323 \- return 1/0 (TRUE/FALSE)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009324 -------------------------------------------------------------------------*/
9325tANI_U8 sme_IsFeatureSupportedByFW(tANI_U8 featEnumValue)
9326{
9327 return IS_FEATURE_SUPPORTED_BY_FW(featEnumValue);
9328}
Kiet Lam0f320422013-11-21 19:29:17 +05309329
9330/* ---------------------------------------------------------------------------
9331 \fn sme_IsFeatureSupportedByDriver
9332 \brief Check if a feature is enabled by Driver
9333
9334 \param featEnumValue - Enumeration value from placeHolderInCapBitmap
9335 \- return 1/0 (TRUE/FALSE)
9336 -------------------------------------------------------------------------*/
9337
9338tANI_U8 sme_IsFeatureSupportedByDriver(tANI_U8 featEnumValue)
9339{
9340 return IS_FEATURE_SUPPORTED_BY_DRIVER(featEnumValue);
9341}
9342
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009343#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309344
9345/* ---------------------------------------------------------------------------
9346 \fn sme_SendTdlsMgmtFrame
9347 \brief API to send TDLS management frames.
9348
9349 \param peerMac - peer's Mac Adress.
9350 \param tdlsLinkEstablishParams - TDLS Peer Link Establishment Parameters
9351 \- return VOS_STATUS_SUCCES
9352 -------------------------------------------------------------------------*/
9353VOS_STATUS sme_SendTdlsLinkEstablishParams(tHalHandle hHal,
9354 tANI_U8 sessionId,
9355 tSirMacAddr peerMac,
9356 tCsrTdlsLinkEstablishParams *tdlsLinkEstablishParams)
9357{
9358 eHalStatus status = eHAL_STATUS_SUCCESS;
9359 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9360
9361 status = sme_AcquireGlobalLock( &pMac->sme );
9362
9363 if ( HAL_STATUS_SUCCESS( status ) )
9364 {
9365 status = csrTdlsSendLinkEstablishParams(hHal, sessionId, peerMac, tdlsLinkEstablishParams) ;
9366 sme_ReleaseGlobalLock( &pMac->sme );
9367 }
9368 return status ;
9369}
9370
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009371/* ---------------------------------------------------------------------------
9372 \fn sme_SendTdlsMgmtFrame
9373 \brief API to send TDLS management frames.
9374
9375 \param peerMac - peer's Mac Adress.
9376 \param frame_type - Type of TDLS mgmt frame to be sent.
9377 \param dialog - dialog token used in the frame.
9378 \param status - status to be incuded in the frame.
9379 \param buf - additional IEs to be included
9380 \param len - lenght of additional Ies
Hoonki Leea34dd892013-02-05 22:56:02 -08009381 \param responder - Tdls request type
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009382 \- return VOS_STATUS_SUCCES
9383 -------------------------------------------------------------------------*/
9384VOS_STATUS sme_SendTdlsMgmtFrame(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08009385 tANI_U8 frame_type, tANI_U8 dialog, tANI_U16 statusCode, tANI_U8 *buf, tANI_U8 len, tANI_U8 responder)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009386{
9387 eHalStatus status = eHAL_STATUS_SUCCESS;
9388 tCsrTdlsSendMgmt sendTdlsReq = {{0}} ;
9389 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9390
9391 status = sme_AcquireGlobalLock( &pMac->sme );
9392 if ( HAL_STATUS_SUCCESS( status ) )
9393 {
9394 vos_mem_copy(sendTdlsReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
9395 sendTdlsReq.frameType = frame_type;
9396 sendTdlsReq.buf = buf;
9397 sendTdlsReq.len = len;
9398 sendTdlsReq.dialog = dialog;
9399 sendTdlsReq.statusCode = statusCode;
Hoonki Leea34dd892013-02-05 22:56:02 -08009400 sendTdlsReq.responder = responder;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009401
9402 status = csrTdlsSendMgmtReq(hHal, sessionId, &sendTdlsReq) ;
9403
9404 sme_ReleaseGlobalLock( &pMac->sme );
9405 }
9406
9407 return status ;
9408
9409}
9410/* ---------------------------------------------------------------------------
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009411 \fn sme_ChangeTdlsPeerSta
9412 \brief API to Update TDLS peer sta parameters.
9413
9414 \param peerMac - peer's Mac Adress.
9415 \param staParams - Peer Station Parameters
9416 \- return VOS_STATUS_SUCCES
9417 -------------------------------------------------------------------------*/
9418VOS_STATUS sme_ChangeTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac,
9419 tCsrStaParams *pstaParams)
9420{
9421 eHalStatus status = eHAL_STATUS_SUCCESS;
9422 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9423
9424 status = sme_AcquireGlobalLock( &pMac->sme );
9425 if ( HAL_STATUS_SUCCESS( status ) )
9426 {
9427 status = csrTdlsChangePeerSta(hHal, sessionId, peerMac,pstaParams);
9428
9429 sme_ReleaseGlobalLock( &pMac->sme );
9430 }
9431
9432 return status ;
9433
9434}
9435
9436/* ---------------------------------------------------------------------------
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009437 \fn sme_AddTdlsPeerSta
9438 \brief API to Add TDLS peer sta entry.
9439
9440 \param peerMac - peer's Mac Adress.
9441 \- return VOS_STATUS_SUCCES
9442 -------------------------------------------------------------------------*/
9443VOS_STATUS sme_AddTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
9444{
9445 eHalStatus status = eHAL_STATUS_SUCCESS;
9446 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9447
9448 status = sme_AcquireGlobalLock( &pMac->sme );
9449 if ( HAL_STATUS_SUCCESS( status ) )
9450 {
9451 status = csrTdlsAddPeerSta(hHal, sessionId, peerMac);
9452
9453 sme_ReleaseGlobalLock( &pMac->sme );
9454 }
9455
9456 return status ;
9457
9458}
9459/* ---------------------------------------------------------------------------
9460 \fn sme_DeleteTdlsPeerSta
9461 \brief API to Delete TDLS peer sta entry.
9462
9463 \param peerMac - peer's Mac Adress.
9464 \- return VOS_STATUS_SUCCES
9465 -------------------------------------------------------------------------*/
9466VOS_STATUS sme_DeleteTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
9467{
9468 eHalStatus status = eHAL_STATUS_SUCCESS;
9469 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9470
9471 status = sme_AcquireGlobalLock( &pMac->sme );
9472 if ( HAL_STATUS_SUCCESS( status ) )
9473 {
9474 status = csrTdlsDelPeerSta(hHal, sessionId, peerMac) ;
9475
9476 sme_ReleaseGlobalLock( &pMac->sme );
9477 }
9478
9479 return status ;
9480
9481}
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07009482/* ---------------------------------------------------------------------------
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07009483 \fn sme_SetTdlsPowerSaveProhibited
9484 \API to set/reset the isTdlsPowerSaveProhibited.
9485
9486 \- return void
9487 -------------------------------------------------------------------------*/
9488void sme_SetTdlsPowerSaveProhibited(tHalHandle hHal, v_BOOL_t val)
9489{
9490 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9491
9492 pMac->isTdlsPowerSaveProhibited = val;
9493 return;
9494}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009495#endif
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05309496/* ---------------------------------------------------------------------------
9497 \fn sme_IsPmcBmps
9498 \API to Check if PMC state is BMPS.
9499
9500 \- return v_BOOL_t
9501 -------------------------------------------------------------------------*/
9502v_BOOL_t sme_IsPmcBmps(tHalHandle hHal)
9503{
9504 return (BMPS == pmcGetPmcState(hHal));
9505}
9506
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009507#ifdef FEATURE_WLAN_TDLS_INTERNAL
9508/*
9509 * SME API to start TDLS discovery Procedure
9510 */
9511VOS_STATUS sme_StartTdlsDiscoveryReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
9512{
9513 VOS_STATUS status = VOS_STATUS_SUCCESS;
9514 tCsrTdlsDisRequest disReq = {{0}} ;
9515 vos_mem_copy(disReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
9516 status = csrTdlsDiscoveryReq(hHal, sessionId, &disReq) ;
9517
9518 return status ;
9519
9520}
9521
9522/*
9523 * Process TDLS discovery results
9524 */
9525v_U8_t sme_GetTdlsDiscoveryResult(tHalHandle hHal,
9526 tSmeTdlsDisResult *disResult, v_U8_t listType)
9527{
9528 tCsrTdlsPeerLinkinfo *peerLinkInfo = NULL ;
9529 tSirTdlsPeerInfo *peerInfo = NULL ;
9530 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9531 tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
9532 tDblLinkList *peerList = &disInfo->tdlsPotentialPeerList ;
9533 tListElem *pEntry = NULL ;
9534 v_U8_t peerCnt = 0 ;
9535
9536 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009537 ("TDLS peer count = %d"),disInfo->tdlsPeerCount ) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009538 pEntry = csrLLPeekHead( peerList, LL_ACCESS_LOCK );
9539 while(pEntry)
9540 {
9541 peerLinkInfo = GET_BASE_ADDR( pEntry, tCsrTdlsPeerLinkinfo,
9542 tdlsPeerStaLink) ;
9543 peerInfo = &peerLinkInfo->tdlsDisPeerInfo ;
9544
9545 switch(listType)
9546 {
9547 case TDLS_SETUP_LIST:
9548 {
9549 if(TDLS_LINK_SETUP_STATE == peerInfo->tdlsPeerState)
9550 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309551 vos_mem_copy(disResult[peerCnt].tdlsPeerMac,
9552 peerInfo->peerMac, sizeof(tSirMacAddr));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009553 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
9554 peerCnt++ ;
9555 }
9556 break ;
9557 }
9558 case TDLS_DIS_LIST:
9559 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309560 vos_mem_copy(disResult[peerCnt].tdlsPeerMac,
9561 peerInfo->peerMac, sizeof(tSirMacAddr));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009562 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
9563 peerCnt++ ;
9564 break ;
9565 }
9566 default:
9567 {
9568 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009569 ("unknown list type ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009570 break ;
9571 }
9572 }
9573
9574 pEntry = csrLLNext( peerList, pEntry, LL_ACCESS_LOCK) ;
9575 }
9576
9577 return peerCnt ;
9578
9579}
9580
9581/*
9582 * SME API to start TDLS link setup Procedure.
9583 */
9584VOS_STATUS sme_StartTdlsLinkSetupReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
9585{
9586 VOS_STATUS status = VOS_STATUS_SUCCESS;
9587 tCsrTdlsSetupRequest setupReq = {{0}} ;
9588 vos_mem_copy(setupReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
9589 status = csrTdlsSetupReq(hHal, sessionId, &setupReq) ;
9590 return status ;
9591
9592}
9593
9594/*
9595 * SME API to start TDLS link Teardown Procedure.
9596 */
9597VOS_STATUS sme_StartTdlsLinkTeardownReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
9598{
9599 VOS_STATUS status = VOS_STATUS_SUCCESS;
9600 tCsrTdlsTeardownRequest teardownReq = {{0}} ;
9601 vos_mem_copy(teardownReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
9602 status = csrTdlsTeardownReq(hHal, sessionId, &teardownReq) ;
9603 return status ;
9604
9605}
9606
9607#endif /* FEATURE_WLAN_TDLS */
9608
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07009609eHalStatus sme_UpdateDfsSetting(tHalHandle hHal, tANI_U8 fUpdateEnableDFSChnlScan)
9610{
9611 eHalStatus status = eHAL_STATUS_FAILURE;
9612 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9613
9614 smsLog(pMac, LOG2, FL("enter"));
9615 status = sme_AcquireGlobalLock( &pMac->sme );
9616 if ( HAL_STATUS_SUCCESS( status ) )
9617 {
9618 pMac->scan.fEnableDFSChnlScan = fUpdateEnableDFSChnlScan;
9619 sme_ReleaseGlobalLock( &pMac->sme );
9620 }
9621 smsLog(pMac, LOG2, FL("exit status %d"), status);
9622
9623 return (status);
9624}
9625
Gopichand Nakkalae620d5a2013-04-26 05:45:57 -07009626/*
9627 * SME API to enable/disable WLAN driver initiated SSR
9628 */
9629void sme_UpdateEnableSSR(tHalHandle hHal, tANI_BOOLEAN enableSSR)
9630{
9631 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9632 eHalStatus status = eHAL_STATUS_SUCCESS;
9633
9634 status = sme_AcquireGlobalLock(&pMac->sme);
9635 if (HAL_STATUS_SUCCESS(status))
9636 {
9637 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
9638 "SSR level is changed %d", enableSSR);
9639 /* not serializing this messsage, as this is only going
9640 * to set a variable in WDA/WDI
9641 */
9642 WDA_SetEnableSSR(enableSSR);
9643 sme_ReleaseGlobalLock(&pMac->sme);
9644 }
9645 return;
9646}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07009647
9648/*
9649 * SME API to determine the channel bonding mode
9650 */
9651VOS_STATUS sme_SelectCBMode(tHalHandle hHal, eCsrPhyMode eCsrPhyMode, tANI_U8 channel)
9652{
9653 tSmeConfigParams smeConfig;
9654 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9655
9656 if (
9657#ifdef WLAN_FEATURE_11AC
9658 eCSR_DOT11_MODE_11ac != eCsrPhyMode &&
9659 eCSR_DOT11_MODE_11ac_ONLY != eCsrPhyMode &&
9660#endif
9661 eCSR_DOT11_MODE_11n != eCsrPhyMode &&
9662 eCSR_DOT11_MODE_11n_ONLY != eCsrPhyMode
9663 )
9664 {
9665 return VOS_STATUS_SUCCESS;
9666 }
9667
9668 /* If channel bonding mode is not required */
9669 if ( !pMac->roam.configParam.channelBondingMode5GHz ) {
9670 return VOS_STATUS_SUCCESS;
9671 }
9672
9673 vos_mem_zero(&smeConfig, sizeof (tSmeConfigParams));
9674 sme_GetConfigParam(pMac, &smeConfig);
9675
9676#ifdef WLAN_FEATURE_11AC
9677 if ( eCSR_DOT11_MODE_11ac == eCsrPhyMode ||
9678 eCSR_DOT11_MODE_11ac_ONLY == eCsrPhyMode )
9679 {
9680 if ( channel== 36 || channel == 52 || channel == 100 ||
9681 channel == 116 || channel == 149 )
9682 {
9683 smeConfig.csrConfig.channelBondingMode5GHz =
9684 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1;
9685 }
9686 else if ( channel == 40 || channel == 56 || channel == 104 ||
9687 channel == 120 || channel == 153 )
9688 {
9689 smeConfig.csrConfig.channelBondingMode5GHz =
9690 PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW - 1;
9691 }
9692 else if ( channel == 44 || channel == 60 || channel == 108 ||
9693 channel == 124 || channel == 157 )
9694 {
9695 smeConfig.csrConfig.channelBondingMode5GHz =
9696 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH -1;
9697 }
9698 else if ( channel == 48 || channel == 64 || channel == 112 ||
9699 channel == 128 || channel == 161 )
9700 {
9701 smeConfig.csrConfig.channelBondingMode5GHz =
9702 PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH - 1;
9703 }
9704 else if ( channel == 165 )
9705 {
9706 smeConfig.csrConfig.channelBondingMode5GHz = 0;
9707 }
9708 }
9709#endif
9710
9711 if ( eCSR_DOT11_MODE_11n == eCsrPhyMode ||
9712 eCSR_DOT11_MODE_11n_ONLY == eCsrPhyMode )
9713 {
9714 if ( channel== 40 || channel == 48 || channel == 56 ||
9715 channel == 64 || channel == 104 || channel == 112 ||
9716 channel == 120 || channel == 128 || channel == 136 ||
9717 channel == 144 || channel == 153 || channel == 161 )
9718 {
9719 smeConfig.csrConfig.channelBondingMode5GHz = 1;
9720 }
9721 else if ( channel== 36 || channel == 44 || channel == 52 ||
9722 channel == 60 || channel == 100 || channel == 108 ||
9723 channel == 116 || channel == 124 || channel == 132 ||
9724 channel == 140 || channel == 149 || channel == 157 )
9725 {
9726 smeConfig.csrConfig.channelBondingMode5GHz = 2;
9727 }
9728 else if ( channel == 165 )
9729 {
9730 smeConfig.csrConfig.channelBondingMode5GHz = 0;
9731 }
9732 }
9733 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009734 "cbmode selected=%d", smeConfig.csrConfig.channelBondingMode5GHz);
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07009735
9736 sme_UpdateConfig (pMac, &smeConfig);
9737 return VOS_STATUS_SUCCESS;
9738}
9739
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07009740/*--------------------------------------------------------------------------
9741
9742 \brief sme_SetCurrDeviceMode() - Sets the current operating device mode.
9743 \param hHal - The handle returned by macOpen.
9744 \param currDeviceMode - Current operating device mode.
9745 --------------------------------------------------------------------------*/
9746
9747void sme_SetCurrDeviceMode (tHalHandle hHal, tVOS_CON_MODE currDeviceMode)
9748{
9749 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9750 pMac->sme.currDeviceMode = currDeviceMode;
9751 return;
9752}
9753
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009754#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9755/*--------------------------------------------------------------------------
9756 \brief sme_HandoffRequest() - a wrapper function to Request a handoff
9757 from CSR.
9758 This is a synchronous call
9759 \param hHal - The handle returned by macOpen
9760 \param pHandoffInfo - info provided by HDD with the handoff request (namely:
9761 BSSID, channel etc.)
9762 \return eHAL_STATUS_SUCCESS - SME passed the request to CSR successfully.
9763 Other status means SME is failed to send the request.
9764 \sa
9765 --------------------------------------------------------------------------*/
9766
9767eHalStatus sme_HandoffRequest(tHalHandle hHal,
9768 tCsrHandoffRequest *pHandoffInfo)
9769{
9770 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9771 eHalStatus status = eHAL_STATUS_SUCCESS;
9772
9773 status = sme_AcquireGlobalLock( &pMac->sme );
9774 if ( HAL_STATUS_SUCCESS( status ) )
9775 {
9776 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
9777 "%s: invoked", __func__);
9778 status = csrHandoffRequest(pMac, pHandoffInfo);
9779 sme_ReleaseGlobalLock( &pMac->sme );
9780 }
9781
9782 return status ;
9783}
9784#endif
9785
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07009786/*
9787 * SME API to check if there is any infra station or
9788 * P2P client is connected
9789 */
9790VOS_STATUS sme_isSta_p2p_clientConnected(tHalHandle hHal)
9791{
9792 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9793 if(csrIsInfraConnected(pMac))
9794 {
9795 return VOS_STATUS_SUCCESS;
9796 }
9797 return VOS_STATUS_E_FAILURE;
9798}
9799
Leo Chang9056f462013-08-01 19:21:11 -07009800
9801#ifdef FEATURE_WLAN_LPHB
9802/* ---------------------------------------------------------------------------
9803 \fn sme_LPHBConfigReq
9804 \API to make configuration LPHB within FW.
9805 \param hHal - The handle returned by macOpen
9806 \param lphdReq - LPHB request argument by client
9807 \param pCallbackfn - LPHB timeout notification callback function pointer
9808 \- return Configuration message posting status, SUCCESS or Fail
9809 -------------------------------------------------------------------------*/
9810eHalStatus sme_LPHBConfigReq
9811(
9812 tHalHandle hHal,
9813 tSirLPHBReq *lphdReq,
9814 void (*pCallbackfn)(void *pAdapter, void *indParam)
9815)
9816{
9817 eHalStatus status = eHAL_STATUS_SUCCESS;
9818 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9819 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9820 vos_msg_t vosMessage;
9821
9822 status = sme_AcquireGlobalLock(&pMac->sme);
9823 if (eHAL_STATUS_SUCCESS == status)
9824 {
9825 if ((LPHB_SET_EN_PARAMS_INDID == lphdReq->cmd) &&
9826 (NULL == pCallbackfn) &&
Leo Changd9df8aa2013-09-26 13:32:26 -07009827 (NULL == pMac->sme.pLphbIndCb))
Leo Chang9056f462013-08-01 19:21:11 -07009828 {
9829 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9830 "%s: Indication Call back did not registered", __func__);
9831 sme_ReleaseGlobalLock(&pMac->sme);
9832 return eHAL_STATUS_FAILURE;
9833 }
9834 else if (NULL != pCallbackfn)
9835 {
Leo Changd9df8aa2013-09-26 13:32:26 -07009836 pMac->sme.pLphbIndCb = pCallbackfn;
Leo Chang9056f462013-08-01 19:21:11 -07009837 }
9838
9839 /* serialize the req through MC thread */
9840 vosMessage.bodyptr = lphdReq;
9841 vosMessage.type = WDA_LPHB_CONF_REQ;
9842 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
9843 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
9844 {
9845 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9846 "%s: Post Config LPHB MSG fail", __func__);
9847 status = eHAL_STATUS_FAILURE;
9848 }
9849 sme_ReleaseGlobalLock(&pMac->sme);
9850 }
9851
9852 return(status);
9853}
9854#endif /* FEATURE_WLAN_LPHB */
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07009855/*--------------------------------------------------------------------------
9856 \brief sme_enable_disable_split_scan() - a wrapper function to set the split
9857 scan parameter.
9858 This is a synchronous call
9859 \param hHal - The handle returned by macOpen
9860 \return NONE.
9861 \sa
9862 --------------------------------------------------------------------------*/
9863void sme_enable_disable_split_scan (tHalHandle hHal, tANI_U8 nNumStaChan,
9864 tANI_U8 nNumP2PChan)
9865{
9866 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9867
9868 pMac->roam.configParam.nNumStaChanCombinedConc = nNumStaChan;
9869 pMac->roam.configParam.nNumP2PChanCombinedConc = nNumP2PChan;
9870
9871 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
9872 "%s: SCAN nNumStaChanCombinedConc : %d,"
9873 "nNumP2PChanCombinedConc : %d ",
9874 __func__, nNumStaChan, nNumP2PChan);
9875
9876 return;
9877
9878}
Leo Chang9056f462013-08-01 19:21:11 -07009879
Yue Mab9c86f42013-08-14 15:59:08 -07009880/* ---------------------------------------------------------------------------
9881 \fn sme_AddPeriodicTxPtrn
9882 \brief API to Periodic TX Pattern Offload feature
9883 \param hHal - The handle returned by macOpen
9884 \param addPeriodicTxPtrnParams - Pointer to the add pattern structure
9885 \return eHalStatus
9886 ---------------------------------------------------------------------------*/
9887eHalStatus sme_AddPeriodicTxPtrn(tHalHandle hHal, tSirAddPeriodicTxPtrn
9888 *addPeriodicTxPtrnParams)
9889{
9890 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9891 eHalStatus status;
9892 vos_msg_t msg;
9893
9894 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
9895 {
9896 msg.type = WDA_ADD_PERIODIC_TX_PTRN_IND;
9897 msg.bodyptr = addPeriodicTxPtrnParams;
9898
9899 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
9900 {
9901 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,"%s: Not able "
9902 "to post WDA_ADD_PERIODIC_TX_PTRN_IND to WDA!",
9903 __func__);
9904
9905 sme_ReleaseGlobalLock(&pMac->sme);
9906 return eHAL_STATUS_FAILURE;
9907 }
9908
9909 sme_ReleaseGlobalLock(&pMac->sme);
9910 return eHAL_STATUS_SUCCESS;
9911 }
9912
9913 return status;
9914}
9915
9916/* ---------------------------------------------------------------------------
9917 \fn sme_DelPeriodicTxPtrn
9918 \brief API to Periodic TX Pattern Offload feature
9919 \param hHal - The handle returned by macOpen
9920 \param delPeriodicTxPtrnParams - Pointer to the delete pattern structure
9921 \return eHalStatus
9922 ---------------------------------------------------------------------------*/
9923eHalStatus sme_DelPeriodicTxPtrn(tHalHandle hHal, tSirDelPeriodicTxPtrn
9924 *delPeriodicTxPtrnParams)
9925{
9926 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9927 eHalStatus status;
9928 vos_msg_t msg;
9929
9930 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
9931 {
9932 msg.type = WDA_DEL_PERIODIC_TX_PTRN_IND;
9933 msg.bodyptr = delPeriodicTxPtrnParams;
9934
9935 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
9936 {
9937 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,"%s: Not able "
9938 "to post WDA_DEL_PERIODIC_TX_PTRN_IND to WDA!",
9939 __func__);
9940
9941 sme_ReleaseGlobalLock(&pMac->sme);
9942 return eHAL_STATUS_FAILURE;
9943 }
9944
9945 sme_ReleaseGlobalLock(&pMac->sme);
9946 return eHAL_STATUS_SUCCESS;
9947 }
9948
9949 return status;
9950}
9951
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009952void smeGetCommandQStatus( tHalHandle hHal )
9953{
9954 tSmeCmd *pTempCmd = NULL;
9955 tListElem *pEntry;
9956 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9957
9958 if (NULL == pMac)
9959 {
Kiet Lamcffc5862013-10-30 16:28:45 +05309960 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
9961 "%s: pMac is null", __func__);
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009962 return;
9963 }
9964
9965 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9966 if( pEntry )
9967 {
9968 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9969 }
9970 smsLog( pMac, LOGE, "Currently smeCmdActiveList has command (0x%X)",
9971 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
9972 if(pTempCmd)
9973 {
9974 if( eSmeCsrCommandMask & pTempCmd->command )
9975 {
9976 //CSR command is stuck. See what the reason code is for that command
9977 dumpCsrCommandInfo(pMac, pTempCmd);
9978 }
9979 } //if(pTempCmd)
9980
9981 smsLog( pMac, LOGE, "Currently smeCmdPendingList has %d commands",
9982 csrLLCount(&pMac->sme.smeCmdPendingList));
9983
9984 smsLog( pMac, LOGE, "Currently roamCmdPendingList has %d commands",
9985 csrLLCount(&pMac->roam.roamCmdPendingList));
9986
9987 return;
9988}
Rajeev79dbe4c2013-10-05 11:03:42 +05309989
9990#ifdef FEATURE_WLAN_BATCH_SCAN
9991/* ---------------------------------------------------------------------------
9992 \fn sme_SetBatchScanReq
9993 \brief API to set batch scan request in FW
9994 \param hHal - The handle returned by macOpen.
9995 \param pRequest - Pointer to the batch request.
9996 \param sessionId - session ID
9997 \param callbackRoutine - HDD callback which needs to be invoked after
9998 getting set batch scan response from FW
9999 \param callbackContext - pAdapter context
10000 \return eHalStatus
10001 ---------------------------------------------------------------------------*/
10002eHalStatus sme_SetBatchScanReq
10003(
10004 tHalHandle hHal, tSirSetBatchScanReq *pRequest, tANI_U8 sessionId,
10005 void (*callbackRoutine) (void *callbackCtx, tSirSetBatchScanRsp *pRsp),
10006 void *callbackContext
10007)
10008{
10009 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10010 eHalStatus status;
10011
10012 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
10013 {
10014 status = pmcSetBatchScanReq(hHal, pRequest, sessionId, callbackRoutine,
10015 callbackContext);
10016 sme_ReleaseGlobalLock( &pMac->sme );
10017 }
10018
10019 return status;
10020}
10021
10022/* ---------------------------------------------------------------------------
Chittajit Mitraf5413a42013-10-18 14:20:08 -070010023 \fn sme_SendRateUpdateInd
10024 \brief API to Update rate
10025 \param hHal - The handle returned by macOpen
10026 \param rateUpdateParams - Pointer to rate update params
10027 \return eHalStatus
10028 ---------------------------------------------------------------------------*/
10029eHalStatus sme_SendRateUpdateInd(tHalHandle hHal, tSirRateUpdateInd *rateUpdateParams)
10030{
10031 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10032 eHalStatus status;
10033 vos_msg_t msg;
10034
10035 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
10036 {
10037 msg.type = WDA_RATE_UPDATE_IND;
10038 msg.bodyptr = rateUpdateParams;
10039
10040 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
10041 {
10042 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,"%s: Not able "
10043 "to post WDA_SET_RMC_RATE_IND to WDA!",
10044 __func__);
10045
10046 sme_ReleaseGlobalLock(&pMac->sme);
10047 return eHAL_STATUS_FAILURE;
10048 }
10049
10050 sme_ReleaseGlobalLock(&pMac->sme);
10051 return eHAL_STATUS_SUCCESS;
10052 }
10053
10054 return status;
10055}
10056
10057/* ---------------------------------------------------------------------------
Rajeev79dbe4c2013-10-05 11:03:42 +053010058 \fn sme_TriggerBatchScanResultInd
10059 \brief API to trigger batch scan result indications from FW
10060 \param hHal - The handle returned by macOpen.
10061 \param pRequest - Pointer to get batch request.
10062 \param sessionId - session ID
10063 \param callbackRoutine - HDD callback which needs to be invoked after
10064 getting batch scan result indication from FW
10065 \param callbackContext - pAdapter context
10066 \return eHalStatus
10067 ---------------------------------------------------------------------------*/
10068eHalStatus sme_TriggerBatchScanResultInd
10069(
10070 tHalHandle hHal, tSirTriggerBatchScanResultInd *pRequest, tANI_U8 sessionId,
10071 void (*callbackRoutine) (void *callbackCtx, void *pRsp),
10072 void *callbackContext
10073)
10074{
10075 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10076 eHalStatus status;
10077
10078 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
10079 {
10080 status = pmcTriggerBatchScanResultInd(hHal, pRequest, sessionId,
10081 callbackRoutine, callbackContext);
10082 sme_ReleaseGlobalLock( &pMac->sme );
10083 }
10084
10085 return status;
10086}
10087
10088
10089/* ---------------------------------------------------------------------------
10090 \fn sme_StopBatchScanInd
10091 \brief API to stop batch scan request in FW
10092 \param hHal - The handle returned by macOpen.
10093 \param pRequest - Pointer to the batch request.
10094 \param sessionId - session ID
10095 \return eHalStatus
10096 ---------------------------------------------------------------------------*/
10097eHalStatus sme_StopBatchScanInd
10098(
10099 tHalHandle hHal, tSirStopBatchScanInd *pRequest, tANI_U8 sessionId
10100)
10101{
10102 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10103 eHalStatus status;
10104
10105 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
10106 {
10107 status = pmcStopBatchScanInd(hHal, pRequest, sessionId);
10108 sme_ReleaseGlobalLock( &pMac->sme );
10109 }
10110
10111 return status;
10112}
10113
10114#endif