blob: 5a632100e25fcccd798471f8523644e6c9860e9b [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05302 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -08003 *
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
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam0fb93dd2014-02-19 00:32:59 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/**=========================================================================
32
33 \file smeApi.c
34
35 \brief Definitions for SME APIs
36
Kiet Lamaa8e15a2014-02-11 23:30:06 -080037
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
40/*===========================================================================
41
42 EDIT HISTORY FOR FILE
43
44
45 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
47
48
49
50 when who what, where, why
51---------- --- --------------------------------------------------------
5206/03/10 js Added support to hostapd driven
53 * deauth/disassoc/mic failure
54
55===========================================================================*/
56
57/*--------------------------------------------------------------------------
58 Include Files
59 ------------------------------------------------------------------------*/
60
Jeff Johnson295189b2012-06-20 16:38:30 -070061
62#include "smsDebug.h"
63#include "sme_Api.h"
64#include "csrInsideApi.h"
65#include "smeInside.h"
66#include "csrInternal.h"
67#include "wlan_qct_wda.h"
68#include "halMsgApi.h"
Katya Nigam70d68332013-09-16 16:49:45 +053069#include "vos_trace.h"
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070070#include "sme_Trace.h"
Katya Nigambcb705f2013-12-26 14:26:22 +053071#include "vos_types.h"
72#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070073#include "sapApi.h"
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053074#include "macTrace.h"
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053075#include "vos_utils.h"
Sachin Ahujae4c6fac2016-12-29 10:30:15 +053076#include "limSession.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070077
Jeff Johnson295189b2012-06-20 16:38:30 -070078extern tSirRetStatus uMacPostCtrlMsg(void* pSirGlobal, tSirMbMsg* pMb);
79
80#include <wlan_qct_pal_api.h>
Katya Nigam70d68332013-09-16 16:49:45 +053081#define LOG_SIZE 256
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -080082#define READ_MEMORY_DUMP_CMD 9
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053083#define TL_INIT_STATE 0
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -080084
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070085
86#define CSR_ACTIVE_LIST_CMD_TIMEOUT_VALUE 1000*30 //30s
87
Jeff Johnson295189b2012-06-20 16:38:30 -070088// TxMB Functions
89extern eHalStatus pmcPrepareCommand( tpAniSirGlobal pMac, eSmeCommandType cmdType, void *pvParam,
90 tANI_U32 size, tSmeCmd **ppCmd );
91extern void pmcReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
92extern void qosReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
Sushant Kaushik298a8592014-12-09 17:34:07 +053093extern void csrReleaseRocReqCommand( tpAniSirGlobal pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070094extern eHalStatus p2pProcessRemainOnChannelCmd(tpAniSirGlobal pMac, tSmeCmd *p2pRemainonChn);
95extern eHalStatus sme_remainOnChnRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070096extern eHalStatus sme_remainOnChnReady( tHalHandle hHal, tANI_U8* pMsg);
97extern eHalStatus sme_sendActionCnf( tHalHandle hHal, tANI_U8* pMsg);
98extern eHalStatus p2pProcessNoAReq(tpAniSirGlobal pMac, tSmeCmd *pNoACmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070099
100static eHalStatus initSmeCmdList(tpAniSirGlobal pMac);
101static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping );
102
103eCsrPhyMode sme_GetPhyMode(tHalHandle hHal);
104
105eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf);
106
Sushant Kaushik1d732562014-05-21 14:15:37 +0530107void sme_DisconnectConnectedSessions(tpAniSirGlobal pMac);
108
Amar Singhal0d15bd52013-10-12 23:13:13 -0700109eHalStatus sme_HandleGenericChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf);
110
Jeff Johnson295189b2012-06-20 16:38:30 -0700111eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal);
112
113eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal);
114
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -0700115#ifdef FEATURE_WLAN_LFR
116tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac);
117#endif
118
Chet Lanctot186b5732013-03-18 10:26:30 -0700119#ifdef WLAN_FEATURE_11W
120eHalStatus sme_UnprotectedMgmtFrmInd( tHalHandle hHal,
121 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm );
122#endif
123
Jeff Johnson295189b2012-06-20 16:38:30 -0700124//Internal SME APIs
125eHalStatus sme_AcquireGlobalLock( tSmeStruct *psSme)
126{
127 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
128
129 if(psSme)
130 {
131 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psSme->lkSmeGlobalLock) ) )
132 {
133 status = eHAL_STATUS_SUCCESS;
134 }
135 }
136
137 return (status);
138}
139
140
141eHalStatus sme_ReleaseGlobalLock( tSmeStruct *psSme)
142{
143 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
144
145 if(psSme)
146 {
147 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psSme->lkSmeGlobalLock) ) )
148 {
149 status = eHAL_STATUS_SUCCESS;
150 }
151 }
152
153 return (status);
154}
155
156
157
158static eHalStatus initSmeCmdList(tpAniSirGlobal pMac)
159{
160 eHalStatus status;
161 tSmeCmd *pCmd;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530162 tANI_U32 cmd_idx;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -0700163 VOS_STATUS vosStatus;
164 vos_timer_t* cmdTimeoutTimer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700165
166 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530167 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
168 &pMac->sme.smeCmdActiveList)))
169 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -0700170
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530171 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
172 &pMac->sme.smeCmdPendingList)))
173 goto end;
174
175 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
176 &pMac->sme.smeScanCmdActiveList)))
177 goto end;
178
179 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
180 &pMac->sme.smeScanCmdPendingList)))
181 goto end;
182
183 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
184 &pMac->sme.smeCmdFreeList)))
185 goto end;
186
Hanumantha Reddy Pothula72342952015-02-26 14:43:54 +0530187 pCmd = (tSmeCmd *) vos_mem_vmalloc(sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
Kiet Lam64c1b492013-07-12 13:56:44 +0530188 if ( NULL == pCmd )
Hanumantha Reddy Pothula72342952015-02-26 14:43:54 +0530189 {
190 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
191 FL("fail to allocate memory %lu"),
192 (unsigned long)(sizeof(tSmeCmd) * pMac->sme.totalSmeCmd));
Kiet Lam64c1b492013-07-12 13:56:44 +0530193 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula72342952015-02-26 14:43:54 +0530194 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530195 else
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530196 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530197 status = eHAL_STATUS_SUCCESS;
198
199 vos_mem_set(pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd, 0);
200 pMac->sme.pSmeCmdBufAddr = pCmd;
201
202 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++)
203 {
204 csrLLInsertTail(&pMac->sme.smeCmdFreeList,
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530205 &pCmd[cmd_idx].Link, LL_ACCESS_LOCK);
Kiet Lam64c1b492013-07-12 13:56:44 +0530206 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 }
208
Kalikinkar Dharaa4988972013-10-28 13:39:54 -0700209 /* This timer is only to debug the active list command timeout */
210
211 cmdTimeoutTimer = (vos_timer_t*)vos_mem_malloc(sizeof(vos_timer_t));
212 if (cmdTimeoutTimer)
213 {
214 pMac->sme.smeCmdActiveList.cmdTimeoutTimer = cmdTimeoutTimer;
215 vosStatus =
216 vos_timer_init( pMac->sme.smeCmdActiveList.cmdTimeoutTimer,
217 VOS_TIMER_TYPE_SW,
218 activeListCmdTimeoutHandle,
219 (void*) pMac);
220
221 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
222 {
223 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
224 "Init Timer fail for active list command process time out");
225 vos_mem_free(pMac->sme.smeCmdActiveList.cmdTimeoutTimer);
226 }
227 else
228 {
229 pMac->sme.smeCmdActiveList.cmdTimeoutDuration =
230 CSR_ACTIVE_LIST_CMD_TIMEOUT_VALUE;
231 }
232 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530233end:
234 if (!HAL_STATUS_SUCCESS(status))
235 smsLog(pMac, LOGE, "failed to initialize sme command list:%d\n",
236 status);
237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 return (status);
239}
240
241
242void smeReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCmd)
243{
244 pCmd->command = eSmeNoCommand;
245 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd->Link, LL_ACCESS_LOCK);
246}
247
248
249
250static void smeReleaseCmdList(tpAniSirGlobal pMac, tDblLinkList *pList)
251{
252 tListElem *pEntry;
253 tSmeCmd *pCommand;
254
255 while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_LOCK)) != NULL)
256 {
257 //TODO: base on command type to call release functions
258 //reinitialize different command types so they can be reused
259 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
260 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
261 }
262}
263
264static void purgeSmeCmdList(tpAniSirGlobal pMac)
265{
266 //release any out standing commands back to free command list
267 smeReleaseCmdList(pMac, &pMac->sme.smeCmdPendingList);
268 smeReleaseCmdList(pMac, &pMac->sme.smeCmdActiveList);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530269 smeReleaseCmdList(pMac, &pMac->sme.smeScanCmdPendingList);
270 smeReleaseCmdList(pMac, &pMac->sme.smeScanCmdActiveList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700271}
272
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +0530273void purgeSmeSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +0530274 tDblLinkList *pList, bool flush_all)
Jeff Johnson295189b2012-06-20 16:38:30 -0700275{
276 //release any out standing commands back to free command list
277 tListElem *pEntry, *pNext;
278 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 tDblLinkList localList;
280
281 vos_mem_zero(&localList, sizeof(tDblLinkList));
282 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
283 {
284 smsLog(pMac, LOGE, FL(" failed to open list"));
285 return;
286 }
287
288 csrLLLock(pList);
289 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
290 while(pEntry != NULL)
291 {
292 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
293 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh7b2d0812016-04-28 11:44:29 +0530294 if (!flush_all &&
295 csr_is_disconnect_full_power_cmd(pCommand)) {
296 smsLog(pMac, LOGW, FL(" Ignore disconnect"));
297 pEntry = pNext;
298 continue;
299 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 if(pCommand->sessionId == sessionId)
301 {
302 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
303 {
304 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
305 }
306 }
307 pEntry = pNext;
308 }
309 csrLLUnlock(pList);
310
311 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
312 {
313 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
314 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
315 }
316 csrLLClose(&localList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700317}
318
319
320static eHalStatus freeSmeCmdList(tpAniSirGlobal pMac)
321{
322 eHalStatus status = eHAL_STATUS_SUCCESS;
323
324 purgeSmeCmdList(pMac);
325 csrLLClose(&pMac->sme.smeCmdPendingList);
326 csrLLClose(&pMac->sme.smeCmdActiveList);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530327 csrLLClose(&pMac->sme.smeScanCmdPendingList);
328 csrLLClose(&pMac->sme.smeScanCmdActiveList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 csrLLClose(&pMac->sme.smeCmdFreeList);
330
Kalikinkar Dharaa4988972013-10-28 13:39:54 -0700331 /*destroy active list command time out timer */
332 vos_timer_destroy(pMac->sme.smeCmdActiveList.cmdTimeoutTimer);
333 vos_mem_free(pMac->sme.smeCmdActiveList.cmdTimeoutTimer);
334 pMac->sme.smeCmdActiveList.cmdTimeoutTimer = NULL;
335
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800336 status = vos_lock_acquire(&pMac->sme.lkSmeGlobalLock);
337 if(status != eHAL_STATUS_SUCCESS)
338 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800339 smsLog(pMac, LOGE,
340 FL("Failed to acquire the lock status = %d"), status);
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800341 goto done;
342 }
343
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 if(NULL != pMac->sme.pSmeCmdBufAddr)
345 {
Hanumantha Reddy Pothula72342952015-02-26 14:43:54 +0530346 vos_mem_vfree(pMac->sme.pSmeCmdBufAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 pMac->sme.pSmeCmdBufAddr = NULL;
348 }
349
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800350 status = vos_lock_release(&pMac->sme.lkSmeGlobalLock);
351 if(status != eHAL_STATUS_SUCCESS)
352 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800353 smsLog(pMac, LOGE,
354 FL("Failed to release the lock status = %d"), status);
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800355 }
356done:
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 return (status);
358}
359
360
361void dumpCsrCommandInfo(tpAniSirGlobal pMac, tSmeCmd *pCmd)
362{
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 switch( pCmd->command )
364 {
365 case eSmeCommandScan:
366 smsLog( pMac, LOGE, " scan command reason is %d", pCmd->u.scanCmd.reason );
367 break;
368
369 case eSmeCommandRoam:
370 smsLog( pMac, LOGE, " roam command reason is %d", pCmd->u.roamCmd.roamReason );
371 break;
372
373 case eSmeCommandWmStatusChange:
374 smsLog( pMac, LOGE, " WMStatusChange command type is %d", pCmd->u.wmStatusChangeCmd.Type );
375 break;
376
377 case eSmeCommandSetKey:
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800378 smsLog( pMac, LOGE, " setKey command auth(%d) enc(%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 pCmd->u.setKeyCmd.authType, pCmd->u.setKeyCmd.encType );
380 break;
381
382 case eSmeCommandRemoveKey:
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800383 smsLog( pMac, LOGE, " removeKey command auth(%d) enc(%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 pCmd->u.removeKeyCmd.authType, pCmd->u.removeKeyCmd.encType );
385 break;
386
387 default:
Kalikinkar Dharaa4988972013-10-28 13:39:54 -0700388 smsLog( pMac, LOGE, " default: Unhandled command %d",
389 pCmd->command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700390 break;
391 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700392}
393
394tSmeCmd *smeGetCommandBuffer( tpAniSirGlobal pMac )
395{
396 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
397 tListElem *pEntry;
Sushant Kaushikc9d0f422014-06-23 18:59:30 +0530398 static int smeCommandQueueFull = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK );
400
401 // If we can get another MS Msg buffer, then we are ok. Just link
402 // the entry onto the linked list. (We are using the linked list
403 // to keep track of tfhe message buffers).
404 if ( pEntry )
405 {
406 pRetCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Sushant Kaushikc9d0f422014-06-23 18:59:30 +0530407 /* reset when free list is available */
408 smeCommandQueueFull = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 }
Padma, Santhosh Kumar0a350582015-06-12 15:23:49 +0530410 else
411 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 int idx = 1;
413
414 //Cannot change pRetCmd here since it needs to return later.
415 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
416 if( pEntry )
417 {
418 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
419 }
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800420 smsLog( pMac, LOGE, "Out of command buffer.... command (0x%X) stuck",
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
422 if(pTempCmd)
423 {
424 if( eSmeCsrCommandMask & pTempCmd->command )
425 {
426 //CSR command is stuck. See what the reason code is for that command
427 dumpCsrCommandInfo(pMac, pTempCmd);
428 }
429 } //if(pTempCmd)
430
431 //dump what is in the pending queue
432 csrLLLock(&pMac->sme.smeCmdPendingList);
433 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
Sushant Kaushikc9d0f422014-06-23 18:59:30 +0530434 while(pEntry && !smeCommandQueueFull)
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 {
436 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Sushant Kaushikc9d0f422014-06-23 18:59:30 +0530437 /* Print only 1st five commands from pending queue. */
438 if (idx <= 5)
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800439 smsLog( pMac, LOGE, "Out of command buffer.... SME pending command #%d (0x%X)",
Sushant Kaushikc9d0f422014-06-23 18:59:30 +0530440 idx, pTempCmd->command );
441 idx++;
Jeff Johnson295189b2012-06-20 16:38:30 -0700442 if( eSmeCsrCommandMask & pTempCmd->command )
443 {
444 //CSR command is stuck. See what the reason code is for that command
445 dumpCsrCommandInfo(pMac, pTempCmd);
446 }
447 pEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
448 }
449 csrLLUnlock(&pMac->sme.smeCmdPendingList);
450
Padma, Santhosh Kumar0a350582015-06-12 15:23:49 +0530451 idx = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 //There may be some more command in CSR's own pending queue
453 csrLLLock(&pMac->roam.roamCmdPendingList);
454 pEntry = csrLLPeekHead( &pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK );
Padma, Santhosh Kumar0a350582015-06-12 15:23:49 +0530455 while(pEntry && !smeCommandQueueFull)
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 {
457 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Padma, Santhosh Kumar0a350582015-06-12 15:23:49 +0530458 /* Print only 1st five commands from CSR pending queue */
459 if (idx <= 5)
460 smsLog( pMac, LOGE,
461 "Out of command buffer...CSR pending command #%d (0x%X)",
462 idx, pTempCmd->command );
463 idx++;
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 dumpCsrCommandInfo(pMac, pTempCmd);
465 pEntry = csrLLNext( &pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
466 }
Padma, Santhosh Kumar0a350582015-06-12 15:23:49 +0530467 /*
468 * Increament static variable so that it prints pending command
469 * only once
470 */
471 smeCommandQueueFull++;
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 csrLLUnlock(&pMac->roam.roamCmdPendingList);
Padma, Santhosh Kumar0a350582015-06-12 15:23:49 +0530473
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +0530474 vos_state_info_dump_all();
475
Abhishek Singh837adf22015-10-01 17:37:37 +0530476 if (pMac->roam.configParam.enableFatalEvent)
477 {
478 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
479 WLAN_LOG_INDICATOR_HOST_DRIVER,
480 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF,
Abhishek Singh4eaf6792016-02-04 12:36:39 +0530481 FALSE, FALSE);
Abhishek Singh837adf22015-10-01 17:37:37 +0530482 }
483 else
484 {
Abhishek Singh84fc7512015-10-06 14:27:25 +0530485 /* Trigger SSR */
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +0530486 vos_wlanRestart(VOS_GET_MSG_BUFF_FAILURE);
Abhishek Singh837adf22015-10-01 17:37:37 +0530487 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 }
489
Masti, Narayanraddi5240fbe2015-02-05 16:51:28 +0530490 if( pRetCmd )
491 {
492 vos_mem_set((tANI_U8 *)&pRetCmd->command, sizeof(pRetCmd->command), 0);
493 vos_mem_set((tANI_U8 *)&pRetCmd->sessionId, sizeof(pRetCmd->sessionId), 0);
494 vos_mem_set((tANI_U8 *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
495 }
496
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 return( pRetCmd );
498}
499
500
501void smePushCommand( tpAniSirGlobal pMac, tSmeCmd *pCmd, tANI_BOOLEAN fHighPriority )
502{
Sushant Kaushik4928e542014-12-29 15:25:54 +0530503 if (!SME_IS_START(pMac))
504 {
505 smsLog( pMac, LOGE, FL("Sme in stop state"));
506 return;
507 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 if ( fHighPriority )
509 {
510 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
511 }
512 else
513 {
514 csrLLInsertTail( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
515 }
516
517 // process the command queue...
518 smeProcessPendingQueue( pMac );
519
520 return;
521}
522
523
524static eSmeCommandType smeIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand )
525{
526 eSmeCommandType pmcCommand = eSmeNoCommand;
527 tANI_BOOLEAN fFullPowerNeeded = eANI_BOOLEAN_FALSE;
528 tPmcState pmcState;
529 eHalStatus status;
530
531 do
532 {
533 pmcState = pmcGetPmcState(pMac);
534
535 status = csrIsFullPowerNeeded( pMac, pCommand, NULL, &fFullPowerNeeded );
536 if( !HAL_STATUS_SUCCESS(status) )
537 {
538 //PMC state is not right for the command, drop it
539 return ( eSmeDropCommand );
540 }
541 if( fFullPowerNeeded ) break;
542 fFullPowerNeeded = ( ( eSmeCommandAddTs == pCommand->command ) ||
543 ( eSmeCommandDelTs == pCommand->command ) );
544 if( fFullPowerNeeded ) break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700545#ifdef FEATURE_OEM_DATA_SUPPORT
Kalikinkar Dharaa4988972013-10-28 13:39:54 -0700546 fFullPowerNeeded = (pmcState == IMPS &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700547 eSmeCommandOemDataReq == pCommand->command);
548 if(fFullPowerNeeded) break;
549#endif
Kalikinkar Dharaa4988972013-10-28 13:39:54 -0700550 fFullPowerNeeded = (pmcState == IMPS &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 eSmeCommandRemainOnChannel == pCommand->command);
552 if(fFullPowerNeeded) break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 } while(0);
554
555 if( fFullPowerNeeded )
556 {
557 switch( pmcState )
558 {
559 case IMPS:
560 case STANDBY:
561 pmcCommand = eSmeCommandExitImps;
562 break;
563
564 case BMPS:
565 pmcCommand = eSmeCommandExitBmps;
566 break;
567
568 case UAPSD:
569 pmcCommand = eSmeCommandExitUapsd;
570 break;
571
572 case WOWL:
573 pmcCommand = eSmeCommandExitWowl;
574 break;
575
576 default:
577 break;
578 }
579 }
580
581 return ( pmcCommand );
582}
583
584
585//For commands that need to do extra cleanup.
586static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
587{
588 if( eSmePmcCommandMask & pCommand->command )
589 {
590 pmcAbortCommand( pMac, pCommand, fStopping );
591 }
592 else if ( eSmeCsrCommandMask & pCommand->command )
593 {
594 csrAbortCommand( pMac, pCommand, fStopping );
595 }
596 else
597 {
598 switch( pCommand->command )
599 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 case eSmeCommandRemainOnChannel:
601 if (NULL != pCommand->u.remainChlCmd.callback)
602 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -0700603 remainOnChanCallback callback =
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 pCommand->u.remainChlCmd.callback;
605 /* process the msg */
606 if( callback )
607 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -0700608 callback(pMac, pCommand->u.remainChlCmd.callbackCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 eCSR_SCAN_ABORT );
610 }
611 }
612 smeReleaseCommand( pMac, pCommand );
613 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 default:
615 smeReleaseCommand( pMac, pCommand );
616 break;
617 }
618 }
619}
620
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530621tListElem *csrGetCmdToProcess(tpAniSirGlobal pMac, tDblLinkList *pList,
622 tANI_U8 sessionId, tANI_BOOLEAN fInterlocked)
623{
624 tListElem *pCurEntry = NULL;
625 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -0700626
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530627 /* Go through the list and return the command whose session id is not
628 * matching with the current ongoing scan cmd sessionId */
629 pCurEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK );
630 while (pCurEntry)
631 {
632 pCommand = GET_BASE_ADDR(pCurEntry, tSmeCmd, Link);
633 if (pCommand->sessionId != sessionId)
634 {
635 smsLog(pMac, LOG1, "selected the command with different sessionId");
636 return pCurEntry;
637 }
638
639 pCurEntry = csrLLNext(pList, pCurEntry, fInterlocked);
640 }
641
642 smsLog(pMac, LOG1, "No command pending with different sessionId");
643 return NULL;
644}
645
646tANI_BOOLEAN smeProcessScanQueue(tpAniSirGlobal pMac)
647{
648 tListElem *pEntry;
649 tSmeCmd *pCommand;
650 tListElem *pSmeEntry;
651 tSmeCmd *pSmeCommand;
652 tANI_BOOLEAN status = eANI_BOOLEAN_TRUE;
653
654 csrLLLock( &pMac->sme.smeScanCmdActiveList );
655 if (csrLLIsListEmpty( &pMac->sme.smeScanCmdActiveList,
656 LL_ACCESS_NOLOCK ))
657 {
658 if (!csrLLIsListEmpty(&pMac->sme.smeScanCmdPendingList,
659 LL_ACCESS_LOCK))
660 {
661 pEntry = csrLLPeekHead( &pMac->sme.smeScanCmdPendingList,
662 LL_ACCESS_LOCK );
663 if (pEntry)
664 {
665 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
666 //We cannot execute any command in wait-for-key state until setKey is through.
667 if (CSR_IS_WAIT_FOR_KEY( pMac, pCommand->sessionId))
668 {
669 if (!CSR_IS_SET_KEY_COMMAND(pCommand))
670 {
671 smsLog(pMac, LOGE,
672 " Cannot process command(%d) while waiting for key",
673 pCommand->command);
674 status = eANI_BOOLEAN_FALSE;
675 goto end;
676 }
677 }
678
679 if ((!csrLLIsListEmpty(&pMac->sme.smeCmdActiveList,
680 LL_ACCESS_LOCK )))
681 {
682 pSmeEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList,
683 LL_ACCESS_LOCK);
684 if (pEntry)
685 {
686 pSmeCommand = GET_BASE_ADDR(pEntry, tSmeCmd,
687 Link) ;
688
689 /* if scan is running on one interface and SME recei
690 ves the next command on the same interface then
691 dont the allow the command to be queued to
692 smeCmdPendingList. If next scan is allowed on
693 the same interface the CSR state machine will
694 get screwed up. */
695 if (pSmeCommand->sessionId == pCommand->sessionId)
696 {
697 status = eANI_BOOLEAN_FALSE;
698 goto end;
699 }
700 }
701 }
702 if ( csrLLRemoveEntry( &pMac->sme.smeScanCmdPendingList,
703 pEntry, LL_ACCESS_LOCK ) )
704 {
705 csrLLInsertHead( &pMac->sme.smeScanCmdActiveList,
706 &pCommand->Link, LL_ACCESS_NOLOCK );
707
708 switch (pCommand->command)
709 {
710 case eSmeCommandScan:
711 smsLog(pMac, LOG1,
712 " Processing scan offload command ");
713 csrProcessScanCommand( pMac, pCommand );
714 break;
715 default:
716 smsLog(pMac, LOGE,
717 " Something wrong, wrong command enqueued"
718 " to smeScanCmdPendingList");
719 pEntry = csrLLRemoveHead(
720 &pMac->sme.smeScanCmdActiveList,
721 LL_ACCESS_NOLOCK );
722 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
723 smeReleaseCommand( pMac, pCommand );
724 break;
725 }
726 }
727 }
728 }
729 }
730end:
731 csrLLUnlock(&pMac->sme.smeScanCmdActiveList);
732 return status;
733}
Jeff Johnson295189b2012-06-20 16:38:30 -0700734
Hanumantha Reddy Pothula28b1e652015-02-02 21:10:13 +0530735eHalStatus smeProcessPnoCommand(tpAniSirGlobal pMac, tSmeCmd *pCmd)
736{
737 tpSirPNOScanReq pnoReqBuf;
738 tSirMsgQ msgQ;
739
740 pnoReqBuf = vos_mem_malloc(sizeof(tSirPNOScanReq));
741 if ( NULL == pnoReqBuf )
742 {
743 smsLog(pMac, LOGE, FL("failed to allocate memory"));
744 return eHAL_STATUS_FAILURE;
745 }
746
747 vos_mem_copy(pnoReqBuf, &(pCmd->u.pnoInfo), sizeof(tSirPNOScanReq));
748
749 smsLog(pMac, LOG1, FL("post WDA_SET_PNO_REQ comamnd"));
750 msgQ.type = WDA_SET_PNO_REQ;
751 msgQ.reserved = 0;
752 msgQ.bodyptr = pnoReqBuf;
753 msgQ.bodyval = 0;
754 wdaPostCtrlMsg( pMac, &msgQ);
755
756 return eHAL_STATUS_SUCCESS;
757}
758
Abhishek Singh99a31be2015-12-10 10:37:44 +0530759/**
760 * sme_process_set_max_tx_power() - Set the Maximum Transmit Power
761 *
762 * @pMac: mac pointer.
763 * @command: cmd param containing bssid, self mac
764 * and power in db
765 *
766 * Set the maximum transmit power dynamically.
767 *
768 * Return: eHalStatus
769 *
770 */
771eHalStatus sme_process_set_max_tx_power(tpAniSirGlobal pMac,
772 tSmeCmd *command)
773{
774 vos_msg_t msg;
775 tMaxTxPowerParams *max_tx_params = NULL;
776
777 max_tx_params = vos_mem_malloc(sizeof(*max_tx_params));
778 if (NULL == max_tx_params)
779 {
780 smsLog(pMac, LOGE, FL("fail to allocate memory for max_tx_params"));
781 return eHAL_STATUS_FAILURE;
782 }
783
784 vos_mem_copy(max_tx_params->bssId,
785 command->u.set_tx_max_pwr.bssid, SIR_MAC_ADDR_LENGTH);
786 vos_mem_copy(max_tx_params->selfStaMacAddr,
787 command->u.set_tx_max_pwr.self_sta_mac_addr,
788 SIR_MAC_ADDR_LENGTH);
789 max_tx_params->power =
790 command->u.set_tx_max_pwr.power;
791
792 msg.type = WDA_SET_MAX_TX_POWER_REQ;
793 msg.reserved = 0;
794 msg.bodyptr = max_tx_params;
795
796 if(VOS_STATUS_SUCCESS !=
797 vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
798 {
799 smsLog(pMac, LOGE,
800 FL("Not able to post WDA_SET_MAX_TX_POWER_REQ message to WDA"));
801 vos_mem_free(max_tx_params);
802 return eHAL_STATUS_FAILURE;
803 }
804 return eHAL_STATUS_SUCCESS;
805}
806
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +0530807/**
808 * sme_process_set_max_tx_power_per_band() - Set the Maximum Transmit Power
809 * specific to band dynamically
810 * @mac_ctx: mac context
811 * @command: cmd param containing band, and power in db
812 *
813 * Set the maximum transmit power dynamically per band
814 *
815 * Return: eHalStatus
816 */
817eHalStatus sme_process_set_max_tx_power_per_band(tpAniSirGlobal mac_ctx,
818 tSmeCmd *command)
819{
820 vos_msg_t msg;
821 tMaxTxPowerPerBandParams *max_tx_params_per_band;
822
823 max_tx_params_per_band =
824 vos_mem_malloc(sizeof(*max_tx_params_per_band));
825 if (max_tx_params_per_band == NULL) {
826 smsLog(mac_ctx, LOGE,
827 FL("fail to allocate memory"));
828 return eHAL_STATUS_FAILURE;
829 }
830
831 max_tx_params_per_band->bandInfo =
832 command->u.set_tx_max_pwr_per_band.band;
833 max_tx_params_per_band->power =
834 command->u.set_tx_max_pwr_per_band.power;
835
836 msg.type = WDA_SET_MAX_TX_POWER_PER_BAND_REQ;
837 msg.reserved = 0;
838 msg.bodyptr = max_tx_params_per_band;
839
840 if (VOS_STATUS_SUCCESS !=
841 vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)) {
842 smsLog(mac_ctx, LOGE,
843 FL("Unable to post message to WDA"));
844 vos_mem_free(max_tx_params_per_band);
845 return eHAL_STATUS_FAILURE;
846 }
847 return eHAL_STATUS_SUCCESS;
848}
849
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530850
851/**
852 * sme_process_update_channel_list() - Update channel list
853 * @mac_ctx: mac context
854 * @command: cmd param containing band, and power in db
855 *
856 * Return: eHalStatus
857 */
858eHalStatus sme_process_update_channel_list(tpAniSirGlobal mac_ctx,
859 tSmeCmd *command)
860{
861 vos_msg_t msg;
862
863 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
864 msg.reserved = 0;
865 msg.bodyptr = command->u.chan_list;
866
867 MTRACE(vos_trace(VOS_MODULE_ID_SME,
868 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
869
870 if (VOS_STATUS_SUCCESS !=
871 vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)) {
872 smsLog(mac_ctx, LOGE,
873 FL("Unable to post message to WDA"));
874 vos_mem_free(command->u.chan_list);
875 return eHAL_STATUS_FAILURE;
876 }
877 return eHAL_STATUS_SUCCESS;
878}
879
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530880static void smeProcessNanReq(tpAniSirGlobal pMac, tSmeCmd *pCommand )
881{
882 tSirMsgQ msgQ;
883 tSirRetStatus retCode = eSIR_SUCCESS;
884
885 msgQ.type = WDA_NAN_REQUEST;
886 msgQ.reserved = 0;
887 msgQ.bodyptr = pCommand->u.pNanReq;
888 msgQ.bodyval = 0;
889
890 retCode = wdaPostCtrlMsg( pMac, &msgQ );
891 if( eSIR_SUCCESS != retCode)
892 {
893 vos_mem_free(pCommand->u.pNanReq);
894 smsLog( pMac, LOGE,
895 FL("Posting WDA_NAN_REQUEST to WDA failed, reason=%X"),
896 retCode );
897 }
898 else
899 {
900 smsLog(pMac, LOG1, FL("posted WDA_NAN_REQUEST command"));
901 }
902}
903
Ashish Kumar Dhanotiyaf59c7762018-04-10 17:54:25 +0530904/**
905 * sme_set_qpower() - Set Qpower
906 * @pMac - context handler
907 * @enable - uint8 value that needs to be sent to FW
908 *
909 * The function sends the qpower to firmware received
910 * via driver command
911 */
912void sme_set_qpower(tpAniSirGlobal pMac, uint8_t enable)
913{
914 tSirMsgQ msgQ;
915 tSirRetStatus retCode = eSIR_SUCCESS;
916
917 vos_mem_zero(&msgQ, sizeof(tSirMsgQ));
918 msgQ.type = WDA_QPOWER;
919 msgQ.reserved = 0;
920 msgQ.bodyval = enable;
921
922 retCode = wdaPostCtrlMsg(pMac, &msgQ);
923 if(eSIR_SUCCESS != retCode)
924 {
925 smsLog(pMac, LOGE,
926 FL("Posting WDA_QPOWER to WDA failed, reason=%X"),
927 retCode);
928 }
929 else
930 {
931 smsLog(pMac, LOG1, FL("posted WDA_QPOWER command"));
932 }
933}
Sourav Mohapatra2416e0e2018-03-05 18:44:21 +0530934
935/**
936 * sme_set_vowifi_mode() - Set VOWIFI mode
937 * @pMac - context handler
938 * @enable - boolean value that determines the state
939 *
940 * The function sends the VOWIFI to firmware received
941 * via driver command
942 */
943void sme_set_vowifi_mode(tpAniSirGlobal pMac, bool enable)
944{
945 tSirMsgQ msgQ;
946 tSirRetStatus retCode = eSIR_SUCCESS;
947
948 vos_mem_zero(&msgQ, sizeof(tSirMsgQ));
949 msgQ.type = WDA_VOWIFI_MODE;
950 msgQ.reserved = 0;
951 msgQ.bodyval = enable;
952
953 retCode = wdaPostCtrlMsg(pMac, &msgQ);
954 if(eSIR_SUCCESS != retCode)
955 {
956 smsLog(pMac, LOGE,
957 FL("Posting WDA_VOWIFI_MODE to WDA failed, reason=%X"),
958 retCode);
959 }
960 else
961 {
962 smsLog(pMac, LOG1, FL("posted WDA_VOWIFI_MODE command"));
963 }
964}
965
Jeff Johnson295189b2012-06-20 16:38:30 -0700966tANI_BOOLEAN smeProcessCommand( tpAniSirGlobal pMac )
967{
968 tANI_BOOLEAN fContinue = eANI_BOOLEAN_FALSE;
969 eHalStatus status = eHAL_STATUS_SUCCESS;
970 tListElem *pEntry;
971 tSmeCmd *pCommand;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530972 tListElem *pSmeEntry;
973 tSmeCmd *pSmeCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 eSmeCommandType pmcCommand = eSmeNoCommand;
975
976 // if the ActiveList is empty, then nothing is active so we can process a
977 // pending command...
978 //alwasy lock active list before locking pending list
979 csrLLLock( &pMac->sme.smeCmdActiveList );
980 if ( csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) )
981 {
982 if(!csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK))
983 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530984 /* If scan command is pending in the smeScanCmdActive list
985 * then pick the command from smeCmdPendingList which is
986 * not matching with the scan command session id.
987 * At any point of time only one command will be allowed
988 * on a single session. */
989 if ((pMac->fScanOffload) &&
990 (!csrLLIsListEmpty(&pMac->sme.smeScanCmdActiveList,
991 LL_ACCESS_LOCK)))
992 {
993 pSmeEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList,
994 LL_ACCESS_LOCK);
995 if (pSmeEntry)
996 {
997 pSmeCommand = GET_BASE_ADDR(pSmeEntry, tSmeCmd, Link);
998
999 pEntry = csrGetCmdToProcess(pMac,
1000 &pMac->sme.smeCmdPendingList,
1001 pSmeCommand->sessionId,
1002 LL_ACCESS_LOCK);
1003 goto sme_process_cmd;
1004 }
1005 }
1006
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 //Peek the command
1008 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK );
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05301009sme_process_cmd:
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 if( pEntry )
1011 {
1012 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05301013
Abhishek Singhf4669da2014-05-26 15:07:49 +05301014 /* Allow only disconnect command
1015 * in wait-for-key state until setKey is through.
1016 */
1017 if( CSR_IS_WAIT_FOR_KEY( pMac, pCommand->sessionId ) &&
1018 !CSR_IS_DISCONNECT_COMMAND( pCommand ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 {
1020 if( !CSR_IS_SET_KEY_COMMAND( pCommand ) )
1021 {
1022 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301023 smsLog(pMac, LOGE, FL("SessionId %d: Cannot process "
1024 "command(%d) while waiting for key"),
1025 pCommand->sessionId, pCommand->command);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05301026 fContinue = eANI_BOOLEAN_FALSE;
1027 goto sme_process_scan_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -07001028 }
1029 }
1030 pmcCommand = smeIsFullPowerNeeded( pMac, pCommand );
1031 if( eSmeDropCommand == pmcCommand )
1032 {
1033 //This command is not ok for current PMC state
1034 if( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
1035 {
1036 smeAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE );
1037 }
1038 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1039 //tell caller to continue
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05301040 fContinue = eANI_BOOLEAN_TRUE;
1041 goto sme_process_scan_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -07001042 }
1043 else if( eSmeNoCommand != pmcCommand )
1044 {
1045 tExitBmpsInfo exitBmpsInfo;
1046 void *pv = NULL;
1047 tANI_U32 size = 0;
1048 tSmeCmd *pPmcCmd = NULL;
1049
1050 if( eSmeCommandExitBmps == pmcCommand )
1051 {
1052 exitBmpsInfo.exitBmpsReason = eSME_REASON_OTHER;
1053 pv = (void *)&exitBmpsInfo;
1054 size = sizeof(tExitBmpsInfo);
1055 }
1056 //pmcCommand has to be one of the exit power save command
1057 status = pmcPrepareCommand( pMac, pmcCommand, pv, size, &pPmcCmd );
1058 if( HAL_STATUS_SUCCESS( status ) && pPmcCmd )
1059 {
Abhishek Singh631dd362015-07-08 10:46:24 +05301060 /* Set the time out to 30 sec */
1061 pMac->sme.smeCmdActiveList.cmdTimeoutDuration =
1062 CSR_ACTIVE_LIST_CMD_TIMEOUT_VALUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 //Force this command to wake up the chip
1064 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK );
Padma, Santhosh Kumar0a350582015-06-12 15:23:49 +05301065 MTRACE(vos_trace(VOS_MODULE_ID_SME,
1066 TRACE_CODE_SME_COMMAND,pPmcCmd->sessionId,
1067 pPmcCmd->command));
Jeff Johnson295189b2012-06-20 16:38:30 -07001068 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1069 fContinue = pmcProcessCommand( pMac, pPmcCmd );
1070 if( fContinue )
1071 {
1072 //The command failed, remove it
1073 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK ) )
1074 {
1075 pmcReleaseCommand( pMac, pPmcCmd );
1076 }
1077 }
1078 }
1079 else
1080 {
1081 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001082 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 -07001083 //Let it retry
1084 fContinue = eANI_BOOLEAN_TRUE;
1085 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05301086 goto sme_process_scan_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 }
1088 if ( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
1089 {
1090 // we can reuse the pCommand
1091
Abhishek Singh50b78042015-08-06 13:59:09 +05301092 /* For ROC set timeot to 30 *3 as Supplicant can retry
1093 * P2P Invitation Request 120 times with 500ms interval.
1094 * For roam command set timeout to 30 * 2 sec.
Abhishek Singh631dd362015-07-08 10:46:24 +05301095 * There are cases where we try to connect to different
1096 * APs with same SSID one by one until sucessfully conneted
1097 * and thus roam command might take more time if connection
1098 * is rejected by too many APs.
1099 */
Abhishek Singh50b78042015-08-06 13:59:09 +05301100 if (eSmeCommandRemainOnChannel == pCommand->command)
1101 pMac->sme.smeCmdActiveList.cmdTimeoutDuration =
1102 CSR_ACTIVE_LIST_CMD_TIMEOUT_VALUE * 3;
1103 else if ((eSmeCommandRoam == pCommand->command) &&
Abhishek Singh631dd362015-07-08 10:46:24 +05301104 (eCsrHddIssued == pCommand->u.roamCmd.roamReason))
1105 pMac->sme.smeCmdActiveList.cmdTimeoutDuration =
1106 CSR_ACTIVE_LIST_CMD_TIMEOUT_VALUE * 2;
1107 else
1108 pMac->sme.smeCmdActiveList.cmdTimeoutDuration =
1109 CSR_ACTIVE_LIST_CMD_TIMEOUT_VALUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 // Insert the command onto the ActiveList...
1111 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pCommand->Link, LL_ACCESS_NOLOCK );
1112
Rashmi Ramanna68b309c2014-05-20 11:52:22 +05301113 if( pMac->deferImps )
1114 {
1115 /* IMPS timer is already running so stop it and
1116 * it will get restarted when no command is pending
1117 */
1118 csrScanStopIdleScanTimer( pMac );
1119 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
1120 pMac->deferImps = eANI_BOOLEAN_FALSE;
1121 }
1122
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 // .... and process the command.
1124
Katya Nigambcb705f2013-12-26 14:26:22 +05301125 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07001126 TRACE_CODE_SME_COMMAND, pCommand->sessionId, pCommand->command));
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 switch ( pCommand->command )
1128 {
1129
1130 case eSmeCommandScan:
1131 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1132 status = csrProcessScanCommand( pMac, pCommand );
1133 break;
1134
1135 case eSmeCommandRoam:
1136 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1137 status = csrRoamProcessCommand( pMac, pCommand );
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -08001138 if(!HAL_STATUS_SUCCESS(status))
1139 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07001140 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -08001141 &pCommand->Link, LL_ACCESS_LOCK ) )
1142 {
1143 csrReleaseCommandRoam( pMac, pCommand );
1144 }
1145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 break;
1147
1148 case eSmeCommandWmStatusChange:
1149 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1150 csrRoamProcessWmStatusChangeCommand(pMac, pCommand);
1151 break;
1152
1153 case eSmeCommandSetKey:
1154 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1155 status = csrRoamProcessSetKeyCommand( pMac, pCommand );
1156 if(!HAL_STATUS_SUCCESS(status))
1157 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07001158 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
Jeff Johnson295189b2012-06-20 16:38:30 -07001159 &pCommand->Link, LL_ACCESS_LOCK ) )
1160 {
1161 csrReleaseCommandSetKey( pMac, pCommand );
1162 }
1163 }
1164 break;
1165
1166 case eSmeCommandRemoveKey:
1167 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1168 status = csrRoamProcessRemoveKeyCommand( pMac, pCommand );
1169 if(!HAL_STATUS_SUCCESS(status))
1170 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07001171 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 &pCommand->Link, LL_ACCESS_LOCK ) )
1173 {
1174 csrReleaseCommandRemoveKey( pMac, pCommand );
1175 }
1176 }
1177 break;
1178
1179 case eSmeCommandAddStaSession:
1180 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1181 csrProcessAddStaSessionCommand( pMac, pCommand );
1182 break;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07001183 case eSmeCommandDelStaSession:
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1185 csrProcessDelStaSessionCommand( pMac, pCommand );
1186 break;
Siddharth Bhald8a95e82015-02-12 20:14:52 +05301187 case eSmeCommandMacSpoofRequest:
1188 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1189 csrProcessMacAddrSpoofCommand( pMac, pCommand );
Siddharth Bhalc3a39b42015-02-26 15:07:54 +05301190 //We need to re-run the command
1191 fContinue = eANI_BOOLEAN_TRUE;
1192
Siddharth Bhald8a95e82015-02-12 20:14:52 +05301193 // No Rsp expected, free cmd from active list
1194 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
1195 &pCommand->Link, LL_ACCESS_LOCK ) )
1196 {
1197 csrReleaseCommand( pMac, pCommand );
1198 }
1199
1200 break;
Siddharth Bhal64246172015-02-27 01:04:37 +05301201 case eSmeCommandGetFrameLogRequest:
1202 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1203 csrProcessGetFrameLogCommand( pMac, pCommand );
1204 //We need to re-run the command
1205 fContinue = eANI_BOOLEAN_TRUE;
1206 // No Rsp expected, free cmd from active list
1207 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
1208 &pCommand->Link, LL_ACCESS_LOCK ) )
1209 {
1210 csrReleaseCommand( pMac, pCommand );
1211 }
1212 break;
Abhishek Singh99a31be2015-12-10 10:37:44 +05301213 case eSmeCommandSetMaxTxPower:
1214 csrLLUnlock(&pMac->sme.smeCmdActiveList);
1215 sme_process_set_max_tx_power(pMac, pCommand);
1216 /* We need to re-run the command */
1217 fContinue = eANI_BOOLEAN_TRUE;
1218 /* No Rsp expected, free cmd from active list */
1219 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList,
1220 &pCommand->Link, LL_ACCESS_LOCK))
1221 {
1222 csrReleaseCommand(pMac, pCommand);
1223 }
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +05301224 pMac->max_power_cmd_pending = false;
Abhishek Singh99a31be2015-12-10 10:37:44 +05301225 break;
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05301226 case eSmeCommandSetMaxTxPowerPerBand:
1227 csrLLUnlock(&pMac->sme.smeCmdActiveList);
1228 sme_process_set_max_tx_power_per_band(pMac,
1229 pCommand);
1230 /* We need to re-run the command */
1231 fContinue = eANI_BOOLEAN_TRUE;
1232 /* No Rsp expected, free cmd from active list */
1233 if (csrLLRemoveEntry(&pMac->sme.smeCmdActiveList,
1234 &pCommand->Link, LL_ACCESS_LOCK)) {
1235 csrReleaseCommand(pMac, pCommand);
1236 }
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +05301237 pMac->max_power_cmd_pending = false;
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05301238 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001239
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +05301240 case eSmeCommandUpdateChannelList:
1241 csrLLUnlock(&pMac->sme.smeCmdActiveList);
1242 sme_process_update_channel_list(pMac, pCommand);
1243 if (csrLLRemoveEntry(&pMac->sme.smeCmdActiveList,
1244 &pCommand->Link, LL_ACCESS_LOCK)) {
1245 csrReleaseCommand(pMac, pCommand);
1246 }
1247 smsLog(pMac, LOG1,
1248 FL("eSmeCommandUpdateChannelList processed"));
1249 fContinue = eANI_BOOLEAN_TRUE;
1250 break;
1251
Jeff Johnsone7245742012-09-05 17:12:55 -07001252#ifdef FEATURE_OEM_DATA_SUPPORT
1253 case eSmeCommandOemDataReq:
1254 csrLLUnlock(&pMac->sme.smeCmdActiveList);
1255 oemData_ProcessOemDataReqCommand(pMac, pCommand);
1256 break;
1257#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 case eSmeCommandRemainOnChannel:
1259 csrLLUnlock(&pMac->sme.smeCmdActiveList);
1260 p2pProcessRemainOnChannelCmd(pMac, pCommand);
1261 break;
1262 case eSmeCommandNoAUpdate:
1263 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1264 p2pProcessNoAReq(pMac,pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 case eSmeCommandEnterImps:
1266 case eSmeCommandExitImps:
1267 case eSmeCommandEnterBmps:
1268 case eSmeCommandExitBmps:
1269 case eSmeCommandEnterUapsd:
1270 case eSmeCommandExitUapsd:
1271 case eSmeCommandEnterWowl:
1272 case eSmeCommandExitWowl:
1273 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1274 fContinue = pmcProcessCommand( pMac, pCommand );
1275 if( fContinue )
1276 {
1277 //The command failed, remove it
1278 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
1279 &pCommand->Link, LL_ACCESS_LOCK ) )
1280 {
1281 pmcReleaseCommand( pMac, pCommand );
1282 }
1283 }
1284 break;
1285
1286 //Treat standby differently here because caller may not be able to handle
1287 //the failure so we do our best here
1288 case eSmeCommandEnterStandby:
1289 if( csrIsConnStateDisconnected( pMac, pCommand->sessionId ) )
1290 {
1291 //It can continue
1292 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1293 fContinue = pmcProcessCommand( pMac, pCommand );
1294 if( fContinue )
1295 {
1296 //The command failed, remove it
1297 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
1298 &pCommand->Link, LL_ACCESS_LOCK ) )
1299 {
1300 pmcReleaseCommand( pMac, pCommand );
1301 }
1302 }
1303 }
1304 else
1305 {
1306 //Need to issue a disconnect first before processing this command
1307 tSmeCmd *pNewCmd;
1308
1309 //We need to re-run the command
1310 fContinue = eANI_BOOLEAN_TRUE;
1311 //Pull off the standby command first
1312 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
1313 &pCommand->Link, LL_ACCESS_NOLOCK ) )
1314 {
1315 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1316 //Need to call CSR function here because the disconnect command
1317 //is handled by CSR
1318 pNewCmd = csrGetCommandBuffer( pMac );
1319 if( NULL != pNewCmd )
1320 {
1321 //Put the standby command to the head of the pending list first
1322 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCommand->Link,
1323 LL_ACCESS_LOCK );
1324 pNewCmd->command = eSmeCommandRoam;
1325 pNewCmd->u.roamCmd.roamReason = eCsrForcedDisassoc;
1326 //Put the disassoc command before the standby command
1327 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pNewCmd->Link,
1328 LL_ACCESS_LOCK );
1329 }
1330 else
1331 {
1332 //Continue the command here
1333 fContinue = pmcProcessCommand( pMac, pCommand );
1334 if( fContinue )
1335 {
1336 //The command failed, remove it
1337 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
1338 &pCommand->Link, LL_ACCESS_LOCK ) )
1339 {
1340 pmcReleaseCommand( pMac, pCommand );
1341 }
1342 }
1343 }
1344 }
1345 else
1346 {
1347 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001348 smsLog( pMac, LOGE, FL(" failed to remove standby command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 VOS_ASSERT(0);
1350 }
1351 }
1352 break;
Hanumantha Reddy Pothula28b1e652015-02-02 21:10:13 +05301353 case eSmeCommandPnoReq:
1354 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1355 status = smeProcessPnoCommand(pMac, pCommand);
1356 if (!HAL_STATUS_SUCCESS(status)){
1357 smsLog(pMac, LOGE,
1358 FL("failed to post SME PNO SCAN %d"), status);
1359 }
Mahesh A Saptasagarbafce5a2015-02-26 12:29:22 +05301360 //We need to re-run the command
1361 fContinue = eANI_BOOLEAN_TRUE;
1362
Hanumantha Reddy Pothula28b1e652015-02-02 21:10:13 +05301363 if (csrLLRemoveEntry(&pMac->sme.smeCmdActiveList,
1364 &pCommand->Link, LL_ACCESS_LOCK))
1365 {
1366 csrReleaseCommand(pMac, pCommand);
1367 }
1368 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001369 case eSmeCommandAddTs:
1370 case eSmeCommandDelTs:
1371 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1372#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1373 fContinue = qosProcessCommand( pMac, pCommand );
1374 if( fContinue )
1375 {
1376 //The command failed, remove it
1377 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
1378 &pCommand->Link, LL_ACCESS_NOLOCK ) )
1379 {
1380//#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1381 qosReleaseCommand( pMac, pCommand );
1382//#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
1383 }
1384 }
1385#endif
1386 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001387#ifdef FEATURE_WLAN_TDLS
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07001388 case eSmeCommandTdlsSendMgmt:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001389 case eSmeCommandTdlsAddPeer:
1390 case eSmeCommandTdlsDelPeer:
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301391 case eSmeCommandTdlsLinkEstablish:
Atul Mittalc0f739f2014-07-31 13:47:47 +05301392 case eSmeCommandTdlsChannelSwitch: // tdlsoffchan
Abhishek Singhf50bad82016-03-02 15:12:44 +05301393 smsLog(pMac, LOG1,
1394 FL("sending TDLS Command 0x%x to PE"),
1395 pCommand->command);
1396 csrLLUnlock(&pMac->sme.smeCmdActiveList);
1397 status = csrTdlsProcessCmd(pMac, pCommand);
1398 if(!HAL_STATUS_SUCCESS(status))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001399 {
Abhishek Singhf50bad82016-03-02 15:12:44 +05301400 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList,
1401 &pCommand->Link, LL_ACCESS_LOCK))
1402 csrReleaseCommand(pMac, pCommand);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001403 }
1404 break ;
1405#endif
Srinivas Dasaria3f11c02015-03-20 13:15:20 +05301406 case eSmeCommandNanReq:
1407 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1408 smeProcessNanReq( pMac, pCommand );
1409 if (csrLLRemoveEntry(&pMac->sme.smeCmdActiveList,
1410 &pCommand->Link, LL_ACCESS_LOCK))
1411 {
1412 csrReleaseCommand(pMac, pCommand);
1413 }
1414 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1415 "eSmeCommandNanReq processed");
1416 fContinue = eANI_BOOLEAN_TRUE;
1417 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001418
1419 default:
1420 //something is wrong
1421 //remove it from the active list
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001422 smsLog(pMac, LOGE, " csrProcessCommand processes an unknown command %d", pCommand->command);
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK );
1424 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1425 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
1426 smeReleaseCommand( pMac, pCommand );
1427 status = eHAL_STATUS_FAILURE;
1428 break;
1429 }
1430 if(!HAL_STATUS_SUCCESS(status))
1431 {
1432 fContinue = eANI_BOOLEAN_TRUE;
1433 }
1434 }//if(pEntry)
1435 else
1436 {
1437 //This is odd. Some one else pull off the command.
1438 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1439 }
1440 }
1441 else
1442 {
1443 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1444 }
1445 }
1446 else
1447 {
1448 //No command waiting
1449 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1450 //This is only used to restart an idle mode scan, it means at least one other idle scan has finished.
1451 if(pMac->scan.fRestartIdleScan && eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
1452 {
1453 tANI_U32 nTime = 0;
1454
1455 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
1456 if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime)))
1457 {
1458 csrScanStartIdleScanTimer(pMac, nTime);
1459 }
1460 }
1461 }
1462 }
1463 else {
1464 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1465 }
1466
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05301467sme_process_scan_queue:
1468 if (pMac->fScanOffload && !(smeProcessScanQueue(pMac)))
1469 fContinue = eANI_BOOLEAN_FALSE;
1470
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 return ( fContinue );
1472}
1473
1474void smeProcessPendingQueue( tpAniSirGlobal pMac )
1475{
1476 while( smeProcessCommand( pMac ) );
1477}
1478
1479
1480tANI_BOOLEAN smeCommandPending(tpAniSirGlobal pMac)
1481{
1482 return ( !csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) ||
1483 !csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK) );
1484}
1485
1486
1487
1488//Global APIs
1489
1490/*--------------------------------------------------------------------------
1491
1492 \brief sme_Open() - Initialze all SME modules and put them at idle state
1493
1494 The function initializes each module inside SME, PMC, CCM, CSR, etc. . Upon
1495 successfully return, all modules are at idle state ready to start.
1496
1497 smeOpen must be called before any other SME APIs can be involved.
1498 smeOpen must be called after macOpen.
Srinivas Girigowdade697412013-02-14 16:31:48 -08001499 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 \param hHal - The handle returned by macOpen.
1501
1502 \return eHAL_STATUS_SUCCESS - SME is successfully initialized.
1503
1504 Other status means SME is failed to be initialized
1505 \sa
1506
1507 --------------------------------------------------------------------------*/
1508eHalStatus sme_Open(tHalHandle hHal)
1509{
1510 eHalStatus status = eHAL_STATUS_FAILURE;
1511 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1512
1513 do {
1514 pMac->sme.state = SME_STATE_STOP;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07001515 pMac->sme.currDeviceMode = VOS_STA_MODE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->sme.lkSmeGlobalLock ) ) )
1517 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001518 smsLog( pMac, LOGE, "sme_Open failed init lock" );
Jeff Johnson295189b2012-06-20 16:38:30 -07001519 status = eHAL_STATUS_FAILURE;
1520 break;
1521 }
1522
1523 status = ccmOpen(hHal);
1524 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1525 smsLog( pMac, LOGE,
1526 "ccmOpen failed during initialization with status=%d", status );
1527 break;
1528 }
1529
1530 status = csrOpen(pMac);
1531 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1532 smsLog( pMac, LOGE,
1533 "csrOpen failed during initialization with status=%d", status );
1534 break;
1535 }
1536
1537 status = pmcOpen(hHal);
1538 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1539 smsLog( pMac, LOGE,
1540 "pmcOpen failed during initialization with status=%d", status );
1541 break;
1542 }
1543
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07001544#ifdef FEATURE_WLAN_TDLS
1545 pMac->isTdlsPowerSaveProhibited = 0;
1546#endif
1547
Jeff Johnson295189b2012-06-20 16:38:30 -07001548#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1549 status = sme_QosOpen(pMac);
1550 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1551 smsLog( pMac, LOGE,
1552 "Qos open failed during initialization with status=%d", status );
1553 break;
1554 }
1555
1556 status = btcOpen(pMac);
1557 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1558 smsLog( pMac, LOGE,
1559 "btcOpen open failed during initialization with status=%d", status );
1560 break;
1561 }
1562#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001563#ifdef FEATURE_OEM_DATA_SUPPORT
1564 status = oemData_OemDataReqOpen(pMac);
1565 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1566 smsLog(pMac, LOGE,
1567 "oemData_OemDataReqOpen failed during initialization with status=%d", status );
1568 break;
1569 }
1570#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001571
1572 if(!HAL_STATUS_SUCCESS((status = initSmeCmdList(pMac))))
1573 break;
1574
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 {
1576 v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SAP, NULL);
1577 if ( NULL == pvosGCtx ){
1578 smsLog( pMac, LOGE, "WLANSAP_Open open failed during initialization");
1579 status = eHAL_STATUS_FAILURE;
1580 break;
1581 }
1582
1583 status = WLANSAP_Open( pvosGCtx );
1584 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1585 smsLog( pMac, LOGE,
1586 "WLANSAP_Open open failed during initialization with status=%d", status );
1587 break;
1588 }
1589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001590#if defined WLAN_FEATURE_VOWIFI
1591 status = rrmOpen(pMac);
1592 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1593 smsLog( pMac, LOGE,
1594 "rrmOpen open failed during initialization with status=%d", status );
1595 break;
1596 }
1597#endif
1598
1599#if defined WLAN_FEATURE_VOWIFI_11R
1600 sme_FTOpen(pMac);
1601#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301602
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 sme_p2pOpen(pMac);
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07001604 smeTraceInit(pMac);
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +05301605 sme_register_debug_callback();
Jeff Johnson295189b2012-06-20 16:38:30 -07001606
1607 }while (0);
1608
1609 return status;
1610}
1611
Jeff Johnson295189b2012-06-20 16:38:30 -07001612/*--------------------------------------------------------------------------
1613
1614 \brief sme_set11dinfo() - Set the 11d information about valid channels
1615 and there power using information from nvRAM
1616 This function is called only for AP.
1617
Srinivas Girigowdade697412013-02-14 16:31:48 -08001618 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001619
1620 \param hHal - The handle returned by macOpen.
1621 \Param pSmeConfigParams - a pointer to a caller allocated object of
1622 typedef struct _smeConfigParams.
1623
1624 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1625
1626 Other status means SME is failed to update the config parameters.
1627 \sa
1628--------------------------------------------------------------------------*/
1629
1630eHalStatus sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1631{
1632 eHalStatus status = eHAL_STATUS_FAILURE;
1633 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1634
Katya Nigambcb705f2013-12-26 14:26:22 +05301635 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07001636 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 if (NULL == pSmeConfigParams ) {
1638 smsLog( pMac, LOGE,
1639 "Empty config param structure for SME, nothing to update");
1640 return status;
1641 }
1642
1643 status = csrSetChannels(hHal, &pSmeConfigParams->csrConfig );
1644 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001645 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 status );
1647 }
1648 return status;
1649}
1650
1651/*--------------------------------------------------------------------------
1652
1653 \brief sme_getSoftApDomain() - Get the current regulatory domain of softAp.
1654
Srinivas Girigowdade697412013-02-14 16:31:48 -08001655 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001656
1657 \param hHal - The handle returned by HostapdAdapter.
1658 \Param v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
1659
1660 \return eHAL_STATUS_SUCCESS - SME successfully completed the request.
1661
1662 Other status means, failed to get the current regulatory domain.
1663 \sa
1664--------------------------------------------------------------------------*/
1665
1666eHalStatus sme_getSoftApDomain(tHalHandle hHal, v_REGDOMAIN_t *domainIdSoftAp)
1667{
1668 eHalStatus status = eHAL_STATUS_FAILURE;
1669 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1670
Katya Nigambcb705f2013-12-26 14:26:22 +05301671 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07001672 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 if (NULL == domainIdSoftAp ) {
1674 smsLog( pMac, LOGE, "Uninitialized domain Id");
1675 return status;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07001676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001677
1678 *domainIdSoftAp = pMac->scan.domainIdCurrent;
1679 status = eHAL_STATUS_SUCCESS;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07001680
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 return status;
1682}
1683
1684
1685eHalStatus sme_setRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
1686{
1687 eHalStatus status = eHAL_STATUS_FAILURE;
1688 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1689
Katya Nigambcb705f2013-12-26 14:26:22 +05301690 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07001691 TRACE_CODE_SME_RX_HDD_MSG_SET_REGINFO, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 if (NULL == apCntryCode ) {
1693 smsLog( pMac, LOGE, "Empty Country Code, nothing to update");
1694 return status;
1695 }
1696
1697 status = csrSetRegInfo(hHal, apCntryCode );
1698 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001699 smsLog( pMac, LOGE, "csrSetRegInfo failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 status );
1701 }
1702 return status;
1703}
1704
Jeff Johnson295189b2012-06-20 16:38:30 -07001705#ifdef FEATURE_WLAN_SCAN_PNO
1706/*--------------------------------------------------------------------------
1707
1708 \brief sme_UpdateChannelConfig() - Update channel configuration in RIVA.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07001709
1710 It is used at driver start up to inform RIVA of the default channel
1711 configuration.
Jeff Johnson295189b2012-06-20 16:38:30 -07001712
Srinivas Girigowdade697412013-02-14 16:31:48 -08001713 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001714
1715 \param hHal - The handle returned by macOpen.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07001716
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 \return eHAL_STATUS_SUCCESS - SME update the channel config successfully.
1718
1719 Other status means SME is failed to update the channel config.
1720 \sa
1721
1722 --------------------------------------------------------------------------*/
1723eHalStatus sme_UpdateChannelConfig(tHalHandle hHal)
1724{
1725 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1726
Katya Nigambcb705f2013-12-26 14:26:22 +05301727 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07001728 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CHANNEL_CONFIG, NO_SESSION, 0));
1729 pmcUpdateScanParams( pMac, &(pMac->roam.configParam),
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 &pMac->scan.base20MHzChannels, FALSE);
1731 return eHAL_STATUS_SUCCESS;
1732}
1733#endif // FEATURE_WLAN_SCAN_PNLO
1734
Abhishek Singhf644b272014-08-21 02:59:39 +05301735eHalStatus sme_UpdateChannelList(tHalHandle hHal)
1736{
1737 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1738 eHalStatus status = eHAL_STATUS_SUCCESS;
1739
1740 status = csrUpdateChannelList(pMac);
1741
1742 if (eHAL_STATUS_SUCCESS != status)
1743 {
1744 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1745 "failed to update the supported channel list");
1746 }
1747 return status;
1748}
1749
Sourav Mohapatra5817dc42017-12-18 17:45:16 +05301750/**
1751 * sme_update_channel_list() - Update configured channel list to fwr
1752 * This is a synchronous API.
1753 *
1754 * @mac_ctx - The handle returned by mac_open.
1755 *
1756 * Return QDF_STATUS SUCCESS.
1757 * FAILURE or RESOURCES The API finished and failed.
1758 */
1759VOS_STATUS
1760sme_update_channel_list(tpAniSirGlobal pMac)
1761{
1762 VOS_STATUS status = VOS_STATUS_SUCCESS;
1763
1764 status = sme_AcquireGlobalLock(&pMac->sme);
1765 if (VOS_IS_STATUS_SUCCESS(status)) {
1766 csrInitGetChannels(pMac);
1767 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
1768 csrScanFilterResults(pMac);
1769 sme_ReleaseGlobalLock(&pMac->sme);
1770 }
1771
1772 return status;
1773}
1774
1775
Jeff Johnson295189b2012-06-20 16:38:30 -07001776/*--------------------------------------------------------------------------
1777
1778 \brief sme_UpdateConfig() - Change configurations for all SME moduels
1779
1780 The function updates some configuration for modules in SME, CCM, CSR, etc
1781 during SMEs close open sequence.
1782
1783 Modules inside SME apply the new configuration at the next transaction.
1784
Srinivas Girigowdade697412013-02-14 16:31:48 -08001785 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001786
1787 \param hHal - The handle returned by macOpen.
1788 \Param pSmeConfigParams - a pointer to a caller allocated object of
1789 typedef struct _smeConfigParams.
1790
1791 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1792
1793 Other status means SME is failed to update the config parameters.
1794 \sa
1795
1796 --------------------------------------------------------------------------*/
1797eHalStatus sme_UpdateConfig(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1798{
1799 eHalStatus status = eHAL_STATUS_FAILURE;
1800 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1801
Katya Nigambcb705f2013-12-26 14:26:22 +05301802 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07001803 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 if (NULL == pSmeConfigParams ) {
1805 smsLog( pMac, LOGE,
1806 "Empty config param structure for SME, nothing to update");
1807 return status;
1808 }
1809
1810 status = csrChangeDefaultConfigParam(pMac, &pSmeConfigParams->csrConfig);
1811
1812 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001813 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 status );
1815 }
1816#if defined WLAN_FEATURE_P2P_INTERNAL
1817 status = p2pChangeDefaultConfigParam(pMac, &pSmeConfigParams->p2pConfig);
1818
1819 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001820 smsLog( pMac, LOGE, "p2pChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 status );
1822 }
1823#endif
1824#if defined WLAN_FEATURE_VOWIFI
1825 status = rrmChangeDefaultConfigParam(hHal, &pSmeConfigParams->rrmConfig);
1826
1827 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001828 smsLog( pMac, LOGE, "rrmChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 status );
1830 }
1831#endif
1832 //For SOC, CFG is set before start
1833 //We don't want to apply global CFG in connect state because that may cause some side affect
1834 if(
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 csrIsAllSessionDisconnected( pMac) )
1836 {
1837 csrSetGlobalCfgs(pMac);
1838 }
1839
Gopichand Nakkala86e42662013-06-11 17:44:11 +05301840 /* update the directed scan offload setting */
1841 pMac->fScanOffload = pSmeConfigParams->fScanOffload;
1842
Madan Mohan Koyyalamudid89feb72013-07-31 15:47:12 +05301843 if (pMac->fScanOffload)
1844 {
1845 /* If scan offload is enabled then lim has allow the sending of
1846 scan request to firmware even in powersave mode. The firmware has
1847 to take care of exiting from power save mode */
1848 status = ccmCfgSetInt(hHal, WNI_CFG_SCAN_IN_POWERSAVE,
1849 eANI_BOOLEAN_TRUE, NULL, eANI_BOOLEAN_FALSE);
1850
1851 if (eHAL_STATUS_SUCCESS != status)
1852 {
1853 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1854 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CCM");
1855 }
1856 }
krunal sonie9002db2013-11-25 14:24:17 -08001857 pMac->isCoalesingInIBSSAllowed =
1858 pSmeConfigParams->csrConfig.isCoalesingInIBSSAllowed;
Tushnim Bhattacharyyaed4d0c22014-01-30 11:56:44 -08001859 pMac->fEnableDebugLog = pSmeConfigParams->fEnableDebugLog;
Rashmi Ramanna68b309c2014-05-20 11:52:22 +05301860 pMac->fDeferIMPSTime = pSmeConfigParams->fDeferIMPSTime;
Chandrasekaran, Manishekar5cb0acd2014-12-23 20:06:52 +05301861 pMac->fBtcEnableIndTimerVal = pSmeConfigParams->fBtcEnableIndTimerVal;
Rashmi Ramanna68b309c2014-05-20 11:52:22 +05301862
Paul Zhang83289792017-02-28 18:58:52 +08001863 pMac->sta_auth_retries_for_code17 =
1864 pSmeConfigParams->csrConfig.sta_auth_retries_for_code17;
1865
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 return status;
1867}
1868
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301869#ifdef WLAN_FEATURE_GTK_OFFLOAD
1870void sme_ProcessGetGtkInfoRsp( tHalHandle hHal,
1871 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
1872{
1873 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1874
1875 if (NULL == pMac)
1876 {
1877 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1878 "%s: pMac is null", __func__);
1879 return ;
1880 }
1881 if (pMac->pmc.GtkOffloadGetInfoCB == NULL)
1882 {
1883 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1884 "%s: HDD callback is null", __func__);
1885 return ;
1886 }
1887 pMac->pmc.GtkOffloadGetInfoCB(pMac->pmc.GtkOffloadGetInfoCBContext,
1888 pGtkOffloadGetInfoRsp);
1889}
1890#endif
1891
Jeff Johnson295189b2012-06-20 16:38:30 -07001892/* ---------------------------------------------------------------------------
1893 \fn sme_ChangeConfigParams
1894 \brief The SME API exposed for HDD to provide config params to SME during
1895 SMEs stop -> start sequence.
1896
1897 If HDD changed the domain that will cause a reset. This function will
1898 provide the new set of 11d information for the new domain. Currrently this
1899 API provides info regarding 11d only at reset but we can extend this for
1900 other params (PMC, QoS) which needs to be initialized again at reset.
1901
Srinivas Girigowdade697412013-02-14 16:31:48 -08001902 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001903
1904 \param hHal - The handle returned by macOpen.
1905
1906 \Param
1907 pUpdateConfigParam - a pointer to a structure (tCsrUpdateConfigParam) that
1908 currently provides 11d related information like Country code,
1909 Regulatory domain, valid channel list, Tx power per channel, a
1910 list with active/passive scan allowed per valid channel.
1911
1912 \return eHalStatus
1913 ---------------------------------------------------------------------------*/
1914eHalStatus sme_ChangeConfigParams(tHalHandle hHal,
1915 tCsrUpdateConfigParam *pUpdateConfigParam)
1916{
1917 eHalStatus status = eHAL_STATUS_FAILURE;
1918 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1919
1920 if (NULL == pUpdateConfigParam ) {
1921 smsLog( pMac, LOGE,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001922 "Empty config param structure for SME, nothing to reset");
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 return status;
1924 }
1925
1926 status = csrChangeConfigParams(pMac, pUpdateConfigParam);
1927
1928 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001929 smsLog( pMac, LOGE, "csrUpdateConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 status );
1931 }
1932
1933 return status;
1934
1935}
1936
1937/*--------------------------------------------------------------------------
1938
1939 \brief sme_HDDReadyInd() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1940 that the NIC is ready tio run.
1941
1942 The function is called by HDD at the end of initialization stage so PE/HAL can
1943 enable the NIC to running state.
1944
Srinivas Girigowdade697412013-02-14 16:31:48 -08001945 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 \param hHal - The handle returned by macOpen.
1947
1948 \return eHAL_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1949 successfully.
1950
1951 Other status means SME failed to send the message to PE.
1952 \sa
1953
1954 --------------------------------------------------------------------------*/
1955eHalStatus sme_HDDReadyInd(tHalHandle hHal)
1956{
1957 tSirSmeReadyReq Msg;
1958 eHalStatus status = eHAL_STATUS_FAILURE;
1959 tPmcPowerState powerState;
1960 tPmcSwitchState hwWlanSwitchState;
1961 tPmcSwitchState swWlanSwitchState;
1962 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1963
Katya Nigambcb705f2013-12-26 14:26:22 +05301964 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07001965 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07001966 do
1967 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001968
1969 Msg.messageType = eWNI_SME_SYS_READY_IND;
1970 Msg.length = sizeof( tSirSmeReadyReq );
Abhinav Kumarc00a7842018-06-13 16:07:31 +05301971 Msg.sme_msg_cb = sme_process_msg_callback;
Jeff Johnson295189b2012-06-20 16:38:30 -07001972
1973 if (eSIR_FAILURE != uMacPostCtrlMsg( hHal, (tSirMbMsg*)&Msg ))
1974 {
1975 status = eHAL_STATUS_SUCCESS;
1976 }
1977 else
1978 {
1979 smsLog( pMac, LOGE,
1980 "uMacPostCtrlMsg failed to send eWNI_SME_SYS_READY_IND");
1981 break;
1982 }
1983
1984 status = pmcQueryPowerState( hHal, &powerState,
1985 &hwWlanSwitchState, &swWlanSwitchState );
1986 if ( ! HAL_STATUS_SUCCESS( status ) )
1987 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001988 smsLog( pMac, LOGE, "pmcQueryPowerState failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 status );
1990 break;
1991 }
1992
1993 if ( (ePMC_SWITCH_OFF != hwWlanSwitchState) &&
1994 (ePMC_SWITCH_OFF != swWlanSwitchState) )
1995 {
1996 status = csrReady(pMac);
1997 if ( ! HAL_STATUS_SUCCESS( status ) )
1998 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001999 smsLog( pMac, LOGE, "csrReady failed with status=%d", status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 break;
2001 }
2002 status = pmcReady(hHal);
2003 if ( ! HAL_STATUS_SUCCESS( status ) )
2004 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002005 smsLog( pMac, LOGE, "pmcReady failed with status=%d", status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002006 break;
2007 }
2008#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2009 if(VOS_STATUS_SUCCESS != btcReady(hHal))
2010 {
2011 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002012 smsLog( pMac, LOGE, "btcReady failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 break;
2014 }
2015#endif
2016
2017#if defined WLAN_FEATURE_VOWIFI
2018 if(VOS_STATUS_SUCCESS != rrmReady(hHal))
2019 {
2020 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002021 smsLog( pMac, LOGE, "rrmReady failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 break;
2023 }
2024#endif
2025 }
2026 pMac->sme.state = SME_STATE_READY;
2027 } while( 0 );
2028
2029 return status;
2030}
2031
Selvaraj, Sridharc045b8b2016-04-06 12:22:35 +05302032/**
2033 * sme_set_allowed_action_frames() - Set allowed action frames to FW
2034 *
2035 * @hal: Handler to HAL
2036 *
2037 * This function conveys the list of action frames that needs to be forwarded
2038 * to driver by FW. Rest of the action frames can be dropped in FW.Bitmask is
2039 * set with ALLOWED_ACTION_FRAMES_BITMAP
2040 *
2041 * Return: None
2042 */
2043static void sme_set_allowed_action_frames(tHalHandle hal)
2044{
2045 eHalStatus status;
2046 tpAniSirGlobal mac = PMAC_STRUCT(hal);
2047 vos_msg_t vos_message;
2048 VOS_STATUS vos_status;
2049 struct sir_allowed_action_frames *sir_allowed_action_frames;
2050
2051 sir_allowed_action_frames =
2052 vos_mem_malloc(sizeof(*sir_allowed_action_frames));
2053 if (!sir_allowed_action_frames) {
2054 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2055 "Not able to allocate memory for WDA_SET_ALLOWED_ACTION_FRAMES_IND");
2056 return;
2057 }
2058
2059 vos_mem_zero(sir_allowed_action_frames, sizeof(*sir_allowed_action_frames));
2060 sir_allowed_action_frames->bitmask = ALLOWED_ACTION_FRAMES_BITMAP;
2061 sir_allowed_action_frames->reserved = 0;
2062
2063 status = sme_AcquireGlobalLock(&mac->sme);
2064 if (status == eHAL_STATUS_SUCCESS) {
2065 /* serialize the req through MC thread */
2066 vos_message.bodyptr = sir_allowed_action_frames;
2067 vos_message.type = WDA_SET_ALLOWED_ACTION_FRAMES_IND;
2068 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2069 TRACE_CODE_SME_TX_WDA_MSG,
2070 NO_SESSION, vos_message.type));
2071 vos_status = vos_mq_post_message(VOS_MQ_ID_WDA, &vos_message);
2072 if (!VOS_IS_STATUS_SUCCESS(vos_status)) {
2073 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2074 "Not able to post WDA_SET_ALLOWED_ACTION_FRAMES_IND message to HAL");
2075 vos_mem_free(sir_allowed_action_frames);
2076 }
2077
2078 sme_ReleaseGlobalLock( &mac->sme );
2079 } else {
2080 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
2081 "sme_AcquireGlobalLock error", __func__);
2082 vos_mem_free(sir_allowed_action_frames);
2083 }
2084 return;
2085}
2086
Jeff Johnson295189b2012-06-20 16:38:30 -07002087/*--------------------------------------------------------------------------
2088
2089 \brief sme_Start() - Put all SME modules at ready state.
2090
2091 The function starts each module in SME, PMC, CCM, CSR, etc. . Upon
2092 successfully return, all modules are ready to run.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002093 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 \param hHal - The handle returned by macOpen.
2095
2096 \return eHAL_STATUS_SUCCESS - SME is ready.
2097
2098 Other status means SME is failed to start
2099 \sa
2100
2101 --------------------------------------------------------------------------*/
2102eHalStatus sme_Start(tHalHandle hHal)
2103{
2104 eHalStatus status = eHAL_STATUS_FAILURE;
2105 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2106
2107 do
2108 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 status = csrStart(pMac);
2110 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002111 smsLog( pMac, LOGE, "csrStart failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 status );
2113 break;
2114 }
2115
2116 status = pmcStart(hHal);
2117 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002118 smsLog( pMac, LOGE, "pmcStart failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 status );
2120 break;
2121 }
2122
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 status = WLANSAP_Start(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
2124 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002125 smsLog( pMac, LOGE, "WLANSAP_Start failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 status );
2127 break;
2128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 pMac->sme.state = SME_STATE_START;
2130 }while (0);
2131
Selvaraj, Sridharc045b8b2016-04-06 12:22:35 +05302132 sme_set_allowed_action_frames(hHal);
2133
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 return status;
2135}
2136
2137
2138#ifdef WLAN_FEATURE_PACKET_FILTERING
2139/******************************************************************************
2140*
2141* Name: sme_PCFilterMatchCountResponseHandler
2142*
2143* Description:
2144* Invoke Packet Coalescing Filter Match Count callback routine
2145*
2146* Parameters:
2147* hHal - HAL handle for device
2148* pMsg - Pointer to tRcvFltPktMatchRsp structure
2149*
2150* Returns: eHalStatus
2151*
2152******************************************************************************/
2153eHalStatus sme_PCFilterMatchCountResponseHandler(tHalHandle hHal, void* pMsg)
2154{
2155 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2156 eHalStatus status = eHAL_STATUS_SUCCESS;
2157 tpSirRcvFltPktMatchRsp pRcvFltPktMatchRsp = (tpSirRcvFltPktMatchRsp)pMsg;
2158
2159 if (NULL == pMsg)
2160 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002161 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 status = eHAL_STATUS_FAILURE;
2163 }
2164 else
2165 {
2166 smsLog(pMac, LOG2, "SME: entering "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002167 "sme_FilterMatchCountResponseHandler");
Jeff Johnson295189b2012-06-20 16:38:30 -07002168
2169 /* Call Packet Coalescing Filter Match Count callback routine. */
2170 if (pMac->pmc.FilterMatchCountCB != NULL)
2171 pMac->pmc.FilterMatchCountCB(pMac->pmc.FilterMatchCountCBContext,
2172 pRcvFltPktMatchRsp);
2173
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002174 smsLog(pMac, LOG1, "%s: status=0x%x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 pRcvFltPktMatchRsp->status);
2176
2177 pMac->pmc.FilterMatchCountCB = NULL;
2178 pMac->pmc.FilterMatchCountCBContext = NULL;
2179 }
2180
2181 return(status);
2182}
2183#endif // WLAN_FEATURE_PACKET_FILTERING
2184
2185
Chet Lanctot186b5732013-03-18 10:26:30 -07002186#ifdef WLAN_FEATURE_11W
2187/*------------------------------------------------------------------
2188 *
2189 * Handle the unprotected management frame indication from LIM and
2190 * forward it to HDD.
2191 *
2192 *------------------------------------------------------------------*/
2193
2194eHalStatus sme_UnprotectedMgmtFrmInd( tHalHandle hHal,
2195 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
2196{
2197 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2198 eHalStatus status = eHAL_STATUS_SUCCESS;
2199 tCsrRoamInfo pRoamInfo = {0};
2200 tANI_U32 SessionId = pSmeMgmtFrm->sessionId;
2201
2202 pRoamInfo.nFrameLength = pSmeMgmtFrm->frameLen;
2203 pRoamInfo.pbFrames = pSmeMgmtFrm->frameBuf;
2204 pRoamInfo.frameType = pSmeMgmtFrm->frameType;
2205
2206 /* forward the mgmt frame to HDD */
2207 csrRoamCallCallback(pMac, SessionId, &pRoamInfo, 0, eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
2208
2209 return status;
2210}
2211#endif
2212
Hardik Kantilal Patel81f76342014-11-14 12:45:26 -08002213#ifdef WLAN_FEATURE_AP_HT40_24G
2214/* ---------------------------------------------------------------------------
2215 \fn sme_HT2040CoexInfoInd
2216 \brief a Send 20/40 Coex info to SAP layer
2217
2218 \param tpSirHT2040CoexInfoInd - 20/40 Coex info param
2219 \return eHalStatus
2220 ---------------------------------------------------------------------------*/
2221
2222eHalStatus sme_HT2040CoexInfoInd( tHalHandle hHal,
2223 tpSirHT2040CoexInfoInd pSmeHT2040CoexInfoInd)
2224{
2225 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2226 eHalStatus status = eHAL_STATUS_SUCCESS;
2227 tANI_U32 SessionId = pSmeHT2040CoexInfoInd->sessionId;
2228 tCsrRoamInfo roamInfo = {0};
2229
2230 roamInfo.pSmeHT2040CoexInfoInd = pSmeHT2040CoexInfoInd;
2231
2232 smsLog(pMac, LOGW, FL("HT40MHzIntolerant: %d HT20MHzBssWidthReq: %d"),
2233 roamInfo.pSmeHT2040CoexInfoInd->HT40MHzIntolerant,
2234 roamInfo.pSmeHT2040CoexInfoInd->HT20MHzBssWidthReq);
2235
2236 smsLog(pMac, LOGW, FL("Total Intolerant Channel: %d"),
2237 roamInfo.pSmeHT2040CoexInfoInd->channel_num);
2238
2239 /* forward the 20/40 BSS Coex information to HDD */
2240 smsLog(pMac, LOGW, FL("Sending eCSR_ROAM_2040_COEX_INFO_IND"
2241 " to WLANSAP_RoamCallback "));
2242
2243 csrRoamCallCallback(pMac, SessionId, &roamInfo,
2244 0, eCSR_ROAM_2040_COEX_INFO_IND, 0);
2245 return status;
2246}
2247#endif
2248
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002249#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002250/*------------------------------------------------------------------
2251 *
2252 * Handle the tsm ie indication from LIM and forward it to HDD.
2253 *
2254 *------------------------------------------------------------------*/
2255
2256eHalStatus sme_TsmIeInd(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
2257{
2258 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2259 eHalStatus status = eHAL_STATUS_SUCCESS;
2260 tCsrRoamInfo pRoamInfo = {0};
2261 tANI_U32 SessionId = pSmeTsmIeInd->sessionId;
2262
2263 pRoamInfo.tsmIe.tsid= pSmeTsmIeInd->tsmIe.tsid;
2264 pRoamInfo.tsmIe.state= pSmeTsmIeInd->tsmIe.state;
2265 pRoamInfo.tsmIe.msmt_interval= pSmeTsmIeInd->tsmIe.msmt_interval;
2266
2267 /* forward the tsm ie information to HDD */
2268 csrRoamCallCallback(pMac, SessionId, &pRoamInfo, 0, eCSR_ROAM_TSM_IE_IND, 0);
2269
2270 return status;
2271}
2272
2273/* ---------------------------------------------------------------------------
2274 \fn sme_SetCCKMIe
2275 \brief function to store the CCKM IE passed from supplicant and use it while packing
2276 reassociation request
2277 \param hHal - HAL handle for device
2278 \param pCckmIe - pointer to CCKM IE data
2279 \param pCckmIeLen - length of the CCKM IE
2280 \- return Success or failure
2281 -------------------------------------------------------------------------*/
2282eHalStatus sme_SetCCKMIe(tHalHandle hHal, tANI_U8 sessionId,
2283 tANI_U8 *pCckmIe, tANI_U8 cckmIeLen)
2284{
2285 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2286 eHalStatus status = eHAL_STATUS_SUCCESS;
2287
2288 status = sme_AcquireGlobalLock( &pMac->sme );
2289 if ( HAL_STATUS_SUCCESS( status ) )
2290 {
2291 csrSetCCKMIe(pMac, sessionId, pCckmIe, cckmIeLen);
2292 sme_ReleaseGlobalLock( &pMac->sme );
2293 }
2294 return status;
2295}
2296
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002297/* ---------------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002298 \fn sme_SetEseBeaconRequest
2299 \brief function to set Ese beacon request parameters
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002300 \param hHal - HAL handle for device
2301 \param sessionId - Session id
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002302 \param pEseBcnReq - pointer to Ese beacon request
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002303 \- return Success or failure
2304 -------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002305eHalStatus sme_SetEseBeaconRequest(tHalHandle hHal, const tANI_U8 sessionId,
2306 const tCsrEseBeaconReq* pEseBcnReq)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002307{
2308 eHalStatus status = eSIR_SUCCESS;
2309 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2310 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002311 tCsrEseBeaconReqParams *pBeaconReq = NULL;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002312 tANI_U8 counter = 0;
2313 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
2314 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
2315
2316 /* Store the info in RRM context */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002317 vos_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq, sizeof(tCsrEseBeaconReq));
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002318
2319 //Prepare the request to send to SME.
2320 pSmeBcnReportReq = vos_mem_malloc(sizeof( tSirBeaconReportReqInd ));
2321 if(NULL == pSmeBcnReportReq)
2322 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002323 smsLog(pMac, LOGP, "Memory Allocation Failure!!! Ese BcnReq Ind to SME");
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002324 return eSIR_FAILURE;
2325 }
2326
2327 smsLog(pMac, LOGE, "Sending Beacon Report Req to SME");
2328 vos_mem_zero( pSmeBcnReportReq, sizeof( tSirBeaconReportReqInd ));
2329
2330 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
2331 pSmeBcnReportReq->length = sizeof( tSirBeaconReportReqInd );
2332 vos_mem_copy( pSmeBcnReportReq->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
2333 pSmeBcnReportReq->channelInfo.channelNum = 255;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002334 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
2335 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002336
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002337 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002338 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002339 pBeaconReq = (tCsrEseBeaconReqParams *)&pEseBcnReq->bcnReq[counter];
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002340 pSmeBcnReportReq->fMeasurementtype[counter] = pBeaconReq->scanMode;
2341 pSmeBcnReportReq->measurementDuration[counter] = SYS_TU_TO_MS(pBeaconReq->measurementDuration);
2342 pSmeBcnReportReq->channelList.channelNumber[counter] = pBeaconReq->channel;
2343 }
2344
2345 sme_RrmProcessBeaconReportReqInd(pMac, pSmeBcnReportReq);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +05302346 vos_mem_free(pSmeBcnReportReq);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002347 return status;
2348}
2349
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002350#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002351
Chet Lanctot186b5732013-03-18 10:26:30 -07002352
Abhishek Singh00b71972016-01-07 10:51:04 +05302353#ifdef WLAN_FEATURE_RMC
2354eHalStatus sme_IbssPeerInfoResponseHandleer( tHalHandle hHal,
2355 tpSirIbssGetPeerInfoRspParams pIbssPeerInfoParams)
2356{
2357 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2358
2359 if (NULL == pMac)
2360 {
2361 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
2362 "%s: pMac is null", __func__);
2363 return eHAL_STATUS_FAILURE;
2364 }
2365 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL)
2366 {
2367 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2368 "%s: HDD callback is null", __func__);
2369 return eHAL_STATUS_FAILURE;
2370 }
2371 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
2372 &pIbssPeerInfoParams->ibssPeerInfoRspParams);
2373 return eHAL_STATUS_SUCCESS;
2374}
2375#endif /* WLAN_FEATURE_RMC */
2376
2377
c_hpothu92367912014-05-01 15:18:17 +05302378/* ---------------------------------------------------------------------------
2379 \fn sme_getBcnMissRate
2380 \brief function sends 'WDA_GET_BCN_MISS_RATE_REQ' to WDA layer,
2381 \param hHal - HAL handle for device.
2382 \param sessionId - session ID.
2383 \- return Success or Failure.
2384 -------------------------------------------------------------------------*/
2385
2386eHalStatus sme_getBcnMissRate(tHalHandle hHal, tANI_U8 sessionId, void *callback, void *data)
2387{
2388 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2389 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2390 vos_msg_t vosMessage;
2391 tSirBcnMissRateReq *pMsg;
2392 tCsrRoamSession *pSession;
2393
2394 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
2395 {
2396 pSession = CSR_GET_SESSION( pMac, sessionId );
2397
2398 if (!pSession)
2399 {
2400 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
2401 sme_ReleaseGlobalLock( &pMac->sme );
2402 return eHAL_STATUS_FAILURE;
2403 }
2404
c_hpothu402de812014-07-10 15:55:45 +05302405 pMsg = (tSirBcnMissRateReq *) vos_mem_malloc(sizeof(tSirBcnMissRateReq));
c_hpothu92367912014-05-01 15:18:17 +05302406 if (NULL == pMsg)
2407 {
2408 smsLog(pMac, LOGE, FL("failed to allocated memory"));
2409 sme_ReleaseGlobalLock( &pMac->sme );
2410 return eHAL_STATUS_FAILURE;
2411 }
2412
2413 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
2414 sizeof(tSirMacAddr));
2415
2416 pMsg->msgLen = sizeof(tSirBcnMissRateReq);
2417 pMsg->callback = callback;
2418 pMsg->data = data;
2419
2420 vosMessage.type = WDA_GET_BCN_MISS_RATE_REQ;
2421 vosMessage.bodyptr = pMsg;
2422 vosMessage.reserved = 0;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302423 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2424 TRACE_CODE_SME_TX_WDA_MSG, sessionId, vosMessage.type));
c_hpothu92367912014-05-01 15:18:17 +05302425 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
2426 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
2427 {
2428 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2429 "%s: Post Set TM Level MSG fail", __func__);
2430 vos_mem_free(pMsg);
2431 sme_ReleaseGlobalLock( &pMac->sme );
2432 return eHAL_STATUS_FAILURE;
2433 }
2434 sme_ReleaseGlobalLock( &pMac->sme);
2435 return eHAL_STATUS_SUCCESS;
2436 }
2437 return eHAL_STATUS_FAILURE;
2438}
2439
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05302440eHalStatus sme_EncryptMsgResponseHandler(tHalHandle hHal,
2441 tpSirEncryptedDataRspParams pEncRspParams)
2442{
2443 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2444
2445 if (NULL == pMac)
2446 {
2447 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
2448 "%s: pMac is null", __func__);
2449 return eHAL_STATUS_FAILURE;
2450 }
2451 if (pMac->sme.pEncMsgInfoParams.pEncMsgCbk == NULL)
2452 {
2453 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2454 "%s: HDD callback is null", __func__);
2455 return eHAL_STATUS_FAILURE;
2456 }
2457 pMac->sme.pEncMsgInfoParams.pEncMsgCbk(pMac->sme.pEncMsgInfoParams.pUserData,
2458 &pEncRspParams->encryptedDataRsp);
2459 return eHAL_STATUS_SUCCESS;
2460}
2461
Girish Gowlia95daca2015-02-04 20:31:31 +05302462eHalStatus sme_UpdateMaxRateInd(tHalHandle hHal,
2463 tSirSmeUpdateMaxRateParams *pSmeUpdateMaxRateParams)
2464{
2465 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2466 eHalStatus status = eHAL_STATUS_SUCCESS;
2467 tANI_U8 sessionId = pSmeUpdateMaxRateParams->smeSessionId;
2468
2469 /* forward the information to HDD */
2470 status = csrRoamCallCallback(pMac, sessionId, NULL, 0,
2471 eCSR_ROAM_UPDATE_MAX_RATE_IND,
2472 pSmeUpdateMaxRateParams->maxRateFlag);
2473 return status;
2474}
2475
Abhishek Singh550aa8c2017-10-30 17:34:53 +05302476/**
2477 * sme_ecsa_msg_processor() - Handle ECSA indication and resp from LIM
2478 * @mac_ctx: A pointer to Global MAC structure
2479 * @msg_type: Indication/resp type
2480 * @msg_buf: Indication/resp buffer
2481 *
2482 * Return VOS_STATUS
2483 */
2484static VOS_STATUS sme_ecsa_msg_processor(tpAniSirGlobal mac_ctx,
2485 uint16_t msg_type, void *msg_buf)
2486{
2487 tCsrRoamInfo roam_info = { 0 };
2488 struct sir_ecsa_ie_complete_ind *ecsa_ie_cmp_ind;
2489 struct sir_channel_chanege_rsp *chan_params;
2490 uint32_t session_id = 0;
2491 eRoamCmdStatus roamStatus;
2492 eCsrRoamResult roamResult;
2493
2494 switch (msg_type) {
2495 case eWNI_SME_ECSA_IE_BEACON_COMP_IND:
2496 ecsa_ie_cmp_ind =
2497 (struct sir_ecsa_ie_complete_ind *) msg_buf;
2498 if (!ecsa_ie_cmp_ind) {
2499 smsLog(mac_ctx, LOGE, FL("pMsg is NULL for eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND"));
2500 return VOS_STATUS_E_FAILURE;
2501 }
2502 session_id = ecsa_ie_cmp_ind->session_id;
2503 roamStatus = eCSR_ROAM_ECSA_BCN_TX_IND;
2504 roamResult = eCSR_ROAM_RESULT_NONE;
2505 smsLog(mac_ctx, LOG1, FL("sapdfs: Received eWNI_SME_ECSA_IE_BEACON_COMP_IND for session id [%d]"),
2506 session_id);
2507 break;
2508 case eWNI_SME_ECSA_CHAN_CHANGE_RSP:
2509 chan_params = (struct sir_channel_chanege_rsp *)msg_buf;
2510 roam_info.ap_chan_change_rsp =
2511 vos_mem_malloc(sizeof(struct sir_channel_chanege_rsp));
2512 if (!roam_info.ap_chan_change_rsp) {
2513 smsLog(mac_ctx, LOGE, FL("failed to allocate ap_chan_change_rsp"));
2514 return VOS_STATUS_E_FAILURE;
2515 }
2516 session_id = chan_params->sme_session_id;
2517 roam_info.ap_chan_change_rsp->sme_session_id = session_id;
2518 roam_info.ap_chan_change_rsp->new_channel = chan_params->new_channel;
2519 if (chan_params->status == VOS_STATUS_SUCCESS) {
2520 roam_info.ap_chan_change_rsp->status = VOS_STATUS_SUCCESS;
2521 roamResult = eCSR_ROAM_RESULT_NONE;
2522 } else {
2523 roam_info.ap_chan_change_rsp->status = VOS_STATUS_E_FAILURE;
2524 roamResult = eCSR_ROAM_RESULT_FAILURE;
2525 }
2526 roamStatus = eCSR_ROAM_ECSA_CHAN_CHANGE_RSP;
2527 break;
2528 default:
2529 smsLog(mac_ctx, LOGE, FL("Invalid ECSA message: 0x%x"), msg_type);
2530 return VOS_STATUS_E_FAILURE;
2531 }
2532
2533 /* Indicate Radar Event to SAP */
2534 csrRoamCallCallback(mac_ctx, session_id, &roam_info, 0,
2535 roamStatus, roamResult);
2536 if (roam_info.ap_chan_change_rsp)
2537 vos_mem_free(roam_info.ap_chan_change_rsp);
2538
2539 return VOS_STATUS_SUCCESS;
2540}
2541
Yeshwanth Sriram Guntuka5dce44c2018-05-22 16:10:01 +05302542static bool sme_get_sessionid_from_scan_cmd(tpAniSirGlobal mac,
2543 tANI_U32 *session_id)
2544{
2545 tListElem *entry = NULL;
2546 tSmeCmd *command = NULL;
2547 bool active_scan = false;
2548
2549 if (!mac->fScanOffload) {
2550 entry = csrLLPeekHead(&mac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
2551 } else {
2552 entry = csrLLPeekHead(&mac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK);
2553 }
2554
2555 if (entry) {
2556 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2557 if (command->command == eSmeCommandScan) {
2558 *session_id = command->sessionId;
2559 active_scan = true;
2560 }
2561 }
2562
2563 return active_scan;
2564}
2565
Jeff Johnson295189b2012-06-20 16:38:30 -07002566/*--------------------------------------------------------------------------
2567
2568 \brief sme_ProcessMsg() - The main message processor for SME.
2569
2570 The function is called by a message dispatcher when to process a message
2571 targeted for SME.
2572
Srinivas Girigowdade697412013-02-14 16:31:48 -08002573 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 \param hHal - The handle returned by macOpen.
2575 \param pMsg - A pointer to a caller allocated object of tSirMsgQ.
2576
2577 \return eHAL_STATUS_SUCCESS - SME successfully process the message.
2578
2579 Other status means SME failed to process the message to HAL.
2580 \sa
2581
2582 --------------------------------------------------------------------------*/
2583eHalStatus sme_ProcessMsg(tHalHandle hHal, vos_msg_t* pMsg)
2584{
2585 eHalStatus status = eHAL_STATUS_FAILURE;
2586 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2587
2588 if (pMsg == NULL) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002589 smsLog( pMac, LOGE, "Empty message for SME, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 return status;
2591 }
2592
2593 status = sme_AcquireGlobalLock( &pMac->sme );
2594 if ( HAL_STATUS_SUCCESS( status ) )
2595 {
2596 if( SME_IS_START(pMac) )
2597 {
2598 switch (pMsg->type) { // TODO: Will be modified to do a range check for msgs instead of having cases for each msgs
2599 case eWNI_PMC_ENTER_BMPS_RSP:
2600 case eWNI_PMC_EXIT_BMPS_RSP:
2601 case eWNI_PMC_EXIT_BMPS_IND:
2602 case eWNI_PMC_ENTER_IMPS_RSP:
2603 case eWNI_PMC_EXIT_IMPS_RSP:
2604 case eWNI_PMC_SMPS_STATE_IND:
2605 case eWNI_PMC_ENTER_UAPSD_RSP:
2606 case eWNI_PMC_EXIT_UAPSD_RSP:
2607 case eWNI_PMC_ENTER_WOWL_RSP:
2608 case eWNI_PMC_EXIT_WOWL_RSP:
2609 //PMC
2610 if (pMsg->bodyptr)
2611 {
2612 pmcMessageProcessor(hHal, pMsg->bodyptr);
2613 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +05302614 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002616 smsLog( pMac, LOGE, "Empty rsp message for PMC, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 }
2618 break;
2619
2620 case WNI_CFG_SET_CNF:
2621 case WNI_CFG_DNLD_CNF:
2622 case WNI_CFG_GET_RSP:
2623 case WNI_CFG_ADD_GRP_ADDR_CNF:
2624 case WNI_CFG_DEL_GRP_ADDR_CNF:
2625 //CCM
2626 if (pMsg->bodyptr)
2627 {
2628 ccmCfgCnfMsgHandler(hHal, pMsg->bodyptr);
2629 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +05302630 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002632 smsLog( pMac, LOGE, "Empty rsp message for CCM, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 }
2634 break;
2635
2636 case eWNI_SME_ADDTS_RSP:
2637 case eWNI_SME_DELTS_RSP:
2638 case eWNI_SME_DELTS_IND:
2639#ifdef WLAN_FEATURE_VOWIFI_11R
2640 case eWNI_SME_FT_AGGR_QOS_RSP:
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07002641#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 //QoS
2643 if (pMsg->bodyptr)
2644 {
2645#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2646 status = sme_QosMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05302647 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002648#endif
2649 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002650 smsLog( pMac, LOGE, "Empty rsp message for QoS, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 }
2652 break;
2653#if defined WLAN_FEATURE_VOWIFI
2654 case eWNI_SME_NEIGHBOR_REPORT_IND:
2655 case eWNI_SME_BEACON_REPORT_REQ_IND:
2656#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002657 smsLog( pMac, LOGE, "Received RRM message. Message Id = %d", pMsg->type );
Jeff Johnson295189b2012-06-20 16:38:30 -07002658#endif
2659 if ( pMsg->bodyptr )
2660 {
2661 status = sme_RrmMsgProcessor( pMac, pMsg->type, pMsg->bodyptr );
Kiet Lam64c1b492013-07-12 13:56:44 +05302662 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 }
2664 else
2665 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002666 smsLog( pMac, LOGE, "Empty message for RRM, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 }
2668 break;
2669#endif
2670
Jeff Johnsone7245742012-09-05 17:12:55 -07002671#ifdef FEATURE_OEM_DATA_SUPPORT
2672 //Handle the eWNI_SME_OEM_DATA_RSP:
2673 case eWNI_SME_OEM_DATA_RSP:
2674 if(pMsg->bodyptr)
2675 {
2676 status = sme_HandleOemDataRsp(pMac, pMsg->bodyptr);
2677 vos_mem_free(pMsg->bodyptr);
2678 }
2679 else
2680 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002681 smsLog( pMac, LOGE, "Empty rsp message for oemData_ (eWNI_SME_OEM_DATA_RSP), nothing to process");
Jeff Johnsone7245742012-09-05 17:12:55 -07002682 }
2683 smeProcessPendingQueue( pMac );
2684 break;
2685#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002686
2687 case eWNI_SME_ADD_STA_SELF_RSP:
2688 if(pMsg->bodyptr)
2689 {
2690 status = csrProcessAddStaSessionRsp(pMac, pMsg->bodyptr);
2691 vos_mem_free(pMsg->bodyptr);
2692 }
2693 else
2694 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002695 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ADD_STA_SELF_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 }
2697 break;
2698 case eWNI_SME_DEL_STA_SELF_RSP:
2699 if(pMsg->bodyptr)
2700 {
2701 status = csrProcessDelStaSessionRsp(pMac, pMsg->bodyptr);
2702 vos_mem_free(pMsg->bodyptr);
2703 }
2704 else
2705 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002706 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_DEL_STA_SELF_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 }
2708 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002709 case eWNI_SME_REMAIN_ON_CHN_RSP:
2710 if(pMsg->bodyptr)
2711 {
2712 status = sme_remainOnChnRsp(pMac, pMsg->bodyptr);
2713 vos_mem_free(pMsg->bodyptr);
2714 }
2715 else
2716 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002717 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 }
2719 break;
2720 case eWNI_SME_REMAIN_ON_CHN_RDY_IND:
2721 if(pMsg->bodyptr)
2722 {
2723 status = sme_remainOnChnReady(pMac, pMsg->bodyptr);
2724 vos_mem_free(pMsg->bodyptr);
2725 }
2726 else
2727 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002728 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 -07002729 }
2730 break;
Hardik Kantilal Patel81f76342014-11-14 12:45:26 -08002731#ifdef WLAN_FEATURE_AP_HT40_24G
2732 case eWNI_SME_2040_COEX_IND:
2733 if(pMsg->bodyptr)
2734 {
2735 sme_HT2040CoexInfoInd(pMac, pMsg->bodyptr);
2736 vos_mem_free(pMsg->bodyptr);
2737 }
2738 else
2739 {
2740 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_2040_COEX_IND), nothing to process");
2741 }
2742 break;
2743#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 case eWNI_SME_ACTION_FRAME_SEND_CNF:
2745 if(pMsg->bodyptr)
2746 {
2747 status = sme_sendActionCnf(pMac, pMsg->bodyptr);
2748 vos_mem_free(pMsg->bodyptr);
2749 }
2750 else
2751 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002752 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ACTION_FRAME_SEND_CNF), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 }
2754 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 case eWNI_SME_COEX_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302756 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2757 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 if(pMsg->bodyptr)
2759 {
c_hpothu3ba2a512014-08-06 14:02:54 +05302760 tSirSmeCoexInd *pSmeCoexInd = (tSirSmeCoexInd *)pMsg->bodyptr;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302761 vos_msg_t vosMessage = {0};
Yeshwanth Sriram Guntuka5dce44c2018-05-22 16:10:01 +05302762 tANI_U32 session_id = 0;
2763 bool active_scan;
Yeshwanth Sriram Guntukaa1869732018-10-31 16:22:01 +05302764 tANI_U32 nTime = 0;
c_hpothu3ba2a512014-08-06 14:02:54 +05302765
2766 if (pSmeCoexInd->coexIndType == SIR_COEX_IND_TYPE_DISABLE_AGGREGATION_IN_2p4)
2767 {
Yeshwanth Sriram Guntukaac589f42018-04-24 17:29:18 +05302768 pMac->btc.agg_disabled = true;
c_hpothu3ba2a512014-08-06 14:02:54 +05302769 smsLog( pMac, LOG1, FL("SIR_COEX_IND_TYPE_DISABLE_AGGREGATION_IN_2p4"));
Yeshwanth Sriram Guntuka5dce44c2018-05-22 16:10:01 +05302770 active_scan = sme_get_sessionid_from_scan_cmd(pMac,
2771 &session_id);
2772 if (active_scan)
2773 sme_AbortMacScan(hHal, session_id,
2774 eCSR_SCAN_ABORT_DEFAULT);
c_hpothu3ba2a512014-08-06 14:02:54 +05302775 sme_RequestFullPower(hHal, NULL, NULL, eSME_REASON_OTHER);
2776 pMac->isCoexScoIndSet = 1;
Ganesh Kondabattini48e9f742017-06-02 22:16:29 +05302777 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
2778 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_TRUE;
Yeshwanth Sriram Guntukaa3961612018-01-04 14:24:50 +05302779
2780 vosMessage.type = eWNI_SME_STA_DEL_BA_REQ;
2781 vos_mq_post_message(VOS_MQ_ID_PE, &vosMessage);
c_hpothu3ba2a512014-08-06 14:02:54 +05302782 }
2783 else if (pSmeCoexInd->coexIndType == SIR_COEX_IND_TYPE_ENABLE_AGGREGATION_IN_2p4)
2784 {
Yeshwanth Sriram Guntukaac589f42018-04-24 17:29:18 +05302785 pMac->btc.agg_disabled = false;
c_hpothu3ba2a512014-08-06 14:02:54 +05302786 smsLog( pMac, LOG1, FL("SIR_COEX_IND_TYPE_ENABLE_AGGREGATION_IN_2p4"));
2787 pMac->isCoexScoIndSet = 0;
2788 sme_RequestBmps(hHal, NULL, NULL);
Ganesh Kondabattini48e9f742017-06-02 22:16:29 +05302789 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
2790 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302791
Yeshwanth Sriram Guntukaa1869732018-10-31 16:22:01 +05302792 if(csrIsAllSessionDisconnected(pMac) &&
2793 !HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac,
2794 &nTime))) {
2795 csrScanStartIdleScanTimer(pMac, nTime);
2796 }
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302797 /*
2798 * If aggregation during SCO is enabled, there is a
2799 * possibility for an active BA session. This session
2800 * should be deleted on receiving enable aggregation
2801 * indication and block ack buffer size should be reset
2802 * to default.
2803 */
2804 if (pMac->roam.configParam.agg_btc_sco_enabled) {
2805 vosMessage.type = eWNI_SME_STA_DEL_BA_REQ;
2806 vos_mq_post_message(VOS_MQ_ID_PE, &vosMessage);
2807 }
c_hpothu3ba2a512014-08-06 14:02:54 +05302808 }
2809
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 status = btcHandleCoexInd((void *)pMac, pMsg->bodyptr);
2811 vos_mem_free(pMsg->bodyptr);
2812 }
2813 else
2814 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002815 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07002817 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002818
2819#ifdef FEATURE_WLAN_SCAN_PNO
2820 case eWNI_SME_PREF_NETWORK_FOUND_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302821 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2822 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 if(pMsg->bodyptr)
2824 {
2825 status = sme_PreferredNetworkFoundInd((void *)pMac, pMsg->bodyptr);
2826 vos_mem_free(pMsg->bodyptr);
2827 }
2828 else
2829 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002830 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_PREF_NETWORK_FOUND_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 }
2832 break;
2833#endif // FEATURE_WLAN_SCAN_PNO
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07002834
Jeff Johnson295189b2012-06-20 16:38:30 -07002835 case eWNI_SME_TX_PER_HIT_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302836 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2837 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 if (pMac->sme.pTxPerHitCallback)
2839 {
2840 pMac->sme.pTxPerHitCallback(pMac->sme.pTxPerHitCbContext);
2841 }
2842 break;
2843
2844 case eWNI_SME_CHANGE_COUNTRY_CODE:
Amar Singhal0d15bd52013-10-12 23:13:13 -07002845 if(pMsg->bodyptr)
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 {
2847 status = sme_HandleChangeCountryCode((void *)pMac, pMsg->bodyptr);
2848 vos_mem_free(pMsg->bodyptr);
2849 }
2850 else
2851 {
Amar Singhal0d15bd52013-10-12 23:13:13 -07002852 smsLog(pMac, LOGE, "Empty rsp message for message (eWNI_SME_CHANGE_COUNTRY_CODE), nothing to process");
2853 }
2854 break;
2855
2856 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2857 if (pMsg->bodyptr)
2858 {
2859 status = sme_HandleGenericChangeCountryCode((void *)pMac, pMsg->bodyptr);
2860 vos_mem_free(pMsg->bodyptr);
2861 }
2862 else
2863 {
2864 smsLog(pMac, LOGE, "Empty rsp message for message (eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 }
2866 break;
2867
2868#ifdef WLAN_FEATURE_PACKET_FILTERING
2869 case eWNI_PMC_PACKET_COALESCING_FILTER_MATCH_COUNT_RSP:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302870 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2871 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 if(pMsg->bodyptr)
2873 {
2874 status = sme_PCFilterMatchCountResponseHandler((void *)pMac, pMsg->bodyptr);
2875 vos_mem_free(pMsg->bodyptr);
2876 }
2877 else
2878 {
2879 smsLog(pMac, LOGE, "Empty rsp message for meas "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002880 "(PACKET_COALESCING_FILTER_MATCH_COUNT_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002881 }
2882 break;
2883#endif // WLAN_FEATURE_PACKET_FILTERING
2884 case eWNI_SME_PRE_SWITCH_CHL_IND:
2885 {
2886 status = sme_HandlePreChannelSwitchInd(pMac);
2887 break;
2888 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07002889
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 case eWNI_SME_POST_SWITCH_CHL_IND:
2891 {
2892 status = sme_HandlePostChannelSwitchInd(pMac);
2893 break;
2894 }
2895
2896#ifdef WLAN_WAKEUP_EVENTS
2897 case eWNI_SME_WAKE_REASON_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302898 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2899 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 if(pMsg->bodyptr)
2901 {
2902 status = sme_WakeReasonIndCallback((void *)pMac, pMsg->bodyptr);
2903 vos_mem_free(pMsg->bodyptr);
2904 }
2905 else
2906 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002907 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_WAKE_REASON_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 }
2909 break;
2910#endif // WLAN_WAKEUP_EVENTS
2911
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002912#ifdef FEATURE_WLAN_TDLS
2913 /*
2914 * command rescived from PE, SME tdls msg processor shall be called
2915 * to process commands recieved from PE
2916 */
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07002917 case eWNI_SME_TDLS_SEND_MGMT_RSP:
2918 case eWNI_SME_TDLS_ADD_STA_RSP:
Hoonki Leee6bfe942013-02-05 15:01:19 -08002919 case eWNI_SME_TDLS_DEL_STA_RSP:
2920 case eWNI_SME_TDLS_DEL_STA_IND:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002921 case eWNI_SME_TDLS_DEL_ALL_PEER_IND:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002922 case eWNI_SME_MGMT_FRM_TX_COMPLETION_IND:
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302923 case eWNI_SME_TDLS_LINK_ESTABLISH_RSP:
Atul Mittal60bd4292014-08-14 12:19:27 +05302924 case eWNI_SME_TDLS_CHANNEL_SWITCH_RSP:
Deepthi Gowri25e25552015-05-14 12:12:50 +05302925 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002926 if (pMsg->bodyptr)
2927 {
2928 status = tdlsMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05302929 vos_mem_free(pMsg->bodyptr);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002930 }
2931 else
2932 {
2933 smsLog( pMac, LOGE, "Empty rsp message for TDLS, \
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002934 nothing to process");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002935 }
2936 break;
2937 }
2938#endif
2939
Chet Lanctot186b5732013-03-18 10:26:30 -07002940#ifdef WLAN_FEATURE_11W
2941 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2942 if (pMsg->bodyptr)
2943 {
2944 sme_UnprotectedMgmtFrmInd(pMac, pMsg->bodyptr);
2945 vos_mem_free(pMsg->bodyptr);
2946 }
2947 else
2948 {
2949 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_UNPROT_MGMT_FRM_IND), nothing to process");
2950 }
2951 break;
2952#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002953#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002954 case eWNI_SME_TSM_IE_IND:
2955 {
2956 if (pMsg->bodyptr)
2957 {
2958 sme_TsmIeInd(pMac, pMsg->bodyptr);
2959 vos_mem_free(pMsg->bodyptr);
2960 }
2961 else
2962 {
2963 smsLog(pMac, LOGE, "Empty rsp message for (eWNI_SME_TSM_IE_IND), nothing to process");
2964 }
2965 break;
2966 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002967#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07002968#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2969 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2970 status = csrRoamOffloadScanRspHdlr((void *)pMac, pMsg->bodyval);
2971 break;
2972#endif // WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Chet Lanctot186b5732013-03-18 10:26:30 -07002973
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05302974#ifdef WLAN_FEATURE_GTK_OFFLOAD
2975 case eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302976 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2977 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05302978 if (pMsg->bodyptr)
2979 {
2980 sme_ProcessGetGtkInfoRsp(pMac, pMsg->bodyptr);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05302981 vos_mem_zero(pMsg->bodyptr,
2982 sizeof(tSirGtkOffloadGetInfoRspParams));
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05302983 vos_mem_free(pMsg->bodyptr);
2984 }
2985 else
2986 {
2987 smsLog(pMac, LOGE, "Empty rsp message for (eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP), nothing to process");
2988 }
2989 break ;
2990#endif
Leo Chang9056f462013-08-01 19:21:11 -07002991
2992#ifdef FEATURE_WLAN_LPHB
2993 /* LPHB timeout indication arrived, send IND to client */
Leo Changd9df8aa2013-09-26 13:32:26 -07002994 case eWNI_SME_LPHB_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302995 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2996 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Leo Changd9df8aa2013-09-26 13:32:26 -07002997 if (pMac->sme.pLphbIndCb)
Leo Chang9056f462013-08-01 19:21:11 -07002998 {
Leo Changd9df8aa2013-09-26 13:32:26 -07002999 pMac->sme.pLphbIndCb(pMac->pAdapter, pMsg->bodyptr);
Leo Chang9056f462013-08-01 19:21:11 -07003000 }
3001 vos_mem_free(pMsg->bodyptr);
3002
3003 break;
3004#endif /* FEATURE_WLAN_LPHB */
3005
Abhishek Singh00b71972016-01-07 10:51:04 +05303006#ifdef WLAN_FEATURE_RMC
3007 case eWNI_SME_IBSS_PEER_INFO_RSP:
3008 MTRACE(vos_trace(VOS_MODULE_ID_SME,
3009 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
3010 if (pMsg->bodyptr)
3011 {
3012 sme_IbssPeerInfoResponseHandleer(pMac, pMsg->bodyptr);
3013 vos_mem_free(pMsg->bodyptr);
3014 }
3015 else
3016 {
3017 smsLog(pMac, LOGE,
3018 "Empty rsp message for (eWNI_SME_IBSS_PEER_INFO_RSP),"
3019 " nothing to process");
3020 }
3021 break ;
3022
3023#endif /* WLAN_FEATURE_RMC */
3024
Leo Chang0b0e45a2013-12-15 15:18:55 -08003025#ifdef FEATURE_WLAN_CH_AVOID
3026 /* LPHB timeout indication arrived, send IND to client */
3027 case eWNI_SME_CH_AVOID_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05303028 MTRACE(vos_trace(VOS_MODULE_ID_SME,
3029 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Leo Chang0b0e45a2013-12-15 15:18:55 -08003030 if (pMac->sme.pChAvoidNotificationCb)
3031 {
3032 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3033 "%s: CH avoid notification", __func__);
3034 pMac->sme.pChAvoidNotificationCb(pMac->pAdapter, pMsg->bodyptr);
3035 }
3036 vos_mem_free(pMsg->bodyptr);
3037
3038 break;
3039#endif /* FEATURE_WLAN_CH_AVOID */
3040
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303041 case eWNI_SME_ENCRYPT_MSG_RSP:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05303042 MTRACE(vos_trace(VOS_MODULE_ID_SME,
3043 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303044 if (pMsg->bodyptr)
3045 {
3046 sme_EncryptMsgResponseHandler(pMac, pMsg->bodyptr);
3047 vos_mem_free(pMsg->bodyptr);
3048 }
3049 else
3050 {
3051 smsLog(pMac, LOGE,
3052 "Empty rsp message for (eWNI_SME_ENCRYPT_MSG_RSP),"
3053 " nothing to process");
3054 }
3055 break ;
3056
Girish Gowlia95daca2015-02-04 20:31:31 +05303057 case eWNI_SME_UPDATE_MAX_RATE_IND:
3058 if (pMsg->bodyptr)
3059 {
3060 sme_UpdateMaxRateInd(pMac, pMsg->bodyptr);
3061 vos_mem_free(pMsg->bodyptr);
3062 }
3063 else
3064 {
3065 smsLog(pMac, LOGE,
3066 "Empty message for (eWNI_SME_UPDATE_MAX_RATE_IND),"
3067 " nothing to process");
3068 }
3069 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303070
Srinivas Dasari030bad32015-02-18 23:23:54 +05303071 case eWNI_SME_NAN_EVENT:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05303072 MTRACE(vos_trace(VOS_MODULE_ID_SME,
3073 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Srinivas Dasari030bad32015-02-18 23:23:54 +05303074 if (pMsg->bodyptr)
3075 {
3076 sme_NanEvent(hHal, pMsg->bodyptr);
3077 vos_mem_free(pMsg->bodyptr);
3078 }
3079 else
3080 {
3081 smsLog(pMac, LOGE,
3082 "Empty message for (eWNI_SME_NAN_EVENT),"
3083 " nothing to process");
3084 }
3085 break;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05303086 case eWNI_SME_ECSA_IE_BEACON_COMP_IND:
3087 case eWNI_SME_ECSA_CHAN_CHANGE_RSP:
3088 MTRACE(vos_trace(VOS_MODULE_ID_SME,
3089 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
3090 if (pMsg->bodyptr)
3091 {
3092 sme_ecsa_msg_processor(pMac, pMsg->type, pMsg->bodyptr);
3093 vos_mem_free(pMsg->bodyptr);
3094 }
3095 else
3096 {
3097 smsLog(pMac, LOGE,
3098 FL("Empty message for (eWNI_SME_ECSA_IE_BEACON_COMP_IND)"));
3099 }
3100 break;
Srinivas Dasari030bad32015-02-18 23:23:54 +05303101
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 default:
3103
3104 if ( ( pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN )
3105 && ( pMsg->type <= eWNI_SME_MSG_TYPES_END ) )
3106 {
3107 //CSR
3108 if (pMsg->bodyptr)
3109 {
3110 status = csrMsgProcessor(hHal, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05303111 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 }
3113 else
3114 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003115 smsLog( pMac, LOGE, "Empty rsp message for CSR, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 }
3117 }
3118 else
3119 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003120 smsLog( pMac, LOGW, "Unknown message type %d, nothing to process",
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 pMsg->type);
3122 if (pMsg->bodyptr)
3123 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303124 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 }
3126 }
3127 }//switch
3128 } //SME_IS_START
3129 else
3130 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003131 smsLog( pMac, LOGW, "message type %d in stop state ignored", pMsg->type);
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 if (pMsg->bodyptr)
3133 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303134 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 }
3136 }
3137 sme_ReleaseGlobalLock( &pMac->sme );
3138 }
3139 else
3140 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003141 smsLog( pMac, LOGW, "Locking failed, bailing out");
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 if (pMsg->bodyptr)
3143 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303144 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 }
3146 }
3147
3148 return status;
3149}
3150
3151
3152//No need to hold the global lock here because this function can only be called
3153//after sme_Stop.
3154v_VOID_t sme_FreeMsg( tHalHandle hHal, vos_msg_t* pMsg )
3155{
3156 if( pMsg )
3157 {
3158 if (pMsg->bodyptr)
3159 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303160 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 }
3162 }
3163
3164}
3165
3166
3167/*--------------------------------------------------------------------------
3168
3169 \brief sme_Stop() - Stop all SME modules and put them at idle state
3170
3171 The function stops each module in SME, PMC, CCM, CSR, etc. . Upon
3172 return, all modules are at idle state ready to start.
3173
Srinivas Girigowdade697412013-02-14 16:31:48 -08003174 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 \param hHal - The handle returned by macOpen
Kiet Lama72a2322013-11-15 11:18:11 +05303176 \param tHalStopType - reason for stopping
Jeff Johnson295189b2012-06-20 16:38:30 -07003177
3178 \return eHAL_STATUS_SUCCESS - SME is stopped.
3179
3180 Other status means SME is failed to stop but caller should still
3181 consider SME is stopped.
3182 \sa
3183
3184 --------------------------------------------------------------------------*/
Kiet Lama72a2322013-11-15 11:18:11 +05303185eHalStatus sme_Stop(tHalHandle hHal, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -07003186{
3187 eHalStatus status = eHAL_STATUS_FAILURE;
3188 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
3189 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3190
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 status = WLANSAP_Stop(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
3192 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003193 smsLog( pMac, LOGE, "WLANSAP_Stop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 status );
3195 fail_status = status;
3196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003197
3198 p2pStop(hHal);
3199
Kiet Lama72a2322013-11-15 11:18:11 +05303200 status = pmcStop(hHal);
3201 if ( ! HAL_STATUS_SUCCESS( status ) ) {
3202 smsLog( pMac, LOGE, "pmcStop failed during smeStop with status=%d",
3203 status );
3204 fail_status = status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 }
3206
Kiet Lama72a2322013-11-15 11:18:11 +05303207 status = csrStop(pMac, stopType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003209 smsLog( pMac, LOGE, "csrStop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 status );
3211 fail_status = status;
3212 }
3213
3214 ccmStop(hHal);
3215
3216 purgeSmeCmdList(pMac);
3217
3218 if (!HAL_STATUS_SUCCESS( fail_status )) {
3219 status = fail_status;
3220 }
3221
3222 pMac->sme.state = SME_STATE_STOP;
3223
3224 return status;
3225}
3226
3227/*--------------------------------------------------------------------------
3228
3229 \brief sme_Close() - Release all SME modules and their resources.
3230
3231 The function release each module in SME, PMC, CCM, CSR, etc. . Upon
3232 return, all modules are at closed state.
3233
3234 No SME APIs can be involved after smeClose except smeOpen.
3235 smeClose must be called before macClose.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003236 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 \param hHal - The handle returned by macOpen
3238
3239 \return eHAL_STATUS_SUCCESS - SME is successfully close.
3240
3241 Other status means SME is failed to be closed but caller still cannot
3242 call any other SME functions except smeOpen.
3243 \sa
3244
3245 --------------------------------------------------------------------------*/
3246eHalStatus sme_Close(tHalHandle hHal)
3247{
3248 eHalStatus status = eHAL_STATUS_FAILURE;
3249 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
3250 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3251
3252 status = csrClose(pMac);
3253 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003254 smsLog( pMac, LOGE, "csrClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 status );
3256 fail_status = status;
3257 }
3258
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 status = WLANSAP_Close(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
3260 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003261 smsLog( pMac, LOGE, "WLANSAP_close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003262 status );
3263 fail_status = status;
3264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003265
3266#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3267 status = btcClose(hHal);
3268 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003269 smsLog( pMac, LOGE, "BTC close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 status );
3271 fail_status = status;
3272 }
3273
3274 status = sme_QosClose(pMac);
3275 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003276 smsLog( pMac, LOGE, "Qos close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 status );
3278 fail_status = status;
3279 }
3280#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003281#ifdef FEATURE_OEM_DATA_SUPPORT
3282 status = oemData_OemDataReqClose(hHal);
3283 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003284 smsLog( pMac, LOGE, "OEM DATA REQ close failed during sme close with status=%d",
Jeff Johnsone7245742012-09-05 17:12:55 -07003285 status );
3286 fail_status = status;
3287 }
3288#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003289
3290 status = ccmClose(hHal);
3291 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003292 smsLog( pMac, LOGE, "ccmClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 status );
3294 fail_status = status;
3295 }
3296
3297 status = pmcClose(hHal);
3298 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003299 smsLog( pMac, LOGE, "pmcClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 status );
3301 fail_status = status;
3302 }
3303#if defined WLAN_FEATURE_VOWIFI
3304 status = rrmClose(hHal);
3305 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003306 smsLog( pMac, LOGE, "RRM close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 status );
3308 fail_status = status;
3309 }
3310#endif
3311
3312#if defined WLAN_FEATURE_VOWIFI_11R
3313 sme_FTClose(hHal);
3314#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 sme_p2pClose(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07003316
3317 freeSmeCmdList(pMac);
3318
3319 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->sme.lkSmeGlobalLock ) ) )
3320 {
3321 fail_status = eHAL_STATUS_FAILURE;
3322 }
3323
3324 if (!HAL_STATUS_SUCCESS( fail_status )) {
3325 status = fail_status;
3326 }
3327
3328 pMac->sme.state = SME_STATE_STOP;
3329
3330 return status;
3331}
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05303332
3333v_VOID_t sme_PreClose(tHalHandle hHal)
3334{
3335 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3336
mukul sharma867a9df2015-07-08 13:28:24 +05303337 if(!pMac)
3338 return;
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05303339
mukul sharma867a9df2015-07-08 13:28:24 +05303340 smsLog(pMac, LOGW, FL("Stopping Active CMD List Timer"));
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05303341 vos_timer_stop( pMac->sme.smeCmdActiveList.cmdTimeoutTimer );
3342
3343}
3344
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003345#ifdef FEATURE_WLAN_LFR
3346tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac)
3347{
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07003348#if 0
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003349 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
3350 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
3351 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
3352 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
3353 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3354 return eANI_BOOLEAN_FALSE;
3355 default:
3356 return eANI_BOOLEAN_TRUE;
3357 }
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07003358#else
3359 /*
3360 * TODO: always return TRUE for now until
3361 * we figure out why we could be stuck in
3362 * one of the roaming states forever.
3363 */
3364 return eANI_BOOLEAN_TRUE;
3365#endif
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003366}
3367#endif
c_hpothu58901462014-11-01 16:44:34 +05303368
3369/* ---------------------------------------------------------------------------
3370 \fn sco_isScanAllowed
3371 \brief check for scan interface connection status
3372 \param pMac - Pointer to the global MAC parameter structure
3373 \param pScanReq - scan request structure.
3374
3375 \return tANI_BOOLEAN TRUE to allow scan otherwise FALSE
3376 ---------------------------------------------------------------------------*/
3377tANI_BOOLEAN sco_isScanAllowed(tpAniSirGlobal pMac, tCsrScanRequest *pscanReq)
3378{
3379 tANI_BOOLEAN ret;
3380
3381 if (pscanReq->p2pSearch)
3382 ret = csrIsP2pSessionConnected(pMac);
3383 else
3384 ret = csrIsStaSessionConnected(pMac);
3385
3386 return !ret;
3387}
3388
Jeff Johnson295189b2012-06-20 16:38:30 -07003389/* ---------------------------------------------------------------------------
3390 \fn sme_ScanRequest
3391 \brief a wrapper function to Request a 11d or full scan from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003392 This is an asynchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 \param pScanRequestID - pointer to an object to get back the request ID
3394 \param callback - a callback function that scan calls upon finish, will not
3395 be called if csrScanRequest returns error
3396 \param pContext - a pointer passed in for the callback
3397 \return eHalStatus
3398 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003399eHalStatus sme_ScanRequest(tHalHandle hHal, tANI_U8 sessionId, tCsrScanRequest *pscanReq,
3400 tANI_U32 *pScanRequestID,
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 csrScanCompleteCallback callback, void *pContext)
3402{
3403 eHalStatus status = eHAL_STATUS_FAILURE;
3404 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05303405 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003406 TRACE_CODE_SME_RX_HDD_MSG_SCAN_REQ, sessionId, pscanReq->scanType));
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05303407
3408 smsLog(pMac, LOG1,
3409 FL("isCoexScoIndSet %d disable_scan_during_sco %d is_disconnected %d"),
3410 pMac->isCoexScoIndSet,
3411 pMac->scan.disable_scan_during_sco,
3412 csrIsConnStateDisconnected(pMac, sessionId));
3413
3414 if (pMac->isCoexScoIndSet && pMac->scan.disable_scan_during_sco &&
3415 csrIsConnStateDisconnected(pMac, sessionId)) {
Padma, Santhosh Kumar4ffece42016-11-15 15:08:53 +05303416 csrScanFlushResult(pMac);
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05303417 pMac->scan.disable_scan_during_sco_timer_info.callback = callback;
3418 pMac->scan.disable_scan_during_sco_timer_info.dev = pContext;
3419 pMac->scan.disable_scan_during_sco_timer_info.scan_id= *pScanRequestID;
3420
3421 vos_timer_start(&pMac->scan.disable_scan_during_sco_timer,
3422 CSR_DISABLE_SCAN_DURING_SCO);
3423 return eHAL_STATUS_SUCCESS;
3424 }
3425
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 do
3427 {
c_hpothu304c0522014-09-30 10:22:57 +05303428 if(pMac->scan.fScanEnable &&
c_hpothu58901462014-11-01 16:44:34 +05303429 (pMac->isCoexScoIndSet ? sco_isScanAllowed(pMac, pscanReq) : TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 {
3431 status = sme_AcquireGlobalLock( &pMac->sme );
3432 if ( HAL_STATUS_SUCCESS( status ) )
3433 {
3434 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003435#ifdef FEATURE_WLAN_LFR
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003436 if(csrIsScanAllowed(pMac))
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003437 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003438#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003439 status = csrScanRequest( hHal, sessionId, pscanReq,
3440 pScanRequestID, callback, pContext );
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05303441 if ( !HAL_STATUS_SUCCESS( status ) )
3442 {
3443 smsLog(pMac, LOGE, FL("csrScanRequest failed"
3444 " SId=%d"), sessionId);
3445 }
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003446#ifdef FEATURE_WLAN_LFR
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003447 }
3448 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003449 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05303450 smsLog(pMac, LOGE, FL("Scan denied in state %s"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05303451 "(sub-state %s)"),
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05303452 macTraceGetNeighbourRoamState(
3453 pMac->roam.neighborRoamInfo.neighborRoamState),
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05303454 macTraceGetcsrRoamSubState(
3455 pMac->roam.curSubState[sessionId]));
Madan Mohan Koyyalamudiab4ab0d2012-10-24 14:26:50 -07003456 /*HandOff is in progress. So schedule this scan later*/
3457 status = eHAL_STATUS_RESOURCES;
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003458 }
3459#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003461
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 sme_ReleaseGlobalLock( &pMac->sme );
3463 } //sme_AcquireGlobalLock success
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003464 else
3465 {
3466 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
3467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 } //if(pMac->scan.fScanEnable)
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003469 else
3470 {
c_hpothu3ba2a512014-08-06 14:02:54 +05303471 smsLog(pMac, LOGE, FL("fScanEnable %d isCoexScoIndSet: %d "),
3472 pMac->scan.fScanEnable, pMac->isCoexScoIndSet);
Agarwal Ashish32bf8632015-02-25 16:02:06 +05303473 status = eHAL_STATUS_RESOURCES;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 } while( 0 );
3476
3477 return (status);
3478
3479
3480}
3481
3482/* ---------------------------------------------------------------------------
3483 \fn sme_ScanGetResult
3484 \brief a wrapper function to request scan results from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003485 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 \param pFilter - If pFilter is NULL, all cached results are returned
3487 \param phResult - an object for the result.
3488 \return eHalStatus
3489 ---------------------------------------------------------------------------*/
3490eHalStatus sme_ScanGetResult(tHalHandle hHal, tANI_U8 sessionId, tCsrScanResultFilter *pFilter,
3491 tScanResultHandle *phResult)
3492{
3493 eHalStatus status = eHAL_STATUS_FAILURE;
3494 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3495
Katya Nigambcb705f2013-12-26 14:26:22 +05303496 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003497 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 smsLog(pMac, LOG2, FL("enter"));
3499 status = sme_AcquireGlobalLock( &pMac->sme );
3500 if ( HAL_STATUS_SUCCESS( status ) )
3501 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07003502 status = csrScanGetResult( hHal, pFilter, phResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 sme_ReleaseGlobalLock( &pMac->sme );
3504 }
3505 smsLog(pMac, LOG2, FL("exit status %d"), status);
3506
3507 return (status);
3508}
3509
3510
3511/* ---------------------------------------------------------------------------
3512 \fn sme_ScanFlushResult
3513 \brief a wrapper function to request CSR to clear scan results.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003514 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 \return eHalStatus
3516 ---------------------------------------------------------------------------*/
3517eHalStatus sme_ScanFlushResult(tHalHandle hHal, tANI_U8 sessionId)
3518{
3519 eHalStatus status = eHAL_STATUS_FAILURE;
3520 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3521
Katya Nigambcb705f2013-12-26 14:26:22 +05303522 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003523 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS, sessionId,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 status = sme_AcquireGlobalLock( &pMac->sme );
3525 if ( HAL_STATUS_SUCCESS( status ) )
3526 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07003527 status = csrScanFlushResult( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 sme_ReleaseGlobalLock( &pMac->sme );
3529 }
3530
3531 return (status);
3532}
3533
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05303534/* ---------------------------------------------------------------------------
3535 \fn sme_FilterScanResults
3536 \brief a wrapper function to request CSR to clear scan results.
3537 This is a synchronous call
3538 \return eHalStatus
3539 ---------------------------------------------------------------------------*/
3540eHalStatus sme_FilterScanResults(tHalHandle hHal, tANI_U8 sessionId)
3541{
3542 eHalStatus status = eHAL_STATUS_SUCCESS;
3543 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3544
3545 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3546 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS, sessionId,0 ));
3547 status = sme_AcquireGlobalLock( &pMac->sme );
3548 if ( HAL_STATUS_SUCCESS( status ) )
3549 {
3550 csrScanFilterResults(pMac);
3551 sme_ReleaseGlobalLock( &pMac->sme );
3552 }
3553
3554 return (status);
3555}
3556
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05303557 /*
3558 * ---------------------------------------------------------------------------
3559 * \fn sme_FilterScanDFSResults
3560 * \brief a wrapper function to request CSR to filter BSSIDs on DFS channels
3561 * from the scan results.
3562 * \return eHalStatus
3563 *---------------------------------------------------------------------------
3564 */
3565eHalStatus sme_FilterScanDFSResults(tHalHandle hHal)
3566{
3567 eHalStatus status = eHAL_STATUS_SUCCESS;
3568 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3569
3570 status = sme_AcquireGlobalLock( &pMac->sme );
3571 if ( HAL_STATUS_SUCCESS( status ) )
3572 {
3573 csrScanFilterDFSResults(pMac);
3574 sme_ReleaseGlobalLock( &pMac->sme );
3575 }
3576
3577 return (status);
3578}
3579
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07003580eHalStatus sme_ScanFlushP2PResult(tHalHandle hHal, tANI_U8 sessionId)
3581{
3582 eHalStatus status = eHAL_STATUS_FAILURE;
3583 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3584
Katya Nigambcb705f2013-12-26 14:26:22 +05303585 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003586 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS, sessionId,0 ));
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07003587 status = sme_AcquireGlobalLock( &pMac->sme );
3588 if ( HAL_STATUS_SUCCESS( status ) )
3589 {
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05303590 status = csrScanFlushSelectiveResult( hHal, VOS_TRUE );
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07003591 sme_ReleaseGlobalLock( &pMac->sme );
3592 }
3593
3594 return (status);
3595}
Jeff Johnson295189b2012-06-20 16:38:30 -07003596
3597/* ---------------------------------------------------------------------------
3598 \fn sme_ScanResultGetFirst
3599 \brief a wrapper function to request CSR to returns the first element of
3600 scan result.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003601 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 \param hScanResult - returned from csrScanGetResult
3603 \return tCsrScanResultInfo * - NULL if no result
3604 ---------------------------------------------------------------------------*/
3605tCsrScanResultInfo *sme_ScanResultGetFirst(tHalHandle hHal,
3606 tScanResultHandle hScanResult)
3607{
3608 eHalStatus status = eHAL_STATUS_FAILURE;
3609 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3610 tCsrScanResultInfo *pRet = NULL;
3611
Katya Nigambcb705f2013-12-26 14:26:22 +05303612 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003613 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST, NO_SESSION,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 status = sme_AcquireGlobalLock( &pMac->sme );
3615 if ( HAL_STATUS_SUCCESS( status ) )
3616 {
3617 pRet = csrScanResultGetFirst( pMac, hScanResult );
3618 sme_ReleaseGlobalLock( &pMac->sme );
3619 }
3620
3621 return (pRet);
3622}
3623
3624
3625/* ---------------------------------------------------------------------------
3626 \fn sme_ScanResultGetNext
3627 \brief a wrapper function to request CSR to returns the next element of
3628 scan result. It can be called without calling csrScanResultGetFirst
3629 first
Srinivas Girigowdade697412013-02-14 16:31:48 -08003630 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 \param hScanResult - returned from csrScanGetResult
3632 \return Null if no result or reach the end
3633 ---------------------------------------------------------------------------*/
3634tCsrScanResultInfo *sme_ScanResultGetNext(tHalHandle hHal,
3635 tScanResultHandle hScanResult)
3636{
3637 eHalStatus status = eHAL_STATUS_FAILURE;
3638 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3639 tCsrScanResultInfo *pRet = NULL;
3640
3641 status = sme_AcquireGlobalLock( &pMac->sme );
3642 if ( HAL_STATUS_SUCCESS( status ) )
3643 {
3644 pRet = csrScanResultGetNext( pMac, hScanResult );
3645 sme_ReleaseGlobalLock( &pMac->sme );
3646 }
3647
3648 return (pRet);
3649}
3650
3651
3652/* ---------------------------------------------------------------------------
3653 \fn sme_ScanSetBGScanparams
3654 \brief a wrapper function to request CSR to set BG scan params in PE
Srinivas Girigowdade697412013-02-14 16:31:48 -08003655 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 \param pScanReq - BG scan request structure
3657 \return eHalStatus
3658 ---------------------------------------------------------------------------*/
3659eHalStatus sme_ScanSetBGScanparams(tHalHandle hHal, tANI_U8 sessionId, tCsrBGScanRequest *pScanReq)
3660{
3661 eHalStatus status = eHAL_STATUS_FAILURE;
3662 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3663
3664 if( NULL != pScanReq )
3665 {
3666 status = sme_AcquireGlobalLock( &pMac->sme );
3667 if ( HAL_STATUS_SUCCESS( status ) )
3668 {
3669 status = csrScanSetBGScanparams( hHal, pScanReq );
3670 sme_ReleaseGlobalLock( &pMac->sme );
3671 }
3672 }
3673
3674 return (status);
3675}
3676
3677
3678/* ---------------------------------------------------------------------------
3679 \fn sme_ScanResultPurge
3680 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
3681 in the list and free memory for each item
Srinivas Girigowdade697412013-02-14 16:31:48 -08003682 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 \param hScanResult - returned from csrScanGetResult. hScanResult is
3684 considered gone by
3685 calling this function and even before this function reutrns.
3686 \return eHalStatus
3687 ---------------------------------------------------------------------------*/
3688eHalStatus sme_ScanResultPurge(tHalHandle hHal, tScanResultHandle hScanResult)
3689{
3690 eHalStatus status = eHAL_STATUS_FAILURE;
3691 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3692
Katya Nigambcb705f2013-12-26 14:26:22 +05303693 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003694 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE, NO_SESSION,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 status = sme_AcquireGlobalLock( &pMac->sme );
3696 if ( HAL_STATUS_SUCCESS( status ) )
3697 {
3698 status = csrScanResultPurge( hHal, hScanResult );
3699 sme_ReleaseGlobalLock( &pMac->sme );
3700 }
3701
3702 return (status);
3703}
3704
3705/* ---------------------------------------------------------------------------
3706 \fn sme_ScanGetPMKIDCandidateList
3707 \brief a wrapper function to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08003708 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 \param pPmkidList - caller allocated buffer point to an array of
3710 tPmkidCandidateInfo
3711 \param pNumItems - pointer to a variable that has the number of
3712 tPmkidCandidateInfo allocated when retruning, this is
3713 either the number needed or number of items put into
3714 pPmkidList
3715 \return eHalStatus - when fail, it usually means the buffer allocated is not
3716 big enough and pNumItems
3717 has the number of tPmkidCandidateInfo.
3718 \Note: pNumItems is a number of tPmkidCandidateInfo,
3719 not sizeof(tPmkidCandidateInfo) * something
3720 ---------------------------------------------------------------------------*/
3721eHalStatus sme_ScanGetPMKIDCandidateList(tHalHandle hHal, tANI_U8 sessionId,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003722 tPmkidCandidateInfo *pPmkidList,
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 tANI_U32 *pNumItems )
3724{
3725 eHalStatus status = eHAL_STATUS_FAILURE;
3726 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3727
3728 status = sme_AcquireGlobalLock( &pMac->sme );
3729 if ( HAL_STATUS_SUCCESS( status ) )
3730 {
3731 status = csrScanGetPMKIDCandidateList( pMac, sessionId, pPmkidList, pNumItems );
3732 sme_ReleaseGlobalLock( &pMac->sme );
3733 }
3734
3735 return (status);
3736}
3737
3738/*----------------------------------------------------------------------------
3739 \fn sme_RoamRegisterLinkQualityIndCallback
3740
3741 \brief
3742 a wrapper function to allow HDD to register a callback handler with CSR for
3743 link quality indications.
3744
3745 Only one callback may be registered at any time.
3746 In order to deregister the callback, a NULL cback may be provided.
3747
3748 Registration happens in the task context of the caller.
3749
3750 \param callback - Call back being registered
3751 \param pContext - user data
3752
3753 DEPENDENCIES: After CSR open
3754
3755 \return eHalStatus
3756-----------------------------------------------------------------------------*/
3757eHalStatus sme_RoamRegisterLinkQualityIndCallback(tHalHandle hHal, tANI_U8 sessionId,
3758 csrRoamLinkQualityIndCallback callback,
3759 void *pContext)
3760{
3761 return(csrRoamRegisterLinkQualityIndCallback((tpAniSirGlobal)hHal, callback, pContext));
3762}
3763
3764/* ---------------------------------------------------------------------------
3765 \fn sme_RoamRegisterCallback
3766 \brief a wrapper function to allow HDD to register a callback with CSR.
3767 Unlike scan, roam has one callback for all the roam requests
3768 \param callback - a callback function that roam calls upon when state changes
3769 \param pContext - a pointer passed in for the callback
3770 \return eHalStatus
3771 ---------------------------------------------------------------------------*/
3772eHalStatus sme_RoamRegisterCallback(tHalHandle hHal,
3773 csrRoamCompleteCallback callback,
3774 void *pContext)
3775{
3776 return(csrRoamRegisterCallback((tpAniSirGlobal)hHal, callback, pContext));
3777}
3778
3779eCsrPhyMode sme_GetPhyMode(tHalHandle hHal)
3780{
3781 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3782 return pMac->roam.configParam.phyMode;
3783}
3784
3785/* ---------------------------------------------------------------------------
Peng Xu117eab42014-09-25 13:33:27 +05303786 \fn sme_GetChannelBondingMode5G
3787 \brief get the channel bonding mode for 5G band
3788 \param hHal - HAL handle
3789 \return channel bonding mode for 5G
3790 ---------------------------------------------------------------------------*/
3791tANI_U32 sme_GetChannelBondingMode5G(tHalHandle hHal)
3792{
3793 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3794 tSmeConfigParams smeConfig;
3795
3796 sme_GetConfigParam(pMac, &smeConfig);
3797
3798 return smeConfig.csrConfig.channelBondingMode5GHz;
3799}
3800
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05303801#ifdef WLAN_FEATURE_AP_HT40_24G
Peng Xu117eab42014-09-25 13:33:27 +05303802/* ---------------------------------------------------------------------------
3803 \fn sme_GetChannelBondingMode24G
3804 \brief get the channel bonding mode for 2.4G band
3805 \param hHal - HAL handle
3806 \return channel bonding mode for 2.4G
3807 ---------------------------------------------------------------------------*/
3808tANI_U32 sme_GetChannelBondingMode24G(tHalHandle hHal)
3809{
3810 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3811 tSmeConfigParams smeConfig;
3812
3813 sme_GetConfigParam(pMac, &smeConfig);
3814
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05303815 return smeConfig.csrConfig.channelBondingAPMode24GHz;
Peng Xu117eab42014-09-25 13:33:27 +05303816}
3817
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05303818/* ---------------------------------------------------------------------------
3819 \fn sme_UpdateChannelBondingMode24G
3820 \brief update the channel bonding mode for 2.4G band
3821 \param hHal - HAL handle
3822 \param cbMode - channel bonding mode
3823 \return
3824 ---------------------------------------------------------------------------*/
3825void sme_UpdateChannelBondingMode24G(tHalHandle hHal, tANI_U8 cbMode)
3826{
3827 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3828 tSmeConfigParams smeConfig;
3829
3830 vos_mem_zero(&smeConfig, sizeof (tSmeConfigParams));
3831 sme_GetConfigParam(pMac, &smeConfig);
3832 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
3833 FL("Previous Channel Bonding : = %d"),
3834 smeConfig.csrConfig.channelBondingAPMode24GHz);
3835
3836 smeConfig.csrConfig.channelBondingAPMode24GHz = cbMode;
3837 sme_UpdateConfig(hHal, &smeConfig);
3838 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
3839 FL("New Channel Bonding : = %d"),
3840 sme_GetChannelBondingMode24G(hHal));
3841 return;
3842}
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05303843
3844/* ---------------------------------------------------------------------------
3845
3846 \fn sme_SetHT2040Mode
3847
3848 \brief To update HT Operation beacon IE & Channel Bonding.
3849
3850 \param
3851
3852 \return eHalStatus SUCCESS
3853 FAILURE or RESOURCES
3854 The API finished and failed.
3855
3856 -------------------------------------------------------------------------------*/
3857eHalStatus sme_SetHT2040Mode(tHalHandle hHal, tANI_U8 sessionId, tANI_U8 cbMode)
3858{
3859 eHalStatus status = eHAL_STATUS_FAILURE;
3860 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3861
3862 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3863 FL("Channel Bonding =%d"),
3864 cbMode);
3865
3866 status = sme_AcquireGlobalLock(&pMac->sme);
3867 if (HAL_STATUS_SUCCESS(status))
3868 {
3869 status = csrSetHT2040Mode(pMac, sessionId, cbMode);
3870 sme_ReleaseGlobalLock(&pMac->sme );
3871 }
3872 return (status);
3873}
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05303874#endif
Peng Xu117eab42014-09-25 13:33:27 +05303875
3876/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 \fn sme_RoamConnect
3878 \brief a wrapper function to request CSR to inititiate an association
Srinivas Girigowdade697412013-02-14 16:31:48 -08003879 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003880 \param sessionId - the sessionId returned by sme_OpenSession.
3881 \param pProfile - description of the network to which to connect
3882 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
3883 from csrScanGetResult
3884 \param pRoamId - to get back the request ID
3885 \return eHalStatus
3886 ---------------------------------------------------------------------------*/
3887eHalStatus sme_RoamConnect(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
3888 tANI_U32 *pRoamId)
3889{
3890 eHalStatus status = eHAL_STATUS_FAILURE;
3891 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3892
Yue Mae36e3552014-03-05 17:06:20 -08003893 if (!pMac)
3894 {
3895 return eHAL_STATUS_FAILURE;
3896 }
3897
Katya Nigambcb705f2013-12-26 14:26:22 +05303898 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003899 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 smsLog(pMac, LOG2, FL("enter"));
3901 status = sme_AcquireGlobalLock( &pMac->sme );
3902 if ( HAL_STATUS_SUCCESS( status ) )
3903 {
3904 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3905 {
3906 status = csrRoamConnect( pMac, sessionId, pProfile, NULL, pRoamId );
3907 }
3908 else
3909 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003910 smsLog(pMac, LOGE, FL("invalid sessionID %d"), sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 status = eHAL_STATUS_INVALID_PARAMETER;
3912 }
3913 sme_ReleaseGlobalLock( &pMac->sme );
3914 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003915 else
3916 {
3917 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
3918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003919
3920 return (status);
3921}
3922
3923/* ---------------------------------------------------------------------------
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05303924
3925 \fn sme_SetPhyMode
3926
3927 \brief Changes the PhyMode.
3928
3929 \param hHal - The handle returned by macOpen.
3930
3931 \param phyMode new phyMode which is to set
3932
3933 \return eHalStatus SUCCESS.
3934
3935 -------------------------------------------------------------------------------*/
3936eHalStatus sme_SetPhyMode(tHalHandle hHal, eCsrPhyMode phyMode)
3937{
3938 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3939
3940 if (NULL == pMac)
3941 {
3942 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3943 "%s: invalid context", __func__);
3944 return eHAL_STATUS_FAILURE;
3945 }
3946
3947 pMac->roam.configParam.phyMode = phyMode;
3948 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL,
3949 pMac->roam.configParam.phyMode,
3950 pMac->roam.configParam.ProprietaryRatesEnabled);
3951
3952 return eHAL_STATUS_SUCCESS;
3953}
3954
3955/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 \fn sme_RoamReassoc
3957 \brief a wrapper function to request CSR to inititiate a re-association
3958 \param pProfile - can be NULL to join the currently connected AP. In that
3959 case modProfileFields should carry the modified field(s) which could trigger
3960 reassoc
3961 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
3962 that might need modification dynamically once STA is up & running and this
3963 could trigger a reassoc
3964 \param pRoamId - to get back the request ID
3965 \return eHalStatus
3966 -------------------------------------------------------------------------------*/
3967eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
3968 tCsrRoamModifyProfileFields modProfileFields,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07003969 tANI_U32 *pRoamId, v_BOOL_t fForce)
Jeff Johnson295189b2012-06-20 16:38:30 -07003970{
3971 eHalStatus status = eHAL_STATUS_FAILURE;
3972 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3973
Katya Nigambcb705f2013-12-26 14:26:22 +05303974 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003975 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 smsLog(pMac, LOG2, FL("enter"));
3977 status = sme_AcquireGlobalLock( &pMac->sme );
3978 if ( HAL_STATUS_SUCCESS( status ) )
3979 {
3980 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3981 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003982 if((NULL == pProfile) && (fForce == 1))
3983 {
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07003984 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3985 /* to force the AP initiate fresh 802.1x authentication need to clear
3986 * the PMKID cache for that set the following boolean. this is needed
3987 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
3988 pSession->fIgnorePMKIDCache = TRUE;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07003989 status = csrReassoc( pMac, sessionId, &modProfileFields, pRoamId , fForce);
3990 }
3991 else
3992 {
3993 status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 }
3996 else
3997 {
3998 status = eHAL_STATUS_INVALID_PARAMETER;
3999 }
4000 sme_ReleaseGlobalLock( &pMac->sme );
4001 }
4002
4003 return (status);
4004}
4005
4006/* ---------------------------------------------------------------------------
4007 \fn sme_RoamConnectToLastProfile
4008 \brief a wrapper function to request CSR to disconnect and reconnect with
4009 the same profile
Srinivas Girigowdade697412013-02-14 16:31:48 -08004010 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 \return eHalStatus. It returns fail if currently connected
4012 ---------------------------------------------------------------------------*/
4013eHalStatus sme_RoamConnectToLastProfile(tHalHandle hHal, tANI_U8 sessionId)
4014{
4015 eHalStatus status = eHAL_STATUS_FAILURE;
4016 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4017
4018 status = sme_AcquireGlobalLock( &pMac->sme );
4019 if ( HAL_STATUS_SUCCESS( status ) )
4020 {
4021 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4022 {
4023 status = csrRoamConnectToLastProfile( pMac, sessionId );
4024 }
4025 else
4026 {
4027 status = eHAL_STATUS_INVALID_PARAMETER;
4028 }
4029 sme_ReleaseGlobalLock( &pMac->sme );
4030 }
4031
4032 return (status);
4033}
4034
4035/* ---------------------------------------------------------------------------
4036 \fn sme_RoamDisconnect
4037 \brief a wrapper function to request CSR to disconnect from a network
Srinivas Girigowdade697412013-02-14 16:31:48 -08004038 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 \param reason -- To indicate the reason for disconnecting. Currently, only
4040 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
4041 \return eHalStatus
4042 ---------------------------------------------------------------------------*/
4043eHalStatus sme_RoamDisconnect(tHalHandle hHal, tANI_U8 sessionId, eCsrRoamDisconnectReason reason)
4044{
4045 eHalStatus status = eHAL_STATUS_FAILURE;
4046 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4047
Katya Nigambcb705f2013-12-26 14:26:22 +05304048 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004049 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId, reason));
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 smsLog(pMac, LOG2, FL("enter"));
4051 status = sme_AcquireGlobalLock( &pMac->sme );
4052 if ( HAL_STATUS_SUCCESS( status ) )
4053 {
4054 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4055 {
Abhishek Singh5de9efd2017-06-15 10:22:39 +05304056 /*
4057 * Indicate csr of disconnect so that
4058 * in progress connection, scan for ssid and preauth
4059 * can be aborted
4060 */
4061 csr_abortConnection(pMac, sessionId);
4062 status = csrRoamDisconnect(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 }
4064 else
4065 {
4066 status = eHAL_STATUS_INVALID_PARAMETER;
4067 }
4068 sme_ReleaseGlobalLock( &pMac->sme );
4069 }
4070
4071 return (status);
4072}
4073
Jeff Johnson295189b2012-06-20 16:38:30 -07004074/* ---------------------------------------------------------------------------
Sushant Kaushikb4834d22015-07-15 15:29:05 +05304075 \fn.sme_abortConnection
4076 \brief a wrapper function to request CSR to stop from connecting a network
4077 \retun void.
4078---------------------------------------------------------------------------*/
4079
4080void sme_abortConnection(tHalHandle hHal, tANI_U8 sessionId)
4081{
4082 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4083 eHalStatus status = eHAL_STATUS_FAILURE;
4084
4085 status = sme_AcquireGlobalLock( &pMac->sme );
4086 if ( HAL_STATUS_SUCCESS( status ) )
4087 {
4088 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4089 {
4090 csr_abortConnection( pMac, sessionId);
4091 }
4092 sme_ReleaseGlobalLock( &pMac->sme );
4093 }
4094 return;
4095}
4096
Abhishek Singhe0bc0992016-05-20 17:58:18 +05304097/* sme_dhcp_done_ind() - send dhcp done ind
4098 * @hal: hal context
4099 * @session_id: session id
4100 *
4101 * Return: void.
4102 */
4103void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
4104{
4105 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4106 tCsrRoamSession *session;
4107
4108 if (!mac_ctx)
4109 return;
4110
4111 session = CSR_GET_SESSION(mac_ctx, session_id);
4112 if(!session)
4113 {
4114 smsLog(mac_ctx, LOGE, FL(" session %d not found "), session_id);
4115 return;
4116 }
4117 session->dhcp_done = true;
4118}
4119
Sushant Kaushikb4834d22015-07-15 15:29:05 +05304120/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 \fn sme_RoamStopBss
4122 \brief To stop BSS for Soft AP. This is an asynchronous API.
4123 \param hHal - Global structure
4124 \param sessionId - sessionId of SoftAP
4125 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
4126 -------------------------------------------------------------------------------*/
4127eHalStatus sme_RoamStopBss(tHalHandle hHal, tANI_U8 sessionId)
4128{
4129 eHalStatus status = eHAL_STATUS_FAILURE;
4130 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4131
4132 smsLog(pMac, LOG2, FL("enter"));
4133 status = sme_AcquireGlobalLock( &pMac->sme );
4134 if ( HAL_STATUS_SUCCESS( status ) )
4135 {
4136 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4137 {
Gopichand Nakkalaf44bdc52013-02-16 00:54:45 +05304138 status = csrRoamIssueStopBssCmd( pMac, sessionId, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 }
4140 else
4141 {
4142 status = eHAL_STATUS_INVALID_PARAMETER;
4143 }
4144 sme_ReleaseGlobalLock( &pMac->sme );
4145 }
4146
4147 return (status);
4148}
4149
4150/* ---------------------------------------------------------------------------
4151 \fn sme_RoamDisconnectSta
4152 \brief To disassociate a station. This is an asynchronous API.
4153 \param hHal - Global structure
4154 \param sessionId - sessionId of SoftAP
4155 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
4156 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
4157 -------------------------------------------------------------------------------*/
4158eHalStatus sme_RoamDisconnectSta(tHalHandle hHal, tANI_U8 sessionId,
Anand N Sunkadc205d952015-07-30 15:36:03 +05304159#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
4160 const tANI_U8 *pPeerMacAddr
4161#else
4162 tANI_U8 *pPeerMacAddr
4163#endif
4164)
Jeff Johnson295189b2012-06-20 16:38:30 -07004165{
4166 eHalStatus status = eHAL_STATUS_FAILURE;
4167 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4168
4169 if ( NULL == pMac )
4170 {
4171 VOS_ASSERT(0);
4172 return status;
4173 }
4174
4175 status = sme_AcquireGlobalLock( &pMac->sme );
4176 if ( HAL_STATUS_SUCCESS( status ) )
4177 {
4178 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4179 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07004180 status = csrRoamIssueDisassociateStaCmd( pMac, sessionId, pPeerMacAddr,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05304181 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 }
4183 else
4184 {
4185 status = eHAL_STATUS_INVALID_PARAMETER;
4186 }
4187 sme_ReleaseGlobalLock( &pMac->sme );
4188 }
4189
4190 return (status);
4191}
4192
4193/* ---------------------------------------------------------------------------
4194 \fn sme_RoamDeauthSta
4195 \brief To disassociate a station. This is an asynchronous API.
4196 \param hHal - Global structure
4197 \param sessionId - sessionId of SoftAP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05304198 \param pDelStaParams -Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
4200 -------------------------------------------------------------------------------*/
4201eHalStatus sme_RoamDeauthSta(tHalHandle hHal, tANI_U8 sessionId,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05304202 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07004203{
4204 eHalStatus status = eHAL_STATUS_FAILURE;
4205 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4206
4207 if ( NULL == pMac )
4208 {
4209 VOS_ASSERT(0);
4210 return status;
4211 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +05304212 MTRACE(vos_trace(VOS_MODULE_ID_SME,
4213 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
4214 sessionId, pDelStaParams->reason_code));
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 status = sme_AcquireGlobalLock( &pMac->sme );
4216 if ( HAL_STATUS_SUCCESS( status ) )
4217 {
4218 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4219 {
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05304220 status = csrRoamIssueDeauthStaCmd( pMac, sessionId, pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 }
4222 else
4223 {
4224 status = eHAL_STATUS_INVALID_PARAMETER;
4225 }
4226 sme_ReleaseGlobalLock( &pMac->sme );
4227 }
4228
4229 return (status);
4230}
4231
4232/* ---------------------------------------------------------------------------
4233 \fn sme_RoamTKIPCounterMeasures
4234 \brief To start or stop TKIP counter measures. This is an asynchronous API.
4235 \param sessionId - sessionId of SoftAP
4236 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
4237 \return eHalStatus
4238 -------------------------------------------------------------------------------*/
4239eHalStatus sme_RoamTKIPCounterMeasures(tHalHandle hHal, tANI_U8 sessionId,
4240 tANI_BOOLEAN bEnable)
4241{
4242 eHalStatus status = eHAL_STATUS_FAILURE;
4243 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4244
4245 if ( NULL == pMac )
4246 {
4247 VOS_ASSERT(0);
4248 return status;
4249 }
4250
4251 status = sme_AcquireGlobalLock( &pMac->sme );
4252 if ( HAL_STATUS_SUCCESS( status ) )
4253 {
4254 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4255 {
4256 status = csrRoamIssueTkipCounterMeasures( pMac, sessionId, bEnable);
4257 }
4258 else
4259 {
4260 status = eHAL_STATUS_INVALID_PARAMETER;
4261 }
4262 sme_ReleaseGlobalLock( &pMac->sme );
4263 }
4264
4265 return (status);
4266}
4267
4268/* ---------------------------------------------------------------------------
4269 \fn sme_RoamGetAssociatedStas
4270 \brief To probe the list of associated stations from various modules of CORE stack.
4271 \This is an asynchronous API.
4272 \param sessionId - sessionId of SoftAP
4273 \param modId - Module from whom list of associtated stations is to be probed.
4274 If an invalid module is passed then by default VOS_MODULE_ID_PE will be probed
4275 \param pUsrContext - Opaque HDD context
4276 \param pfnSapEventCallback - Sap event callback in HDD
4277 \param pAssocBuf - Caller allocated memory to be filled with associatd stations info
4278 \return eHalStatus
4279 -------------------------------------------------------------------------------*/
4280eHalStatus sme_RoamGetAssociatedStas(tHalHandle hHal, tANI_U8 sessionId,
4281 VOS_MODULE_ID modId, void *pUsrContext,
4282 void *pfnSapEventCallback, tANI_U8 *pAssocStasBuf)
4283{
4284 eHalStatus status = eHAL_STATUS_FAILURE;
4285 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4286
4287 if ( NULL == pMac )
4288 {
4289 VOS_ASSERT(0);
4290 return status;
4291 }
4292
4293 status = sme_AcquireGlobalLock( &pMac->sme );
4294 if ( HAL_STATUS_SUCCESS( status ) )
4295 {
4296 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4297 {
4298 status = csrRoamGetAssociatedStas( pMac, sessionId, modId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
4299 }
4300 else
4301 {
4302 status = eHAL_STATUS_INVALID_PARAMETER;
4303 }
4304 sme_ReleaseGlobalLock( &pMac->sme );
4305 }
4306
4307 return (status);
4308}
4309
4310/* ---------------------------------------------------------------------------
4311 \fn sme_RoamGetWpsSessionOverlap
4312 \brief To get the WPS PBC session overlap information.
4313 \This is an asynchronous API.
4314 \param sessionId - sessionId of SoftAP
4315 \param pUsrContext - Opaque HDD context
4316 \param pfnSapEventCallback - Sap event callback in HDD
4317 \pRemoveMac - pointer to Mac address which needs to be removed from session
4318 \return eHalStatus
4319 -------------------------------------------------------------------------------*/
4320eHalStatus sme_RoamGetWpsSessionOverlap(tHalHandle hHal, tANI_U8 sessionId,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07004321 void *pUsrContext, void
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 *pfnSapEventCallback, v_MACADDR_t pRemoveMac)
4323{
4324 eHalStatus status = eHAL_STATUS_FAILURE;
4325 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4326
4327 if ( NULL == pMac )
4328 {
4329 VOS_ASSERT(0);
4330 return status;
4331 }
4332
4333 status = sme_AcquireGlobalLock( &pMac->sme );
4334 if ( HAL_STATUS_SUCCESS( status ) )
4335 {
4336 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4337 {
4338 status = csrRoamGetWpsSessionOverlap( pMac, sessionId, pUsrContext, pfnSapEventCallback, pRemoveMac);
4339 }
4340 else
4341 {
4342 status = eHAL_STATUS_INVALID_PARAMETER;
4343 }
4344 sme_ReleaseGlobalLock( &pMac->sme );
4345 }
4346
4347 return (status);
4348}
4349
Jeff Johnson295189b2012-06-20 16:38:30 -07004350
4351/* ---------------------------------------------------------------------------
4352 \fn sme_RoamGetConnectState
4353 \brief a wrapper function to request CSR to return the current connect state
4354 of Roaming
Srinivas Girigowdade697412013-02-14 16:31:48 -08004355 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 \return eHalStatus
4357 ---------------------------------------------------------------------------*/
4358eHalStatus sme_RoamGetConnectState(tHalHandle hHal, tANI_U8 sessionId, eCsrConnectState *pState)
4359{
4360 eHalStatus status = eHAL_STATUS_FAILURE;
4361 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4362
4363 status = sme_AcquireGlobalLock( &pMac->sme );
4364 if ( HAL_STATUS_SUCCESS( status ) )
4365 {
4366 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4367 {
4368 status = csrRoamGetConnectState( pMac, sessionId, pState );
4369 }
4370 else
4371 {
4372 status = eHAL_STATUS_INVALID_PARAMETER;
4373 }
4374 sme_ReleaseGlobalLock( &pMac->sme );
4375 }
4376
4377 return (status);
4378}
4379
4380/* ---------------------------------------------------------------------------
4381 \fn sme_RoamGetConnectProfile
4382 \brief a wrapper function to request CSR to return the current connect
4383 profile. Caller must call csrRoamFreeConnectProfile after it is done
4384 and before reuse for another csrRoamGetConnectProfile call.
Srinivas Girigowdade697412013-02-14 16:31:48 -08004385 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 \param pProfile - pointer to a caller allocated structure
4387 tCsrRoamConnectedProfile
4388 \return eHalStatus. Failure if not connected
4389 ---------------------------------------------------------------------------*/
4390eHalStatus sme_RoamGetConnectProfile(tHalHandle hHal, tANI_U8 sessionId,
4391 tCsrRoamConnectedProfile *pProfile)
4392{
4393 eHalStatus status = eHAL_STATUS_FAILURE;
4394 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4395
Katya Nigambcb705f2013-12-26 14:26:22 +05304396 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004397 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 status = sme_AcquireGlobalLock( &pMac->sme );
4399 if ( HAL_STATUS_SUCCESS( status ) )
4400 {
4401 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4402 {
4403 status = csrRoamGetConnectProfile( pMac, sessionId, pProfile );
4404 }
4405 else
4406 {
4407 status = eHAL_STATUS_INVALID_PARAMETER;
4408 }
4409 sme_ReleaseGlobalLock( &pMac->sme );
4410 }
4411
4412 return (status);
4413}
4414
4415/* ---------------------------------------------------------------------------
4416 \fn sme_RoamFreeConnectProfile
4417 \brief a wrapper function to request CSR to free and reinitialize the
4418 profile returned previously by csrRoamGetConnectProfile.
Srinivas Girigowdade697412013-02-14 16:31:48 -08004419 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 \param pProfile - pointer to a caller allocated structure
4421 tCsrRoamConnectedProfile
4422 \return eHalStatus.
4423 ---------------------------------------------------------------------------*/
4424eHalStatus sme_RoamFreeConnectProfile(tHalHandle hHal,
4425 tCsrRoamConnectedProfile *pProfile)
4426{
4427 eHalStatus status = eHAL_STATUS_FAILURE;
4428 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4429
Katya Nigambcb705f2013-12-26 14:26:22 +05304430 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004431 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 status = sme_AcquireGlobalLock( &pMac->sme );
4433 if ( HAL_STATUS_SUCCESS( status ) )
4434 {
4435 status = csrRoamFreeConnectProfile( pMac, pProfile );
4436 sme_ReleaseGlobalLock( &pMac->sme );
4437 }
4438
4439 return (status);
4440}
4441
4442/* ---------------------------------------------------------------------------
4443 \fn sme_RoamSetPMKIDCache
4444 \brief a wrapper function to request CSR to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08004445 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 \param pPMKIDCache - caller allocated buffer point to an array of
4447 tPmkidCacheInfo
4448 \param numItems - a variable that has the number of tPmkidCacheInfo
4449 allocated when retruning, this is either the number needed
4450 or number of items put into pPMKIDCache
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304451 \param update_entire_cache - this bool value specifies if the entire pmkid
4452 cache should be overwritten or should it be
4453 updated entry by entry.
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 \return eHalStatus - when fail, it usually means the buffer allocated is not
4455 big enough and pNumItems has the number of
4456 tPmkidCacheInfo.
4457 \Note: pNumItems is a number of tPmkidCacheInfo,
4458 not sizeof(tPmkidCacheInfo) * something
4459 ---------------------------------------------------------------------------*/
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304460eHalStatus sme_RoamSetPMKIDCache( tHalHandle hHal, tANI_U8 sessionId,
4461 tPmkidCacheInfo *pPMKIDCache,
4462 tANI_U32 numItems,
4463 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -07004464{
4465 eHalStatus status = eHAL_STATUS_FAILURE;
4466 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4467
Katya Nigambcb705f2013-12-26 14:26:22 +05304468 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004469 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId, numItems));
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 status = sme_AcquireGlobalLock( &pMac->sme );
4471 if ( HAL_STATUS_SUCCESS( status ) )
4472 {
4473 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4474 {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304475 status = csrRoamSetPMKIDCache( pMac, sessionId, pPMKIDCache,
4476 numItems, update_entire_cache );
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 }
4478 else
4479 {
4480 status = eHAL_STATUS_INVALID_PARAMETER;
4481 }
4482 sme_ReleaseGlobalLock( &pMac->sme );
4483 }
4484
4485 return (status);
4486}
4487
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304488eHalStatus sme_RoamDelPMKIDfromCache( tHalHandle hHal, tANI_U8 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304489#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
Abhinav Kumar8c122592019-08-07 15:43:20 +05304490 tPmkidCacheInfo *pmksa,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304491#else
Abhinav Kumar8c122592019-08-07 15:43:20 +05304492 tPmkidCacheInfo *pmksa,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304493#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304494 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -07004495{
4496 eHalStatus status = eHAL_STATUS_FAILURE;
4497 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4498 status = sme_AcquireGlobalLock( &pMac->sme );
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +05304499
4500 MTRACE(vos_trace(VOS_MODULE_ID_SME,
4501 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE, sessionId, flush_cache));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -07004502 if ( HAL_STATUS_SUCCESS( status ) )
4503 {
4504 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4505 {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304506 status = csrRoamDelPMKIDfromCache( pMac, sessionId,
Abhinav Kumar8c122592019-08-07 15:43:20 +05304507 pmksa, flush_cache );
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -07004508 }
4509 else
4510 {
4511 status = eHAL_STATUS_INVALID_PARAMETER;
4512 }
4513 sme_ReleaseGlobalLock( &pMac->sme );
4514 }
4515 return (status);
4516}
Wilson Yang47b58192013-12-11 11:40:19 -08004517
Jeff Johnson295189b2012-06-20 16:38:30 -07004518/* ---------------------------------------------------------------------------
4519 \fn sme_RoamGetSecurityReqIE
4520 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
4521 passes to PE to JOIN request or START_BSS request
Srinivas Girigowdade697412013-02-14 16:31:48 -08004522 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 \param pLen - caller allocated memory that has the length of pBuf as input.
4524 Upon returned, *pLen has the needed or IE length in pBuf.
4525 \param pBuf - Caller allocated memory that contain the IE field, if any,
4526 upon return
4527 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
4528 \return eHalStatus - when fail, it usually means the buffer allocated is not
4529 big enough
4530 ---------------------------------------------------------------------------*/
4531eHalStatus sme_RoamGetSecurityReqIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
4532 tANI_U8 *pBuf, eCsrSecurityType secType)
4533{
4534 eHalStatus status = eHAL_STATUS_FAILURE;
4535 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4536
4537 status = sme_AcquireGlobalLock( &pMac->sme );
4538 if ( HAL_STATUS_SUCCESS( status ) )
4539 {
4540 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4541 {
4542 status = csrRoamGetWpaRsnReqIE( hHal, sessionId, pLen, pBuf );
4543 }
4544 else
4545 {
4546 status = eHAL_STATUS_INVALID_PARAMETER;
4547 }
4548 sme_ReleaseGlobalLock( &pMac->sme );
4549 }
4550
4551 return (status);
4552}
4553
4554/* ---------------------------------------------------------------------------
4555 \fn sme_RoamGetSecurityRspIE
4556 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE from
4557 the beacon or probe rsp if connected
Srinivas Girigowdade697412013-02-14 16:31:48 -08004558 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 \param pLen - caller allocated memory that has the length of pBuf as input.
4560 Upon returned, *pLen has the needed or IE length in pBuf.
4561 \param pBuf - Caller allocated memory that contain the IE field, if any,
4562 upon return
4563 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
4564 \return eHalStatus - when fail, it usually means the buffer allocated is not
4565 big enough
4566 ---------------------------------------------------------------------------*/
4567eHalStatus sme_RoamGetSecurityRspIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
4568 tANI_U8 *pBuf, eCsrSecurityType secType)
4569{
4570 eHalStatus status = eHAL_STATUS_FAILURE;
4571 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4572
4573 status = sme_AcquireGlobalLock( &pMac->sme );
4574 if ( HAL_STATUS_SUCCESS( status ) )
4575 {
4576 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4577 {
4578 status = csrRoamGetWpaRsnRspIE( pMac, sessionId, pLen, pBuf );
4579 }
4580 else
4581 {
4582 status = eHAL_STATUS_INVALID_PARAMETER;
4583 }
4584 sme_ReleaseGlobalLock( &pMac->sme );
4585 }
4586
4587 return (status);
4588
4589}
4590
4591
4592/* ---------------------------------------------------------------------------
4593 \fn sme_RoamGetNumPMKIDCache
4594 \brief a wrapper function to request CSR to return number of PMKID cache
4595 entries
Srinivas Girigowdade697412013-02-14 16:31:48 -08004596 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 \return tANI_U32 - the number of PMKID cache entries
4598 ---------------------------------------------------------------------------*/
4599tANI_U32 sme_RoamGetNumPMKIDCache(tHalHandle hHal, tANI_U8 sessionId)
4600{
4601 eHalStatus status = eHAL_STATUS_FAILURE;
4602 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4603 tANI_U32 numPmkidCache = 0;
4604
4605 status = sme_AcquireGlobalLock( &pMac->sme );
4606 if ( HAL_STATUS_SUCCESS( status ) )
4607 {
4608 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4609 {
4610 numPmkidCache = csrRoamGetNumPMKIDCache( pMac, sessionId );
4611 status = eHAL_STATUS_SUCCESS;
4612 }
4613 else
4614 {
4615 status = eHAL_STATUS_INVALID_PARAMETER;
4616 }
4617 sme_ReleaseGlobalLock( &pMac->sme );
4618 }
4619
4620 return (numPmkidCache);
4621}
4622
4623/* ---------------------------------------------------------------------------
4624 \fn sme_RoamGetPMKIDCache
4625 \brief a wrapper function to request CSR to return PMKID cache from CSR
Srinivas Girigowdade697412013-02-14 16:31:48 -08004626 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 \param pNum - caller allocated memory that has the space of the number of
4628 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
4629 needed or actually number in tPmkidCacheInfo.
4630 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
4631 any, upon return
4632 \return eHalStatus - when fail, it usually means the buffer allocated is not
4633 big enough
4634 ---------------------------------------------------------------------------*/
4635eHalStatus sme_RoamGetPMKIDCache(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pNum,
4636 tPmkidCacheInfo *pPmkidCache)
4637{
4638 eHalStatus status = eHAL_STATUS_FAILURE;
4639 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4640
4641 status = sme_AcquireGlobalLock( &pMac->sme );
4642 if ( HAL_STATUS_SUCCESS( status ) )
4643 {
4644 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4645 {
4646 status = csrRoamGetPMKIDCache( pMac, sessionId, pNum, pPmkidCache );
4647 }
4648 else
4649 {
4650 status = eHAL_STATUS_INVALID_PARAMETER;
4651 }
4652 sme_ReleaseGlobalLock( &pMac->sme );
4653 }
4654
4655 return (status);
4656}
4657
4658
4659/* ---------------------------------------------------------------------------
4660 \fn sme_GetConfigParam
4661 \brief a wrapper function that HDD calls to get the global settings
4662 currently maintained by CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08004663 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 \param pParam - caller allocated memory
4665 \return eHalStatus
4666 ---------------------------------------------------------------------------*/
4667eHalStatus sme_GetConfigParam(tHalHandle hHal, tSmeConfigParams *pParam)
4668{
4669 eHalStatus status = eHAL_STATUS_FAILURE;
4670 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4671
Katya Nigambcb705f2013-12-26 14:26:22 +05304672 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004673 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 status = sme_AcquireGlobalLock( &pMac->sme );
4675 if ( HAL_STATUS_SUCCESS( status ) )
4676 {
4677 status = csrGetConfigParam(pMac, &pParam->csrConfig);
4678 if (status != eHAL_STATUS_SUCCESS)
4679 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004680 smsLog( pMac, LOGE, "%s csrGetConfigParam failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 sme_ReleaseGlobalLock( &pMac->sme );
4682 return status;
4683 }
4684#if defined WLAN_FEATURE_P2P_INTERNAL
4685 status = p2pGetConfigParam(pMac, &pParam->p2pConfig);
4686 if (status != eHAL_STATUS_SUCCESS)
4687 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004688 smsLog( pMac, LOGE, "%s p2pGetConfigParam failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 sme_ReleaseGlobalLock( &pMac->sme );
4690 return status;
4691 }
4692#endif
Chandrasekaran, Manishekareebd1642015-03-16 10:35:03 +05304693 pParam->fBtcEnableIndTimerVal = pMac->fBtcEnableIndTimerVal;
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 sme_ReleaseGlobalLock( &pMac->sme );
4695 }
4696
4697 return (status);
4698}
4699
4700/* ---------------------------------------------------------------------------
4701 \fn sme_CfgSetInt
4702 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08004703 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 \param cfgId - Configuration Parameter ID (type) for STA.
4705 \param ccmValue - The information related to Configuration Parameter ID
4706 which needs to be saved in CFG
4707 \param callback - To be registered by CSR with CCM. Once the CFG done with
4708 saving the information in the database, it notifies CCM &
4709 then the callback will be invoked to notify.
4710 \param toBeSaved - To save the request for future reference
4711 \return eHalStatus
4712 ---------------------------------------------------------------------------*/
4713eHalStatus sme_CfgSetInt(tHalHandle hHal, tANI_U32 cfgId, tANI_U32 ccmValue,
4714 tCcmCfgSetCallback callback, eAniBoolean toBeSaved)
4715{
4716 return(ccmCfgSetInt(hHal, cfgId, ccmValue, callback, toBeSaved));
4717}
4718
4719/* ---------------------------------------------------------------------------
4720 \fn sme_CfgSetStr
4721 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08004722 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 \param cfgId - Configuration Parameter ID (type) for STA.
4724 \param pStr - Pointer to the byte array which carries the information needs
4725 to be saved in CFG
4726 \param length - Length of the data to be saved
4727 \param callback - To be registered by CSR with CCM. Once the CFG done with
4728 saving the information in the database, it notifies CCM &
4729 then the callback will be invoked to notify.
4730 \param toBeSaved - To save the request for future reference
4731 \return eHalStatus
4732 ---------------------------------------------------------------------------*/
4733eHalStatus sme_CfgSetStr(tHalHandle hHal, tANI_U32 cfgId, tANI_U8 *pStr,
4734 tANI_U32 length, tCcmCfgSetCallback callback,
4735 eAniBoolean toBeSaved)
4736{
4737 return(ccmCfgSetStr(hHal, cfgId, pStr, length, callback, toBeSaved));
4738}
4739
4740/* ---------------------------------------------------------------------------
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05304741 \fn sme_GetModifyProfileFields
4742 \brief HDD or SME - QOS calls this function to get the current values of
4743 connected profile fields, changing which can cause reassoc.
4744 This function must be called after CFG is downloaded and STA is in connected
4745 state. Also, make sure to call this function to get the current profile
4746 fields before calling the reassoc. So that pModifyProfileFields will have
4747 all the latest values plus the one(s) has been updated as part of reassoc
4748 request.
4749 \param pModifyProfileFields - pointer to the connected profile fields
4750 changing which can cause reassoc
4751
4752 \return eHalStatus
4753 -------------------------------------------------------------------------------*/
4754eHalStatus sme_GetModifyProfileFields(tHalHandle hHal, tANI_U8 sessionId,
4755 tCsrRoamModifyProfileFields * pModifyProfileFields)
4756{
4757 eHalStatus status = eHAL_STATUS_FAILURE;
4758 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4759
4760 MTRACE(vos_trace(VOS_MODULE_ID_SME,
4761 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId, 0));
4762 status = sme_AcquireGlobalLock( &pMac->sme );
4763 if ( HAL_STATUS_SUCCESS( status ) )
4764 {
4765 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4766 {
4767 status = csrGetModifyProfileFields(pMac, sessionId, pModifyProfileFields);
4768 }
4769 else
4770 {
4771 status = eHAL_STATUS_INVALID_PARAMETER;
4772 }
4773 sme_ReleaseGlobalLock( &pMac->sme );
4774 }
4775
4776 return (status);
4777}
4778
4779/* ---------------------------------------------------------------------------
Sandeep Puligilla332ea912014-02-04 00:16:24 +05304780 \fn sme_HT40StopOBSSScan
4781 \brief HDD or SME - Command to stop the OBSS scan
4782 THis is implemented only for debugging purpose.
4783 As per spec while operating in 2.4GHz OBSS scan shouldnt be stopped.
4784 \param sessionId - sessionId
4785 changing which can cause reassoc
4786
4787 \return eHalStatus
4788 -------------------------------------------------------------------------------*/
4789eHalStatus sme_HT40StopOBSSScan(tHalHandle hHal, tANI_U8 sessionId)
4790{
4791 eHalStatus status = eHAL_STATUS_FAILURE;
4792 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4793
4794 smsLog(pMac, LOG2, FL("enter"));
4795 status = sme_AcquireGlobalLock( &pMac->sme );
4796 if ( HAL_STATUS_SUCCESS( status ) )
4797 {
4798 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4799 {
4800 csrHT40StopOBSSScan( pMac, sessionId );
4801 }
4802 else
4803 {
4804 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4805 "%s: Invalid session sessionId %d", __func__,sessionId);
4806 status = eHAL_STATUS_INVALID_PARAMETER;
4807 }
4808 sme_ReleaseGlobalLock( &pMac->sme );
4809 }
4810 return (status);
4811}
4812
Jeff Johnson295189b2012-06-20 16:38:30 -07004813/*--------------------------------------------------------------------------
4814 \fn sme_SetConfigPowerSave
4815 \brief Wrapper fn to change power save configuration in SME (PMC) module.
4816 For BMPS related configuration, this function also updates the CFG
4817 and sends a message to FW to pick up the new values. Note: Calling
4818 this function only updates the configuration and does not enable
4819 the specified power save mode.
4820 \param hHal - The handle returned by macOpen.
4821 \param psMode - Power Saving mode being modified
4822 \param pConfigParams - a pointer to a caller allocated object of type
4823 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
4824 \return eHalStatus
4825 --------------------------------------------------------------------------*/
4826eHalStatus sme_SetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
4827 void *pConfigParams)
4828{
4829 eHalStatus status = eHAL_STATUS_FAILURE;
4830 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4831
Katya Nigambcb705f2013-12-26 14:26:22 +05304832 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004833 TRACE_CODE_SME_RX_HDD_SET_CONFIG_PWRSAVE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 if (NULL == pConfigParams ) {
4835 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
4836 "nothing to update");
4837 return eHAL_STATUS_FAILURE;
4838 }
4839
4840 status = sme_AcquireGlobalLock( &pMac->sme );
4841 if ( HAL_STATUS_SUCCESS( status ) )
4842 {
4843 status = pmcSetConfigPowerSave(hHal, psMode, pConfigParams);
4844 sme_ReleaseGlobalLock( &pMac->sme );
4845 }
4846
4847 return (status);
4848}
4849
4850/*--------------------------------------------------------------------------
4851 \fn sme_GetConfigPowerSave
4852 \brief Wrapper fn to retrieve power save configuration in SME (PMC) module
4853 \param hHal - The handle returned by macOpen.
4854 \param psMode - Power Saving mode
4855 \param pConfigParams - a pointer to a caller allocated object of type
4856 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
4857 \return eHalStatus
4858 --------------------------------------------------------------------------*/
4859eHalStatus sme_GetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
4860 void *pConfigParams)
4861{
4862 eHalStatus status = eHAL_STATUS_FAILURE;
4863 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4864
Katya Nigambcb705f2013-12-26 14:26:22 +05304865 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004866 TRACE_CODE_SME_RX_HDD_GET_CONFIG_PWRSAVE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 if (NULL == pConfigParams ) {
4868 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
4869 "nothing to update");
4870 return eHAL_STATUS_FAILURE;
4871 }
4872
4873 status = sme_AcquireGlobalLock( &pMac->sme );
4874 if ( HAL_STATUS_SUCCESS( status ) )
4875 {
4876 status = pmcGetConfigPowerSave(hHal, psMode, pConfigParams);
4877 sme_ReleaseGlobalLock( &pMac->sme );
4878 }
4879
4880 return (status);
4881}
4882
4883/* ---------------------------------------------------------------------------
4884 \fn sme_SignalPowerEvent
4885 \brief Signals to PMC that a power event has occurred. Used for putting
4886 the chip into deep sleep mode.
4887 \param hHal - The handle returned by macOpen.
4888 \param event - the event that has occurred
4889 \return eHalStatus
4890 ---------------------------------------------------------------------------*/
4891eHalStatus sme_SignalPowerEvent (tHalHandle hHal, tPmcPowerEvent event)
4892{
4893 eHalStatus status = eHAL_STATUS_FAILURE;
4894 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4895
4896 status = sme_AcquireGlobalLock( &pMac->sme );
4897 if ( HAL_STATUS_SUCCESS( status ) )
4898 {
4899 status = pmcSignalPowerEvent(hHal, event);
4900 sme_ReleaseGlobalLock( &pMac->sme );
4901 }
4902
4903 return (status);
4904}
4905
4906/* ---------------------------------------------------------------------------
4907 \fn sme_EnablePowerSave
4908 \brief Enables one of the power saving modes.
4909 \param hHal - The handle returned by macOpen.
4910 \param psMode - The power saving mode to enable. If BMPS mode is enabled
4911 while the chip is operating in Full Power, PMC will start
4912 a timer that will try to put the chip in BMPS mode after
4913 expiry.
4914 \return eHalStatus
4915 ---------------------------------------------------------------------------*/
4916eHalStatus sme_EnablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
4917{
4918 eHalStatus status = eHAL_STATUS_FAILURE;
4919 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4920
Katya Nigambcb705f2013-12-26 14:26:22 +05304921 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004922 TRACE_CODE_SME_RX_HDD_ENABLE_PWRSAVE, NO_SESSION, psMode));
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 status = sme_AcquireGlobalLock( &pMac->sme );
4924 if ( HAL_STATUS_SUCCESS( status ) )
4925 {
4926 status = pmcEnablePowerSave(hHal, psMode);
4927 sme_ReleaseGlobalLock( &pMac->sme );
4928 }
4929
4930 return (status);
4931}
4932
4933/* ---------------------------------------------------------------------------
4934 \fn sme_DisablePowerSave
4935 \brief Disables one of the power saving modes.
4936 \param hHal - The handle returned by macOpen.
4937 \param psMode - The power saving mode to disable. Disabling does not imply
4938 that device will be brought out of the current PS mode. This
4939 is purely a configuration API.
4940 \return eHalStatus
4941 ---------------------------------------------------------------------------*/
4942eHalStatus sme_DisablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
4943{
4944 eHalStatus status = eHAL_STATUS_FAILURE;
4945 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4946
Katya Nigambcb705f2013-12-26 14:26:22 +05304947 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004948 TRACE_CODE_SME_RX_HDD_DISABLE_PWRSAVE, NO_SESSION, psMode));
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 status = sme_AcquireGlobalLock( &pMac->sme );
4950 if ( HAL_STATUS_SUCCESS( status ) )
4951 {
4952 status = pmcDisablePowerSave(hHal, psMode);
4953 sme_ReleaseGlobalLock( &pMac->sme );
4954 }
4955
4956 return (status);
4957 }
4958
4959/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +05304960+ \fn sme_SetHostPowerSave
4961+ \brief Enables BMPS logic to be controlled by User level apps
4962+ \param hHal - The handle returned by macOpen.
4963+ \param psMode - The power saving mode to disable. Disabling does not imply
4964+ that device will be brought out of the current PS mode. This
4965+ is purely a configuration API.
4966+ \return eHalStatus
4967+ ---------------------------------------------------------------------------*/
4968eHalStatus sme_SetHostPowerSave (tHalHandle hHal, v_BOOL_t psMode)
4969{
4970 eHalStatus status = eHAL_STATUS_FAILURE;
4971 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4972
4973 pMac->pmc.isHostPsEn = psMode;
4974
4975 return (status);
4976}
4977
4978/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 \fn sme_StartAutoBmpsTimer
4980 \brief Starts a timer that periodically polls all the registered
4981 module for entry into Bmps mode. This timer is started only if BMPS is
4982 enabled and whenever the device is in full power.
4983 \param hHal - The handle returned by macOpen.
4984 \return eHalStatus
4985 ---------------------------------------------------------------------------*/
4986eHalStatus sme_StartAutoBmpsTimer ( tHalHandle hHal)
4987{
4988 eHalStatus status = eHAL_STATUS_FAILURE;
4989 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4990
Katya Nigambcb705f2013-12-26 14:26:22 +05304991 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004992 TRACE_CODE_SME_RX_HDD_START_AUTO_BMPSTIMER, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 status = sme_AcquireGlobalLock( &pMac->sme );
4994 if ( HAL_STATUS_SUCCESS( status ) )
4995 {
4996 status = pmcStartAutoBmpsTimer(hHal);
4997 sme_ReleaseGlobalLock( &pMac->sme );
4998 }
4999
5000 return (status);
5001}
5002/* ---------------------------------------------------------------------------
5003 \fn sme_StopAutoBmpsTimer
5004 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
5005 Stopping the timer does not cause a device state change. Only the timer
5006 is stopped. If "Full Power" is desired, use the sme_RequestFullPower API
5007 \param hHal - The handle returned by macOpen.
5008 \return eHalStatus
5009 ---------------------------------------------------------------------------*/
5010eHalStatus sme_StopAutoBmpsTimer ( tHalHandle hHal)
5011{
5012 eHalStatus status = eHAL_STATUS_FAILURE;
5013 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5014
Katya Nigambcb705f2013-12-26 14:26:22 +05305015 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005016 TRACE_CODE_SME_RX_HDD_STOP_AUTO_BMPSTIMER, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 status = sme_AcquireGlobalLock( &pMac->sme );
5018 if ( HAL_STATUS_SUCCESS( status ) )
5019 {
5020 status = pmcStopAutoBmpsTimer(hHal);
5021 sme_ReleaseGlobalLock( &pMac->sme );
5022 }
5023
5024 return (status);
5025}
5026/* ---------------------------------------------------------------------------
5027 \fn sme_QueryPowerState
5028 \brief Returns the current power state of the device.
5029 \param hHal - The handle returned by macOpen.
5030 \param pPowerState - pointer to location to return power state (LOW or HIGH)
5031 \param pSwWlanSwitchState - ptr to location to return SW WLAN Switch state
5032 \return eHalStatus
5033 ---------------------------------------------------------------------------*/
5034eHalStatus sme_QueryPowerState (
5035 tHalHandle hHal,
5036 tPmcPowerState *pPowerState,
5037 tPmcSwitchState *pSwWlanSwitchState)
5038{
5039 eHalStatus status = eHAL_STATUS_FAILURE;
5040 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5041
5042 status = sme_AcquireGlobalLock( &pMac->sme );
5043 if ( HAL_STATUS_SUCCESS( status ) )
5044 {
5045 status = pmcQueryPowerState (hHal, pPowerState, NULL, pSwWlanSwitchState);
5046 sme_ReleaseGlobalLock( &pMac->sme );
5047 }
5048
5049 return (status);
5050}
5051
5052/* ---------------------------------------------------------------------------
5053 \fn sme_IsPowerSaveEnabled
5054 \brief Checks if the device is able to enter a particular power save mode
5055 This does not imply that the device is in a particular PS mode
5056 \param hHal - The handle returned by macOpen.
5057 \param psMode - the power saving mode
5058 \return eHalStatus
5059 ---------------------------------------------------------------------------*/
5060tANI_BOOLEAN sme_IsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
5061{
5062 eHalStatus status = eHAL_STATUS_FAILURE;
5063 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5064 tANI_BOOLEAN result = false;
5065
Katya Nigambcb705f2013-12-26 14:26:22 +05305066 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005067 TRACE_CODE_SME_RX_HDD_IS_PWRSAVE_ENABLED, NO_SESSION, psMode));
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 status = sme_AcquireGlobalLock( &pMac->sme );
5069 if ( HAL_STATUS_SUCCESS( status ) )
5070 {
5071 result = pmcIsPowerSaveEnabled(hHal, psMode);
5072 sme_ReleaseGlobalLock( &pMac->sme );
5073 return result;
5074 }
5075
5076 return false;
5077}
5078
5079/* ---------------------------------------------------------------------------
5080 \fn sme_RequestFullPower
5081 \brief Request that the device be brought to full power state. When the
5082 device enters Full Power PMC will start a BMPS timer if BMPS PS mode
5083 is enabled. On timer expiry PMC will attempt to put the device in
5084 BMPS mode if following holds true:
5085 - BMPS mode is enabled
5086 - Polling of all modules through the Power Save Check routine passes
5087 - STA is associated to an access point
5088 \param hHal - The handle returned by macOpen.
5089 \param - callbackRoutine Callback routine invoked in case of success/failure
5090 \return eHalStatus - status
5091 eHAL_STATUS_SUCCESS - device brought to full power state
5092 eHAL_STATUS_FAILURE - device cannot be brought to full power state
5093 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
5094 ---------------------------------------------------------------------------*/
5095eHalStatus sme_RequestFullPower (
5096 tHalHandle hHal,
5097 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
5098 void *callbackContext,
5099 tRequestFullPowerReason fullPowerReason)
5100{
5101 eHalStatus status = eHAL_STATUS_FAILURE;
5102 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5103
Katya Nigambcb705f2013-12-26 14:26:22 +05305104 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005105 TRACE_CODE_SME_RX_HDD_REQUEST_FULLPOWER, NO_SESSION, fullPowerReason));
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 status = sme_AcquireGlobalLock( &pMac->sme );
5107 if ( HAL_STATUS_SUCCESS( status ) )
5108 {
5109 status = pmcRequestFullPower(hHal, callbackRoutine, callbackContext, fullPowerReason);
5110 sme_ReleaseGlobalLock( &pMac->sme );
5111 }
5112
5113 return (status);
5114}
5115
5116/* ---------------------------------------------------------------------------
5117 \fn sme_RequestBmps
5118 \brief Request that the device be put in BMPS state. Request will be
5119 accepted only if BMPS mode is enabled and power save check routine
5120 passes.
5121 \param hHal - The handle returned by macOpen.
5122 \param - callbackRoutine Callback routine invoked in case of success/failure
5123 \return eHalStatus
5124 eHAL_STATUS_SUCCESS - device is in BMPS state
5125 eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
5126 eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state
5127 ---------------------------------------------------------------------------*/
5128eHalStatus sme_RequestBmps (
5129 tHalHandle hHal,
5130 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
5131 void *callbackContext)
5132{
5133 eHalStatus status = eHAL_STATUS_FAILURE;
5134 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5135
Katya Nigambcb705f2013-12-26 14:26:22 +05305136 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005137 TRACE_CODE_SME_RX_HDD_REQUEST_BMPS, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 status = sme_AcquireGlobalLock( &pMac->sme );
5139 if ( HAL_STATUS_SUCCESS( status ) )
5140 {
5141 status = pmcRequestBmps(hHal, callbackRoutine, callbackContext);
5142 sme_ReleaseGlobalLock( &pMac->sme );
5143 }
5144
5145 return (status);
5146}
5147
5148
5149/* ---------------------------------------------------------------------------
5150 \fn sme_SetDHCPTillPowerActiveFlag
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07005151 \brief Sets/Clears DHCP related flag in PMC to disable/enable auto BMPS
5152 entry by PMC
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 \param hHal - The handle returned by macOpen.
5154 ---------------------------------------------------------------------------*/
5155void sme_SetDHCPTillPowerActiveFlag(tHalHandle hHal, tANI_U8 flag)
5156{
5157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5158
Katya Nigambcb705f2013-12-26 14:26:22 +05305159 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005160 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION, flag));
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 // Set/Clear the DHCP flag which will disable/enable auto BMPS entery by PMC
5162 pMac->pmc.remainInPowerActiveTillDHCP = flag;
5163}
5164
5165
5166/* ---------------------------------------------------------------------------
5167 \fn sme_StartUapsd
5168 \brief Request that the device be put in UAPSD state. If the device is in
5169 Full Power it will be put in BMPS mode first and then into UAPSD
5170 mode.
5171 \param hHal - The handle returned by macOpen.
5172 \param - callbackRoutine Callback routine invoked in case of success/failure
5173 eHAL_STATUS_SUCCESS - device is in UAPSD state
5174 eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
5175 eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
5176 eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
5177 \return eHalStatus
5178 ---------------------------------------------------------------------------*/
5179eHalStatus sme_StartUapsd (
5180 tHalHandle hHal,
5181 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
5182 void *callbackContext)
5183{
5184 eHalStatus status = eHAL_STATUS_FAILURE;
5185 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5186
5187 status = sme_AcquireGlobalLock( &pMac->sme );
5188 if ( HAL_STATUS_SUCCESS( status ) )
5189 {
5190 status = pmcStartUapsd(hHal, callbackRoutine, callbackContext);
5191 sme_ReleaseGlobalLock( &pMac->sme );
5192 }
5193
5194 return (status);
5195 }
5196
5197/* ---------------------------------------------------------------------------
5198 \fn sme_StopUapsd
5199 \brief Request that the device be put out of UAPSD state. Device will be
5200 put in in BMPS state after stop UAPSD completes.
5201 \param hHal - The handle returned by macOpen.
5202 \return eHalStatus
5203 eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
5204 eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
5205 ---------------------------------------------------------------------------*/
5206eHalStatus sme_StopUapsd (tHalHandle hHal)
5207{
5208 eHalStatus status = eHAL_STATUS_FAILURE;
5209 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5210
5211 status = sme_AcquireGlobalLock( &pMac->sme );
5212 if ( HAL_STATUS_SUCCESS( status ) )
5213 {
5214 status = pmcStopUapsd(hHal);
5215 sme_ReleaseGlobalLock( &pMac->sme );
5216 }
5217
5218 return (status);
5219}
5220
5221/* ---------------------------------------------------------------------------
5222 \fn sme_RequestStandby
5223 \brief Request that the device be put in standby. It is HDD's responsibility
5224 to bring the chip to full power and do a disassoc before calling
5225 this API.
5226 \param hHal - The handle returned by macOpen.
5227 \param - callbackRoutine Callback routine invoked in case of success/failure
5228 \return eHalStatus
5229 eHAL_STATUS_SUCCESS - device is in Standby mode
5230 eHAL_STATUS_FAILURE - device cannot be put in standby mode
5231 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
5232 ---------------------------------------------------------------------------*/
5233eHalStatus sme_RequestStandby (
5234 tHalHandle hHal,
5235 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
5236 void *callbackContext)
5237{
5238 eHalStatus status = eHAL_STATUS_FAILURE;
5239 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5240
Katya Nigambcb705f2013-12-26 14:26:22 +05305241 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005242 TRACE_CODE_SME_RX_HDD_REQUEST_STANDBY, NO_SESSION, 0));
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305243 smsLog( pMac, LOG1, FL(" called") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 status = sme_AcquireGlobalLock( &pMac->sme );
5245 if ( HAL_STATUS_SUCCESS( status ) )
5246 {
5247 status = pmcRequestStandby(hHal, callbackRoutine, callbackContext);
5248 sme_ReleaseGlobalLock( &pMac->sme );
5249 }
5250
5251 return (status);
5252}
5253
5254/* ---------------------------------------------------------------------------
5255 \fn sme_RegisterPowerSaveCheck
5256 \brief Register a power save check routine that is called whenever
5257 the device is about to enter one of the power save modes.
5258 \param hHal - The handle returned by macOpen.
5259 \param checkRoutine - Power save check routine to be registered
5260 \return eHalStatus
5261 eHAL_STATUS_SUCCESS - successfully registered
5262 eHAL_STATUS_FAILURE - not successfully registered
5263 ---------------------------------------------------------------------------*/
5264eHalStatus sme_RegisterPowerSaveCheck (
5265 tHalHandle hHal,
5266 tANI_BOOLEAN (*checkRoutine) (void *checkContext), void *checkContext)
5267{
5268 eHalStatus status = eHAL_STATUS_FAILURE;
5269 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5270
5271 status = sme_AcquireGlobalLock( &pMac->sme );
5272 if ( HAL_STATUS_SUCCESS( status ) )
5273 {
5274 status = pmcRegisterPowerSaveCheck (hHal, checkRoutine, checkContext);
5275 sme_ReleaseGlobalLock( &pMac->sme );
5276 }
5277
5278 return (status);
5279}
5280
5281/* ---------------------------------------------------------------------------
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05305282 \fn sme_Register11dScanDoneCallback
5283 \brief Register a routine of type csrScanCompleteCallback which is
5284 called whenever an 11d scan is done
5285 \param hHal - The handle returned by macOpen.
5286 \param callback - 11d scan complete routine to be registered
5287 \return eHalStatus
5288 ---------------------------------------------------------------------------*/
5289eHalStatus sme_Register11dScanDoneCallback (
5290 tHalHandle hHal,
5291 csrScanCompleteCallback callback)
5292{
5293 eHalStatus status = eHAL_STATUS_SUCCESS;
5294 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5295
5296 pMac->scan.callback11dScanDone = callback;
5297
5298 return (status);
5299}
5300
5301/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 \fn sme_DeregisterPowerSaveCheck
5303 \brief Deregister a power save check routine
5304 \param hHal - The handle returned by macOpen.
5305 \param checkRoutine - Power save check routine to be deregistered
5306 \return eHalStatus
5307 eHAL_STATUS_SUCCESS - successfully deregistered
5308 eHAL_STATUS_FAILURE - not successfully deregistered
5309 ---------------------------------------------------------------------------*/
5310eHalStatus sme_DeregisterPowerSaveCheck (
5311 tHalHandle hHal,
5312 tANI_BOOLEAN (*checkRoutine) (void *checkContext))
5313{
5314 eHalStatus status = eHAL_STATUS_FAILURE;
5315 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5316
5317 status = sme_AcquireGlobalLock( &pMac->sme );
5318 if ( HAL_STATUS_SUCCESS( status ) )
5319 {
5320 status = pmcDeregisterPowerSaveCheck (hHal, checkRoutine);
5321 sme_ReleaseGlobalLock( &pMac->sme );
5322 }
5323
5324 return (status);
5325}
5326
5327/* ---------------------------------------------------------------------------
5328 \fn sme_RegisterDeviceStateUpdateInd
5329 \brief Register a callback routine that is called whenever
5330 the device enters a new device state (Full Power, BMPS, UAPSD)
5331 \param hHal - The handle returned by macOpen.
5332 \param callbackRoutine - Callback routine to be registered
5333 \param callbackContext - Cookie to be passed back during callback
5334 \return eHalStatus
5335 eHAL_STATUS_SUCCESS - successfully registered
5336 eHAL_STATUS_FAILURE - not successfully registered
5337 ---------------------------------------------------------------------------*/
5338eHalStatus sme_RegisterDeviceStateUpdateInd (
5339 tHalHandle hHal,
5340 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
5341 void *callbackContext)
5342{
5343 eHalStatus status = eHAL_STATUS_FAILURE;
5344 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5345
5346 status = sme_AcquireGlobalLock( &pMac->sme );
5347 if ( HAL_STATUS_SUCCESS( status ) )
5348 {
5349 status = pmcRegisterDeviceStateUpdateInd (hHal, callbackRoutine, callbackContext);
5350 sme_ReleaseGlobalLock( &pMac->sme );
5351 }
5352
5353 return (status);
5354}
5355
5356/* ---------------------------------------------------------------------------
5357 \fn sme_DeregisterDeviceStateUpdateInd
5358 \brief Deregister a routine that was registered for device state changes
5359 \param hHal - The handle returned by macOpen.
5360 \param callbackRoutine - Callback routine to be deregistered
5361 \return eHalStatus
5362 eHAL_STATUS_SUCCESS - successfully deregistered
5363 eHAL_STATUS_FAILURE - not successfully deregistered
5364 ---------------------------------------------------------------------------*/
5365eHalStatus sme_DeregisterDeviceStateUpdateInd (
5366 tHalHandle hHal,
5367 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
5368{
5369 eHalStatus status = eHAL_STATUS_FAILURE;
5370 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5371
5372 status = sme_AcquireGlobalLock( &pMac->sme );
5373 if ( HAL_STATUS_SUCCESS( status ) )
5374 {
5375 status = pmcDeregisterDeviceStateUpdateInd (hHal, callbackRoutine);
5376 sme_ReleaseGlobalLock( &pMac->sme );
5377 }
5378
5379 return (status);
5380}
5381
5382/* ---------------------------------------------------------------------------
5383 \fn sme_WowlAddBcastPattern
5384 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
5385 do a pattern match on these patterns when Wowl is enabled during BMPS
5386 mode. Note that Firmware performs the pattern matching only on
5387 broadcast frames and while Libra is in BMPS mode.
5388 \param hHal - The handle returned by macOpen.
5389 \param pattern - Pattern to be added
5390 \return eHalStatus
5391 eHAL_STATUS_FAILURE Cannot add pattern
5392 eHAL_STATUS_SUCCESS Request accepted.
5393 ---------------------------------------------------------------------------*/
5394eHalStatus sme_WowlAddBcastPattern (
5395 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005396 tpSirWowlAddBcastPtrn pattern,
5397 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005398{
5399 eHalStatus status = eHAL_STATUS_FAILURE;
5400 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05305401 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005402 TRACE_CODE_SME_RX_HDD_WOWL_ADDBCAST_PATTERN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 status = sme_AcquireGlobalLock( &pMac->sme );
5404 if ( HAL_STATUS_SUCCESS( status ) )
5405 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005406 status = pmcWowlAddBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005407 sme_ReleaseGlobalLock( &pMac->sme );
5408 }
5409
5410 return (status);
5411}
5412
5413/* ---------------------------------------------------------------------------
5414 \fn sme_WowlDelBcastPattern
5415 \brief Delete a pattern that was added for Pattern Byte Matching.
5416 \param hHal - The handle returned by macOpen.
5417 \param pattern - Pattern to be deleted
5418 \return eHalStatus
5419 eHAL_STATUS_FAILURE Cannot delete pattern
5420 eHAL_STATUS_SUCCESS Request accepted.
5421 ---------------------------------------------------------------------------*/
5422eHalStatus sme_WowlDelBcastPattern (
5423 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005424 tpSirWowlDelBcastPtrn pattern,
5425 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005426{
5427 eHalStatus status = eHAL_STATUS_FAILURE;
5428 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05305429 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005430 TRACE_CODE_SME_RX_HDD_WOWL_DELBCAST_PATTERN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 status = sme_AcquireGlobalLock( &pMac->sme );
5432 if ( HAL_STATUS_SUCCESS( status ) )
5433 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005434 status = pmcWowlDelBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 sme_ReleaseGlobalLock( &pMac->sme );
5436 }
5437
5438 return (status);
5439}
5440
5441/* ---------------------------------------------------------------------------
5442 \fn sme_EnterWowl
5443 \brief This is the SME API exposed to HDD to request enabling of WOWL mode.
5444 WoWLAN works on top of BMPS mode. If the device is not in BMPS mode,
5445 SME will will cache the information that WOWL has been enabled and
5446 attempt to put the device in BMPS. On entry into BMPS, SME will
5447 enable the WOWL mode.
5448 Note 1: If we exit BMPS mode (someone requests full power), we
5449 will NOT resume WOWL when we go back to BMPS again. Request for full
5450 power (while in WOWL mode) means disable WOWL and go to full power.
5451 Note 2: Both UAPSD and WOWL work on top of BMPS. On entry into BMPS, SME
5452 will give priority to UAPSD and enable only UAPSD if both UAPSD and WOWL
5453 are required. Currently there is no requirement or use case to support
5454 UAPSD and WOWL at the same time.
5455
5456 \param hHal - The handle returned by macOpen.
5457 \param enterWowlCallbackRoutine - Callback routine provided by HDD.
5458 Used for success/failure notification by SME
5459 \param enterWowlCallbackContext - A cookie passed by HDD, that is passed back to HDD
5460 at the time of callback.
5461 \param wakeReasonIndCB - Callback routine provided by HDD.
5462 Used for Wake Reason Indication by SME
5463 \param wakeReasonIndCBContext - A cookie passed by HDD, that is passed back to HDD
5464 at the time of callback.
5465 \return eHalStatus
5466 eHAL_STATUS_SUCCESS Device is already in WoWLAN mode
5467 eHAL_STATUS_FAILURE Device cannot enter WoWLAN mode.
5468 eHAL_STATUS_PMC_PENDING Request accepted. SME will enable WOWL after
5469 BMPS mode is entered.
5470 ---------------------------------------------------------------------------*/
5471eHalStatus sme_EnterWowl (
5472 tHalHandle hHal,
5473 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
5474 void *enterWowlCallbackContext,
5475#ifdef WLAN_WAKEUP_EVENTS
5476 void (*wakeIndicationCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
5477 void *wakeIndicationCBContext,
5478#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005479 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005480{
5481 eHalStatus status = eHAL_STATUS_FAILURE;
5482 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05305483 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005484 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 status = sme_AcquireGlobalLock( &pMac->sme );
5486 if ( HAL_STATUS_SUCCESS( status ) )
5487 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07005488 status = pmcEnterWowl (hHal, enterWowlCallbackRoutine, enterWowlCallbackContext,
Jeff Johnson295189b2012-06-20 16:38:30 -07005489#ifdef WLAN_WAKEUP_EVENTS
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07005490 wakeIndicationCB, wakeIndicationCBContext,
Jeff Johnson295189b2012-06-20 16:38:30 -07005491#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005492 wowlEnterParams, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 sme_ReleaseGlobalLock( &pMac->sme );
5494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 return (status);
5496}
5497/* ---------------------------------------------------------------------------
5498 \fn sme_ExitWowl
5499 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
5500 SME will initiate exit from WoWLAN mode and device will be put in BMPS
5501 mode.
5502 \param hHal - The handle returned by macOpen.
5503 \return eHalStatus
5504 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
5505 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
5506 ---------------------------------------------------------------------------*/
c_hpothu01484c02014-05-16 14:05:15 +05305507eHalStatus sme_ExitWowl (tHalHandle hHal, tWowlExitSource wowlExitSrc)
Jeff Johnson295189b2012-06-20 16:38:30 -07005508{
5509 eHalStatus status = eHAL_STATUS_FAILURE;
5510 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05305511 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005512 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 status = sme_AcquireGlobalLock( &pMac->sme );
5514 if ( HAL_STATUS_SUCCESS( status ) )
5515 {
c_hpothu01484c02014-05-16 14:05:15 +05305516 status = pmcExitWowl (hHal, wowlExitSrc);
Jeff Johnson295189b2012-06-20 16:38:30 -07005517 sme_ReleaseGlobalLock( &pMac->sme );
5518 }
5519
5520 return (status);
5521}
5522
5523/* ---------------------------------------------------------------------------
5524
5525 \fn sme_RoamSetKey
5526
5527 \brief To set encryption key. This function should be called only when connected
5528 This is an asynchronous API.
5529
5530 \param pSetKeyInfo - pointer to a caller allocated object of tCsrSetContextInfo
5531
5532 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
5533
5534 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
5535
5536 FAILURE or RESOURCES The API finished and failed.
5537
5538 -------------------------------------------------------------------------------*/
5539eHalStatus sme_RoamSetKey(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 *pRoamId)
5540{
5541 eHalStatus status = eHAL_STATUS_FAILURE;
5542 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5543 tANI_U32 roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 tANI_U32 i;
5545 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005546
Katya Nigambcb705f2013-12-26 14:26:22 +05305547 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005548 TRACE_CODE_SME_RX_HDD_SET_KEY, sessionId, 0));
Jeff Johnsonf89f4b52013-03-27 10:32:44 -07005549 if (pSetKey->keyLength > CSR_MAX_KEY_LEN)
5550 {
5551 smsLog(pMac, LOGE, FL("Invalid key length %d"), pSetKey->keyLength);
5552 return eHAL_STATUS_FAILURE;
5553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 status = sme_AcquireGlobalLock( &pMac->sme );
5555 if ( HAL_STATUS_SUCCESS( status ) )
5556 {
5557 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5558 if(pRoamId)
5559 {
5560 *pRoamId = roamId;
5561 }
5562
Jeff Johnsonf89f4b52013-03-27 10:32:44 -07005563 smsLog(pMac, LOG2, FL("keyLength %d"), pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005564
5565 for(i=0; i<pSetKey->keyLength; i++)
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005566 smsLog(pMac, LOG2, FL("%02x"), pSetKey->Key[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005567
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005568 smsLog(pMac, LOG2, "\n sessionId=%d roamId=%d", sessionId, roamId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005569
5570 pSession = CSR_GET_SESSION(pMac, sessionId);
5571
Jeff Johnson32d95a32012-09-10 13:15:23 -07005572 if(!pSession)
5573 {
5574 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08005575 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005576 return eHAL_STATUS_FAILURE;
5577 }
5578
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
5580 {
Agrawal Ashish65ab9552017-01-05 15:29:17 +05305581#ifdef SAP_AUTH_OFFLOAD
5582 if (pMac->sap_auth_offload_sec_type)
5583 {
5584 smsLog(pMac, LOGE,
5585 FL("No set key is required in sap auth offload enable"));
5586 sme_ReleaseGlobalLock(&pMac->sme);
5587 return eHAL_STATUS_SUCCESS;
5588 }
5589#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
5591 {
5592 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
5593 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
5594 {
5595 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5596 }
5597 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
5598 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
5599 {
5600 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5601 }
5602 }
5603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005604
5605 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
5606 sme_ReleaseGlobalLock( &pMac->sme );
5607 }
Girish Gowli1c2fc802015-01-19 16:18:07 +05305608 if (pMac->roam.configParam.roamDelayStatsEnabled)
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05305609 {
Girish Gowli1c2fc802015-01-19 16:18:07 +05305610 //Store sent PTK key time
5611 if(pSetKey->keyDirection == eSIR_TX_RX)
5612 {
5613 vos_record_roam_event(e_HDD_SET_PTK_REQ, NULL, 0);
5614 }
5615 else if(pSetKey->keyDirection == eSIR_RX_ONLY)
5616 {
5617 vos_record_roam_event(e_HDD_SET_GTK_REQ, NULL, 0);
5618 }
5619 else
5620 {
5621 return (status);
5622 }
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05305623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005624
5625 return (status);
5626}
5627
5628
5629/* ---------------------------------------------------------------------------
5630
5631 \fn sme_RoamRemoveKey
5632
5633 \brief To set encryption key. This is an asynchronous API.
5634
5635 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
5636
5637 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
5638
5639 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
5640
5641 FAILURE or RESOURCES The API finished and failed.
5642
5643 -------------------------------------------------------------------------------*/
5644eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
5645 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
5646{
5647 eHalStatus status = eHAL_STATUS_FAILURE;
5648 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5649 tANI_U32 roamId;
5650
Katya Nigambcb705f2013-12-26 14:26:22 +05305651 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005652 TRACE_CODE_SME_RX_HDD_REMOVE_KEY, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 status = sme_AcquireGlobalLock( &pMac->sme );
5654 if ( HAL_STATUS_SUCCESS( status ) )
5655 {
5656 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5657 if(pRoamId)
5658 {
5659 *pRoamId = roamId;
5660 }
5661 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
5662 sme_ReleaseGlobalLock( &pMac->sme );
5663 }
5664
5665 return (status);
5666}
5667
5668/* ---------------------------------------------------------------------------
5669 \fn sme_GetRssi
5670 \brief a wrapper function that client calls to register a callback to get RSSI
5671
5672 \param callback - SME sends back the requested stats using the callback
5673 \param staId - The station ID for which the stats is requested for
5674 \param pContext - user context to be passed back along with the callback
5675 \param pVosContext - vos context
5676 \return eHalStatus
5677 ---------------------------------------------------------------------------*/
5678eHalStatus sme_GetRssi(tHalHandle hHal,
5679 tCsrRssiCallback callback,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07005680 tANI_U8 staId, tCsrBssid bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 void *pContext, void* pVosContext)
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 {
5689 status = csrGetRssi( pMac, callback,
5690 staId, bssId, pContext, pVosContext);
5691 sme_ReleaseGlobalLock( &pMac->sme );
5692 }
5693 return (status);
5694}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305695
5696/* ---------------------------------------------------------------------------
5697 \fn sme_GetSnr
5698 \brief a wrapper function that client calls to register a callback to
5699 get SNR
5700
5701 \param callback - SME sends back the requested stats using the callback
5702 \param staId - The station ID for which the stats is requested for
5703 \param pContext - user context to be passed back along with the callback
5704 \param pVosContext - vos context
5705 \return eHalStatus
5706 ---------------------------------------------------------------------------*/
5707eHalStatus sme_GetSnr(tHalHandle hHal,
5708 tCsrSnrCallback callback,
5709 tANI_U8 staId, tCsrBssid bssId,
5710 void *pContext)
5711{
5712 eHalStatus status = eHAL_STATUS_FAILURE;
5713 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5714
5715 status = sme_AcquireGlobalLock( &pMac->sme );
5716 if ( HAL_STATUS_SUCCESS( status ) )
5717 {
5718 status = csrGetSnr(pMac, callback,
5719 staId, bssId, pContext);
5720 sme_ReleaseGlobalLock( &pMac->sme );
5721 }
5722 return status;
5723}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005724#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005725/* ---------------------------------------------------------------------------
5726 \fn sme_GetRoamRssi
5727 \brief a wrapper function that client calls to register a callback to get Roam RSSI
5728
5729 \param callback - SME sends back the requested stats using the callback
5730 \param staId - The station ID for which the stats is requested for
5731 \param pContext - user context to be passed back along with the callback
5732 \param pVosContext - vos context
5733 \return eHalStatus
5734 ---------------------------------------------------------------------------*/
5735eHalStatus sme_GetRoamRssi(tHalHandle hHal,
5736 tCsrRssiCallback callback,
5737 tANI_U8 staId, tCsrBssid bssId,
5738 void *pContext, void* pVosContext)
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 = csrGetRoamRssi( pMac, callback,
5747 staId, bssId, pContext, pVosContext);
5748 sme_ReleaseGlobalLock( &pMac->sme );
5749 }
5750 return (status);
5751}
5752#endif
5753
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005754#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005755/* ---------------------------------------------------------------------------
5756 \fn sme_GetTsmStats
5757 \brief a wrapper function that client calls to register a callback to get TSM Stats
5758
5759 \param callback - SME sends back the requested stats using the callback
5760 \param staId - The station ID for which the stats is requested for
5761 \param pContext - user context to be passed back along with the callback
5762 \param pVosContext - vos context
5763 \return eHalStatus
5764 ---------------------------------------------------------------------------*/
5765eHalStatus sme_GetTsmStats(tHalHandle hHal,
5766 tCsrTsmStatsCallback callback,
5767 tANI_U8 staId, tCsrBssid bssId,
5768 void *pContext, void* pVosContext, tANI_U8 tid)
5769{
5770 eHalStatus status = eHAL_STATUS_FAILURE;
5771 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5772
5773 status = sme_AcquireGlobalLock( &pMac->sme );
5774 if ( HAL_STATUS_SUCCESS( status ) )
5775 {
5776 status = csrGetTsmStats( pMac, callback,
5777 staId, bssId, pContext, pVosContext, tid);
5778 sme_ReleaseGlobalLock( &pMac->sme );
5779 }
5780 return (status);
5781}
5782#endif
5783
5784
Jeff Johnson295189b2012-06-20 16:38:30 -07005785/* ---------------------------------------------------------------------------
5786 \fn sme_GetStatistics
5787 \brief a wrapper function that client calls to register a callback to get
5788 different PHY level statistics from CSR.
5789
5790 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
5791 \param statsMask - The different category/categories of stats requester is looking for
5792 \param callback - SME sends back the requested stats using the callback
5793 \param periodicity - If requester needs periodic update in millisec, 0 means
5794 it's an one time request
5795 \param cache - If requester is happy with cached stats
5796 \param staId - The station ID for which the stats is requested for
5797 \param pContext - user context to be passed back along with the callback
5798 \return eHalStatus
5799 ---------------------------------------------------------------------------*/
5800eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
5801 tANI_U32 statsMask,
5802 tCsrStatsCallback callback,
5803 tANI_U32 periodicity, tANI_BOOLEAN cache,
5804 tANI_U8 staId, void *pContext)
5805{
5806 eHalStatus status = eHAL_STATUS_FAILURE;
5807 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5808
Katya Nigambcb705f2013-12-26 14:26:22 +05305809 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005810 TRACE_CODE_SME_RX_HDD_GET_STATS, NO_SESSION, periodicity));
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 status = sme_AcquireGlobalLock( &pMac->sme );
5812 if ( HAL_STATUS_SUCCESS( status ) )
5813 {
5814 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
5815 periodicity, cache, staId, pContext);
5816 sme_ReleaseGlobalLock( &pMac->sme );
5817 }
5818
5819 return (status);
5820
5821}
5822
Abhishek Singh08aa7762014-12-16 13:59:03 +05305823eHalStatus sme_GetFwStats(tHalHandle hHal, tANI_U32 stats,
5824 void *pContext, tSirFWStatsCallback callback)
Abhishek Singh3ae443b2014-10-08 11:49:27 +05305825{
5826 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5827 vos_msg_t msg;
5828 tSirFWStatsGetReq *pGetFWStatsReq;
5829
5830 smsLog(pMac, LOG1, FL(" ENTER stats = %d "),stats);
5831
5832 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ))
5833 {
5834 pGetFWStatsReq = (tSirFWStatsGetReq *)vos_mem_malloc(sizeof(tSirFWStatsGetReq));
5835 if ( NULL == pGetFWStatsReq)
5836 {
5837 smsLog(pMac, LOGE, FL("Not able to allocate memory for "
5838 "WDA_FW_STATS_GET_REQ"));
5839 sme_ReleaseGlobalLock( &pMac->sme );
5840 return eHAL_STATUS_FAILURE;
5841 }
5842 pGetFWStatsReq->stats = stats;
5843 pGetFWStatsReq->callback = (tSirFWStatsCallback)callback;
Abhishek Singh08aa7762014-12-16 13:59:03 +05305844 pGetFWStatsReq->data = pContext;
Abhishek Singh3ae443b2014-10-08 11:49:27 +05305845
5846 msg.type = WDA_FW_STATS_GET_REQ;
5847 msg.reserved = 0;
5848 msg.bodyptr = pGetFWStatsReq;
5849 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_WDA, &msg))
5850 {
5851 smsLog(pMac, LOGE,
5852 FL("Not able to post WDA_FW_STATS_GET_REQ message to HAL"));
5853 vos_mem_free(pGetFWStatsReq);
5854 sme_ReleaseGlobalLock( &pMac->sme );
5855 return eHAL_STATUS_FAILURE;
5856 }
5857 sme_ReleaseGlobalLock( &pMac->sme );
5858 return eHAL_STATUS_SUCCESS;
5859 }
5860 return eHAL_STATUS_FAILURE;
5861}
5862
Jeff Johnson295189b2012-06-20 16:38:30 -07005863/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305864 \fn smeGetTLSTAState
5865 \helper function to get the TL STA State whenever the function is called.
5866
5867 \param staId - The staID to be passed to the TL
5868 to get the relevant TL STA State
5869 \return the state as tANI_U16
5870 ---------------------------------------------------------------------------*/
5871tANI_U16 smeGetTLSTAState(tHalHandle hHal, tANI_U8 staId)
5872{
5873 tANI_U16 tlSTAState = TL_INIT_STATE;
5874 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5875 eHalStatus status = eHAL_STATUS_FAILURE;
5876
5877 status = sme_AcquireGlobalLock( &pMac->sme );
5878 if ( HAL_STATUS_SUCCESS( status ) )
5879 {
5880 tlSTAState = csrGetTLSTAState( pMac, staId);
5881 sme_ReleaseGlobalLock( &pMac->sme );
5882 }
5883
5884 return tlSTAState;
5885}
5886
5887/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07005888
5889 \fn sme_GetCountryCode
5890
5891 \brief To return the current country code. If no country code is applied, default country code is
5892 used to fill the buffer.
5893 If 11d supported is turned off, an error is return and the last applied/default country code is used.
5894 This is a synchronous API.
5895
5896 \param pBuf - pointer to a caller allocated buffer for returned country code.
5897
5898 \param pbLen For input, this parameter indicates how big is the buffer.
5899 Upon return, this parameter has the number of bytes for country. If pBuf
5900 doesn't have enough space, this function returns
5901 fail status and this parameter contains the number that is needed.
5902
5903 \return eHalStatus SUCCESS.
5904
5905 FAILURE or RESOURCES The API finished and failed.
5906
5907 -------------------------------------------------------------------------------*/
5908eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
5909{
5910 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5911
Katya Nigambcb705f2013-12-26 14:26:22 +05305912 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005913 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
5914
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
5916}
5917
5918
5919/* ---------------------------------------------------------------------------
5920
5921 \fn sme_SetCountryCode
5922
5923 \brief To change the current/default country code.
5924 If 11d supported is turned off, an error is return.
5925 This is a synchronous API.
5926
5927 \param pCountry - pointer to a caller allocated buffer for the country code.
5928
5929 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
5930 whether a reset is required.
5931
5932 \return eHalStatus SUCCESS.
5933
5934 FAILURE or RESOURCES The API finished and failed.
5935
5936 -------------------------------------------------------------------------------*/
5937eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
5938{
5939 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5940
Katya Nigambcb705f2013-12-26 14:26:22 +05305941 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005942 TRACE_CODE_SME_RX_HDD_SET_CNTRYCODE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
5944}
5945
5946
5947/* ---------------------------------------------------------------------------
5948 \fn sme_ResetCountryCodeInformation
5949 \brief this function is to reset the country code current being used back to EEPROM default
5950 this includes channel list and power setting. This is a synchronous API.
5951 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
5952 a restart is needed to apply the change
5953 \return eHalStatus
5954 -------------------------------------------------------------------------------*/
5955eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
5956{
5957 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5958
5959 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
5960}
5961
5962
5963/* ---------------------------------------------------------------------------
5964 \fn sme_GetSupportedCountryCode
5965 \brief this function is to get a list of the country code current being supported
5966 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
5967 this has the country code list. 3 bytes for each country code. This may be NULL if
5968 caller wants to know the needed byte count.
5969 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
5970 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
5971 \return eHalStatus
5972 -------------------------------------------------------------------------------*/
5973eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
5974{
5975 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5976
5977 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
5978}
5979
5980
5981/* ---------------------------------------------------------------------------
5982 \fn sme_GetCurrentRegulatoryDomain
5983 \brief this function is to get the current regulatory domain. This is a synchronous API.
5984 This function must be called after CFG is downloaded and all the band/mode setting already passed into
5985 SME. The function fails if 11d support is turned off.
5986 \param pDomain - Caller allocated buffer to return the current domain.
5987 \return eHalStatus SUCCESS.
5988
5989 FAILURE or RESOURCES The API finished and failed.
5990 -------------------------------------------------------------------------------*/
5991eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
5992{
5993 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5994 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
5995
5996 if( pDomain )
5997 {
5998 if( csrIs11dSupported( pMac ) )
5999 {
6000 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
6001 status = eHAL_STATUS_SUCCESS;
6002 }
6003 else
6004 {
6005 status = eHAL_STATUS_FAILURE;
6006 }
6007 }
6008
6009 return ( status );
6010}
6011
6012
6013/* ---------------------------------------------------------------------------
6014 \fn sme_SetRegulatoryDomain
6015 \brief this function is to set the current regulatory domain.
6016 This function must be called after CFG is downloaded and all the band/mode setting already passed into
6017 SME. This is a synchronous API.
6018 \param domainId - indicate the domain (defined in the driver) needs to set to.
6019 See v_REGDOMAIN_t for definition
6020 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
6021 a restart is needed to apply the change
6022 \return eHalStatus
6023 -------------------------------------------------------------------------------*/
6024eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6025{
6026 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6027
6028 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
6029}
6030
6031
6032/* ---------------------------------------------------------------------------
6033
6034 \fn sme_GetRegulatoryDomainForCountry
6035
6036 \brief To return a regulatory domain base on a country code. This is a synchronous API.
6037
6038 \param pCountry - pointer to a caller allocated buffer for input country code.
6039
6040 \param pDomainId Upon successful return, it is the domain that country belongs to.
6041 If it is NULL, returning success means that the country code is known.
6042
6043 \return eHalStatus SUCCESS.
6044
6045 FAILURE or RESOURCES The API finished and failed.
6046
6047 -------------------------------------------------------------------------------*/
6048eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
6049{
6050 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6051
Kiet Lam6c583332013-10-14 05:37:09 +05306052 return csrGetRegulatoryDomainForCountry(pMac, pCountry, pDomainId,
6053 COUNTRY_QUERY);
Jeff Johnson295189b2012-06-20 16:38:30 -07006054}
6055
6056
6057
6058
6059/* ---------------------------------------------------------------------------
6060
6061 \fn sme_GetSupportedRegulatoryDomains
6062
6063 \brief To return a list of supported regulatory domains. This is a synchronous API.
6064
6065 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
6066
6067 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
6068 Upon return, this parameter has the number for supported domains. If pDomains
6069 doesn't have enough space for all the supported domains, this function returns
6070 fail status and this parameter contains the number that is needed.
6071
6072 \return eHalStatus SUCCESS.
6073
6074 FAILURE or RESOURCES The API finished and failed.
6075
6076 -------------------------------------------------------------------------------*/
6077eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
6078{
6079 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6080
6081 //We support all domains for now
6082 if( pNumDomains )
6083 {
6084 if( NUM_REG_DOMAINS <= *pNumDomains )
6085 {
6086 status = eHAL_STATUS_SUCCESS;
6087 }
6088 *pNumDomains = NUM_REG_DOMAINS;
6089 }
6090 if( HAL_STATUS_SUCCESS( status ) )
6091 {
6092 if( pDomains )
6093 {
6094 pDomains[0] = REGDOMAIN_FCC;
6095 pDomains[1] = REGDOMAIN_ETSI;
6096 pDomains[2] = REGDOMAIN_JAPAN;
6097 pDomains[3] = REGDOMAIN_WORLD;
6098 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
6099 pDomains[5] = REGDOMAIN_APAC;
6100 pDomains[6] = REGDOMAIN_KOREA;
6101 pDomains[7] = REGDOMAIN_HI_5GHZ;
6102 pDomains[8] = REGDOMAIN_NO_5GHZ;
6103 }
6104 else
6105 {
6106 status = eHAL_STATUS_INVALID_PARAMETER;
6107 }
6108 }
6109
6110 return ( status );
6111}
6112
6113
6114//some support functions
6115tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
6116{
6117 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6118
6119 return ( csrIs11dSupported( pMac ) );
6120}
6121
6122
6123tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
6124{
6125 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6126
6127 return ( csrIs11hSupported( pMac ) );
6128}
6129
6130
6131tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
6132{
6133 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6134
6135 return ( csrIsWmmSupported( pMac ) );
6136}
6137
6138//Upper layer to get the list of the base channels to scan for passively 11d info from csr
6139eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
6140{
6141 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6142
6143 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
6144}
6145
6146/* ---------------------------------------------------------------------------
6147
6148 \fn sme_ChangeCountryCode
6149
6150 \brief Change Country code from upperlayer during WLAN driver operation.
6151 This is a synchronous API.
6152
6153 \param hHal - The handle returned by macOpen.
6154
6155 \param pCountry New Country Code String
6156
Abhishek Singha306a442013-11-07 18:39:01 +05306157 \param sendRegHint If we want to send reg hint to nl80211
6158
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 \return eHalStatus SUCCESS.
6160
6161 FAILURE or RESOURCES The API finished and failed.
6162
6163 -------------------------------------------------------------------------------*/
6164eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
6165 tSmeChangeCountryCallback callback,
6166 tANI_U8 *pCountry,
6167 void *pContext,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05306168 void* pVosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05306169 tAniBool countryFromUserSpace,
6170 tAniBool sendRegHint )
Jeff Johnson295189b2012-06-20 16:38:30 -07006171{
6172 eHalStatus status = eHAL_STATUS_FAILURE;
6173 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6174 vos_msg_t msg;
6175 tAniChangeCountryCodeReq *pMsg;
6176
Katya Nigambcb705f2013-12-26 14:26:22 +05306177 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006178 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 status = sme_AcquireGlobalLock( &pMac->sme );
6180 if ( HAL_STATUS_SUCCESS( status ) )
6181 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006182 smsLog(pMac, LOG1, FL(" called"));
Amar Singhal97a2d992013-11-19 10:58:07 -08006183
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05306184 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true) &&
Amar Singhal97a2d992013-11-19 10:58:07 -08006185 (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
6186 {
6187
6188 smsLog(pMac, LOGW, "Set Country Code Fail since the STA is associated and userspace does not have priority ");
6189
6190 sme_ReleaseGlobalLock( &pMac->sme );
6191 status = eHAL_STATUS_FAILURE;
6192 return status;
6193 }
6194
Kiet Lam64c1b492013-07-12 13:56:44 +05306195 pMsg = vos_mem_malloc(sizeof(tAniChangeCountryCodeReq));
6196 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006198 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req");
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08006199 sme_ReleaseGlobalLock( &pMac->sme );
Kiet Lam64c1b492013-07-12 13:56:44 +05306200 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 }
6202
6203 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
6204 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
Kiet Lam64c1b492013-07-12 13:56:44 +05306205 vos_mem_copy(pMsg->countryCode, pCountry, 3);
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05306206 pMsg->countryFromUserSpace = countryFromUserSpace;
Abhishek Singha306a442013-11-07 18:39:01 +05306207 pMsg->sendRegHint = sendRegHint;
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 pMsg->changeCCCallback = callback;
6209 pMsg->pDevContext = pContext;
6210 pMsg->pVosContext = pVosContext;
6211
6212 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
6213 msg.bodyptr = pMsg;
6214 msg.reserved = 0;
6215
6216 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
6217 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006218 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +05306219 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 status = eHAL_STATUS_FAILURE;
6221 }
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006222 smsLog(pMac, LOG1, FL(" returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 sme_ReleaseGlobalLock( &pMac->sme );
6224 }
6225
6226 return (status);
6227}
Amar Singhal0d15bd52013-10-12 23:13:13 -07006228
6229/*--------------------------------------------------------------------------
6230
6231 \fn sme_GenericChangeCountryCode
6232
6233 \brief Change Country code from upperlayer during WLAN driver operation.
6234 This is a synchronous API.
6235
6236 \param hHal - The handle returned by macOpen.
6237
6238 \param pCountry New Country Code String
6239
6240 \param reg_domain regulatory domain
6241
6242 \return eHalStatus SUCCESS.
6243
6244 FAILURE or RESOURCES The API finished and failed.
6245
6246-----------------------------------------------------------------------------*/
6247eHalStatus sme_GenericChangeCountryCode( tHalHandle hHal,
6248 tANI_U8 *pCountry,
6249 v_REGDOMAIN_t reg_domain)
6250{
6251 eHalStatus status = eHAL_STATUS_FAILURE;
6252 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6253 vos_msg_t msg;
6254 tAniGenericChangeCountryCodeReq *pMsg;
6255
Kiet Lamcffc5862013-10-30 16:28:45 +05306256 if (NULL == pMac)
6257 {
6258 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
6259 "%s: pMac is null", __func__);
6260 return status;
6261 }
6262
Amar Singhal0d15bd52013-10-12 23:13:13 -07006263 status = sme_AcquireGlobalLock( &pMac->sme );
6264 if ( HAL_STATUS_SUCCESS( status ) )
6265 {
6266 smsLog(pMac, LOG1, FL(" called"));
Kiet Lamf2f201e2013-11-16 21:24:16 +05306267 pMsg = vos_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
6268 if (NULL == pMsg)
Amar Singhal0d15bd52013-10-12 23:13:13 -07006269 {
6270 smsLog(pMac, LOGE, " sme_GenericChangeCountryCode: failed to allocate mem for req");
6271 sme_ReleaseGlobalLock( &pMac->sme );
Kiet Lamf2f201e2013-11-16 21:24:16 +05306272 return eHAL_STATUS_FAILURE;
Amar Singhal0d15bd52013-10-12 23:13:13 -07006273 }
6274
6275 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE);
6276 pMsg->msgLen = (tANI_U16)sizeof(tAniGenericChangeCountryCodeReq);
Sameer Thalappil7324e8b2014-01-15 10:32:54 -08006277 vos_mem_copy(pMsg->countryCode, pCountry, 2);
Dino Mycle6c77a962014-08-19 15:34:23 +05306278
6279 pMsg->countryCode[2] = ' '; /* For ASCII space */
6280
Amar Singhal0d15bd52013-10-12 23:13:13 -07006281 pMsg->domain_index = reg_domain;
6282
6283 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
6284 msg.bodyptr = pMsg;
6285 msg.reserved = 0;
6286
6287 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
6288 {
6289 smsLog(pMac, LOGE, "sme_GenericChangeCountryCode failed to post msg to self");
Kiet Lamf2f201e2013-11-16 21:24:16 +05306290 vos_mem_free(pMsg);
Amar Singhal0d15bd52013-10-12 23:13:13 -07006291 status = eHAL_STATUS_FAILURE;
6292 }
6293 smsLog(pMac, LOG1, FL(" returned"));
6294 sme_ReleaseGlobalLock( &pMac->sme );
6295 }
6296
6297 return (status);
6298}
Mihir Shetee1093ba2014-01-21 20:13:32 +05306299
6300/* ---------------------------------------------------------------------------
6301
6302 \fn sme_InitChannels
6303
6304 \brief Used to initialize CSR channel lists while driver loading
6305
6306 \param hHal - global pMac structure
6307
6308 \return eHalStatus SUCCESS.
6309
6310 FAILURE or RESOURCES The API finished and failed.
6311
6312 -------------------------------------------------------------------------------*/
6313eHalStatus sme_InitChannels(tHalHandle hHal)
6314{
6315 eHalStatus status = eHAL_STATUS_FAILURE;
6316 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6317
6318 if (NULL == pMac)
6319 {
6320 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
6321 "%s: pMac is null", __func__);
6322 return status;
6323 }
6324
Vinay Krishna Erannab9295ae2014-05-09 13:43:23 +05306325 status = csrInitChannels(pMac);
6326
Mihir Shetee1093ba2014-01-21 20:13:32 +05306327 return status;
6328}
6329
Mihir Shete04206452014-11-20 17:50:58 +05306330#ifdef CONFIG_ENABLE_LINUX_REG
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05306331/*-------------------------------------------------------------------------
6332 \fn sme_InitChannelsForCC
6333
6334 \brief Used to issue regulatory hint to user
6335
6336 \param hHal - global pMac structure
6337
6338 \return eHalStatus SUCCESS.
6339
6340 FAILURE or RESOURCES The API finished and failed.
6341--------------------------------------------------------------------------*/
6342
Agarwal Ashish6db9d532014-09-30 18:19:10 +05306343eHalStatus sme_InitChannelsForCC(tHalHandle hHal, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05306344{
6345 eHalStatus status = eHAL_STATUS_FAILURE;
6346 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6347
6348 if (NULL == pMac)
6349 {
6350 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
6351 "%s: pMac is null", __func__);
6352 return status;
6353 }
Agarwal Ashish6db9d532014-09-30 18:19:10 +05306354 status = csrInitChannelsForCC(pMac, init);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05306355
6356 return status;
6357}
Mihir Shete04206452014-11-20 17:50:58 +05306358#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05306359
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306360/* ---------------------------------------------------------------------------
6361
6362 \fn sme_DHCPStartInd
6363
6364 \brief API to signal the FW about the DHCP Start event.
6365
6366 \param hHal - HAL handle for device.
6367
6368 \param device_mode - mode(AP,SAP etc) of the device.
6369
6370 \param macAddr - MAC address of the device.
6371
6372 \return eHalStatus SUCCESS.
6373
6374 FAILURE or RESOURCES The API finished and failed.
6375 --------------------------------------------------------------------------*/
6376eHalStatus sme_DHCPStartInd( tHalHandle hHal,
6377 tANI_U8 device_mode,
c_hpothu0b0cab72014-02-13 21:52:40 +05306378 tANI_U8 sessionId )
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306379{
6380 eHalStatus status;
6381 VOS_STATUS vosStatus;
6382 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6383 vos_msg_t vosMessage;
6384 tAniDHCPInd *pMsg;
c_hpothu0b0cab72014-02-13 21:52:40 +05306385 tCsrRoamSession *pSession;
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306386
6387 status = sme_AcquireGlobalLock(&pMac->sme);
6388 if ( eHAL_STATUS_SUCCESS == status)
6389 {
c_hpothu0b0cab72014-02-13 21:52:40 +05306390 pSession = CSR_GET_SESSION( pMac, sessionId );
6391
6392 if (!pSession)
6393 {
6394 smsLog(pMac, LOGE, FL("session %d not found "), sessionId);
6395 sme_ReleaseGlobalLock( &pMac->sme );
6396 return eHAL_STATUS_FAILURE;
6397 }
Arif Hussaine709d372016-12-06 19:49:31 +05306398 pSession->dhcp_done = false;
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306399 pMsg = (tAniDHCPInd*)vos_mem_malloc(sizeof(tAniDHCPInd));
6400 if (NULL == pMsg)
6401 {
6402 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6403 "%s: Not able to allocate memory for dhcp start", __func__);
6404 sme_ReleaseGlobalLock( &pMac->sme );
6405 return eHAL_STATUS_FAILURE;
6406 }
6407 pMsg->msgType = WDA_DHCP_START_IND;
6408 pMsg->msgLen = (tANI_U16)sizeof(tAniDHCPInd);
6409 pMsg->device_mode = device_mode;
c_hpothu0b0cab72014-02-13 21:52:40 +05306410 vos_mem_copy(pMsg->macAddr, pSession->connectedProfile.bssid,
6411 sizeof(tSirMacAddr));
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306412 vosMessage.type = WDA_DHCP_START_IND;
6413 vosMessage.bodyptr = pMsg;
6414 vosMessage.reserved = 0;
6415
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05306416 MTRACE(vos_trace(VOS_MODULE_ID_SME,
6417 TRACE_CODE_SME_TX_WDA_MSG, sessionId, vosMessage.type));
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306418 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6419 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6420 {
6421 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6422 "%s: Post DHCP Start MSG fail", __func__);
6423 vos_mem_free(pMsg);
6424 status = eHAL_STATUS_FAILURE;
6425 }
6426 sme_ReleaseGlobalLock( &pMac->sme );
6427 }
6428 return (status);
6429}
6430/* ---------------------------------------------------------------------------
6431 \fn sme_DHCPStopInd
6432
6433 \brief API to signal the FW about the DHCP complete event.
6434
6435 \param hHal - HAL handle for device.
6436
6437 \param device_mode - mode(AP, SAP etc) of the device.
6438
6439 \param macAddr - MAC address of the device.
6440
6441 \return eHalStatus SUCCESS.
6442 FAILURE or RESOURCES The API finished and failed.
6443 --------------------------------------------------------------------------*/
6444eHalStatus sme_DHCPStopInd( tHalHandle hHal,
6445 tANI_U8 device_mode,
c_hpothu0b0cab72014-02-13 21:52:40 +05306446 tANI_U8 sessionId )
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306447{
6448 eHalStatus status;
6449 VOS_STATUS vosStatus;
6450 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6451 vos_msg_t vosMessage;
6452 tAniDHCPInd *pMsg;
c_hpothu0b0cab72014-02-13 21:52:40 +05306453 tCsrRoamSession *pSession;
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306454
6455 status = sme_AcquireGlobalLock(&pMac->sme);
6456 if ( eHAL_STATUS_SUCCESS == status)
6457 {
c_hpothu0b0cab72014-02-13 21:52:40 +05306458 pSession = CSR_GET_SESSION( pMac, sessionId );
6459
6460 if (!pSession)
6461 {
6462 smsLog(pMac, LOGE, FL("session %d not found "), sessionId);
6463 sme_ReleaseGlobalLock( &pMac->sme );
6464 return eHAL_STATUS_FAILURE;
6465 }
Arif Hussaine709d372016-12-06 19:49:31 +05306466 pSession->dhcp_done = true;
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306467 pMsg = (tAniDHCPInd*)vos_mem_malloc(sizeof(tAniDHCPInd));
6468 if (NULL == pMsg)
6469 {
6470 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6471 "%s: Not able to allocate memory for dhcp stop", __func__);
6472 sme_ReleaseGlobalLock( &pMac->sme );
6473 return eHAL_STATUS_FAILURE;
6474 }
6475
6476 pMsg->msgType = WDA_DHCP_STOP_IND;
6477 pMsg->msgLen = (tANI_U16)sizeof(tAniDHCPInd);
6478 pMsg->device_mode = device_mode;
c_hpothu0b0cab72014-02-13 21:52:40 +05306479 vos_mem_copy(pMsg->macAddr, pSession->connectedProfile.bssid,
6480 sizeof(tSirMacAddr));
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306481
6482 vosMessage.type = WDA_DHCP_STOP_IND;
6483 vosMessage.bodyptr = pMsg;
6484 vosMessage.reserved = 0;
6485
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05306486 MTRACE(vos_trace(VOS_MODULE_ID_SME,
6487 TRACE_CODE_SME_TX_WDA_MSG, sessionId, vosMessage.type));
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306488 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6489 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6490 {
6491 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6492 "%s: Post DHCP Stop MSG fail", __func__);
6493 vos_mem_free(pMsg);
6494 status = eHAL_STATUS_FAILURE;
6495 }
6496
6497 sme_ReleaseGlobalLock( &pMac->sme );
6498 }
6499 return (status);
6500}
6501
Abhishek Singh00b71972016-01-07 10:51:04 +05306502#ifdef WLAN_FEATURE_RMC
6503/*---------------------------------------------------------------------------
6504
6505 \fn sme_TXFailMonitorStopInd
6506
6507 \brief API to signal the FW to start monitoring TX failures
6508
6509 \return eHalStatus SUCCESS.
6510
6511 FAILURE or RESOURCES The API finished and failed.
6512 --------------------------------------------------------------------------*/
6513eHalStatus sme_TXFailMonitorStartStopInd(tHalHandle hHal, tANI_U8 tx_fail_count,
6514 void * txFailIndCallback)
6515{
6516 eHalStatus status;
6517 VOS_STATUS vosStatus;
6518 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6519 vos_msg_t vosMessage;
6520 tAniTXFailMonitorInd *pMsg;
6521
6522 status = sme_AcquireGlobalLock(&pMac->sme);
6523 if ( eHAL_STATUS_SUCCESS == status)
6524 {
6525 pMsg = (tAniTXFailMonitorInd*)
6526 vos_mem_malloc(sizeof(tAniTXFailMonitorInd));
6527 if (NULL == pMsg)
6528 {
6529 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6530 "%s: Failed to allocate memory", __func__);
6531 sme_ReleaseGlobalLock( &pMac->sme );
6532 return eHAL_STATUS_FAILURE;
6533 }
6534
6535 pMsg->msgType = WDA_TX_FAIL_MONITOR_IND;
6536 pMsg->msgLen = (tANI_U16)sizeof(tAniTXFailMonitorInd);
6537
6538 //tx_fail_count = 0 should disable the Monitoring in FW
6539 pMsg->tx_fail_count = tx_fail_count;
6540 pMsg->txFailIndCallback = txFailIndCallback;
6541
6542 vosMessage.type = WDA_TX_FAIL_MONITOR_IND;
6543 vosMessage.bodyptr = pMsg;
6544 vosMessage.reserved = 0;
6545
6546 MTRACE(vos_trace(VOS_MODULE_ID_SME,
6547 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
6548 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage );
6549 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6550 {
6551 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6552 "%s: Post TX Fail monitor Start MSG fail", __func__);
6553 vos_mem_free(pMsg);
6554 status = eHAL_STATUS_FAILURE;
6555 }
6556 sme_ReleaseGlobalLock( &pMac->sme );
6557 }
6558 return (status);
6559}
6560#endif /* WLAN_FEATURE_RMC */
Jeff Johnson295189b2012-06-20 16:38:30 -07006561
Kapil Gupta04ab1992016-06-26 13:36:51 +05306562#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
6563void sme_PERRoamScanStartStop(void *hHal, tANI_U8 start)
6564{
6565 eHalStatus status;
6566 VOS_STATUS vosStatus;
6567 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6568 vos_msg_t vosMessage;
6569 tPERRoamScanStart *pMsg;
6570
6571 status = sme_AcquireGlobalLock(&pMac->sme);
6572 if ( eHAL_STATUS_SUCCESS == status)
6573 {
6574 pMsg = (tPERRoamScanStart *)
6575 vos_mem_malloc(sizeof(tPERRoamScanStart));
6576 if (NULL == pMsg)
6577 {
6578 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6579 "%s: Failed to allocate memory", __func__);
6580 sme_ReleaseGlobalLock( &pMac->sme );
6581 return;
6582 }
6583
6584 pMsg->msgType = WDA_PER_ROAM_SCAN_TRIGGER_REQ;
6585 pMsg->msgLen = (tANI_U16)sizeof(*pMsg);
6586
6587 pMsg->start = start;
6588
6589 vosMessage.type = WDA_PER_ROAM_SCAN_TRIGGER_REQ;
6590 vosMessage.bodyptr = pMsg;
6591 vosMessage.reserved = 0;
6592
6593 MTRACE(vos_trace(VOS_MODULE_ID_SME,
6594 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
6595 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage );
6596 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6597 {
6598 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6599 "%s: Post TX Fail monitor Start MSG fail", __func__);
6600 vos_mem_free(pMsg);
6601 status = eHAL_STATUS_FAILURE;
6602 }
6603 sme_ReleaseGlobalLock(&pMac->sme);
6604 }
6605}
6606
6607/* sme_set_per_roam_rxconfig : set PER config for Rx monitoring
6608 * @hHal: hal pointer
6609 * @staId: station id
6610 * @minRate : rate at which to start monitoring
6611 * @maxRate : Rate at which to stop monitoring
6612 * @minPercentage: minimum % of packets required in minRate to trigger a scan
6613 * @minPktRequired: minimum number of packets required to trigger a scan
6614 * @waitPeriodForNextPERScan: time to wait before start monitoring again once
6615 * roam scan is triggered
6616 * */
6617
6618VOS_STATUS sme_set_per_roam_rxconfig (tHalHandle hHal, v_U8_t staId,
6619 v_U16_t minRate, v_U16_t maxRate,
6620 v_U8_t minPercentage, v_U16_t minPktRequired,
6621 v_U64_t waitPeriodForNextPERScan)
6622{
6623 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6624 v_VOID_t * pVosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
6625 WLANTL_StartRxRateMonitor(pVosContext, staId, minRate, maxRate,
6626 minPercentage, minPktRequired,
6627 (void *) hHal, waitPeriodForNextPERScan,
6628 sme_PERRoamScanStartStop);
6629 pMac->PERroamCandidatesCnt = 0;
6630 return eHAL_STATUS_SUCCESS;
6631}
6632
6633/* sme_unset_per_roam_rxconfig : unset PER config for Rx monitoring
6634 * */
6635VOS_STATUS sme_unset_per_roam_rxconfig (tHalHandle hHal)
6636{
6637 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6638 v_VOID_t * pVosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
6639 vos_mem_set(pMac->previousRoamApInfo,
6640 sizeof(tSirRoamAPInfo) * SIR_PER_ROAM_MAX_CANDIDATE_CNT, 0);
6641 WLANTL_StopRxRateMonitor(pVosContext);
6642 return eHAL_STATUS_SUCCESS;
6643}
6644#endif
6645
Jeff Johnson295189b2012-06-20 16:38:30 -07006646/* ---------------------------------------------------------------------------
6647 \fn sme_BtcSignalBtEvent
6648 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
6649 BT event type and the current operating mode of Libra (full power,
6650 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
6651 would be employed.
6652 \param hHal - The handle returned by macOpen.
6653 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
6654 Caller owns the memory and is responsible for freeing it.
6655 \return VOS_STATUS
6656 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
6657 if BTC execution mode is set to BTC_WLAN_ONLY
6658 or BTC_PTA_ONLY.
6659 VOS_STATUS_SUCCESS BT Event passed to HAL
6660 ---------------------------------------------------------------------------*/
6661VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
6662{
6663 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006664
Jeff Johnson295189b2012-06-20 16:38:30 -07006665#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6666 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6667
Katya Nigambcb705f2013-12-26 14:26:22 +05306668 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006669 TRACE_CODE_SME_RX_HDD_BTC_SIGNALEVENT, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6671 {
6672 status = btcSignalBTEvent (hHal, pBtEvent);
6673 sme_ReleaseGlobalLock( &pMac->sme );
6674 }
6675#endif
6676 return (status);
6677}
6678
6679/* ---------------------------------------------------------------------------
6680 \fn sme_BtcSetConfig
6681 \brief API to change the current Bluetooth Coexistence (BTC) configuration
6682 This function should be invoked only after CFG download has completed.
6683 Calling it after sme_HDDReadyInd is recommended.
6684 \param hHal - The handle returned by macOpen.
6685 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
6686 Caller owns the memory and is responsible for freeing it.
6687 \return VOS_STATUS
6688 VOS_STATUS_E_FAILURE Config not passed to HAL.
6689 VOS_STATUS_SUCCESS Config passed to HAL
6690 ---------------------------------------------------------------------------*/
6691VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
6692{
6693 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6694#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6695 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05306696 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006697 TRACE_CODE_SME_RX_HDD_BTC_SETCONFIG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006698 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6699 {
6700 status = btcSetConfig (hHal, pSmeBtcConfig);
6701 sme_ReleaseGlobalLock( &pMac->sme );
6702 }
6703#endif
6704 return (status);
6705}
6706
6707/* ---------------------------------------------------------------------------
6708 \fn sme_BtcGetConfig
6709 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
6710 \param hHal - The handle returned by macOpen.
6711 \param pSmeBtcConfig - Pointer to a caller allocated object of type
6712 tSmeBtcConfig. Caller owns the memory and is responsible
6713 for freeing it.
6714 \return VOS_STATUS
6715 VOS_STATUS_E_FAILURE - failure
6716 VOS_STATUS_SUCCESS success
6717 ---------------------------------------------------------------------------*/
6718VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
6719{
6720 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6721#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6722 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6723
Katya Nigambcb705f2013-12-26 14:26:22 +05306724 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006725 TRACE_CODE_SME_RX_HDD_BTC_GETCONFIG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6727 {
6728 status = btcGetConfig (hHal, pSmeBtcConfig);
6729 sme_ReleaseGlobalLock( &pMac->sme );
6730 }
6731#endif
6732 return (status);
6733}
6734/* ---------------------------------------------------------------------------
6735 \fn sme_SetCfgPrivacy
6736 \brief API to set configure privacy parameters
6737 \param hHal - The handle returned by macOpen.
6738 \param pProfile - Pointer CSR Roam profile.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006739 \param fPrivacy - This parameter indicates status of privacy
Jeff Johnson295189b2012-06-20 16:38:30 -07006740
6741 \return void
6742 ---------------------------------------------------------------------------*/
6743void sme_SetCfgPrivacy( tHalHandle hHal,
6744 tCsrRoamProfile *pProfile,
6745 tANI_BOOLEAN fPrivacy
6746 )
6747{
6748 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05306749 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006750 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6752 {
6753 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
6754 sme_ReleaseGlobalLock( &pMac->sme );
6755 }
6756}
6757
6758#if defined WLAN_FEATURE_VOWIFI
6759/* ---------------------------------------------------------------------------
6760 \fn sme_NeighborReportRequest
6761 \brief API to request neighbor report.
6762 \param hHal - The handle returned by macOpen.
6763 \param pRrmNeighborReq - Pointer to a caller allocated object of type
6764 tRrmNeighborReq. Caller owns the memory and is responsible
6765 for freeing it.
6766 \return VOS_STATUS
6767 VOS_STATUS_E_FAILURE - failure
6768 VOS_STATUS_SUCCESS success
6769 ---------------------------------------------------------------------------*/
6770VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
6771 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
6772{
6773 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6774 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05306775 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006776 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006777
6778 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6779 {
6780 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
6781 sme_ReleaseGlobalLock( &pMac->sme );
6782 }
6783
6784 return (status);
6785}
6786#endif
6787
6788//The following are debug APIs to support direct read/write register/memory
6789//They are placed in SME because HW cannot be access when in LOW_POWER state
6790//AND not connected. The knowledge and synchronization is done in SME
6791
6792//sme_DbgReadRegister
6793//Caller needs to validate the input values
6794VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
6795{
6796 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6797 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 tPmcPowerState PowerState;
6799 tANI_U32 sessionId = 0;
Katya Nigambcb705f2013-12-26 14:26:22 +05306800 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006801 TRACE_CODE_SME_RX_HDD_DBG_READREG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006802
6803 /* 1) To make Quarky work in FTM mode **************************************/
6804
6805 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
6806 {
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08006807 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 {
6809 return VOS_STATUS_SUCCESS;
6810 }
6811 return VOS_STATUS_E_FAILURE;
6812 }
6813
6814 /* 2) NON FTM mode driver *************************************************/
6815
6816 /* Acquire SME global lock */
6817 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
6818 {
6819 return VOS_STATUS_E_FAILURE;
6820 }
6821
6822 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
6823 {
6824 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
6825 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
6826 {
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08006827 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07006828 {
6829 status = VOS_STATUS_SUCCESS;
6830 }
6831 else
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006832 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006833 status = VOS_STATUS_E_FAILURE;
6834 }
6835 }
6836 else
6837 {
6838 status = VOS_STATUS_E_FAILURE;
6839 }
6840 }
6841
6842 /* This is a hack for Qualky/pttWniSocket
6843 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
6844 if ( VOS_STATUS_SUCCESS != status )
6845 {
6846 *pRegValue = 0xDEADBEEF;
6847 status = VOS_STATUS_SUCCESS;
6848 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006849
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 /* Release SME global lock */
6851 sme_ReleaseGlobalLock(&pMac->sme);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006852
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 return (status);
6854}
6855
6856
6857//sme_DbgWriteRegister
6858//Caller needs to validate the input values
6859VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
6860{
6861 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6862 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 tPmcPowerState PowerState;
6864 tANI_U32 sessionId = 0;
6865
6866 /* 1) To make Quarky work in FTM mode **************************************/
6867
Katya Nigambcb705f2013-12-26 14:26:22 +05306868 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006869 TRACE_CODE_SME_RX_HDD_DBG_WRITEREG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
6871 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 {
6874 return VOS_STATUS_SUCCESS;
6875 }
6876 return VOS_STATUS_E_FAILURE;
6877 }
6878
6879 /* 2) NON FTM mode driver *************************************************/
6880
6881 /* Acquire SME global lock */
6882 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
6883 {
6884 return VOS_STATUS_E_FAILURE;
6885 }
6886
6887 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
6888 {
6889 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
6890 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
6891 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006892 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07006893 {
6894 status = VOS_STATUS_SUCCESS;
6895 }
6896 else
6897 {
6898 status = VOS_STATUS_E_FAILURE;
6899 }
6900 }
6901 else
6902 {
6903 status = VOS_STATUS_E_FAILURE;
6904 }
6905 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006906
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 /* Release SME global lock */
6908 sme_ReleaseGlobalLock(&pMac->sme);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006909
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 return (status);
6911}
6912
6913
6914
6915//sme_DbgReadMemory
6916//Caller needs to validate the input values
6917//pBuf caller allocated buffer has the length of nLen
6918VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
6919{
6920 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6921 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 tPmcPowerState PowerState;
6923 tANI_U32 sessionId = 0;
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08006924 tANI_U32 cmd = READ_MEMORY_DUMP_CMD;
6925 tANI_U32 arg1 = memAddr;
6926 tANI_U32 arg2 = nLen/4;
6927 tANI_U32 arg3 = 4;
6928 tANI_U32 arg4 = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 /* 1) To make Quarky work in FTM mode **************************************/
6930
Katya Nigambcb705f2013-12-26 14:26:22 +05306931 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006932 TRACE_CODE_SME_RX_HDD_DBG_READMEM, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
6934 {
Siddharth Bhal68115602015-01-18 20:44:55 +05306935 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8*)pBuf, 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 {
6937 return VOS_STATUS_SUCCESS;
6938 }
6939 return VOS_STATUS_E_FAILURE;
6940 }
6941
6942 /* 2) NON FTM mode driver *************************************************/
6943
6944 /* Acquire SME global lock */
6945 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
6946 {
6947 return VOS_STATUS_E_FAILURE;
6948 }
6949
6950 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
6951 {
6952 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
6953 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
6954 {
Siddharth Bhal68115602015-01-18 20:44:55 +05306955 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8 *)pBuf, 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006956 {
6957 status = VOS_STATUS_SUCCESS;
6958 }
6959 else
6960 {
6961 status = VOS_STATUS_E_FAILURE;
6962 }
6963 }
6964 else
6965 {
6966 status = VOS_STATUS_E_FAILURE;
6967 }
6968 }
6969
6970 /* This is a hack for Qualky/pttWniSocket
6971 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
6972 if (VOS_STATUS_SUCCESS != status)
6973 {
6974 vos_mem_set(pBuf, nLen, 0xCD);
6975 status = VOS_STATUS_SUCCESS;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006976 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 }
6978
6979 /* Release SME lock */
6980 sme_ReleaseGlobalLock(&pMac->sme);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006981
Jeff Johnson295189b2012-06-20 16:38:30 -07006982 return (status);
6983}
6984
6985
6986//sme_DbgWriteMemory
6987//Caller needs to validate the input values
6988VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
6989{
6990 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6991 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006992 tPmcPowerState PowerState;
6993 tANI_U32 sessionId = 0;
6994
6995 /* 1) To make Quarky work in FTM mode **************************************/
6996
Katya Nigambcb705f2013-12-26 14:26:22 +05306997 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006998 TRACE_CODE_SME_RX_HDD_DBG_WRITEMEM, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006999 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
7000 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 {
7002 return VOS_STATUS_SUCCESS;
7003 }
7004 return VOS_STATUS_E_FAILURE;
7005 }
7006
7007 /* 2) NON FTM mode driver *************************************************/
7008
7009 /* Acquire SME global lock */
7010 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
7011 {
7012 return VOS_STATUS_E_FAILURE;
7013 }
7014
7015 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
7016 {
7017 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
7018 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
7019 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 {
7022 status = VOS_STATUS_SUCCESS;
7023 }
7024 else
7025 {
7026 status = VOS_STATUS_E_FAILURE;
7027 }
7028 }
7029 else
7030 {
7031 status = VOS_STATUS_E_FAILURE;
7032 }
7033 }
7034
7035 /* Release Global lock */
7036 sme_ReleaseGlobalLock(&pMac->sme);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007037
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 return (status);
7039}
7040
7041
Katya Nigam70d68332013-09-16 16:49:45 +05307042void pmcLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString, ...)
7043{
7044 VOS_TRACE_LEVEL vosDebugLevel;
7045 char logBuffer[LOG_SIZE];
7046 va_list marker;
7047
7048 /* getting proper Debug level */
7049 vosDebugLevel = getVosDebugLevel(loglevel);
7050
7051 /* extracting arguments from pstring */
7052 va_start( marker, pString );
7053 vsnprintf(logBuffer, LOG_SIZE, pString, marker);
7054
7055 VOS_TRACE(VOS_MODULE_ID_PMC, vosDebugLevel, "%s", logBuffer);
7056 va_end( marker );
7057}
7058
7059
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007060void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
Jeff Johnson295189b2012-06-20 16:38:30 -07007061{
7062#ifdef WLAN_DEBUG
7063 // Verify against current log level
7064 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
7065 return;
7066 else
7067 {
7068 va_list marker;
7069
7070 va_start( marker, pString ); /* Initialize variable arguments. */
7071
7072 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
7073
7074 va_end( marker ); /* Reset variable arguments. */
7075 }
7076#endif
7077}
Jeff Johnson295189b2012-06-20 16:38:30 -07007078
Jeff Johnson295189b2012-06-20 16:38:30 -07007079/* ---------------------------------------------------------------------------
7080 \fn sme_GetWcnssWlanCompiledVersion
7081 \brief This API returns the version of the WCNSS WLAN API with
7082 which the HOST driver was built
7083 \param hHal - The handle returned by macOpen.
7084 \param pVersion - Points to the Version structure to be filled
7085 \return VOS_STATUS
7086 VOS_STATUS_E_INVAL - failure
7087 VOS_STATUS_SUCCESS success
7088 ---------------------------------------------------------------------------*/
7089VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
7090 tSirVersionType *pVersion)
7091{
7092 VOS_STATUS status = VOS_STATUS_SUCCESS;
7093 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7094 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
7095
7096 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
7097 {
7098 if( pVersion != NULL )
7099 {
7100 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
7101 }
7102 else
7103 {
7104 status = VOS_STATUS_E_INVAL;
7105 }
7106 sme_ReleaseGlobalLock( &pMac->sme );
7107 }
7108
7109 return (status);
7110}
7111
7112
7113/* ---------------------------------------------------------------------------
7114 \fn sme_GetWcnssWlanReportedVersion
7115 \brief This API returns the version of the WCNSS WLAN API with
7116 which the WCNSS driver reports it was built
7117 \param hHal - The handle returned by macOpen.
7118 \param pVersion - Points to the Version structure to be filled
7119 \return VOS_STATUS
7120 VOS_STATUS_E_INVAL - failure
7121 VOS_STATUS_SUCCESS success
7122 ---------------------------------------------------------------------------*/
7123VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
7124 tSirVersionType *pVersion)
7125{
7126 VOS_STATUS status = VOS_STATUS_SUCCESS;
7127 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7128 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
7129
7130 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
7131 {
7132 if( pVersion != NULL )
7133 {
7134 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
7135 }
7136 else
7137 {
7138 status = VOS_STATUS_E_INVAL;
7139 }
7140 sme_ReleaseGlobalLock( &pMac->sme );
7141 }
7142
7143 return (status);
7144}
7145
7146
7147/* ---------------------------------------------------------------------------
7148 \fn sme_GetWcnssSoftwareVersion
7149 \brief This API returns the version string of the WCNSS driver
7150 \param hHal - The handle returned by macOpen.
7151 \param pVersion - Points to the Version string buffer to be filled
7152 \param versionBufferSize - THe size of the Version string buffer
7153 \return VOS_STATUS
7154 VOS_STATUS_E_INVAL - failure
7155 VOS_STATUS_SUCCESS success
7156 ---------------------------------------------------------------------------*/
7157VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
7158 tANI_U8 *pVersion,
7159 tANI_U32 versionBufferSize)
7160{
7161 VOS_STATUS status = VOS_STATUS_SUCCESS;
7162 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7163 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
7164
7165 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
7166 {
7167 if( pVersion != NULL )
7168 {
7169 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
7170 versionBufferSize);
7171 }
7172 else
7173 {
7174 status = VOS_STATUS_E_INVAL;
7175 }
7176 sme_ReleaseGlobalLock( &pMac->sme );
7177 }
7178
7179 return (status);
7180}
7181
7182
7183/* ---------------------------------------------------------------------------
7184 \fn sme_GetWcnssHardwareVersion
7185 \brief This API returns the version string of the WCNSS hardware
7186 \param hHal - The handle returned by macOpen.
7187 \param pVersion - Points to the Version string buffer to be filled
7188 \param versionBufferSize - THe size of the Version string buffer
7189 \return VOS_STATUS
7190 VOS_STATUS_E_INVAL - failure
7191 VOS_STATUS_SUCCESS success
7192 ---------------------------------------------------------------------------*/
7193VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
7194 tANI_U8 *pVersion,
7195 tANI_U32 versionBufferSize)
7196{
7197 VOS_STATUS status = VOS_STATUS_SUCCESS;
7198 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7199 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
7200
7201 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
7202 {
7203 if( pVersion != NULL )
7204 {
7205 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
7206 versionBufferSize);
7207 }
7208 else
7209 {
7210 status = VOS_STATUS_E_INVAL;
7211 }
7212 sme_ReleaseGlobalLock( &pMac->sme );
7213 }
7214
7215 return (status);
7216}
Jeff Johnson4824d4c2013-02-12 14:23:57 -08007217
Jeff Johnson295189b2012-06-20 16:38:30 -07007218
7219#ifdef FEATURE_WLAN_WAPI
7220/* ---------------------------------------------------------------------------
7221 \fn sme_RoamSetBKIDCache
7222 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
7223 candidate list.
7224 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
7225 it is opened (by calling halOpen).
7226 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
7227 \param numItems - a variable that has the number of tBkidCacheInfo allocated
7228 when retruning, this is the number of items put into pBKIDCache
7229 \return eHalStatus - when fail, it usually means the buffer allocated is not
7230 big enough and pNumItems has the number of tBkidCacheInfo.
7231 ---------------------------------------------------------------------------*/
7232eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
7233 tANI_U32 numItems )
7234{
7235 eHalStatus status = eHAL_STATUS_FAILURE;
7236 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7237
7238 status = sme_AcquireGlobalLock( &pMac->sme );
7239 if ( HAL_STATUS_SUCCESS( status ) )
7240 {
7241 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
7242 sme_ReleaseGlobalLock( &pMac->sme );
7243 }
7244
7245 return (status);
7246}
7247
7248/* ---------------------------------------------------------------------------
7249 \fn sme_RoamGetBKIDCache
7250 \brief The SME API exposed to HDD to allow HDD to request SME to return its
7251 BKID cache.
7252 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
7253 it is opened (by calling halOpen).
7254 \param pNum - caller allocated memory that has the space of the number of
7255 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
7256 in SME cache.
7257 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
7258 upon return
7259 \return eHalStatus - when fail, it usually means the buffer allocated is not
7260 big enough.
7261 ---------------------------------------------------------------------------*/
7262eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
7263 tBkidCacheInfo *pBkidCache)
7264{
7265 eHalStatus status = eHAL_STATUS_FAILURE;
7266 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7267
7268 status = sme_AcquireGlobalLock( &pMac->sme );
7269 if ( HAL_STATUS_SUCCESS( status ) )
7270 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007271 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
7273 sme_ReleaseGlobalLock( &pMac->sme );
7274 }
7275
7276 return (status);
7277}
7278
7279/* ---------------------------------------------------------------------------
7280 \fn sme_RoamGetNumBKIDCache
7281 \brief The SME API exposed to HDD to allow HDD to request SME to return the
7282 number of BKID cache entries.
7283 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
7284 it is opened (by calling halOpen).
7285 \return tANI_U32 - the number of BKID cache entries.
7286 ---------------------------------------------------------------------------*/
7287tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
7288{
7289 eHalStatus status = eHAL_STATUS_FAILURE;
7290 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7291 tANI_U32 numBkidCache = 0;
7292
7293 status = sme_AcquireGlobalLock( &pMac->sme );
7294 if ( HAL_STATUS_SUCCESS( status ) )
7295 {
7296 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
7297 sme_ReleaseGlobalLock( &pMac->sme );
7298 }
7299
7300 return (numBkidCache);
7301}
7302
7303/* ---------------------------------------------------------------------------
7304 \fn sme_ScanGetBKIDCandidateList
7305 \brief a wrapper function to return the BKID candidate list
7306 \param pBkidList - caller allocated buffer point to an array of
7307 tBkidCandidateInfo
7308 \param pNumItems - pointer to a variable that has the number of
7309 tBkidCandidateInfo allocated when retruning, this is
7310 either the number needed or number of items put into
7311 pPmkidList
7312 \return eHalStatus - when fail, it usually means the buffer allocated is not
7313 big enough and pNumItems
7314 has the number of tBkidCandidateInfo.
7315 \Note: pNumItems is a number of tBkidCandidateInfo,
7316 not sizeof(tBkidCandidateInfo) * something
7317 ---------------------------------------------------------------------------*/
7318eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
7319 tBkidCandidateInfo *pBkidList,
7320 tANI_U32 *pNumItems )
7321{
7322 eHalStatus status = eHAL_STATUS_FAILURE;
7323 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7324
7325 status = sme_AcquireGlobalLock( &pMac->sme );
7326 if ( HAL_STATUS_SUCCESS( status ) )
7327 {
7328 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
7329 sme_ReleaseGlobalLock( &pMac->sme );
7330 }
7331
7332 return (status);
7333}
7334#endif /* FEATURE_WLAN_WAPI */
7335
Jeff Johnsone7245742012-09-05 17:12:55 -07007336#ifdef FEATURE_OEM_DATA_SUPPORT
7337
7338/*****************************************************************************
7339 OEM DATA related modifications and function additions
7340 *****************************************************************************/
7341
7342/* ---------------------------------------------------------------------------
7343 \fn sme_getOemDataRsp
7344 \brief a wrapper function to obtain the OEM DATA RSP
7345 \param pOemDataRsp - A pointer to the response object
7346 \param pContext - a pointer passed in for the callback
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007347 \return eHalStatus
Jeff Johnsone7245742012-09-05 17:12:55 -07007348 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007349eHalStatus sme_getOemDataRsp(tHalHandle hHal,
Jeff Johnsone7245742012-09-05 17:12:55 -07007350 tOemDataRsp **pOemDataRsp)
7351{
7352 eHalStatus status = eHAL_STATUS_SUCCESS;
7353 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7354
7355 do
7356 {
7357 //acquire the lock for the sme object
7358 status = sme_AcquireGlobalLock(&pMac->sme);
7359
7360 if(!HAL_STATUS_SUCCESS(status))
7361 {
7362 break;
7363 }
7364
7365 if(pMac->oemData.pOemDataRsp != NULL)
7366 {
7367 *pOemDataRsp = pMac->oemData.pOemDataRsp;
7368 }
7369 else
7370 {
7371 status = eHAL_STATUS_FAILURE;
7372 }
7373
7374 //release the lock for the sme object
7375 sme_ReleaseGlobalLock( &pMac->sme );
7376
7377 } while(0);
7378
7379 return status;
7380}
7381
7382/* ---------------------------------------------------------------------------
7383 \fn sme_OemDataReq
7384 \brief a wrapper function for OEM DATA REQ
7385 \param sessionId - session id to be used.
7386 \param pOemDataReqId - pointer to an object to get back the request ID
7387 \param callback - a callback function that is called upon finish
7388 \param pContext - a pointer passed in for the callback
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007389 \return eHalStatus
Jeff Johnsone7245742012-09-05 17:12:55 -07007390 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007391eHalStatus sme_OemDataReq(tHalHandle hHal,
Jeff Johnsone7245742012-09-05 17:12:55 -07007392 tANI_U8 sessionId,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007393 tOemDataReqConfig *pOemDataReqConfig,
7394 tANI_U32 *pOemDataReqID,
7395 oemData_OemDataReqCompleteCallback callback,
Jeff Johnsone7245742012-09-05 17:12:55 -07007396 void *pContext)
7397{
7398 eHalStatus status = eHAL_STATUS_SUCCESS;
7399 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7400
7401 do
7402 {
7403 //acquire the lock for the sme object
7404 status = sme_AcquireGlobalLock(&pMac->sme);
7405 if(HAL_STATUS_SUCCESS(status))
7406 {
7407 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
7408
7409 if(pOemDataReqID)
7410 {
7411 *pOemDataReqID = lOemDataReqId;
7412 }
7413 else
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08007414 {
7415 sme_ReleaseGlobalLock( &pMac->sme );
7416 return eHAL_STATUS_FAILURE;
7417 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007418
7419 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
7420
7421 //release the lock for the sme object
7422 sme_ReleaseGlobalLock( &pMac->sme );
7423 }
7424 } while(0);
7425
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007426 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07007427
7428 return(status);
7429}
7430
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +05307431/* ---------------------------------------------------------------------------
7432 \fn sme_OemDataReqNew
7433 \brief a wrapper function for OEM DATA REQ NEW
7434 \param pOemDataReqNewConfig - Data to be passed to FW
7435 ---------------------------------------------------------------------------*/
7436void sme_OemDataReqNew(tHalHandle hHal,
7437 tOemDataReqNewConfig *pOemDataReqNewConfig)
7438{
7439 eHalStatus status = eHAL_STATUS_SUCCESS;
7440 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7441 tOemDataReqNewConfig *pLocalOemDataReqNewConfig;
7442 vos_msg_t vosMessage = {0};
7443
7444 pLocalOemDataReqNewConfig =
7445 vos_mem_malloc(sizeof(*pLocalOemDataReqNewConfig));
7446
7447 if (!pLocalOemDataReqNewConfig)
7448 {
7449 smsLog(pMac, LOGE,
7450 "Failed to allocate memory for WDA_START_OEM_DATA_REQ_IND_NEW");
7451 return;
7452 }
7453
7454 vos_mem_zero(pLocalOemDataReqNewConfig, sizeof(tOemDataReqNewConfig));
7455 vos_mem_copy(pLocalOemDataReqNewConfig, pOemDataReqNewConfig,
7456 sizeof(tOemDataReqNewConfig));
7457
7458 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
7459 /* Serialize the req through MC thread */
7460 vosMessage.bodyptr = pLocalOemDataReqNewConfig;
7461 vosMessage.type = WDA_START_OEM_DATA_REQ_IND_NEW;
7462 MTRACE(vos_trace(VOS_MODULE_ID_SME,
7463 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
7464
7465 if(VOS_STATUS_SUCCESS !=
7466 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage)) {
7467 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s:"
7468 "Failed to post WDA_START_OEM_DATA_REQ_IND_NEW msg to WDA",
7469 __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +05307470 vos_mem_free(pLocalOemDataReqNewConfig);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +05307471 }
7472 sme_ReleaseGlobalLock(&pMac->sme);
7473 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +05307474 else
7475 {
7476 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
7477 "sme_AcquireGlobalLock error", __func__);
7478 vos_mem_free(pLocalOemDataReqNewConfig);
7479 }
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +05307480}
7481
Jeff Johnsone7245742012-09-05 17:12:55 -07007482#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07007483
7484/*--------------------------------------------------------------------------
7485
7486 \brief sme_OpenSession() - Open a session for scan/roam operation.
7487
7488 This is a synchronous API.
7489
7490
7491 \param hHal - The handle returned by macOpen.
7492 \param callback - A pointer to the function caller specifies for roam/connect status indication
7493 \param pContext - The context passed with callback
7494 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
7495 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
7496
7497 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
7498
7499 Other status means SME is failed to open the session.
7500 eHAL_STATUS_RESOURCES - no more session available.
7501 \sa
7502
7503 --------------------------------------------------------------------------*/
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07007504eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback,
7505 void *pContext, tANI_U8 *pSelfMacAddr,
7506 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007507{
7508 eHalStatus status;
7509 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7510
7511 if( NULL == pbSessionId )
7512 {
7513 status = eHAL_STATUS_INVALID_PARAMETER;
7514 }
7515 else
7516 {
7517 status = sme_AcquireGlobalLock( &pMac->sme );
7518 if ( HAL_STATUS_SUCCESS( status ) )
7519 {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07007520 status = csrRoamOpenSession(pMac, callback, pContext,
7521 pSelfMacAddr, pbSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007522
7523 sme_ReleaseGlobalLock( &pMac->sme );
7524 }
7525 }
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007526 if( NULL != pbSessionId )
Katya Nigambcb705f2013-12-26 14:26:22 +05307527 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007528 TRACE_CODE_SME_RX_HDD_OPEN_SESSION,*pbSessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007529
7530 return ( status );
7531}
7532
7533
7534/*--------------------------------------------------------------------------
7535
7536 \brief sme_CloseSession() - Open a session for scan/roam operation.
7537
7538 This is a synchronous API.
7539
7540
7541 \param hHal - The handle returned by macOpen.
7542
7543 \param sessionId - A previous opened session's ID.
7544
7545 \return eHAL_STATUS_SUCCESS - session is closed.
7546
7547 Other status means SME is failed to open the session.
7548 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
7549 \sa
7550
7551 --------------------------------------------------------------------------*/
7552eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
Agrawal Ashish5a3522c2016-03-02 15:08:28 +05307553 tANI_BOOLEAN fSync,
mukul sharmabab477d2015-06-11 17:14:55 +05307554 tANI_U8 bPurgeSmeCmdList,
7555 csrRoamSessionCloseCallback callback,
7556 void *pContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07007557{
7558 eHalStatus status;
7559 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7560
Katya Nigambcb705f2013-12-26 14:26:22 +05307561 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007562 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, sessionId, 0));
Agrawal Ashish5a3522c2016-03-02 15:08:28 +05307563 status = sme_AcquireGlobalLock(&pMac->sme);
7564 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 {
Agrawal Ashish5a3522c2016-03-02 15:08:28 +05307566 status = csrRoamCloseSession(pMac, sessionId, fSync, bPurgeSmeCmdList,
7567 callback, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07007568
7569 sme_ReleaseGlobalLock( &pMac->sme );
7570 }
7571
7572 return ( status );
7573}
7574
Jeff Johnson295189b2012-06-20 16:38:30 -07007575/* ---------------------------------------------------------------------------
7576
7577 \fn sme_RoamUpdateAPWPSIE
7578
7579 \brief To update AP's WPS IE. This function should be called after SME AP session is created
7580 This is an asynchronous API.
7581
7582 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
7583
7584 \return eHalStatus – SUCCESS –
7585
7586 FAILURE or RESOURCES – The API finished and failed.
7587
7588 -------------------------------------------------------------------------------*/
7589eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
7590{
7591
7592 eHalStatus status = eHAL_STATUS_FAILURE;
7593 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7594
7595 status = sme_AcquireGlobalLock( &pMac->sme );
7596 if ( HAL_STATUS_SUCCESS( status ) )
7597 {
7598
7599 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
7600
7601 sme_ReleaseGlobalLock( &pMac->sme );
7602 }
7603
7604 return (status);
7605}
7606/* ---------------------------------------------------------------------------
7607
7608 \fn sme_RoamUpdateAPWPARSNIEs
7609
7610 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
7611 This is an asynchronous API.
7612
7613 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
7614
7615 \return eHalStatus – SUCCESS –
7616
7617 FAILURE or RESOURCES – The API finished and failed.
7618
7619 -------------------------------------------------------------------------------*/
7620eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
7621{
7622
7623 eHalStatus status = eHAL_STATUS_FAILURE;
7624 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7625
7626 status = sme_AcquireGlobalLock( &pMac->sme );
7627 if ( HAL_STATUS_SUCCESS( status ) )
7628 {
7629
7630 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
7631
7632 sme_ReleaseGlobalLock( &pMac->sme );
7633 }
7634
7635 return (status);
7636}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007637/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07007638
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007639 \fn sme_ChangeMCCBeaconInterval
7640
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007641 \brief To update P2P-GO beaconInterval. This function should be called after
7642 disassociating all the station is done
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007643 This is an asynchronous API.
7644
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007645 \param
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007646
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007647 \return eHalStatus SUCCESS
7648 FAILURE or RESOURCES
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007649 The API finished and failed.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007650
7651 -------------------------------------------------------------------------------*/
7652eHalStatus sme_ChangeMCCBeaconInterval(tHalHandle hHal, tANI_U8 sessionId)
7653{
7654 eHalStatus status = eHAL_STATUS_FAILURE;
7655 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7656
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007657 smsLog(pMac, LOG1, FL("Update Beacon PARAMS "));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007658 status = sme_AcquireGlobalLock( &pMac->sme );
7659 if ( HAL_STATUS_SUCCESS( status ) )
7660 {
7661 status = csrSendChngMCCBeaconInterval( pMac, sessionId);
7662 sme_ReleaseGlobalLock( &pMac->sme );
7663 }
7664 return (status);
7665}
Jeff Johnson295189b2012-06-20 16:38:30 -07007666
7667/*-------------------------------------------------------------------------------*
7668
7669 \fn sme_sendBTAmpEvent
7670
7671 \brief to receive the coex priorty request from BT-AMP PAL
7672 and send the BT_AMP link state to HAL
7673
7674 \param btAmpEvent - btAmpEvent
7675
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007676 \return eHalStatus: SUCCESS : BTAmp event successfully sent to HAL
Jeff Johnson295189b2012-06-20 16:38:30 -07007677
7678 FAILURE: API failed
7679
7680-------------------------------------------------------------------------------*/
7681
7682eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
7683{
7684 vos_msg_t msg;
7685 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
7686 eHalStatus status = eHAL_STATUS_FAILURE;
7687
Leela Venkata Kiran Kumar Reddy Chiralaf7ea5432013-11-15 11:03:04 -08007688 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tSmeBtAmpEvent));
Jeff Johnson295189b2012-06-20 16:38:30 -07007689 if (NULL == ptrSmeBtAmpEvent)
7690 {
7691 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007692 "Not able to allocate memory for BTAmp event", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 return status;
7694 }
7695
7696 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
7697 msg.type = WDA_SIGNAL_BTAMP_EVENT;
7698 msg.reserved = 0;
7699 msg.bodyptr = ptrSmeBtAmpEvent;
7700
7701 //status = halFW_SendBTAmpEventMesg(pMac, event);
7702
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05307703 MTRACE(vos_trace(VOS_MODULE_ID_SME,
7704 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007705 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
7706 {
7707 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007708 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 vos_mem_free(ptrSmeBtAmpEvent);
7710 return status;
7711 }
7712
7713 return eHAL_STATUS_SUCCESS;
7714
7715}
7716
7717/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05307718 \fn smeIssueFastRoamNeighborAPEvent
7719 \brief API to trigger fast BSS roam independent of RSSI triggers
7720 \param hHal - The handle returned by macOpen.
7721 \param bssid - Pointer to the BSSID to roam to.
7722 \param fastRoamTrig - Trigger to Scan or roam
Mukul Sharma9e4e0f92015-02-13 18:45:20 +05307723 \param channel - channel number on which fastroam is requested
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05307724 \return eHalStatus
7725 ---------------------------------------------------------------------------*/
7726eHalStatus smeIssueFastRoamNeighborAPEvent (tHalHandle hHal,
7727 tANI_U8 *bssid,
Mukul Sharma9e4e0f92015-02-13 18:45:20 +05307728 tSmeFastRoamTrigger fastRoamTrig,
7729 tANI_U8 channel)
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05307730{
7731 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7732 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7733 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7734 eHalStatus status = eHAL_STATUS_SUCCESS;
7735
7736 status = sme_AcquireGlobalLock( &pMac->sme );
7737 if ( HAL_STATUS_SUCCESS( status ) )
7738 {
7739 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7740 "%s: invoked", __func__);
7741
7742 if (eSME_ROAM_TRIGGER_SCAN == fastRoamTrig)
7743 {
7744 smsLog(pMac, LOG1, FL("CFG Channel list scan... "));
7745 pNeighborRoamInfo->cfgRoamEn = eSME_ROAM_TRIGGER_SCAN;
7746 vos_mem_copy((void *)(&pNeighborRoamInfo->cfgRoambssId),
7747 (void *)bssid, sizeof(tSirMacAddr));
Mukul Sharma9e4e0f92015-02-13 18:45:20 +05307748 smsLog(pMac, LOG1, "Calling Roam Look Up down Event BSSID"
Arif Hussaina7c8e412013-11-20 11:06:42 -08007749 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pNeighborRoamInfo->cfgRoambssId));
Mukul Sharma9e4e0f92015-02-13 18:45:20 +05307750 /*
7751 * As FastReassoc is based on assumption that roamable AP should be
7752 * present into the occupied channel list.We shd add i/p channel
7753 * in occupied channel list if roamable-ap(BSSID in fastreassoc cmd)
7754 * aged out prior to connection and there is no scan from aged out
7755 * to till connection indication.
7756 */
7757 csrAddChannelToOccupiedChannelList(pMac, channel);
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05307758 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
7759 if (VOS_STATUS_SUCCESS != vosStatus)
7760 {
7761 smsLog(pMac, LOGE,
7762 FL("CFG Channel list scan state failed with status %d "),
7763 vosStatus);
7764 }
7765 }
7766 else if (eSME_ROAM_TRIGGER_FAST_ROAM == fastRoamTrig)
7767 {
7768 vos_mem_copy((void *)(&pNeighborRoamInfo->cfgRoambssId),
7769 (void *)bssid, sizeof(tSirMacAddr));
7770 pNeighborRoamInfo->cfgRoamEn = eSME_ROAM_TRIGGER_FAST_ROAM;
Arif Hussaina7c8e412013-11-20 11:06:42 -08007771 smsLog(pMac, LOG1, "Roam to BSSID "MAC_ADDRESS_STR,
7772 MAC_ADDR_ARRAY(pNeighborRoamInfo->cfgRoambssId));
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05307773
7774 vosStatus = csrNeighborRoamReassocIndCallback(pMac->roam.gVosContext,
7775 0,
7776 pMac,
7777 0);
7778
7779 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
7780 {
7781 smsLog(pMac,
7782 LOGE,
7783 FL(" Call to csrNeighborRoamReassocIndCallback failed, status = %d"),
7784 vosStatus);
7785 }
7786 }
7787 sme_ReleaseGlobalLock( &pMac->sme );
7788 }
7789 return vosStatus;
7790}
7791/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07007792 \fn sme_SetHostOffload
7793 \brief API to set the host offload feature.
7794 \param hHal - The handle returned by macOpen.
7795 \param pRequest - Pointer to the offload request.
7796 \return eHalStatus
7797 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007798eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07007799 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07007800{
7801 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07007802 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007803
Katya Nigambcb705f2013-12-26 14:26:22 +05307804 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007805 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7807 {
7808#ifdef WLAN_NS_OFFLOAD
7809 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
7810 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007811 status = pmcSetNSOffload( hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007812 }
7813 else
7814#endif //WLAN_NS_OFFLOAD
7815 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007816 status = pmcSetHostOffload (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007817 }
7818 sme_ReleaseGlobalLock( &pMac->sme );
7819 }
7820
7821 return (status);
7822}
7823
7824#ifdef WLAN_FEATURE_GTK_OFFLOAD
7825/* ---------------------------------------------------------------------------
7826 \fn sme_SetGTKOffload
7827 \brief API to set GTK offload information.
7828 \param hHal - The handle returned by macOpen.
7829 \param pRequest - Pointer to the GTK offload request.
7830 \return eHalStatus
7831 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007832eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007833 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007834{
7835 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7836 eHalStatus status;
7837
Katya Nigambcb705f2013-12-26 14:26:22 +05307838 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007839 TRACE_CODE_SME_RX_HDD_SET_GTKOFFLOAD, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7841 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007842 status = pmcSetGTKOffload( hHal, pRequest, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 sme_ReleaseGlobalLock( &pMac->sme );
7844 }
7845
7846 return (status);
7847}
7848
7849/* ---------------------------------------------------------------------------
7850 \fn sme_GetGTKOffload
7851 \brief API to get GTK offload information.
7852 \param hHal - The handle returned by macOpen.
7853 \param pRequest - Pointer to the GTK offload response.
7854 \return eHalStatus
7855 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007856eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007857 void *callbackContext, tANI_U8 sessionId )
Jeff Johnson295189b2012-06-20 16:38:30 -07007858{
7859 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7860 eHalStatus status;
7861
Katya Nigambcb705f2013-12-26 14:26:22 +05307862 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007863 TRACE_CODE_SME_RX_HDD_GET_GTKOFFLOAD, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7865 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007866 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 sme_ReleaseGlobalLock( &pMac->sme );
7868 }
7869
7870 return (status);
7871}
7872#endif // WLAN_FEATURE_GTK_OFFLOAD
7873
7874/* ---------------------------------------------------------------------------
7875 \fn sme_SetKeepAlive
7876 \brief API to set the Keep Alive feature.
7877 \param hHal - The handle returned by macOpen.
7878 \param pRequest - Pointer to the Keep Alive request.
7879 \return eHalStatus
7880 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007881eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07007882 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07007883{
7884 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7885 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007886 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7887 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007888 status = pmcSetKeepAlive (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007889 sme_ReleaseGlobalLock( &pMac->sme );
7890 }
7891
7892 return (status);
7893}
7894
7895#ifdef FEATURE_WLAN_SCAN_PNO
7896/* ---------------------------------------------------------------------------
7897 \fn sme_SetPreferredNetworkList
7898 \brief API to set the Preferred Network List Offload feature.
7899 \param hHal - The handle returned by macOpen.
7900 \param pRequest - Pointer to the offload request.
7901 \return eHalStatus
7902 ---------------------------------------------------------------------------*/
7903eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
7904{
7905 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7906 eHalStatus status;
7907
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +05307908 MTRACE(vos_trace(VOS_MODULE_ID_SME,
7909 TRACE_CODE_SME_RX_HDD_PREF_NET_LIST,
7910 sessionId, pRequest->ucNetworksCount));
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7912 {
7913 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
7914 sme_ReleaseGlobalLock( &pMac->sme );
7915 }
7916
7917 return (status);
7918}
7919
7920eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
7921{
7922 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7923 eHalStatus status;
7924
7925 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7926 {
7927 pmcSetRssiFilter(hHal, rssiThreshold);
7928 sme_ReleaseGlobalLock( &pMac->sme );
7929 }
7930
7931 return (status);
7932}
7933
7934#endif // FEATURE_WLAN_SCAN_PNO
7935
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007936eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams, tANI_BOOLEAN forced)
Jeff Johnson295189b2012-06-20 16:38:30 -07007937{
7938 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7939 eHalStatus status;
7940
Katya Nigambcb705f2013-12-26 14:26:22 +05307941 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007942 TRACE_CODE_SME_RX_HDD_SET_POWERPARAMS, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007943 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7944 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007945 pmcSetPowerParams(hHal, pwParams, forced);
Jeff Johnson295189b2012-06-20 16:38:30 -07007946 sme_ReleaseGlobalLock( &pMac->sme );
7947 }
7948
7949 return (status);
7950}
7951
7952/* ---------------------------------------------------------------------------
7953 \fn sme_AbortMacScan
7954 \brief API to cancel MAC scan.
7955 \param hHal - The handle returned by macOpen.
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307956 \param sessionId - sessionId on which we need to abort scan.
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307957 \param reason - Reason to abort the scan.
c_hpothua3d45d52015-01-05 14:11:17 +05307958 \return tSirAbortScanStatus Abort scan status
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 ---------------------------------------------------------------------------*/
c_hpothua3d45d52015-01-05 14:11:17 +05307960tSirAbortScanStatus sme_AbortMacScan(tHalHandle hHal, tANI_U8 sessionId,
7961 eCsrAbortReason reason)
Jeff Johnson295189b2012-06-20 16:38:30 -07007962{
c_hpothua3d45d52015-01-05 14:11:17 +05307963 tSirAbortScanStatus scanAbortStatus = eSIR_ABORT_SCAN_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007964 eHalStatus status;
7965 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7966
Katya Nigambcb705f2013-12-26 14:26:22 +05307967 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007968 TRACE_CODE_SME_RX_HDD_ABORT_MACSCAN, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 status = sme_AcquireGlobalLock( &pMac->sme );
7970 if ( HAL_STATUS_SUCCESS( status ) )
7971 {
c_hpothua3d45d52015-01-05 14:11:17 +05307972 scanAbortStatus = csrScanAbortMacScan(pMac, sessionId, reason);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007973
Jeff Johnson295189b2012-06-20 16:38:30 -07007974 sme_ReleaseGlobalLock( &pMac->sme );
7975 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007976
c_hpothua3d45d52015-01-05 14:11:17 +05307977 return ( scanAbortStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07007978}
7979
7980/* ----------------------------------------------------------------------------
7981 \fn sme_GetOperationChannel
7982 \brief API to get current channel on which STA is parked
7983 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007984 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07007985 \returns eHAL_STATUS_SUCCESS
7986 eHAL_STATUS_FAILURE
7987-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007988eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007989{
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7991 tCsrRoamSession *pSession;
7992
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007993 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007994 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007995 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007996
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007997 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007998 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007999 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008000 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
8001 {
8002 *pChannel =pSession->connectedProfile.operationChannel;
8003 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008004 }
8005 }
8006 return eHAL_STATUS_FAILURE;
8007}// sme_GetOperationChannel ends here
8008
Abhishek Singh7d624e12015-11-30 14:29:27 +05308009/**
8010 * sme_register_mgmt_frame_ind_callback() - Register a callback for
8011 * management frame indication to PE.
8012 * @hHal: hal pointer
8013 * @callback: callback pointer to be registered
8014 *
8015 * This function is used to register a callback for management
8016 * frame indication to PE.
8017 *
8018 * Return: Success if msg is posted to PE else Failure.
8019 */
8020eHalStatus sme_register_mgmt_frame_ind_callback(tHalHandle hHal,
8021 sir_mgmt_frame_ind_callback callback)
8022{
8023 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8024 struct sir_sme_mgmt_frame_cb_req *msg;
8025 eHalStatus status = eHAL_STATUS_SUCCESS;
8026
8027 smsLog(pMac, LOG1, FL(": ENTER"));
8028
8029 if (eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock(&pMac->sme))
8030 {
8031 msg = vos_mem_malloc(sizeof(*msg));
8032 if (NULL == msg)
8033 {
8034 smsLog(pMac, LOGE,
8035 FL("Not able to allocate memory for eWNI_SME_REGISTER_MGMT_FRAME_CB"));
8036 sme_ReleaseGlobalLock( &pMac->sme );
8037 return eHAL_STATUS_FAILURE;
8038 }
8039 vos_mem_set(msg, sizeof(*msg), 0);
8040 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
8041 msg->length = sizeof(*msg);
8042
8043 msg->callback = callback;
8044 status = palSendMBMessage(pMac->hHdd, msg);
8045 sme_ReleaseGlobalLock( &pMac->sme );
8046 return status;
8047 }
8048 return eHAL_STATUS_FAILURE;
8049}
8050
Jeff Johnson295189b2012-06-20 16:38:30 -07008051/* ---------------------------------------------------------------------------
8052
8053 \fn sme_RegisterMgtFrame
8054
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008055 \brief To register managment frame of specified type and subtype.
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 \param frameType - type of the frame that needs to be passed to HDD.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008057 \param matchData - data which needs to be matched before passing frame
8058 to HDD.
Jeff Johnson295189b2012-06-20 16:38:30 -07008059 \param matchDataLen - Length of matched data.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008060 \return eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 -------------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008062eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008063 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
8064{
8065 eHalStatus status = eHAL_STATUS_SUCCESS;
8066 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8067
Katya Nigambcb705f2013-12-26 14:26:22 +05308068 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008069 TRACE_CODE_SME_RX_HDD_REGISTER_MGMTFR, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008070 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8071 {
8072 tSirRegisterMgmtFrame *pMsg;
8073 tANI_U16 len;
8074 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008075
8076 if(!pSession)
8077 {
8078 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08008079 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008080 return eHAL_STATUS_FAILURE;
8081 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008082
Jeff Johnson295189b2012-06-20 16:38:30 -07008083 if( !pSession->sessionActive )
8084 {
8085 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008086 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 sme_ReleaseGlobalLock( &pMac->sme );
8088 return eHAL_STATUS_FAILURE;
8089 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008090
Jeff Johnson295189b2012-06-20 16:38:30 -07008091 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
8092
Kiet Lam64c1b492013-07-12 13:56:44 +05308093 pMsg = vos_mem_malloc(len);
8094 if ( NULL == pMsg )
8095 status = eHAL_STATUS_FAILURE;
8096 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308098 vos_mem_set(pMsg, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008099 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
8100 pMsg->length = len;
8101 pMsg->sessionId = sessionId;
8102 pMsg->registerFrame = VOS_TRUE;
8103 pMsg->frameType = frameType;
8104 pMsg->matchLen = matchLen;
Kiet Lam64c1b492013-07-12 13:56:44 +05308105 vos_mem_copy(pMsg->matchData, matchData, matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 status = palSendMBMessage(pMac->hHdd, pMsg);
8107 }
8108 sme_ReleaseGlobalLock( &pMac->sme );
8109 }
8110 return status;
8111}
8112
8113/* ---------------------------------------------------------------------------
8114
8115 \fn sme_DeregisterMgtFrame
8116
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008117 \brief To De-register managment frame of specified type and subtype.
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 \param frameType - type of the frame that needs to be passed to HDD.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008119 \param matchData - data which needs to be matched before passing frame
8120 to HDD.
Jeff Johnson295189b2012-06-20 16:38:30 -07008121 \param matchDataLen - Length of matched data.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008122 \return eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -07008123 -------------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008124eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
8126{
8127 eHalStatus status = eHAL_STATUS_SUCCESS;
8128 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8129
Katya Nigambcb705f2013-12-26 14:26:22 +05308130 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008131 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008132 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8133 {
8134 tSirRegisterMgmtFrame *pMsg;
8135 tANI_U16 len;
8136 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008137
8138 if(!pSession)
8139 {
8140 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08008141 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008142 return eHAL_STATUS_FAILURE;
8143 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008144
8145 if( !pSession->sessionActive )
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 {
8147 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008148 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008149 sme_ReleaseGlobalLock( &pMac->sme );
8150 return eHAL_STATUS_FAILURE;
8151 }
8152
8153 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
8154
Kiet Lam64c1b492013-07-12 13:56:44 +05308155 pMsg = vos_mem_malloc(len);
8156 if ( NULL == pMsg )
8157 status = eHAL_STATUS_FAILURE;
8158 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008159 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308160 vos_mem_set(pMsg, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008162 pMsg->length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07008163 pMsg->registerFrame = VOS_FALSE;
8164 pMsg->frameType = frameType;
8165 pMsg->matchLen = matchLen;
Kiet Lam64c1b492013-07-12 13:56:44 +05308166 vos_mem_copy(pMsg->matchData, matchData, matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 status = palSendMBMessage(pMac->hHdd, pMsg);
8168 }
8169 sme_ReleaseGlobalLock( &pMac->sme );
8170 }
8171 return status;
8172}
8173
8174/* ---------------------------------------------------------------------------
8175 \fn sme_RemainOnChannel
8176 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
8177 \param hHal - The handle returned by macOpen.
8178 \param pRequest - channel
8179 \param duration - duration in ms
8180 \param callback - HDD registered callback to process reaminOnChannelRsp
8181 \param context - HDD Callback param
8182 \return eHalStatus
8183 ---------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008184eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
8185 tANI_U8 channel, tANI_U32 duration,
Gopichand Nakkala924e4552013-05-08 19:18:14 +05308186 remainOnChanCallback callback,
8187 void *pContext,
8188 tANI_U8 isP2PProbeReqAllowed)
Jeff Johnson295189b2012-06-20 16:38:30 -07008189{
8190 eHalStatus status = eHAL_STATUS_SUCCESS;
8191 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8192
Katya Nigambcb705f2013-12-26 14:26:22 +05308193 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008194 TRACE_CODE_SME_RX_HDD_REMAIN_ONCHAN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008195 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8196 {
Gopichand Nakkala924e4552013-05-08 19:18:14 +05308197 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext,
8198 isP2PProbeReqAllowed
Jeff Johnson295189b2012-06-20 16:38:30 -07008199#ifdef WLAN_FEATURE_P2P_INTERNAL
8200 , eP2PRemainOnChnReasonUnknown
8201#endif
8202 );
8203 sme_ReleaseGlobalLock( &pMac->sme );
8204 }
8205 return(status);
8206}
8207
8208/* ---------------------------------------------------------------------------
8209 \fn sme_ReportProbeReq
8210 \brief API to enable/disable forwarding of probeReq to apps in p2p.
8211 \param hHal - The handle returned by macOpen.
8212 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
8213 \return eHalStatus
8214 ---------------------------------------------------------------------------*/
8215
8216#ifndef WLAN_FEATURE_CONCURRENT_P2P
8217eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
8218{
8219 eHalStatus status = eHAL_STATUS_SUCCESS;
8220 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8221
8222 do
8223 {
8224 //acquire the lock for the sme object
8225 status = sme_AcquireGlobalLock(&pMac->sme);
8226 if(HAL_STATUS_SUCCESS(status))
8227 {
8228 /* call set in context */
8229 pMac->p2pContext.probeReqForwarding = flag;
8230 //release the lock for the sme object
8231 sme_ReleaseGlobalLock( &pMac->sme );
8232 }
8233 } while(0);
8234
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008235 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008236
8237 return(status);
8238}
8239
8240/* ---------------------------------------------------------------------------
8241 \fn sme_updateP2pIe
8242 \brief API to set the P2p Ie in p2p context
8243 \param hHal - The handle returned by macOpen.
8244 \param p2pIe - Ptr to p2pIe from HDD.
8245 \param p2pIeLength: length of p2pIe
8246 \return eHalStatus
8247 ---------------------------------------------------------------------------*/
8248
8249eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
8250{
8251 eHalStatus status = eHAL_STATUS_SUCCESS;
8252 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8253
8254 //acquire the lock for the sme object
8255 status = sme_AcquireGlobalLock(&pMac->sme);
8256 if(HAL_STATUS_SUCCESS(status))
8257 {
8258 if(NULL != pMac->p2pContext.probeRspIe){
8259 vos_mem_free(pMac->p2pContext.probeRspIe);
8260 pMac->p2pContext.probeRspIeLength = 0;
8261 }
8262
8263 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
8264 if (NULL == pMac->p2pContext.probeRspIe)
8265 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008266 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 pMac->p2pContext.probeRspIeLength = 0;
8268 status = eHAL_STATUS_FAILURE;
8269 }
8270 else
8271 {
8272 pMac->p2pContext.probeRspIeLength = p2pIeLength;
8273
8274 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
8275 pMac->p2pContext.probeRspIe,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008276 pMac->p2pContext.probeRspIeLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008277 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
8278 p2pIeLength);
8279 }
8280
8281 //release the lock for the sme object
8282 sme_ReleaseGlobalLock( &pMac->sme );
8283 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008284
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008285 smsLog(pMac, LOG2, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008286
8287 return(status);
8288}
8289#endif
8290
8291/* ---------------------------------------------------------------------------
8292 \fn sme_sendAction
8293 \brief API to send action frame from supplicant.
8294 \param hHal - The handle returned by macOpen.
8295 \return eHalStatus
8296 ---------------------------------------------------------------------------*/
8297
8298eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07008299 const tANI_U8 *pBuf, tANI_U32 len,
8300 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07008301{
8302 eHalStatus status = eHAL_STATUS_SUCCESS;
8303 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8304
Katya Nigambcb705f2013-12-26 14:26:22 +05308305 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008306 TRACE_CODE_SME_RX_HDD_SEND_ACTION, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 //acquire the lock for the sme object
8308 status = sme_AcquireGlobalLock(&pMac->sme);
8309 if(HAL_STATUS_SUCCESS(status))
8310 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008311 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 //release the lock for the sme object
8313 sme_ReleaseGlobalLock( &pMac->sme );
8314 }
8315
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008316 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008317
8318 return(status);
8319}
8320
8321eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
8322{
8323 eHalStatus status = eHAL_STATUS_SUCCESS;
8324 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8325
Katya Nigambcb705f2013-12-26 14:26:22 +05308326 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008327 TRACE_CODE_SME_RX_HDD_CANCEL_REMAIN_ONCHAN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008328 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8329 {
8330 status = p2pCancelRemainOnChannel (hHal, sessionId);
8331 sme_ReleaseGlobalLock( &pMac->sme );
8332 }
8333 return(status);
8334}
8335
8336//Power Save Related
8337eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
8338{
8339 eHalStatus status = eHAL_STATUS_SUCCESS;
8340 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8341
8342 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8343 {
8344 status = p2pSetPs (hHal, data);
8345 sme_ReleaseGlobalLock( &pMac->sme );
8346 }
8347 return(status);
8348}
8349
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308350/* ---------------------------------------------------------------------------
Siddharth Bhal64246172015-02-27 01:04:37 +05308351 \fn sme_GetFramesLog
8352 \brief a wrapper function that client calls to register a callback to get
8353 mgmt frames logged
Siddharth Bhal64246172015-02-27 01:04:37 +05308354 \param flag - flag tells to clear OR send the frame log buffer
Siddharth Bhal64246172015-02-27 01:04:37 +05308355 \return eHalStatus
8356 ---------------------------------------------------------------------------*/
Abhishek Singh611295e2015-07-09 11:11:54 +05308357eHalStatus sme_GetFramesLog(tHalHandle hHal, tANI_U8 flag)
Siddharth Bhal64246172015-02-27 01:04:37 +05308358{
8359 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8360 eHalStatus status = eHAL_STATUS_SUCCESS;
8361 tSmeCmd *pGetFrameLogCmd;
8362
mukul sharmaca8e4322015-07-20 18:33:43 +05308363 status = sme_AcquireGlobalLock( &pMac->sme );
8364 if ( HAL_STATUS_SUCCESS( status ) )
8365 {
8366 pGetFrameLogCmd = csrGetCommandBuffer(pMac);
8367 if (pGetFrameLogCmd)
Siddharth Bhal64246172015-02-27 01:04:37 +05308368 {
mukul sharmaca8e4322015-07-20 18:33:43 +05308369 pGetFrameLogCmd->command = eSmeCommandGetFrameLogRequest;
8370 pGetFrameLogCmd->u.getFramelogCmd.getFrameLogCmdFlag= flag;
Siddharth Bhal64246172015-02-27 01:04:37 +05308371
mukul sharmaca8e4322015-07-20 18:33:43 +05308372 status = csrQueueSmeCommand(pMac, pGetFrameLogCmd, eANI_BOOLEAN_TRUE);
8373 if ( !HAL_STATUS_SUCCESS( status ) )
8374 {
8375 smsLog( pMac, LOGE, FL("fail to send msg status = %d\n"), status );
8376 csrReleaseCommandScan(pMac, pGetFrameLogCmd);
8377 }
8378 }
8379 else
8380 {
8381 //log error
8382 smsLog(pMac, LOGE, FL("can not obtain a common buffer\n"));
8383 status = eHAL_STATUS_RESOURCES;
8384 }
8385 sme_ReleaseGlobalLock( &pMac->sme);
8386 }
Siddharth Bhal64246172015-02-27 01:04:37 +05308387 return (status);
8388}
8389
8390/* ---------------------------------------------------------------------------
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308391
8392 \fn sme_InitMgmtFrameLogging
8393
8394 \brief
8395 SME will pass this request to lower mac to initialize Frame Logging.
8396
8397 \param
8398
8399 hHal - The handle returned by macOpen.
8400
Siddharth Bhald1be97f2015-05-27 22:39:59 +05308401 wlanFWLoggingInitParam - Params to initialize frame logging
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308402
8403 \return eHalStatus
8404
8405
8406--------------------------------------------------------------------------- */
8407eHalStatus sme_InitMgmtFrameLogging( tHalHandle hHal,
Siddharth Bhald1be97f2015-05-27 22:39:59 +05308408 tSirFWLoggingInitParam *wlanFWLoggingInitParam)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308409{
8410 eHalStatus status = eHAL_STATUS_SUCCESS;
8411 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8412 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8413 vos_msg_t vosMessage;
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05308414 tpSirFWLoggingInitParam msg;
8415
8416 msg = vos_mem_malloc(sizeof(tSirFWLoggingInitParam));
8417
8418 if (NULL == msg)
8419 {
8420 smsLog(pMac, LOGE, FL("Failed to alloc mem of size %zu for msg"),
8421 sizeof(*msg));
8422 return eHAL_STATUS_FAILED_ALLOC;
8423 }
8424 *msg = *wlanFWLoggingInitParam;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308425
8426 if ( eHAL_STATUS_SUCCESS == ( status =
8427 sme_AcquireGlobalLock( &pMac->sme ) ) )
8428 {
8429 /* serialize the req through MC thread */
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05308430 vosMessage.bodyptr = msg;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308431 vosMessage.type = WDA_MGMT_LOGGING_INIT_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05308432 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8433 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308434 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8435 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8436 {
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05308437 vos_mem_free(msg);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308438 status = eHAL_STATUS_FAILURE;
8439 }
8440 sme_ReleaseGlobalLock( &pMac->sme );
8441 }
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05308442 else
8443 {
8444 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock error"));
8445 vos_mem_free(msg);
8446 }
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308447 return(status);
8448}
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308449/* ---------------------------------------------------------------------------
8450
8451 \fn sme_StartRssiMonitoring
8452
8453 \brief
8454 SME will pass this request to lower mac to start monitoring rssi range on
8455 a bssid.
8456
8457 \param
8458
8459 hHal - The handle returned by macOpen.
8460
8461 tSirRssiMonitorReq req- depict the monitor req params.
8462
8463 \return eHalStatus
8464
8465--------------------------------------------------------------------------- */
8466eHalStatus sme_StartRssiMonitoring( tHalHandle hHal,
8467 tSirRssiMonitorReq *req)
8468{
8469 eHalStatus status = eHAL_STATUS_SUCCESS;
8470 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8471 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8472 vos_msg_t vosMessage;
8473
8474 if ( eHAL_STATUS_SUCCESS == ( status =
8475 sme_AcquireGlobalLock( &pMac->sme ) ) )
8476 {
8477 /* serialize the req through MC thread */
8478 vosMessage.bodyptr = req;
8479 vosMessage.type = WDA_START_RSSI_MONITOR_REQ;
8480 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8481 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
8482 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8483 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8484 {
8485 status = eHAL_STATUS_FAILURE;
8486 }
8487 sme_ReleaseGlobalLock( &pMac->sme );
8488 }
8489 return(status);
8490}
8491
8492/* ---------------------------------------------------------------------------
8493
8494 \fn sme_StopRssiMonitoring
8495
8496 \brief
8497 SME will pass this request to lower mac to stop monitoring rssi range on
8498 a bssid.
8499
8500 \param
8501
8502 hHal - The handle returned by macOpen.
8503
8504 tSirRssiMonitorReq req- depict the monitor req params.
8505
8506 \return eHalStatus
8507
8508--------------------------------------------------------------------------- */
8509eHalStatus sme_StopRssiMonitoring(tHalHandle hHal,
8510 tSirRssiMonitorReq *req)
8511{
8512 eHalStatus status = eHAL_STATUS_SUCCESS;
8513 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8514 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8515 vos_msg_t vosMessage;
8516
8517 if ( eHAL_STATUS_SUCCESS == ( status =
8518 sme_AcquireGlobalLock( &pMac->sme ) ) )
8519 {
8520 /* serialize the req through MC thread */
8521 vosMessage.bodyptr = req;
8522 vosMessage.type = WDA_STOP_RSSI_MONITOR_REQ;
8523 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8524 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
8525 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8526 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8527 {
8528 status = eHAL_STATUS_FAILURE;
8529 }
8530 sme_ReleaseGlobalLock( &pMac->sme );
8531 }
8532 return(status);
8533}
Jeff Johnson295189b2012-06-20 16:38:30 -07008534
8535/* ---------------------------------------------------------------------------
8536
8537 \fn sme_ConfigureRxpFilter
8538
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008539 \brief
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 SME will pass this request to lower mac to set/reset the filter on RXP for
8541 multicast & broadcast traffic.
8542
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008543 \param
Jeff Johnson295189b2012-06-20 16:38:30 -07008544
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008545 hHal - The handle returned by macOpen.
8546
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
8548 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
8549 on this param. In future we can use this as a mask to set various types of
8550 filters as suggested below:
8551 FILTER_ALL_MULTICAST:
8552 FILTER_ALL_BROADCAST:
8553 FILTER_ALL_MULTICAST_BROADCAST:
8554
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008555
8556 \return eHalStatus
8557
8558
Jeff Johnson295189b2012-06-20 16:38:30 -07008559--------------------------------------------------------------------------- */
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008560eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07008561 tpSirWlanSetRxpFilters wlanRxpFilterParam)
8562{
8563 eHalStatus status = eHAL_STATUS_SUCCESS;
8564 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8565 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8566 vos_msg_t vosMessage;
8567
Katya Nigambcb705f2013-12-26 14:26:22 +05308568 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008569 TRACE_CODE_SME_RX_HDD_CONFIG_RXPFIL, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008570 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8571 {
8572 /* serialize the req through MC thread */
8573 vosMessage.bodyptr = wlanRxpFilterParam;
8574 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05308575 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8576 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8578 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8579 {
8580 status = eHAL_STATUS_FAILURE;
8581 }
8582 sme_ReleaseGlobalLock( &pMac->sme );
8583 }
8584 return(status);
8585}
8586
Jeff Johnson295189b2012-06-20 16:38:30 -07008587/* ---------------------------------------------------------------------------
8588
mukul sharma6b53e202016-11-23 19:29:18 +05308589 \fn sme_update_hal_int_param
8590
8591 \brief
8592 SME will pass this request to lower mac to indicate that the host needs to
8593 update the cfg item
8594
8595 \param
8596
8597 hHal - The handle returned by macOpen.
8598
8599 cfg_id- cfg param id
8600
8601
8602 \return eHalStatus
8603
8604
8605--------------------------------------------------------------------------- */
8606
8607eHalStatus sme_update_cfg_int_param(tHalHandle hHal,
8608 tANI_U32 cfg_id)
8609{
8610 eHalStatus status = eHAL_STATUS_SUCCESS;
8611 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8612 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8613 vos_msg_t vosMessage;
8614 tpSirUpdateCfgIntParam updateCfgIntParam =
8615 vos_mem_malloc(sizeof(tSirUpdateCfgIntParam));
8616
8617 if (updateCfgIntParam == NULL)
8618 {
8619 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8620 "%s: vos_mem_alloc for updateCfgIntParam", __func__);
8621 return eHAL_STATUS_FAILURE;
8622 }
8623
8624 updateCfgIntParam->cfgId = cfg_id;
8625 /*
8626 * This API expect user must have updated cfg item using cfg API's.
8627 * Hence it just need the cfg param id not the cfg value.
8628 */
8629 status = sme_AcquireGlobalLock(&pMac->sme);
8630 if (eHAL_STATUS_SUCCESS == status)
8631 {
8632 /* serialize the req through MC thread */
8633 vosMessage.bodyptr = updateCfgIntParam;
8634 vosMessage.type = WDA_UPDATE_CFG_INT_PARAM;
8635 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
8636 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8637 {
8638 status = eHAL_STATUS_FAILURE;
8639 vos_mem_free(updateCfgIntParam);
8640 }
8641 sme_ReleaseGlobalLock(&pMac->sme);
8642 }
8643 else
8644 {
8645 status = eHAL_STATUS_FAILURE;
8646 vos_mem_free(updateCfgIntParam);
8647 }
8648 return(status);
8649}
8650
8651/* ---------------------------------------------------------------------------
8652
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 \fn sme_ConfigureSuspendInd
8654
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008655 \brief
8656 SME will pass this request to lower mac to Indicate that the wlan needs to
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 be suspended
8658
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008659 \param
Jeff Johnson295189b2012-06-20 16:38:30 -07008660
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008661 hHal - The handle returned by macOpen.
8662
Jeff Johnson295189b2012-06-20 16:38:30 -07008663 wlanSuspendParam- Depicts the wlan suspend params
8664
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008665
8666 \return eHalStatus
8667
8668
Jeff Johnson295189b2012-06-20 16:38:30 -07008669--------------------------------------------------------------------------- */
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008670eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07008671 tpSirWlanSuspendParam wlanSuspendParam)
8672{
8673 eHalStatus status = eHAL_STATUS_SUCCESS;
8674 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8675 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8676 vos_msg_t vosMessage;
8677
Katya Nigambcb705f2013-12-26 14:26:22 +05308678 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008679 TRACE_CODE_SME_RX_HDD_CONFIG_SUSPENDIND, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008680 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8681 {
8682 /* serialize the req through MC thread */
8683 vosMessage.bodyptr = wlanSuspendParam;
8684 vosMessage.type = WDA_WLAN_SUSPEND_IND;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05308685 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8686 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8688 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8689 {
8690 status = eHAL_STATUS_FAILURE;
8691 }
8692 sme_ReleaseGlobalLock( &pMac->sme );
8693 }
8694 return(status);
8695}
8696
8697/* ---------------------------------------------------------------------------
8698
8699 \fn sme_ConfigureResumeReq
8700
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008701 \brief
8702 SME will pass this request to lower mac to Indicate that the wlan needs to
Jeff Johnson295189b2012-06-20 16:38:30 -07008703 be Resumed
8704
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008705 \param
Jeff Johnson295189b2012-06-20 16:38:30 -07008706
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008707 hHal - The handle returned by macOpen.
8708
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 wlanResumeParam- Depicts the wlan resume params
8710
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008711
8712 \return eHalStatus
8713
8714
Jeff Johnson295189b2012-06-20 16:38:30 -07008715--------------------------------------------------------------------------- */
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008716eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07008717 tpSirWlanResumeParam wlanResumeParam)
8718{
8719 eHalStatus status = eHAL_STATUS_SUCCESS;
8720 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8721 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8722 vos_msg_t vosMessage;
8723
Katya Nigambcb705f2013-12-26 14:26:22 +05308724 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008725 TRACE_CODE_SME_RX_HDD_CONFIG_RESUMEREQ, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8727 {
8728 /* serialize the req through MC thread */
8729 vosMessage.bodyptr = wlanResumeParam;
8730 vosMessage.type = WDA_WLAN_RESUME_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05308731 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8732 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07008733 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8734 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8735 {
8736 status = eHAL_STATUS_FAILURE;
8737 }
8738 sme_ReleaseGlobalLock( &pMac->sme );
8739 }
8740 return(status);
8741}
8742
Jeff Johnson295189b2012-06-20 16:38:30 -07008743/* ---------------------------------------------------------------------------
8744
8745 \fn sme_GetInfraSessionId
8746
8747 \brief To get the session ID for infra session, if connected
8748 This is a synchronous API.
8749
8750 \param hHal - The handle returned by macOpen.
8751
8752 \return sessionid, -1 if infra session is not connected
8753
8754 -------------------------------------------------------------------------------*/
8755tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
8756{
8757 eHalStatus status = eHAL_STATUS_FAILURE;
8758 tANI_S8 sessionid = -1;
8759 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008760
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 status = sme_AcquireGlobalLock( &pMac->sme );
8762 if ( HAL_STATUS_SUCCESS( status ) )
8763 {
8764
8765 sessionid = csrGetInfraSessionId( pMac);
8766
8767 sme_ReleaseGlobalLock( &pMac->sme );
8768 }
8769
8770 return (sessionid);
8771}
8772
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +05308773tANI_U32 sme_get_sessionid_from_activeList(tpAniSirGlobal mac)
8774{
8775 tListElem *entry = NULL;
8776 tSmeCmd *command = NULL;
8777 tANI_U32 session_id = 0;
8778
8779 entry = csrLLPeekHead( &mac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8780 if ( entry ) {
8781 command = GET_BASE_ADDR( entry, tSmeCmd, Link );
8782 session_id = command->sessionId;
8783 }
8784
8785 return (session_id);
8786}
8787
Jeff Johnson295189b2012-06-20 16:38:30 -07008788/* ---------------------------------------------------------------------------
8789
8790 \fn sme_GetInfraOperationChannel
8791
8792 \brief To get the operating channel for infra session, if connected
8793 This is a synchronous API.
8794
8795 \param hHal - The handle returned by macOpen.
8796 \param sessionId - the sessionId returned by sme_OpenSession.
8797
8798 \return operating channel, 0 if infra session is not connected
8799
8800 -------------------------------------------------------------------------------*/
8801tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
8802{
8803 eHalStatus status = eHAL_STATUS_FAILURE;
8804 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8805 tANI_U8 channel = 0;
8806 status = sme_AcquireGlobalLock( &pMac->sme );
8807 if ( HAL_STATUS_SUCCESS( status ) )
8808 {
8809
8810 channel = csrGetInfraOperationChannel( pMac, sessionId);
8811
8812 sme_ReleaseGlobalLock( &pMac->sme );
8813 }
8814
8815 return (channel);
8816}
8817
8818//This routine will return poerating channel on which other BSS is operating to be used for concurrency mode.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008819//If other BSS is not up or not connected it will return 0
Jeff Johnson295189b2012-06-20 16:38:30 -07008820tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
8821{
8822 eHalStatus status = eHAL_STATUS_FAILURE;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008823 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 tANI_U8 channel = 0;
8825 status = sme_AcquireGlobalLock( &pMac->sme );
8826 if ( HAL_STATUS_SUCCESS( status ) )
8827 {
8828
8829 channel = csrGetConcurrentOperationChannel( pMac );
8830 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008831 " Other Concurrent Channel = %d", __func__,channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07008832 sme_ReleaseGlobalLock( &pMac->sme );
8833 }
8834
8835 return (channel);
8836}
8837
8838#ifdef FEATURE_WLAN_SCAN_PNO
8839/******************************************************************************
8840*
8841* Name: sme_PreferredNetworkFoundInd
8842*
8843* Description:
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008844* Invoke Preferred Network Found Indication
Jeff Johnson295189b2012-06-20 16:38:30 -07008845*
8846* Parameters:
8847* hHal - HAL handle for device
8848* pMsg - found network description
8849*
8850* Returns: eHalStatus
8851*
8852******************************************************************************/
8853eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
8854{
8855 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8856 eHalStatus status = eHAL_STATUS_SUCCESS;
8857 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
Srikant Kuppa066904f2013-05-07 13:56:02 -07008858 v_U8_t dumpSsId[SIR_MAC_MAX_SSID_LENGTH + 1];
8859 tANI_U8 ssIdLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008860
8861 if (NULL == pMsg)
8862 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008863 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008864 status = eHAL_STATUS_FAILURE;
8865 }
8866 else
8867 {
8868 if (pPrefNetworkFoundInd->ssId.length > 0)
8869 {
Srikant Kuppa066904f2013-05-07 13:56:02 -07008870 ssIdLength = CSR_MIN(SIR_MAC_MAX_SSID_LENGTH,
8871 pPrefNetworkFoundInd->ssId.length);
8872 vos_mem_copy(dumpSsId, pPrefNetworkFoundInd->ssId.ssId, ssIdLength);
8873 dumpSsId[ssIdLength] = 0;
Abhishek Singh195c03e2014-05-14 17:21:30 +05308874 smsLog(pMac, LOG1, FL(" SSID=%s frame length %d"),
8875 dumpSsId, pPrefNetworkFoundInd->frameLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008876
Vinay Krishna Erannab13043b2013-12-06 11:50:21 +05308877 /* Flush scan results, So as to avoid indication/updation of
8878 * stale entries, which may not have aged out during APPS collapse
8879 */
8880 sme_ScanFlushResult(hHal,0);
8881
Srikant Kuppa066904f2013-05-07 13:56:02 -07008882 //Save the frame to scan result
8883 if (pPrefNetworkFoundInd->mesgLen > sizeof(tSirPrefNetworkFoundInd))
8884 {
8885 //we may have a frame
8886 status = csrScanSavePreferredNetworkFound(pMac,
8887 pPrefNetworkFoundInd);
8888 if (!HAL_STATUS_SUCCESS(status))
8889 {
8890 smsLog(pMac, LOGE, FL(" fail to save preferred network"));
8891 }
8892 }
8893 else
8894 {
Jeff Johnsonafeb9582013-11-22 18:39:00 -08008895 smsLog(pMac, LOGE, FL(" not enough data length %u needed %zu"),
Srikant Kuppa066904f2013-05-07 13:56:02 -07008896 pPrefNetworkFoundInd->mesgLen, sizeof(tSirPrefNetworkFoundInd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008897 }
8898
Srikant Kuppa066904f2013-05-07 13:56:02 -07008899 /* Call Preferred Netowrk Found Indication callback routine. */
8900 if (HAL_STATUS_SUCCESS(status) && (pMac->pmc.prefNetwFoundCB != NULL))
8901 {
8902 pMac->pmc.prefNetwFoundCB(
8903 pMac->pmc.preferredNetworkFoundIndCallbackContext,
8904 pPrefNetworkFoundInd);
8905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008906 }
8907 else
8908 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008909 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 status = eHAL_STATUS_FAILURE;
8911 }
8912 }
8913
8914
8915 return(status);
8916}
8917
8918#endif // FEATURE_WLAN_SCAN_PNO
8919
8920
8921eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
8922{
8923 eHalStatus status = eHAL_STATUS_FAILURE;
8924 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008925
Jeff Johnson295189b2012-06-20 16:38:30 -07008926 status = sme_AcquireGlobalLock( &pMac->sme );
8927 if ( HAL_STATUS_SUCCESS( status ) )
8928 {
8929 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
8930 sme_ReleaseGlobalLock( &pMac->sme );
8931 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008932
Jeff Johnson295189b2012-06-20 16:38:30 -07008933 return (status);
8934}
8935
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05308936eHalStatus sme_SetCfgScanControlList(tHalHandle hHal, tANI_U8 *countryCode, tCsrChannel *pChannelList)
8937{
8938 eHalStatus status = eHAL_STATUS_SUCCESS;
8939 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8940
8941 status = sme_AcquireGlobalLock( &pMac->sme );
8942 if ( HAL_STATUS_SUCCESS( status ) )
8943 {
8944 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
8945 sme_ReleaseGlobalLock( &pMac->sme );
8946 }
8947
8948 return (status);
8949}
Jeff Johnson295189b2012-06-20 16:38:30 -07008950
8951/* ---------------------------------------------------------------------------
8952
8953 \fn sme_SetTxPerTracking
8954
8955 \brief Set Tx PER tracking configuration parameters
8956
8957 \param hHal - The handle returned by macOpen.
8958 \param pTxPerTrackingConf - Tx PER configuration parameters
8959
8960 \return eHalStatus
8961
8962 -------------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008963eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
8964 void (*pCallbackfn) (void *pCallbackContext),
Jeff Johnson295189b2012-06-20 16:38:30 -07008965 void *pCallbackContext,
8966 tpSirTxPerTrackingParam pTxPerTrackingParam)
8967{
8968 vos_msg_t msg;
8969 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
8970 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8971
8972 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
8973 {
8974 pMac->sme.pTxPerHitCallback = pCallbackfn;
8975 pMac->sme.pTxPerHitCbContext = pCallbackContext;
8976 sme_ReleaseGlobalLock( &pMac->sme );
8977 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008978
Jeff Johnson295189b2012-06-20 16:38:30 -07008979 // free this memory in failure case or WDA request callback function
8980 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
8981 if (NULL == pTxPerTrackingParamReq)
8982 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008983 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 -07008984 return eHAL_STATUS_FAILURE;
8985 }
8986
Kiet Lam64c1b492013-07-12 13:56:44 +05308987 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam,
8988 sizeof(tSirTxPerTrackingParam));
Jeff Johnson295189b2012-06-20 16:38:30 -07008989 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
8990 msg.reserved = 0;
8991 msg.bodyptr = pTxPerTrackingParamReq;
8992
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05308993 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8994 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07008995 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
8996 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008997 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 -07008998 vos_mem_free(pTxPerTrackingParamReq);
8999 return eHAL_STATUS_FAILURE;
9000 }
9001
9002 return eHAL_STATUS_SUCCESS;
9003}
9004
9005/* ---------------------------------------------------------------------------
9006
9007 \fn sme_HandleChangeCountryCode
9008
9009 \brief Change Country code, Reg Domain and channel list
9010
9011 \details Country Code Priority
9012 0 = 11D > Configured Country > NV
9013 1 = Configured Country > 11D > NV
9014 If Supplicant country code is priority than 11d is disabled.
9015 If 11D is enabled, we update the country code after every scan.
9016 Hence when Supplicant country code is priority, we don't need 11D info.
9017 Country code from Supplicant is set as current courtry code.
9018 User can send reset command XX (instead of country code) to reset the
9019 country code to default values which is read from NV.
9020 In case of reset, 11D is enabled and default NV code is Set as current country code
9021 If 11D is priority,
9022 Than Supplicant country code code is set to default code. But 11D code is set as current country code
9023
9024 \param pMac - The handle returned by macOpen.
9025 \param pMsgBuf - MSG Buffer
9026
9027 \return eHalStatus
9028
9029 -------------------------------------------------------------------------------*/
9030eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
9031{
9032 eHalStatus status = eHAL_STATUS_SUCCESS;
9033 tAniChangeCountryCodeReq *pMsg;
Amar Singhal0d15bd52013-10-12 23:13:13 -07009034 v_REGDOMAIN_t domainIdIoctl;
Jeff Johnson295189b2012-06-20 16:38:30 -07009035 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9036 static uNvTables nvTables;
9037 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
9038
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +05309039 if (pMac->scan.fcc_constraint)
9040 {
9041 pMac->scan.fcc_constraint = false;
9042 if (VOS_TRUE== vos_mem_compare(pMac->scan.countryCodeCurrent,
9043 pMsg->countryCode, 2))
9044 {
9045 csrInitGetChannels(pMac);
9046 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
9047 csrScanFilterResults(pMac);
9048 return status ;
9049 }
9050 }
9051
Jeff Johnson295189b2012-06-20 16:38:30 -07009052
9053 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
9054 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
9055 {
9056 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
9057
9058 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
9059
9060 /* read the country code from NV and use it */
9061 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
9062 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309063 vos_mem_copy(pMsg->countryCode,
9064 nvTables.defaultCountryTable.countryCode,
9065 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009066 }
9067 else
9068 {
9069 status = eHAL_STATUS_FAILURE;
9070 return status;
9071 }
Abhishek Singh4d6b54c2014-10-14 12:31:00 +05309072 /* Update the 11d country to default country from NV bin so that when
9073 * callback is received for this default country, driver will not
9074 * disable the 11d taking it as valid country by user.
9075 */
9076 smsLog(pMac, LOG1,
9077 FL("Set default country code (%c%c) from NV as invalid country received"),
9078 pMsg->countryCode[0],pMsg->countryCode[1]);
9079 vos_mem_copy(pMac->scan.countryCode11d, pMsg->countryCode,
9080 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009081 }
9082 else
9083 {
9084 /* if Supplicant country code has priority, disable 11d */
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05309085 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
9086 pMsg->countryFromUserSpace)
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 {
9088 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
9089 }
9090 }
9091
9092 /* WEXT set country code means
9093 * 11D should be supported?
9094 * 11D Channel should be enforced?
9095 * 11D Country code should be matched?
9096 * 11D Reg Domian should be matched?
9097 * Country string changed */
9098 if(pMac->roam.configParam.Is11dSupportEnabled &&
9099 pMac->roam.configParam.fEnforce11dChannels &&
9100 pMac->roam.configParam.fEnforceCountryCodeMatch &&
9101 pMac->roam.configParam.fEnforceDefaultDomain &&
9102 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
9103 {
9104 /* All 11D related options are already enabled
9105 * Country string is not changed
9106 * Do not need do anything for country code change request */
9107 return eHAL_STATUS_SUCCESS;
9108 }
9109
9110 /* Set Current Country code and Current Regulatory domain */
9111 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
9112 if(eHAL_STATUS_SUCCESS != status)
9113 {
9114 /* Supplicant country code failed. So give 11D priority */
9115 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
9116 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009117 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009118 }
9119
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 /* overwrite the defualt country code */
Kiet Lam64c1b492013-07-12 13:56:44 +05309121 vos_mem_copy(pMac->scan.countryCodeDefault,
9122 pMac->scan.countryCodeCurrent,
9123 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009124
9125 /* Get Domain ID from country code */
Kiet Lam6c583332013-10-14 05:37:09 +05309126 status = csrGetRegulatoryDomainForCountry(pMac,
9127 pMac->scan.countryCodeCurrent,
9128 (v_REGDOMAIN_t *) &domainIdIoctl,
9129 COUNTRY_QUERY);
Jeff Johnson295189b2012-06-20 16:38:30 -07009130 if ( status != eHAL_STATUS_SUCCESS )
9131 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009132 smsLog( pMac, LOGE, FL(" fail to get regId %d"), domainIdIoctl );
Jeff Johnson295189b2012-06-20 16:38:30 -07009133 return status;
9134 }
Tushnim Bhattacharyya796ffe82013-11-05 16:31:36 -08009135 else if (REGDOMAIN_WORLD == domainIdIoctl)
9136 {
9137 /* Supplicant country code is invalid, so we are on world mode now. So
9138 give 11D chance to update */
9139 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
9140 smsLog(pMac, LOG1, FL("Country Code unrecognized by driver"));
9141 }
9142
Jeff Johnson295189b2012-06-20 16:38:30 -07009143
Abhishek Singha306a442013-11-07 18:39:01 +05309144 status = WDA_SetRegDomain(pMac, domainIdIoctl, pMsg->sendRegHint);
Jeff Johnson295189b2012-06-20 16:38:30 -07009145
9146 if ( status != eHAL_STATUS_SUCCESS )
9147 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009148 smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainIdIoctl );
Jeff Johnson295189b2012-06-20 16:38:30 -07009149 return status;
9150 }
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009151 else
9152 {
9153 //if 11d has priority, clear currentCountryBssid & countryCode11d to get
9154 //set again if we find AP with 11d info during scan
Sachin Ahujacb64fc82015-01-12 17:01:05 +05309155 status = csrSetRegulatoryDomain(pMac, domainIdIoctl, NULL);
9156 if (status != eHAL_STATUS_SUCCESS)
9157 {
9158 smsLog( pMac, LOGE, FL("fail to set regId.status : %d"), status);
9159 }
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009160 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority)
9161 {
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009162 smsLog( pMac, LOGW, FL("Clearing currentCountryBssid, countryCode11d"));
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009163 vos_mem_zero(&pMac->scan.currentCountryBssid, sizeof(tCsrBssid));
9164 vos_mem_zero( pMac->scan.countryCode11d, sizeof( pMac->scan.countryCode11d ) );
9165 }
9166 }
Kiet Lam6c583332013-10-14 05:37:09 +05309167#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -07009168 /* set to default domain ID */
9169 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
9170
9171 /* get the channels based on new cc */
9172 status = csrInitGetChannels( pMac );
9173
9174 if ( status != eHAL_STATUS_SUCCESS )
9175 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009176 smsLog( pMac, LOGE, FL(" fail to get Channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 return status;
9178 }
9179
9180 /* reset info based on new cc, and we are done */
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08009181 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Agarwal Ashishfaef6692014-01-29 19:40:30 +05309182 /* Country code Changed, Purge Only scan result
9183 * which does not have channel number belong to 11d
9184 * channel list
9185 */
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05309186 csrScanFilterResults(pMac);
Agarwal Ashishfaef6692014-01-29 19:40:30 +05309187
Kiet Lam6c583332013-10-14 05:37:09 +05309188#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 if( pMsg->changeCCCallback )
9190 {
9191 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
9192 }
9193
9194 return eHAL_STATUS_SUCCESS;
9195}
9196
Amar Singhal0d15bd52013-10-12 23:13:13 -07009197/* ---------------------------------------------------------------------------
9198
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009199 \fn sme_HandleChangeCountryCodeByUser
Amar Singhal0d15bd52013-10-12 23:13:13 -07009200
9201 \brief Change Country code, Reg Domain and channel list
9202
9203 If Supplicant country code is priority than 11d is disabled.
9204 If 11D is enabled, we update the country code after every scan.
9205 Hence when Supplicant country code is priority, we don't need 11D info.
9206 Country code from Supplicant is set as current country code.
9207
9208 \param pMac - The handle returned by macOpen.
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009209 \param pMsg - Carrying new CC & domain set in kernel by user
Amar Singhal0d15bd52013-10-12 23:13:13 -07009210
9211 \return eHalStatus
9212
9213 -------------------------------------------------------------------------------*/
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009214eHalStatus sme_HandleChangeCountryCodeByUser(tpAniSirGlobal pMac,
9215 tAniGenericChangeCountryCodeReq *pMsg)
Amar Singhal0d15bd52013-10-12 23:13:13 -07009216{
9217 eHalStatus status = eHAL_STATUS_SUCCESS;
Amar Singhal0d15bd52013-10-12 23:13:13 -07009218 v_REGDOMAIN_t reg_domain_id;
Kiet Lam6c583332013-10-14 05:37:09 +05309219 v_BOOL_t is11dCountry = VOS_FALSE;
Amar Singhal0d15bd52013-10-12 23:13:13 -07009220
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009221 smsLog(pMac, LOG1, FL(" called"));
Amar Singhal0d15bd52013-10-12 23:13:13 -07009222 reg_domain_id = (v_REGDOMAIN_t)pMsg->domain_index;
9223
Kiet Lam6c583332013-10-14 05:37:09 +05309224 if (memcmp(pMsg->countryCode, pMac->scan.countryCode11d,
9225 VOS_COUNTRY_CODE_LEN) == 0)
9226 {
9227 is11dCountry = VOS_TRUE;
9228 }
Amar Singhal0d15bd52013-10-12 23:13:13 -07009229
Sachin Ahuja120bf632015-02-24 18:06:34 +05309230 smsLog( pMac, LOG1, FL("pMsg->countryCode : %c%c,"
9231 "pMac->scan.countryCode11d : %c%c\n"),
9232 pMsg->countryCode[0], pMsg->countryCode[1],
9233 pMac->scan.countryCode11d[0], pMac->scan.countryCode11d[1]);
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05309234 /* Set the country code given by userspace when 11dOriginal is FALSE
9235 * when 11doriginal is True,is11dCountry =0 and
9236 * fSupplicantCountryCodeHasPriority = 0, then revert the country code,
9237 * and return failure
9238 */
9239 if (pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
Amar Singhal97a2d992013-11-19 10:58:07 -08009240 {
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309241 if ((!is11dCountry) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority)&&
9242 (!pMac->roam.configParam.fEnforceCountryCode) )
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05309243 {
Amar Singhal97a2d992013-11-19 10:58:07 -08009244
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05309245 smsLog( pMac, LOGW, FL(" incorrect country being set, nullify this request"));
Amar Singhal97a2d992013-11-19 10:58:07 -08009246
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05309247 status = csrGetRegulatoryDomainForCountry(pMac,
Amar Singhal97a2d992013-11-19 10:58:07 -08009248 pMac->scan.countryCode11d,
9249 (v_REGDOMAIN_t *) &reg_domain_id,
9250 COUNTRY_IE);
9251
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05309252 return eHAL_STATUS_FAILURE;
9253 }
Amar Singhal97a2d992013-11-19 10:58:07 -08009254 }
Amar Singhal0d15bd52013-10-12 23:13:13 -07009255 /* if Supplicant country code has priority, disable 11d */
Sachin Ahuja120bf632015-02-24 18:06:34 +05309256 if ((!is11dCountry) &&
9257 (pMac->roam.configParam.fSupplicantCountryCodeHasPriority) &&
9258 (!pMac->roam.configParam.fEnforceCountryCode))
Amar Singhal0d15bd52013-10-12 23:13:13 -07009259 {
9260 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +05309261 smsLog( pMac, LOG1, FL(" 11d is being disabled"));
Amar Singhal0d15bd52013-10-12 23:13:13 -07009262 }
9263
Sachin Ahuja120bf632015-02-24 18:06:34 +05309264 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Kiet Lamf2f201e2013-11-16 21:24:16 +05309265 vos_mem_copy(pMac->scan.countryCodeCurrent, pMsg->countryCode,
Amar Singhal0d15bd52013-10-12 23:13:13 -07009266 WNI_CFG_COUNTRY_CODE_LEN);
Sachin Ahuja120bf632015-02-24 18:06:34 +05309267 vos_mem_copy(pMac->scan.countryCode11d, pMsg->countryCode,
9268 WNI_CFG_COUNTRY_CODE_LEN);
9269
Amar Singhal0d15bd52013-10-12 23:13:13 -07009270
Sachin Ahujacb64fc82015-01-12 17:01:05 +05309271 status = csrSetRegulatoryDomain(pMac, reg_domain_id, NULL);
9272 if (status != eHAL_STATUS_SUCCESS)
9273 {
9274 smsLog( pMac, LOGE, FL("fail to set regId.status : %d"), status);
9275 }
Abhishek Singha306a442013-11-07 18:39:01 +05309276 status = WDA_SetRegDomain(pMac, reg_domain_id, eSIR_TRUE);
Amar Singhal0d15bd52013-10-12 23:13:13 -07009277
Kiet Lam6c583332013-10-14 05:37:09 +05309278 if (VOS_FALSE == is11dCountry )
9279 {
9280 /* overwrite the defualt country code */
Kiet Lamf2f201e2013-11-16 21:24:16 +05309281 vos_mem_copy(pMac->scan.countryCodeDefault,
Kiet Lam6c583332013-10-14 05:37:09 +05309282 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
9283 /* set to default domain ID */
9284 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
9285 }
9286
Amar Singhal0d15bd52013-10-12 23:13:13 -07009287 if ( status != eHAL_STATUS_SUCCESS )
9288 {
9289 smsLog( pMac, LOGE, FL(" fail to set regId %d"), reg_domain_id );
Kiet Lam6c583332013-10-14 05:37:09 +05309290 return status;
Amar Singhal0d15bd52013-10-12 23:13:13 -07009291 }
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009292 else
9293 {
9294 //if 11d has priority, clear currentCountryBssid & countryCode11d to get
9295 //set again if we find AP with 11d info during scan
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009296 if((!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) &&
9297 (VOS_FALSE == is11dCountry ))
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009298 {
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009299 smsLog( pMac, LOGW, FL("Clearing currentCountryBssid, countryCode11d"));
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009300 vos_mem_zero(&pMac->scan.currentCountryBssid, sizeof(tCsrBssid));
9301 vos_mem_zero( pMac->scan.countryCode11d, sizeof( pMac->scan.countryCode11d ) );
9302 }
9303 }
Amar Singhal0d15bd52013-10-12 23:13:13 -07009304
Amar Singhal0d15bd52013-10-12 23:13:13 -07009305 /* get the channels based on new cc */
9306 status = csrInitGetChannels(pMac);
9307
9308 if ( status != eHAL_STATUS_SUCCESS )
9309 {
9310 smsLog( pMac, LOGE, FL(" fail to get Channels "));
9311 return status;
9312 }
9313
9314 /* reset info based on new cc, and we are done */
9315 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Kiet Lam6c583332013-10-14 05:37:09 +05309316 if (VOS_TRUE == is11dCountry)
9317 {
Kiet Lam6c583332013-10-14 05:37:09 +05309318 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_TRUE;
9319 pMac->scan.f11dInfoReset = eANI_BOOLEAN_FALSE;
9320 }
Agarwal Ashishfaef6692014-01-29 19:40:30 +05309321 /* Country code Changed, Purge Only scan result
9322 * which does not have channel number belong to 11d
9323 * channel list
9324 */
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05309325 csrScanFilterResults(pMac);
Kiet Lambd5cd9b2013-11-11 19:01:45 +05309326 // Do active scans after the country is set by User hints or Country IE
9327 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
Sushant Kaushik1d732562014-05-21 14:15:37 +05309328 sme_DisconnectConnectedSessions(pMac);
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009329 smsLog(pMac, LOG1, FL(" returned"));
9330 return eHAL_STATUS_SUCCESS;
9331}
9332
9333/* ---------------------------------------------------------------------------
9334
Kiet Lamcffc5862013-10-30 16:28:45 +05309335 \fn sme_HandleChangeCountryCodeByCore
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009336
9337 \brief Update Country code in the driver if set by kernel as world
9338
9339 If 11D is enabled, we update the country code after every scan & notify kernel.
9340 This is to make sure kernel & driver are in sync in case of CC found in
9341 driver but not in kernel database
9342
9343 \param pMac - The handle returned by macOpen.
9344 \param pMsg - Carrying new CC set in kernel
9345
9346 \return eHalStatus
9347
9348 -------------------------------------------------------------------------------*/
Kiet Lamcffc5862013-10-30 16:28:45 +05309349eHalStatus sme_HandleChangeCountryCodeByCore(tpAniSirGlobal pMac, tAniGenericChangeCountryCodeReq *pMsg)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009350{
Kiet Lamcffc5862013-10-30 16:28:45 +05309351 eHalStatus status;
9352
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009353 smsLog(pMac, LOG1, FL(" called"));
9354
9355 //this is to make sure kernel & driver are in sync in case of CC found in
9356 //driver but not in kernel database
9357 if (('0' == pMsg->countryCode[0]) && ('0' == pMsg->countryCode[1]))
9358 {
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08009359 smsLog( pMac, LOGW, FL("Setting countryCode11d & countryCodeCurrent to world CC"));
Kiet Lamf2f201e2013-11-16 21:24:16 +05309360 vos_mem_copy(pMac->scan.countryCode11d, pMsg->countryCode,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009361 WNI_CFG_COUNTRY_CODE_LEN);
Kiet Lamf2f201e2013-11-16 21:24:16 +05309362 vos_mem_copy(pMac->scan.countryCodeCurrent, pMsg->countryCode,
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08009363 WNI_CFG_COUNTRY_CODE_LEN);
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009364 }
Kiet Lamcffc5862013-10-30 16:28:45 +05309365
Abhishek Singha306a442013-11-07 18:39:01 +05309366 status = WDA_SetRegDomain(pMac, REGDOMAIN_WORLD, eSIR_TRUE);
Kiet Lamcffc5862013-10-30 16:28:45 +05309367
9368 if ( status != eHAL_STATUS_SUCCESS )
9369 {
9370 smsLog( pMac, LOGE, FL(" fail to set regId") );
9371 return status;
9372 }
9373 else
9374 {
Sachin Ahujacb64fc82015-01-12 17:01:05 +05309375 status = csrSetRegulatoryDomain(pMac, REGDOMAIN_WORLD, NULL);
9376 if (status != eHAL_STATUS_SUCCESS)
9377 {
9378 smsLog( pMac, LOGE, FL("fail to set regId.status : %d"), status);
9379 }
Kiet Lamcffc5862013-10-30 16:28:45 +05309380 status = csrInitGetChannels(pMac);
9381 if ( status != eHAL_STATUS_SUCCESS )
9382 {
9383 smsLog( pMac, LOGE, FL(" fail to get Channels "));
9384 }
9385 else
9386 {
9387 csrInitChannelList(pMac);
9388 }
9389 }
Agarwal Ashishfaef6692014-01-29 19:40:30 +05309390 /* Country code Changed, Purge Only scan result
9391 * which does not have channel number belong to 11d
9392 * channel list
9393 */
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05309394 csrScanFilterResults(pMac);
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009395 smsLog(pMac, LOG1, FL(" returned"));
9396 return eHAL_STATUS_SUCCESS;
9397}
9398
9399/* ---------------------------------------------------------------------------
9400
Sushant Kaushik1d732562014-05-21 14:15:37 +05309401 \fn sme_DisconnectConnectedSessions
9402
9403 \brief Disconnect STA and P2P client session if channel is not supported
9404
9405 If new country code does not support the channel on which STA/P2P client
9406 is connetced, it sends the disconnect to the AP/P2P GO
9407
9408 \param pMac - The handle returned by macOpen
9409
9410 \return eHalStatus
9411
9412 -------------------------------------------------------------------------------*/
9413
9414void sme_DisconnectConnectedSessions(tpAniSirGlobal pMac)
9415{
9416 v_U8_t i, sessionId, isChanFound = false;
9417 tANI_U8 currChannel;
9418
9419 for (sessionId=0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
9420 {
9421 if (csrIsSessionClientAndConnected(pMac, sessionId))
9422 {
9423 isChanFound = false;
9424 //Session is connected.Check the channel
9425 currChannel = csrGetInfraOperationChannel(pMac, sessionId);
9426 smsLog(pMac, LOGW, "Current Operating channel : %d, session :%d",
9427 currChannel, sessionId);
9428 for (i=0; i < pMac->scan.base20MHzChannels.numChannels; i++)
9429 {
9430 if (pMac->scan.base20MHzChannels.channelList[i] == currChannel)
9431 {
9432 isChanFound = true;
9433 break;
9434 }
9435 }
9436
9437 if (!isChanFound)
9438 {
9439 for (i=0; i < pMac->scan.base40MHzChannels.numChannels; i++)
9440 {
9441 if (pMac->scan.base40MHzChannels.channelList[i] == currChannel)
9442 {
9443 isChanFound = true;
9444 break;
9445 }
9446 }
9447 }
9448 if (!isChanFound)
9449 {
9450 smsLog(pMac, LOGW, "%s : Disconnect Session :%d", __func__, sessionId);
9451 csrRoamDisconnect(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9452 }
9453 }
9454 }
9455}
9456/* ---------------------------------------------------------------------------
9457
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009458 \fn sme_HandleGenericChangeCountryCode
9459
9460 \brief Change Country code, Reg Domain and channel list
9461
9462 If Supplicant country code is priority than 11d is disabled.
9463 If 11D is enabled, we update the country code after every scan.
9464 Hence when Supplicant country code is priority, we don't need 11D info.
9465 Country code from kernel is set as current country code.
9466
9467 \param pMac - The handle returned by macOpen.
9468 \param pMsgBuf - message buffer
9469
9470 \return eHalStatus
9471
9472 -------------------------------------------------------------------------------*/
9473eHalStatus sme_HandleGenericChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
9474{
9475 tAniGenericChangeCountryCodeReq *pMsg;
9476 v_REGDOMAIN_t reg_domain_id;
9477
9478 smsLog(pMac, LOG1, FL(" called"));
9479 pMsg = (tAniGenericChangeCountryCodeReq *)pMsgBuf;
9480 reg_domain_id = (v_REGDOMAIN_t)pMsg->domain_index;
9481
9482 if (REGDOMAIN_COUNT == reg_domain_id)
9483 {
Kiet Lamcffc5862013-10-30 16:28:45 +05309484 sme_HandleChangeCountryCodeByCore(pMac, pMsg);
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009485 }
9486 else
9487 {
9488 sme_HandleChangeCountryCodeByUser(pMac, pMsg);
9489 }
9490 smsLog(pMac, LOG1, FL(" returned"));
Amar Singhal0d15bd52013-10-12 23:13:13 -07009491 return eHAL_STATUS_SUCCESS;
9492}
9493
Jeff Johnson295189b2012-06-20 16:38:30 -07009494#ifdef WLAN_FEATURE_PACKET_FILTERING
Amar Singhalf3a6e762013-02-19 15:06:50 -08009495eHalStatus sme_8023MulticastList (tHalHandle hHal, tANI_U8 sessionId, tpSirRcvFltMcAddrList pMulticastAddrs)
Jeff Johnson295189b2012-06-20 16:38:30 -07009496{
9497 tpSirRcvFltMcAddrList pRequestBuf;
9498 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07009499 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnsone7245742012-09-05 17:12:55 -07009500 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009501
9502 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
Jeff Johnson89477502017-09-19 08:35:23 -07009503 "ulMulticastAddrCnt=%d, multicastAddr[0]=%pK", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009504 pMulticastAddrs->ulMulticastAddrCnt,
9505 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07009506
9507 /*
9508 *Find the connected Infra / P2P_client connected session
Amar Singhalf3a6e762013-02-19 15:06:50 -08009509 */
9510 if (CSR_IS_SESSION_VALID(pMac, sessionId) &&
9511 csrIsConnStateInfra(pMac, sessionId))
9512 {
9513 pSession = CSR_GET_SESSION( pMac, sessionId );
9514 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009515
9516 if(pSession == NULL )
9517 {
Anurag Chouhan65ea6dc2016-10-25 19:59:14 +05309518 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN, "%s: Unable to find "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009519 "the right session", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07009520 return eHAL_STATUS_FAILURE;
9521 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08009522
Jeff Johnson295189b2012-06-20 16:38:30 -07009523 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9524 if (NULL == pRequestBuf)
9525 {
9526 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009527 "allocate memory for 8023 Multicast List request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009528 return eHAL_STATUS_FAILED_ALLOC;
9529 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08009530
9531 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
9532 {
9533 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
9534 "indication as we are not connected", __func__);
9535 vos_mem_free(pRequestBuf);
9536 return eHAL_STATUS_FAILURE;
9537 }
9538
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
9540
Kiet Lam64c1b492013-07-12 13:56:44 +05309541 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr,
9542 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07009543 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
9544 sizeof(tSirMacAddr));
9545
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 msg.type = WDA_8023_MULTICAST_LIST_REQ;
9547 msg.reserved = 0;
9548 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05309549 MTRACE(vos_trace(VOS_MODULE_ID_SME,
9550 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
9552 {
9553 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009554 "post WDA_8023_MULTICAST_LIST message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009555 vos_mem_free(pRequestBuf);
9556 return eHAL_STATUS_FAILURE;
9557 }
9558
9559 return eHAL_STATUS_SUCCESS;
9560}
9561
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009562eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
Jeff Johnsone7245742012-09-05 17:12:55 -07009563 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07009564{
9565 tpSirRcvPktFilterCfgType pRequestBuf;
9566 v_SINT_t allocSize;
9567 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07009568 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9569 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 v_U8_t idx=0;
9571
9572 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009573 "filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009575
Madan Mohan Koyyalamudid4029622012-10-18 20:30:17 -07009576 allocSize = sizeof(tSirRcvPktFilterCfgType);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009577
Jeff Johnson295189b2012-06-20 16:38:30 -07009578 pRequestBuf = vos_mem_malloc(allocSize);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009579
9580 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07009581 {
9582 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009583 "allocate memory for Receive Filter Set Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 return eHAL_STATUS_FAILED_ALLOC;
9585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009586
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009587 if( NULL == pSession )
9588 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009589 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Session Not found ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009590 vos_mem_free(pRequestBuf);
9591 return eHAL_STATUS_FAILURE;
9592 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009593
Kiet Lam64c1b492013-07-12 13:56:44 +05309594 vos_mem_copy(pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr,
9595 sizeof(tSirMacAddr));
9596 vos_mem_copy(pRcvPktFilterCfg->bssId, pSession->connectedProfile.bssid,
9597 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009598 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
9599
Jeff Johnson295189b2012-06-20 16:38:30 -07009600 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
9601 msg.reserved = 0;
9602 msg.bodyptr = pRequestBuf;
9603
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05309604 MTRACE(vos_trace(VOS_MODULE_ID_SME,
9605 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07009606 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009607 "FT %d FID %d ",
9608 pRequestBuf->filterType, pRequestBuf->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009609
9610 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009611 "params %d CT %d",
9612 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07009613
9614 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
9615 {
9616
9617 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009618 "Proto %d Comp Flag %d ",
Jeff Johnson295189b2012-06-20 16:38:30 -07009619 pRequestBuf->paramsData[idx].protocolLayer,
9620 pRequestBuf->paramsData[idx].cmpFlag);
9621
9622 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009623 "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009624 pRequestBuf->paramsData[idx].dataOffset,
9625 pRequestBuf->paramsData[idx].dataLength);
9626
9627 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009628 "CData: %d:%d:%d:%d:%d:%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009629 pRequestBuf->paramsData[idx].compareData[0],
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009630 pRequestBuf->paramsData[idx].compareData[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07009631 pRequestBuf->paramsData[idx].compareData[2],
9632 pRequestBuf->paramsData[idx].compareData[3],
9633 pRequestBuf->paramsData[idx].compareData[4],
9634 pRequestBuf->paramsData[idx].compareData[5]);
9635
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009636 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009637 "MData: %d:%d:%d:%d:%d:%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009638 pRequestBuf->paramsData[idx].dataMask[0],
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009639 pRequestBuf->paramsData[idx].dataMask[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 pRequestBuf->paramsData[idx].dataMask[2],
9641 pRequestBuf->paramsData[idx].dataMask[3],
9642 pRequestBuf->paramsData[idx].dataMask[4],
9643 pRequestBuf->paramsData[idx].dataMask[5]);
9644
9645 }
9646
9647 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
9648 {
9649 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009650 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 vos_mem_free(pRequestBuf);
9652 return eHAL_STATUS_FAILURE;
9653 }
9654
9655 return eHAL_STATUS_SUCCESS;
9656}
9657
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009658eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 FilterMatchCountCallback callbackRoutine,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009660 void *callbackContext,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009661 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07009662{
9663 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9664 eHalStatus status;
9665
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009666 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009667
9668 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
9669 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009670 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009671 sme_ReleaseGlobalLock( &pMac->sme );
9672 }
9673
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009674 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009675
9676 return (status);
9677}
9678
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009679eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
Jeff Johnsone7245742012-09-05 17:12:55 -07009680 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07009681{
9682 tpSirRcvFltPktClearParam pRequestBuf;
9683 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07009684 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9685 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009686
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009687 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 pRcvFltPktClearParam->filterId);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009689
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009691 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 {
9693 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9694 "%s: Not able to allocate memory for Receive Filter "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009695 "Clear Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 return eHAL_STATUS_FAILED_ALLOC;
9697 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009698 if( NULL == pSession )
9699 {
9700 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009701 "%s: Session Not find ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009702 vos_mem_free(pRequestBuf);
9703 return eHAL_STATUS_FAILURE;
9704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009705
Kiet Lam64c1b492013-07-12 13:56:44 +05309706 vos_mem_copy(pRcvFltPktClearParam->selfMacAddr, pSession->selfMacAddr,
9707 sizeof(tSirMacAddr));
9708 vos_mem_copy(pRcvFltPktClearParam->bssId, pSession->connectedProfile.bssid,
9709 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07009710
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009711 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
9712
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
9714 msg.reserved = 0;
9715 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05309716 MTRACE(vos_trace(VOS_MODULE_ID_SME,
9717 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
9719 {
9720 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009721 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009722 vos_mem_free(pRequestBuf);
9723 return eHAL_STATUS_FAILURE;
9724 }
9725
9726 return eHAL_STATUS_SUCCESS;
9727}
9728#endif // WLAN_FEATURE_PACKET_FILTERING
9729
9730/* ---------------------------------------------------------------------------
9731 \fn sme_PreChannelSwitchIndFullPowerCB
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009732 \brief call back function for the PMC full power request because of pre
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 channel switch.
9734 \param callbackContext
9735 \param status
9736 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009737void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
Jeff Johnson295189b2012-06-20 16:38:30 -07009738 eHalStatus status)
9739{
9740 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
9741 tSirMbMsg *pMsg;
9742 tANI_U16 msgLen;
9743
9744 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
Kiet Lam64c1b492013-07-12 13:56:44 +05309745 pMsg = vos_mem_malloc(msgLen);
9746 if ( NULL != pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -07009747 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309748 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009749 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
9750 pMsg->msgLen = pal_cpu_to_be16(msgLen);
9751 status = palSendMBMessage(pMac->hHdd, pMsg);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009753
9754 return;
9755}
9756
9757/* ---------------------------------------------------------------------------
9758 \fn sme_HandlePreChannelSwitchInd
9759 \brief Processes the indcation from PE for pre-channel switch.
9760 \param hHal
9761 \- The handle returned by macOpen. return eHalStatus
9762 ---------------------------------------------------------------------------*/
9763eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
9764{
9765 eHalStatus status = eHAL_STATUS_FAILURE;
9766 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9767 status = sme_AcquireGlobalLock( &pMac->sme );
9768 if ( HAL_STATUS_SUCCESS( status ) )
9769 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009770 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
9771 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
Jeff Johnson295189b2012-06-20 16:38:30 -07009772 sme_ReleaseGlobalLock( &pMac->sme );
9773 }
9774
9775 return (status);
9776}
9777
9778/* ---------------------------------------------------------------------------
9779 \fn sme_HandlePostChannelSwitchInd
9780 \brief Processes the indcation from PE for post-channel switch.
9781 \param hHal
9782 \- The handle returned by macOpen. return eHalStatus
9783 ---------------------------------------------------------------------------*/
9784eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
9785{
9786 eHalStatus status = eHAL_STATUS_FAILURE;
9787 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9788
9789 status = sme_AcquireGlobalLock( &pMac->sme );
9790 if ( HAL_STATUS_SUCCESS( status ) )
9791 {
9792 status = pmcRequestBmps(hHal, NULL, NULL);
9793 sme_ReleaseGlobalLock( &pMac->sme );
9794 }
9795
9796 return (status);
9797}
9798
9799/* ---------------------------------------------------------------------------
9800
9801 \fn sme_IsChannelValid
9802
9803 \brief To check if the channel is valid for currently established domain
9804 This is a synchronous API.
9805
9806 \param hHal - The handle returned by macOpen.
9807 \param channel - channel to verify
9808
9809 \return TRUE/FALSE, TRUE if channel is valid
9810
9811 -------------------------------------------------------------------------------*/
9812tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
9813{
9814 eHalStatus status = eHAL_STATUS_FAILURE;
9815 tANI_BOOLEAN valid = FALSE;
9816 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009817
Jeff Johnson295189b2012-06-20 16:38:30 -07009818 status = sme_AcquireGlobalLock( &pMac->sme );
9819 if ( HAL_STATUS_SUCCESS( status ) )
9820 {
9821
9822 valid = csrRoamIsChannelValid( pMac, channel);
9823
9824 sme_ReleaseGlobalLock( &pMac->sme );
9825 }
9826
9827 return (valid);
9828}
9829
9830/* ---------------------------------------------------------------------------
9831 \fn sme_SetFreqBand
9832 \brief Used to set frequency band.
9833 \param hHal
9834 \eBand band value to be configured
9835 \- return eHalStatus
9836 -------------------------------------------------------------------------*/
9837eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
9838{
9839 eHalStatus status = eHAL_STATUS_FAILURE;
9840 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9841
9842 status = sme_AcquireGlobalLock( &pMac->sme );
9843 if ( HAL_STATUS_SUCCESS( status ) )
9844 {
9845 status = csrSetBand(hHal, eBand);
9846 sme_ReleaseGlobalLock( &pMac->sme );
9847 }
9848 return status;
9849}
9850
9851/* ---------------------------------------------------------------------------
9852 \fn sme_GetFreqBand
9853 \brief Used to get the current band settings.
9854 \param hHal
9855 \pBand pointer to hold band value
9856 \- return eHalStatus
9857 -------------------------------------------------------------------------*/
9858eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
9859{
9860 eHalStatus status = eHAL_STATUS_FAILURE;
9861 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9862
9863 status = sme_AcquireGlobalLock( &pMac->sme );
9864 if ( HAL_STATUS_SUCCESS( status ) )
9865 {
9866 *pBand = csrGetCurrentBand( hHal );
9867 sme_ReleaseGlobalLock( &pMac->sme );
9868 }
9869 return status;
9870}
9871
9872#ifdef WLAN_WAKEUP_EVENTS
9873/******************************************************************************
9874 \fn sme_WakeReasonIndCallback
9875
9876 \brief
9877 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
9878
9879 \param hHal - HAL handle for device
9880 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
9881
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009882 \return eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -07009883******************************************************************************/
9884eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
9885{
9886 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9887 eHalStatus status = eHAL_STATUS_SUCCESS;
9888 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
9889
9890 if (NULL == pMsg)
9891 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009892 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009893 status = eHAL_STATUS_FAILURE;
9894 }
9895 else
9896 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009897 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback");
Jeff Johnson295189b2012-06-20 16:38:30 -07009898
9899 /* Call Wake Reason Indication callback routine. */
9900 if (pMac->pmc.wakeReasonIndCB != NULL)
9901 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009902
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009903 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __func__, pWakeReasonInd->ulReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 }
9905
9906 return(status);
9907}
9908#endif // WLAN_WAKEUP_EVENTS
9909
9910
Abhishek Singh99a31be2015-12-10 10:37:44 +05309911/**
9912 * sme_SetMaxTxPower() - Set the Maximum Transmit Power
9913 *
9914 * @hHal: hal pointer.
9915 * @bssid: bssid to set the power cap for
9916 * @self_mac_addr:self mac address
9917 * @db: power to set in dB
9918 *
9919 * Set the maximum transmit power dynamically.
9920 *
9921 * Return: eHalStatus
9922 *
9923 */
9924eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr bssid,
9925 tSirMacAddr self_mac_addr, v_S7_t db)
Jeff Johnson295189b2012-06-20 16:38:30 -07009926{
Abhishek Singh99a31be2015-12-10 10:37:44 +05309927 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9928 eHalStatus status = eHAL_STATUS_SUCCESS;
9929 tSmeCmd *set_max_tx_pwr;
9930
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +05309931 if (pMac->max_power_cmd_pending)
9932 {
9933 smsLog(pMac, LOG1,
9934 FL("set max tx power already in progress"));
9935 return eHAL_STATUS_RESOURCES;
9936 }
9937
Abhishek Singh99a31be2015-12-10 10:37:44 +05309938 MTRACE(vos_trace(VOS_MODULE_ID_SME,
9939 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
9940 smsLog(pMac, LOG1,
9941 FL("bssid :" MAC_ADDRESS_STR " self addr: "MAC_ADDRESS_STR" power %d Db"),
9942 MAC_ADDR_ARRAY(bssid), MAC_ADDR_ARRAY(self_mac_addr), db);
9943
9944 status = sme_AcquireGlobalLock( &pMac->sme );
9945 if ( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009946 {
Abhishek Singh99a31be2015-12-10 10:37:44 +05309947 set_max_tx_pwr = csrGetCommandBuffer(pMac);
9948 if (set_max_tx_pwr)
9949 {
9950 set_max_tx_pwr->command = eSmeCommandSetMaxTxPower;
9951 vos_mem_copy(set_max_tx_pwr->u.set_tx_max_pwr.bssid,
9952 bssid, SIR_MAC_ADDR_LENGTH);
9953 vos_mem_copy(set_max_tx_pwr->u.set_tx_max_pwr.self_sta_mac_addr,
9954 self_mac_addr, SIR_MAC_ADDR_LENGTH);
9955 set_max_tx_pwr->u.set_tx_max_pwr.power = db;
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +05309956 pMac->max_power_cmd_pending = true;
Abhishek Singh99a31be2015-12-10 10:37:44 +05309957 status = csrQueueSmeCommand(pMac, set_max_tx_pwr, eANI_BOOLEAN_TRUE);
9958 if ( !HAL_STATUS_SUCCESS( status ) )
9959 {
9960 smsLog( pMac, LOGE, FL("fail to send msg status = %d"), status );
9961 csrReleaseCommandScan(pMac, set_max_tx_pwr);
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +05309962 pMac->max_power_cmd_pending = false;
Abhishek Singh99a31be2015-12-10 10:37:44 +05309963 }
9964 }
9965 else
9966 {
9967 smsLog(pMac, LOGE, FL("can not obtain a common buffer"));
9968 status = eHAL_STATUS_RESOURCES;
9969 }
9970 sme_ReleaseGlobalLock( &pMac->sme);
9971 }
9972 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009973}
9974
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05309975/**
9976 * sme_SetMaxTxPowerPerBand() - Set the Maximum Transmit Power
9977 * specific to band dynamically
9978 * @band: Band for which power needs to be applied
9979 * @dB: power to set in dB
9980 * @hal: HAL handle
9981 *
9982 * Set the maximum transmit power dynamically per band
9983 *
9984 * Return: eHalStatus
9985 */
9986eHalStatus sme_SetMaxTxPowerPerBand(eCsrBand band, v_S7_t dB,
9987 tHalHandle hal)
Arif Hussaina5ebce02013-08-09 15:09:58 -07009988{
9989 vos_msg_t msg;
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05309990 eHalStatus status;
9991 tSmeCmd *set_max_tx_pwr_per_band;
9992 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussaina5ebce02013-08-09 15:09:58 -07009993
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +05309994 if (mac_ctx->max_power_cmd_pending)
9995 {
9996 smsLog(mac_ctx, LOG1,
9997 FL("set max tx power already in progress"));
9998 return eHAL_STATUS_RESOURCES;
9999 }
10000
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +053010001 smsLog(mac_ctx, LOG1,
10002 FL("band : %d power %d dB"),
10003 band, dB);
10004
10005 MTRACE(vos_trace(VOS_MODULE_ID_SME,
10006 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
10007
10008 status = sme_AcquireGlobalLock(&mac_ctx->sme);
10009 if (HAL_STATUS_SUCCESS(status)) {
10010 set_max_tx_pwr_per_band = csrGetCommandBuffer(mac_ctx);
10011 if (set_max_tx_pwr_per_band) {
10012 set_max_tx_pwr_per_band->command = eSmeCommandSetMaxTxPowerPerBand;
10013 set_max_tx_pwr_per_band->u.set_tx_max_pwr_per_band.band = band;
10014 set_max_tx_pwr_per_band->u.set_tx_max_pwr_per_band.power = dB;
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +053010015 mac_ctx->max_power_cmd_pending = true;
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +053010016 status = csrQueueSmeCommand(mac_ctx, set_max_tx_pwr_per_band,
10017 eANI_BOOLEAN_TRUE);
10018 if (!HAL_STATUS_SUCCESS(status)) {
10019 smsLog(mac_ctx, LOGE, FL("fail to send msg status = %d"), status);
10020 csrReleaseCommand(mac_ctx, set_max_tx_pwr_per_band);
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +053010021 mac_ctx->max_power_cmd_pending = false;
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +053010022 }
10023 } else {
10024 smsLog(mac_ctx, LOGE, FL("can not obtain a common buffer"));
10025 status = eHAL_STATUS_RESOURCES;
10026 }
10027 sme_ReleaseGlobalLock(&mac_ctx->sme);
Arif Hussaina5ebce02013-08-09 15:09:58 -070010028 }
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +053010029 return status;
Arif Hussaina5ebce02013-08-09 15:09:58 -070010030}
10031
10032/* ---------------------------------------------------------------------------
10033
schang86c22c42013-03-13 18:41:24 -070010034 \fn sme_SetTxPower
10035
10036 \brief Set Transmit Power dynamically. Note: this setting will
10037 not persist over reboots.
10038
10039 \param hHal
10040 \param sessionId Target Session ID
10041 \param mW power to set in mW
10042 \- return eHalStatus
10043
10044 -------------------------------------------------------------------------------*/
10045eHalStatus sme_SetTxPower(tHalHandle hHal, v_U8_t sessionId, v_U8_t mW)
10046{
10047
10048 eHalStatus status = eHAL_STATUS_FAILURE;
10049 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10050
Katya Nigambcb705f2013-12-26 14:26:22 +053010051 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010052 TRACE_CODE_SME_RX_HDD_SET_TXPOW, NO_SESSION, 0));
schang86c22c42013-03-13 18:41:24 -070010053 smsLog(pMac, LOG1, FL("set tx power %dmW"), mW);
10054 status = sme_AcquireGlobalLock(&pMac->sme);
10055 if (HAL_STATUS_SUCCESS(status))
10056 {
10057 status = csrSetTxPower(pMac, sessionId, mW);
10058 sme_ReleaseGlobalLock(&pMac->sme);
10059 }
10060 return status;
10061}
10062
10063/* ---------------------------------------------------------------------------
10064
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 \fn sme_HideSSID
10066
10067 \brief hide/show SSID dynamically. Note: this setting will
10068 not persist over reboots.
10069
10070 \param hHal
10071 \param sessionId
10072 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
10073 \- return eHalStatus
10074
10075 -------------------------------------------------------------------------------*/
10076eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
10077{
10078 eHalStatus status = eHAL_STATUS_SUCCESS;
10079 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10080 tANI_U16 len;
10081
10082 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
10083 {
10084 tpSirUpdateParams pMsg;
10085 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010086
10087 if(!pSession)
10088 {
10089 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -080010090 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010091 return eHAL_STATUS_FAILURE;
10092 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010093
10094 if( !pSession->sessionActive )
Jeff Johnson295189b2012-06-20 16:38:30 -070010095 VOS_ASSERT(0);
10096
10097 /* Create the message and send to lim */
10098 len = sizeof(tSirUpdateParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053010099 pMsg = vos_mem_malloc(len);
10100 if ( NULL == pMsg )
10101 status = eHAL_STATUS_FAILURE;
10102 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010104 vos_mem_set(pMsg, sizeof(tSirUpdateParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010105 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
10106 pMsg->length = len;
10107 /* Data starts from here */
10108 pMsg->sessionId = sessionId;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010109 pMsg->ssidHidden = ssidHidden;
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 status = palSendMBMessage(pMac->hHdd, pMsg);
10111 }
10112 sme_ReleaseGlobalLock( &pMac->sme );
10113 }
10114 return status;
10115}
Jeff Johnson295189b2012-06-20 16:38:30 -070010116
10117/* ---------------------------------------------------------------------------
10118
10119 \fn sme_SetTmLevel
10120 \brief Set Thermal Mitigation Level to RIVA
10121 \param hHal - The handle returned by macOpen.
10122 \param newTMLevel - new Thermal Mitigation Level
10123 \param tmMode - Thermal Mitigation handle mode, default 0
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010124 \return eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -070010125 ---------------------------------------------------------------------------*/
10126eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
10127{
10128 eHalStatus status = eHAL_STATUS_SUCCESS;
10129 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10130 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10131 vos_msg_t vosMessage;
10132 tAniSetTmLevelReq *setTmLevelReq = NULL;
10133
Katya Nigambcb705f2013-12-26 14:26:22 +053010134 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010135 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
10137 {
10138 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
Kiet Lam64c1b492013-07-12 13:56:44 +053010139 if (NULL == setTmLevelReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070010140 {
10141 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010142 "%s: Not able to allocate memory for sme_SetTmLevel", __func__);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -080010143 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson295189b2012-06-20 16:38:30 -070010144 return eHAL_STATUS_FAILURE;
10145 }
10146
10147 setTmLevelReq->tmMode = tmMode;
10148 setTmLevelReq->newTmLevel = newTMLevel;
10149
10150 /* serialize the req through MC thread */
10151 vosMessage.bodyptr = setTmLevelReq;
10152 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053010153 MTRACE(vos_trace(VOS_MODULE_ID_SME,
10154 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Jeff Johnson295189b2012-06-20 16:38:30 -070010155 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
10156 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
10157 {
10158 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010159 "%s: Post Set TM Level MSG fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 vos_mem_free(setTmLevelReq);
10161 status = eHAL_STATUS_FAILURE;
10162 }
10163 sme_ReleaseGlobalLock( &pMac->sme );
10164 }
10165 return(status);
10166}
10167
Rajeev Kumar Sirasanagandla4c068d42019-02-22 21:39:36 +053010168VOS_STATUS
10169sme_featureCapsExchange(struct sir_feature_caps_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070010170{
Rajeev Kumar Sirasanagandla4c068d42019-02-22 21:39:36 +053010171 VOS_STATUS status;
10172 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME,
10173 NULL);
10174
10175 MTRACE(vos_trace(VOS_MODULE_ID_SME,
10176 TRACE_CODE_SME_RX_HDD_CAPS_EXCH, NO_SESSION, 0));
10177
10178 status = WDA_featureCapsExchange(vosContext, params);
10179
10180 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010181}
Jeff Johnsond13512a2012-07-17 11:42:19 -070010182
Yathish9f22e662012-12-10 14:21:35 -080010183/*---------------------------------------------------------------------------
10184
10185 \brief sme_disableFeatureCapablity() - SME interface to disable Active mode offload capablity
10186 in Host.
10187
10188 \param hHal - HAL handle for device
10189
10190 \return NONE
10191
10192---------------------------------------------------------------------------*/
10193void sme_disableFeatureCapablity(tANI_U8 feature_index)
10194{
10195 WDA_disableCapablityFeature(feature_index);
10196}
10197
Jeff Johnsond13512a2012-07-17 11:42:19 -070010198/* ---------------------------------------------------------------------------
10199
10200 \fn sme_GetDefaultCountryCode
10201
10202 \brief Get the default country code from NV
10203
10204 \param hHal
10205 \param pCountry
10206 \- return eHalStatus
10207
10208 -------------------------------------------------------------------------------*/
10209eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
10210{
10211 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +053010212 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010213 TRACE_CODE_SME_RX_HDD_GET_DEFCCNV, NO_SESSION, 0));
Jeff Johnsond13512a2012-07-17 11:42:19 -070010214 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
10215}
10216
10217/* ---------------------------------------------------------------------------
10218
10219 \fn sme_GetCurrentCountryCode
10220
10221 \brief Get the current country code
10222
10223 \param hHal
10224 \param pCountry
10225 \- return eHalStatus
10226
10227 -------------------------------------------------------------------------------*/
10228eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
10229{
10230 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +053010231 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010232 TRACE_CODE_SME_RX_HDD_GET_CURCC, NO_SESSION, 0));
Jeff Johnsond13512a2012-07-17 11:42:19 -070010233 return csrGetCurrentCountryCode(pMac, pCountry);
10234}
10235
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010236/* ---------------------------------------------------------------------------
10237 \fn sme_transportDebug
10238 \brief Dynamically monitoring Transport channels
10239 Private IOCTL will querry transport channel status if driver loaded
schang6295e542013-03-12 15:31:23 -070010240 \param hHal Upper MAC context
Jeff Johnsonb88db982012-12-10 13:34:59 -080010241 \param displaySnapshot Display transport channel snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010242 \param toggleStallDetect Enable stall detect feature
10243 This feature will take effect to data performance
10244 Not integrate till fully verification
10245 \- return NONE
10246 -------------------------------------------------------------------------*/
schang6295e542013-03-12 15:31:23 -070010247void sme_transportDebug(tHalHandle hHal, v_BOOL_t displaySnapshot, v_BOOL_t toggleStallDetect)
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010248{
schang6295e542013-03-12 15:31:23 -070010249 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10250
10251 if (NULL == pMac)
10252 {
10253 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10254 "%s: invalid context", __func__);
10255 return;
10256 }
10257 WDA_TransportChannelDebug(pMac, displaySnapshot, toggleStallDetect);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010258}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -080010259
Kiran4a17ebe2013-01-31 10:43:43 -080010260/* ---------------------------------------------------------------------------
10261 \fn sme_ResetPowerValuesFor5G
10262 \brief Reset the power values for 5G band with NV power values.
10263 \param hHal - HAL handle for device
10264 \- return NONE
10265 -------------------------------------------------------------------------*/
10266void sme_ResetPowerValuesFor5G (tHalHandle hHal)
10267{
10268 tpAniSirGlobal pMac = PMAC_STRUCT (hHal);
Katya Nigambcb705f2013-12-26 14:26:22 +053010269 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010270 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
Kiran4a17ebe2013-01-31 10:43:43 -080010271 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
10272 csrApplyPower2Current(pMac); // Store the channel+power info in the global place: Cfg
10273}
10274
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010275#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -080010276/* ---------------------------------------------------------------------------
10277 \fn sme_UpdateRoamPrefer5GHz
10278 \brief enable/disable Roam prefer 5G runtime option
10279 This function is called through dynamic setConfig callback function
10280 to configure the Roam prefer 5G runtime option
10281 \param hHal - HAL handle for device
10282 \param nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
10283 \- return Success or failure
10284 -------------------------------------------------------------------------*/
10285
10286eHalStatus sme_UpdateRoamPrefer5GHz(tHalHandle hHal, v_BOOL_t nRoamPrefer5GHz)
10287{
10288 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -080010289 eHalStatus status = eHAL_STATUS_SUCCESS;
10290
Katya Nigambcb705f2013-12-26 14:26:22 +053010291 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010292 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010293 status = sme_AcquireGlobalLock( &pMac->sme );
10294 if ( HAL_STATUS_SUCCESS( status ) )
10295 {
10296 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10297 "%s: gRoamPrefer5GHz is changed from %d to %d", __func__,
10298 pMac->roam.configParam.nRoamPrefer5GHz,
10299 nRoamPrefer5GHz);
10300 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
10301 sme_ReleaseGlobalLock( &pMac->sme );
10302 }
10303
10304 return status ;
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -080010305}
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -080010306
10307/* ---------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010308 \fn sme_setRoamIntraBand
10309 \brief enable/disable Intra band roaming
10310 This function is called through dynamic setConfig callback function
10311 to configure the intra band roaming
10312 \param hHal - HAL handle for device
10313 \param nRoamIntraBand Enable/Disable Intra band roaming
10314 \- return Success or failure
10315 -------------------------------------------------------------------------*/
10316eHalStatus sme_setRoamIntraBand(tHalHandle hHal, const v_BOOL_t nRoamIntraBand)
10317{
10318 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10319 eHalStatus status = eHAL_STATUS_SUCCESS;
10320
Katya Nigambcb705f2013-12-26 14:26:22 +053010321 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010322 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010323 status = sme_AcquireGlobalLock( &pMac->sme );
10324 if ( HAL_STATUS_SUCCESS( status ) )
10325 {
10326 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10327 "%s: gRoamIntraBand is changed from %d to %d", __func__,
10328 pMac->roam.configParam.nRoamIntraBand,
10329 nRoamIntraBand);
10330 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
10331 sme_ReleaseGlobalLock( &pMac->sme );
10332 }
10333
10334 return status ;
10335}
10336
10337/* ---------------------------------------------------------------------------
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010338 \fn sme_UpdateRoamScanNProbes
10339 \brief function to update roam scan N probes
10340 This function is called through dynamic setConfig callback function
10341 to update roam scan N probes
10342 \param hHal - HAL handle for device
10343 \param nProbes number of probe requests to be sent out
10344 \- return Success or failure
10345 -------------------------------------------------------------------------*/
10346eHalStatus sme_UpdateRoamScanNProbes(tHalHandle hHal, const v_U8_t nProbes)
10347{
10348 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10349 eHalStatus status = eHAL_STATUS_SUCCESS;
10350
10351 status = sme_AcquireGlobalLock( &pMac->sme );
10352 if ( HAL_STATUS_SUCCESS( status ) )
10353 {
10354 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10355 "%s: gRoamScanNProbes is changed from %d to %d", __func__,
10356 pMac->roam.configParam.nProbes,
10357 nProbes);
10358 pMac->roam.configParam.nProbes = nProbes;
10359 sme_ReleaseGlobalLock( &pMac->sme );
10360 }
10361#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10362 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
10363 {
10364 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10365 REASON_NPROBES_CHANGED);
10366 }
10367#endif
10368 return status ;
10369}
10370
10371/* ---------------------------------------------------------------------------
10372 \fn sme_UpdateRoamScanHomeAwayTime
10373 \brief function to update roam scan Home away time
10374 This function is called through dynamic setConfig callback function
10375 to update roam scan home away time
10376 \param hHal - HAL handle for device
10377 \param nRoamScanAwayTime Scan home away time
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070010378 \param bSendOffloadCmd If TRUE then send offload command to firmware
10379 If FALSE then command is not sent to firmware
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010380 \- return Success or failure
10381 -------------------------------------------------------------------------*/
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070010382eHalStatus sme_UpdateRoamScanHomeAwayTime(tHalHandle hHal, const v_U16_t nRoamScanHomeAwayTime,
10383 const eAniBoolean bSendOffloadCmd)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010384{
10385 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10386 eHalStatus status = eHAL_STATUS_SUCCESS;
10387
10388 status = sme_AcquireGlobalLock( &pMac->sme );
10389 if ( HAL_STATUS_SUCCESS( status ) )
10390 {
10391 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10392 "%s: gRoamScanHomeAwayTime is changed from %d to %d", __func__,
10393 pMac->roam.configParam.nRoamScanHomeAwayTime,
10394 nRoamScanHomeAwayTime);
10395 pMac->roam.configParam.nRoamScanHomeAwayTime = nRoamScanHomeAwayTime;
10396 sme_ReleaseGlobalLock( &pMac->sme );
10397 }
10398
10399#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070010400 if (pMac->roam.configParam.isRoamOffloadScanEnabled && bSendOffloadCmd)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010401 {
10402 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10403 REASON_HOME_AWAY_TIME_CHANGED);
10404 }
10405#endif
10406 return status;
10407}
10408
10409
10410/* ---------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010411 \fn sme_getRoamIntraBand
10412 \brief get Intra band roaming
10413 \param hHal - HAL handle for device
10414 \- return Success or failure
10415 -------------------------------------------------------------------------*/
10416v_BOOL_t sme_getRoamIntraBand(tHalHandle hHal)
10417{
10418 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +053010419 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010420 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010421 return pMac->roam.configParam.nRoamIntraBand;
10422}
10423
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010424/* ---------------------------------------------------------------------------
10425 \fn sme_getRoamScanNProbes
10426 \brief get N Probes
10427 \param hHal - HAL handle for device
10428 \- return Success or failure
10429 -------------------------------------------------------------------------*/
10430v_U8_t sme_getRoamScanNProbes(tHalHandle hHal)
10431{
10432 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10433 return pMac->roam.configParam.nProbes;
10434}
10435
10436/* ---------------------------------------------------------------------------
10437 \fn sme_getRoamScanHomeAwayTime
10438 \brief get Roam scan home away time
10439 \param hHal - HAL handle for device
10440 \- return Success or failure
10441 -------------------------------------------------------------------------*/
10442v_U16_t sme_getRoamScanHomeAwayTime(tHalHandle hHal)
10443{
10444 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10445 return pMac->roam.configParam.nRoamScanHomeAwayTime;
10446}
10447
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010448
10449/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -080010450 \fn sme_UpdateImmediateRoamRssiDiff
10451 \brief Update nImmediateRoamRssiDiff
10452 This function is called through dynamic setConfig callback function
10453 to configure nImmediateRoamRssiDiff
10454 Usage: adb shell iwpriv wlan0 setConfig gImmediateRoamRssiDiff=[0 .. 125]
10455 \param hHal - HAL handle for device
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010456 \param nImmediateRoamRssiDiff - minimum rssi difference between potential
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -080010457 candidate and current AP.
10458 \- return Success or failure
10459 -------------------------------------------------------------------------*/
10460
10461eHalStatus sme_UpdateImmediateRoamRssiDiff(tHalHandle hHal, v_U8_t nImmediateRoamRssiDiff)
10462{
10463 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -080010464 eHalStatus status = eHAL_STATUS_SUCCESS;
10465
Katya Nigambcb705f2013-12-26 14:26:22 +053010466 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010467 TRACE_CODE_SME_RX_HDD_UPDATE_IMMRSSIDIFF, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010468 status = sme_AcquireGlobalLock( &pMac->sme );
10469 if ( HAL_STATUS_SUCCESS( status ) )
10470 {
10471 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010472 "LFR runtime successfully set immediate roam rssi diff to"
10473 "%d - old value is %d - roam state is %s",
Srinivas Girigowdade697412013-02-14 16:31:48 -080010474 nImmediateRoamRssiDiff,
10475 pMac->roam.configParam.nImmediateRoamRssiDiff,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010476 macTraceGetNeighbourRoamState(
10477 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010478 pMac->roam.configParam.nImmediateRoamRssiDiff = nImmediateRoamRssiDiff;
10479 sme_ReleaseGlobalLock( &pMac->sme );
10480 }
10481
10482 return status ;
10483}
10484
10485/* ---------------------------------------------------------------------------
10486 \fn sme_UpdateRoamRssiDiff
10487 \brief Update RoamRssiDiff
10488 This function is called through dynamic setConfig callback function
10489 to configure RoamRssiDiff
10490 Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
10491 \param hHal - HAL handle for device
10492 \param RoamRssiDiff - minimum rssi difference between potential
10493 candidate and current AP.
10494 \- return Success or failure
10495 -------------------------------------------------------------------------*/
10496
10497eHalStatus sme_UpdateRoamRssiDiff(tHalHandle hHal, v_U8_t RoamRssiDiff)
10498{
10499 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10500 eHalStatus status = eHAL_STATUS_SUCCESS;
10501
10502 status = sme_AcquireGlobalLock( &pMac->sme );
Katya Nigambcb705f2013-12-26 14:26:22 +053010503 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010504 TRACE_CODE_SME_RX_HDD_UPDATE_RSSIDIFF, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010505 if ( HAL_STATUS_SUCCESS( status ) )
10506 {
10507 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010508 "LFR runtime successfully set roam rssi diff to %d"
10509 " - old value is %d - roam state is %s",
Srinivas Girigowdade697412013-02-14 16:31:48 -080010510 RoamRssiDiff,
10511 pMac->roam.configParam.RoamRssiDiff,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010512 macTraceGetNeighbourRoamState(
10513 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010514 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
10515 sme_ReleaseGlobalLock( &pMac->sme );
10516 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010517#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10518 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
10519 {
10520 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_RSSI_DIFF_CHANGED);
10521 }
10522#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -080010523 return status ;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -080010524}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010525
10526/*--------------------------------------------------------------------------
10527 \brief sme_UpdateFastTransitionEnabled() - enable/disable Fast Transition support at runtime
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010528 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010529 isFastTransitionEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -080010530 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010531 \param hHal - The handle returned by macOpen.
10532 \return eHAL_STATUS_SUCCESS - SME update isFastTransitionEnabled config successfully.
10533 Other status means SME is failed to update isFastTransitionEnabled.
10534 \sa
10535 --------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010536eHalStatus sme_UpdateFastTransitionEnabled(tHalHandle hHal,
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010537 v_BOOL_t isFastTransitionEnabled)
10538{
10539 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -080010540 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010541
Katya Nigambcb705f2013-12-26 14:26:22 +053010542 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010543 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010544 status = sme_AcquireGlobalLock( &pMac->sme );
10545 if ( HAL_STATUS_SUCCESS( status ) )
10546 {
10547 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10548 "%s: FastTransitionEnabled is changed from %d to %d", __func__,
10549 pMac->roam.configParam.isFastTransitionEnabled,
10550 isFastTransitionEnabled);
10551 pMac->roam.configParam.isFastTransitionEnabled = isFastTransitionEnabled;
10552 sme_ReleaseGlobalLock( &pMac->sme );
10553 }
10554
10555 return status ;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010556}
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010557
10558/* ---------------------------------------------------------------------------
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -070010559 \fn sme_UpdateWESMode
10560 \brief Update WES Mode
10561 This function is called through dynamic setConfig callback function
10562 to configure isWESModeEnabled
10563 \param hHal - HAL handle for device
10564 \return eHAL_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
10565 Other status means SME is failed to update isWESModeEnabled.
10566 -------------------------------------------------------------------------*/
10567
10568eHalStatus sme_UpdateWESMode(tHalHandle hHal, v_BOOL_t isWESModeEnabled)
10569{
10570 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10571 eHalStatus status = eHAL_STATUS_SUCCESS;
10572
10573 status = sme_AcquireGlobalLock( &pMac->sme );
10574 if ( HAL_STATUS_SUCCESS( status ) )
10575 {
10576 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010577 "LFR runtime successfully set WES Mode to %d"
10578 "- old value is %d - roam state is %s",
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -070010579 isWESModeEnabled,
10580 pMac->roam.configParam.isWESModeEnabled,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010581 macTraceGetNeighbourRoamState(
10582 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -070010583 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
10584 sme_ReleaseGlobalLock( &pMac->sme );
10585 }
10586
10587 return status ;
10588}
10589
10590/* ---------------------------------------------------------------------------
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010591 \fn sme_SetRoamScanControl
10592 \brief Set roam scan control
10593 This function is called to set roam scan control
10594 if roam scan control is set to 0, roaming scan cache is cleared
10595 any value other than 0 is treated as invalid value
10596 \param hHal - HAL handle for device
10597 \return eHAL_STATUS_SUCCESS - SME update config successfully.
10598 Other status means SME failure to update
10599 -------------------------------------------------------------------------*/
10600eHalStatus sme_SetRoamScanControl(tHalHandle hHal, v_BOOL_t roamScanControl)
10601{
10602 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10603 eHalStatus status = eHAL_STATUS_SUCCESS;
10604
Katya Nigambcb705f2013-12-26 14:26:22 +053010605 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010606 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010607 status = sme_AcquireGlobalLock( &pMac->sme );
10608 if ( HAL_STATUS_SUCCESS( status ) )
10609 {
10610 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010611 "LFR runtime successfully set roam scan control to %d"
10612 " - old value is %d - roam state is %s",
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010613 roamScanControl,
10614 pMac->roam.configParam.nRoamScanControl,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010615 macTraceGetNeighbourRoamState(
10616 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010617 pMac->roam.configParam.nRoamScanControl = roamScanControl;
10618 if ( 0 == roamScanControl)
10619 {
10620 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
10621 "LFR runtime successfully cleared roam scan cache");
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010622 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010623#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10624 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
10625 {
10626 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_FLUSH_CHANNEL_LIST);
10627 }
10628#endif
10629 }
10630 sme_ReleaseGlobalLock( &pMac->sme );
10631 }
10632 return status ;
10633}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010634#endif /* (WLAN_FEATURE_VOWIFI_11R) || (FEATURE_WLAN_ESE) || (FEATURE_WLAN_LFR) */
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010635
10636#ifdef FEATURE_WLAN_LFR
10637/*--------------------------------------------------------------------------
10638 \brief sme_UpdateIsFastRoamIniFeatureEnabled() - enable/disable LFR support at runtime
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010639 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010640 isFastRoamIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -080010641 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010642 \param hHal - The handle returned by macOpen.
10643 \return eHAL_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config successfully.
10644 Other status means SME is failed to update isFastRoamIniFeatureEnabled.
10645 \sa
10646 --------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010647eHalStatus sme_UpdateIsFastRoamIniFeatureEnabled(tHalHandle hHal,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010648 const v_BOOL_t isFastRoamIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010649{
10650 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10651
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010652 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled == isFastRoamIniFeatureEnabled)
10653 {
10654 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10655 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)", __func__,
10656 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
10657 isFastRoamIniFeatureEnabled);
10658 return eHAL_STATUS_SUCCESS;
10659 }
Padma, Santhosh Kumardccd6232017-05-10 16:18:00 +053010660 if (smeNeighborMiddleOfRoaming(hHal))
10661 {
10662 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10663 "%s: In middle of roaming isFastRoamIniFeatureEnabled %d",
10664 __func__, isFastRoamIniFeatureEnabled);
10665 if (!isFastRoamIniFeatureEnabled)
10666 pMac->roam.pending_roam_disable = TRUE;
10667
10668 return eHAL_STATUS_SUCCESS;
10669 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010670
Srinivas Girigowdade697412013-02-14 16:31:48 -080010671 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10672 "%s: FastRoamEnabled is changed from %d to %d", __func__,
10673 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
10674 isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010675 pMac->roam.configParam.isFastRoamIniFeatureEnabled = isFastRoamIniFeatureEnabled;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010676 csrNeighborRoamUpdateFastRoamingEnabled(pMac, isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010677
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010678 return eHAL_STATUS_SUCCESS;
10679}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070010680
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080010681/*--------------------------------------------------------------------------
Mukul Sharma2a271632014-10-13 14:59:01 +053010682 \brief sme_ConfigFwrRoaming() - enable/disable LFR support at runtime
10683 When Supplicant issue enabled / disable fwr based roaming on the basis
10684 of the Bssid modification in network block ( e.g. AutoJoin mody N/W block)
10685
10686 This is a synchronous call
10687 \param hHal - The handle returned by macOpen.
10688 \return eHAL_STATUS_SUCCESS - SME (enabled/disabled) offload scan successfully.
10689 Other status means SME is failed to (enabled/disabled) offload scan.
10690 \sa
10691 --------------------------------------------------------------------------*/
10692
10693eHalStatus sme_ConfigFwrRoaming(tHalHandle hHal,
10694 const v_BOOL_t isFastRoamEnabled)
10695{
10696 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10697 if (!pMac->roam.configParam.isFastRoamIniFeatureEnabled)
10698 {
10699 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10700 "%s: FastRoam is disabled through ini", __func__);
10701 return eHAL_STATUS_FAILURE;
10702 }
10703 csrNeighborRoamUpdateFastRoamingEnabled(pMac, isFastRoamEnabled);
10704 return eHAL_STATUS_SUCCESS;
10705}
10706
10707/*--------------------------------------------------------------------------
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080010708 \brief sme_UpdateIsMAWCIniFeatureEnabled() -
10709 Enable/disable LFR MAWC support at runtime
10710 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
10711 isMAWCIniFeatureEnabled.
10712 This is a synchronous call
10713 \param hHal - The handle returned by macOpen.
10714 \return eHAL_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
10715 Other status means SME is failed to update MAWCEnabled.
10716 \sa
10717 --------------------------------------------------------------------------*/
10718eHalStatus sme_UpdateIsMAWCIniFeatureEnabled(tHalHandle hHal,
10719 const v_BOOL_t MAWCEnabled)
10720{
10721 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10722 eHalStatus status = eHAL_STATUS_SUCCESS;
10723
10724 status = sme_AcquireGlobalLock( &pMac->sme );
10725 if ( HAL_STATUS_SUCCESS( status ) )
10726 {
10727 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10728 "%s: MAWCEnabled is changed from %d to %d", __func__,
10729 pMac->roam.configParam.MAWCEnabled,
10730 MAWCEnabled);
10731 pMac->roam.configParam.MAWCEnabled = MAWCEnabled;
10732 sme_ReleaseGlobalLock( &pMac->sme );
10733 }
10734
10735 return status ;
10736
10737}
10738
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070010739#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10740/*--------------------------------------------------------------------------
10741 \brief sme_UpdateEnableFastRoamInConcurrency() - enable/disable LFR if Concurrent session exists
10742 This is a synchronuous call
10743 \param hHal - The handle returned by macOpen.
10744 \return eHAL_STATUS_SUCCESS
10745 Other status means SME is failed
10746 \sa
10747 --------------------------------------------------------------------------*/
10748
10749eHalStatus sme_UpdateEnableFastRoamInConcurrency(tHalHandle hHal,
10750 v_BOOL_t bFastRoamInConIniFeatureEnabled)
10751{
10752
10753 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10754 eHalStatus status = eHAL_STATUS_SUCCESS;
10755
10756 status = sme_AcquireGlobalLock( &pMac->sme );
10757 if ( HAL_STATUS_SUCCESS( status ) )
10758 {
10759 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = bFastRoamInConIniFeatureEnabled;
10760 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled)
10761 {
10762 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = 0;
10763 }
10764 sme_ReleaseGlobalLock( &pMac->sme );
10765 }
10766
10767 return status;
10768}
10769#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010770#endif /* FEATURE_WLAN_LFR */
10771
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010772#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010773/*--------------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010774 \brief sme_UpdateIsEseFeatureEnabled() - enable/disable Ese support at runtime
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010775 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010776 isEseIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -080010777 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010778 \param hHal - The handle returned by macOpen.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010779 \return eHAL_STATUS_SUCCESS - SME update isEseIniFeatureEnabled config successfully.
10780 Other status means SME is failed to update isEseIniFeatureEnabled.
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010781 \sa
10782 --------------------------------------------------------------------------*/
10783
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010784eHalStatus sme_UpdateIsEseFeatureEnabled(tHalHandle hHal,
10785 const v_BOOL_t isEseIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010786{
10787 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10788
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010789 if (pMac->roam.configParam.isEseIniFeatureEnabled == isEseIniFeatureEnabled)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010790 {
10791 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010792 "%s: Ese Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)", __func__,
10793 pMac->roam.configParam.isEseIniFeatureEnabled,
10794 isEseIniFeatureEnabled);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010795 return eHAL_STATUS_SUCCESS;
10796 }
10797
Srinivas Girigowdade697412013-02-14 16:31:48 -080010798 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010799 "%s: EseEnabled is changed from %d to %d", __func__,
10800 pMac->roam.configParam.isEseIniFeatureEnabled,
10801 isEseIniFeatureEnabled);
10802 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
10803 csrNeighborRoamUpdateEseModeEnabled(pMac, isEseIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010804
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010805 if(TRUE == isEseIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010806 {
10807 sme_UpdateFastTransitionEnabled(hHal, TRUE);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010808 }
Srinivas Girigowdaba173692013-08-07 11:55:38 -070010809
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010810#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10811 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
10812 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010813 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_ESE_INI_CFG_CHANGED);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010814 }
10815#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010816 return eHAL_STATUS_SUCCESS;
10817}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010818#endif /* FEATURE_WLAN_ESE */
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010819
10820/*--------------------------------------------------------------------------
10821 \brief sme_UpdateConfigFwRssiMonitoring() - enable/disable firmware RSSI Monitoring at runtime
10822 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
10823 fEnableFwRssiMonitoring.
Srinivas Girigowdade697412013-02-14 16:31:48 -080010824 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010825 \param hHal - The handle returned by macOpen.
10826 \return eHAL_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring. config successfully.
10827 Other status means SME is failed to update fEnableFwRssiMonitoring.
10828 \sa
10829 --------------------------------------------------------------------------*/
10830
10831eHalStatus sme_UpdateConfigFwRssiMonitoring(tHalHandle hHal,
10832 v_BOOL_t fEnableFwRssiMonitoring)
10833{
10834 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
10835
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010836 if (ccmCfgSetInt(hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR, fEnableFwRssiMonitoring,
10837 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
10838 {
10839 halStatus = eHAL_STATUS_FAILURE;
10840 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -080010841 "Failure: Could not pass on WNI_CFG_PS_RSSI_MONITOR configuration info to CCM");
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010842 }
10843
10844 return (halStatus);
10845}
10846
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010847#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srinivas Girigowdade697412013-02-14 16:31:48 -080010848/*--------------------------------------------------------------------------
10849 \brief sme_setNeighborLookupRssiThreshold() - update neighbor lookup rssi threshold
10850 This is a synchronous call
10851 \param hHal - The handle returned by macOpen.
10852 \return eHAL_STATUS_SUCCESS - SME update config successful.
10853 Other status means SME is failed to update
10854 \sa
10855 --------------------------------------------------------------------------*/
10856eHalStatus sme_setNeighborLookupRssiThreshold(tHalHandle hHal,
10857 v_U8_t neighborLookupRssiThreshold)
10858{
10859 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10860 eHalStatus status = eHAL_STATUS_SUCCESS;
10861
10862 status = sme_AcquireGlobalLock( &pMac->sme );
10863 if ( HAL_STATUS_SUCCESS( status ) )
10864 {
10865 status = csrNeighborRoamSetLookupRssiThreshold(pMac, neighborLookupRssiThreshold);
10866 if (HAL_STATUS_SUCCESS(status))
10867 {
10868 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010869 "LFR runtime successfully set Lookup threshold to %d"
10870 " - old value is %d - roam state is %s",
10871 neighborLookupRssiThreshold,
10872 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold,
10873 macTraceGetNeighbourRoamState(
10874 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010875 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
10876 neighborLookupRssiThreshold;
10877 }
10878 sme_ReleaseGlobalLock( &pMac->sme );
10879 }
Srinivas Girigowdade697412013-02-14 16:31:48 -080010880 return status;
10881}
10882
10883/*--------------------------------------------------------------------------
10884 \brief sme_setNeighborReassocRssiThreshold() - update neighbor reassoc rssi threshold
10885 This is a synchronous call
10886 \param hHal - The handle returned by macOpen.
10887 \return eHAL_STATUS_SUCCESS - SME update config successful.
10888 Other status means SME is failed to update
10889 \sa
10890 --------------------------------------------------------------------------*/
10891eHalStatus sme_setNeighborReassocRssiThreshold(tHalHandle hHal,
10892 v_U8_t neighborReassocRssiThreshold)
10893{
10894 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10895 eHalStatus status = eHAL_STATUS_SUCCESS;
10896
10897 status = sme_AcquireGlobalLock( &pMac->sme );
10898 if ( HAL_STATUS_SUCCESS( status ) )
10899 {
10900 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010901 "LFR runtime successfully set Reassoc threshold to %d"
10902 "- old value is %d - roam state is %s",
Srinivas Girigowdade697412013-02-14 16:31:48 -080010903 neighborReassocRssiThreshold,
10904 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010905 macTraceGetNeighbourRoamState(
10906 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010907 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold =
10908 neighborReassocRssiThreshold;
10909 pMac->roam.neighborRoamInfo.cfgParams.neighborReassocThreshold =
10910 neighborReassocRssiThreshold;
10911 sme_ReleaseGlobalLock( &pMac->sme );
10912 }
10913
10914 return status ;
10915}
10916
10917
10918/*--------------------------------------------------------------------------
10919 \brief sme_getNeighborLookupRssiThreshold() - get neighbor lookup rssi threshold
10920 This is a synchronous call
10921 \param hHal - The handle returned by macOpen.
10922 \return eHAL_STATUS_SUCCESS - SME update config successful.
10923 Other status means SME is failed to update
10924 \sa
10925 --------------------------------------------------------------------------*/
10926v_U8_t sme_getNeighborLookupRssiThreshold(tHalHandle hHal)
10927{
10928 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10929 return pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
10930}
10931
10932/*--------------------------------------------------------------------------
10933 \brief sme_setNeighborScanRefreshPeriod() - set neighbor scan results refresh period
10934 This is a synchronous call
10935 \param hHal - The handle returned by macOpen.
10936 \return eHAL_STATUS_SUCCESS - SME update config successful.
10937 Other status means SME is failed to update
10938 \sa
10939 --------------------------------------------------------------------------*/
10940eHalStatus sme_setNeighborScanRefreshPeriod(tHalHandle hHal,
10941 v_U16_t neighborScanResultsRefreshPeriod)
10942{
10943 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10944 eHalStatus status = eHAL_STATUS_SUCCESS;
10945
10946 status = sme_AcquireGlobalLock( &pMac->sme );
10947 if ( HAL_STATUS_SUCCESS( status ) )
10948 {
10949 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010950 "LFR runtime successfully set roam scan refresh period to %d"
10951 " - old value is %d - roam state is %s",
Srinivas Girigowdade697412013-02-14 16:31:48 -080010952 neighborScanResultsRefreshPeriod,
10953 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010954 macTraceGetNeighbourRoamState(
10955 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010956 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod =
10957 neighborScanResultsRefreshPeriod;
10958 pMac->roam.neighborRoamInfo.cfgParams.neighborResultsRefreshPeriod =
10959 neighborScanResultsRefreshPeriod;
10960
10961 sme_ReleaseGlobalLock( &pMac->sme );
10962 }
10963
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010964#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10965 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
10966 {
10967 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10968 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
10969 }
10970#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -080010971 return status ;
10972}
10973
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010974#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10975/*--------------------------------------------------------------------------
10976 \brief sme_UpdateRoamScanOffloadEnabled() - enable/disable roam scan offload feaure
10977 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
10978 gRoamScanOffloadEnabled.
10979 This is a synchronous call
10980 \param hHal - The handle returned by macOpen.
10981 \return eHAL_STATUS_SUCCESS - SME update config successfully.
10982 Other status means SME is failed to update.
10983 \sa
10984 --------------------------------------------------------------------------*/
10985
10986eHalStatus sme_UpdateRoamScanOffloadEnabled(tHalHandle hHal,
10987 v_BOOL_t nRoamScanOffloadEnabled)
10988{
10989 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10990 eHalStatus status = eHAL_STATUS_SUCCESS;
10991
10992 status = sme_AcquireGlobalLock( &pMac->sme );
10993 if ( HAL_STATUS_SUCCESS( status ) )
10994 {
10995 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10996 "%s: gRoamScanOffloadEnabled is changed from %d to %d", __func__,
10997 pMac->roam.configParam.isRoamOffloadScanEnabled,
10998 nRoamScanOffloadEnabled);
10999 pMac->roam.configParam.isRoamOffloadScanEnabled = nRoamScanOffloadEnabled;
11000 sme_ReleaseGlobalLock( &pMac->sme );
11001 }
11002
11003 return status ;
11004}
11005#endif
11006
Srinivas Girigowdade697412013-02-14 16:31:48 -080011007/*--------------------------------------------------------------------------
11008 \brief sme_getNeighborScanRefreshPeriod() - get neighbor scan results refresh period
11009 This is a synchronous call
11010 \param hHal - The handle returned by macOpen.
11011 \return v_U16_t - Neighbor scan results refresh period value
11012 \sa
11013 --------------------------------------------------------------------------*/
11014v_U16_t sme_getNeighborScanRefreshPeriod(tHalHandle hHal)
11015{
11016 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11017 return pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
11018}
11019
11020/*--------------------------------------------------------------------------
11021 \brief sme_getEmptyScanRefreshPeriod() - get empty scan refresh period
11022 This is a synchronuous call
11023 \param hHal - The handle returned by macOpen.
11024 \return eHAL_STATUS_SUCCESS - SME update config successful.
11025 Other status means SME is failed to update
11026 \sa
11027 --------------------------------------------------------------------------*/
11028v_U16_t sme_getEmptyScanRefreshPeriod(tHalHandle hHal)
11029{
11030 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11031 return pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
11032}
11033
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011034/* ---------------------------------------------------------------------------
11035 \fn sme_UpdateEmptyScanRefreshPeriod
11036 \brief Update nEmptyScanRefreshPeriod
11037 This function is called through dynamic setConfig callback function
11038 to configure nEmptyScanRefreshPeriod
11039 Usage: adb shell iwpriv wlan0 setConfig nEmptyScanRefreshPeriod=[0 .. 60]
11040 \param hHal - HAL handle for device
11041 \param nEmptyScanRefreshPeriod - scan period following empty scan results.
11042 \- return Success or failure
11043 -------------------------------------------------------------------------*/
11044
11045eHalStatus sme_UpdateEmptyScanRefreshPeriod(tHalHandle hHal, v_U16_t nEmptyScanRefreshPeriod)
11046{
11047 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11048 eHalStatus status = eHAL_STATUS_SUCCESS;
11049
11050 status = sme_AcquireGlobalLock( &pMac->sme );
11051 if ( HAL_STATUS_SUCCESS( status ) )
11052 {
11053 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011054 "LFR runtime successfully set roam scan period to %d -"
11055 "old value is %d - roam state is %s",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011056 nEmptyScanRefreshPeriod,
11057 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011058 macTraceGetNeighbourRoamState(
11059 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011060 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
11061 pMac->roam.neighborRoamInfo.cfgParams.emptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
11062 sme_ReleaseGlobalLock( &pMac->sme );
11063 }
11064
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -070011065#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11066 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
11067 {
11068 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11069 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
11070 }
11071#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011072 return status ;
11073}
11074
11075/* ---------------------------------------------------------------------------
11076 \fn sme_setNeighborScanMinChanTime
11077 \brief Update nNeighborScanMinChanTime
11078 This function is called through dynamic setConfig callback function
11079 to configure gNeighborScanChannelMinTime
11080 Usage: adb shell iwpriv wlan0 setConfig gNeighborScanChannelMinTime=[0 .. 60]
11081 \param hHal - HAL handle for device
11082 \param nNeighborScanMinChanTime - Channel minimum dwell time
11083 \- return Success or failure
11084 -------------------------------------------------------------------------*/
11085eHalStatus sme_setNeighborScanMinChanTime(tHalHandle hHal, const v_U16_t nNeighborScanMinChanTime)
11086{
11087 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11088 eHalStatus status = eHAL_STATUS_SUCCESS;
11089
11090 status = sme_AcquireGlobalLock( &pMac->sme );
11091 if ( HAL_STATUS_SUCCESS( status ) )
11092 {
11093 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011094 "LFR runtime successfully set channel min dwell time to %d"
11095 " - old value is %d - roam state is %s",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011096 nNeighborScanMinChanTime,
11097 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011098 macTraceGetNeighbourRoamState(
11099 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011100 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = nNeighborScanMinChanTime;
11101 pMac->roam.neighborRoamInfo.cfgParams.minChannelScanTime = nNeighborScanMinChanTime;
11102 sme_ReleaseGlobalLock( &pMac->sme );
11103 }
11104
11105 return status ;
11106}
11107
11108/* ---------------------------------------------------------------------------
11109 \fn sme_setNeighborScanMaxChanTime
11110 \brief Update nNeighborScanMaxChanTime
11111 This function is called through dynamic setConfig callback function
11112 to configure gNeighborScanChannelMaxTime
11113 Usage: adb shell iwpriv wlan0 setConfig gNeighborScanChannelMaxTime=[0 .. 60]
11114 \param hHal - HAL handle for device
11115 \param nNeighborScanMinChanTime - Channel maximum dwell time
11116 \- return Success or failure
11117 -------------------------------------------------------------------------*/
11118eHalStatus sme_setNeighborScanMaxChanTime(tHalHandle hHal, const v_U16_t nNeighborScanMaxChanTime)
11119{
11120 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11121 eHalStatus status = eHAL_STATUS_SUCCESS;
11122
11123 status = sme_AcquireGlobalLock( &pMac->sme );
11124 if ( HAL_STATUS_SUCCESS( status ) )
11125 {
11126 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011127 "LFR runtime successfully set channel max dwell time to %d"
11128 " - old value is %d - roam state is %s",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011129 nNeighborScanMaxChanTime,
11130 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011131 macTraceGetNeighbourRoamState(
11132 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011133 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = nNeighborScanMaxChanTime;
11134 pMac->roam.neighborRoamInfo.cfgParams.maxChannelScanTime = nNeighborScanMaxChanTime;
11135 sme_ReleaseGlobalLock( &pMac->sme );
11136 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -070011137#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11138 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
11139 {
11140 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11141 REASON_SCAN_CH_TIME_CHANGED);
11142 }
11143#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011144
11145 return status ;
11146}
11147
11148/* ---------------------------------------------------------------------------
11149 \fn sme_getNeighborScanMinChanTime
11150 \brief get neighbor scan min channel time
11151 \param hHal - The handle returned by macOpen.
11152 \return v_U16_t - channel min time value
11153 -------------------------------------------------------------------------*/
11154v_U16_t sme_getNeighborScanMinChanTime(tHalHandle hHal)
11155{
11156 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11157 return pMac->roam.neighborRoamInfo.cfgParams.minChannelScanTime;
11158}
11159
11160/* ---------------------------------------------------------------------------
11161 \fn sme_getNeighborScanMaxChanTime
11162 \brief get neighbor scan max channel time
11163 \param hHal - The handle returned by macOpen.
11164 \return v_U16_t - channel max time value
11165 -------------------------------------------------------------------------*/
11166v_U16_t sme_getNeighborScanMaxChanTime(tHalHandle hHal)
11167{
11168 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11169 return pMac->roam.neighborRoamInfo.cfgParams.maxChannelScanTime;
11170}
11171
11172/* ---------------------------------------------------------------------------
11173 \fn sme_setNeighborScanPeriod
11174 \brief Update nNeighborScanPeriod
11175 This function is called through dynamic setConfig callback function
11176 to configure nNeighborScanPeriod
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -070011177 Usage: adb shell iwpriv wlan0 setConfig nNeighborScanPeriod=[0 .. 1000]
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011178 \param hHal - HAL handle for device
11179 \param nNeighborScanPeriod - neighbor scan period
11180 \- return Success or failure
11181 -------------------------------------------------------------------------*/
11182eHalStatus sme_setNeighborScanPeriod(tHalHandle hHal, const v_U16_t nNeighborScanPeriod)
11183{
11184 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11185 eHalStatus status = eHAL_STATUS_SUCCESS;
11186
11187 status = sme_AcquireGlobalLock( &pMac->sme );
11188 if ( HAL_STATUS_SUCCESS( status ) )
11189 {
11190 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011191 "LFR runtime successfully set neighbor scan period to %d"
11192 " - old value is %d - roam state is %s",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011193 nNeighborScanPeriod,
11194 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011195 macTraceGetNeighbourRoamState(
11196 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011197 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = nNeighborScanPeriod;
11198 pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod = nNeighborScanPeriod;
11199 sme_ReleaseGlobalLock( &pMac->sme );
11200 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -070011201#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11202 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
11203 {
11204 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11205 REASON_SCAN_HOME_TIME_CHANGED);
11206 }
11207#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011208
11209 return status ;
11210}
11211
11212/* ---------------------------------------------------------------------------
11213 \fn sme_getNeighborScanPeriod
11214 \brief get neighbor scan period
11215 \param hHal - The handle returned by macOpen.
11216 \return v_U16_t - neighbor scan period
11217 -------------------------------------------------------------------------*/
11218v_U16_t sme_getNeighborScanPeriod(tHalHandle hHal)
11219{
11220 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11221 return pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
11222}
11223
11224#endif
11225
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011226#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011227
Srinivas Girigowdade697412013-02-14 16:31:48 -080011228/*--------------------------------------------------------------------------
11229 \brief sme_getRoamRssiDiff() - get Roam rssi diff
11230 This is a synchronous call
11231 \param hHal - The handle returned by macOpen.
11232 \return v_U16_t - Rssi diff value
11233 \sa
11234 --------------------------------------------------------------------------*/
11235v_U8_t sme_getRoamRssiDiff(tHalHandle hHal)
11236{
11237 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11238 return pMac->roam.configParam.RoamRssiDiff;
11239}
11240
11241/*--------------------------------------------------------------------------
11242 \brief sme_ChangeRoamScanChannelList() - Change roam scan channel list
11243 This is a synchronous call
11244 \param hHal - The handle returned by macOpen.
11245 \return eHAL_STATUS_SUCCESS - SME update config successful.
11246 Other status means SME is failed to update
11247 \sa
11248 --------------------------------------------------------------------------*/
11249eHalStatus sme_ChangeRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
11250 tANI_U8 numChannels)
11251{
11252 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11253 eHalStatus status = eHAL_STATUS_SUCCESS;
11254 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011255 tANI_U8 oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
Kiet Lam600d3ca2013-08-31 16:33:32 +053011256 tANI_U8 newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
Srinivas Girigowdade697412013-02-14 16:31:48 -080011257 tANI_U8 i = 0, j = 0;
11258
11259 status = sme_AcquireGlobalLock( &pMac->sme );
11260 if ( HAL_STATUS_SUCCESS( status ) )
11261 {
11262 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
11263 {
11264 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
11265 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011266 if (j < sizeof(oldChannelList))
11267 {
11268 j += snprintf(oldChannelList + j, sizeof(oldChannelList) - j," %d",
11269 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
11270 }
11271 else
11272 {
11273 break;
11274 }
Srinivas Girigowdade697412013-02-14 16:31:48 -080011275 }
11276 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011277 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011278 csrCreateBgScanRoamChannelList(pMac, pChannelList, numChannels);
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080011279 sme_SetRoamScanControl(hHal, 1);
11280 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -080011281 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080011282 j = 0;
11283 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
Srinivas Girigowdade697412013-02-14 16:31:48 -080011284 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011285 if (j < sizeof(oldChannelList))
11286 {
11287 j += snprintf(newChannelList + j, sizeof(newChannelList) - j," %d",
11288 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
11289 }
11290 else
11291 {
11292 break;
11293 }
Srinivas Girigowdade697412013-02-14 16:31:48 -080011294 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011295 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080011296
11297 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011298 "LFR runtime successfully set roam scan channels to %s"
11299 "- old value is %s - roam state is %s",
11300 newChannelList, oldChannelList,
11301 macTraceGetNeighbourRoamState(
11302 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080011303 sme_ReleaseGlobalLock( &pMac->sme );
11304 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011305#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11306 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
11307 {
11308 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
11309 }
11310#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -080011311
11312 return status ;
11313}
11314
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011315
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011316#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011317/*--------------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011318 \brief sme_SetEseRoamScanChannelList() - set ese roam scan channel list
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011319 This is a synchronuous call
11320 \param hHal - The handle returned by macOpen.
11321 \return eHAL_STATUS_SUCCESS - SME update config successful.
11322 Other status means SME is failed to update
11323 \sa
11324 --------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011325eHalStatus sme_SetEseRoamScanChannelList(tHalHandle hHal,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011326 tANI_U8 *pChannelList,
11327 tANI_U8 numChannels)
11328{
11329 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11330 eHalStatus status = eHAL_STATUS_SUCCESS;
11331 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
11332 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
11333 tANI_U8 oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
11334 tANI_U8 newChannelList[128] = {0};
11335 tANI_U8 i = 0, j = 0;
11336
11337 status = sme_AcquireGlobalLock( &pMac->sme );
11338 if ( HAL_STATUS_SUCCESS( status ) )
11339 {
11340 if (NULL != currChannelListInfo->ChannelList)
11341 {
11342 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
11343 {
11344 j += snprintf(oldChannelList + j, sizeof(oldChannelList) - j," %d",
11345 currChannelListInfo->ChannelList[i]);
11346 }
11347 }
11348 status = csrCreateRoamScanChannelList(pMac, pChannelList, numChannels, csrGetCurrentBand(hHal));
11349
11350 if ( HAL_STATUS_SUCCESS( status ))
11351 {
11352 if (NULL != currChannelListInfo->ChannelList)
11353 {
11354 j = 0;
11355 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
11356 {
11357 j += snprintf(newChannelList + j, sizeof(newChannelList) - j," %d",
11358 currChannelListInfo->ChannelList[i]);
11359 }
11360 }
11361
11362 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011363 "ESE roam scan channel list successfully set to %s - old value is %s - roam state is %s",
11364 newChannelList, oldChannelList,
11365 macTraceGetNeighbourRoamState(pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011366 }
11367 sme_ReleaseGlobalLock( &pMac->sme );
11368 }
11369#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11370 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
11371 {
11372 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
11373 }
11374#endif
11375
11376 return status ;
11377}
11378#endif
11379
Srinivas Girigowdade697412013-02-14 16:31:48 -080011380/*--------------------------------------------------------------------------
Srinivas Girigowdade697412013-02-14 16:31:48 -080011381 \brief sme_getRoamScanChannelList() - get roam scan channel list
11382 This is a synchronous call
11383 \param hHal - The handle returned by macOpen.
11384 \return eHAL_STATUS_SUCCESS - SME update config successful.
11385 Other status means SME is failed to update
11386 \sa
11387 --------------------------------------------------------------------------*/
11388eHalStatus sme_getRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
11389 tANI_U8 *pNumChannels)
11390{
11391 int i = 0;
11392 tANI_U8 *pOutPtr = pChannelList;
11393 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11394 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
11395 eHalStatus status = eHAL_STATUS_SUCCESS;
11396
11397 status = sme_AcquireGlobalLock( &pMac->sme );
11398 if ( HAL_STATUS_SUCCESS( status ) )
11399 {
11400 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
11401 {
11402 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
11403 "Roam Scan channel list is NOT yet initialized");
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011404 *pNumChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -080011405 sme_ReleaseGlobalLock( &pMac->sme );
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011406 return status;
Srinivas Girigowdade697412013-02-14 16:31:48 -080011407 }
11408
11409 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
11410 for (i = 0; i < (*pNumChannels); i++)
11411 {
11412 pOutPtr[i] = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
11413 }
11414 pOutPtr[i] = '\0';
11415 sme_ReleaseGlobalLock( &pMac->sme );
11416 }
Srinivas Girigowdade697412013-02-14 16:31:48 -080011417 return status ;
11418}
11419
11420/*--------------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011421 \brief sme_getIsEseFeatureEnabled() - get Ese feature enabled or not
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011422 This is a synchronuous call
11423 \param hHal - The handle returned by macOpen.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011424 \return TRUE (1) - if the Ese feature is enabled
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011425 FALSE (0) - if feature is disabled (compile or runtime)
11426 \sa
11427 --------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011428tANI_BOOLEAN sme_getIsEseFeatureEnabled(tHalHandle hHal)
Srinivas Girigowdade697412013-02-14 16:31:48 -080011429{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011430#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdade697412013-02-14 16:31:48 -080011431 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011432 return csrRoamIsEseIniFeatureEnabled(pMac);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011433#else
11434 return eANI_BOOLEAN_FALSE;
11435#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -080011436}
11437
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011438/*--------------------------------------------------------------------------
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -070011439 \brief sme_GetWESMode() - get WES Mode
11440 This is a synchronous call
11441 \param hHal - The handle returned by macOpen
11442 \return v_U8_t - WES Mode Enabled(1)/Disabled(0)
11443 \sa
11444 --------------------------------------------------------------------------*/
11445v_BOOL_t sme_GetWESMode(tHalHandle hHal)
11446{
11447 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11448 return pMac->roam.configParam.isWESModeEnabled;
11449}
11450
11451/*--------------------------------------------------------------------------
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011452 \brief sme_GetRoamScanControl() - get scan control
11453 This is a synchronous call
11454 \param hHal - The handle returned by macOpen.
11455 \return v_BOOL_t - Enabled(1)/Disabled(0)
11456 \sa
11457 --------------------------------------------------------------------------*/
11458v_BOOL_t sme_GetRoamScanControl(tHalHandle hHal)
11459{
11460 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11461 return pMac->roam.configParam.nRoamScanControl;
11462}
11463#endif
11464
11465/*--------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011466 \brief sme_getIsLfrFeatureEnabled() - get LFR feature enabled or not
11467 This is a synchronuous call
11468 \param hHal - The handle returned by macOpen.
11469 \return TRUE (1) - if the feature is enabled
11470 FALSE (0) - if feature is disabled (compile or runtime)
11471 \sa
11472 --------------------------------------------------------------------------*/
11473tANI_BOOLEAN sme_getIsLfrFeatureEnabled(tHalHandle hHal)
11474{
11475#ifdef FEATURE_WLAN_LFR
11476 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11477 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
11478#else
11479 return eANI_BOOLEAN_FALSE;
11480#endif
11481}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -080011482
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011483/*--------------------------------------------------------------------------
11484 \brief sme_getIsFtFeatureEnabled() - get FT feature enabled or not
11485 This is a synchronuous call
11486 \param hHal - The handle returned by macOpen.
11487 \return TRUE (1) - if the feature is enabled
11488 FALSE (0) - if feature is disabled (compile or runtime)
11489 \sa
11490 --------------------------------------------------------------------------*/
11491tANI_BOOLEAN sme_getIsFtFeatureEnabled(tHalHandle hHal)
11492{
11493#ifdef WLAN_FEATURE_VOWIFI_11R
11494 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11495 return pMac->roam.configParam.isFastTransitionEnabled;
11496#else
11497 return eANI_BOOLEAN_FALSE;
11498#endif
11499}
11500
Abhishek Singh00b71972016-01-07 10:51:04 +053011501
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011502/* ---------------------------------------------------------------------------
11503 \fn sme_IsFeatureSupportedByFW
Kiet Lam0f320422013-11-21 19:29:17 +053011504 \brief Check if a feature is enabled by FW
11505
11506 \param featEnumValue - Enumeration value from placeHolderInCapBitmap
11507 \- return 1/0 (TRUE/FALSE)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011508 -------------------------------------------------------------------------*/
11509tANI_U8 sme_IsFeatureSupportedByFW(tANI_U8 featEnumValue)
11510{
11511 return IS_FEATURE_SUPPORTED_BY_FW(featEnumValue);
11512}
Kiet Lam0f320422013-11-21 19:29:17 +053011513
11514/* ---------------------------------------------------------------------------
11515 \fn sme_IsFeatureSupportedByDriver
11516 \brief Check if a feature is enabled by Driver
11517
11518 \param featEnumValue - Enumeration value from placeHolderInCapBitmap
11519 \- return 1/0 (TRUE/FALSE)
11520 -------------------------------------------------------------------------*/
11521
11522tANI_U8 sme_IsFeatureSupportedByDriver(tANI_U8 featEnumValue)
11523{
11524 return IS_FEATURE_SUPPORTED_BY_DRIVER(featEnumValue);
11525}
11526
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011527#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011528
11529/* ---------------------------------------------------------------------------
11530 \fn sme_SendTdlsMgmtFrame
11531 \brief API to send TDLS management frames.
11532
11533 \param peerMac - peer's Mac Adress.
11534 \param tdlsLinkEstablishParams - TDLS Peer Link Establishment Parameters
11535 \- return VOS_STATUS_SUCCES
11536 -------------------------------------------------------------------------*/
11537VOS_STATUS sme_SendTdlsLinkEstablishParams(tHalHandle hHal,
Anand N Sunkadc205d952015-07-30 15:36:03 +053011538 tANI_U8 sessionId,
11539#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11540 const tSirMacAddr peerMac,
11541#else
11542 tSirMacAddr peerMac,
11543#endif
11544 tCsrTdlsLinkEstablishParams *tdlsLinkEstablishParams)
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011545{
11546 eHalStatus status = eHAL_STATUS_SUCCESS;
11547 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11548
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011549 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11550 TRACE_CODE_SME_RX_HDD_TDLS_LINK_ESTABLISH_PARAM,
11551 sessionId, tdlsLinkEstablishParams->isOffChannelSupported));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011552 status = sme_AcquireGlobalLock( &pMac->sme );
11553
11554 if ( HAL_STATUS_SUCCESS( status ) )
11555 {
11556 status = csrTdlsSendLinkEstablishParams(hHal, sessionId, peerMac, tdlsLinkEstablishParams) ;
11557 sme_ReleaseGlobalLock( &pMac->sme );
11558 }
11559 return status ;
11560}
11561
Atul Mittalc0f739f2014-07-31 13:47:47 +053011562// tdlsoffchan
11563
11564/* ---------------------------------------------------------------------------
11565 \fn sme_SendTdlsChanSwitchReq
11566 \brief API to send TDLS management frames.
11567
11568 \param peerMac - peer's Mac Adress.
11569 \param tdlsLinkEstablishParams - TDLS Peer Link Establishment Parameters
11570 \- return VOS_STATUS_SUCCES
11571 -------------------------------------------------------------------------*/
11572VOS_STATUS sme_SendTdlsChanSwitchReq(tHalHandle hHal,
11573 tANI_U8 sessionId,
11574 tSirMacAddr peerMac,
11575 tANI_S32 tdlsOffCh,
11576 tANI_S32 tdlsOffChBwOffset,
11577 tANI_U8 tdlsSwMode)
11578{
11579 eHalStatus status = eHAL_STATUS_SUCCESS;
11580 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11581
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011582 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11583 TRACE_CODE_SME_RX_HDD_TDLS_CHAN_SWITCH_REQ,
11584 sessionId, tdlsOffCh));
Atul Mittalc0f739f2014-07-31 13:47:47 +053011585 status = sme_AcquireGlobalLock( &pMac->sme );
11586
11587 if ( HAL_STATUS_SUCCESS( status ) )
11588 {
11589 status = csrTdlsSendChanSwitchReq(hHal, sessionId, peerMac,
11590 tdlsOffCh, tdlsOffChBwOffset,
11591 tdlsSwMode);
11592 }
11593 sme_ReleaseGlobalLock( &pMac->sme );
11594 return status ;
11595}
11596
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011597/* ---------------------------------------------------------------------------
11598 \fn sme_SendTdlsMgmtFrame
11599 \brief API to send TDLS management frames.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070011600
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011601 \param peerMac - peer's Mac Adress.
11602 \param frame_type - Type of TDLS mgmt frame to be sent.
11603 \param dialog - dialog token used in the frame.
11604 \param status - status to be incuded in the frame.
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053011605 \param peerCapability - peer cpabilities
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011606 \param buf - additional IEs to be included
11607 \param len - lenght of additional Ies
Hoonki Leea34dd892013-02-05 22:56:02 -080011608 \param responder - Tdls request type
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011609 \- return VOS_STATUS_SUCCES
11610 -------------------------------------------------------------------------*/
Anand N Sunkadc205d952015-07-30 15:36:03 +053011611VOS_STATUS sme_SendTdlsMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
11612#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11613 const tSirMacAddr peerMac,
11614#else
11615 tSirMacAddr peerMac,
11616#endif
11617 tANI_U8 frame_type, tANI_U8 dialog,
11618 tANI_U16 statusCode, tANI_U32 peerCapability,
11619 tANI_U8 *buf, tANI_U8 len, tANI_U8 responder)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011620{
11621 eHalStatus status = eHAL_STATUS_SUCCESS;
11622 tCsrTdlsSendMgmt sendTdlsReq = {{0}} ;
11623 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11624
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011625 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11626 TRACE_CODE_SME_RX_HDD_TDLS_SEND_MGMT_FRAME,
11627 sessionId, statusCode));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011628 status = sme_AcquireGlobalLock( &pMac->sme );
11629 if ( HAL_STATUS_SUCCESS( status ) )
11630 {
11631 vos_mem_copy(sendTdlsReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
11632 sendTdlsReq.frameType = frame_type;
11633 sendTdlsReq.buf = buf;
11634 sendTdlsReq.len = len;
11635 sendTdlsReq.dialog = dialog;
11636 sendTdlsReq.statusCode = statusCode;
Hoonki Leea34dd892013-02-05 22:56:02 -080011637 sendTdlsReq.responder = responder;
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053011638 sendTdlsReq.peerCapability = peerCapability;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011639
11640 status = csrTdlsSendMgmtReq(hHal, sessionId, &sendTdlsReq) ;
11641
11642 sme_ReleaseGlobalLock( &pMac->sme );
11643 }
11644
11645 return status ;
11646
11647}
11648/* ---------------------------------------------------------------------------
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011649 \fn sme_ChangeTdlsPeerSta
11650 \brief API to Update TDLS peer sta parameters.
11651
11652 \param peerMac - peer's Mac Adress.
11653 \param staParams - Peer Station Parameters
11654 \- return VOS_STATUS_SUCCES
11655 -------------------------------------------------------------------------*/
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011656VOS_STATUS sme_ChangeTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId,
11657#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11658 const tSirMacAddr peerMac,
11659#else
11660 tSirMacAddr peerMac,
11661#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011662 tCsrStaParams *pstaParams)
11663{
11664 eHalStatus status = eHAL_STATUS_SUCCESS;
11665 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11666
Sushant Kaushikd62d9782014-02-19 15:39:40 +053011667 if (NULL == pstaParams)
11668 {
11669 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
11670 "%s :pstaParams is NULL",__func__);
11671 return eHAL_STATUS_FAILURE;
11672 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011673
11674 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11675 TRACE_CODE_SME_RX_HDD_TDLS_CHANGE_PEER_STA, sessionId,
11676 pstaParams->capability));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011677 status = sme_AcquireGlobalLock( &pMac->sme );
11678 if ( HAL_STATUS_SUCCESS( status ) )
11679 {
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011680 status = csrTdlsChangePeerSta(hHal, sessionId, peerMac, pstaParams);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011681
11682 sme_ReleaseGlobalLock( &pMac->sme );
11683 }
11684
11685 return status ;
11686
11687}
11688
11689/* ---------------------------------------------------------------------------
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011690 \fn sme_AddTdlsPeerSta
11691 \brief API to Add TDLS peer sta entry.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070011692
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011693 \param peerMac - peer's Mac Adress.
11694 \- return VOS_STATUS_SUCCES
11695 -------------------------------------------------------------------------*/
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011696VOS_STATUS sme_AddTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId,
11697#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11698 const tSirMacAddr peerMac
11699#else
11700 tSirMacAddr peerMac
11701#endif
11702 )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011703{
11704 eHalStatus status = eHAL_STATUS_SUCCESS;
11705 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11706
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011707 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11708 TRACE_CODE_SME_RX_HDD_TDLS_ADD_PEER_STA,
11709 sessionId, 0));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011710 status = sme_AcquireGlobalLock( &pMac->sme );
11711 if ( HAL_STATUS_SUCCESS( status ) )
11712 {
11713 status = csrTdlsAddPeerSta(hHal, sessionId, peerMac);
11714
11715 sme_ReleaseGlobalLock( &pMac->sme );
11716 }
11717
11718 return status ;
11719
11720}
11721/* ---------------------------------------------------------------------------
11722 \fn sme_DeleteTdlsPeerSta
11723 \brief API to Delete TDLS peer sta entry.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070011724
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011725 \param peerMac - peer's Mac Adress.
11726 \- return VOS_STATUS_SUCCES
11727 -------------------------------------------------------------------------*/
Anand N Sunkadc205d952015-07-30 15:36:03 +053011728VOS_STATUS sme_DeleteTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId,
11729#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11730 const tSirMacAddr peerMac
11731#else
11732 tSirMacAddr peerMac
11733#endif
11734)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011735{
11736 eHalStatus status = eHAL_STATUS_SUCCESS;
11737 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11738
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011739 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11740 TRACE_CODE_SME_RX_HDD_TDLS_DEL_PEER_STA,
11741 sessionId, 0));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011742 status = sme_AcquireGlobalLock( &pMac->sme );
11743 if ( HAL_STATUS_SUCCESS( status ) )
11744 {
11745 status = csrTdlsDelPeerSta(hHal, sessionId, peerMac) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011746 sme_ReleaseGlobalLock( &pMac->sme );
11747 }
11748
11749 return status ;
11750
11751}
Gopichand Nakkala75e7b282013-03-15 18:37:13 -070011752/* ---------------------------------------------------------------------------
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070011753 \fn sme_SetTdlsPowerSaveProhibited
11754 \API to set/reset the isTdlsPowerSaveProhibited.
11755
11756 \- return void
11757 -------------------------------------------------------------------------*/
11758void sme_SetTdlsPowerSaveProhibited(tHalHandle hHal, v_BOOL_t val)
11759{
11760 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11761
11762 pMac->isTdlsPowerSaveProhibited = val;
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053011763 smsLog(pMac, LOG1, FL("isTdlsPowerSaveProhibited is %d"),
11764 pMac->isTdlsPowerSaveProhibited);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070011765 return;
11766}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011767#endif
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +053011768/* ---------------------------------------------------------------------------
11769 \fn sme_IsPmcBmps
11770 \API to Check if PMC state is BMPS.
11771
11772 \- return v_BOOL_t
11773 -------------------------------------------------------------------------*/
11774v_BOOL_t sme_IsPmcBmps(tHalHandle hHal)
11775{
11776 return (BMPS == pmcGetPmcState(hHal));
11777}
11778
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -070011779eHalStatus sme_UpdateDfsSetting(tHalHandle hHal, tANI_U8 fUpdateEnableDFSChnlScan)
11780{
11781 eHalStatus status = eHAL_STATUS_FAILURE;
11782 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11783
11784 smsLog(pMac, LOG2, FL("enter"));
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053011785
11786 if (pMac->fActiveScanOnDFSChannels)
11787 {
11788 smsLog(pMac, LOG1, FL("Skip updating fEnableDFSChnlScan"
11789 " as DFS feature is triggered"));
11790 return (status);
11791 }
11792
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -070011793 status = sme_AcquireGlobalLock( &pMac->sme );
11794 if ( HAL_STATUS_SUCCESS( status ) )
11795 {
11796 pMac->scan.fEnableDFSChnlScan = fUpdateEnableDFSChnlScan;
11797 sme_ReleaseGlobalLock( &pMac->sme );
11798 }
11799 smsLog(pMac, LOG2, FL("exit status %d"), status);
11800
11801 return (status);
11802}
11803
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053011804/* ---------------------------------------------------------------------------
11805 \fn sme_UpdateDFSRoamMode
11806 \brief Update DFS roam scan mode
11807 This function is called to configure allowDFSChannelRoam
11808 dynamically
11809 \param hHal - HAL handle for device
11810 \param allowDFSChannelRoam - DFS roaming scan mode
11811 mode 0 disable roam scan on DFS channels
11812 mode 1 enables roam scan (passive/active) on DFS channels
11813 \return eHAL_STATUS_SUCCESS - SME update DFS roaming scan config
11814 successfully.
11815 Other status means SME failed to update DFS roaming scan config.
11816 \sa
11817 -------------------------------------------------------------------------*/
11818eHalStatus sme_UpdateDFSRoamMode(tHalHandle hHal, tANI_U8 allowDFSChannelRoam)
11819{
11820 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11821 eHalStatus status = eHAL_STATUS_SUCCESS;
11822
11823 status = sme_AcquireGlobalLock( &pMac->sme );
11824 if ( HAL_STATUS_SUCCESS( status ) )
11825 {
11826 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
11827 "LFR runtime successfully set AllowDFSChannelRoam Mode to "
11828 "%d - old value is %d",
11829 allowDFSChannelRoam,
11830 pMac->roam.configParam.allowDFSChannelRoam);
11831 pMac->roam.configParam.allowDFSChannelRoam = allowDFSChannelRoam;
11832 sme_ReleaseGlobalLock( &pMac->sme );
11833 }
11834#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11835 if (csrRoamIsRoamOffloadScanEnabled(pMac))
11836 {
11837 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11838 REASON_CHANNEL_LIST_CHANGED);
11839 }
11840#endif
11841
11842 return status ;
11843}
11844
11845/* ---------------------------------------------------------------------------
11846 \fn sme_UpdateDFSScanMode
11847 \brief Update DFS scan mode
11848 This function is called to configure fEnableDFSChnlScan.
11849 \param hHal - HAL handle for device
11850 \param dfsScanMode - DFS scan mode
11851 mode 0 disable scan on DFS channels
11852 mode 1 enables passive scan on DFS channels
11853 mode 2 enables active scan on DFS channels for static list
11854 \return eHAL_STATUS_SUCCESS - SME update DFS roaming scan config
11855 successfully.
11856 Other status means SME failed to update DFS scan config.
11857 \sa
11858 -------------------------------------------------------------------------*/
11859eHalStatus sme_UpdateDFSScanMode(tHalHandle hHal, tANI_U8 dfsScanMode)
11860{
11861 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11862 eHalStatus status = eHAL_STATUS_SUCCESS;
11863
11864 status = sme_AcquireGlobalLock( &pMac->sme );
11865 if ( HAL_STATUS_SUCCESS( status ) )
11866 {
11867 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
11868 "DFS scan Mode changed to %d, old value is %d ",
11869 dfsScanMode,
11870 pMac->scan.fEnableDFSChnlScan);
11871 pMac->scan.fEnableDFSChnlScan = dfsScanMode;
11872 sme_ReleaseGlobalLock( &pMac->sme );
11873 }
11874
11875 sme_FilterScanDFSResults(hHal);
11876 sme_UpdateChannelList( hHal );
11877
11878 return status ;
11879}
11880
11881/*--------------------------------------------------------------------------
11882 \brief sme_GetDFSScanMode() - get DFS scan mode
11883 \param hHal - The handle returned by macOpen.
11884 \return DFS scan mode
11885 mode 0 disable scan on DFS channels
11886 mode 1 enables passive scan on DFS channels
11887 mode 2 enables active scan on DFS channels for static list
11888 \sa
11889 --------------------------------------------------------------------------*/
11890v_U8_t sme_GetDFSScanMode(tHalHandle hHal)
11891{
11892 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11893 return pMac->scan.fEnableDFSChnlScan;
11894}
11895
11896/* ---------------------------------------------------------------------------
11897 \fn sme_HandleDFSChanScan
11898 \brief Gets Valid channel list and updates scan control list according to
11899 dfsScanMode
11900 \param hHal - HAL handle for device
11901 \return eHAL_STATUS_FAILURE when failed to get valid channel list
11902 Otherwise eHAL_STATUS_SUCCESS -
11903 \sa
11904 -------------------------------------------------------------------------*/
11905eHalStatus sme_HandleDFSChanScan(tHalHandle hHal)
11906{
11907 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11908 eHalStatus status = eHAL_STATUS_SUCCESS;
11909 tCsrChannel ChannelList;
11910
Abhishek Singh5f391bd2016-05-04 12:52:45 +053011911 /*
11912 * Set Flag to block driver scan type conversion from active to passive
11913 * and vice versa in case if fEnableDFSChnlScan is
11914 * DFS_CHNL_SCAN_ENABLED_ACTIVE
11915 */
11916 if (DFS_CHNL_SCAN_ENABLED_ACTIVE ==
11917 pMac->scan.fEnableDFSChnlScan)
11918 pMac->fActiveScanOnDFSChannels = 1;
11919 else
11920 pMac->fActiveScanOnDFSChannels = 0;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053011921
11922 ChannelList.numChannels = sizeof(ChannelList.channelList);
11923 status = sme_GetCfgValidChannels(hHal, (tANI_U8 *)ChannelList.channelList,
11924 (tANI_U32*)&ChannelList.numChannels);
11925 if (!HAL_STATUS_SUCCESS(status))
11926 {
11927 smsLog(pMac, LOGE,
11928 FL("Failed to get valid channel list (err=%d)"), status);
11929 return status;
11930 }
11931
11932 smsLog(pMac, LOG1, FL("Valid Channel list:"));
11933 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
11934 ChannelList.channelList, ChannelList.numChannels);
11935
11936 sme_SetCfgScanControlList(hHal, pMac->scan.countryCodeCurrent,
11937 &ChannelList);
11938 return status ;
11939}
11940
Gopichand Nakkalae620d5a2013-04-26 05:45:57 -070011941/*
11942 * SME API to enable/disable WLAN driver initiated SSR
11943 */
11944void sme_UpdateEnableSSR(tHalHandle hHal, tANI_BOOLEAN enableSSR)
11945{
11946 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11947 eHalStatus status = eHAL_STATUS_SUCCESS;
11948
11949 status = sme_AcquireGlobalLock(&pMac->sme);
11950 if (HAL_STATUS_SUCCESS(status))
11951 {
11952 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
11953 "SSR level is changed %d", enableSSR);
11954 /* not serializing this messsage, as this is only going
11955 * to set a variable in WDA/WDI
11956 */
11957 WDA_SetEnableSSR(enableSSR);
11958 sme_ReleaseGlobalLock(&pMac->sme);
11959 }
11960 return;
11961}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011962
11963/*
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053011964 * SME API to stringify bonding mode. (hostapd convention)
11965 */
11966
11967static const char* sme_CBMode2String( tANI_U32 mode)
11968{
11969 switch (mode)
11970 {
11971 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
11972 return "HT20";
11973 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
11974 return "HT40-"; /* lower secondary channel */
11975 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
11976 return "HT40+"; /* upper secondary channel */
11977#ifdef WLAN_FEATURE_11AC
11978 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
11979 return "VHT80+40+"; /* upper secondary channels */
11980 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
11981 return "VHT80+40-"; /* 1 lower and 2 upper secondary channels */
11982 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
11983 return "VHT80-40+"; /* 2 lower and 1 upper secondary channels */
11984 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
11985 return "VHT80-40-"; /* lower secondary channels */
11986#endif
11987 default:
11988 VOS_ASSERT(0);
11989 return "Unknown";
11990 }
11991}
11992
11993/*
Abhishek Singh6b27f072015-09-10 14:46:33 +053011994 * SME API to adjust bonding mode to regulatory .. etc.
11995 *
11996 */
11997static VOS_STATUS sme_AdjustCBMode(tAniSirGlobal* pMac,
11998 tSmeConfigParams *smeConfig,
11999 tANI_U8 channel)
12000{
12001 const tANI_U8 step = SME_START_CHAN_STEP;
12002 tANI_U8 i, startChan = channel, chanCnt = 0, chanBitmap = 0;
12003 tANI_BOOLEAN violation = VOS_FALSE;
12004 tANI_U32 newMode, mode;
12005 tANI_U8 centerChan = channel;
12006 /* to validate 40MHz channels against the regulatory domain */
12007 tANI_BOOLEAN ht40PhyMode = VOS_FALSE;
12008
12009 /* get the bonding mode */
12010 mode = (channel <= 14) ? smeConfig->csrConfig.channelBondingMode24GHz :
12011 smeConfig->csrConfig.channelBondingMode5GHz;
12012 newMode = mode;
12013
12014 /* get the channels */
12015 switch (mode)
12016 {
12017 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
12018 startChan = channel;
12019 chanCnt = 1;
12020 break;
12021 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
12022 startChan = channel - step;
12023 chanCnt = 2;
12024 centerChan = channel - CSR_CB_CENTER_CHANNEL_OFFSET;
12025 ht40PhyMode = VOS_TRUE;
12026 break;
12027 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
12028 startChan = channel;
12029 chanCnt=2;
12030 centerChan = channel + CSR_CB_CENTER_CHANNEL_OFFSET;
12031 ht40PhyMode = VOS_TRUE;
12032 break;
12033#ifdef WLAN_FEATURE_11AC
12034 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
12035 startChan = channel;
12036 chanCnt = 4;
12037 break;
12038 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
12039 startChan = channel - step;
12040 chanCnt = 4;
12041 break;
12042 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
12043 startChan = channel - 2*step;
12044 chanCnt = 4;
12045 break;
12046 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
12047 startChan = channel - 3*step;
12048 chanCnt = 4;
12049 break;
12050#endif
12051 default:
12052 VOS_ASSERT(0);
12053 return VOS_STATUS_E_FAILURE;
12054 }
12055
12056 /* find violation; also map valid channels to a bitmap */
12057 for (i = 0; i < chanCnt; i++)
12058 {
12059 if (csrIsValidChannel(pMac, (startChan + (i * step))) ==
12060 eHAL_STATUS_SUCCESS)
12061 chanBitmap = chanBitmap | 1 << i;
12062 else
12063 violation = VOS_TRUE;
12064 }
12065 /* validate if 40MHz channel is allowed */
12066 if (ht40PhyMode)
12067 {
12068 if (!csrRoamIsValid40MhzChannel(pMac, centerChan))
12069 violation = VOS_TRUE;
12070 }
12071
12072 /* no channels are valid */
12073 if (chanBitmap == 0)
12074 {
12075 /* never be in this case */
12076 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12077 FL("channel %d %s is not supported"),
12078 channel,
12079 sme_CBMode2String(mode));
12080 return VOS_STATUS_E_INVAL;
12081 }
12082
12083 /* fix violation */
12084 if (violation)
12085 {
12086 const tANI_U8 lowerMask = 0x03, upperMask = 0x0c;
12087 /* fall back to single channel in all exception cases */
12088 newMode = eCSR_INI_SINGLE_CHANNEL_CENTERED;
12089
12090 switch (mode)
12091 {
12092 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
12093 /* fall thru */
12094 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
12095 /* fall thru */
12096 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
12097 break;
12098#ifdef WLAN_FEATURE_11AC
12099 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
12100 if ((chanBitmap & lowerMask) == lowerMask)
12101 newMode = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
12102 break;
12103 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
12104 if ((chanBitmap & lowerMask) == lowerMask)
12105 newMode = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
12106 break;
12107 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
12108 if ((chanBitmap & upperMask) == upperMask)
12109 newMode = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
12110 break;
12111 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
12112 if ((chanBitmap & upperMask) == upperMask)
12113 newMode = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
12114 break;
12115#endif
12116 default:
12117 return VOS_STATUS_E_NOSUPPORT;
12118 break;
12119 }
12120
12121 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
12122 FL("bonding mode adjust: %s to %s"),
12123 sme_CBMode2String(mode),
12124 sme_CBMode2String(newMode));
12125
12126 }
12127
12128 /* check for mode change */
12129 if (newMode != mode)
12130 {
12131 if (channel <= 14)
12132 smeConfig->csrConfig.channelBondingMode24GHz = newMode;
12133 else
12134 smeConfig->csrConfig.channelBondingMode5GHz = newMode;
12135 }
12136
12137 return VOS_STATUS_SUCCESS;
12138
12139}
12140
12141/*
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012142 * SME API to determine the channel bonding mode
12143 */
Abhishek Singh02b823e2017-10-30 17:53:20 +053012144VOS_STATUS sme_SelectCBMode(tHalHandle hHal,
12145 eCsrPhyMode eCsrPhyMode, tANI_U8 channel,
12146 enum eSirMacHTChannelWidth max_bw)
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012147{
12148 tSmeConfigParams smeConfig;
12149 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Abhishek Singh4fe2b6b2015-09-15 17:13:27 +053012150#ifdef WLAN_FEATURE_11AC
12151 tANI_U8 vht80Allowed;
12152#endif
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012153
12154 if (
12155#ifdef WLAN_FEATURE_11AC
12156 eCSR_DOT11_MODE_11ac != eCsrPhyMode &&
12157 eCSR_DOT11_MODE_11ac_ONLY != eCsrPhyMode &&
12158#endif
12159 eCSR_DOT11_MODE_11n != eCsrPhyMode &&
krunal soni634aba32014-03-06 17:46:50 -080012160 eCSR_DOT11_MODE_11n_ONLY != eCsrPhyMode &&
12161
12162 eCSR_DOT11_MODE_11a != eCsrPhyMode &&
12163 eCSR_DOT11_MODE_11a_ONLY != eCsrPhyMode &&
12164
12165 eCSR_DOT11_MODE_abg != eCsrPhyMode
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012166 )
12167 {
12168 return VOS_STATUS_SUCCESS;
12169 }
12170
Kaushik, Sushant553a06c2014-11-26 15:29:40 +053012171 vos_mem_zero(&smeConfig, sizeof (tSmeConfigParams));
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012172 sme_GetConfigParam(pMac, &smeConfig);
12173
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012174 /* If channel bonding mode is not required */
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012175#ifdef WLAN_FEATURE_AP_HT40_24G
12176 if ( !pMac->roam.configParam.channelBondingMode5GHz
12177 && !smeConfig.csrConfig.apHT40_24GEnabled ) {
12178#else
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012179 if ( !pMac->roam.configParam.channelBondingMode5GHz ) {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012180#endif
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012181 return VOS_STATUS_SUCCESS;
12182 }
12183
Abhishek Singh02b823e2017-10-30 17:53:20 +053012184/* Check if VHT80 is allowed for the channel*/
12185 vht80Allowed = vos_is_channel_valid_for_vht80(channel);
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012186
12187#ifdef WLAN_FEATURE_11AC
Abhishek Singh02b823e2017-10-30 17:53:20 +053012188 if ((eCSR_DOT11_MODE_11ac == eCsrPhyMode ||
12189 eCSR_DOT11_MODE_11ac_ONLY == eCsrPhyMode) &&
12190 vht80Allowed && (max_bw >= eHT_CHANNEL_WIDTH_80MHZ)) {
12191 if (channel== 36 || channel == 52 || channel == 100 ||
12192 channel == 116 || channel == 149 || channel == 132) {
12193 smeConfig.csrConfig.channelBondingMode5GHz =
12194 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
12195 } else if (channel == 40 || channel == 56 || channel == 104 ||
12196 channel == 120 || channel == 153 || channel == 136) {
12197 smeConfig.csrConfig.channelBondingMode5GHz =
12198 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
12199 } else if (channel == 44 || channel == 60 || channel == 108 ||
12200 channel == 124 || channel == 157 || channel == 140) {
12201 smeConfig.csrConfig.channelBondingMode5GHz =
12202 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
12203 } else if (channel == 48 || channel == 64 || channel == 112 ||
12204 channel == 128 || channel == 144 || channel == 161) {
12205 smeConfig.csrConfig.channelBondingMode5GHz =
12206 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
12207 } else if (channel == 165) {
12208 smeConfig.csrConfig.channelBondingMode5GHz =
12209 eCSR_INI_SINGLE_CHANNEL_CENTERED;
12210 }
Abhishek Singh4fe2b6b2015-09-15 17:13:27 +053012211
Abhishek Singh02b823e2017-10-30 17:53:20 +053012212#ifdef WLAN_FEATURE_AP_HT40_24G
12213 if (smeConfig.csrConfig.apHT40_24GEnabled &&
12214 max_bw >= eHT_CHANNEL_WIDTH_40MHZ)
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012215 {
Abhishek Singh02b823e2017-10-30 17:53:20 +053012216 if (channel >= 1 && channel <= 7)
12217 smeConfig.csrConfig.channelBondingAPMode24GHz =
Abhishek Singh4fe2b6b2015-09-15 17:13:27 +053012218 eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Abhishek Singh02b823e2017-10-30 17:53:20 +053012219 else if (channel >= 8 && channel <= 13)
12220 smeConfig.csrConfig.channelBondingAPMode24GHz =
12221 eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
12222 else if (channel ==14)
12223 smeConfig.csrConfig.channelBondingAPMode24GHz =
Abhishek Singh4fe2b6b2015-09-15 17:13:27 +053012224 eCSR_INI_SINGLE_CHANNEL_CENTERED;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012225 }
Abhishek Singh02b823e2017-10-30 17:53:20 +053012226#endif
12227 } else
12228#endif
12229 if ((eCSR_DOT11_MODE_11n == eCsrPhyMode ||
12230 eCSR_DOT11_MODE_11n_ONLY == eCsrPhyMode ||
12231 eCSR_DOT11_MODE_11ac == eCsrPhyMode ||
12232 eCSR_DOT11_MODE_11ac_ONLY == eCsrPhyMode) &&
12233 (max_bw >= eHT_CHANNEL_WIDTH_40MHZ)) {
12234 if (channel== 40 || channel == 48 || channel == 56 ||
12235 channel == 64 || channel == 104 || channel == 112 ||
12236 channel == 120 || channel == 128 || channel == 136 ||
12237 channel == 153 || channel == 161 || channel == 144) {
12238 smeConfig.csrConfig.channelBondingMode5GHz =
12239 eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
12240 } else if (channel== 36 || channel == 44 || channel == 52 ||
12241 channel == 60 || channel == 100 || channel == 108 ||
12242 channel == 116 || channel == 124 || channel == 132 ||
12243 channel == 149 || channel == 157 || channel == 140) {
12244 smeConfig.csrConfig.channelBondingMode5GHz =
12245 eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
12246 } else if (channel == 165) {
12247 smeConfig.csrConfig.channelBondingMode5GHz =
12248 eCSR_INI_SINGLE_CHANNEL_CENTERED;
12249 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012250
12251#ifdef WLAN_FEATURE_AP_HT40_24G
12252 if (smeConfig.csrConfig.apHT40_24GEnabled)
12253 {
12254 if (channel >= 1 && channel <= 7)
12255 smeConfig.csrConfig.channelBondingAPMode24GHz =
12256 eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
12257 else if (channel >= 8 && channel <= 13)
12258 smeConfig.csrConfig.channelBondingAPMode24GHz =
12259 eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
12260 else if (channel ==14)
12261 smeConfig.csrConfig.channelBondingAPMode24GHz =
12262 eCSR_INI_SINGLE_CHANNEL_CENTERED;
12263 }
12264#endif
Abhishek Singh02b823e2017-10-30 17:53:20 +053012265 } else {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012266#ifdef WLAN_FEATURE_AP_HT40_24G
Abhishek Singh02b823e2017-10-30 17:53:20 +053012267 if (CSR_IS_CHANNEL_24GHZ(channel)) {
12268 smeConfig.csrConfig.channelBondingMode24GHz =
12269 eCSR_INI_SINGLE_CHANNEL_CENTERED;
12270 } else
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012271#endif
Abhishek Singh02b823e2017-10-30 17:53:20 +053012272 {
12273 smeConfig.csrConfig.channelBondingMode5GHz =
12274 eCSR_INI_SINGLE_CHANNEL_CENTERED;
12275 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012276 }
krunal soni634aba32014-03-06 17:46:50 -080012277
Abhishek Singh6b27f072015-09-10 14:46:33 +053012278 sme_AdjustCBMode(pMac, &smeConfig, channel);
12279
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012280#ifdef WLAN_FEATURE_AP_HT40_24G
12281 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12282 FL("%s cbmode selected=%d bonding mode:%s"),
12283 (channel <= 14) ? "2G" : "5G",
12284 (channel <= 14) ? smeConfig.csrConfig.channelBondingAPMode24GHz :
12285 smeConfig.csrConfig.channelBondingMode5GHz,
12286 (channel <= 14) ?
12287 sme_CBMode2String(smeConfig.csrConfig.channelBondingAPMode24GHz) :
12288 sme_CBMode2String(smeConfig.csrConfig.channelBondingMode5GHz));
12289#else
Agarwal Ashishbf98caf2014-03-25 13:29:11 +053012290 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012291 "cbmode selected=%d", smeConfig.csrConfig.channelBondingMode5GHz);
12292#endif
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012293
12294 sme_UpdateConfig (pMac, &smeConfig);
12295 return VOS_STATUS_SUCCESS;
12296}
12297
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070012298/*--------------------------------------------------------------------------
12299
12300 \brief sme_SetCurrDeviceMode() - Sets the current operating device mode.
12301 \param hHal - The handle returned by macOpen.
12302 \param currDeviceMode - Current operating device mode.
12303 --------------------------------------------------------------------------*/
12304
12305void sme_SetCurrDeviceMode (tHalHandle hHal, tVOS_CON_MODE currDeviceMode)
12306{
12307 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12308 pMac->sme.currDeviceMode = currDeviceMode;
12309 return;
12310}
12311
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070012312#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
12313/*--------------------------------------------------------------------------
12314 \brief sme_HandoffRequest() - a wrapper function to Request a handoff
12315 from CSR.
12316 This is a synchronous call
12317 \param hHal - The handle returned by macOpen
12318 \param pHandoffInfo - info provided by HDD with the handoff request (namely:
12319 BSSID, channel etc.)
12320 \return eHAL_STATUS_SUCCESS - SME passed the request to CSR successfully.
12321 Other status means SME is failed to send the request.
12322 \sa
12323 --------------------------------------------------------------------------*/
12324
12325eHalStatus sme_HandoffRequest(tHalHandle hHal,
12326 tCsrHandoffRequest *pHandoffInfo)
12327{
12328 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12329 eHalStatus status = eHAL_STATUS_SUCCESS;
12330
12331 status = sme_AcquireGlobalLock( &pMac->sme );
12332 if ( HAL_STATUS_SUCCESS( status ) )
12333 {
12334 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
12335 "%s: invoked", __func__);
12336 status = csrHandoffRequest(pMac, pHandoffInfo);
12337 sme_ReleaseGlobalLock( &pMac->sme );
12338 }
12339
12340 return status ;
12341}
12342#endif
12343
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -070012344/*
12345 * SME API to check if there is any infra station or
12346 * P2P client is connected
12347 */
12348VOS_STATUS sme_isSta_p2p_clientConnected(tHalHandle hHal)
12349{
12350 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12351 if(csrIsInfraConnected(pMac))
12352 {
12353 return VOS_STATUS_SUCCESS;
12354 }
12355 return VOS_STATUS_E_FAILURE;
12356}
12357
Agarwal Ashish57e84372014-12-05 18:26:53 +053012358/*
12359 * SME API to check if any sessoion connected.
12360 */
12361VOS_STATUS sme_is_any_session_connected(tHalHandle hHal)
12362{
12363 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12364 if(csrIsAnySessionConnected(pMac))
12365 {
12366
12367 return VOS_STATUS_SUCCESS;
12368 }
12369 return VOS_STATUS_E_FAILURE;
12370}
12371
Leo Chang9056f462013-08-01 19:21:11 -070012372
12373#ifdef FEATURE_WLAN_LPHB
12374/* ---------------------------------------------------------------------------
12375 \fn sme_LPHBConfigReq
12376 \API to make configuration LPHB within FW.
12377 \param hHal - The handle returned by macOpen
12378 \param lphdReq - LPHB request argument by client
12379 \param pCallbackfn - LPHB timeout notification callback function pointer
12380 \- return Configuration message posting status, SUCCESS or Fail
12381 -------------------------------------------------------------------------*/
12382eHalStatus sme_LPHBConfigReq
12383(
12384 tHalHandle hHal,
12385 tSirLPHBReq *lphdReq,
12386 void (*pCallbackfn)(void *pAdapter, void *indParam)
12387)
12388{
12389 eHalStatus status = eHAL_STATUS_SUCCESS;
12390 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12391 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12392 vos_msg_t vosMessage;
12393
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053012394 MTRACE(vos_trace(VOS_MODULE_ID_SME,
12395 TRACE_CODE_SME_RX_HDD_LPHB_CONFIG_REQ,
12396 NO_SESSION, lphdReq->cmd));
Leo Chang9056f462013-08-01 19:21:11 -070012397 status = sme_AcquireGlobalLock(&pMac->sme);
12398 if (eHAL_STATUS_SUCCESS == status)
12399 {
12400 if ((LPHB_SET_EN_PARAMS_INDID == lphdReq->cmd) &&
12401 (NULL == pCallbackfn) &&
Leo Changd9df8aa2013-09-26 13:32:26 -070012402 (NULL == pMac->sme.pLphbIndCb))
Leo Chang9056f462013-08-01 19:21:11 -070012403 {
12404 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12405 "%s: Indication Call back did not registered", __func__);
12406 sme_ReleaseGlobalLock(&pMac->sme);
12407 return eHAL_STATUS_FAILURE;
12408 }
12409 else if (NULL != pCallbackfn)
12410 {
Leo Changd9df8aa2013-09-26 13:32:26 -070012411 pMac->sme.pLphbIndCb = pCallbackfn;
Leo Chang9056f462013-08-01 19:21:11 -070012412 }
12413
12414 /* serialize the req through MC thread */
12415 vosMessage.bodyptr = lphdReq;
12416 vosMessage.type = WDA_LPHB_CONF_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053012417 MTRACE(vos_trace(VOS_MODULE_ID_SME,
12418 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Leo Chang9056f462013-08-01 19:21:11 -070012419 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
12420 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12421 {
12422 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12423 "%s: Post Config LPHB MSG fail", __func__);
12424 status = eHAL_STATUS_FAILURE;
12425 }
12426 sme_ReleaseGlobalLock(&pMac->sme);
12427 }
12428
12429 return(status);
12430}
12431#endif /* FEATURE_WLAN_LPHB */
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -070012432/*--------------------------------------------------------------------------
12433 \brief sme_enable_disable_split_scan() - a wrapper function to set the split
12434 scan parameter.
12435 This is a synchronous call
12436 \param hHal - The handle returned by macOpen
12437 \return NONE.
12438 \sa
12439 --------------------------------------------------------------------------*/
12440void sme_enable_disable_split_scan (tHalHandle hHal, tANI_U8 nNumStaChan,
12441 tANI_U8 nNumP2PChan)
12442{
12443 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12444
12445 pMac->roam.configParam.nNumStaChanCombinedConc = nNumStaChan;
12446 pMac->roam.configParam.nNumP2PChanCombinedConc = nNumP2PChan;
12447
12448 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
12449 "%s: SCAN nNumStaChanCombinedConc : %d,"
12450 "nNumP2PChanCombinedConc : %d ",
12451 __func__, nNumStaChan, nNumP2PChan);
12452
12453 return;
12454
12455}
Leo Chang9056f462013-08-01 19:21:11 -070012456
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012457/**
12458 * sme_AddPeriodicTxPtrn() - Add Periodic TX Pattern
12459 * @hal: global hal handle
12460 * @addPeriodicTxPtrnParams: request message
12461 *
12462 * Return: eHalStatus enumeration
12463 */
12464eHalStatus
12465sme_AddPeriodicTxPtrn(tHalHandle hal,
12466 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
Yue Mab9c86f42013-08-14 15:59:08 -070012467{
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012468 eHalStatus status = eHAL_STATUS_SUCCESS;
12469 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
12470 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12471 struct sSirAddPeriodicTxPtrn *req_msg;
Yue Mab9c86f42013-08-14 15:59:08 -070012472 vos_msg_t msg;
12473
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012474 smsLog(mac, LOG1, FL("enter"));
12475
12476 req_msg = vos_mem_malloc(sizeof(*req_msg));
12477 if (!req_msg)
Yue Mab9c86f42013-08-14 15:59:08 -070012478 {
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012479 smsLog(mac, LOGE, FL("vos_mem_malloc failed"));
12480 return eHAL_STATUS_FAILED_ALLOC;
Yue Mab9c86f42013-08-14 15:59:08 -070012481 }
12482
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012483 *req_msg = *addPeriodicTxPtrnParams;
12484
12485 status = sme_AcquireGlobalLock(&mac->sme);
12486 if (status != eHAL_STATUS_SUCCESS)
12487 {
12488 smsLog(mac, LOGE,
12489 FL("sme_AcquireGlobalLock failed!(status=%d)"),
12490 status);
12491 vos_mem_free(req_msg);
12492 return status;
12493 }
12494
12495 /* Serialize the req through MC thread */
12496 msg.bodyptr = req_msg;
12497 msg.type = WDA_ADD_PERIODIC_TX_PTRN_IND;
12498 vos_status = vos_mq_post_message(VOS_MQ_ID_WDA, &msg);
12499 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12500 {
12501 smsLog(mac, LOGE,
12502 FL("vos_mq_post_message failed!(err=%d)"),
12503 vos_status);
12504 vos_mem_free(req_msg);
12505 status = eHAL_STATUS_FAILURE;
12506 }
12507 sme_ReleaseGlobalLock(&mac->sme);
Yue Mab9c86f42013-08-14 15:59:08 -070012508 return status;
12509}
12510
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012511
12512/**
12513 * sme_DelPeriodicTxPtrn() - Delete Periodic TX Pattern
12514 * @hal: global hal handle
12515 * @delPeriodicTxPtrnParams: request message
12516 *
12517 * Return: eHalStatus enumeration
12518 */
12519eHalStatus
12520sme_DelPeriodicTxPtrn(tHalHandle hal,
12521 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
Yue Mab9c86f42013-08-14 15:59:08 -070012522{
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012523
12524 eHalStatus status = eHAL_STATUS_SUCCESS;
12525 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
12526 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12527 struct sSirDelPeriodicTxPtrn *req_msg;
Yue Mab9c86f42013-08-14 15:59:08 -070012528 vos_msg_t msg;
12529
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012530 smsLog(mac, LOG1, FL("enter"));
12531
12532 req_msg = vos_mem_malloc(sizeof(*req_msg));
12533
12534 if (!req_msg)
Yue Mab9c86f42013-08-14 15:59:08 -070012535 {
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012536 smsLog(mac, LOGE, FL("vos_mem_malloc failed"));
12537 return eHAL_STATUS_FAILED_ALLOC;
Yue Mab9c86f42013-08-14 15:59:08 -070012538 }
12539
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012540 *req_msg = *delPeriodicTxPtrnParams;
12541
12542 status = sme_AcquireGlobalLock(&mac->sme);
12543 if (status != eHAL_STATUS_SUCCESS)
12544 {
12545 smsLog(mac, LOGE,
12546 FL("sme_AcquireGlobalLock failed!(status=%d)"),
12547 status);
12548 vos_mem_free(req_msg);
12549 return status;
12550 }
12551
12552 /* Serialize the req through MC thread */
12553 msg.bodyptr = req_msg;
12554 msg.type = WDA_DEL_PERIODIC_TX_PTRN_IND;
12555 vos_status = vos_mq_post_message(VOS_MQ_ID_WDA, &msg);
12556 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12557 {
12558 smsLog(mac, LOGE,
12559 FL("vos_mq_post_message failed!(err=%d)"),
12560 vos_status);
12561 vos_mem_free(req_msg);
12562 status = eHAL_STATUS_FAILURE;
12563 }
12564 sme_ReleaseGlobalLock(&mac->sme);
Yue Mab9c86f42013-08-14 15:59:08 -070012565 return status;
12566}
12567
Abhishek Singh00b71972016-01-07 10:51:04 +053012568#ifdef WLAN_FEATURE_RMC
12569/* ---------------------------------------------------------------------------
12570 \fn sme_EnableRMC
12571 \brief Used to enable RMC
12572 setting will not persist over reboots
12573 \param hHal
12574 \param sessionId
12575 \- return eHalStatus
12576 -------------------------------------------------------------------------*/
12577eHalStatus sme_EnableRMC(tHalHandle hHal, tANI_U32 sessionId)
12578{
12579 eHalStatus status = eHAL_STATUS_FAILURE;
12580 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12581
12582 smsLog(pMac, LOG1, FL("enable RMC"));
12583 status = sme_AcquireGlobalLock(&pMac->sme);
12584 if (HAL_STATUS_SUCCESS(status))
12585 {
12586 status = csrEnableRMC(pMac, sessionId);
12587 sme_ReleaseGlobalLock(&pMac->sme);
12588 }
12589 return status;
12590}
12591
12592/* ---------------------------------------------------------------------------
12593 \fn sme_DisableRMC
12594 \brief Used to disable RMC
12595 setting will not persist over reboots
12596 \param hHal
12597 \param sessionId
12598 \- return eHalStatus
12599 -------------------------------------------------------------------------*/
12600eHalStatus sme_DisableRMC(tHalHandle hHal, tANI_U32 sessionId)
12601{
12602 eHalStatus status = eHAL_STATUS_FAILURE;
12603 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12604
12605 smsLog(pMac, LOG1, FL("disable RMC"));
12606 status = sme_AcquireGlobalLock(&pMac->sme);
12607 if (HAL_STATUS_SUCCESS(status))
12608 {
12609 status = csrDisableRMC(pMac, sessionId);
12610 sme_ReleaseGlobalLock(&pMac->sme);
12611 }
12612 return status;
12613}
12614#endif /* WLAN_FEATURE_RMC */
12615
12616/* ---------------------------------------------------------------------------
12617 \fn sme_SendRateUpdateInd
12618 \brief API to Update rate
12619 \param hHal - The handle returned by macOpen
12620 \param rateUpdateParams - Pointer to rate update params
12621 \return eHalStatus
12622 ---------------------------------------------------------------------------*/
12623eHalStatus sme_SendRateUpdateInd(tHalHandle hHal, tSirRateUpdateInd *rateUpdateParams)
12624{
12625 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12626 eHalStatus status;
12627 vos_msg_t msg;
12628
12629 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
12630 {
12631 msg.type = WDA_RATE_UPDATE_IND;
12632 msg.bodyptr = rateUpdateParams;
12633
12634 MTRACE(vos_trace(VOS_MODULE_ID_SME,
12635 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
12636 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
12637 {
12638 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,"%s: Not able "
12639 "to post WDA_SET_RMC_RATE_IND to WDA!",
12640 __func__);
12641
12642 sme_ReleaseGlobalLock(&pMac->sme);
12643 return eHAL_STATUS_FAILURE;
12644 }
12645
12646 sme_ReleaseGlobalLock(&pMac->sme);
12647 return eHAL_STATUS_SUCCESS;
12648 }
12649
12650 return status;
12651}
12652
12653#ifdef WLAN_FEATURE_RMC
12654/* ---------------------------------------------------------------------------
12655 \fn sme_GetIBSSPeerInfo
12656 \brief Used to disable RMC
12657 setting will not persist over reboots
12658 \param hHal
12659 \param ibssPeerInfoReq multicast Group IP address
12660 \- return eHalStatus
12661 -------------------------------------------------------------------------*/
12662eHalStatus sme_RequestIBSSPeerInfo(tHalHandle hHal, void *pUserData,
12663 pIbssPeerInfoCb peerInfoCbk,
12664 tANI_BOOLEAN allPeerInfoReqd,
12665 tANI_U8 staIdx)
12666{
12667 eHalStatus status = eHAL_STATUS_FAILURE;
12668 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
12669 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12670 vos_msg_t vosMessage;
12671 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
12672
12673 status = sme_AcquireGlobalLock(&pMac->sme);
12674 if ( eHAL_STATUS_SUCCESS == status)
12675 {
12676 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
12677 pMac->sme.peerInfoParams.pUserData = pUserData;
12678
12679 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
12680 vos_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
12681 if (NULL == pIbssInfoReqParams)
12682 {
12683 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12684 "%s: Not able to allocate memory for dhcp start", __func__);
12685 sme_ReleaseGlobalLock( &pMac->sme );
12686 return eHAL_STATUS_FAILURE;
12687 }
12688 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
12689 pIbssInfoReqParams->staIdx = staIdx;
12690
12691 vosMessage.type = WDA_GET_IBSS_PEER_INFO_REQ;
12692 vosMessage.bodyptr = pIbssInfoReqParams;
12693 vosMessage.reserved = 0;
12694
12695 MTRACE(vos_trace(VOS_MODULE_ID_SME,
12696 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
12697 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
12698 if ( VOS_STATUS_SUCCESS != vosStatus )
12699 {
12700 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12701 "%s: Post WDA_GET_IBSS_PEER_INFO_REQ MSG failed", __func__);
12702 vos_mem_free(pIbssInfoReqParams);
12703 vosStatus = eHAL_STATUS_FAILURE;
12704 }
12705 sme_ReleaseGlobalLock( &pMac->sme );
12706 }
12707
12708 return (vosStatus);
12709}
12710#endif
12711
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -070012712void smeGetCommandQStatus( tHalHandle hHal )
12713{
12714 tSmeCmd *pTempCmd = NULL;
12715 tListElem *pEntry;
12716 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12717
12718 if (NULL == pMac)
12719 {
Kiet Lamcffc5862013-10-30 16:28:45 +053012720 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
12721 "%s: pMac is null", __func__);
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -070012722 return;
12723 }
12724
12725 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12726 if( pEntry )
12727 {
12728 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12729 }
12730 smsLog( pMac, LOGE, "Currently smeCmdActiveList has command (0x%X)",
12731 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
12732 if(pTempCmd)
12733 {
12734 if( eSmeCsrCommandMask & pTempCmd->command )
12735 {
12736 //CSR command is stuck. See what the reason code is for that command
12737 dumpCsrCommandInfo(pMac, pTempCmd);
12738 }
12739 } //if(pTempCmd)
12740
12741 smsLog( pMac, LOGE, "Currently smeCmdPendingList has %d commands",
12742 csrLLCount(&pMac->sme.smeCmdPendingList));
12743
12744 smsLog( pMac, LOGE, "Currently roamCmdPendingList has %d commands",
12745 csrLLCount(&pMac->roam.roamCmdPendingList));
12746
12747 return;
12748}
Rajeev79dbe4c2013-10-05 11:03:42 +053012749
12750#ifdef FEATURE_WLAN_BATCH_SCAN
12751/* ---------------------------------------------------------------------------
12752 \fn sme_SetBatchScanReq
12753 \brief API to set batch scan request in FW
12754 \param hHal - The handle returned by macOpen.
12755 \param pRequest - Pointer to the batch request.
12756 \param sessionId - session ID
12757 \param callbackRoutine - HDD callback which needs to be invoked after
12758 getting set batch scan response from FW
12759 \param callbackContext - pAdapter context
12760 \return eHalStatus
12761 ---------------------------------------------------------------------------*/
12762eHalStatus sme_SetBatchScanReq
12763(
12764 tHalHandle hHal, tSirSetBatchScanReq *pRequest, tANI_U8 sessionId,
12765 void (*callbackRoutine) (void *callbackCtx, tSirSetBatchScanRsp *pRsp),
12766 void *callbackContext
12767)
12768{
12769 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12770 eHalStatus status;
12771
Yue Mae36e3552014-03-05 17:06:20 -080012772 if (!pMac)
12773 {
12774 return eHAL_STATUS_FAILURE;
12775 }
12776
Rajeev79dbe4c2013-10-05 11:03:42 +053012777 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
12778 {
12779 status = pmcSetBatchScanReq(hHal, pRequest, sessionId, callbackRoutine,
12780 callbackContext);
12781 sme_ReleaseGlobalLock( &pMac->sme );
12782 }
12783
12784 return status;
12785}
12786
12787/* ---------------------------------------------------------------------------
12788 \fn sme_TriggerBatchScanResultInd
12789 \brief API to trigger batch scan result indications from FW
12790 \param hHal - The handle returned by macOpen.
12791 \param pRequest - Pointer to get batch request.
12792 \param sessionId - session ID
12793 \param callbackRoutine - HDD callback which needs to be invoked after
12794 getting batch scan result indication from FW
12795 \param callbackContext - pAdapter context
12796 \return eHalStatus
12797 ---------------------------------------------------------------------------*/
12798eHalStatus sme_TriggerBatchScanResultInd
12799(
12800 tHalHandle hHal, tSirTriggerBatchScanResultInd *pRequest, tANI_U8 sessionId,
12801 void (*callbackRoutine) (void *callbackCtx, void *pRsp),
12802 void *callbackContext
12803)
12804{
12805 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12806 eHalStatus status;
12807
12808 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
12809 {
12810 status = pmcTriggerBatchScanResultInd(hHal, pRequest, sessionId,
12811 callbackRoutine, callbackContext);
12812 sme_ReleaseGlobalLock( &pMac->sme );
12813 }
12814
12815 return status;
12816}
12817
12818
12819/* ---------------------------------------------------------------------------
12820 \fn sme_StopBatchScanInd
12821 \brief API to stop batch scan request in FW
12822 \param hHal - The handle returned by macOpen.
12823 \param pRequest - Pointer to the batch request.
12824 \param sessionId - session ID
12825 \return eHalStatus
12826 ---------------------------------------------------------------------------*/
12827eHalStatus sme_StopBatchScanInd
12828(
12829 tHalHandle hHal, tSirStopBatchScanInd *pRequest, tANI_U8 sessionId
12830)
12831{
12832 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12833 eHalStatus status;
12834
12835 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
12836 {
12837 status = pmcStopBatchScanInd(hHal, pRequest, sessionId);
12838 sme_ReleaseGlobalLock( &pMac->sme );
12839 }
12840
12841 return status;
12842}
12843
12844#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -080012845
Abhishek Singh30fd58c2015-07-15 14:19:21 +053012846void activeListCmdTimeoutHandle(void *userData)
12847{
Abhishek Singh837adf22015-10-01 17:37:37 +053012848 tHalHandle hHal= (tHalHandle) userData;
12849 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Abhishek Singh55a24422016-02-04 18:18:04 +053012850 tListElem *pEntry;
12851 tSmeCmd *pTempCmd = NULL;
Abhishek Singh837adf22015-10-01 17:37:37 +053012852
12853 if (NULL == pMac)
12854 {
12855 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
12856 "%s: pMac is null", __func__);
12857 return;
12858 }
Abhishek Singh30fd58c2015-07-15 14:19:21 +053012859 /* Return if no cmd pending in active list as
12860 * in this case we should not be here.
12861 */
12862 if ((NULL == userData) ||
Abhishek Singh837adf22015-10-01 17:37:37 +053012863 (0 == csrLLCount(&pMac->sme.smeCmdActiveList)))
Abhishek Singh30fd58c2015-07-15 14:19:21 +053012864 return;
12865 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12866 "%s: Active List command timeout Cmd List Count %d", __func__,
Abhishek Singh837adf22015-10-01 17:37:37 +053012867 csrLLCount(&pMac->sme.smeCmdActiveList) );
12868 smeGetCommandQStatus(hHal);
Abhishek Singh30fd58c2015-07-15 14:19:21 +053012869
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +053012870 vos_state_info_dump_all();
12871
Abhishek Singh55a24422016-02-04 18:18:04 +053012872
12873 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
12874 if (pEntry) {
12875 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
12876 }
12877 /* If user initiated scan took more than active list timeout
12878 * abort it.
12879 */
12880 if (pTempCmd && (eSmeCommandScan == pTempCmd->command) &&
12881 (eCsrScanUserRequest == pTempCmd->u.scanCmd.reason)) {
12882 sme_AbortMacScan(hHal, pTempCmd->sessionId,
12883 eCSR_SCAN_ABORT_DEFAULT);
12884 return;
Gupta, Kapil35756d62016-03-17 14:19:32 +053012885 } else if (pTempCmd &&
12886 (eSmeCommandRemainOnChannel == pTempCmd->command)) {
12887 /* Ignore if ROC took more than 120 sec */
12888 return;
Abhishek Singh55a24422016-02-04 18:18:04 +053012889 }
Abhishek Singh837adf22015-10-01 17:37:37 +053012890 if (pMac->roam.configParam.enableFatalEvent)
12891 {
12892 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
12893 WLAN_LOG_INDICATOR_HOST_DRIVER,
12894 WLAN_LOG_REASON_SME_COMMAND_STUCK,
Abhishek Singh4eaf6792016-02-04 12:36:39 +053012895 FALSE, FALSE);
Abhishek Singh837adf22015-10-01 17:37:37 +053012896 }
12897 else
12898 {
Abhishek Singh1fb64af2015-10-05 18:12:48 +053012899 /* Initiate SSR to recover */
Abhishek Singh837adf22015-10-01 17:37:37 +053012900 if (!(vos_isLoadUnloadInProgress() ||
12901 vos_is_logp_in_progress(VOS_MODULE_ID_SME, NULL)))
Abhishek Singhc7d6fbc2015-10-19 12:14:41 +053012902 {
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +053012903 vos_wlanRestart(VOS_ACTIVE_LIST_TIMEOUT);
Abhishek Singhc7d6fbc2015-10-19 12:14:41 +053012904 }
Abhishek Singh837adf22015-10-01 17:37:37 +053012905 }
Abhishek Singh30fd58c2015-07-15 14:19:21 +053012906}
12907
Leo Chang0b0e45a2013-12-15 15:18:55 -080012908#ifdef FEATURE_WLAN_CH_AVOID
12909/* ---------------------------------------------------------------------------
12910 \fn sme_AddChAvoidCallback
12911 \brief Used to plug in callback function
12912 Which notify channel may not be used with SAP or P2PGO mode.
12913 Notification come from FW.
12914 \param hHal
12915 \param pCallbackfn : callback function pointer should be plugged in
12916 \- return eHalStatus
12917 -------------------------------------------------------------------------*/
12918eHalStatus sme_AddChAvoidCallback
12919(
12920 tHalHandle hHal,
12921 void (*pCallbackfn)(void *pAdapter, void *indParam)
12922)
12923{
12924 eHalStatus status = eHAL_STATUS_SUCCESS;
12925 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12926
12927 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
12928 "%s: Plug in CH AVOID CB", __func__);
12929
12930 status = sme_AcquireGlobalLock(&pMac->sme);
12931 if (eHAL_STATUS_SUCCESS == status)
12932 {
12933 if (NULL != pCallbackfn)
12934 {
12935 pMac->sme.pChAvoidNotificationCb = pCallbackfn;
12936 }
12937 sme_ReleaseGlobalLock(&pMac->sme);
12938 }
12939
12940 return(status);
12941}
12942#endif /* FEATURE_WLAN_CH_AVOID */
12943
Gupta, Kapil7c34b322015-09-30 13:12:35 +053012944
12945/**
12946 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
12947 * @hal: global hal handle
12948 * @cb: callback function pointer
12949 *
12950 * This function stores the rssi threshold breached callback function.
12951 *
12952 * Return: eHalStatus enumeration.
12953 */
12954eHalStatus sme_set_rssi_threshold_breached_cb(tHalHandle hal,
12955 void (*cb)(void *, struct rssi_breach_event *))
12956{
12957 eHalStatus status = eHAL_STATUS_SUCCESS;
12958 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12959
12960 status = sme_AcquireGlobalLock(&mac->sme);
12961 if (status != eHAL_STATUS_SUCCESS) {
12962 smsLog(mac, LOGE,
12963 FL("sme_AcquireGlobalLock failed!(status=%d)"),
12964 status);
12965 return status;
12966 }
12967
12968 mac->sme.rssiThresholdBreachedCb = cb;
12969 sme_ReleaseGlobalLock(&mac->sme);
12970 return status;
12971}
12972
Sunil Duttc69bccb2014-05-26 21:30:20 +053012973#ifdef WLAN_FEATURE_LINK_LAYER_STATS
12974
12975/* ---------------------------------------------------------------------------
12976 \fn sme_LLStatsSetReq
12977 \brief API to set link layer stats request to FW
12978 \param hHal - The handle returned by macOpen.
12979
12980 \Param pStatsReq - a pointer to a caller allocated object of
12981 typedef struct tSirLLStatsSetReq, signifying the parameters to link layer
12982 stats set.
12983
12984 \return eHalStatus
12985 ---------------------------------------------------------------------------*/
12986eHalStatus sme_LLStatsSetReq(tHalHandle hHal,
12987 tSirLLStatsSetReq *pLinkLayerStatsSetReq)
12988{
12989 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12990 vos_msg_t msg;
12991 eHalStatus status = eHAL_STATUS_FAILURE;
Dino Mycledf0a5d92014-07-04 09:41:55 +053012992 tSirLLStatsSetReq *plinkLayerSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053012993
Dino Mycledf0a5d92014-07-04 09:41:55 +053012994 plinkLayerSetReq = vos_mem_malloc(sizeof(*plinkLayerSetReq));
12995 if ( !plinkLayerSetReq)
12996 {
12997 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12998 "%s: Not able to allocate memory for "
12999 "WDA_LINK_LAYER_STATS_SET_REQ",
13000 __func__);
13001 return eHAL_STATUS_FAILURE;
13002 }
Sunil Duttc69bccb2014-05-26 21:30:20 +053013003
Dino Mycledf0a5d92014-07-04 09:41:55 +053013004 *plinkLayerSetReq = *pLinkLayerStatsSetReq;
13005
Sunil Duttc69bccb2014-05-26 21:30:20 +053013006
13007 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
13008 {
13009 msg.type = WDA_LINK_LAYER_STATS_SET_REQ;
13010 msg.reserved = 0;
Dino Mycledf0a5d92014-07-04 09:41:55 +053013011 msg.bodyptr = plinkLayerSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013012
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013013 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13014 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Sunil Duttc69bccb2014-05-26 21:30:20 +053013015 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
13016 {
13017 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13018 "Not able to post SIR_HAL_LL_STATS_SET message to HAL", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013019 vos_mem_free(plinkLayerSetReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +053013020 status = eHAL_STATUS_FAILURE;
13021 }
13022 sme_ReleaseGlobalLock( &pMac->sme );
13023 }
13024 else
13025 {
13026 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13027 "sme_AcquireGlobalLock error", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013028 vos_mem_free(plinkLayerSetReq);
13029 status = eHAL_STATUS_FAILURE;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013030 }
13031 return status;
13032}
13033
13034/* ---------------------------------------------------------------------------
13035 \fn sme_LLStatsGetReq
13036 \brief API to get link layer stats request to FW
13037 \param hHal - The handle returned by macOpen.
13038
13039 \Param pStatsReq - a pointer to a caller allocated object of
13040 typedef struct tSirLLStatsGetReq, signifying the parameters to link layer
13041 stats get.
13042
13043 \return eHalStatus
13044 ---------------------------------------------------------------------------*/
13045eHalStatus sme_LLStatsGetReq(tHalHandle hHal,
13046 tSirLLStatsGetReq *pLinkLayerStatsGetReq)
13047{
13048 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
13049 vos_msg_t msg;
13050 eHalStatus status = eHAL_STATUS_FAILURE;
Dino Mycledf0a5d92014-07-04 09:41:55 +053013051 tSirLLStatsGetReq *pGetStatsReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013052
Dino Mycledf0a5d92014-07-04 09:41:55 +053013053 pGetStatsReq = vos_mem_malloc(sizeof(*pGetStatsReq));
13054 if ( !pGetStatsReq)
13055 {
13056 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13057 "%s: Not able to allocate memory for "
13058 "WDA_LINK_LAYER_STATS_GET_REQ",
13059 __func__);
13060 return eHAL_STATUS_FAILURE;
13061 }
13062 *pGetStatsReq = *pLinkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013063
13064 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
13065 {
13066 msg.type = WDA_LINK_LAYER_STATS_GET_REQ;
13067 msg.reserved = 0;
Dino Mycledf0a5d92014-07-04 09:41:55 +053013068 msg.bodyptr = pGetStatsReq;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013069 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13070 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Sunil Duttc69bccb2014-05-26 21:30:20 +053013071 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
13072 {
13073 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13074 "Not able to post SIR_HAL_LL_STATS_GET message to HAL", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013075 vos_mem_free(pGetStatsReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +053013076 status = eHAL_STATUS_FAILURE;
13077 }
13078 sme_ReleaseGlobalLock( &pMac->sme );
13079 }
13080 else
13081 {
13082 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13083 "sme_AcquireGlobalLock error", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013084 vos_mem_free(pGetStatsReq);
13085 status = eHAL_STATUS_FAILURE;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013086 }
13087 return status;
13088}
13089
13090/* ---------------------------------------------------------------------------
13091 \fn sme_LLStatsClearReq
13092 \brief API to clear link layer stats request to FW
13093 \param hHal - The handle returned by macOpen.
13094
13095 \Param pStatsReq - a pointer to a caller allocated object of
13096 typedef struct tSirLLStatsClearReq, signifying the parameters to link layer
13097 stats clear.
13098
13099 \return eHalStatus
13100 ---------------------------------------------------------------------------*/
13101eHalStatus sme_LLStatsClearReq(tHalHandle hHal,
13102 tSirLLStatsClearReq *pLinkLayerStatsClear)
13103{
13104 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
13105 vos_msg_t msg;
13106 eHalStatus status = eHAL_STATUS_FAILURE;
Dino Mycledf0a5d92014-07-04 09:41:55 +053013107 tSirLLStatsClearReq *pClearStatsReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013108
13109
Sunil Duttc69bccb2014-05-26 21:30:20 +053013110
Dino Mycledf0a5d92014-07-04 09:41:55 +053013111 pClearStatsReq = vos_mem_malloc(sizeof(*pClearStatsReq));
13112 if ( !pClearStatsReq)
13113 {
13114 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13115 "%s: Not able to allocate memory for "
13116 "WDA_LINK_LAYER_STATS_CLEAR_REQ",
13117 __func__);
13118 return eHAL_STATUS_FAILURE;
13119 }
13120
13121 *pClearStatsReq = *pLinkLayerStatsClear;
13122
Sunil Duttc69bccb2014-05-26 21:30:20 +053013123 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
13124 {
13125 msg.type = WDA_LINK_LAYER_STATS_CLEAR_REQ;
13126 msg.reserved = 0;
Dino Mycledf0a5d92014-07-04 09:41:55 +053013127 msg.bodyptr = pClearStatsReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013128
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013129 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13130 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Sunil Duttc69bccb2014-05-26 21:30:20 +053013131 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
13132 {
13133 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13134 "Not able to post SIR_HAL_LL_STATS_CLEAR message to HAL", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013135 vos_mem_free(pClearStatsReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +053013136 status = eHAL_STATUS_FAILURE;
13137 }
13138 sme_ReleaseGlobalLock( &pMac->sme );
13139 }
13140 else
13141 {
13142 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13143 "sme_AcquireGlobalLock error", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013144 vos_mem_free(pClearStatsReq);
13145 status = eHAL_STATUS_FAILURE;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013146 }
13147
13148 return status;
13149}
13150
13151/* ---------------------------------------------------------------------------
13152 \fn sme_SetLinkLayerStatsIndCB
13153 \brief API to trigger Link Layer Statistic indications from FW
13154 \param hHal - The handle returned by macOpen.
13155 \param sessionId - session ID
13156 \param callbackRoutine - HDD callback which needs to be invoked after
13157 getting Link Layer Statistics from FW
13158 \param callbackContext - pAdapter context
13159 \return eHalStatus
13160 ---------------------------------------------------------------------------*/
13161eHalStatus sme_SetLinkLayerStatsIndCB
13162(
Dino Mycled3d50022014-07-07 12:58:25 +053013163 tHalHandle hHal,
13164 void (*callbackRoutine) (void *callbackCtx, int indType, void *pRsp,
13165 tANI_U8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +053013166)
13167{
13168 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
13169 eHalStatus status;
13170
13171 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
13172 {
13173 if (NULL != callbackRoutine)
13174 {
13175 pMac->sme.pLinkLayerStatsIndCallback = callbackRoutine;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013176 }
13177 sme_ReleaseGlobalLock( &pMac->sme );
13178 }
13179
13180 return status;
13181}
13182#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
13183
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +053013184
Tushnim Bhattacharyyaed4d0c22014-01-30 11:56:44 -080013185eHalStatus sme_UpdateConnectDebug(tHalHandle hHal, tANI_U32 set_value)
13186{
13187 eHalStatus status = eHAL_STATUS_SUCCESS;
13188 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13189 pMac->fEnableDebugLog = set_value;
13190 return (status);
13191}
13192
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013193VOS_STATUS sme_UpdateDSCPtoUPMapping( tHalHandle hHal,
Kumar Anand82c009f2014-05-29 00:29:42 -070013194 sme_QosWmmUpType *dscpmapping,
13195 v_U8_t sessionId )
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013196{
13197 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Kumar Anand82c009f2014-05-29 00:29:42 -070013198 eHalStatus status = eHAL_STATUS_SUCCESS;
13199 v_U8_t i, j, peSessionId;
13200 tCsrRoamSession *pCsrSession = NULL;
13201 tpPESession pSession = NULL;
13202
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013203 status = sme_AcquireGlobalLock( &pMac->sme );
13204 if ( HAL_STATUS_SUCCESS( status ) )
13205 {
Kumar Anand82c009f2014-05-29 00:29:42 -070013206 pCsrSession = CSR_GET_SESSION( pMac, sessionId );
13207
13208 if (pCsrSession == NULL)
13209 {
13210 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13211 "%s: CSR Session lookup fails %u", __func__, sessionId);
13212 sme_ReleaseGlobalLock( &pMac->sme);
13213 return eHAL_STATUS_FAILURE;
13214 }
13215
Ratheesh S Pe8f00c62015-08-20 13:03:01 +053013216 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13217 {
13218 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13219 "%s: Invalid session Id %u", __func__, sessionId);
13220 sme_ReleaseGlobalLock( &pMac->sme);
13221 return eHAL_STATUS_FAILURE;
13222 }
13223
Kumar Anand82c009f2014-05-29 00:29:42 -070013224 pSession = peFindSessionByBssid( pMac,
13225 pCsrSession->connectedProfile.bssid, &peSessionId );
13226
13227 if (pSession == NULL)
13228 {
13229 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13230 "%s: Session lookup fails for BSSID", __func__);
13231 sme_ReleaseGlobalLock( &pMac->sme);
13232 return eHAL_STATUS_FAILURE;
13233 }
13234
13235 if ( !pSession->QosMapSet.present )
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013236 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053013237 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013238 "%s: QOS Mapping IE not present", __func__);
13239 sme_ReleaseGlobalLock( &pMac->sme);
13240 return eHAL_STATUS_FAILURE;
13241 }
13242 else
13243 {
Kumar Anand82c009f2014-05-29 00:29:42 -070013244 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++)
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013245 {
Kumar Anand82c009f2014-05-29 00:29:42 -070013246 for (j = pSession->QosMapSet.dscp_range[i][0];
Abhishek Ambure863e3052019-12-12 12:25:52 +053013247 j <= pSession->QosMapSet.dscp_range[i][1] &&
13248 j <= WLAN_MAX_DSCP; j++)
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013249 dscpmapping[j]= i;
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013250 }
Kumar Anand82c009f2014-05-29 00:29:42 -070013251 for (i = 0; i< pSession->QosMapSet.num_dscp_exceptions; i++)
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013252 {
Abhishek Ambure863e3052019-12-12 12:25:52 +053013253 if (pSession->QosMapSet.dscp_exceptions[i][0] <= WLAN_MAX_DSCP)
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013254 {
Kumar Anand82c009f2014-05-29 00:29:42 -070013255 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0] ] =
13256 pSession->QosMapSet.dscp_exceptions[i][1];
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013257 }
13258 }
13259 }
13260 }
13261 sme_ReleaseGlobalLock( &pMac->sme);
13262 return status;
13263}
Agarwal Ashish5e414792014-06-08 15:25:23 +053013264
Agarwal Ashish5e414792014-06-08 15:25:23 +053013265tANI_BOOLEAN sme_Is11dCountrycode(tHalHandle hHal)
13266{
13267 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
13268
13269 if (VOS_TRUE == vos_mem_compare(pMac->scan.countryCodeCurrent,
13270 pMac->scan.countryCode11d, 2))
13271 {
13272 return eANI_BOOLEAN_TRUE;
13273 }
13274 else
13275 {
13276 return eANI_BOOLEAN_FALSE;
13277 }
13278}
Dino Mycle2c198072014-06-10 10:15:52 +053013279
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +053013280eHalStatus
13281sme_SpoofMacAddrReq(tHalHandle hHal, v_MACADDR_t *macaddr, bool spoof_mac_oui)
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +053013282{
Siddharth Bhald8a95e82015-02-12 20:14:52 +053013283 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13284 eHalStatus status = eHAL_STATUS_SUCCESS;
13285 tSmeCmd *pMacSpoofCmd;
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +053013286
mukul sharmaca8e4322015-07-20 18:33:43 +053013287 status = sme_AcquireGlobalLock( &pMac->sme );
13288 if ( HAL_STATUS_SUCCESS( status ) )
13289 {
13290 pMacSpoofCmd = csrGetCommandBuffer(pMac);
13291 if (pMacSpoofCmd)
Siddharth Bhald8a95e82015-02-12 20:14:52 +053013292 {
mukul sharmaca8e4322015-07-20 18:33:43 +053013293 pMacSpoofCmd->command = eSmeCommandMacSpoofRequest;
13294 vos_mem_set(&pMacSpoofCmd->u.macAddrSpoofCmd,
13295 sizeof(tSirSpoofMacAddrReq), 0);
13296 vos_mem_copy(pMacSpoofCmd->u.macAddrSpoofCmd.macAddr,
13297 macaddr->bytes, VOS_MAC_ADDRESS_LEN);
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +053013298
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +053013299 pMacSpoofCmd->u.macAddrSpoofCmd.spoof_mac_oui = spoof_mac_oui;
13300
Abhishek Singh06c4b8b2016-04-05 10:27:07 +053013301 status = csrQueueSmeCommand(pMac, pMacSpoofCmd, false);
mukul sharmaca8e4322015-07-20 18:33:43 +053013302 if ( !HAL_STATUS_SUCCESS( status ) )
13303 {
13304 smsLog( pMac, LOGE, FL("fail to send msg status = %d\n"), status );
Abhishek Singh06c4b8b2016-04-05 10:27:07 +053013305 csrReleaseCommand(pMac, pMacSpoofCmd);
mukul sharmaca8e4322015-07-20 18:33:43 +053013306 }
13307 }
13308 else
13309 {
13310 //log error
13311 smsLog(pMac, LOGE, FL("can not obtain a common buffer\n"));
13312 status = eHAL_STATUS_RESOURCES;
13313 }
13314 sme_ReleaseGlobalLock( &pMac->sme);
13315 }
Siddharth Bhald8a95e82015-02-12 20:14:52 +053013316 return (status);
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +053013317}
13318
Dino Mycle2c198072014-06-10 10:15:52 +053013319#ifdef WLAN_FEATURE_EXTSCAN
13320/* ---------------------------------------------------------------------------
13321 \fn sme_GetValidChannelsByBand
13322 \brief SME API to fetch all valid channel filtered by band
13323 \param hHal
13324 \param wifiBand: RF band information
13325 \param aValidChannels: Array to store channel info
13326 \param len: number of channels
13327 \- return eHalStatus
13328 -------------------------------------------------------------------------*/
13329eHalStatus sme_GetValidChannelsByBand (tHalHandle hHal, tANI_U8 wifiBand,
13330 tANI_U32 *aValidChannels, tANI_U8 *pNumChannels)
13331{
13332 eHalStatus status = eHAL_STATUS_SUCCESS;
13333 tANI_U8 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
13334 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13335 tANI_U8 numChannels = 0;
13336 tANI_U8 i = 0;
13337 tANI_U32 totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
13338
13339 if (!aValidChannels || !pNumChannels) {
13340 smsLog(pMac, VOS_TRACE_LEVEL_ERROR,
13341 FL("Output channel list/NumChannels is NULL"));
13342 return eHAL_STATUS_INVALID_PARAMETER;
13343 }
13344
13345 if ((wifiBand < WIFI_BAND_UNSPECIFIED) || (wifiBand >= WIFI_BAND_MAX)) {
13346 smsLog(pMac, VOS_TRACE_LEVEL_ERROR,
13347 FL("Invalid wifiBand (%d)"), wifiBand);
13348 return eHAL_STATUS_INVALID_PARAMETER;
13349 }
13350
13351 status = sme_GetCfgValidChannels(hHal, &chanList[0],
13352 &totValidChannels);
13353 if (!HAL_STATUS_SUCCESS(status)) {
13354 smsLog(pMac, VOS_TRACE_LEVEL_ERROR,
13355 FL("Failed to get valid channel list (err=%d)"), status);
13356 return status;
13357 }
13358
13359 switch (wifiBand) {
13360 case WIFI_BAND_UNSPECIFIED:
13361 smsLog(pMac, VOS_TRACE_LEVEL_INFO, FL("Unspecified wifiBand, "
13362 "return all (%d) valid channels"), totValidChannels);
13363 numChannels = totValidChannels;
13364 for (i = 0; i < numChannels; i++)
13365 aValidChannels[i] = vos_chan_to_freq(chanList[i]);
13366 break;
13367
13368 case WIFI_BAND_BG:
13369 smsLog(pMac, VOS_TRACE_LEVEL_INFO, FL("WIFI_BAND_BG (2.4 GHz)"));
13370 for (i = 0; i < totValidChannels; i++)
13371 if (CSR_IS_CHANNEL_24GHZ(chanList[i]))
13372 aValidChannels[numChannels++] =
13373 vos_chan_to_freq(chanList[i]);
13374 break;
13375
13376 case WIFI_BAND_A:
13377 smsLog(pMac, VOS_TRACE_LEVEL_INFO,
13378 FL("WIFI_BAND_A (5 GHz without DFS)"));
13379 for (i = 0; i < totValidChannels; i++)
13380 if (CSR_IS_CHANNEL_5GHZ(chanList[i]) &&
13381 !CSR_IS_CHANNEL_DFS(chanList[i]))
13382 aValidChannels[numChannels++] =
13383 vos_chan_to_freq(chanList[i]);
13384 break;
13385
13386 case WIFI_BAND_ABG:
13387 smsLog(pMac, VOS_TRACE_LEVEL_INFO,
13388 FL("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)"));
13389 for (i = 0; i < totValidChannels; i++)
13390 if ((CSR_IS_CHANNEL_24GHZ(chanList[i]) ||
13391 CSR_IS_CHANNEL_5GHZ(chanList[i])) &&
13392 !CSR_IS_CHANNEL_DFS(chanList[i]))
13393 aValidChannels[numChannels++] =
13394 vos_chan_to_freq(chanList[i]);
13395 break;
13396
13397 case WIFI_BAND_A_DFS_ONLY:
13398 smsLog(pMac, VOS_TRACE_LEVEL_INFO,
13399 FL("WIFI_BAND_A_DFS (5 GHz DFS only)"));
13400 for (i = 0; i < totValidChannels; i++)
13401 if (CSR_IS_CHANNEL_5GHZ(chanList[i]) &&
13402 CSR_IS_CHANNEL_DFS(chanList[i]))
13403 aValidChannels[numChannels++] =
13404 vos_chan_to_freq(chanList[i]);
13405 break;
13406
13407 case WIFI_BAND_A_WITH_DFS:
13408 smsLog(pMac, VOS_TRACE_LEVEL_INFO,
13409 FL("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)"));
13410 for (i = 0; i < totValidChannels; i++)
13411 if (CSR_IS_CHANNEL_5GHZ(chanList[i]))
13412 aValidChannels[numChannels++] =
13413 vos_chan_to_freq(chanList[i]);
13414 break;
13415
13416 case WIFI_BAND_ABG_WITH_DFS:
13417 smsLog(pMac, VOS_TRACE_LEVEL_INFO,
13418 FL("WIFI_BAND_ABG_WITH_DFS (2.4 GHz + 5 GHz with DFS)"));
13419 for (i = 0; i < totValidChannels; i++)
13420 if (CSR_IS_CHANNEL_24GHZ(chanList[i]) ||
13421 CSR_IS_CHANNEL_5GHZ(chanList[i]))
13422 aValidChannels[numChannels++] =
13423 vos_chan_to_freq(chanList[i]);
13424 break;
13425
13426 default:
13427 smsLog(pMac, VOS_TRACE_LEVEL_ERROR,
13428 FL("Unknown wifiBand (%d))"), wifiBand);
13429 return eHAL_STATUS_INVALID_PARAMETER;
13430 break;
13431 }
13432 *pNumChannels = numChannels;
13433
13434 return status;
13435}
13436/* ---------------------------------------------------------------------------
13437 \fn sme_EXTScanGetCapabilities
13438 \brief SME API to fetch Extended Scan capabilities
13439 \param hHal
13440 \param pReq: Extended Scan capabilities structure
13441 \- return eHalStatus
13442 -------------------------------------------------------------------------*/
13443eHalStatus sme_EXTScanGetCapabilities (tHalHandle hHal,
13444 tSirGetEXTScanCapabilitiesReqParams *pReq)
13445{
13446 eHalStatus status = eHAL_STATUS_SUCCESS;
13447 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13448 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13449 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013450 tSirGetEXTScanCapabilitiesReqParams *pGetEXTScanCapabilitiesReq;
13451
13452 pGetEXTScanCapabilitiesReq =
13453 vos_mem_malloc(sizeof(*pGetEXTScanCapabilitiesReq));
13454 if ( !pGetEXTScanCapabilitiesReq)
13455 {
13456 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13457 "%s: Not able to allocate memory for "
13458 "WDA_EXTSCAN_GET_CAPABILITIES_REQ",
13459 __func__);
13460 return eHAL_STATUS_FAILURE;
13461 }
13462
13463 *pGetEXTScanCapabilitiesReq = *pReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013464
Dino Mycle2c198072014-06-10 10:15:52 +053013465 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13466 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013467 vosMessage.bodyptr = pGetEXTScanCapabilitiesReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013468 vosMessage.type = WDA_EXTSCAN_GET_CAPABILITIES_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013469 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13470 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013471 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013472 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13473 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13474 "failed to post WDA_EXTSCAN_GET_CAPABILITIES_REQ ",
13475 __func__);
13476 vos_mem_free(pGetEXTScanCapabilitiesReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013477 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013478 }
Dino Mycle2c198072014-06-10 10:15:52 +053013479
13480 sme_ReleaseGlobalLock(&pMac->sme);
13481 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013482 else
13483 {
13484 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13485 "sme_AcquireGlobalLock error", __func__);
13486 vos_mem_free(pGetEXTScanCapabilitiesReq);
13487 status = eHAL_STATUS_FAILURE;
13488 }
Dino Mycle2c198072014-06-10 10:15:52 +053013489 return(status);
13490}
13491
13492/* ---------------------------------------------------------------------------
13493 \fn sme_EXTScanStart
13494 \brief SME API to issue Extended Scan start
13495 \param hHal
13496 \param pStartCmd: Extended Scan start structure
13497 \- return eHalStatus
13498 -------------------------------------------------------------------------*/
13499eHalStatus sme_EXTScanStart (tHalHandle hHal,
13500 tSirEXTScanStartReqParams *pStartCmd)
13501{
13502 eHalStatus status = eHAL_STATUS_SUCCESS;
13503 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13504 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13505 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013506 tSirEXTScanStartReqParams *pextScanStartReq;
13507
13508 pextScanStartReq = vos_mem_malloc(sizeof(*pextScanStartReq));
13509 if ( !pextScanStartReq)
13510 {
13511 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13512 "%s: Not able to allocate memory for "
13513 "WDA_EXTSCAN_START_REQ",
13514 __func__);
13515 return eHAL_STATUS_FAILURE;
13516 }
13517
13518 *pextScanStartReq = *pStartCmd;
13519
Dino Mycle2c198072014-06-10 10:15:52 +053013520
13521 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13522 TRACE_CODE_SME_RX_HDD_EXTSCAN_START, NO_SESSION, 0));
13523 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13524 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013525 vosMessage.bodyptr = pextScanStartReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013526 vosMessage.type = WDA_EXTSCAN_START_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013527 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13528 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013529 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013530 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13531 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13532 "%s: failed to post WDA_EXTSCAN_START_REQ", __func__);
13533 vos_mem_free(pextScanStartReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013534 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013535 }
Dino Mycle2c198072014-06-10 10:15:52 +053013536 sme_ReleaseGlobalLock(&pMac->sme);
13537 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013538 else
13539 {
13540 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13541 "sme_AcquireGlobalLock error", __func__);
13542 vos_mem_free(pextScanStartReq);
13543 status = eHAL_STATUS_FAILURE;
13544 }
Dino Mycle2c198072014-06-10 10:15:52 +053013545 return(status);
13546}
13547
13548/* ---------------------------------------------------------------------------
13549 \fn sme_EXTScanStop
13550 \brief SME API to issue Extended Scan stop
13551 \param hHal
13552 \param pStopReq: Extended Scan stop structure
13553 \- return eHalStatus
13554 -------------------------------------------------------------------------*/
13555eHalStatus sme_EXTScanStop(tHalHandle hHal, tSirEXTScanStopReqParams *pStopReq)
13556{
13557 eHalStatus status = eHAL_STATUS_SUCCESS;
13558 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13559 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13560 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013561 tSirEXTScanStopReqParams *pEXTScanStopReq;
13562
13563 pEXTScanStopReq = vos_mem_malloc(sizeof(*pEXTScanStopReq));
13564 if ( !pEXTScanStopReq)
13565 {
13566 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13567 "%s: Not able to allocate memory for "
13568 "WDA_EXTSCAN_STOP_REQ",
13569 __func__);
13570 return eHAL_STATUS_FAILURE;
13571 }
13572
13573 *pEXTScanStopReq = *pStopReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013574
13575 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13576 TRACE_CODE_SME_RX_HDD_EXTSCAN_STOP, NO_SESSION, 0));
13577 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
13578 {
13579 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013580 vosMessage.bodyptr = pEXTScanStopReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013581 vosMessage.type = WDA_EXTSCAN_STOP_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013582 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13583 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013584 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
13585 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
13586 {
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013587 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13588 "%s: failed to post WDA_EXTSCAN_STOP_REQ", __func__);
13589 vos_mem_free(pEXTScanStopReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013590 status = eHAL_STATUS_FAILURE;
13591 }
13592 sme_ReleaseGlobalLock(&pMac->sme);
13593 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013594 else
13595 {
13596 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13597 "sme_AcquireGlobalLock error", __func__);
13598 vos_mem_free(pEXTScanStopReq);
13599 status = eHAL_STATUS_FAILURE;
13600 }
Dino Mycle2c198072014-06-10 10:15:52 +053013601 return(status);
13602}
13603
13604/* ---------------------------------------------------------------------------
13605 \fn sme_SetBssHotlist
13606 \brief SME API to set BSSID hotlist
13607 \param hHal
13608 \param pSetHotListReq: Extended Scan set hotlist structure
13609 \- return eHalStatus
13610 -------------------------------------------------------------------------*/
13611eHalStatus sme_SetBssHotlist (tHalHandle hHal,
13612 tSirEXTScanSetBssidHotListReqParams *pSetHotListReq)
13613{
13614 eHalStatus status = eHAL_STATUS_SUCCESS;
13615 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13616 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13617 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013618 tSirEXTScanSetBssidHotListReqParams *pEXTScanSetBssidHotlistReq;
13619
13620 pEXTScanSetBssidHotlistReq =
13621 vos_mem_malloc(sizeof(*pEXTScanSetBssidHotlistReq));
13622 if ( !pEXTScanSetBssidHotlistReq)
13623 {
13624 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13625 "%s: Not able to allocate memory for "
13626 "WDA_EXTSCAN_SET_BSSID_HOTLIST_REQ",
13627 __func__);
13628 return eHAL_STATUS_FAILURE;
13629 }
13630
13631 *pEXTScanSetBssidHotlistReq = *pSetHotListReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013632
13633 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13634 TRACE_CODE_SME_RX_HDD_EXTSCAN_SET_BSS_HOTLIST, NO_SESSION, 0));
13635 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13636 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013637 vosMessage.bodyptr = pEXTScanSetBssidHotlistReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013638 vosMessage.type = WDA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013639 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13640 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013641 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013642 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13643 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13644 "%s: failed to post WDA_EXTSCAN_STOP_REQ", __func__);
13645 vos_mem_free(pEXTScanSetBssidHotlistReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013646 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013647 }
Dino Mycle2c198072014-06-10 10:15:52 +053013648 sme_ReleaseGlobalLock(&pMac->sme);
13649 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013650 else
13651 {
13652 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13653 "sme_AcquireGlobalLock error", __func__);
13654 vos_mem_free(pEXTScanSetBssidHotlistReq);
13655 status = eHAL_STATUS_FAILURE;
13656 }
Dino Mycle2c198072014-06-10 10:15:52 +053013657
13658 return(status);
13659}
13660
13661/* ---------------------------------------------------------------------------
13662 \fn sme_ResetBssHotlist
13663 \brief SME API to reset BSSID hotlist
13664 \param hHal
13665 \param pSetHotListReq: Extended Scan set hotlist structure
13666 \- return eHalStatus
13667 -------------------------------------------------------------------------*/
13668eHalStatus sme_ResetBssHotlist (tHalHandle hHal,
13669 tSirEXTScanResetBssidHotlistReqParams *pResetReq)
13670{
13671 eHalStatus status = eHAL_STATUS_SUCCESS;
13672 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13673 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13674 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013675 tSirEXTScanResetBssidHotlistReqParams *pEXTScanHotlistResetReq;
13676
13677 pEXTScanHotlistResetReq = vos_mem_malloc(sizeof(*pEXTScanHotlistResetReq));
13678 if ( !pEXTScanHotlistResetReq)
13679 {
13680 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13681 "%s: Not able to allocate memory for "
13682 "WDA_EXTSCAN_RESET_BSSID_HOTLIST_REQ",
13683 __func__);
13684 return eHAL_STATUS_FAILURE;
13685 }
13686
13687 *pEXTScanHotlistResetReq = *pResetReq;
13688
Dino Mycle2c198072014-06-10 10:15:52 +053013689
13690 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13691 TRACE_CODE_SME_RX_HDD_EXTSCAN_RESET_BSS_HOTLIST, NO_SESSION, 0));
13692 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13693 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013694 vosMessage.bodyptr = pEXTScanHotlistResetReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013695 vosMessage.type = WDA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013696 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13697 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013698 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013699 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13700 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13701 "%s: failed to post WDA_EXTSCAN_RESET_BSSID_HOTLIST_REQ",
13702 __func__);
13703 vos_mem_free(pEXTScanHotlistResetReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013704 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013705 }
Dino Mycle2c198072014-06-10 10:15:52 +053013706 sme_ReleaseGlobalLock(&pMac->sme);
13707 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013708 else
13709 {
13710 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13711 "sme_AcquireGlobalLock error", __func__);
13712 vos_mem_free(pEXTScanHotlistResetReq);
13713 status = eHAL_STATUS_FAILURE;
13714 }
Dino Mycle2c198072014-06-10 10:15:52 +053013715 return(status);
13716}
13717
13718/* ---------------------------------------------------------------------------
Dino Mycle2c198072014-06-10 10:15:52 +053013719 \fn sme_getCachedResults
13720 \brief SME API to get cached results
13721 \param hHal
13722 \param pCachedResultsReq: Extended Scan get cached results structure
13723 \- return eHalStatus
13724 -------------------------------------------------------------------------*/
13725eHalStatus sme_getCachedResults (tHalHandle hHal,
13726 tSirEXTScanGetCachedResultsReqParams *pCachedResultsReq)
13727{
13728 eHalStatus status = eHAL_STATUS_SUCCESS;
13729 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13730 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13731 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013732 tSirEXTScanGetCachedResultsReqParams *pEXTScanCachedResultsReq;
13733
13734 pEXTScanCachedResultsReq =
13735 vos_mem_malloc(sizeof(*pEXTScanCachedResultsReq));
13736 if ( !pEXTScanCachedResultsReq)
13737 {
13738 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13739 "%s: Not able to allocate memory for "
13740 "WDA_EXTSCAN_GET_CACHED_RESULTS_REQ",
13741 __func__);
13742 return eHAL_STATUS_FAILURE;
13743 }
13744
13745 *pEXTScanCachedResultsReq = *pCachedResultsReq;
13746
Dino Mycle2c198072014-06-10 10:15:52 +053013747
13748 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13749 TRACE_CODE_SME_RX_HDD_EXTSCAN_GET_CACHED_RESULTS, NO_SESSION, 0));
13750 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13751 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013752 vosMessage.bodyptr = pEXTScanCachedResultsReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013753 vosMessage.type = WDA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013754 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13755 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013756 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013757 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13758 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13759 "%s: failed tp post WDA_EXTSCAN_GET_CACHED_RESULTS_REQ",
13760 __func__);
13761 vos_mem_free(pEXTScanCachedResultsReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013762 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013763 }
Dino Mycle2c198072014-06-10 10:15:52 +053013764 sme_ReleaseGlobalLock(&pMac->sme);
13765 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013766 else
13767 {
13768 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13769 FL("Failed to acquire SME Global Lock"));
13770 vos_mem_free(pEXTScanCachedResultsReq);
13771 status = eHAL_STATUS_FAILURE;
13772 }
Dino Mycle2c198072014-06-10 10:15:52 +053013773 return(status);
13774}
13775
13776eHalStatus sme_EXTScanRegisterCallback (tHalHandle hHal,
13777 void (*pEXTScanIndCb)(void *, const tANI_U16, void *),
13778 void *callbackContext)
13779{
13780 eHalStatus status = eHAL_STATUS_SUCCESS;
13781 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13782
13783 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13784 pMac->sme.pEXTScanIndCb = pEXTScanIndCb;
13785 pMac->sme.pEXTScanCallbackContext = callbackContext;
13786 sme_ReleaseGlobalLock(&pMac->sme);
13787 }
13788 return(status);
13789}
13790
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053013791#ifdef FEATURE_OEM_DATA_SUPPORT
13792eHalStatus sme_OemDataRegisterCallback (tHalHandle hHal,
Padma, Santhosh Kumaree7c3d22016-01-25 10:36:08 +053013793 void (*pOemDataIndCb)(void *, const tANI_U16, void *, tANI_U32),
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053013794 void *callbackContext)
13795{
13796 eHalStatus status = eHAL_STATUS_SUCCESS;
13797 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13798
13799 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13800 pMac->sme.pOemDataIndCb = pOemDataIndCb;
13801 pMac->sme.pOemDataCallbackContext = callbackContext;
13802 sme_ReleaseGlobalLock(&pMac->sme);
13803 }
13804 return(status);
13805}
13806#endif
13807
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +053013808void sme_SetMiracastMode (tHalHandle hHal,tANI_U8 mode)
13809{
13810 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Padma, Santhosh Kumarc1f7f052015-08-26 12:29:01 +053013811 eHalStatus status = eHAL_STATUS_SUCCESS;
13812 vos_msg_t vosMessage = {0};
13813 tSirHighPriorityDataInfoInd *phighPriorityDataInfo;
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +053013814
13815 pMac->miracast_mode = mode;
Padma, Santhosh Kumarc1f7f052015-08-26 12:29:01 +053013816
13817 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
13818 "%s: miracast_mode: %d", __func__, mode);
13819
13820 phighPriorityDataInfo =
13821 vos_mem_malloc(sizeof(*phighPriorityDataInfo));
13822 if ( !phighPriorityDataInfo)
13823 {
13824 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s:"
13825 "Failed to allocate memory for WDA_HIGH_PRIORITY_DATA_INFO_IND",
13826 __func__);
13827 return;
13828 }
13829
13830 if (mode)
13831 phighPriorityDataInfo->pause = TRUE;
13832 else
13833 phighPriorityDataInfo->pause = FALSE;
13834
13835 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13836 /* Serialize the req through MC thread */
13837 vosMessage.bodyptr = phighPriorityDataInfo;
13838 vosMessage.type = WDA_HIGH_PRIORITY_DATA_INFO_IND;
13839 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13840 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
13841
13842 if(VOS_STATUS_SUCCESS !=
13843 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage)) {
13844 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s:"
13845 "Failed to post WDA_HIGH_PRIORITY_DATA_INFO_IND msg to WDA",
13846 __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013847 vos_mem_free(phighPriorityDataInfo);
Padma, Santhosh Kumarc1f7f052015-08-26 12:29:01 +053013848 }
13849 sme_ReleaseGlobalLock(&pMac->sme);
13850 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013851 else
13852 {
13853 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13854 "sme_AcquireGlobalLock error", __func__);
13855 vos_mem_free(phighPriorityDataInfo);
13856 }
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +053013857}
Dino Mycle2c198072014-06-10 10:15:52 +053013858#endif /* WLAN_FEATURE_EXTSCAN */
c_hpothuef45bc32014-09-11 10:10:18 +053013859
13860void sme_resetCoexEevent(tHalHandle hHal)
13861{
13862 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13863
13864 if (pMac == NULL)
13865 {
13866 printk("btc: %s pMac is NULL \n",__func__);
13867 return;
13868 }
13869
13870 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
13871 FL("isCoexScoIndSet: %d"), pMac->isCoexScoIndSet);
13872
13873 if (pMac->isCoexScoIndSet)
13874 {
13875 pMac->isCoexScoIndSet = 0;
13876 ccmCfgSetInt(pMac, WNI_CFG_DEL_ALL_RX_TX_BA_SESSIONS_2_4_G_BTC, 0,
13877 NULL, eANI_BOOLEAN_FALSE);
13878 }
13879
13880 return;
13881}
Agarwal Ashish738843c2014-09-25 12:27:56 +053013882
13883void sme_disable_dfs_channel(tHalHandle hHal, bool disbale_dfs)
13884{
13885 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13886 pMac->scan.fEnableDFSChnlScan = !disbale_dfs;
13887 csrDisableDfsChannel(pMac);
13888
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053013889 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
13890 "%s: Modified fEnableDFSChnlScan: %d", __func__,
13891 pMac->scan.fEnableDFSChnlScan);
Agarwal Ashish738843c2014-09-25 12:27:56 +053013892}
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053013893
13894/* ---------------------------------------------------------------------------
13895 \fn sme_Encryptmsgsend
13896 \brief SME API to issue encrypt message request
13897 \param hHal
13898 \param pCmd: Data to be encrypted
13899 \- return eHalStatus
13900 -------------------------------------------------------------------------*/
13901eHalStatus sme_Encryptmsgsend (tHalHandle hHal,
13902 u8 *pCmd,
13903 int length,
13904 pEncryptMsgRSPCb encMsgCbk)
13905{
13906 eHalStatus status = eHAL_STATUS_SUCCESS;
13907 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13908 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13909 vos_msg_t vosMessage;
13910 u8 *pEncryptMsg;
13911
13912 pEncryptMsg = vos_mem_malloc(length);
13913 if ( !pEncryptMsg)
13914 {
13915 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13916 "%s: Not able to allocate memory for "
13917 "SIR_HAL_ENCRYPT_MSG_REQ",
13918 __func__);
13919 return eHAL_STATUS_FAILURE;
13920 }
13921
13922 vos_mem_copy(pEncryptMsg, pCmd, length);
13923
13924 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13925
13926 pMac->sme.pEncMsgInfoParams.pEncMsgCbk = encMsgCbk;
13927 pMac->sme.pEncMsgInfoParams.pUserData = hHal;
13928 /* Serialize the req through MC thread */
13929 vosMessage.bodyptr = pEncryptMsg;
13930 vosMessage.type = SIR_HAL_ENCRYPT_MSG_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013931 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13932 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053013933 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013934 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13935 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13936 "%s: failed to post SIR_HAL_ENCRYPT_MSG_REQ", __func__);
13937 vos_mem_free(pEncryptMsg);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053013938 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013939 }
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053013940 sme_ReleaseGlobalLock(&pMac->sme);
13941 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013942 else
13943 {
13944 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13945 "sme_AcquireGlobalLock error", __func__);
13946 vos_mem_free(pEncryptMsg);
13947 status = eHAL_STATUS_FAILURE;
13948 }
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053013949 return(status);
13950}
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +053013951
13952/* ---------------------------------------------------------------------------
13953 \fn sme_RegisterBtCoexTDLSCallback
13954 \brief Used to plug in callback function
13955 Which notify btcoex on or off.
13956 Notification come from FW.
13957 \param hHal
13958 \param pCallbackfn : callback function pointer should be plugged in
13959 \- return eHalStatus
13960 -------------------------------------------------------------------------*/
13961eHalStatus sme_RegisterBtCoexTDLSCallback
13962(
13963 tHalHandle hHal,
13964 void (*pCallbackfn)(void *pAdapter, int )
13965)
13966{
13967 eHalStatus status = eHAL_STATUS_SUCCESS;
13968 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13969
13970 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
13971 "%s: Plug in BtCoex TDLS CB", __func__);
13972
13973 status = sme_AcquireGlobalLock(&pMac->sme);
13974 if (eHAL_STATUS_SUCCESS == status)
13975 {
13976 if (NULL != pCallbackfn)
13977 {
13978 pMac->sme.pBtCoexTDLSNotification = pCallbackfn;
13979 }
13980 sme_ReleaseGlobalLock(&pMac->sme);
13981 }
13982 return(status);
13983}
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013984
13985/* ---------------------------------------------------------------------------
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013986 \fn smeNeighborMiddleOfRoaming
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013987
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013988 \brief This function is a wrapper to call csrNeighborMiddleOfRoaming
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013989
13990 \param hHal - The handle returned by macOpen.
13991
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013992 \return eANI_BOOLEAN_TRUE if reassoc in progress,
13993 eANI_BOOLEAN_FALSE otherwise
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013994---------------------------------------------------------------------------*/
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013995
13996tANI_BOOLEAN smeNeighborMiddleOfRoaming(tHalHandle hHal)
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013997{
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013998 return (csrNeighborMiddleOfRoaming(PMAC_STRUCT(hHal)));
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013999}
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +053014000
14001/* ---------------------------------------------------------------------------
14002
14003 \fn sme_IsTdlsOffChannelValid
14004
14005 \brief To check if the channel is valid for currently established domain
14006 This is a synchronous API.
14007
14008 \param hHal - The handle returned by macOpen.
14009 \param channel - channel to verify
14010
14011 \return TRUE/FALSE, TRUE if channel is valid
14012
14013 -------------------------------------------------------------------------------*/
14014tANI_BOOLEAN sme_IsTdlsOffChannelValid(tHalHandle hHal, tANI_U8 channel)
14015{
14016 eHalStatus status = eHAL_STATUS_FAILURE;
14017 tANI_BOOLEAN valid = FALSE;
14018 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14019
14020 status = sme_AcquireGlobalLock( &pMac->sme );
14021 if ( HAL_STATUS_SUCCESS( status ) )
14022 {
14023 /* check whether off channel is valid and non DFS */
Pradeep Reddy POTTETIb9c5f992015-02-18 14:15:55 +053014024 if (csrRoamIsChannelValid(pMac, channel))
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +053014025 {
Pradeep Reddy POTTETIb9c5f992015-02-18 14:15:55 +053014026 if (!CSR_IS_CHANNEL_DFS(channel))
14027 valid = TRUE;
14028 else {
14029 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14030 "%s: configured channel is DFS", __func__);
14031 }
14032 }
14033 else {
14034 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14035 "%s: configured channel is not valid", __func__);
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +053014036 }
14037 sme_ReleaseGlobalLock( &pMac->sme );
14038 }
Pradeep Reddy POTTETIb9c5f992015-02-18 14:15:55 +053014039 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14040 "%s: current country code %c%c channel %d valid %d",
14041 __func__, pMac->scan.countryCodeCurrent[0],
14042 pMac->scan.countryCodeCurrent[1], channel, valid);
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +053014043 return (valid);
14044}
Mukul Sharma4be88422015-03-09 20:29:07 +053014045
14046tANI_BOOLEAN sme_IsCoexScoIndicationSet(tHalHandle hHal)
14047{
14048 eHalStatus status = eHAL_STATUS_FAILURE;
14049 tANI_BOOLEAN valid = FALSE;
14050 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14051
14052 status = sme_AcquireGlobalLock( &pMac->sme );
14053 if ( HAL_STATUS_SUCCESS( status ) )
14054 {
14055 valid = pMac->isCoexScoIndSet;
14056 }
14057 sme_ReleaseGlobalLock( &pMac->sme );
14058 return (valid);
14059}
Abhishek Singh01c73d12015-03-12 15:13:44 +053014060eHalStatus sme_SetMiracastVendorConfig(tHalHandle hHal,
14061 tANI_U32 iniNumBuffAdvert , tANI_U32 set_value)
14062{
14063 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14064 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
14065 tANI_U32 val = SIZE_OF_SUPPORTED_MCS_SET;
14066
14067 if (ccmCfgGetStr(hHal, WNI_CFG_SUPPORTED_MCS_SET, mcsSet, &val)
14068 != eHAL_STATUS_SUCCESS)
14069 {
14070 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14071 FL("failed to get ini param, WNI_CFG_SUPPORTED_MCS_SET"));
14072 return eHAL_STATUS_FAILURE;
14073 }
14074
14075 if (set_value)
14076 {
14077 if (pMac->miracastVendorConfig)
14078 {
14079 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14080 FL(" Miracast tuning already enabled!!"));
14081 return eHAL_STATUS_SUCCESS;
14082 }
14083
14084 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14085 FL("Enable Miracast tuning by disabling 64QAM rates, setting 4 blocks for aggregation and disabling probe response for broadcast probe in P2P-GO mode"));
14086
14087 if (ccmCfgSetInt(hHal, WNI_CFG_NUM_BUFF_ADVERT, 4,
14088 NULL, eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14089 {
14090 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14091 FL("Failure: Could not set WNI_CFG_NUM_BUFF_ADVERT"));
14092 return eHAL_STATUS_FAILURE;
14093 }
14094 /* Disable 64QAM rates ie (MCS 5,6 and 7)
14095 */
14096 mcsSet[0]=0x1F;
14097 }
14098 else
14099 {
14100 if (!pMac->miracastVendorConfig)
14101 {
14102 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14103 FL(" Miracast tuning already disabled!!"));
14104 return eHAL_STATUS_SUCCESS;
14105 }
14106
14107 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14108 FL("Disable Miracast tuning by enabling all MCS rates, setting %d blocks for aggregation and enabling probe response for broadcast probe in P2P-GO mode"),
14109 iniNumBuffAdvert);
14110
14111 if (ccmCfgSetInt(hHal, WNI_CFG_NUM_BUFF_ADVERT, iniNumBuffAdvert,
14112 NULL, eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14113 {
14114 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14115 FL("Failure: Could not set WNI_CFG_NUM_BUFF_ADVERT"));
14116 return eHAL_STATUS_FAILURE;
14117 }
14118 /* Enable all MCS rates)
14119 */
14120 mcsSet[0]=0xFF;
14121 }
14122
14123 if (ccmCfgSetStr(hHal, WNI_CFG_SUPPORTED_MCS_SET, mcsSet,
14124 val, NULL, eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14125 {
14126 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14127 FL("Failure: Could not set WNI_CFG_SUPPORTED_MCS_SET"));
14128 return eHAL_STATUS_FAILURE;
14129 }
14130
14131 pMac->miracastVendorConfig = set_value;
14132 return eHAL_STATUS_SUCCESS;
14133}
Mukul Sharma4be88422015-03-09 20:29:07 +053014134
Mukul Sharma45063942015-04-01 20:07:59 +053014135void sme_SetDefDot11Mode(tHalHandle hHal)
14136{
14137 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14138 csrSetDefaultDot11Mode(pMac);
14139}
14140
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053014141/* ---------------------------------------------------------------------------
14142 \fn sme_SetTdls2040BSSCoexistence
14143 \brief API to enable or disable 20_40 BSS Coexistence IE in TDLS frames.
14144
14145 \param isEnabled - Enable or Disable.
14146 \- return VOS_STATUS_SUCCES
14147 -------------------------------------------------------------------------*/
14148eHalStatus sme_SetTdls2040BSSCoexistence(tHalHandle hHal,
14149 tANI_S32 isTdls2040BSSCoexEnabled)
14150{
14151 eHalStatus status = eHAL_STATUS_SUCCESS;
14152 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14153 vos_msg_t msg;
14154 tAniSetTdls2040BSSCoex *pMsg;
14155
14156 status = sme_AcquireGlobalLock( &pMac->sme );
14157 if (HAL_STATUS_SUCCESS( status ))
14158 {
14159 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14160 "%s: is2040BSSCoexEnabled %d ",
14161 __func__, isTdls2040BSSCoexEnabled);
14162 pMsg = vos_mem_malloc(sizeof(tAniSetTdls2040BSSCoex));
14163 if (NULL == pMsg )
14164 {
14165 smsLog(pMac, LOGE, "failed to allocate mem for SetTdls2040BSSCoex");
14166 sme_ReleaseGlobalLock( &pMac->sme );
14167 return eHAL_STATUS_FAILURE;
14168 }
14169
14170 pMsg->msgType = pal_cpu_to_be16(
14171 (tANI_U16)eWNI_SME_SET_TDLS_2040_BSSCOEX_REQ);
14172 pMsg->msgLen = (tANI_U16)sizeof(tAniSetTdls2040BSSCoex);
14173 pMsg->SetTdls2040BSSCoex = isTdls2040BSSCoexEnabled;
14174
14175 msg.type = eWNI_SME_SET_TDLS_2040_BSSCOEX_REQ;
14176 msg.reserved = 0;
14177 msg.bodyptr = pMsg;
14178 msg.bodyval = 0;
14179
14180 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_PE, &msg))
14181 {
14182 smsLog(pMac, LOGE,
14183 "sme_SetTdls2040BSSCoexistence failed to post msg to PE ");
14184 vos_mem_free((void *)pMsg);
14185 status = eHAL_STATUS_FAILURE;
14186 }
14187 smsLog(pMac, LOG1, FL(" returned"));
14188 sme_ReleaseGlobalLock( &pMac->sme );
14189 }
14190 return status;
14191}
Abhishek Singh41988ba2015-05-25 19:42:29 +053014192
14193/* ---------------------------------------------------------------------------
14194 \fn sme_SetRtsCtsHtVht
14195 \brief API to to enable/disable RTS/CTS for different modes.
14196
14197 \param set_value - Bit mask value to enable RTS/CTS for different modes.
14198 \- return VOS_STATUS_SUCCES if INdication is posted to
14199 WDA else return eHAL_STATUS_FAILURE
14200 -------------------------------------------------------------------------*/
14201eHalStatus sme_SetRtsCtsHtVht(tHalHandle hHal, tANI_U32 set_value)
14202{
14203 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14204 vos_msg_t msg;
14205
14206 smsLog(pMac, LOG1, FL(" set_value = %d"), set_value);
14207
14208 if (ccmCfgSetInt(hHal, WNI_CFG_ENABLE_RTSCTS_HTVHT, set_value,
14209 NULL, eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14210 {
14211 smsLog(pMac, LOGE,
14212 FL("Failure: Could not set WNI_CFG_ENABLE_RTSCTS_HTVHT"));
14213 return eHAL_STATUS_FAILURE;
14214 }
14215 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ))
14216 {
14217 vos_mem_zero(&msg, sizeof(vos_msg_t));
14218 msg.type = WDA_SET_RTS_CTS_HTVHT;
14219 msg.reserved = 0;
14220 msg.bodyval = set_value;
14221 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_WDA, &msg))
14222 {
14223 smsLog(pMac, LOGE,
14224 FL("Not able to post WDA_SET_RTS_CTS_HTVHT message to HAL"));
14225 sme_ReleaseGlobalLock( &pMac->sme );
14226 return eHAL_STATUS_FAILURE;
14227 }
14228 sme_ReleaseGlobalLock( &pMac->sme );
14229 return eHAL_STATUS_SUCCESS;
14230 }
14231 return eHAL_STATUS_FAILURE;
14232
14233}
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +053014234
Sachin Ahuja715aafc2015-07-21 23:35:10 +053014235
14236/* ---------------------------------------------------------------------------
14237 \fn sme_fatal_event_logs_req
14238 \brief API to to send flush log command to FW..
14239
14240 \param hHal - Mac Context Handle
14241 \- return VOS_STATUS_SUCCES if command is posted to
14242 WDA else return eHAL_STATUS_FAILURE
14243 -------------------------------------------------------------------------*/
14244eHalStatus sme_fatal_event_logs_req(tHalHandle hHal, tANI_U32 is_fatal,
Abhishek Singh837adf22015-10-01 17:37:37 +053014245 tANI_U32 indicator, tANI_U32 reason_code,
14246 tANI_BOOLEAN dump_vos_trace)
Sachin Ahuja715aafc2015-07-21 23:35:10 +053014247{
14248 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14249 vos_msg_t msg;
14250 eHalStatus status = eHAL_STATUS_SUCCESS;
14251 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
14252 tpSirFatalEventLogsReqParam pFatalEventLogsReqParams;
14253
Abhishek Singh4eaf6792016-02-04 12:36:39 +053014254 /* Dump last 500 VosTrace */
Abhishek Singh837adf22015-10-01 17:37:37 +053014255 if (dump_vos_trace)
Abhishek Singh4eaf6792016-02-04 12:36:39 +053014256 vosTraceDumpAll(pMac, 0, 0, 500, 0);
Abhishek Singh837adf22015-10-01 17:37:37 +053014257
14258 if (WLAN_LOG_INDICATOR_HOST_ONLY == indicator)
14259 {
14260 vos_flush_host_logs_for_fatal();
14261 return VOS_STATUS_SUCCESS;
14262 }
14263
Sachin Ahuja715aafc2015-07-21 23:35:10 +053014264 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ))
14265 {
Hanumantha Reddy Pothula368eefb2016-01-22 15:36:40 +053014266 pFatalEventLogsReqParams =
14267 vos_mem_malloc(sizeof(*pFatalEventLogsReqParams));
Sachin Ahuja715aafc2015-07-21 23:35:10 +053014268 if(NULL == pFatalEventLogsReqParams)
14269 {
14270 smsLog(pMac, LOGE,
14271 FL("vos_mem_alloc failed "));
14272 return eHAL_STATUS_FAILED_ALLOC;
14273 }
Hanumantha Reddy Pothula368eefb2016-01-22 15:36:40 +053014274 vos_mem_set(pFatalEventLogsReqParams,
14275 sizeof(*pFatalEventLogsReqParams), 0);
Sachin Ahuja715aafc2015-07-21 23:35:10 +053014276 pFatalEventLogsReqParams->reason_code = reason_code;
14277
14278 vos_mem_zero(&msg, sizeof(vos_msg_t));
14279 msg.type = WDA_FATAL_EVENT_LOGS_REQ;
14280 msg.reserved = 0;
14281 msg.bodyptr = pFatalEventLogsReqParams;
14282 msg.bodyval = 0;
14283 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &msg);
14284 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
14285 {
14286 vos_mem_free(pFatalEventLogsReqParams);
14287 status = eHAL_STATUS_FAILURE;
14288 }
14289 sme_ReleaseGlobalLock( &pMac->sme );
14290 return status;
14291
14292 }
14293 return eHAL_STATUS_FAILURE;
14294}
14295
14296
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +053014297/**
14298 * sme_handleSetFccChannel() - handle fcc constraint request
14299 * @hal: HAL pointer
14300 * @fcc_constraint: whether to apply or remove fcc constraint
14301 *
14302 * Return: tANI_BOOLEAN.
14303 */
Agrawal Ashish842eea82016-02-04 17:56:16 +053014304tANI_BOOLEAN sme_handleSetFccChannel(tHalHandle hHal, tANI_U8 fcc_constraint,
14305 v_U32_t scan_pending)
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +053014306{
14307 eHalStatus status = eHAL_STATUS_SUCCESS;
14308 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14309
14310 status = sme_AcquireGlobalLock(&pMac->sme);
14311
14312 if (eHAL_STATUS_SUCCESS == status &&
14313 (!sme_Is11dSupported(hHal)) )
14314 {
Agrawal Ashish842eea82016-02-04 17:56:16 +053014315 pMac->scan.fcc_constraint = !fcc_constraint;
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +053014316
Agrawal Ashish842eea82016-02-04 17:56:16 +053014317 if (scan_pending == TRUE) {
14318 pMac->scan.defer_update_channel_list = true;
14319 } else {
14320 /* update the channel list to the firmware */
Sourav Mohapatra3dd5dba2018-03-26 15:12:47 +053014321 csrUpdateFCCChannelList(pMac);
Agrawal Ashish842eea82016-02-04 17:56:16 +053014322 }
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +053014323 }
14324
14325 sme_ReleaseGlobalLock(&pMac->sme);
14326
14327 return status;
14328}
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +053014329
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +053014330eHalStatus sme_enableDisableChanAvoidIndEvent(tHalHandle hHal, tANI_U8 set_value)
14331{
14332 eHalStatus status = eHAL_STATUS_SUCCESS;
14333 VOS_STATUS vosStatus;
14334 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14335 vos_msg_t msg;
14336
14337 smsLog(pMac, LOG1, FL("set_value: %d"), set_value);
14338 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ))
14339 {
14340 vos_mem_zero(&msg, sizeof(vos_msg_t));
14341 msg.type = WDA_SEND_FREQ_RANGE_CONTROL_IND;
14342 msg.reserved = 0;
14343 msg.bodyval = set_value;
14344 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &msg);
14345 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
14346 {
14347 status = eHAL_STATUS_FAILURE;
14348 }
14349 sme_ReleaseGlobalLock( &pMac->sme );
14350 return status;
14351 }
14352
14353 return eHAL_STATUS_FAILURE;
14354}
14355
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +053014356eHalStatus sme_DeleteAllTDLSPeers(tHalHandle hHal, uint8_t sessionId)
14357{
14358 tSirDelAllTdlsPeers *pMsg;
14359 eHalStatus status = eHAL_STATUS_SUCCESS;
14360 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14361 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14362
14363 pMsg = vos_mem_malloc(sizeof(tSirDelAllTdlsPeers));
14364 if (NULL == pMsg)
14365 {
14366 smsLog(pMac, LOGE, FL("memory alloc failed"));
14367 return eHAL_STATUS_FAILURE;
14368 }
14369 vos_mem_set(pMsg, sizeof( tSirDelAllTdlsPeers ), 0);
14370 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_ALL_TDLS_PEERS);
14371 pMsg->mesgLen = pal_cpu_to_be16((tANI_U16)sizeof( tSirDelAllTdlsPeers ));
14372 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
14373 sizeof(tSirMacAddr));
14374 status = palSendMBMessage( pMac->hHdd, pMsg );
14375 return status;
14376}
c_manjeecfd1efb2015-09-25 19:32:34 +053014377
14378
14379/**
14380 * sme_FwMemDumpReq() - Send Fwr mem Dump Request
14381 * @hal: HAL pointer
14382 *
14383 * Return: eHalStatus
14384 */
14385
14386eHalStatus sme_FwMemDumpReq(tHalHandle hHal, tAniFwrDumpReq *recv_req)
14387{
14388
14389 eHalStatus status = eHAL_STATUS_SUCCESS;
14390 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14391 vos_msg_t msg;
14392 tAniFwrDumpReq * send_req;
14393
14394 send_req = vos_mem_malloc(sizeof(*send_req));
14395 if(!send_req) {
14396 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14397 FL("Mem allo failed for FW_MEM_DUMP"));
14398 return eHAL_STATUS_FAILURE;
14399 }
14400
14401 send_req->fwMemDumpReqCallback = recv_req->fwMemDumpReqCallback;
14402 send_req->fwMemDumpReqContext = recv_req->fwMemDumpReqContext;
14403
14404 if (eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock(&pMac->sme))
14405 {
14406 msg.bodyptr = send_req;
14407 msg.type = WDA_FW_MEM_DUMP_REQ;
14408 msg.reserved = 0;
14409
14410 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
14411 {
14412 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14413 FL("Not able to post WDA_FW_MEM_DUMP"));
14414 vos_mem_free(send_req);
14415 status = eHAL_STATUS_FAILURE;
14416 }
14417 sme_ReleaseGlobalLock(&pMac->sme);
14418 }
14419 else
14420 {
14421 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14422 FL("Failed to acquire SME Global Lock"));
14423 vos_mem_free(send_req);
14424 status = eHAL_STATUS_FAILURE;
14425 }
14426
14427 return status;
14428}
14429
Arun Khandavalli7eeb1592015-10-19 21:36:57 +053014430eHalStatus sme_set_wificonfig_params(tHalHandle hHal, tSetWifiConfigParams *req)
14431{
14432 eHalStatus status = eHAL_STATUS_SUCCESS;
14433 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14434 vos_msg_t msg;
14435
14436 status = sme_AcquireGlobalLock(&pMac->sme);
14437
14438 if (eHAL_STATUS_SUCCESS == status){
14439
14440 /* serialize the req through MC thread */
14441 msg.type = WDA_WIFI_CONFIG_REQ;
14442 msg.reserved = 0;
14443 msg.bodyptr = req;
14444
14445 MTRACE(vos_trace(VOS_MODULE_ID_SME,
14446 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
14447
14448 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
14449 {
14450 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
14451 "Not able to post SIR_HAL_WIFI_CONFIG_PARAMS message to HAL", __func__);
14452 status = eHAL_STATUS_FAILURE;
14453 }
14454 sme_ReleaseGlobalLock( &pMac->sme );
14455 }
14456 else
14457 {
14458 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
14459 "sme_AcquireGlobalLock error", __func__);
14460 }
14461 return status;
14462}
Padma, Santhosh Kumar2762e9d2015-10-20 15:02:57 +053014463
14464eHalStatus sme_getRegInfo(tHalHandle hHal, tANI_U8 chanId,
14465 tANI_U32 *regInfo1, tANI_U32 *regInfo2)
14466{
14467 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14468 eHalStatus status;
14469 tANI_U8 i;
14470 eAniBoolean found = false;
14471
14472 status = sme_AcquireGlobalLock(&pMac->sme);
14473 *regInfo1 = 0;
14474 *regInfo2 = 0;
14475 if (HAL_STATUS_SUCCESS(status))
14476 {
14477 for (i = 0 ; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++)
14478 {
14479 if (pMac->scan.defaultPowerTable[i].chanId == chanId)
14480 {
14481 SME_SET_CHANNEL_REG_POWER(*regInfo1,
14482 pMac->scan.defaultPowerTable[i].pwr);
14483
14484 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
14485 pMac->scan.defaultPowerTable[i].pwr);
14486
14487
14488 found = true;
14489 break;
14490 }
14491 }
14492
14493 if (!found)
14494 status = eHAL_STATUS_FAILURE;
14495
14496 sme_ReleaseGlobalLock(&pMac->sme);
14497 }
14498 return status;
14499}
Mahesh A Saptasagarcfc65ae2015-12-22 15:06:10 +053014500
14501eHalStatus sme_GetCurrentAntennaIndex(tHalHandle hHal,
14502 tCsrAntennaIndexCallback callback,
14503 void *pContext, tANI_U8 sessionId)
14504{
14505 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14506 eHalStatus status = eHAL_STATUS_SUCCESS;
14507 tSirAntennaDiversitySelectionReq *pMsg;
14508 tCsrRoamSession *pSession;
14509 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
14510 vos_msg_t vosMessage;
14511
14512 status = sme_AcquireGlobalLock(&pMac->sme);
14513 if (HAL_STATUS_SUCCESS(status))
14514 {
14515 pSession = CSR_GET_SESSION( pMac, sessionId );
14516 if (!pSession)
14517 {
14518 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
14519 sme_ReleaseGlobalLock( &pMac->sme );
14520 return eHAL_STATUS_FAILURE;
14521 }
14522
14523 pMsg = (tSirAntennaDiversitySelectionReq*)vos_mem_malloc(sizeof(*pMsg));
14524 if (NULL == pMsg)
14525 {
14526 smsLog(pMac, LOGE, FL("failed to allocated memory"));
14527 sme_ReleaseGlobalLock( &pMac->sme );
14528 return eHAL_STATUS_FAILURE;
14529 }
14530 pMsg->callback = callback;
14531 pMsg->data = pContext;
14532
14533 vosMessage.type = WDA_ANTENNA_DIVERSITY_SELECTION_REQ;
14534 vosMessage.bodyptr = pMsg;
14535 vosMessage.reserved = 0;
14536
14537 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
14538 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
14539 {
14540 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14541 "%s: Failed to post message to WDA", __func__);
14542 vos_mem_free(pMsg);
14543 sme_ReleaseGlobalLock( &pMac->sme );
14544 return eHAL_STATUS_FAILURE;
14545 }
14546 sme_ReleaseGlobalLock( &pMac->sme);
14547 return eHAL_STATUS_SUCCESS;
14548 }
14549 return eHAL_STATUS_FAILURE;
14550}
Mahesh A Saptasagar7d432952016-02-09 14:01:03 +053014551
14552eHalStatus sme_setBcnMissPenaltyCount(tHalHandle hHal,
14553 tModifyRoamParamsReqParams *pModifyRoamReqParams)
14554{
14555 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14556 eHalStatus status = eHAL_STATUS_SUCCESS;
14557 VOS_STATUS vosStatus;
14558 tModifyRoamParamsReqParams *pMsg;
14559 vos_msg_t msg;
14560
14561 status = sme_AcquireGlobalLock(&pMac->sme);
14562 if (HAL_STATUS_SUCCESS(status))
14563 {
14564 pMsg = (tModifyRoamParamsReqParams*)vos_mem_malloc(sizeof(*pMsg));
14565 if (NULL == pMsg)
14566 {
14567 smsLog(pMac, LOGE, FL("failed to allocated memory"));
14568 sme_ReleaseGlobalLock( &pMac->sme );
14569 return eHAL_STATUS_FAILURE;
14570 }
14571 if (NULL == pModifyRoamReqParams)
14572 {
14573 smsLog(pMac, LOGE, FL("Invalid memory"));
14574 vos_mem_free(pMsg);
14575 sme_ReleaseGlobalLock( &pMac->sme );
14576 return eHAL_STATUS_FAILURE;
14577 }
14578 pMsg->param = pModifyRoamReqParams->param;
14579 pMsg->value = pModifyRoamReqParams->value;
14580 vos_mem_zero(&msg, sizeof(vos_msg_t));
14581 msg.type = WDA_MODIFY_ROAM_PARAMS_IND;
14582 msg.reserved = 0;
14583 msg.bodyptr = pMsg;
14584 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &msg);
14585 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
14586 {
14587 status = eHAL_STATUS_FAILURE;
14588 vos_mem_free(pMsg);
14589 }
14590 sme_ReleaseGlobalLock( &pMac->sme );
14591 return status;
14592 }
14593
14594 return eHAL_STATUS_FAILURE;
14595}
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +053014596
14597/**
14598 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
14599 * scan list
14600 * @hal: hal context.
14601 * @bssid: bssid to be removed
14602 *
14603 * This function remove the given bssid from scan list.
14604 *
14605 * Return: hal status.
14606 */
14607eHalStatus sme_remove_bssid_from_scan_list(tHalHandle hal,
14608 tSirMacAddr bssid)
14609{
14610 eHalStatus status = eHAL_STATUS_FAILURE;
14611 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
14612
14613 status = sme_AcquireGlobalLock(&pMac->sme);
14614 if (HAL_STATUS_SUCCESS(status)) {
14615 csr_remove_bssid_from_scan_list(pMac, bssid);
14616 sme_ReleaseGlobalLock(&pMac->sme);
14617 }
14618
14619 return status;
14620}
14621
Agrawal Ashish0552be02016-03-02 18:03:43 +053014622/**
14623 * sme_set_mgmt_frm_via_wq5() - Set INI params sendMgmtPktViaWQ5 to WDA.
14624 * @hal: HAL pointer
14625 * @sendMgmtPktViaWQ5: INI params to enable/disable sending mgmt pkt via WQ5.
14626 *
14627 * Return: void
14628 */
14629void sme_set_mgmt_frm_via_wq5(tHalHandle hHal, tANI_BOOLEAN sendMgmtPktViaWQ5)
14630{
14631 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14632 eHalStatus status = eHAL_STATUS_SUCCESS;
14633
14634 status = sme_AcquireGlobalLock(&pMac->sme);
14635 if (HAL_STATUS_SUCCESS(status))
14636 {
14637 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14638 "sendMgmtPktViaWQ5 is %d", sendMgmtPktViaWQ5);
14639 /* not serializing this messsage, as this is only going
14640 * to set a variable in WDA/WDI
14641 */
14642 WDA_SetMgmtPktViaWQ5(sendMgmtPktViaWQ5);
14643 sme_ReleaseGlobalLock(&pMac->sme);
14644 }
14645 return;
14646}
Agrawal Ashish17ef5082016-10-17 18:33:21 +053014647
Anurag Chouhan6ee81542017-02-09 18:09:27 +053014648/* ARP DEBUG STATS */
14649
14650/**
14651 * sme_set_nud_debug_stats() - sme api to set nud debug stats
14652 * @hHal: handle to hal
14653 * @pSetStatsParam: pointer to set stats param
14654 */
14655eHalStatus sme_set_nud_debug_stats(tHalHandle hHal,
14656 setArpStatsParams *pSetStatsParam)
14657{
14658 setArpStatsParams *arp_set_param;
14659 vos_msg_t msg;
14660
14661 arp_set_param = vos_mem_malloc(sizeof(*arp_set_param));
14662 if (arp_set_param == NULL) {
14663 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14664 FL("Memory allocation failure"));
14665 return VOS_STATUS_E_NOMEM;
14666 }
14667
14668 vos_mem_copy(arp_set_param, pSetStatsParam, sizeof(*arp_set_param));
14669
14670 msg.type = WDA_SET_ARP_STATS_REQ;
14671 msg.reserved = 0;
14672 msg.bodyptr = arp_set_param;
14673
14674 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)) {
14675 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14676 FL("Not able to post message to WDA"));
14677 vos_mem_free(arp_set_param);
14678 return VOS_STATUS_E_FAILURE;
14679 }
14680
14681 return VOS_STATUS_SUCCESS;
14682}
14683
14684/**
14685 * sme_get_nud_debug_stats() - sme api to get nud debug stats
14686 * @hHal: handle to hal
14687 * @pGetStatsParam: pointer to set stats param
14688 */
14689eHalStatus sme_get_nud_debug_stats(tHalHandle hHal,
14690 getArpStatsParams *pGetStatsParam)
14691{
14692 getArpStatsParams *arpGetParams;
14693 vos_msg_t msg;
14694
14695 arpGetParams = vos_mem_malloc(sizeof(*arpGetParams));
14696 if (arpGetParams == NULL) {
14697 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14698 FL("Memory allocation failure"));
14699 return VOS_STATUS_E_NOMEM;
14700 }
14701
14702 vos_mem_copy(arpGetParams, pGetStatsParam, sizeof(*arpGetParams));
14703
14704 msg.type = WDA_GET_ARP_STATS_REQ;
14705 msg.reserved = 0;
14706 msg.bodyptr = arpGetParams;
14707
14708 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)) {
14709 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14710 FL("Not able to post message to WDA"));
14711 vos_mem_free(arpGetParams);
14712 return VOS_STATUS_E_FAILURE;
14713 }
14714
14715 return VOS_STATUS_SUCCESS;
14716}
14717
14718
Agrawal Ashish17ef5082016-10-17 18:33:21 +053014719#ifdef SAP_AUTH_OFFLOAD
14720/**
14721 * sme_set_sap_auth_offload() enable/disable Software AP Auth Offload
14722 * @hHal: hal layer handler
14723 * @sap_auth_offload_info: the information of Software AP Auth offload
14724 *
14725 * This function provide enable/disable Software AP authenticaiton offload
14726 * feature on target firmware
14727 *
14728 * Return: Return eHalStatus.
14729 */
14730eHalStatus sme_set_sap_auth_offload(tHalHandle hHal,
14731 struct tSirSapOffloadInfo *sap_auth_offload_info)
14732{
14733 vos_msg_t vosMessage;
14734 struct tSirSapOffloadInfo *sme_sap_auth_offload_info;
14735 eHalStatus status = eHAL_STATUS_SUCCESS;
14736 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14737
14738 pMac->sap_auth_offload_sec_type =
14739 sap_auth_offload_info->sap_auth_offload_sec_type;
14740 pMac->sap_auth_offload = sap_auth_offload_info->sap_auth_offload_enable;
14741
14742 sme_sap_auth_offload_info =
14743 vos_mem_malloc(sizeof(*sme_sap_auth_offload_info));
14744
14745 if (!sme_sap_auth_offload_info)
14746 {
14747 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14748 "%s: Not able to allocate memory for WDA_SET_SAP_AUTH_OFL",
14749 __func__);
14750 return eHAL_STATUS_E_MALLOC_FAILED;
14751 }
14752 vos_mem_copy(sme_sap_auth_offload_info, sap_auth_offload_info,
14753 sizeof(*sap_auth_offload_info));
14754
14755 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
14756 {
14757 /* serialize the req through MC thread */
14758 vosMessage.type = WDA_SET_SAP_AUTH_OFL;
14759 vosMessage.bodyptr = sme_sap_auth_offload_info;
14760
14761 if (!VOS_IS_STATUS_SUCCESS(
14762 vos_mq_post_message(VOS_MODULE_ID_WDA, &vosMessage)))
14763 {
14764 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14765 "%s: Not able to post WDA_SET_SAP_AUTH_OFL to WDA!",
14766 __func__);
14767 vos_mem_free(sme_sap_auth_offload_info);
14768 status = eHAL_STATUS_FAILURE;
14769 }
14770 sme_ReleaseGlobalLock(&pMac->sme);
14771 }
14772 else
14773 {
14774 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14775 "%s: sme_AcquireGlobalLock error!",
14776 __func__);
14777 vos_mem_free(sme_sap_auth_offload_info);
14778 status = eHAL_STATUS_FAILURE;
14779 }
14780
14781 return (status);
14782}
14783#endif
Anurag Chouhan83026002016-12-13 22:46:21 +053014784
14785#ifdef DHCP_SERVER_OFFLOAD
14786/**
14787 * sme_set_dhcp_srv_offload() - sme api to set dhcp server offload info
14788 * @hal: handle to hal
14789 * @dhcp_srv_info: pointer to dhcp server info
14790 *
14791 * Return: eHalStatus
14792 * eHAL_STATUS_SUCCESS - success or else failure code
14793 */
14794eHalStatus sme_set_dhcp_srv_offload(tHalHandle hal,
14795 sir_dhcp_srv_offload_info_t *dhcp_srv_info)
14796{
14797 vos_msg_t vos_msg;
14798 eHalStatus status = eHAL_STATUS_SUCCESS;
14799 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14800 sir_dhcp_srv_offload_info_t *dhcp_serv_info = NULL;
14801
14802 dhcp_serv_info =
14803 vos_mem_malloc(sizeof(*dhcp_serv_info));
14804 if (NULL == dhcp_serv_info) {
14805 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14806 "Failed to alloc memory");
14807 return VOS_STATUS_E_NOMEM;
14808 }
14809
14810 vos_mem_copy(dhcp_serv_info, dhcp_srv_info,
14811 sizeof(*dhcp_serv_info));
14812
Sachin Ahujae4c6fac2016-12-29 10:30:15 +053014813 dhcp_serv_info->bssidx = peFindBssIdxFromSmeSessionId(mac, dhcp_srv_info->bssidx);
Anurag Chouhan83026002016-12-13 22:46:21 +053014814 status = sme_AcquireGlobalLock(&mac->sme);
14815 if (eHAL_STATUS_SUCCESS == status) {
14816 /* serialize the req through MC thread */
14817 vos_msg.type = WDA_SET_DHCP_SERVER_OFFLOAD_REQ;
14818 vos_msg.bodyptr = dhcp_serv_info;
14819
14820 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message
14821 (VOS_MODULE_ID_WDA, &vos_msg))) {
14822 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14823 "%s: Not able to post WDA_SET_DHCP_SERVER_OFFLOAD_REQ to WDA!",
14824 __func__);
14825 vos_mem_free(dhcp_serv_info);
14826 status = eHAL_STATUS_FAILURE;
14827 }
14828 sme_ReleaseGlobalLock(&mac->sme);
14829 } else {
14830 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14831 "%s: sme_AcquireGlobalLock error!",
14832 __func__);
14833 vos_mem_free(dhcp_serv_info);
14834 }
14835
14836 return status;
14837}
14838#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +053014839
14840#ifdef MDNS_OFFLOAD
14841/**
14842 * sme_set_mdns_offload() - sme API to set mdns offload enable/disable
14843 * @hal: handle to hal pointer
14844 * @mdns_info: pointer to mdns offload info
14845 *
14846 * Return - eHalStatus
14847 */
14848eHalStatus sme_set_mdns_offload(tHalHandle hal,
14849 sir_mdns_offload_info_t *mdns_info)
14850{
14851 vos_msg_t vos_msg;
14852 sir_mdns_offload_info_t *mdns_offload;
14853 eHalStatus status = eHAL_STATUS_SUCCESS;
14854 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14855
14856 mdns_offload = vos_mem_malloc(sizeof(*mdns_offload));
14857
14858 if (!mdns_offload) {
14859 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14860 "%s: Not able to allocate memory for WDA_SET_MDNS_OFFLOAD_CMD",
14861 __func__);
14862 return eHAL_STATUS_E_MALLOC_FAILED;
14863 }
14864
14865 vos_mem_copy(mdns_offload, mdns_info, sizeof(*mdns_offload));
Sachin Ahujae4c6fac2016-12-29 10:30:15 +053014866 mdns_offload->bss_idx =
14867 peFindBssIdxFromSmeSessionId(mac, mdns_info->bss_idx);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053014868 status = sme_AcquireGlobalLock(&mac->sme);
14869 if (eHAL_STATUS_SUCCESS == status) {
14870 /* serialize the req through MC thread */
14871 vos_msg.type = WDA_SET_MDNS_OFFLOAD_CMD;
14872 vos_msg.bodyptr = mdns_offload;
14873
14874 if (!VOS_IS_STATUS_SUCCESS(
14875 vos_mq_post_message(VOS_MODULE_ID_WDA,
14876 &vos_msg))) {
14877 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14878 "%s: Not able to post WDA_SET_MDNS_OFFLOAD_CMD to WDA!",
14879 __func__);
14880 vos_mem_free(mdns_offload);
14881 status = eHAL_STATUS_FAILURE;
14882 }
14883 sme_ReleaseGlobalLock(&mac->sme);
14884 } else {
14885 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14886 "%s: sme_AcquireGlobalLock error!",
14887 __func__);
14888 vos_mem_free(mdns_offload);
14889 }
14890
14891 return (status);
14892}
14893
14894/**
14895 * sme_set_mdns_fqdn() - SME API to set mDNS Fqdn info
14896 * @hal: hal handle
14897 * @mdns_fqdn: mDNS Fqdn info struct
14898 *
14899 * Return - return eHalStatus
14900 */
14901eHalStatus sme_set_mdns_fqdn(tHalHandle hal,
14902 sir_mdns_fqdn_info_t *mdns_fqdn)
14903{
14904 vos_msg_t vos_msg;
14905 sir_mdns_fqdn_info_t *fqdn_info;
14906 eHalStatus status = eHAL_STATUS_SUCCESS;
14907 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14908
14909 fqdn_info = vos_mem_malloc(sizeof(*fqdn_info));
14910
14911 if (!fqdn_info) {
14912 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14913 "%s: Not able to allocate memory for WDA_SET_MDNS_FQDN_CMD",
14914 __func__);
14915 return eHAL_STATUS_E_MALLOC_FAILED;
14916 }
14917
14918 vos_mem_copy(fqdn_info, mdns_fqdn, sizeof(*fqdn_info));
Sachin Ahujae4c6fac2016-12-29 10:30:15 +053014919 fqdn_info->bss_idx = peFindBssIdxFromSmeSessionId(mac, mdns_fqdn->bss_idx);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053014920 status = sme_AcquireGlobalLock(&mac->sme);
14921 if (eHAL_STATUS_SUCCESS == status) {
14922 /* serialize the req through MC thread */
14923 vos_msg.type = WDA_SET_MDNS_FQDN_CMD;
14924 vos_msg.bodyptr = fqdn_info;
14925
14926 if (!VOS_IS_STATUS_SUCCESS(
14927 vos_mq_post_message(VOS_MODULE_ID_WDA,
14928 &vos_msg))) {
14929 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14930 "%s: Not able to post WDA_SET_MDNS_FQDN_CMD to WDA!",
14931 __func__);
14932 vos_mem_free(fqdn_info);
14933 status = eHAL_STATUS_FAILURE;
14934 }
14935 sme_ReleaseGlobalLock(&mac->sme);
14936 } else {
14937 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14938 "%s: sme_AcquireGlobalLock error!",
14939 __func__);
14940 vos_mem_free(fqdn_info);
14941 }
14942
14943 return (status);
14944}
14945
14946/**
14947 * sme_set_mdns_resp() - SME API to set mDNS response info
14948 * @hal: hal handle
14949 * @mdns_resp : mDNS response info struct
14950 *
14951 * Return - eHalStatus
14952 */
14953eHalStatus sme_set_mdns_resp(tHalHandle hal,
14954 sir_mdns_resp_info_t *mdns_resp)
14955{
14956 vos_msg_t vos_msg;
14957 sir_mdns_resp_info_t *resp_info;
14958 eHalStatus status = eHAL_STATUS_SUCCESS;
14959 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14960
14961 resp_info = vos_mem_malloc(sizeof(*resp_info));
14962
14963 if (!resp_info) {
14964 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14965 "%s: Not able to allocate memory for WDA_SET_MDNS_RESPONSE_CMD",
14966 __func__);
14967 return eHAL_STATUS_E_MALLOC_FAILED;
14968 }
14969
14970 vos_mem_copy(resp_info, mdns_resp, sizeof(*resp_info));
Sachin Ahujae4c6fac2016-12-29 10:30:15 +053014971 resp_info->bss_idx = peFindBssIdxFromSmeSessionId(mac, mdns_resp->bss_idx);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053014972 status = sme_AcquireGlobalLock(&mac->sme);
14973 if (eHAL_STATUS_SUCCESS == status) {
14974 /* serialize the req through MC thread */
14975 vos_msg.type = WDA_SET_MDNS_RESPONSE_CMD;
14976 vos_msg.bodyptr = resp_info;
14977
14978 if (!VOS_IS_STATUS_SUCCESS(
14979 vos_mq_post_message(VOS_MODULE_ID_WDA,
14980 &vos_msg))) {
14981 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14982 "%s: Not able to post WDA_SET_MDNS_RESPONSE_CMD to WDA!",
14983 __func__);
14984 vos_mem_free(resp_info);
14985 status = eHAL_STATUS_FAILURE;
14986 }
14987 sme_ReleaseGlobalLock(&mac->sme);
14988 } else {
14989 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14990 "%s: sme_AcquireGlobalLock error!",
14991 __func__);
14992 vos_mem_free(resp_info);
14993 }
14994
14995 return (status);
14996}
14997#endif /* MDNS_OFFLOAD */
Ravi Kumar bokka7d032762016-12-12 23:33:01 +053014998
14999/**
15000 * sme_update_hb_threshold() - Set heartbeat Threshold value.
15001 * @hal: HAL pointer
15002 * @cfgId: cfg param id
15003 * @hbThresh: heartbeat threshold value.
15004 *
15005 * Return: Success/Failure
15006 */
15007eHalStatus sme_update_hb_threshold(tHalHandle hHal, tANI_U32 cfgId,
15008 tANI_U8 hbThresh, eCsrBand eBand)
15009{
15010 eHalStatus status = eHAL_STATUS_SUCCESS;
15011 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15012
15013 if ((hbThresh < WNI_CFG_HEART_BEAT_THRESHOLD_STAMIN) ||
15014 (hbThresh > WNI_CFG_HEART_BEAT_THRESHOLD_STAMAX)) {
15015 smsLog(pMac, LOGE, FL("invalid heartbeat threshold %hhu"), hbThresh);
15016 return eHAL_STATUS_FAILURE;
15017 }
15018
15019 if(eBand == eCSR_BAND_24)
15020 pMac->roam.configParam.HeartbeatThresh24 = hbThresh;
15021
15022 if(eBand == eCSR_BAND_5G)
15023 pMac->roam.configParam.HeartbeatThresh50 = hbThresh;
15024
15025 status = sme_update_cfg_int_param(hHal, WNI_CFG_HEART_BEAT_THRESHOLD);
15026 if (eHAL_STATUS_SUCCESS != status) {
15027 smsLog(pMac, LOGE, FL("WLAN set heartbeat threshold FAILED"));
15028 status = eHAL_STATUS_FAILURE;
15029 }
15030 return status;
15031}
Kapil Gupta3d923fb2016-12-20 18:59:27 +053015032
15033#ifdef WLAN_FEATURE_APFIND
15034/**
15035 * sme_apfind_set_cmd() - set apfind configuration to firmware
15036 * @input: pointer to apfind request data.
15037 *
15038 * SME API to set APFIND configuations to firmware.
15039 *
15040 * Return: VOS_STATUS.
15041 */
15042VOS_STATUS sme_apfind_set_cmd(struct sme_ap_find_request_req *input)
15043{
15044 vos_msg_t msg;
15045 struct hal_apfind_request *data;
15046 size_t data_len;
15047
15048 data_len = sizeof(struct hal_apfind_request) + input->request_data_len;
15049 data = vos_mem_malloc(data_len);
15050
15051 if (data == NULL) {
15052 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15053 FL("Memory allocation failure"));
15054 return VOS_STATUS_E_NOMEM;
15055 }
15056
15057 vos_mem_zero(data, data_len);
15058 data->request_data_len = input->request_data_len;
15059 if (input->request_data_len) {
15060 vos_mem_copy(data->request_data,
15061 input->request_data, input->request_data_len);
15062 }
15063
15064 msg.type = WDA_APFIND_SET_CMD;
15065 msg.reserved = 0;
15066 msg.bodyptr = data;
15067
15068 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)) {
15069 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15070 FL("Not able to post WDA_APFIND_SET_CMD message to WDA"));
15071 vos_mem_free(data);
15072 return VOS_STATUS_E_FAILURE;
15073 }
15074
15075 return VOS_STATUS_SUCCESS;
15076}
Manjeet Singh3ed79242017-01-11 19:04:32 +053015077
Kapil Gupta3d923fb2016-12-20 18:59:27 +053015078#endif /* WLAN_FEATURE_APFIND */
Manjeet Singh3ed79242017-01-11 19:04:32 +053015079
15080/**
15081 * sme_capture_tsf_req() - send tsf capture request to firmware
15082 * @hHal: hal handle.
15083 * @cap_tsf_params: capture tsf request params.
15084 *
15085 * Return: hal status.
15086 */
15087eHalStatus sme_capture_tsf_req(tHalHandle hHal, tSirCapTsfParams cap_tsf_params)
15088{
15089 eHalStatus status = eHAL_STATUS_SUCCESS;
15090 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15091 vos_msg_t vosMessage;
15092 tpSirCapTsfParams tsf_params = NULL;
15093 VOS_STATUS vos_status;
15094 tCsrRoamSession *pSession;
15095
15096 MTRACE(vos_trace(VOS_MODULE_ID_SME,
15097 TRACE_CODE_SME_TX_HDD_CAP_TSF_REQ, NO_SESSION, 0));
15098 if (eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock(&pMac->sme)))
15099 {
15100 pSession = CSR_GET_SESSION(pMac, cap_tsf_params.session_id);
15101 if (!pSession)
15102 {
15103 smsLog(pMac, LOGE, FL("session %d not found"),
15104 cap_tsf_params.bss_idx);
15105 sme_ReleaseGlobalLock( &pMac->sme );
15106 return eHAL_STATUS_FAILURE;
15107 }
15108
15109 tsf_params = (tpSirCapTsfParams)
15110 vos_mem_malloc(sizeof(*tsf_params));
15111
15112 if (NULL == tsf_params)
15113 {
15114 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15115 "%s: Not able to allocate memory for sme_capture_tsf_req",
15116 __func__);
15117 sme_ReleaseGlobalLock( &pMac->sme );
15118 return eHAL_STATUS_FAILURE;
15119 }
15120 vos_mem_copy(&tsf_params->bssid, &pSession->connectedProfile.bssid,
15121 sizeof(tsf_params->bssid));
15122
15123 tsf_params->tsf_rsp_cb_func = cap_tsf_params.tsf_rsp_cb_func;
15124 tsf_params->tsf_rsp_cb_ctx = cap_tsf_params.tsf_rsp_cb_ctx;
15125
15126 /* serialize the req through MC thread */
15127 /* TODO: check if callback is required */
15128 vosMessage.bodyptr = tsf_params;
15129 vosMessage.type = eWNI_SME_CAP_TSF_REQ;
15130
15131 vos_status = vos_mq_post_message(VOS_MQ_ID_PE, &vosMessage);
15132
15133 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15134 {
15135 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15136 "%s: Post Set TM Level MSG fail", __func__);
15137 vos_mem_free(tsf_params);
15138 status = eHAL_STATUS_FAILURE;
15139 }
15140 sme_ReleaseGlobalLock( &pMac->sme );
15141 }
15142 return(status);
15143}
15144
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053015145eHalStatus sme_del_sta_ba_session_req(tHalHandle hHal,
15146 tDelBaParams sta_del_params)
15147{
15148 eHalStatus status = eHAL_STATUS_SUCCESS;
15149 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15150 vos_msg_t vosMessage;
15151 ptDelBaParams del_params = NULL;
15152 VOS_STATUS vos_status;
15153 tCsrRoamSession *pSession;
15154
15155 MTRACE(vos_trace(VOS_MODULE_ID_SME,
15156 TRACE_CODE_SME_DEL_STA_BA_SESSION_REQ, NO_SESSION, 0));
15157 if (eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock(&pMac->sme)))
15158 {
15159 pSession = CSR_GET_SESSION(pMac, sta_del_params.session_id);
15160 if (!pSession)
15161 {
15162 smsLog(pMac, LOGE, FL("session not found"));
15163 sme_ReleaseGlobalLock( &pMac->sme );
15164 return eHAL_STATUS_FAILURE;
15165 }
15166
15167 del_params = (ptDelBaParams) vos_mem_malloc(sizeof(*del_params));
15168
15169 if (NULL == del_params)
15170 {
15171 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15172 "%s: Not able to allocate memory for sme_del_sta_ba_session_req", __func__);
15173 sme_ReleaseGlobalLock( &pMac->sme );
15174 return eHAL_STATUS_FAILURE;
15175 }
15176 vos_mem_copy(&del_params->session_id, &pSession->sessionId,
15177 sizeof(del_params->session_id));
15178
15179 vosMessage.bodyptr = del_params;
15180 vosMessage.type = eWNI_SME_DEL_BA_SES_REQ;
15181
15182 vos_status = vos_mq_post_message(VOS_MQ_ID_PE, &vosMessage);
15183
15184 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15185 {
15186 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15187 "%s: Post Set TM Level MSG fail", __func__);
15188 vos_mem_free(del_params);
15189 status = eHAL_STATUS_FAILURE;
15190 }
15191 sme_ReleaseGlobalLock( &pMac->sme );
15192 }
15193 return(status);
15194}
15195
Manjeet Singh3ed79242017-01-11 19:04:32 +053015196/**
15197 * sme_get_tsf_req() - send tsf get request to firmware
15198 * @hHal: hal handle.
15199 * @cap_tsf_params: capture tsf request params.
15200 *
15201 * Return: hal status.
15202 */
15203eHalStatus sme_get_tsf_req(tHalHandle hHal, tSirCapTsfParams cap_tsf_params)
15204{
15205 eHalStatus status = eHAL_STATUS_SUCCESS;
15206 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15207 vos_msg_t vosMessage;
15208 tpSirCapTsfParams tsf_params = NULL;
15209 VOS_STATUS vosStatus;
15210 tCsrRoamSession *pSession;
15211
15212 MTRACE(vos_trace(VOS_MODULE_ID_SME,
15213 TRACE_CODE_SME_TX_HDD_GET_TSF_REQ, NO_SESSION, 0));
15214
15215 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
15216 {
15217 pSession = CSR_GET_SESSION(pMac, cap_tsf_params.session_id);
15218
15219 if (!pSession)
15220 {
15221 smsLog(pMac, LOGE, FL("session %d not found"),
15222 cap_tsf_params.bss_idx);
15223 sme_ReleaseGlobalLock(&pMac->sme);
15224 return eHAL_STATUS_FAILURE;
15225 }
15226
15227 tsf_params = (tpSirCapTsfParams)
15228 vos_mem_malloc(sizeof(*tsf_params));
15229 if (NULL == tsf_params)
15230 {
15231 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15232 "%s: Not able to allocate memory for sme_capture_tsf_req",
15233 __func__);
15234 sme_ReleaseGlobalLock(&pMac->sme);
15235 return eHAL_STATUS_FAILURE;
15236 }
15237
15238 vos_mem_copy(&tsf_params->bssid, &pSession->connectedProfile.bssid,
15239 sizeof(tsf_params->bssid));
15240 tsf_params->tsf_rsp_cb_func = cap_tsf_params.tsf_rsp_cb_func;
15241 tsf_params->tsf_rsp_cb_ctx = cap_tsf_params.tsf_rsp_cb_ctx;
15242
15243 /* serialize the req through MC thread */
15244 /* TODO: check if callback is required */
15245 vosMessage.bodyptr = tsf_params;
15246 vosMessage.type = eWNI_SME_GET_TSF_REQ;
15247
15248 vosStatus = vos_mq_post_message(VOS_MQ_ID_PE, &vosMessage);
15249 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
15250 {
15251 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15252 "%s: Post Set TM Level MSG fail", __func__);
15253 vos_mem_free(tsf_params);
15254 status = eHAL_STATUS_FAILURE;
15255 }
15256 sme_ReleaseGlobalLock(&pMac->sme);
15257 }
15258 return(status);
15259}
Abhishek Singh02605092017-10-25 14:06:12 +053015260
15261VOS_STATUS sme_roam_csa_ie_request(tHalHandle hal, tCsrBssid bssid,
Abhishek Singh02b823e2017-10-30 17:53:20 +053015262 uint8_t new_chan, uint32_t phy_mode,
15263 uint8_t sme_session_id)
Abhishek Singh02605092017-10-25 14:06:12 +053015264{
15265 VOS_STATUS status = VOS_STATUS_E_FAILURE;
15266 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15267 uint8_t cb_mode = 0;
Abhishek Singh02b823e2017-10-30 17:53:20 +053015268 tCsrRoamSession *session;
15269
15270 session = CSR_GET_SESSION(mac_ctx, sme_session_id);
15271
15272 if (!session) {
15273 smsLog(mac_ctx, LOGE, FL("session %d not found"), sme_session_id);
15274 return VOS_STATUS_E_FAILURE;
15275 }
Abhishek Singh02605092017-10-25 14:06:12 +053015276
15277 status = sme_AcquireGlobalLock(&mac_ctx->sme);
15278 if (VOS_IS_STATUS_SUCCESS(status)) {
15279 if (CSR_IS_CHANNEL_5GHZ(new_chan)) {
Abhishek Singh02b823e2017-10-30 17:53:20 +053015280 sme_SelectCBMode(hal, phy_mode, new_chan,
Himanshu Agarwal6caf4422018-05-29 17:38:18 +053015281 eHT_MAX_CHANNEL_WIDTH);
Abhishek Singh02605092017-10-25 14:06:12 +053015282 cb_mode = mac_ctx->roam.configParam.channelBondingMode5GHz;
15283 }
15284 status = csr_roam_send_chan_sw_ie_request(mac_ctx, bssid,
15285 new_chan, cb_mode);
15286 sme_ReleaseGlobalLock(&mac_ctx->sme);
15287 }
15288 return status;
15289}
15290
Abhishek Singh550aa8c2017-10-30 17:34:53 +053015291
15292VOS_STATUS sme_roam_channel_change_req(tHalHandle hal, tCsrBssid bssid,
Abhishek Singh02b823e2017-10-30 17:53:20 +053015293 uint8_t new_chan, tCsrRoamProfile *profile,
15294 uint8_t sme_session_id)
Abhishek Singh550aa8c2017-10-30 17:34:53 +053015295{
15296 VOS_STATUS status;
15297 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15298 uint8_t cb_mode = 0;
Abhishek Singh02b823e2017-10-30 17:53:20 +053015299 tCsrRoamSession *session;
15300
15301 session = CSR_GET_SESSION(mac_ctx, sme_session_id);
15302
15303 if (!session) {
15304 smsLog(mac_ctx, LOGE, FL("session %d not found"), sme_session_id);
15305 return VOS_STATUS_E_FAILURE;
15306 }
Abhishek Singh550aa8c2017-10-30 17:34:53 +053015307
15308 status = sme_AcquireGlobalLock(&mac_ctx->sme);
15309 if (VOS_IS_STATUS_SUCCESS(status)) {
15310 if (CSR_IS_CHANNEL_5GHZ(new_chan)) {
Abhishek Singh02b823e2017-10-30 17:53:20 +053015311 sme_SelectCBMode(hal, profile->phyMode, new_chan,
Himanshu Agarwal6caf4422018-05-29 17:38:18 +053015312 eHT_MAX_CHANNEL_WIDTH);
Abhishek Singh550aa8c2017-10-30 17:34:53 +053015313 cb_mode = mac_ctx->roam.configParam.channelBondingMode5GHz;
15314 }
15315 status = csr_roam_channel_change_req(mac_ctx, bssid, new_chan, cb_mode,
15316 profile);
15317 sme_ReleaseGlobalLock(&mac_ctx->sme);
15318 }
15319 return status;
15320}
15321
Abhishek Singh78c691f2017-11-30 13:48:44 +053015322v_TIME_t
15323sme_get_connect_strt_time(tHalHandle hal, uint8_t session_id)
15324{
15325 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15326 tCsrRoamSession *session;
15327
15328 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15329 smsLog(mac_ctx, LOGE, FL("session id %d not valid"), session_id);
15330 return vos_timer_get_system_time();
15331 }
15332 session = CSR_GET_SESSION(mac_ctx, session_id);
15333 return session->connect_req_start_time;
15334}
Yeshwanth Sriram Guntukab973f1c2018-03-29 19:35:49 +053015335
15336void sme_request_imps(tHalHandle hal)
15337{
15338 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15339
15340 csrScanStartIdleScan(mac_ctx);
15341}
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +053015342
15343bool sme_is_sta_key_exchange_in_progress(tHalHandle hal, uint8_t session_id)
15344{
15345 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15346
15347 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15348 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15349 FL("Invalid session %d"), session_id);
15350 return false;
15351 }
15352
15353 return CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id);
15354}
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015355
15356VOS_STATUS sme_process_msg_callback(tHalHandle hal, vos_msg_t *msg)
15357{
15358 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15359 VOS_STATUS status = VOS_STATUS_E_FAILURE;
15360
15361 if (msg == NULL) {
15362 smsLog(mac_ctx, LOGE, FL("Empty message for SME Msg callback"));
15363 return status;
15364 }
15365 status = sme_ProcessMsg(hal, msg);
15366
15367 return status;
15368}
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +053015369
15370uint32_t sme_unpack_rsn_ie(tHalHandle hal, uint8_t *buf,
15371 uint8_t buf_len,
15372 tDot11fIERSN *rsn_ie)
15373{
15374 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15375
15376 return dot11fUnpackIeRSN(mac_ctx, buf, buf_len, rsn_ie);
15377}
Abhinav Kumar8eed0362019-08-05 14:26:07 +053015378
15379/**
15380 * sme_prepare_mgmt_tx() - Prepares mgmt frame
15381 * @hal: The handle returned by mac_open
15382 * @session_id: session id
15383 * @buf: pointer to frame
15384 * @len: frame length
15385 *
15386 * Return: eHalStatus
15387 */
15388static eHalStatus sme_prepare_mgmt_tx(tHalHandle hal, uint8_t session_id,
15389 const uint8_t *buf, uint32_t len)
15390{
15391 eHalStatus status = eHAL_STATUS_SUCCESS;
15392 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
15393 vos_msg_t vos_message;
15394 struct sir_mgmt_msg *msg;
15395 uint16_t msg_len;
15396
15397 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15398 ("prepares auth frame"));
15399
15400 msg_len = sizeof(*msg) + len;
15401 msg = vos_mem_malloc(msg_len);
15402 if (msg == NULL) {
15403 status = eHAL_STATUS_FAILED_ALLOC;
15404 } else {
15405 msg->type = eWNI_SME_SEND_MGMT_FRAME_TX;
15406 msg->msg_len = msg_len;
15407 msg->session_id = session_id;
15408 msg->data = (uint8_t *)msg + sizeof(*msg);
15409 vos_mem_copy(msg->data, buf, len);
15410 vos_message.bodyptr = msg;
15411 vos_message.type = eWNI_SME_SEND_MGMT_FRAME_TX;
15412 vos_status = vos_mq_post_message(VOS_MQ_ID_PE, &vos_message);
15413 if (!VOS_IS_STATUS_SUCCESS(vos_status)) {
15414 vos_mem_free(msg);
15415 status = eHAL_STATUS_FAILURE;
15416 }
15417 }
15418 return status;
15419}
15420
15421eHalStatus sme_send_mgmt_tx(tHalHandle hal, uint8_t session_id,
15422 const uint8_t *buf, uint32_t len)
15423{
15424 eHalStatus status = eHAL_STATUS_SUCCESS;
15425 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15426
15427 MTRACE(vos_trace(VOS_MODULE_ID_SME,
15428 TRACE_CODE_SME_RX_HDD_SEND_MGMT_TX, session_id, 0));
15429
15430 status = sme_AcquireGlobalLock(&mac->sme);
15431 if (HAL_STATUS_SUCCESS(status)) {
15432 status = sme_prepare_mgmt_tx(hal, session_id, buf, len);
15433 sme_ReleaseGlobalLock(&mac->sme);
15434 }
15435
15436 return status;
15437}
Abhinav Kumard9664da2019-08-05 17:11:25 +053015438
15439#ifdef WLAN_FEATURE_SAE
15440eHalStatus sme_handle_sae_msg(tHalHandle hal, uint8_t session_id,
15441 uint8_t sae_status)
15442{
15443 eHalStatus hal_status = eHAL_STATUS_SUCCESS;
15444 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15445 struct sir_sae_msg *sae_msg;
15446 vos_msg_t vos_message;
15447 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
15448
15449 hal_status = sme_AcquireGlobalLock(&mac->sme);
15450 if (HAL_STATUS_SUCCESS(hal_status)) {
15451 sae_msg = vos_mem_malloc(sizeof(*sae_msg));
15452 if (!sae_msg) {
15453 hal_status = eHAL_STATUS_FAILED_ALLOC;
15454 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15455 "SAE: memory allocation failed");
15456 } else {
15457 sae_msg->message_type = eWNI_SME_SEND_SAE_MSG;
15458 sae_msg->length = sizeof(*sae_msg);
15459 sae_msg->session_id = session_id;
15460 sae_msg->sae_status = sae_status;
15461 vos_message.bodyptr = sae_msg;
15462 vos_message.type = eWNI_SME_SEND_SAE_MSG;
15463 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15464 "SAE: sae_status %d session_id %d", sae_msg->sae_status,
15465 sae_msg->session_id);
15466
15467 vos_status = vos_mq_post_message(VOS_MQ_ID_PE, &vos_message);
15468 if (!VOS_IS_STATUS_SUCCESS(vos_status)) {
15469 vos_mem_free(sae_msg);
15470 hal_status = eHAL_STATUS_FAILURE;
15471 }
15472 }
15473 sme_ReleaseGlobalLock(&mac->sme);
15474}
15475
15476return hal_status;
15477}
15478#endif