blob: 1a73933554272bc7a844cca2b4fde095e77b88c0 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Yeshwanth Sriram Guntukaa3961612018-01-04 14:24:50 +05302 * Copyright (c) 2012-2018 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 );
1971
1972 if (eSIR_FAILURE != uMacPostCtrlMsg( hHal, (tSirMbMsg*)&Msg ))
1973 {
1974 status = eHAL_STATUS_SUCCESS;
1975 }
1976 else
1977 {
1978 smsLog( pMac, LOGE,
1979 "uMacPostCtrlMsg failed to send eWNI_SME_SYS_READY_IND");
1980 break;
1981 }
1982
1983 status = pmcQueryPowerState( hHal, &powerState,
1984 &hwWlanSwitchState, &swWlanSwitchState );
1985 if ( ! HAL_STATUS_SUCCESS( status ) )
1986 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001987 smsLog( pMac, LOGE, "pmcQueryPowerState failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001988 status );
1989 break;
1990 }
1991
1992 if ( (ePMC_SWITCH_OFF != hwWlanSwitchState) &&
1993 (ePMC_SWITCH_OFF != swWlanSwitchState) )
1994 {
1995 status = csrReady(pMac);
1996 if ( ! HAL_STATUS_SUCCESS( status ) )
1997 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001998 smsLog( pMac, LOGE, "csrReady failed with status=%d", status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 break;
2000 }
2001 status = pmcReady(hHal);
2002 if ( ! HAL_STATUS_SUCCESS( status ) )
2003 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002004 smsLog( pMac, LOGE, "pmcReady failed with status=%d", status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 break;
2006 }
2007#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2008 if(VOS_STATUS_SUCCESS != btcReady(hHal))
2009 {
2010 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002011 smsLog( pMac, LOGE, "btcReady failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 break;
2013 }
2014#endif
2015
2016#if defined WLAN_FEATURE_VOWIFI
2017 if(VOS_STATUS_SUCCESS != rrmReady(hHal))
2018 {
2019 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002020 smsLog( pMac, LOGE, "rrmReady failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 break;
2022 }
2023#endif
2024 }
2025 pMac->sme.state = SME_STATE_READY;
2026 } while( 0 );
2027
2028 return status;
2029}
2030
Selvaraj, Sridharc045b8b2016-04-06 12:22:35 +05302031/**
2032 * sme_set_allowed_action_frames() - Set allowed action frames to FW
2033 *
2034 * @hal: Handler to HAL
2035 *
2036 * This function conveys the list of action frames that needs to be forwarded
2037 * to driver by FW. Rest of the action frames can be dropped in FW.Bitmask is
2038 * set with ALLOWED_ACTION_FRAMES_BITMAP
2039 *
2040 * Return: None
2041 */
2042static void sme_set_allowed_action_frames(tHalHandle hal)
2043{
2044 eHalStatus status;
2045 tpAniSirGlobal mac = PMAC_STRUCT(hal);
2046 vos_msg_t vos_message;
2047 VOS_STATUS vos_status;
2048 struct sir_allowed_action_frames *sir_allowed_action_frames;
2049
2050 sir_allowed_action_frames =
2051 vos_mem_malloc(sizeof(*sir_allowed_action_frames));
2052 if (!sir_allowed_action_frames) {
2053 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2054 "Not able to allocate memory for WDA_SET_ALLOWED_ACTION_FRAMES_IND");
2055 return;
2056 }
2057
2058 vos_mem_zero(sir_allowed_action_frames, sizeof(*sir_allowed_action_frames));
2059 sir_allowed_action_frames->bitmask = ALLOWED_ACTION_FRAMES_BITMAP;
2060 sir_allowed_action_frames->reserved = 0;
2061
2062 status = sme_AcquireGlobalLock(&mac->sme);
2063 if (status == eHAL_STATUS_SUCCESS) {
2064 /* serialize the req through MC thread */
2065 vos_message.bodyptr = sir_allowed_action_frames;
2066 vos_message.type = WDA_SET_ALLOWED_ACTION_FRAMES_IND;
2067 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2068 TRACE_CODE_SME_TX_WDA_MSG,
2069 NO_SESSION, vos_message.type));
2070 vos_status = vos_mq_post_message(VOS_MQ_ID_WDA, &vos_message);
2071 if (!VOS_IS_STATUS_SUCCESS(vos_status)) {
2072 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2073 "Not able to post WDA_SET_ALLOWED_ACTION_FRAMES_IND message to HAL");
2074 vos_mem_free(sir_allowed_action_frames);
2075 }
2076
2077 sme_ReleaseGlobalLock( &mac->sme );
2078 } else {
2079 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
2080 "sme_AcquireGlobalLock error", __func__);
2081 vos_mem_free(sir_allowed_action_frames);
2082 }
2083 return;
2084}
2085
Jeff Johnson295189b2012-06-20 16:38:30 -07002086/*--------------------------------------------------------------------------
2087
2088 \brief sme_Start() - Put all SME modules at ready state.
2089
2090 The function starts each module in SME, PMC, CCM, CSR, etc. . Upon
2091 successfully return, all modules are ready to run.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002092 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 \param hHal - The handle returned by macOpen.
2094
2095 \return eHAL_STATUS_SUCCESS - SME is ready.
2096
2097 Other status means SME is failed to start
2098 \sa
2099
2100 --------------------------------------------------------------------------*/
2101eHalStatus sme_Start(tHalHandle hHal)
2102{
2103 eHalStatus status = eHAL_STATUS_FAILURE;
2104 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2105
2106 do
2107 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 status = csrStart(pMac);
2109 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002110 smsLog( pMac, LOGE, "csrStart failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 status );
2112 break;
2113 }
2114
2115 status = pmcStart(hHal);
2116 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002117 smsLog( pMac, LOGE, "pmcStart failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 status );
2119 break;
2120 }
2121
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 status = WLANSAP_Start(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
2123 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002124 smsLog( pMac, LOGE, "WLANSAP_Start failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 status );
2126 break;
2127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 pMac->sme.state = SME_STATE_START;
2129 }while (0);
2130
Selvaraj, Sridharc045b8b2016-04-06 12:22:35 +05302131 sme_set_allowed_action_frames(hHal);
2132
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 return status;
2134}
2135
2136
2137#ifdef WLAN_FEATURE_PACKET_FILTERING
2138/******************************************************************************
2139*
2140* Name: sme_PCFilterMatchCountResponseHandler
2141*
2142* Description:
2143* Invoke Packet Coalescing Filter Match Count callback routine
2144*
2145* Parameters:
2146* hHal - HAL handle for device
2147* pMsg - Pointer to tRcvFltPktMatchRsp structure
2148*
2149* Returns: eHalStatus
2150*
2151******************************************************************************/
2152eHalStatus sme_PCFilterMatchCountResponseHandler(tHalHandle hHal, void* pMsg)
2153{
2154 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2155 eHalStatus status = eHAL_STATUS_SUCCESS;
2156 tpSirRcvFltPktMatchRsp pRcvFltPktMatchRsp = (tpSirRcvFltPktMatchRsp)pMsg;
2157
2158 if (NULL == pMsg)
2159 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002160 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 status = eHAL_STATUS_FAILURE;
2162 }
2163 else
2164 {
2165 smsLog(pMac, LOG2, "SME: entering "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002166 "sme_FilterMatchCountResponseHandler");
Jeff Johnson295189b2012-06-20 16:38:30 -07002167
2168 /* Call Packet Coalescing Filter Match Count callback routine. */
2169 if (pMac->pmc.FilterMatchCountCB != NULL)
2170 pMac->pmc.FilterMatchCountCB(pMac->pmc.FilterMatchCountCBContext,
2171 pRcvFltPktMatchRsp);
2172
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002173 smsLog(pMac, LOG1, "%s: status=0x%x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 pRcvFltPktMatchRsp->status);
2175
2176 pMac->pmc.FilterMatchCountCB = NULL;
2177 pMac->pmc.FilterMatchCountCBContext = NULL;
2178 }
2179
2180 return(status);
2181}
2182#endif // WLAN_FEATURE_PACKET_FILTERING
2183
2184
Chet Lanctot186b5732013-03-18 10:26:30 -07002185#ifdef WLAN_FEATURE_11W
2186/*------------------------------------------------------------------
2187 *
2188 * Handle the unprotected management frame indication from LIM and
2189 * forward it to HDD.
2190 *
2191 *------------------------------------------------------------------*/
2192
2193eHalStatus sme_UnprotectedMgmtFrmInd( tHalHandle hHal,
2194 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
2195{
2196 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2197 eHalStatus status = eHAL_STATUS_SUCCESS;
2198 tCsrRoamInfo pRoamInfo = {0};
2199 tANI_U32 SessionId = pSmeMgmtFrm->sessionId;
2200
2201 pRoamInfo.nFrameLength = pSmeMgmtFrm->frameLen;
2202 pRoamInfo.pbFrames = pSmeMgmtFrm->frameBuf;
2203 pRoamInfo.frameType = pSmeMgmtFrm->frameType;
2204
2205 /* forward the mgmt frame to HDD */
2206 csrRoamCallCallback(pMac, SessionId, &pRoamInfo, 0, eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
2207
2208 return status;
2209}
2210#endif
2211
Hardik Kantilal Patel81f76342014-11-14 12:45:26 -08002212#ifdef WLAN_FEATURE_AP_HT40_24G
2213/* ---------------------------------------------------------------------------
2214 \fn sme_HT2040CoexInfoInd
2215 \brief a Send 20/40 Coex info to SAP layer
2216
2217 \param tpSirHT2040CoexInfoInd - 20/40 Coex info param
2218 \return eHalStatus
2219 ---------------------------------------------------------------------------*/
2220
2221eHalStatus sme_HT2040CoexInfoInd( tHalHandle hHal,
2222 tpSirHT2040CoexInfoInd pSmeHT2040CoexInfoInd)
2223{
2224 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2225 eHalStatus status = eHAL_STATUS_SUCCESS;
2226 tANI_U32 SessionId = pSmeHT2040CoexInfoInd->sessionId;
2227 tCsrRoamInfo roamInfo = {0};
2228
2229 roamInfo.pSmeHT2040CoexInfoInd = pSmeHT2040CoexInfoInd;
2230
2231 smsLog(pMac, LOGW, FL("HT40MHzIntolerant: %d HT20MHzBssWidthReq: %d"),
2232 roamInfo.pSmeHT2040CoexInfoInd->HT40MHzIntolerant,
2233 roamInfo.pSmeHT2040CoexInfoInd->HT20MHzBssWidthReq);
2234
2235 smsLog(pMac, LOGW, FL("Total Intolerant Channel: %d"),
2236 roamInfo.pSmeHT2040CoexInfoInd->channel_num);
2237
2238 /* forward the 20/40 BSS Coex information to HDD */
2239 smsLog(pMac, LOGW, FL("Sending eCSR_ROAM_2040_COEX_INFO_IND"
2240 " to WLANSAP_RoamCallback "));
2241
2242 csrRoamCallCallback(pMac, SessionId, &roamInfo,
2243 0, eCSR_ROAM_2040_COEX_INFO_IND, 0);
2244 return status;
2245}
2246#endif
2247
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002248#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002249/*------------------------------------------------------------------
2250 *
2251 * Handle the tsm ie indication from LIM and forward it to HDD.
2252 *
2253 *------------------------------------------------------------------*/
2254
2255eHalStatus sme_TsmIeInd(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
2256{
2257 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2258 eHalStatus status = eHAL_STATUS_SUCCESS;
2259 tCsrRoamInfo pRoamInfo = {0};
2260 tANI_U32 SessionId = pSmeTsmIeInd->sessionId;
2261
2262 pRoamInfo.tsmIe.tsid= pSmeTsmIeInd->tsmIe.tsid;
2263 pRoamInfo.tsmIe.state= pSmeTsmIeInd->tsmIe.state;
2264 pRoamInfo.tsmIe.msmt_interval= pSmeTsmIeInd->tsmIe.msmt_interval;
2265
2266 /* forward the tsm ie information to HDD */
2267 csrRoamCallCallback(pMac, SessionId, &pRoamInfo, 0, eCSR_ROAM_TSM_IE_IND, 0);
2268
2269 return status;
2270}
2271
2272/* ---------------------------------------------------------------------------
2273 \fn sme_SetCCKMIe
2274 \brief function to store the CCKM IE passed from supplicant and use it while packing
2275 reassociation request
2276 \param hHal - HAL handle for device
2277 \param pCckmIe - pointer to CCKM IE data
2278 \param pCckmIeLen - length of the CCKM IE
2279 \- return Success or failure
2280 -------------------------------------------------------------------------*/
2281eHalStatus sme_SetCCKMIe(tHalHandle hHal, tANI_U8 sessionId,
2282 tANI_U8 *pCckmIe, tANI_U8 cckmIeLen)
2283{
2284 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2285 eHalStatus status = eHAL_STATUS_SUCCESS;
2286
2287 status = sme_AcquireGlobalLock( &pMac->sme );
2288 if ( HAL_STATUS_SUCCESS( status ) )
2289 {
2290 csrSetCCKMIe(pMac, sessionId, pCckmIe, cckmIeLen);
2291 sme_ReleaseGlobalLock( &pMac->sme );
2292 }
2293 return status;
2294}
2295
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002296/* ---------------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002297 \fn sme_SetEseBeaconRequest
2298 \brief function to set Ese beacon request parameters
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002299 \param hHal - HAL handle for device
2300 \param sessionId - Session id
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002301 \param pEseBcnReq - pointer to Ese beacon request
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002302 \- return Success or failure
2303 -------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002304eHalStatus sme_SetEseBeaconRequest(tHalHandle hHal, const tANI_U8 sessionId,
2305 const tCsrEseBeaconReq* pEseBcnReq)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002306{
2307 eHalStatus status = eSIR_SUCCESS;
2308 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2309 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002310 tCsrEseBeaconReqParams *pBeaconReq = NULL;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002311 tANI_U8 counter = 0;
2312 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
2313 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
2314
2315 /* Store the info in RRM context */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002316 vos_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq, sizeof(tCsrEseBeaconReq));
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002317
2318 //Prepare the request to send to SME.
2319 pSmeBcnReportReq = vos_mem_malloc(sizeof( tSirBeaconReportReqInd ));
2320 if(NULL == pSmeBcnReportReq)
2321 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002322 smsLog(pMac, LOGP, "Memory Allocation Failure!!! Ese BcnReq Ind to SME");
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002323 return eSIR_FAILURE;
2324 }
2325
2326 smsLog(pMac, LOGE, "Sending Beacon Report Req to SME");
2327 vos_mem_zero( pSmeBcnReportReq, sizeof( tSirBeaconReportReqInd ));
2328
2329 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
2330 pSmeBcnReportReq->length = sizeof( tSirBeaconReportReqInd );
2331 vos_mem_copy( pSmeBcnReportReq->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
2332 pSmeBcnReportReq->channelInfo.channelNum = 255;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002333 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
2334 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002335
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002336 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002337 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002338 pBeaconReq = (tCsrEseBeaconReqParams *)&pEseBcnReq->bcnReq[counter];
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002339 pSmeBcnReportReq->fMeasurementtype[counter] = pBeaconReq->scanMode;
2340 pSmeBcnReportReq->measurementDuration[counter] = SYS_TU_TO_MS(pBeaconReq->measurementDuration);
2341 pSmeBcnReportReq->channelList.channelNumber[counter] = pBeaconReq->channel;
2342 }
2343
2344 sme_RrmProcessBeaconReportReqInd(pMac, pSmeBcnReportReq);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +05302345 vos_mem_free(pSmeBcnReportReq);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002346 return status;
2347}
2348
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002349#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002350
Chet Lanctot186b5732013-03-18 10:26:30 -07002351
Abhishek Singh00b71972016-01-07 10:51:04 +05302352#ifdef WLAN_FEATURE_RMC
2353eHalStatus sme_IbssPeerInfoResponseHandleer( tHalHandle hHal,
2354 tpSirIbssGetPeerInfoRspParams pIbssPeerInfoParams)
2355{
2356 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2357
2358 if (NULL == pMac)
2359 {
2360 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
2361 "%s: pMac is null", __func__);
2362 return eHAL_STATUS_FAILURE;
2363 }
2364 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL)
2365 {
2366 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2367 "%s: HDD callback is null", __func__);
2368 return eHAL_STATUS_FAILURE;
2369 }
2370 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
2371 &pIbssPeerInfoParams->ibssPeerInfoRspParams);
2372 return eHAL_STATUS_SUCCESS;
2373}
2374#endif /* WLAN_FEATURE_RMC */
2375
2376
c_hpothu92367912014-05-01 15:18:17 +05302377/* ---------------------------------------------------------------------------
2378 \fn sme_getBcnMissRate
2379 \brief function sends 'WDA_GET_BCN_MISS_RATE_REQ' to WDA layer,
2380 \param hHal - HAL handle for device.
2381 \param sessionId - session ID.
2382 \- return Success or Failure.
2383 -------------------------------------------------------------------------*/
2384
2385eHalStatus sme_getBcnMissRate(tHalHandle hHal, tANI_U8 sessionId, void *callback, void *data)
2386{
2387 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2388 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2389 vos_msg_t vosMessage;
2390 tSirBcnMissRateReq *pMsg;
2391 tCsrRoamSession *pSession;
2392
2393 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
2394 {
2395 pSession = CSR_GET_SESSION( pMac, sessionId );
2396
2397 if (!pSession)
2398 {
2399 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
2400 sme_ReleaseGlobalLock( &pMac->sme );
2401 return eHAL_STATUS_FAILURE;
2402 }
2403
c_hpothu402de812014-07-10 15:55:45 +05302404 pMsg = (tSirBcnMissRateReq *) vos_mem_malloc(sizeof(tSirBcnMissRateReq));
c_hpothu92367912014-05-01 15:18:17 +05302405 if (NULL == pMsg)
2406 {
2407 smsLog(pMac, LOGE, FL("failed to allocated memory"));
2408 sme_ReleaseGlobalLock( &pMac->sme );
2409 return eHAL_STATUS_FAILURE;
2410 }
2411
2412 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
2413 sizeof(tSirMacAddr));
2414
2415 pMsg->msgLen = sizeof(tSirBcnMissRateReq);
2416 pMsg->callback = callback;
2417 pMsg->data = data;
2418
2419 vosMessage.type = WDA_GET_BCN_MISS_RATE_REQ;
2420 vosMessage.bodyptr = pMsg;
2421 vosMessage.reserved = 0;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302422 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2423 TRACE_CODE_SME_TX_WDA_MSG, sessionId, vosMessage.type));
c_hpothu92367912014-05-01 15:18:17 +05302424 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
2425 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
2426 {
2427 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2428 "%s: Post Set TM Level MSG fail", __func__);
2429 vos_mem_free(pMsg);
2430 sme_ReleaseGlobalLock( &pMac->sme );
2431 return eHAL_STATUS_FAILURE;
2432 }
2433 sme_ReleaseGlobalLock( &pMac->sme);
2434 return eHAL_STATUS_SUCCESS;
2435 }
2436 return eHAL_STATUS_FAILURE;
2437}
2438
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05302439eHalStatus sme_EncryptMsgResponseHandler(tHalHandle hHal,
2440 tpSirEncryptedDataRspParams pEncRspParams)
2441{
2442 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2443
2444 if (NULL == pMac)
2445 {
2446 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
2447 "%s: pMac is null", __func__);
2448 return eHAL_STATUS_FAILURE;
2449 }
2450 if (pMac->sme.pEncMsgInfoParams.pEncMsgCbk == NULL)
2451 {
2452 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2453 "%s: HDD callback is null", __func__);
2454 return eHAL_STATUS_FAILURE;
2455 }
2456 pMac->sme.pEncMsgInfoParams.pEncMsgCbk(pMac->sme.pEncMsgInfoParams.pUserData,
2457 &pEncRspParams->encryptedDataRsp);
2458 return eHAL_STATUS_SUCCESS;
2459}
2460
Girish Gowlia95daca2015-02-04 20:31:31 +05302461eHalStatus sme_UpdateMaxRateInd(tHalHandle hHal,
2462 tSirSmeUpdateMaxRateParams *pSmeUpdateMaxRateParams)
2463{
2464 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2465 eHalStatus status = eHAL_STATUS_SUCCESS;
2466 tANI_U8 sessionId = pSmeUpdateMaxRateParams->smeSessionId;
2467
2468 /* forward the information to HDD */
2469 status = csrRoamCallCallback(pMac, sessionId, NULL, 0,
2470 eCSR_ROAM_UPDATE_MAX_RATE_IND,
2471 pSmeUpdateMaxRateParams->maxRateFlag);
2472 return status;
2473}
2474
Abhishek Singh550aa8c2017-10-30 17:34:53 +05302475/**
2476 * sme_ecsa_msg_processor() - Handle ECSA indication and resp from LIM
2477 * @mac_ctx: A pointer to Global MAC structure
2478 * @msg_type: Indication/resp type
2479 * @msg_buf: Indication/resp buffer
2480 *
2481 * Return VOS_STATUS
2482 */
2483static VOS_STATUS sme_ecsa_msg_processor(tpAniSirGlobal mac_ctx,
2484 uint16_t msg_type, void *msg_buf)
2485{
2486 tCsrRoamInfo roam_info = { 0 };
2487 struct sir_ecsa_ie_complete_ind *ecsa_ie_cmp_ind;
2488 struct sir_channel_chanege_rsp *chan_params;
2489 uint32_t session_id = 0;
2490 eRoamCmdStatus roamStatus;
2491 eCsrRoamResult roamResult;
2492
2493 switch (msg_type) {
2494 case eWNI_SME_ECSA_IE_BEACON_COMP_IND:
2495 ecsa_ie_cmp_ind =
2496 (struct sir_ecsa_ie_complete_ind *) msg_buf;
2497 if (!ecsa_ie_cmp_ind) {
2498 smsLog(mac_ctx, LOGE, FL("pMsg is NULL for eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND"));
2499 return VOS_STATUS_E_FAILURE;
2500 }
2501 session_id = ecsa_ie_cmp_ind->session_id;
2502 roamStatus = eCSR_ROAM_ECSA_BCN_TX_IND;
2503 roamResult = eCSR_ROAM_RESULT_NONE;
2504 smsLog(mac_ctx, LOG1, FL("sapdfs: Received eWNI_SME_ECSA_IE_BEACON_COMP_IND for session id [%d]"),
2505 session_id);
2506 break;
2507 case eWNI_SME_ECSA_CHAN_CHANGE_RSP:
2508 chan_params = (struct sir_channel_chanege_rsp *)msg_buf;
2509 roam_info.ap_chan_change_rsp =
2510 vos_mem_malloc(sizeof(struct sir_channel_chanege_rsp));
2511 if (!roam_info.ap_chan_change_rsp) {
2512 smsLog(mac_ctx, LOGE, FL("failed to allocate ap_chan_change_rsp"));
2513 return VOS_STATUS_E_FAILURE;
2514 }
2515 session_id = chan_params->sme_session_id;
2516 roam_info.ap_chan_change_rsp->sme_session_id = session_id;
2517 roam_info.ap_chan_change_rsp->new_channel = chan_params->new_channel;
2518 if (chan_params->status == VOS_STATUS_SUCCESS) {
2519 roam_info.ap_chan_change_rsp->status = VOS_STATUS_SUCCESS;
2520 roamResult = eCSR_ROAM_RESULT_NONE;
2521 } else {
2522 roam_info.ap_chan_change_rsp->status = VOS_STATUS_E_FAILURE;
2523 roamResult = eCSR_ROAM_RESULT_FAILURE;
2524 }
2525 roamStatus = eCSR_ROAM_ECSA_CHAN_CHANGE_RSP;
2526 break;
2527 default:
2528 smsLog(mac_ctx, LOGE, FL("Invalid ECSA message: 0x%x"), msg_type);
2529 return VOS_STATUS_E_FAILURE;
2530 }
2531
2532 /* Indicate Radar Event to SAP */
2533 csrRoamCallCallback(mac_ctx, session_id, &roam_info, 0,
2534 roamStatus, roamResult);
2535 if (roam_info.ap_chan_change_rsp)
2536 vos_mem_free(roam_info.ap_chan_change_rsp);
2537
2538 return VOS_STATUS_SUCCESS;
2539}
2540
Yeshwanth Sriram Guntuka5dce44c2018-05-22 16:10:01 +05302541static bool sme_get_sessionid_from_scan_cmd(tpAniSirGlobal mac,
2542 tANI_U32 *session_id)
2543{
2544 tListElem *entry = NULL;
2545 tSmeCmd *command = NULL;
2546 bool active_scan = false;
2547
2548 if (!mac->fScanOffload) {
2549 entry = csrLLPeekHead(&mac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
2550 } else {
2551 entry = csrLLPeekHead(&mac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK);
2552 }
2553
2554 if (entry) {
2555 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2556 if (command->command == eSmeCommandScan) {
2557 *session_id = command->sessionId;
2558 active_scan = true;
2559 }
2560 }
2561
2562 return active_scan;
2563}
2564
Jeff Johnson295189b2012-06-20 16:38:30 -07002565/*--------------------------------------------------------------------------
2566
2567 \brief sme_ProcessMsg() - The main message processor for SME.
2568
2569 The function is called by a message dispatcher when to process a message
2570 targeted for SME.
2571
Srinivas Girigowdade697412013-02-14 16:31:48 -08002572 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 \param hHal - The handle returned by macOpen.
2574 \param pMsg - A pointer to a caller allocated object of tSirMsgQ.
2575
2576 \return eHAL_STATUS_SUCCESS - SME successfully process the message.
2577
2578 Other status means SME failed to process the message to HAL.
2579 \sa
2580
2581 --------------------------------------------------------------------------*/
2582eHalStatus sme_ProcessMsg(tHalHandle hHal, vos_msg_t* pMsg)
2583{
2584 eHalStatus status = eHAL_STATUS_FAILURE;
2585 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2586
2587 if (pMsg == NULL) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002588 smsLog( pMac, LOGE, "Empty message for SME, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 return status;
2590 }
2591
2592 status = sme_AcquireGlobalLock( &pMac->sme );
2593 if ( HAL_STATUS_SUCCESS( status ) )
2594 {
2595 if( SME_IS_START(pMac) )
2596 {
2597 switch (pMsg->type) { // TODO: Will be modified to do a range check for msgs instead of having cases for each msgs
2598 case eWNI_PMC_ENTER_BMPS_RSP:
2599 case eWNI_PMC_EXIT_BMPS_RSP:
2600 case eWNI_PMC_EXIT_BMPS_IND:
2601 case eWNI_PMC_ENTER_IMPS_RSP:
2602 case eWNI_PMC_EXIT_IMPS_RSP:
2603 case eWNI_PMC_SMPS_STATE_IND:
2604 case eWNI_PMC_ENTER_UAPSD_RSP:
2605 case eWNI_PMC_EXIT_UAPSD_RSP:
2606 case eWNI_PMC_ENTER_WOWL_RSP:
2607 case eWNI_PMC_EXIT_WOWL_RSP:
2608 //PMC
2609 if (pMsg->bodyptr)
2610 {
2611 pmcMessageProcessor(hHal, pMsg->bodyptr);
2612 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +05302613 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002615 smsLog( pMac, LOGE, "Empty rsp message for PMC, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 }
2617 break;
2618
2619 case WNI_CFG_SET_CNF:
2620 case WNI_CFG_DNLD_CNF:
2621 case WNI_CFG_GET_RSP:
2622 case WNI_CFG_ADD_GRP_ADDR_CNF:
2623 case WNI_CFG_DEL_GRP_ADDR_CNF:
2624 //CCM
2625 if (pMsg->bodyptr)
2626 {
2627 ccmCfgCnfMsgHandler(hHal, pMsg->bodyptr);
2628 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +05302629 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002631 smsLog( pMac, LOGE, "Empty rsp message for CCM, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 }
2633 break;
2634
2635 case eWNI_SME_ADDTS_RSP:
2636 case eWNI_SME_DELTS_RSP:
2637 case eWNI_SME_DELTS_IND:
2638#ifdef WLAN_FEATURE_VOWIFI_11R
2639 case eWNI_SME_FT_AGGR_QOS_RSP:
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07002640#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 //QoS
2642 if (pMsg->bodyptr)
2643 {
2644#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2645 status = sme_QosMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05302646 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002647#endif
2648 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002649 smsLog( pMac, LOGE, "Empty rsp message for QoS, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 }
2651 break;
2652#if defined WLAN_FEATURE_VOWIFI
2653 case eWNI_SME_NEIGHBOR_REPORT_IND:
2654 case eWNI_SME_BEACON_REPORT_REQ_IND:
2655#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002656 smsLog( pMac, LOGE, "Received RRM message. Message Id = %d", pMsg->type );
Jeff Johnson295189b2012-06-20 16:38:30 -07002657#endif
2658 if ( pMsg->bodyptr )
2659 {
2660 status = sme_RrmMsgProcessor( pMac, pMsg->type, pMsg->bodyptr );
Kiet Lam64c1b492013-07-12 13:56:44 +05302661 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 }
2663 else
2664 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002665 smsLog( pMac, LOGE, "Empty message for RRM, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 }
2667 break;
2668#endif
2669
Jeff Johnsone7245742012-09-05 17:12:55 -07002670#ifdef FEATURE_OEM_DATA_SUPPORT
2671 //Handle the eWNI_SME_OEM_DATA_RSP:
2672 case eWNI_SME_OEM_DATA_RSP:
2673 if(pMsg->bodyptr)
2674 {
2675 status = sme_HandleOemDataRsp(pMac, pMsg->bodyptr);
2676 vos_mem_free(pMsg->bodyptr);
2677 }
2678 else
2679 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002680 smsLog( pMac, LOGE, "Empty rsp message for oemData_ (eWNI_SME_OEM_DATA_RSP), nothing to process");
Jeff Johnsone7245742012-09-05 17:12:55 -07002681 }
2682 smeProcessPendingQueue( pMac );
2683 break;
2684#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002685
2686 case eWNI_SME_ADD_STA_SELF_RSP:
2687 if(pMsg->bodyptr)
2688 {
2689 status = csrProcessAddStaSessionRsp(pMac, pMsg->bodyptr);
2690 vos_mem_free(pMsg->bodyptr);
2691 }
2692 else
2693 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002694 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ADD_STA_SELF_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 }
2696 break;
2697 case eWNI_SME_DEL_STA_SELF_RSP:
2698 if(pMsg->bodyptr)
2699 {
2700 status = csrProcessDelStaSessionRsp(pMac, pMsg->bodyptr);
2701 vos_mem_free(pMsg->bodyptr);
2702 }
2703 else
2704 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002705 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_DEL_STA_SELF_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 }
2707 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 case eWNI_SME_REMAIN_ON_CHN_RSP:
2709 if(pMsg->bodyptr)
2710 {
2711 status = sme_remainOnChnRsp(pMac, pMsg->bodyptr);
2712 vos_mem_free(pMsg->bodyptr);
2713 }
2714 else
2715 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002716 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 }
2718 break;
2719 case eWNI_SME_REMAIN_ON_CHN_RDY_IND:
2720 if(pMsg->bodyptr)
2721 {
2722 status = sme_remainOnChnReady(pMac, pMsg->bodyptr);
2723 vos_mem_free(pMsg->bodyptr);
2724 }
2725 else
2726 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002727 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 -07002728 }
2729 break;
Hardik Kantilal Patel81f76342014-11-14 12:45:26 -08002730#ifdef WLAN_FEATURE_AP_HT40_24G
2731 case eWNI_SME_2040_COEX_IND:
2732 if(pMsg->bodyptr)
2733 {
2734 sme_HT2040CoexInfoInd(pMac, pMsg->bodyptr);
2735 vos_mem_free(pMsg->bodyptr);
2736 }
2737 else
2738 {
2739 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_2040_COEX_IND), nothing to process");
2740 }
2741 break;
2742#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 case eWNI_SME_ACTION_FRAME_SEND_CNF:
2744 if(pMsg->bodyptr)
2745 {
2746 status = sme_sendActionCnf(pMac, pMsg->bodyptr);
2747 vos_mem_free(pMsg->bodyptr);
2748 }
2749 else
2750 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002751 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ACTION_FRAME_SEND_CNF), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002752 }
2753 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 case eWNI_SME_COEX_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302755 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2756 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 if(pMsg->bodyptr)
2758 {
c_hpothu3ba2a512014-08-06 14:02:54 +05302759 tSirSmeCoexInd *pSmeCoexInd = (tSirSmeCoexInd *)pMsg->bodyptr;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302760 vos_msg_t vosMessage = {0};
Yeshwanth Sriram Guntuka5dce44c2018-05-22 16:10:01 +05302761 tANI_U32 session_id = 0;
2762 bool active_scan;
c_hpothu3ba2a512014-08-06 14:02:54 +05302763
2764 if (pSmeCoexInd->coexIndType == SIR_COEX_IND_TYPE_DISABLE_AGGREGATION_IN_2p4)
2765 {
Yeshwanth Sriram Guntukaac589f42018-04-24 17:29:18 +05302766 pMac->btc.agg_disabled = true;
c_hpothu3ba2a512014-08-06 14:02:54 +05302767 smsLog( pMac, LOG1, FL("SIR_COEX_IND_TYPE_DISABLE_AGGREGATION_IN_2p4"));
Yeshwanth Sriram Guntuka5dce44c2018-05-22 16:10:01 +05302768 active_scan = sme_get_sessionid_from_scan_cmd(pMac,
2769 &session_id);
2770 if (active_scan)
2771 sme_AbortMacScan(hHal, session_id,
2772 eCSR_SCAN_ABORT_DEFAULT);
c_hpothu3ba2a512014-08-06 14:02:54 +05302773 sme_RequestFullPower(hHal, NULL, NULL, eSME_REASON_OTHER);
2774 pMac->isCoexScoIndSet = 1;
Ganesh Kondabattini48e9f742017-06-02 22:16:29 +05302775 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
2776 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_TRUE;
Yeshwanth Sriram Guntukaa3961612018-01-04 14:24:50 +05302777
2778 vosMessage.type = eWNI_SME_STA_DEL_BA_REQ;
2779 vos_mq_post_message(VOS_MQ_ID_PE, &vosMessage);
c_hpothu3ba2a512014-08-06 14:02:54 +05302780 }
2781 else if (pSmeCoexInd->coexIndType == SIR_COEX_IND_TYPE_ENABLE_AGGREGATION_IN_2p4)
2782 {
Yeshwanth Sriram Guntukaac589f42018-04-24 17:29:18 +05302783 pMac->btc.agg_disabled = false;
c_hpothu3ba2a512014-08-06 14:02:54 +05302784 smsLog( pMac, LOG1, FL("SIR_COEX_IND_TYPE_ENABLE_AGGREGATION_IN_2p4"));
2785 pMac->isCoexScoIndSet = 0;
2786 sme_RequestBmps(hHal, NULL, NULL);
Ganesh Kondabattini48e9f742017-06-02 22:16:29 +05302787 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
2788 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302789
2790 /*
2791 * If aggregation during SCO is enabled, there is a
2792 * possibility for an active BA session. This session
2793 * should be deleted on receiving enable aggregation
2794 * indication and block ack buffer size should be reset
2795 * to default.
2796 */
2797 if (pMac->roam.configParam.agg_btc_sco_enabled) {
2798 vosMessage.type = eWNI_SME_STA_DEL_BA_REQ;
2799 vos_mq_post_message(VOS_MQ_ID_PE, &vosMessage);
2800 }
c_hpothu3ba2a512014-08-06 14:02:54 +05302801 }
2802
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 status = btcHandleCoexInd((void *)pMac, pMsg->bodyptr);
2804 vos_mem_free(pMsg->bodyptr);
2805 }
2806 else
2807 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002808 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07002810 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002811
2812#ifdef FEATURE_WLAN_SCAN_PNO
2813 case eWNI_SME_PREF_NETWORK_FOUND_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302814 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2815 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 if(pMsg->bodyptr)
2817 {
2818 status = sme_PreferredNetworkFoundInd((void *)pMac, pMsg->bodyptr);
2819 vos_mem_free(pMsg->bodyptr);
2820 }
2821 else
2822 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002823 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_PREF_NETWORK_FOUND_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 }
2825 break;
2826#endif // FEATURE_WLAN_SCAN_PNO
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07002827
Jeff Johnson295189b2012-06-20 16:38:30 -07002828 case eWNI_SME_TX_PER_HIT_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302829 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2830 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 if (pMac->sme.pTxPerHitCallback)
2832 {
2833 pMac->sme.pTxPerHitCallback(pMac->sme.pTxPerHitCbContext);
2834 }
2835 break;
2836
2837 case eWNI_SME_CHANGE_COUNTRY_CODE:
Amar Singhal0d15bd52013-10-12 23:13:13 -07002838 if(pMsg->bodyptr)
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 {
2840 status = sme_HandleChangeCountryCode((void *)pMac, pMsg->bodyptr);
2841 vos_mem_free(pMsg->bodyptr);
2842 }
2843 else
2844 {
Amar Singhal0d15bd52013-10-12 23:13:13 -07002845 smsLog(pMac, LOGE, "Empty rsp message for message (eWNI_SME_CHANGE_COUNTRY_CODE), nothing to process");
2846 }
2847 break;
2848
2849 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2850 if (pMsg->bodyptr)
2851 {
2852 status = sme_HandleGenericChangeCountryCode((void *)pMac, pMsg->bodyptr);
2853 vos_mem_free(pMsg->bodyptr);
2854 }
2855 else
2856 {
2857 smsLog(pMac, LOGE, "Empty rsp message for message (eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 }
2859 break;
2860
2861#ifdef WLAN_FEATURE_PACKET_FILTERING
2862 case eWNI_PMC_PACKET_COALESCING_FILTER_MATCH_COUNT_RSP:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302863 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2864 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 if(pMsg->bodyptr)
2866 {
2867 status = sme_PCFilterMatchCountResponseHandler((void *)pMac, pMsg->bodyptr);
2868 vos_mem_free(pMsg->bodyptr);
2869 }
2870 else
2871 {
2872 smsLog(pMac, LOGE, "Empty rsp message for meas "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002873 "(PACKET_COALESCING_FILTER_MATCH_COUNT_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 }
2875 break;
2876#endif // WLAN_FEATURE_PACKET_FILTERING
2877 case eWNI_SME_PRE_SWITCH_CHL_IND:
2878 {
2879 status = sme_HandlePreChannelSwitchInd(pMac);
2880 break;
2881 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07002882
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 case eWNI_SME_POST_SWITCH_CHL_IND:
2884 {
2885 status = sme_HandlePostChannelSwitchInd(pMac);
2886 break;
2887 }
2888
2889#ifdef WLAN_WAKEUP_EVENTS
2890 case eWNI_SME_WAKE_REASON_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302891 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2892 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 if(pMsg->bodyptr)
2894 {
2895 status = sme_WakeReasonIndCallback((void *)pMac, pMsg->bodyptr);
2896 vos_mem_free(pMsg->bodyptr);
2897 }
2898 else
2899 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002900 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_WAKE_REASON_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 }
2902 break;
2903#endif // WLAN_WAKEUP_EVENTS
2904
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002905#ifdef FEATURE_WLAN_TDLS
2906 /*
2907 * command rescived from PE, SME tdls msg processor shall be called
2908 * to process commands recieved from PE
2909 */
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07002910 case eWNI_SME_TDLS_SEND_MGMT_RSP:
2911 case eWNI_SME_TDLS_ADD_STA_RSP:
Hoonki Leee6bfe942013-02-05 15:01:19 -08002912 case eWNI_SME_TDLS_DEL_STA_RSP:
2913 case eWNI_SME_TDLS_DEL_STA_IND:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002914 case eWNI_SME_TDLS_DEL_ALL_PEER_IND:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002915 case eWNI_SME_MGMT_FRM_TX_COMPLETION_IND:
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302916 case eWNI_SME_TDLS_LINK_ESTABLISH_RSP:
Atul Mittal60bd4292014-08-14 12:19:27 +05302917 case eWNI_SME_TDLS_CHANNEL_SWITCH_RSP:
Deepthi Gowri25e25552015-05-14 12:12:50 +05302918 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002919 if (pMsg->bodyptr)
2920 {
2921 status = tdlsMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05302922 vos_mem_free(pMsg->bodyptr);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002923 }
2924 else
2925 {
2926 smsLog( pMac, LOGE, "Empty rsp message for TDLS, \
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002927 nothing to process");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002928 }
2929 break;
2930 }
2931#endif
2932
Chet Lanctot186b5732013-03-18 10:26:30 -07002933#ifdef WLAN_FEATURE_11W
2934 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2935 if (pMsg->bodyptr)
2936 {
2937 sme_UnprotectedMgmtFrmInd(pMac, pMsg->bodyptr);
2938 vos_mem_free(pMsg->bodyptr);
2939 }
2940 else
2941 {
2942 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_UNPROT_MGMT_FRM_IND), nothing to process");
2943 }
2944 break;
2945#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002946#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002947 case eWNI_SME_TSM_IE_IND:
2948 {
2949 if (pMsg->bodyptr)
2950 {
2951 sme_TsmIeInd(pMac, pMsg->bodyptr);
2952 vos_mem_free(pMsg->bodyptr);
2953 }
2954 else
2955 {
2956 smsLog(pMac, LOGE, "Empty rsp message for (eWNI_SME_TSM_IE_IND), nothing to process");
2957 }
2958 break;
2959 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002960#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07002961#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2962 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2963 status = csrRoamOffloadScanRspHdlr((void *)pMac, pMsg->bodyval);
2964 break;
2965#endif // WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Chet Lanctot186b5732013-03-18 10:26:30 -07002966
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05302967#ifdef WLAN_FEATURE_GTK_OFFLOAD
2968 case eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302969 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2970 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05302971 if (pMsg->bodyptr)
2972 {
2973 sme_ProcessGetGtkInfoRsp(pMac, pMsg->bodyptr);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05302974 vos_mem_zero(pMsg->bodyptr,
2975 sizeof(tSirGtkOffloadGetInfoRspParams));
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05302976 vos_mem_free(pMsg->bodyptr);
2977 }
2978 else
2979 {
2980 smsLog(pMac, LOGE, "Empty rsp message for (eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP), nothing to process");
2981 }
2982 break ;
2983#endif
Leo Chang9056f462013-08-01 19:21:11 -07002984
2985#ifdef FEATURE_WLAN_LPHB
2986 /* LPHB timeout indication arrived, send IND to client */
Leo Changd9df8aa2013-09-26 13:32:26 -07002987 case eWNI_SME_LPHB_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302988 MTRACE(vos_trace(VOS_MODULE_ID_SME,
2989 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Leo Changd9df8aa2013-09-26 13:32:26 -07002990 if (pMac->sme.pLphbIndCb)
Leo Chang9056f462013-08-01 19:21:11 -07002991 {
Leo Changd9df8aa2013-09-26 13:32:26 -07002992 pMac->sme.pLphbIndCb(pMac->pAdapter, pMsg->bodyptr);
Leo Chang9056f462013-08-01 19:21:11 -07002993 }
2994 vos_mem_free(pMsg->bodyptr);
2995
2996 break;
2997#endif /* FEATURE_WLAN_LPHB */
2998
Abhishek Singh00b71972016-01-07 10:51:04 +05302999#ifdef WLAN_FEATURE_RMC
3000 case eWNI_SME_IBSS_PEER_INFO_RSP:
3001 MTRACE(vos_trace(VOS_MODULE_ID_SME,
3002 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
3003 if (pMsg->bodyptr)
3004 {
3005 sme_IbssPeerInfoResponseHandleer(pMac, pMsg->bodyptr);
3006 vos_mem_free(pMsg->bodyptr);
3007 }
3008 else
3009 {
3010 smsLog(pMac, LOGE,
3011 "Empty rsp message for (eWNI_SME_IBSS_PEER_INFO_RSP),"
3012 " nothing to process");
3013 }
3014 break ;
3015
3016#endif /* WLAN_FEATURE_RMC */
3017
Leo Chang0b0e45a2013-12-15 15:18:55 -08003018#ifdef FEATURE_WLAN_CH_AVOID
3019 /* LPHB timeout indication arrived, send IND to client */
3020 case eWNI_SME_CH_AVOID_IND:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05303021 MTRACE(vos_trace(VOS_MODULE_ID_SME,
3022 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Leo Chang0b0e45a2013-12-15 15:18:55 -08003023 if (pMac->sme.pChAvoidNotificationCb)
3024 {
3025 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3026 "%s: CH avoid notification", __func__);
3027 pMac->sme.pChAvoidNotificationCb(pMac->pAdapter, pMsg->bodyptr);
3028 }
3029 vos_mem_free(pMsg->bodyptr);
3030
3031 break;
3032#endif /* FEATURE_WLAN_CH_AVOID */
3033
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303034 case eWNI_SME_ENCRYPT_MSG_RSP:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05303035 MTRACE(vos_trace(VOS_MODULE_ID_SME,
3036 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303037 if (pMsg->bodyptr)
3038 {
3039 sme_EncryptMsgResponseHandler(pMac, pMsg->bodyptr);
3040 vos_mem_free(pMsg->bodyptr);
3041 }
3042 else
3043 {
3044 smsLog(pMac, LOGE,
3045 "Empty rsp message for (eWNI_SME_ENCRYPT_MSG_RSP),"
3046 " nothing to process");
3047 }
3048 break ;
3049
Girish Gowlia95daca2015-02-04 20:31:31 +05303050 case eWNI_SME_UPDATE_MAX_RATE_IND:
3051 if (pMsg->bodyptr)
3052 {
3053 sme_UpdateMaxRateInd(pMac, pMsg->bodyptr);
3054 vos_mem_free(pMsg->bodyptr);
3055 }
3056 else
3057 {
3058 smsLog(pMac, LOGE,
3059 "Empty message for (eWNI_SME_UPDATE_MAX_RATE_IND),"
3060 " nothing to process");
3061 }
3062 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303063
Srinivas Dasari030bad32015-02-18 23:23:54 +05303064 case eWNI_SME_NAN_EVENT:
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05303065 MTRACE(vos_trace(VOS_MODULE_ID_SME,
3066 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
Srinivas Dasari030bad32015-02-18 23:23:54 +05303067 if (pMsg->bodyptr)
3068 {
3069 sme_NanEvent(hHal, pMsg->bodyptr);
3070 vos_mem_free(pMsg->bodyptr);
3071 }
3072 else
3073 {
3074 smsLog(pMac, LOGE,
3075 "Empty message for (eWNI_SME_NAN_EVENT),"
3076 " nothing to process");
3077 }
3078 break;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05303079 case eWNI_SME_ECSA_IE_BEACON_COMP_IND:
3080 case eWNI_SME_ECSA_CHAN_CHANGE_RSP:
3081 MTRACE(vos_trace(VOS_MODULE_ID_SME,
3082 TRACE_CODE_SME_RX_WDA_MSG, NO_SESSION, pMsg->type));
3083 if (pMsg->bodyptr)
3084 {
3085 sme_ecsa_msg_processor(pMac, pMsg->type, pMsg->bodyptr);
3086 vos_mem_free(pMsg->bodyptr);
3087 }
3088 else
3089 {
3090 smsLog(pMac, LOGE,
3091 FL("Empty message for (eWNI_SME_ECSA_IE_BEACON_COMP_IND)"));
3092 }
3093 break;
Srinivas Dasari030bad32015-02-18 23:23:54 +05303094
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 default:
3096
3097 if ( ( pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN )
3098 && ( pMsg->type <= eWNI_SME_MSG_TYPES_END ) )
3099 {
3100 //CSR
3101 if (pMsg->bodyptr)
3102 {
3103 status = csrMsgProcessor(hHal, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05303104 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 }
3106 else
3107 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003108 smsLog( pMac, LOGE, "Empty rsp message for CSR, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 }
3110 }
3111 else
3112 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003113 smsLog( pMac, LOGW, "Unknown message type %d, nothing to process",
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 pMsg->type);
3115 if (pMsg->bodyptr)
3116 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303117 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 }
3119 }
3120 }//switch
3121 } //SME_IS_START
3122 else
3123 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003124 smsLog( pMac, LOGW, "message type %d in stop state ignored", pMsg->type);
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 if (pMsg->bodyptr)
3126 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303127 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 }
3129 }
3130 sme_ReleaseGlobalLock( &pMac->sme );
3131 }
3132 else
3133 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003134 smsLog( pMac, LOGW, "Locking failed, bailing out");
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 if (pMsg->bodyptr)
3136 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303137 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 }
3139 }
3140
3141 return status;
3142}
3143
3144
3145//No need to hold the global lock here because this function can only be called
3146//after sme_Stop.
3147v_VOID_t sme_FreeMsg( tHalHandle hHal, vos_msg_t* pMsg )
3148{
3149 if( pMsg )
3150 {
3151 if (pMsg->bodyptr)
3152 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303153 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 }
3155 }
3156
3157}
3158
3159
3160/*--------------------------------------------------------------------------
3161
3162 \brief sme_Stop() - Stop all SME modules and put them at idle state
3163
3164 The function stops each module in SME, PMC, CCM, CSR, etc. . Upon
3165 return, all modules are at idle state ready to start.
3166
Srinivas Girigowdade697412013-02-14 16:31:48 -08003167 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 \param hHal - The handle returned by macOpen
Kiet Lama72a2322013-11-15 11:18:11 +05303169 \param tHalStopType - reason for stopping
Jeff Johnson295189b2012-06-20 16:38:30 -07003170
3171 \return eHAL_STATUS_SUCCESS - SME is stopped.
3172
3173 Other status means SME is failed to stop but caller should still
3174 consider SME is stopped.
3175 \sa
3176
3177 --------------------------------------------------------------------------*/
Kiet Lama72a2322013-11-15 11:18:11 +05303178eHalStatus sme_Stop(tHalHandle hHal, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -07003179{
3180 eHalStatus status = eHAL_STATUS_FAILURE;
3181 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
3182 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3183
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 status = WLANSAP_Stop(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
3185 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003186 smsLog( pMac, LOGE, "WLANSAP_Stop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 status );
3188 fail_status = status;
3189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003190
3191 p2pStop(hHal);
3192
Kiet Lama72a2322013-11-15 11:18:11 +05303193 status = pmcStop(hHal);
3194 if ( ! HAL_STATUS_SUCCESS( status ) ) {
3195 smsLog( pMac, LOGE, "pmcStop failed during smeStop with status=%d",
3196 status );
3197 fail_status = status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 }
3199
Kiet Lama72a2322013-11-15 11:18:11 +05303200 status = csrStop(pMac, stopType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003202 smsLog( pMac, LOGE, "csrStop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 status );
3204 fail_status = status;
3205 }
3206
3207 ccmStop(hHal);
3208
3209 purgeSmeCmdList(pMac);
3210
3211 if (!HAL_STATUS_SUCCESS( fail_status )) {
3212 status = fail_status;
3213 }
3214
3215 pMac->sme.state = SME_STATE_STOP;
3216
3217 return status;
3218}
3219
3220/*--------------------------------------------------------------------------
3221
3222 \brief sme_Close() - Release all SME modules and their resources.
3223
3224 The function release each module in SME, PMC, CCM, CSR, etc. . Upon
3225 return, all modules are at closed state.
3226
3227 No SME APIs can be involved after smeClose except smeOpen.
3228 smeClose must be called before macClose.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003229 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 \param hHal - The handle returned by macOpen
3231
3232 \return eHAL_STATUS_SUCCESS - SME is successfully close.
3233
3234 Other status means SME is failed to be closed but caller still cannot
3235 call any other SME functions except smeOpen.
3236 \sa
3237
3238 --------------------------------------------------------------------------*/
3239eHalStatus sme_Close(tHalHandle hHal)
3240{
3241 eHalStatus status = eHAL_STATUS_FAILURE;
3242 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
3243 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3244
3245 status = csrClose(pMac);
3246 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003247 smsLog( pMac, LOGE, "csrClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 status );
3249 fail_status = status;
3250 }
3251
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 status = WLANSAP_Close(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
3253 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003254 smsLog( pMac, LOGE, "WLANSAP_close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 status );
3256 fail_status = status;
3257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003258
3259#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3260 status = btcClose(hHal);
3261 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003262 smsLog( pMac, LOGE, "BTC close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003263 status );
3264 fail_status = status;
3265 }
3266
3267 status = sme_QosClose(pMac);
3268 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003269 smsLog( pMac, LOGE, "Qos close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 status );
3271 fail_status = status;
3272 }
3273#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003274#ifdef FEATURE_OEM_DATA_SUPPORT
3275 status = oemData_OemDataReqClose(hHal);
3276 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003277 smsLog( pMac, LOGE, "OEM DATA REQ close failed during sme close with status=%d",
Jeff Johnsone7245742012-09-05 17:12:55 -07003278 status );
3279 fail_status = status;
3280 }
3281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003282
3283 status = ccmClose(hHal);
3284 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003285 smsLog( pMac, LOGE, "ccmClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 status );
3287 fail_status = status;
3288 }
3289
3290 status = pmcClose(hHal);
3291 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003292 smsLog( pMac, LOGE, "pmcClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 status );
3294 fail_status = status;
3295 }
3296#if defined WLAN_FEATURE_VOWIFI
3297 status = rrmClose(hHal);
3298 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003299 smsLog( pMac, LOGE, "RRM close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 status );
3301 fail_status = status;
3302 }
3303#endif
3304
3305#if defined WLAN_FEATURE_VOWIFI_11R
3306 sme_FTClose(hHal);
3307#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 sme_p2pClose(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07003309
3310 freeSmeCmdList(pMac);
3311
3312 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->sme.lkSmeGlobalLock ) ) )
3313 {
3314 fail_status = eHAL_STATUS_FAILURE;
3315 }
3316
3317 if (!HAL_STATUS_SUCCESS( fail_status )) {
3318 status = fail_status;
3319 }
3320
3321 pMac->sme.state = SME_STATE_STOP;
3322
3323 return status;
3324}
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05303325
3326v_VOID_t sme_PreClose(tHalHandle hHal)
3327{
3328 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3329
mukul sharma867a9df2015-07-08 13:28:24 +05303330 if(!pMac)
3331 return;
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05303332
mukul sharma867a9df2015-07-08 13:28:24 +05303333 smsLog(pMac, LOGW, FL("Stopping Active CMD List Timer"));
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05303334 vos_timer_stop( pMac->sme.smeCmdActiveList.cmdTimeoutTimer );
3335
3336}
3337
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003338#ifdef FEATURE_WLAN_LFR
3339tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac)
3340{
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07003341#if 0
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003342 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
3343 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
3344 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
3345 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
3346 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3347 return eANI_BOOLEAN_FALSE;
3348 default:
3349 return eANI_BOOLEAN_TRUE;
3350 }
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07003351#else
3352 /*
3353 * TODO: always return TRUE for now until
3354 * we figure out why we could be stuck in
3355 * one of the roaming states forever.
3356 */
3357 return eANI_BOOLEAN_TRUE;
3358#endif
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003359}
3360#endif
c_hpothu58901462014-11-01 16:44:34 +05303361
3362/* ---------------------------------------------------------------------------
3363 \fn sco_isScanAllowed
3364 \brief check for scan interface connection status
3365 \param pMac - Pointer to the global MAC parameter structure
3366 \param pScanReq - scan request structure.
3367
3368 \return tANI_BOOLEAN TRUE to allow scan otherwise FALSE
3369 ---------------------------------------------------------------------------*/
3370tANI_BOOLEAN sco_isScanAllowed(tpAniSirGlobal pMac, tCsrScanRequest *pscanReq)
3371{
3372 tANI_BOOLEAN ret;
3373
3374 if (pscanReq->p2pSearch)
3375 ret = csrIsP2pSessionConnected(pMac);
3376 else
3377 ret = csrIsStaSessionConnected(pMac);
3378
3379 return !ret;
3380}
3381
Jeff Johnson295189b2012-06-20 16:38:30 -07003382/* ---------------------------------------------------------------------------
3383 \fn sme_ScanRequest
3384 \brief a wrapper function to Request a 11d or full scan from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003385 This is an asynchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 \param pScanRequestID - pointer to an object to get back the request ID
3387 \param callback - a callback function that scan calls upon finish, will not
3388 be called if csrScanRequest returns error
3389 \param pContext - a pointer passed in for the callback
3390 \return eHalStatus
3391 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003392eHalStatus sme_ScanRequest(tHalHandle hHal, tANI_U8 sessionId, tCsrScanRequest *pscanReq,
3393 tANI_U32 *pScanRequestID,
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 csrScanCompleteCallback callback, void *pContext)
3395{
3396 eHalStatus status = eHAL_STATUS_FAILURE;
3397 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05303398 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003399 TRACE_CODE_SME_RX_HDD_MSG_SCAN_REQ, sessionId, pscanReq->scanType));
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05303400
3401 smsLog(pMac, LOG1,
3402 FL("isCoexScoIndSet %d disable_scan_during_sco %d is_disconnected %d"),
3403 pMac->isCoexScoIndSet,
3404 pMac->scan.disable_scan_during_sco,
3405 csrIsConnStateDisconnected(pMac, sessionId));
3406
3407 if (pMac->isCoexScoIndSet && pMac->scan.disable_scan_during_sco &&
3408 csrIsConnStateDisconnected(pMac, sessionId)) {
Padma, Santhosh Kumar4ffece42016-11-15 15:08:53 +05303409 csrScanFlushResult(pMac);
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05303410 pMac->scan.disable_scan_during_sco_timer_info.callback = callback;
3411 pMac->scan.disable_scan_during_sco_timer_info.dev = pContext;
3412 pMac->scan.disable_scan_during_sco_timer_info.scan_id= *pScanRequestID;
3413
3414 vos_timer_start(&pMac->scan.disable_scan_during_sco_timer,
3415 CSR_DISABLE_SCAN_DURING_SCO);
3416 return eHAL_STATUS_SUCCESS;
3417 }
3418
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 do
3420 {
c_hpothu304c0522014-09-30 10:22:57 +05303421 if(pMac->scan.fScanEnable &&
c_hpothu58901462014-11-01 16:44:34 +05303422 (pMac->isCoexScoIndSet ? sco_isScanAllowed(pMac, pscanReq) : TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 {
3424 status = sme_AcquireGlobalLock( &pMac->sme );
3425 if ( HAL_STATUS_SUCCESS( status ) )
3426 {
3427 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003428#ifdef FEATURE_WLAN_LFR
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003429 if(csrIsScanAllowed(pMac))
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003430 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003431#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003432 status = csrScanRequest( hHal, sessionId, pscanReq,
3433 pScanRequestID, callback, pContext );
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05303434 if ( !HAL_STATUS_SUCCESS( status ) )
3435 {
3436 smsLog(pMac, LOGE, FL("csrScanRequest failed"
3437 " SId=%d"), sessionId);
3438 }
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003439#ifdef FEATURE_WLAN_LFR
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003440 }
3441 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003442 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05303443 smsLog(pMac, LOGE, FL("Scan denied in state %s"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05303444 "(sub-state %s)"),
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05303445 macTraceGetNeighbourRoamState(
3446 pMac->roam.neighborRoamInfo.neighborRoamState),
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05303447 macTraceGetcsrRoamSubState(
3448 pMac->roam.curSubState[sessionId]));
Madan Mohan Koyyalamudiab4ab0d2012-10-24 14:26:50 -07003449 /*HandOff is in progress. So schedule this scan later*/
3450 status = eHAL_STATUS_RESOURCES;
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07003451 }
3452#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003454
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 sme_ReleaseGlobalLock( &pMac->sme );
3456 } //sme_AcquireGlobalLock success
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003457 else
3458 {
3459 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
3460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 } //if(pMac->scan.fScanEnable)
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003462 else
3463 {
c_hpothu3ba2a512014-08-06 14:02:54 +05303464 smsLog(pMac, LOGE, FL("fScanEnable %d isCoexScoIndSet: %d "),
3465 pMac->scan.fScanEnable, pMac->isCoexScoIndSet);
Agarwal Ashish32bf8632015-02-25 16:02:06 +05303466 status = eHAL_STATUS_RESOURCES;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 } while( 0 );
3469
3470 return (status);
3471
3472
3473}
3474
3475/* ---------------------------------------------------------------------------
3476 \fn sme_ScanGetResult
3477 \brief a wrapper function to request scan results from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003478 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 \param pFilter - If pFilter is NULL, all cached results are returned
3480 \param phResult - an object for the result.
3481 \return eHalStatus
3482 ---------------------------------------------------------------------------*/
3483eHalStatus sme_ScanGetResult(tHalHandle hHal, tANI_U8 sessionId, tCsrScanResultFilter *pFilter,
3484 tScanResultHandle *phResult)
3485{
3486 eHalStatus status = eHAL_STATUS_FAILURE;
3487 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3488
Katya Nigambcb705f2013-12-26 14:26:22 +05303489 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003490 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 smsLog(pMac, LOG2, FL("enter"));
3492 status = sme_AcquireGlobalLock( &pMac->sme );
3493 if ( HAL_STATUS_SUCCESS( status ) )
3494 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07003495 status = csrScanGetResult( hHal, pFilter, phResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 sme_ReleaseGlobalLock( &pMac->sme );
3497 }
3498 smsLog(pMac, LOG2, FL("exit status %d"), status);
3499
3500 return (status);
3501}
3502
3503
3504/* ---------------------------------------------------------------------------
3505 \fn sme_ScanFlushResult
3506 \brief a wrapper function to request CSR to clear scan results.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003507 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 \return eHalStatus
3509 ---------------------------------------------------------------------------*/
3510eHalStatus sme_ScanFlushResult(tHalHandle hHal, tANI_U8 sessionId)
3511{
3512 eHalStatus status = eHAL_STATUS_FAILURE;
3513 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3514
Katya Nigambcb705f2013-12-26 14:26:22 +05303515 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003516 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS, sessionId,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 status = sme_AcquireGlobalLock( &pMac->sme );
3518 if ( HAL_STATUS_SUCCESS( status ) )
3519 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07003520 status = csrScanFlushResult( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 sme_ReleaseGlobalLock( &pMac->sme );
3522 }
3523
3524 return (status);
3525}
3526
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05303527/* ---------------------------------------------------------------------------
3528 \fn sme_FilterScanResults
3529 \brief a wrapper function to request CSR to clear scan results.
3530 This is a synchronous call
3531 \return eHalStatus
3532 ---------------------------------------------------------------------------*/
3533eHalStatus sme_FilterScanResults(tHalHandle hHal, tANI_U8 sessionId)
3534{
3535 eHalStatus status = eHAL_STATUS_SUCCESS;
3536 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3537
3538 MTRACE(macTraceNew(pMac, VOS_MODULE_ID_SME,
3539 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS, sessionId,0 ));
3540 status = sme_AcquireGlobalLock( &pMac->sme );
3541 if ( HAL_STATUS_SUCCESS( status ) )
3542 {
3543 csrScanFilterResults(pMac);
3544 sme_ReleaseGlobalLock( &pMac->sme );
3545 }
3546
3547 return (status);
3548}
3549
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05303550 /*
3551 * ---------------------------------------------------------------------------
3552 * \fn sme_FilterScanDFSResults
3553 * \brief a wrapper function to request CSR to filter BSSIDs on DFS channels
3554 * from the scan results.
3555 * \return eHalStatus
3556 *---------------------------------------------------------------------------
3557 */
3558eHalStatus sme_FilterScanDFSResults(tHalHandle hHal)
3559{
3560 eHalStatus status = eHAL_STATUS_SUCCESS;
3561 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3562
3563 status = sme_AcquireGlobalLock( &pMac->sme );
3564 if ( HAL_STATUS_SUCCESS( status ) )
3565 {
3566 csrScanFilterDFSResults(pMac);
3567 sme_ReleaseGlobalLock( &pMac->sme );
3568 }
3569
3570 return (status);
3571}
3572
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07003573eHalStatus sme_ScanFlushP2PResult(tHalHandle hHal, tANI_U8 sessionId)
3574{
3575 eHalStatus status = eHAL_STATUS_FAILURE;
3576 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3577
Katya Nigambcb705f2013-12-26 14:26:22 +05303578 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003579 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS, sessionId,0 ));
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07003580 status = sme_AcquireGlobalLock( &pMac->sme );
3581 if ( HAL_STATUS_SUCCESS( status ) )
3582 {
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05303583 status = csrScanFlushSelectiveResult( hHal, VOS_TRUE );
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07003584 sme_ReleaseGlobalLock( &pMac->sme );
3585 }
3586
3587 return (status);
3588}
Jeff Johnson295189b2012-06-20 16:38:30 -07003589
3590/* ---------------------------------------------------------------------------
3591 \fn sme_ScanResultGetFirst
3592 \brief a wrapper function to request CSR to returns the first element of
3593 scan result.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003594 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 \param hScanResult - returned from csrScanGetResult
3596 \return tCsrScanResultInfo * - NULL if no result
3597 ---------------------------------------------------------------------------*/
3598tCsrScanResultInfo *sme_ScanResultGetFirst(tHalHandle hHal,
3599 tScanResultHandle hScanResult)
3600{
3601 eHalStatus status = eHAL_STATUS_FAILURE;
3602 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3603 tCsrScanResultInfo *pRet = NULL;
3604
Katya Nigambcb705f2013-12-26 14:26:22 +05303605 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003606 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST, NO_SESSION,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 status = sme_AcquireGlobalLock( &pMac->sme );
3608 if ( HAL_STATUS_SUCCESS( status ) )
3609 {
3610 pRet = csrScanResultGetFirst( pMac, hScanResult );
3611 sme_ReleaseGlobalLock( &pMac->sme );
3612 }
3613
3614 return (pRet);
3615}
3616
3617
3618/* ---------------------------------------------------------------------------
3619 \fn sme_ScanResultGetNext
3620 \brief a wrapper function to request CSR to returns the next element of
3621 scan result. It can be called without calling csrScanResultGetFirst
3622 first
Srinivas Girigowdade697412013-02-14 16:31:48 -08003623 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 \param hScanResult - returned from csrScanGetResult
3625 \return Null if no result or reach the end
3626 ---------------------------------------------------------------------------*/
3627tCsrScanResultInfo *sme_ScanResultGetNext(tHalHandle hHal,
3628 tScanResultHandle hScanResult)
3629{
3630 eHalStatus status = eHAL_STATUS_FAILURE;
3631 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3632 tCsrScanResultInfo *pRet = NULL;
3633
3634 status = sme_AcquireGlobalLock( &pMac->sme );
3635 if ( HAL_STATUS_SUCCESS( status ) )
3636 {
3637 pRet = csrScanResultGetNext( pMac, hScanResult );
3638 sme_ReleaseGlobalLock( &pMac->sme );
3639 }
3640
3641 return (pRet);
3642}
3643
3644
3645/* ---------------------------------------------------------------------------
3646 \fn sme_ScanSetBGScanparams
3647 \brief a wrapper function to request CSR to set BG scan params in PE
Srinivas Girigowdade697412013-02-14 16:31:48 -08003648 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 \param pScanReq - BG scan request structure
3650 \return eHalStatus
3651 ---------------------------------------------------------------------------*/
3652eHalStatus sme_ScanSetBGScanparams(tHalHandle hHal, tANI_U8 sessionId, tCsrBGScanRequest *pScanReq)
3653{
3654 eHalStatus status = eHAL_STATUS_FAILURE;
3655 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3656
3657 if( NULL != pScanReq )
3658 {
3659 status = sme_AcquireGlobalLock( &pMac->sme );
3660 if ( HAL_STATUS_SUCCESS( status ) )
3661 {
3662 status = csrScanSetBGScanparams( hHal, pScanReq );
3663 sme_ReleaseGlobalLock( &pMac->sme );
3664 }
3665 }
3666
3667 return (status);
3668}
3669
3670
3671/* ---------------------------------------------------------------------------
3672 \fn sme_ScanResultPurge
3673 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
3674 in the list and free memory for each item
Srinivas Girigowdade697412013-02-14 16:31:48 -08003675 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 \param hScanResult - returned from csrScanGetResult. hScanResult is
3677 considered gone by
3678 calling this function and even before this function reutrns.
3679 \return eHalStatus
3680 ---------------------------------------------------------------------------*/
3681eHalStatus sme_ScanResultPurge(tHalHandle hHal, tScanResultHandle hScanResult)
3682{
3683 eHalStatus status = eHAL_STATUS_FAILURE;
3684 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3685
Katya Nigambcb705f2013-12-26 14:26:22 +05303686 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003687 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE, NO_SESSION,0 ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 status = sme_AcquireGlobalLock( &pMac->sme );
3689 if ( HAL_STATUS_SUCCESS( status ) )
3690 {
3691 status = csrScanResultPurge( hHal, hScanResult );
3692 sme_ReleaseGlobalLock( &pMac->sme );
3693 }
3694
3695 return (status);
3696}
3697
3698/* ---------------------------------------------------------------------------
3699 \fn sme_ScanGetPMKIDCandidateList
3700 \brief a wrapper function to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08003701 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 \param pPmkidList - caller allocated buffer point to an array of
3703 tPmkidCandidateInfo
3704 \param pNumItems - pointer to a variable that has the number of
3705 tPmkidCandidateInfo allocated when retruning, this is
3706 either the number needed or number of items put into
3707 pPmkidList
3708 \return eHalStatus - when fail, it usually means the buffer allocated is not
3709 big enough and pNumItems
3710 has the number of tPmkidCandidateInfo.
3711 \Note: pNumItems is a number of tPmkidCandidateInfo,
3712 not sizeof(tPmkidCandidateInfo) * something
3713 ---------------------------------------------------------------------------*/
3714eHalStatus sme_ScanGetPMKIDCandidateList(tHalHandle hHal, tANI_U8 sessionId,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003715 tPmkidCandidateInfo *pPmkidList,
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 tANI_U32 *pNumItems )
3717{
3718 eHalStatus status = eHAL_STATUS_FAILURE;
3719 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3720
3721 status = sme_AcquireGlobalLock( &pMac->sme );
3722 if ( HAL_STATUS_SUCCESS( status ) )
3723 {
3724 status = csrScanGetPMKIDCandidateList( pMac, sessionId, pPmkidList, pNumItems );
3725 sme_ReleaseGlobalLock( &pMac->sme );
3726 }
3727
3728 return (status);
3729}
3730
3731/*----------------------------------------------------------------------------
3732 \fn sme_RoamRegisterLinkQualityIndCallback
3733
3734 \brief
3735 a wrapper function to allow HDD to register a callback handler with CSR for
3736 link quality indications.
3737
3738 Only one callback may be registered at any time.
3739 In order to deregister the callback, a NULL cback may be provided.
3740
3741 Registration happens in the task context of the caller.
3742
3743 \param callback - Call back being registered
3744 \param pContext - user data
3745
3746 DEPENDENCIES: After CSR open
3747
3748 \return eHalStatus
3749-----------------------------------------------------------------------------*/
3750eHalStatus sme_RoamRegisterLinkQualityIndCallback(tHalHandle hHal, tANI_U8 sessionId,
3751 csrRoamLinkQualityIndCallback callback,
3752 void *pContext)
3753{
3754 return(csrRoamRegisterLinkQualityIndCallback((tpAniSirGlobal)hHal, callback, pContext));
3755}
3756
3757/* ---------------------------------------------------------------------------
3758 \fn sme_RoamRegisterCallback
3759 \brief a wrapper function to allow HDD to register a callback with CSR.
3760 Unlike scan, roam has one callback for all the roam requests
3761 \param callback - a callback function that roam calls upon when state changes
3762 \param pContext - a pointer passed in for the callback
3763 \return eHalStatus
3764 ---------------------------------------------------------------------------*/
3765eHalStatus sme_RoamRegisterCallback(tHalHandle hHal,
3766 csrRoamCompleteCallback callback,
3767 void *pContext)
3768{
3769 return(csrRoamRegisterCallback((tpAniSirGlobal)hHal, callback, pContext));
3770}
3771
3772eCsrPhyMode sme_GetPhyMode(tHalHandle hHal)
3773{
3774 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3775 return pMac->roam.configParam.phyMode;
3776}
3777
3778/* ---------------------------------------------------------------------------
Peng Xu117eab42014-09-25 13:33:27 +05303779 \fn sme_GetChannelBondingMode5G
3780 \brief get the channel bonding mode for 5G band
3781 \param hHal - HAL handle
3782 \return channel bonding mode for 5G
3783 ---------------------------------------------------------------------------*/
3784tANI_U32 sme_GetChannelBondingMode5G(tHalHandle hHal)
3785{
3786 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3787 tSmeConfigParams smeConfig;
3788
3789 sme_GetConfigParam(pMac, &smeConfig);
3790
3791 return smeConfig.csrConfig.channelBondingMode5GHz;
3792}
3793
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05303794#ifdef WLAN_FEATURE_AP_HT40_24G
Peng Xu117eab42014-09-25 13:33:27 +05303795/* ---------------------------------------------------------------------------
3796 \fn sme_GetChannelBondingMode24G
3797 \brief get the channel bonding mode for 2.4G band
3798 \param hHal - HAL handle
3799 \return channel bonding mode for 2.4G
3800 ---------------------------------------------------------------------------*/
3801tANI_U32 sme_GetChannelBondingMode24G(tHalHandle hHal)
3802{
3803 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3804 tSmeConfigParams smeConfig;
3805
3806 sme_GetConfigParam(pMac, &smeConfig);
3807
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05303808 return smeConfig.csrConfig.channelBondingAPMode24GHz;
Peng Xu117eab42014-09-25 13:33:27 +05303809}
3810
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05303811/* ---------------------------------------------------------------------------
3812 \fn sme_UpdateChannelBondingMode24G
3813 \brief update the channel bonding mode for 2.4G band
3814 \param hHal - HAL handle
3815 \param cbMode - channel bonding mode
3816 \return
3817 ---------------------------------------------------------------------------*/
3818void sme_UpdateChannelBondingMode24G(tHalHandle hHal, tANI_U8 cbMode)
3819{
3820 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3821 tSmeConfigParams smeConfig;
3822
3823 vos_mem_zero(&smeConfig, sizeof (tSmeConfigParams));
3824 sme_GetConfigParam(pMac, &smeConfig);
3825 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
3826 FL("Previous Channel Bonding : = %d"),
3827 smeConfig.csrConfig.channelBondingAPMode24GHz);
3828
3829 smeConfig.csrConfig.channelBondingAPMode24GHz = cbMode;
3830 sme_UpdateConfig(hHal, &smeConfig);
3831 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
3832 FL("New Channel Bonding : = %d"),
3833 sme_GetChannelBondingMode24G(hHal));
3834 return;
3835}
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05303836
3837/* ---------------------------------------------------------------------------
3838
3839 \fn sme_SetHT2040Mode
3840
3841 \brief To update HT Operation beacon IE & Channel Bonding.
3842
3843 \param
3844
3845 \return eHalStatus SUCCESS
3846 FAILURE or RESOURCES
3847 The API finished and failed.
3848
3849 -------------------------------------------------------------------------------*/
3850eHalStatus sme_SetHT2040Mode(tHalHandle hHal, tANI_U8 sessionId, tANI_U8 cbMode)
3851{
3852 eHalStatus status = eHAL_STATUS_FAILURE;
3853 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3854
3855 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3856 FL("Channel Bonding =%d"),
3857 cbMode);
3858
3859 status = sme_AcquireGlobalLock(&pMac->sme);
3860 if (HAL_STATUS_SUCCESS(status))
3861 {
3862 status = csrSetHT2040Mode(pMac, sessionId, cbMode);
3863 sme_ReleaseGlobalLock(&pMac->sme );
3864 }
3865 return (status);
3866}
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05303867#endif
Peng Xu117eab42014-09-25 13:33:27 +05303868
3869/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 \fn sme_RoamConnect
3871 \brief a wrapper function to request CSR to inititiate an association
Srinivas Girigowdade697412013-02-14 16:31:48 -08003872 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 \param sessionId - the sessionId returned by sme_OpenSession.
3874 \param pProfile - description of the network to which to connect
3875 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
3876 from csrScanGetResult
3877 \param pRoamId - to get back the request ID
3878 \return eHalStatus
3879 ---------------------------------------------------------------------------*/
3880eHalStatus sme_RoamConnect(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
3881 tANI_U32 *pRoamId)
3882{
3883 eHalStatus status = eHAL_STATUS_FAILURE;
3884 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3885
Yue Mae36e3552014-03-05 17:06:20 -08003886 if (!pMac)
3887 {
3888 return eHAL_STATUS_FAILURE;
3889 }
3890
Katya Nigambcb705f2013-12-26 14:26:22 +05303891 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003892 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 smsLog(pMac, LOG2, FL("enter"));
3894 status = sme_AcquireGlobalLock( &pMac->sme );
3895 if ( HAL_STATUS_SUCCESS( status ) )
3896 {
3897 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3898 {
3899 status = csrRoamConnect( pMac, sessionId, pProfile, NULL, pRoamId );
3900 }
3901 else
3902 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003903 smsLog(pMac, LOGE, FL("invalid sessionID %d"), sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 status = eHAL_STATUS_INVALID_PARAMETER;
3905 }
3906 sme_ReleaseGlobalLock( &pMac->sme );
3907 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003908 else
3909 {
3910 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
3911 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003912
3913 return (status);
3914}
3915
3916/* ---------------------------------------------------------------------------
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05303917
3918 \fn sme_SetPhyMode
3919
3920 \brief Changes the PhyMode.
3921
3922 \param hHal - The handle returned by macOpen.
3923
3924 \param phyMode new phyMode which is to set
3925
3926 \return eHalStatus SUCCESS.
3927
3928 -------------------------------------------------------------------------------*/
3929eHalStatus sme_SetPhyMode(tHalHandle hHal, eCsrPhyMode phyMode)
3930{
3931 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3932
3933 if (NULL == pMac)
3934 {
3935 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3936 "%s: invalid context", __func__);
3937 return eHAL_STATUS_FAILURE;
3938 }
3939
3940 pMac->roam.configParam.phyMode = phyMode;
3941 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL,
3942 pMac->roam.configParam.phyMode,
3943 pMac->roam.configParam.ProprietaryRatesEnabled);
3944
3945 return eHAL_STATUS_SUCCESS;
3946}
3947
3948/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 \fn sme_RoamReassoc
3950 \brief a wrapper function to request CSR to inititiate a re-association
3951 \param pProfile - can be NULL to join the currently connected AP. In that
3952 case modProfileFields should carry the modified field(s) which could trigger
3953 reassoc
3954 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
3955 that might need modification dynamically once STA is up & running and this
3956 could trigger a reassoc
3957 \param pRoamId - to get back the request ID
3958 \return eHalStatus
3959 -------------------------------------------------------------------------------*/
3960eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
3961 tCsrRoamModifyProfileFields modProfileFields,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07003962 tANI_U32 *pRoamId, v_BOOL_t fForce)
Jeff Johnson295189b2012-06-20 16:38:30 -07003963{
3964 eHalStatus status = eHAL_STATUS_FAILURE;
3965 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3966
Katya Nigambcb705f2013-12-26 14:26:22 +05303967 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07003968 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 smsLog(pMac, LOG2, FL("enter"));
3970 status = sme_AcquireGlobalLock( &pMac->sme );
3971 if ( HAL_STATUS_SUCCESS( status ) )
3972 {
3973 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3974 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003975 if((NULL == pProfile) && (fForce == 1))
3976 {
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07003977 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3978 /* to force the AP initiate fresh 802.1x authentication need to clear
3979 * the PMKID cache for that set the following boolean. this is needed
3980 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
3981 pSession->fIgnorePMKIDCache = TRUE;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07003982 status = csrReassoc( pMac, sessionId, &modProfileFields, pRoamId , fForce);
3983 }
3984 else
3985 {
3986 status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07003987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 }
3989 else
3990 {
3991 status = eHAL_STATUS_INVALID_PARAMETER;
3992 }
3993 sme_ReleaseGlobalLock( &pMac->sme );
3994 }
3995
3996 return (status);
3997}
3998
3999/* ---------------------------------------------------------------------------
4000 \fn sme_RoamConnectToLastProfile
4001 \brief a wrapper function to request CSR to disconnect and reconnect with
4002 the same profile
Srinivas Girigowdade697412013-02-14 16:31:48 -08004003 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 \return eHalStatus. It returns fail if currently connected
4005 ---------------------------------------------------------------------------*/
4006eHalStatus sme_RoamConnectToLastProfile(tHalHandle hHal, tANI_U8 sessionId)
4007{
4008 eHalStatus status = eHAL_STATUS_FAILURE;
4009 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4010
4011 status = sme_AcquireGlobalLock( &pMac->sme );
4012 if ( HAL_STATUS_SUCCESS( status ) )
4013 {
4014 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4015 {
4016 status = csrRoamConnectToLastProfile( pMac, sessionId );
4017 }
4018 else
4019 {
4020 status = eHAL_STATUS_INVALID_PARAMETER;
4021 }
4022 sme_ReleaseGlobalLock( &pMac->sme );
4023 }
4024
4025 return (status);
4026}
4027
4028/* ---------------------------------------------------------------------------
4029 \fn sme_RoamDisconnect
4030 \brief a wrapper function to request CSR to disconnect from a network
Srinivas Girigowdade697412013-02-14 16:31:48 -08004031 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 \param reason -- To indicate the reason for disconnecting. Currently, only
4033 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
4034 \return eHalStatus
4035 ---------------------------------------------------------------------------*/
4036eHalStatus sme_RoamDisconnect(tHalHandle hHal, tANI_U8 sessionId, eCsrRoamDisconnectReason reason)
4037{
4038 eHalStatus status = eHAL_STATUS_FAILURE;
4039 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4040
Katya Nigambcb705f2013-12-26 14:26:22 +05304041 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004042 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId, reason));
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 smsLog(pMac, LOG2, FL("enter"));
4044 status = sme_AcquireGlobalLock( &pMac->sme );
4045 if ( HAL_STATUS_SUCCESS( status ) )
4046 {
4047 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4048 {
Abhishek Singh5de9efd2017-06-15 10:22:39 +05304049 /*
4050 * Indicate csr of disconnect so that
4051 * in progress connection, scan for ssid and preauth
4052 * can be aborted
4053 */
4054 csr_abortConnection(pMac, sessionId);
4055 status = csrRoamDisconnect(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 }
4057 else
4058 {
4059 status = eHAL_STATUS_INVALID_PARAMETER;
4060 }
4061 sme_ReleaseGlobalLock( &pMac->sme );
4062 }
4063
4064 return (status);
4065}
4066
Jeff Johnson295189b2012-06-20 16:38:30 -07004067/* ---------------------------------------------------------------------------
Sushant Kaushikb4834d22015-07-15 15:29:05 +05304068 \fn.sme_abortConnection
4069 \brief a wrapper function to request CSR to stop from connecting a network
4070 \retun void.
4071---------------------------------------------------------------------------*/
4072
4073void sme_abortConnection(tHalHandle hHal, tANI_U8 sessionId)
4074{
4075 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4076 eHalStatus status = eHAL_STATUS_FAILURE;
4077
4078 status = sme_AcquireGlobalLock( &pMac->sme );
4079 if ( HAL_STATUS_SUCCESS( status ) )
4080 {
4081 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4082 {
4083 csr_abortConnection( pMac, sessionId);
4084 }
4085 sme_ReleaseGlobalLock( &pMac->sme );
4086 }
4087 return;
4088}
4089
Abhishek Singhe0bc0992016-05-20 17:58:18 +05304090/* sme_dhcp_done_ind() - send dhcp done ind
4091 * @hal: hal context
4092 * @session_id: session id
4093 *
4094 * Return: void.
4095 */
4096void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
4097{
4098 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4099 tCsrRoamSession *session;
4100
4101 if (!mac_ctx)
4102 return;
4103
4104 session = CSR_GET_SESSION(mac_ctx, session_id);
4105 if(!session)
4106 {
4107 smsLog(mac_ctx, LOGE, FL(" session %d not found "), session_id);
4108 return;
4109 }
4110 session->dhcp_done = true;
4111}
4112
Sushant Kaushikb4834d22015-07-15 15:29:05 +05304113/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 \fn sme_RoamStopBss
4115 \brief To stop BSS for Soft AP. This is an asynchronous API.
4116 \param hHal - Global structure
4117 \param sessionId - sessionId of SoftAP
4118 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
4119 -------------------------------------------------------------------------------*/
4120eHalStatus sme_RoamStopBss(tHalHandle hHal, tANI_U8 sessionId)
4121{
4122 eHalStatus status = eHAL_STATUS_FAILURE;
4123 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4124
4125 smsLog(pMac, LOG2, FL("enter"));
4126 status = sme_AcquireGlobalLock( &pMac->sme );
4127 if ( HAL_STATUS_SUCCESS( status ) )
4128 {
4129 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4130 {
Gopichand Nakkalaf44bdc52013-02-16 00:54:45 +05304131 status = csrRoamIssueStopBssCmd( pMac, sessionId, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 }
4133 else
4134 {
4135 status = eHAL_STATUS_INVALID_PARAMETER;
4136 }
4137 sme_ReleaseGlobalLock( &pMac->sme );
4138 }
4139
4140 return (status);
4141}
4142
4143/* ---------------------------------------------------------------------------
4144 \fn sme_RoamDisconnectSta
4145 \brief To disassociate a station. This is an asynchronous API.
4146 \param hHal - Global structure
4147 \param sessionId - sessionId of SoftAP
4148 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
4149 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
4150 -------------------------------------------------------------------------------*/
4151eHalStatus sme_RoamDisconnectSta(tHalHandle hHal, tANI_U8 sessionId,
Anand N Sunkadc205d952015-07-30 15:36:03 +05304152#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
4153 const tANI_U8 *pPeerMacAddr
4154#else
4155 tANI_U8 *pPeerMacAddr
4156#endif
4157)
Jeff Johnson295189b2012-06-20 16:38:30 -07004158{
4159 eHalStatus status = eHAL_STATUS_FAILURE;
4160 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4161
4162 if ( NULL == pMac )
4163 {
4164 VOS_ASSERT(0);
4165 return status;
4166 }
4167
4168 status = sme_AcquireGlobalLock( &pMac->sme );
4169 if ( HAL_STATUS_SUCCESS( status ) )
4170 {
4171 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4172 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07004173 status = csrRoamIssueDisassociateStaCmd( pMac, sessionId, pPeerMacAddr,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05304174 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 }
4176 else
4177 {
4178 status = eHAL_STATUS_INVALID_PARAMETER;
4179 }
4180 sme_ReleaseGlobalLock( &pMac->sme );
4181 }
4182
4183 return (status);
4184}
4185
4186/* ---------------------------------------------------------------------------
4187 \fn sme_RoamDeauthSta
4188 \brief To disassociate a station. This is an asynchronous API.
4189 \param hHal - Global structure
4190 \param sessionId - sessionId of SoftAP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05304191 \param pDelStaParams -Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
4193 -------------------------------------------------------------------------------*/
4194eHalStatus sme_RoamDeauthSta(tHalHandle hHal, tANI_U8 sessionId,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05304195 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07004196{
4197 eHalStatus status = eHAL_STATUS_FAILURE;
4198 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4199
4200 if ( NULL == pMac )
4201 {
4202 VOS_ASSERT(0);
4203 return status;
4204 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +05304205 MTRACE(vos_trace(VOS_MODULE_ID_SME,
4206 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
4207 sessionId, pDelStaParams->reason_code));
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 status = sme_AcquireGlobalLock( &pMac->sme );
4209 if ( HAL_STATUS_SUCCESS( status ) )
4210 {
4211 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4212 {
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05304213 status = csrRoamIssueDeauthStaCmd( pMac, sessionId, pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 }
4215 else
4216 {
4217 status = eHAL_STATUS_INVALID_PARAMETER;
4218 }
4219 sme_ReleaseGlobalLock( &pMac->sme );
4220 }
4221
4222 return (status);
4223}
4224
4225/* ---------------------------------------------------------------------------
4226 \fn sme_RoamTKIPCounterMeasures
4227 \brief To start or stop TKIP counter measures. This is an asynchronous API.
4228 \param sessionId - sessionId of SoftAP
4229 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
4230 \return eHalStatus
4231 -------------------------------------------------------------------------------*/
4232eHalStatus sme_RoamTKIPCounterMeasures(tHalHandle hHal, tANI_U8 sessionId,
4233 tANI_BOOLEAN bEnable)
4234{
4235 eHalStatus status = eHAL_STATUS_FAILURE;
4236 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4237
4238 if ( NULL == pMac )
4239 {
4240 VOS_ASSERT(0);
4241 return status;
4242 }
4243
4244 status = sme_AcquireGlobalLock( &pMac->sme );
4245 if ( HAL_STATUS_SUCCESS( status ) )
4246 {
4247 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4248 {
4249 status = csrRoamIssueTkipCounterMeasures( pMac, sessionId, bEnable);
4250 }
4251 else
4252 {
4253 status = eHAL_STATUS_INVALID_PARAMETER;
4254 }
4255 sme_ReleaseGlobalLock( &pMac->sme );
4256 }
4257
4258 return (status);
4259}
4260
4261/* ---------------------------------------------------------------------------
4262 \fn sme_RoamGetAssociatedStas
4263 \brief To probe the list of associated stations from various modules of CORE stack.
4264 \This is an asynchronous API.
4265 \param sessionId - sessionId of SoftAP
4266 \param modId - Module from whom list of associtated stations is to be probed.
4267 If an invalid module is passed then by default VOS_MODULE_ID_PE will be probed
4268 \param pUsrContext - Opaque HDD context
4269 \param pfnSapEventCallback - Sap event callback in HDD
4270 \param pAssocBuf - Caller allocated memory to be filled with associatd stations info
4271 \return eHalStatus
4272 -------------------------------------------------------------------------------*/
4273eHalStatus sme_RoamGetAssociatedStas(tHalHandle hHal, tANI_U8 sessionId,
4274 VOS_MODULE_ID modId, void *pUsrContext,
4275 void *pfnSapEventCallback, tANI_U8 *pAssocStasBuf)
4276{
4277 eHalStatus status = eHAL_STATUS_FAILURE;
4278 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4279
4280 if ( NULL == pMac )
4281 {
4282 VOS_ASSERT(0);
4283 return status;
4284 }
4285
4286 status = sme_AcquireGlobalLock( &pMac->sme );
4287 if ( HAL_STATUS_SUCCESS( status ) )
4288 {
4289 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4290 {
4291 status = csrRoamGetAssociatedStas( pMac, sessionId, modId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
4292 }
4293 else
4294 {
4295 status = eHAL_STATUS_INVALID_PARAMETER;
4296 }
4297 sme_ReleaseGlobalLock( &pMac->sme );
4298 }
4299
4300 return (status);
4301}
4302
4303/* ---------------------------------------------------------------------------
4304 \fn sme_RoamGetWpsSessionOverlap
4305 \brief To get the WPS PBC session overlap information.
4306 \This is an asynchronous API.
4307 \param sessionId - sessionId of SoftAP
4308 \param pUsrContext - Opaque HDD context
4309 \param pfnSapEventCallback - Sap event callback in HDD
4310 \pRemoveMac - pointer to Mac address which needs to be removed from session
4311 \return eHalStatus
4312 -------------------------------------------------------------------------------*/
4313eHalStatus sme_RoamGetWpsSessionOverlap(tHalHandle hHal, tANI_U8 sessionId,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07004314 void *pUsrContext, void
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 *pfnSapEventCallback, v_MACADDR_t pRemoveMac)
4316{
4317 eHalStatus status = eHAL_STATUS_FAILURE;
4318 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4319
4320 if ( NULL == pMac )
4321 {
4322 VOS_ASSERT(0);
4323 return status;
4324 }
4325
4326 status = sme_AcquireGlobalLock( &pMac->sme );
4327 if ( HAL_STATUS_SUCCESS( status ) )
4328 {
4329 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4330 {
4331 status = csrRoamGetWpsSessionOverlap( pMac, sessionId, pUsrContext, pfnSapEventCallback, pRemoveMac);
4332 }
4333 else
4334 {
4335 status = eHAL_STATUS_INVALID_PARAMETER;
4336 }
4337 sme_ReleaseGlobalLock( &pMac->sme );
4338 }
4339
4340 return (status);
4341}
4342
Jeff Johnson295189b2012-06-20 16:38:30 -07004343
4344/* ---------------------------------------------------------------------------
4345 \fn sme_RoamGetConnectState
4346 \brief a wrapper function to request CSR to return the current connect state
4347 of Roaming
Srinivas Girigowdade697412013-02-14 16:31:48 -08004348 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004349 \return eHalStatus
4350 ---------------------------------------------------------------------------*/
4351eHalStatus sme_RoamGetConnectState(tHalHandle hHal, tANI_U8 sessionId, eCsrConnectState *pState)
4352{
4353 eHalStatus status = eHAL_STATUS_FAILURE;
4354 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4355
4356 status = sme_AcquireGlobalLock( &pMac->sme );
4357 if ( HAL_STATUS_SUCCESS( status ) )
4358 {
4359 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4360 {
4361 status = csrRoamGetConnectState( pMac, sessionId, pState );
4362 }
4363 else
4364 {
4365 status = eHAL_STATUS_INVALID_PARAMETER;
4366 }
4367 sme_ReleaseGlobalLock( &pMac->sme );
4368 }
4369
4370 return (status);
4371}
4372
4373/* ---------------------------------------------------------------------------
4374 \fn sme_RoamGetConnectProfile
4375 \brief a wrapper function to request CSR to return the current connect
4376 profile. Caller must call csrRoamFreeConnectProfile after it is done
4377 and before reuse for another csrRoamGetConnectProfile call.
Srinivas Girigowdade697412013-02-14 16:31:48 -08004378 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 \param pProfile - pointer to a caller allocated structure
4380 tCsrRoamConnectedProfile
4381 \return eHalStatus. Failure if not connected
4382 ---------------------------------------------------------------------------*/
4383eHalStatus sme_RoamGetConnectProfile(tHalHandle hHal, tANI_U8 sessionId,
4384 tCsrRoamConnectedProfile *pProfile)
4385{
4386 eHalStatus status = eHAL_STATUS_FAILURE;
4387 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4388
Katya Nigambcb705f2013-12-26 14:26:22 +05304389 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004390 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 status = sme_AcquireGlobalLock( &pMac->sme );
4392 if ( HAL_STATUS_SUCCESS( status ) )
4393 {
4394 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4395 {
4396 status = csrRoamGetConnectProfile( pMac, sessionId, pProfile );
4397 }
4398 else
4399 {
4400 status = eHAL_STATUS_INVALID_PARAMETER;
4401 }
4402 sme_ReleaseGlobalLock( &pMac->sme );
4403 }
4404
4405 return (status);
4406}
4407
4408/* ---------------------------------------------------------------------------
4409 \fn sme_RoamFreeConnectProfile
4410 \brief a wrapper function to request CSR to free and reinitialize the
4411 profile returned previously by csrRoamGetConnectProfile.
Srinivas Girigowdade697412013-02-14 16:31:48 -08004412 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 \param pProfile - pointer to a caller allocated structure
4414 tCsrRoamConnectedProfile
4415 \return eHalStatus.
4416 ---------------------------------------------------------------------------*/
4417eHalStatus sme_RoamFreeConnectProfile(tHalHandle hHal,
4418 tCsrRoamConnectedProfile *pProfile)
4419{
4420 eHalStatus status = eHAL_STATUS_FAILURE;
4421 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4422
Katya Nigambcb705f2013-12-26 14:26:22 +05304423 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004424 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 status = sme_AcquireGlobalLock( &pMac->sme );
4426 if ( HAL_STATUS_SUCCESS( status ) )
4427 {
4428 status = csrRoamFreeConnectProfile( pMac, pProfile );
4429 sme_ReleaseGlobalLock( &pMac->sme );
4430 }
4431
4432 return (status);
4433}
4434
4435/* ---------------------------------------------------------------------------
4436 \fn sme_RoamSetPMKIDCache
4437 \brief a wrapper function to request CSR to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08004438 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 \param pPMKIDCache - caller allocated buffer point to an array of
4440 tPmkidCacheInfo
4441 \param numItems - a variable that has the number of tPmkidCacheInfo
4442 allocated when retruning, this is either the number needed
4443 or number of items put into pPMKIDCache
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304444 \param update_entire_cache - this bool value specifies if the entire pmkid
4445 cache should be overwritten or should it be
4446 updated entry by entry.
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 \return eHalStatus - when fail, it usually means the buffer allocated is not
4448 big enough and pNumItems has the number of
4449 tPmkidCacheInfo.
4450 \Note: pNumItems is a number of tPmkidCacheInfo,
4451 not sizeof(tPmkidCacheInfo) * something
4452 ---------------------------------------------------------------------------*/
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304453eHalStatus sme_RoamSetPMKIDCache( tHalHandle hHal, tANI_U8 sessionId,
4454 tPmkidCacheInfo *pPMKIDCache,
4455 tANI_U32 numItems,
4456 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -07004457{
4458 eHalStatus status = eHAL_STATUS_FAILURE;
4459 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4460
Katya Nigambcb705f2013-12-26 14:26:22 +05304461 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004462 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId, numItems));
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 status = sme_AcquireGlobalLock( &pMac->sme );
4464 if ( HAL_STATUS_SUCCESS( status ) )
4465 {
4466 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4467 {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304468 status = csrRoamSetPMKIDCache( pMac, sessionId, pPMKIDCache,
4469 numItems, update_entire_cache );
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 }
4471 else
4472 {
4473 status = eHAL_STATUS_INVALID_PARAMETER;
4474 }
4475 sme_ReleaseGlobalLock( &pMac->sme );
4476 }
4477
4478 return (status);
4479}
4480
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304481eHalStatus sme_RoamDelPMKIDfromCache( tHalHandle hHal, tANI_U8 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304482#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
4483 const tANI_U8 *pBSSId,
4484#else
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304485 tANI_U8 *pBSSId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304486#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304487 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -07004488{
4489 eHalStatus status = eHAL_STATUS_FAILURE;
4490 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4491 status = sme_AcquireGlobalLock( &pMac->sme );
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +05304492
4493 MTRACE(vos_trace(VOS_MODULE_ID_SME,
4494 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE, sessionId, flush_cache));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -07004495 if ( HAL_STATUS_SUCCESS( status ) )
4496 {
4497 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4498 {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304499 status = csrRoamDelPMKIDfromCache( pMac, sessionId,
4500 pBSSId, flush_cache );
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -07004501 }
4502 else
4503 {
4504 status = eHAL_STATUS_INVALID_PARAMETER;
4505 }
4506 sme_ReleaseGlobalLock( &pMac->sme );
4507 }
4508 return (status);
4509}
Wilson Yang47b58192013-12-11 11:40:19 -08004510
Jeff Johnson295189b2012-06-20 16:38:30 -07004511/* ---------------------------------------------------------------------------
4512 \fn sme_RoamGetSecurityReqIE
4513 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
4514 passes to PE to JOIN request or START_BSS request
Srinivas Girigowdade697412013-02-14 16:31:48 -08004515 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 \param pLen - caller allocated memory that has the length of pBuf as input.
4517 Upon returned, *pLen has the needed or IE length in pBuf.
4518 \param pBuf - Caller allocated memory that contain the IE field, if any,
4519 upon return
4520 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
4521 \return eHalStatus - when fail, it usually means the buffer allocated is not
4522 big enough
4523 ---------------------------------------------------------------------------*/
4524eHalStatus sme_RoamGetSecurityReqIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
4525 tANI_U8 *pBuf, eCsrSecurityType secType)
4526{
4527 eHalStatus status = eHAL_STATUS_FAILURE;
4528 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4529
4530 status = sme_AcquireGlobalLock( &pMac->sme );
4531 if ( HAL_STATUS_SUCCESS( status ) )
4532 {
4533 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4534 {
4535 status = csrRoamGetWpaRsnReqIE( hHal, sessionId, pLen, pBuf );
4536 }
4537 else
4538 {
4539 status = eHAL_STATUS_INVALID_PARAMETER;
4540 }
4541 sme_ReleaseGlobalLock( &pMac->sme );
4542 }
4543
4544 return (status);
4545}
4546
4547/* ---------------------------------------------------------------------------
4548 \fn sme_RoamGetSecurityRspIE
4549 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE from
4550 the beacon or probe rsp if connected
Srinivas Girigowdade697412013-02-14 16:31:48 -08004551 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 \param pLen - caller allocated memory that has the length of pBuf as input.
4553 Upon returned, *pLen has the needed or IE length in pBuf.
4554 \param pBuf - Caller allocated memory that contain the IE field, if any,
4555 upon return
4556 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
4557 \return eHalStatus - when fail, it usually means the buffer allocated is not
4558 big enough
4559 ---------------------------------------------------------------------------*/
4560eHalStatus sme_RoamGetSecurityRspIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
4561 tANI_U8 *pBuf, eCsrSecurityType secType)
4562{
4563 eHalStatus status = eHAL_STATUS_FAILURE;
4564 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4565
4566 status = sme_AcquireGlobalLock( &pMac->sme );
4567 if ( HAL_STATUS_SUCCESS( status ) )
4568 {
4569 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4570 {
4571 status = csrRoamGetWpaRsnRspIE( pMac, sessionId, pLen, pBuf );
4572 }
4573 else
4574 {
4575 status = eHAL_STATUS_INVALID_PARAMETER;
4576 }
4577 sme_ReleaseGlobalLock( &pMac->sme );
4578 }
4579
4580 return (status);
4581
4582}
4583
4584
4585/* ---------------------------------------------------------------------------
4586 \fn sme_RoamGetNumPMKIDCache
4587 \brief a wrapper function to request CSR to return number of PMKID cache
4588 entries
Srinivas Girigowdade697412013-02-14 16:31:48 -08004589 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 \return tANI_U32 - the number of PMKID cache entries
4591 ---------------------------------------------------------------------------*/
4592tANI_U32 sme_RoamGetNumPMKIDCache(tHalHandle hHal, tANI_U8 sessionId)
4593{
4594 eHalStatus status = eHAL_STATUS_FAILURE;
4595 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4596 tANI_U32 numPmkidCache = 0;
4597
4598 status = sme_AcquireGlobalLock( &pMac->sme );
4599 if ( HAL_STATUS_SUCCESS( status ) )
4600 {
4601 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4602 {
4603 numPmkidCache = csrRoamGetNumPMKIDCache( pMac, sessionId );
4604 status = eHAL_STATUS_SUCCESS;
4605 }
4606 else
4607 {
4608 status = eHAL_STATUS_INVALID_PARAMETER;
4609 }
4610 sme_ReleaseGlobalLock( &pMac->sme );
4611 }
4612
4613 return (numPmkidCache);
4614}
4615
4616/* ---------------------------------------------------------------------------
4617 \fn sme_RoamGetPMKIDCache
4618 \brief a wrapper function to request CSR to return PMKID cache from CSR
Srinivas Girigowdade697412013-02-14 16:31:48 -08004619 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 \param pNum - caller allocated memory that has the space of the number of
4621 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
4622 needed or actually number in tPmkidCacheInfo.
4623 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
4624 any, upon return
4625 \return eHalStatus - when fail, it usually means the buffer allocated is not
4626 big enough
4627 ---------------------------------------------------------------------------*/
4628eHalStatus sme_RoamGetPMKIDCache(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pNum,
4629 tPmkidCacheInfo *pPmkidCache)
4630{
4631 eHalStatus status = eHAL_STATUS_FAILURE;
4632 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4633
4634 status = sme_AcquireGlobalLock( &pMac->sme );
4635 if ( HAL_STATUS_SUCCESS( status ) )
4636 {
4637 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4638 {
4639 status = csrRoamGetPMKIDCache( pMac, sessionId, pNum, pPmkidCache );
4640 }
4641 else
4642 {
4643 status = eHAL_STATUS_INVALID_PARAMETER;
4644 }
4645 sme_ReleaseGlobalLock( &pMac->sme );
4646 }
4647
4648 return (status);
4649}
4650
4651
4652/* ---------------------------------------------------------------------------
4653 \fn sme_GetConfigParam
4654 \brief a wrapper function that HDD calls to get the global settings
4655 currently maintained by CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08004656 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 \param pParam - caller allocated memory
4658 \return eHalStatus
4659 ---------------------------------------------------------------------------*/
4660eHalStatus sme_GetConfigParam(tHalHandle hHal, tSmeConfigParams *pParam)
4661{
4662 eHalStatus status = eHAL_STATUS_FAILURE;
4663 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4664
Katya Nigambcb705f2013-12-26 14:26:22 +05304665 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004666 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 status = sme_AcquireGlobalLock( &pMac->sme );
4668 if ( HAL_STATUS_SUCCESS( status ) )
4669 {
4670 status = csrGetConfigParam(pMac, &pParam->csrConfig);
4671 if (status != eHAL_STATUS_SUCCESS)
4672 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004673 smsLog( pMac, LOGE, "%s csrGetConfigParam failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 sme_ReleaseGlobalLock( &pMac->sme );
4675 return status;
4676 }
4677#if defined WLAN_FEATURE_P2P_INTERNAL
4678 status = p2pGetConfigParam(pMac, &pParam->p2pConfig);
4679 if (status != eHAL_STATUS_SUCCESS)
4680 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004681 smsLog( pMac, LOGE, "%s p2pGetConfigParam failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 sme_ReleaseGlobalLock( &pMac->sme );
4683 return status;
4684 }
4685#endif
Chandrasekaran, Manishekareebd1642015-03-16 10:35:03 +05304686 pParam->fBtcEnableIndTimerVal = pMac->fBtcEnableIndTimerVal;
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 sme_ReleaseGlobalLock( &pMac->sme );
4688 }
4689
4690 return (status);
4691}
4692
4693/* ---------------------------------------------------------------------------
4694 \fn sme_CfgSetInt
4695 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08004696 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 \param cfgId - Configuration Parameter ID (type) for STA.
4698 \param ccmValue - The information related to Configuration Parameter ID
4699 which needs to be saved in CFG
4700 \param callback - To be registered by CSR with CCM. Once the CFG done with
4701 saving the information in the database, it notifies CCM &
4702 then the callback will be invoked to notify.
4703 \param toBeSaved - To save the request for future reference
4704 \return eHalStatus
4705 ---------------------------------------------------------------------------*/
4706eHalStatus sme_CfgSetInt(tHalHandle hHal, tANI_U32 cfgId, tANI_U32 ccmValue,
4707 tCcmCfgSetCallback callback, eAniBoolean toBeSaved)
4708{
4709 return(ccmCfgSetInt(hHal, cfgId, ccmValue, callback, toBeSaved));
4710}
4711
4712/* ---------------------------------------------------------------------------
4713 \fn sme_CfgSetStr
4714 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08004715 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 \param cfgId - Configuration Parameter ID (type) for STA.
4717 \param pStr - Pointer to the byte array which carries the information needs
4718 to be saved in CFG
4719 \param length - Length of the data to be saved
4720 \param callback - To be registered by CSR with CCM. Once the CFG done with
4721 saving the information in the database, it notifies CCM &
4722 then the callback will be invoked to notify.
4723 \param toBeSaved - To save the request for future reference
4724 \return eHalStatus
4725 ---------------------------------------------------------------------------*/
4726eHalStatus sme_CfgSetStr(tHalHandle hHal, tANI_U32 cfgId, tANI_U8 *pStr,
4727 tANI_U32 length, tCcmCfgSetCallback callback,
4728 eAniBoolean toBeSaved)
4729{
4730 return(ccmCfgSetStr(hHal, cfgId, pStr, length, callback, toBeSaved));
4731}
4732
4733/* ---------------------------------------------------------------------------
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05304734 \fn sme_GetModifyProfileFields
4735 \brief HDD or SME - QOS calls this function to get the current values of
4736 connected profile fields, changing which can cause reassoc.
4737 This function must be called after CFG is downloaded and STA is in connected
4738 state. Also, make sure to call this function to get the current profile
4739 fields before calling the reassoc. So that pModifyProfileFields will have
4740 all the latest values plus the one(s) has been updated as part of reassoc
4741 request.
4742 \param pModifyProfileFields - pointer to the connected profile fields
4743 changing which can cause reassoc
4744
4745 \return eHalStatus
4746 -------------------------------------------------------------------------------*/
4747eHalStatus sme_GetModifyProfileFields(tHalHandle hHal, tANI_U8 sessionId,
4748 tCsrRoamModifyProfileFields * pModifyProfileFields)
4749{
4750 eHalStatus status = eHAL_STATUS_FAILURE;
4751 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4752
4753 MTRACE(vos_trace(VOS_MODULE_ID_SME,
4754 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId, 0));
4755 status = sme_AcquireGlobalLock( &pMac->sme );
4756 if ( HAL_STATUS_SUCCESS( status ) )
4757 {
4758 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4759 {
4760 status = csrGetModifyProfileFields(pMac, sessionId, pModifyProfileFields);
4761 }
4762 else
4763 {
4764 status = eHAL_STATUS_INVALID_PARAMETER;
4765 }
4766 sme_ReleaseGlobalLock( &pMac->sme );
4767 }
4768
4769 return (status);
4770}
4771
4772/* ---------------------------------------------------------------------------
Sandeep Puligilla332ea912014-02-04 00:16:24 +05304773 \fn sme_HT40StopOBSSScan
4774 \brief HDD or SME - Command to stop the OBSS scan
4775 THis is implemented only for debugging purpose.
4776 As per spec while operating in 2.4GHz OBSS scan shouldnt be stopped.
4777 \param sessionId - sessionId
4778 changing which can cause reassoc
4779
4780 \return eHalStatus
4781 -------------------------------------------------------------------------------*/
4782eHalStatus sme_HT40StopOBSSScan(tHalHandle hHal, tANI_U8 sessionId)
4783{
4784 eHalStatus status = eHAL_STATUS_FAILURE;
4785 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4786
4787 smsLog(pMac, LOG2, FL("enter"));
4788 status = sme_AcquireGlobalLock( &pMac->sme );
4789 if ( HAL_STATUS_SUCCESS( status ) )
4790 {
4791 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
4792 {
4793 csrHT40StopOBSSScan( pMac, sessionId );
4794 }
4795 else
4796 {
4797 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4798 "%s: Invalid session sessionId %d", __func__,sessionId);
4799 status = eHAL_STATUS_INVALID_PARAMETER;
4800 }
4801 sme_ReleaseGlobalLock( &pMac->sme );
4802 }
4803 return (status);
4804}
4805
Jeff Johnson295189b2012-06-20 16:38:30 -07004806/*--------------------------------------------------------------------------
4807 \fn sme_SetConfigPowerSave
4808 \brief Wrapper fn to change power save configuration in SME (PMC) module.
4809 For BMPS related configuration, this function also updates the CFG
4810 and sends a message to FW to pick up the new values. Note: Calling
4811 this function only updates the configuration and does not enable
4812 the specified power save mode.
4813 \param hHal - The handle returned by macOpen.
4814 \param psMode - Power Saving mode being modified
4815 \param pConfigParams - a pointer to a caller allocated object of type
4816 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
4817 \return eHalStatus
4818 --------------------------------------------------------------------------*/
4819eHalStatus sme_SetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
4820 void *pConfigParams)
4821{
4822 eHalStatus status = eHAL_STATUS_FAILURE;
4823 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4824
Katya Nigambcb705f2013-12-26 14:26:22 +05304825 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004826 TRACE_CODE_SME_RX_HDD_SET_CONFIG_PWRSAVE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 if (NULL == pConfigParams ) {
4828 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
4829 "nothing to update");
4830 return eHAL_STATUS_FAILURE;
4831 }
4832
4833 status = sme_AcquireGlobalLock( &pMac->sme );
4834 if ( HAL_STATUS_SUCCESS( status ) )
4835 {
4836 status = pmcSetConfigPowerSave(hHal, psMode, pConfigParams);
4837 sme_ReleaseGlobalLock( &pMac->sme );
4838 }
4839
4840 return (status);
4841}
4842
4843/*--------------------------------------------------------------------------
4844 \fn sme_GetConfigPowerSave
4845 \brief Wrapper fn to retrieve power save configuration in SME (PMC) module
4846 \param hHal - The handle returned by macOpen.
4847 \param psMode - Power Saving mode
4848 \param pConfigParams - a pointer to a caller allocated object of type
4849 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
4850 \return eHalStatus
4851 --------------------------------------------------------------------------*/
4852eHalStatus sme_GetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
4853 void *pConfigParams)
4854{
4855 eHalStatus status = eHAL_STATUS_FAILURE;
4856 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4857
Katya Nigambcb705f2013-12-26 14:26:22 +05304858 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004859 TRACE_CODE_SME_RX_HDD_GET_CONFIG_PWRSAVE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004860 if (NULL == pConfigParams ) {
4861 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
4862 "nothing to update");
4863 return eHAL_STATUS_FAILURE;
4864 }
4865
4866 status = sme_AcquireGlobalLock( &pMac->sme );
4867 if ( HAL_STATUS_SUCCESS( status ) )
4868 {
4869 status = pmcGetConfigPowerSave(hHal, psMode, pConfigParams);
4870 sme_ReleaseGlobalLock( &pMac->sme );
4871 }
4872
4873 return (status);
4874}
4875
4876/* ---------------------------------------------------------------------------
4877 \fn sme_SignalPowerEvent
4878 \brief Signals to PMC that a power event has occurred. Used for putting
4879 the chip into deep sleep mode.
4880 \param hHal - The handle returned by macOpen.
4881 \param event - the event that has occurred
4882 \return eHalStatus
4883 ---------------------------------------------------------------------------*/
4884eHalStatus sme_SignalPowerEvent (tHalHandle hHal, tPmcPowerEvent event)
4885{
4886 eHalStatus status = eHAL_STATUS_FAILURE;
4887 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4888
4889 status = sme_AcquireGlobalLock( &pMac->sme );
4890 if ( HAL_STATUS_SUCCESS( status ) )
4891 {
4892 status = pmcSignalPowerEvent(hHal, event);
4893 sme_ReleaseGlobalLock( &pMac->sme );
4894 }
4895
4896 return (status);
4897}
4898
4899/* ---------------------------------------------------------------------------
4900 \fn sme_EnablePowerSave
4901 \brief Enables one of the power saving modes.
4902 \param hHal - The handle returned by macOpen.
4903 \param psMode - The power saving mode to enable. If BMPS mode is enabled
4904 while the chip is operating in Full Power, PMC will start
4905 a timer that will try to put the chip in BMPS mode after
4906 expiry.
4907 \return eHalStatus
4908 ---------------------------------------------------------------------------*/
4909eHalStatus sme_EnablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
4910{
4911 eHalStatus status = eHAL_STATUS_FAILURE;
4912 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4913
Katya Nigambcb705f2013-12-26 14:26:22 +05304914 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004915 TRACE_CODE_SME_RX_HDD_ENABLE_PWRSAVE, NO_SESSION, psMode));
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 status = sme_AcquireGlobalLock( &pMac->sme );
4917 if ( HAL_STATUS_SUCCESS( status ) )
4918 {
4919 status = pmcEnablePowerSave(hHal, psMode);
4920 sme_ReleaseGlobalLock( &pMac->sme );
4921 }
4922
4923 return (status);
4924}
4925
4926/* ---------------------------------------------------------------------------
4927 \fn sme_DisablePowerSave
4928 \brief Disables one of the power saving modes.
4929 \param hHal - The handle returned by macOpen.
4930 \param psMode - The power saving mode to disable. Disabling does not imply
4931 that device will be brought out of the current PS mode. This
4932 is purely a configuration API.
4933 \return eHalStatus
4934 ---------------------------------------------------------------------------*/
4935eHalStatus sme_DisablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
4936{
4937 eHalStatus status = eHAL_STATUS_FAILURE;
4938 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4939
Katya Nigambcb705f2013-12-26 14:26:22 +05304940 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004941 TRACE_CODE_SME_RX_HDD_DISABLE_PWRSAVE, NO_SESSION, psMode));
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 status = sme_AcquireGlobalLock( &pMac->sme );
4943 if ( HAL_STATUS_SUCCESS( status ) )
4944 {
4945 status = pmcDisablePowerSave(hHal, psMode);
4946 sme_ReleaseGlobalLock( &pMac->sme );
4947 }
4948
4949 return (status);
4950 }
4951
4952/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +05304953+ \fn sme_SetHostPowerSave
4954+ \brief Enables BMPS logic to be controlled by User level apps
4955+ \param hHal - The handle returned by macOpen.
4956+ \param psMode - The power saving mode to disable. Disabling does not imply
4957+ that device will be brought out of the current PS mode. This
4958+ is purely a configuration API.
4959+ \return eHalStatus
4960+ ---------------------------------------------------------------------------*/
4961eHalStatus sme_SetHostPowerSave (tHalHandle hHal, v_BOOL_t psMode)
4962{
4963 eHalStatus status = eHAL_STATUS_FAILURE;
4964 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4965
4966 pMac->pmc.isHostPsEn = psMode;
4967
4968 return (status);
4969}
4970
4971/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 \fn sme_StartAutoBmpsTimer
4973 \brief Starts a timer that periodically polls all the registered
4974 module for entry into Bmps mode. This timer is started only if BMPS is
4975 enabled and whenever the device is in full power.
4976 \param hHal - The handle returned by macOpen.
4977 \return eHalStatus
4978 ---------------------------------------------------------------------------*/
4979eHalStatus sme_StartAutoBmpsTimer ( tHalHandle hHal)
4980{
4981 eHalStatus status = eHAL_STATUS_FAILURE;
4982 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4983
Katya Nigambcb705f2013-12-26 14:26:22 +05304984 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07004985 TRACE_CODE_SME_RX_HDD_START_AUTO_BMPSTIMER, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 status = sme_AcquireGlobalLock( &pMac->sme );
4987 if ( HAL_STATUS_SUCCESS( status ) )
4988 {
4989 status = pmcStartAutoBmpsTimer(hHal);
4990 sme_ReleaseGlobalLock( &pMac->sme );
4991 }
4992
4993 return (status);
4994}
4995/* ---------------------------------------------------------------------------
4996 \fn sme_StopAutoBmpsTimer
4997 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
4998 Stopping the timer does not cause a device state change. Only the timer
4999 is stopped. If "Full Power" is desired, use the sme_RequestFullPower API
5000 \param hHal - The handle returned by macOpen.
5001 \return eHalStatus
5002 ---------------------------------------------------------------------------*/
5003eHalStatus sme_StopAutoBmpsTimer ( tHalHandle hHal)
5004{
5005 eHalStatus status = eHAL_STATUS_FAILURE;
5006 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5007
Katya Nigambcb705f2013-12-26 14:26:22 +05305008 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005009 TRACE_CODE_SME_RX_HDD_STOP_AUTO_BMPSTIMER, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 status = sme_AcquireGlobalLock( &pMac->sme );
5011 if ( HAL_STATUS_SUCCESS( status ) )
5012 {
5013 status = pmcStopAutoBmpsTimer(hHal);
5014 sme_ReleaseGlobalLock( &pMac->sme );
5015 }
5016
5017 return (status);
5018}
5019/* ---------------------------------------------------------------------------
5020 \fn sme_QueryPowerState
5021 \brief Returns the current power state of the device.
5022 \param hHal - The handle returned by macOpen.
5023 \param pPowerState - pointer to location to return power state (LOW or HIGH)
5024 \param pSwWlanSwitchState - ptr to location to return SW WLAN Switch state
5025 \return eHalStatus
5026 ---------------------------------------------------------------------------*/
5027eHalStatus sme_QueryPowerState (
5028 tHalHandle hHal,
5029 tPmcPowerState *pPowerState,
5030 tPmcSwitchState *pSwWlanSwitchState)
5031{
5032 eHalStatus status = eHAL_STATUS_FAILURE;
5033 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5034
5035 status = sme_AcquireGlobalLock( &pMac->sme );
5036 if ( HAL_STATUS_SUCCESS( status ) )
5037 {
5038 status = pmcQueryPowerState (hHal, pPowerState, NULL, pSwWlanSwitchState);
5039 sme_ReleaseGlobalLock( &pMac->sme );
5040 }
5041
5042 return (status);
5043}
5044
5045/* ---------------------------------------------------------------------------
5046 \fn sme_IsPowerSaveEnabled
5047 \brief Checks if the device is able to enter a particular power save mode
5048 This does not imply that the device is in a particular PS mode
5049 \param hHal - The handle returned by macOpen.
5050 \param psMode - the power saving mode
5051 \return eHalStatus
5052 ---------------------------------------------------------------------------*/
5053tANI_BOOLEAN sme_IsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
5054{
5055 eHalStatus status = eHAL_STATUS_FAILURE;
5056 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5057 tANI_BOOLEAN result = false;
5058
Katya Nigambcb705f2013-12-26 14:26:22 +05305059 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005060 TRACE_CODE_SME_RX_HDD_IS_PWRSAVE_ENABLED, NO_SESSION, psMode));
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 status = sme_AcquireGlobalLock( &pMac->sme );
5062 if ( HAL_STATUS_SUCCESS( status ) )
5063 {
5064 result = pmcIsPowerSaveEnabled(hHal, psMode);
5065 sme_ReleaseGlobalLock( &pMac->sme );
5066 return result;
5067 }
5068
5069 return false;
5070}
5071
5072/* ---------------------------------------------------------------------------
5073 \fn sme_RequestFullPower
5074 \brief Request that the device be brought to full power state. When the
5075 device enters Full Power PMC will start a BMPS timer if BMPS PS mode
5076 is enabled. On timer expiry PMC will attempt to put the device in
5077 BMPS mode if following holds true:
5078 - BMPS mode is enabled
5079 - Polling of all modules through the Power Save Check routine passes
5080 - STA is associated to an access point
5081 \param hHal - The handle returned by macOpen.
5082 \param - callbackRoutine Callback routine invoked in case of success/failure
5083 \return eHalStatus - status
5084 eHAL_STATUS_SUCCESS - device brought to full power state
5085 eHAL_STATUS_FAILURE - device cannot be brought to full power state
5086 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
5087 ---------------------------------------------------------------------------*/
5088eHalStatus sme_RequestFullPower (
5089 tHalHandle hHal,
5090 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
5091 void *callbackContext,
5092 tRequestFullPowerReason fullPowerReason)
5093{
5094 eHalStatus status = eHAL_STATUS_FAILURE;
5095 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5096
Katya Nigambcb705f2013-12-26 14:26:22 +05305097 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005098 TRACE_CODE_SME_RX_HDD_REQUEST_FULLPOWER, NO_SESSION, fullPowerReason));
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 status = sme_AcquireGlobalLock( &pMac->sme );
5100 if ( HAL_STATUS_SUCCESS( status ) )
5101 {
5102 status = pmcRequestFullPower(hHal, callbackRoutine, callbackContext, fullPowerReason);
5103 sme_ReleaseGlobalLock( &pMac->sme );
5104 }
5105
5106 return (status);
5107}
5108
5109/* ---------------------------------------------------------------------------
5110 \fn sme_RequestBmps
5111 \brief Request that the device be put in BMPS state. Request will be
5112 accepted only if BMPS mode is enabled and power save check routine
5113 passes.
5114 \param hHal - The handle returned by macOpen.
5115 \param - callbackRoutine Callback routine invoked in case of success/failure
5116 \return eHalStatus
5117 eHAL_STATUS_SUCCESS - device is in BMPS state
5118 eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
5119 eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state
5120 ---------------------------------------------------------------------------*/
5121eHalStatus sme_RequestBmps (
5122 tHalHandle hHal,
5123 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
5124 void *callbackContext)
5125{
5126 eHalStatus status = eHAL_STATUS_FAILURE;
5127 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5128
Katya Nigambcb705f2013-12-26 14:26:22 +05305129 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005130 TRACE_CODE_SME_RX_HDD_REQUEST_BMPS, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 status = sme_AcquireGlobalLock( &pMac->sme );
5132 if ( HAL_STATUS_SUCCESS( status ) )
5133 {
5134 status = pmcRequestBmps(hHal, callbackRoutine, callbackContext);
5135 sme_ReleaseGlobalLock( &pMac->sme );
5136 }
5137
5138 return (status);
5139}
5140
5141
5142/* ---------------------------------------------------------------------------
5143 \fn sme_SetDHCPTillPowerActiveFlag
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07005144 \brief Sets/Clears DHCP related flag in PMC to disable/enable auto BMPS
5145 entry by PMC
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 \param hHal - The handle returned by macOpen.
5147 ---------------------------------------------------------------------------*/
5148void sme_SetDHCPTillPowerActiveFlag(tHalHandle hHal, tANI_U8 flag)
5149{
5150 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5151
Katya Nigambcb705f2013-12-26 14:26:22 +05305152 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005153 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION, flag));
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 // Set/Clear the DHCP flag which will disable/enable auto BMPS entery by PMC
5155 pMac->pmc.remainInPowerActiveTillDHCP = flag;
5156}
5157
5158
5159/* ---------------------------------------------------------------------------
5160 \fn sme_StartUapsd
5161 \brief Request that the device be put in UAPSD state. If the device is in
5162 Full Power it will be put in BMPS mode first and then into UAPSD
5163 mode.
5164 \param hHal - The handle returned by macOpen.
5165 \param - callbackRoutine Callback routine invoked in case of success/failure
5166 eHAL_STATUS_SUCCESS - device is in UAPSD state
5167 eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
5168 eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
5169 eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
5170 \return eHalStatus
5171 ---------------------------------------------------------------------------*/
5172eHalStatus sme_StartUapsd (
5173 tHalHandle hHal,
5174 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
5175 void *callbackContext)
5176{
5177 eHalStatus status = eHAL_STATUS_FAILURE;
5178 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5179
5180 status = sme_AcquireGlobalLock( &pMac->sme );
5181 if ( HAL_STATUS_SUCCESS( status ) )
5182 {
5183 status = pmcStartUapsd(hHal, callbackRoutine, callbackContext);
5184 sme_ReleaseGlobalLock( &pMac->sme );
5185 }
5186
5187 return (status);
5188 }
5189
5190/* ---------------------------------------------------------------------------
5191 \fn sme_StopUapsd
5192 \brief Request that the device be put out of UAPSD state. Device will be
5193 put in in BMPS state after stop UAPSD completes.
5194 \param hHal - The handle returned by macOpen.
5195 \return eHalStatus
5196 eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
5197 eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
5198 ---------------------------------------------------------------------------*/
5199eHalStatus sme_StopUapsd (tHalHandle hHal)
5200{
5201 eHalStatus status = eHAL_STATUS_FAILURE;
5202 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5203
5204 status = sme_AcquireGlobalLock( &pMac->sme );
5205 if ( HAL_STATUS_SUCCESS( status ) )
5206 {
5207 status = pmcStopUapsd(hHal);
5208 sme_ReleaseGlobalLock( &pMac->sme );
5209 }
5210
5211 return (status);
5212}
5213
5214/* ---------------------------------------------------------------------------
5215 \fn sme_RequestStandby
5216 \brief Request that the device be put in standby. It is HDD's responsibility
5217 to bring the chip to full power and do a disassoc before calling
5218 this API.
5219 \param hHal - The handle returned by macOpen.
5220 \param - callbackRoutine Callback routine invoked in case of success/failure
5221 \return eHalStatus
5222 eHAL_STATUS_SUCCESS - device is in Standby mode
5223 eHAL_STATUS_FAILURE - device cannot be put in standby mode
5224 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
5225 ---------------------------------------------------------------------------*/
5226eHalStatus sme_RequestStandby (
5227 tHalHandle hHal,
5228 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
5229 void *callbackContext)
5230{
5231 eHalStatus status = eHAL_STATUS_FAILURE;
5232 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5233
Katya Nigambcb705f2013-12-26 14:26:22 +05305234 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005235 TRACE_CODE_SME_RX_HDD_REQUEST_STANDBY, NO_SESSION, 0));
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305236 smsLog( pMac, LOG1, FL(" called") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 status = sme_AcquireGlobalLock( &pMac->sme );
5238 if ( HAL_STATUS_SUCCESS( status ) )
5239 {
5240 status = pmcRequestStandby(hHal, callbackRoutine, callbackContext);
5241 sme_ReleaseGlobalLock( &pMac->sme );
5242 }
5243
5244 return (status);
5245}
5246
5247/* ---------------------------------------------------------------------------
5248 \fn sme_RegisterPowerSaveCheck
5249 \brief Register a power save check routine that is called whenever
5250 the device is about to enter one of the power save modes.
5251 \param hHal - The handle returned by macOpen.
5252 \param checkRoutine - Power save check routine to be registered
5253 \return eHalStatus
5254 eHAL_STATUS_SUCCESS - successfully registered
5255 eHAL_STATUS_FAILURE - not successfully registered
5256 ---------------------------------------------------------------------------*/
5257eHalStatus sme_RegisterPowerSaveCheck (
5258 tHalHandle hHal,
5259 tANI_BOOLEAN (*checkRoutine) (void *checkContext), void *checkContext)
5260{
5261 eHalStatus status = eHAL_STATUS_FAILURE;
5262 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5263
5264 status = sme_AcquireGlobalLock( &pMac->sme );
5265 if ( HAL_STATUS_SUCCESS( status ) )
5266 {
5267 status = pmcRegisterPowerSaveCheck (hHal, checkRoutine, checkContext);
5268 sme_ReleaseGlobalLock( &pMac->sme );
5269 }
5270
5271 return (status);
5272}
5273
5274/* ---------------------------------------------------------------------------
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05305275 \fn sme_Register11dScanDoneCallback
5276 \brief Register a routine of type csrScanCompleteCallback which is
5277 called whenever an 11d scan is done
5278 \param hHal - The handle returned by macOpen.
5279 \param callback - 11d scan complete routine to be registered
5280 \return eHalStatus
5281 ---------------------------------------------------------------------------*/
5282eHalStatus sme_Register11dScanDoneCallback (
5283 tHalHandle hHal,
5284 csrScanCompleteCallback callback)
5285{
5286 eHalStatus status = eHAL_STATUS_SUCCESS;
5287 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5288
5289 pMac->scan.callback11dScanDone = callback;
5290
5291 return (status);
5292}
5293
5294/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07005295 \fn sme_DeregisterPowerSaveCheck
5296 \brief Deregister a power save check routine
5297 \param hHal - The handle returned by macOpen.
5298 \param checkRoutine - Power save check routine to be deregistered
5299 \return eHalStatus
5300 eHAL_STATUS_SUCCESS - successfully deregistered
5301 eHAL_STATUS_FAILURE - not successfully deregistered
5302 ---------------------------------------------------------------------------*/
5303eHalStatus sme_DeregisterPowerSaveCheck (
5304 tHalHandle hHal,
5305 tANI_BOOLEAN (*checkRoutine) (void *checkContext))
5306{
5307 eHalStatus status = eHAL_STATUS_FAILURE;
5308 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5309
5310 status = sme_AcquireGlobalLock( &pMac->sme );
5311 if ( HAL_STATUS_SUCCESS( status ) )
5312 {
5313 status = pmcDeregisterPowerSaveCheck (hHal, checkRoutine);
5314 sme_ReleaseGlobalLock( &pMac->sme );
5315 }
5316
5317 return (status);
5318}
5319
5320/* ---------------------------------------------------------------------------
5321 \fn sme_RegisterDeviceStateUpdateInd
5322 \brief Register a callback routine that is called whenever
5323 the device enters a new device state (Full Power, BMPS, UAPSD)
5324 \param hHal - The handle returned by macOpen.
5325 \param callbackRoutine - Callback routine to be registered
5326 \param callbackContext - Cookie to be passed back during callback
5327 \return eHalStatus
5328 eHAL_STATUS_SUCCESS - successfully registered
5329 eHAL_STATUS_FAILURE - not successfully registered
5330 ---------------------------------------------------------------------------*/
5331eHalStatus sme_RegisterDeviceStateUpdateInd (
5332 tHalHandle hHal,
5333 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
5334 void *callbackContext)
5335{
5336 eHalStatus status = eHAL_STATUS_FAILURE;
5337 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5338
5339 status = sme_AcquireGlobalLock( &pMac->sme );
5340 if ( HAL_STATUS_SUCCESS( status ) )
5341 {
5342 status = pmcRegisterDeviceStateUpdateInd (hHal, callbackRoutine, callbackContext);
5343 sme_ReleaseGlobalLock( &pMac->sme );
5344 }
5345
5346 return (status);
5347}
5348
5349/* ---------------------------------------------------------------------------
5350 \fn sme_DeregisterDeviceStateUpdateInd
5351 \brief Deregister a routine that was registered for device state changes
5352 \param hHal - The handle returned by macOpen.
5353 \param callbackRoutine - Callback routine to be deregistered
5354 \return eHalStatus
5355 eHAL_STATUS_SUCCESS - successfully deregistered
5356 eHAL_STATUS_FAILURE - not successfully deregistered
5357 ---------------------------------------------------------------------------*/
5358eHalStatus sme_DeregisterDeviceStateUpdateInd (
5359 tHalHandle hHal,
5360 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
5361{
5362 eHalStatus status = eHAL_STATUS_FAILURE;
5363 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5364
5365 status = sme_AcquireGlobalLock( &pMac->sme );
5366 if ( HAL_STATUS_SUCCESS( status ) )
5367 {
5368 status = pmcDeregisterDeviceStateUpdateInd (hHal, callbackRoutine);
5369 sme_ReleaseGlobalLock( &pMac->sme );
5370 }
5371
5372 return (status);
5373}
5374
5375/* ---------------------------------------------------------------------------
5376 \fn sme_WowlAddBcastPattern
5377 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
5378 do a pattern match on these patterns when Wowl is enabled during BMPS
5379 mode. Note that Firmware performs the pattern matching only on
5380 broadcast frames and while Libra is in BMPS mode.
5381 \param hHal - The handle returned by macOpen.
5382 \param pattern - Pattern to be added
5383 \return eHalStatus
5384 eHAL_STATUS_FAILURE Cannot add pattern
5385 eHAL_STATUS_SUCCESS Request accepted.
5386 ---------------------------------------------------------------------------*/
5387eHalStatus sme_WowlAddBcastPattern (
5388 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005389 tpSirWowlAddBcastPtrn pattern,
5390 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005391{
5392 eHalStatus status = eHAL_STATUS_FAILURE;
5393 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05305394 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005395 TRACE_CODE_SME_RX_HDD_WOWL_ADDBCAST_PATTERN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005396 status = sme_AcquireGlobalLock( &pMac->sme );
5397 if ( HAL_STATUS_SUCCESS( status ) )
5398 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005399 status = pmcWowlAddBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 sme_ReleaseGlobalLock( &pMac->sme );
5401 }
5402
5403 return (status);
5404}
5405
5406/* ---------------------------------------------------------------------------
5407 \fn sme_WowlDelBcastPattern
5408 \brief Delete a pattern that was added for Pattern Byte Matching.
5409 \param hHal - The handle returned by macOpen.
5410 \param pattern - Pattern to be deleted
5411 \return eHalStatus
5412 eHAL_STATUS_FAILURE Cannot delete pattern
5413 eHAL_STATUS_SUCCESS Request accepted.
5414 ---------------------------------------------------------------------------*/
5415eHalStatus sme_WowlDelBcastPattern (
5416 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005417 tpSirWowlDelBcastPtrn pattern,
5418 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005419{
5420 eHalStatus status = eHAL_STATUS_FAILURE;
5421 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05305422 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005423 TRACE_CODE_SME_RX_HDD_WOWL_DELBCAST_PATTERN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 status = sme_AcquireGlobalLock( &pMac->sme );
5425 if ( HAL_STATUS_SUCCESS( status ) )
5426 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005427 status = pmcWowlDelBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 sme_ReleaseGlobalLock( &pMac->sme );
5429 }
5430
5431 return (status);
5432}
5433
5434/* ---------------------------------------------------------------------------
5435 \fn sme_EnterWowl
5436 \brief This is the SME API exposed to HDD to request enabling of WOWL mode.
5437 WoWLAN works on top of BMPS mode. If the device is not in BMPS mode,
5438 SME will will cache the information that WOWL has been enabled and
5439 attempt to put the device in BMPS. On entry into BMPS, SME will
5440 enable the WOWL mode.
5441 Note 1: If we exit BMPS mode (someone requests full power), we
5442 will NOT resume WOWL when we go back to BMPS again. Request for full
5443 power (while in WOWL mode) means disable WOWL and go to full power.
5444 Note 2: Both UAPSD and WOWL work on top of BMPS. On entry into BMPS, SME
5445 will give priority to UAPSD and enable only UAPSD if both UAPSD and WOWL
5446 are required. Currently there is no requirement or use case to support
5447 UAPSD and WOWL at the same time.
5448
5449 \param hHal - The handle returned by macOpen.
5450 \param enterWowlCallbackRoutine - Callback routine provided by HDD.
5451 Used for success/failure notification by SME
5452 \param enterWowlCallbackContext - A cookie passed by HDD, that is passed back to HDD
5453 at the time of callback.
5454 \param wakeReasonIndCB - Callback routine provided by HDD.
5455 Used for Wake Reason Indication by SME
5456 \param wakeReasonIndCBContext - A cookie passed by HDD, that is passed back to HDD
5457 at the time of callback.
5458 \return eHalStatus
5459 eHAL_STATUS_SUCCESS Device is already in WoWLAN mode
5460 eHAL_STATUS_FAILURE Device cannot enter WoWLAN mode.
5461 eHAL_STATUS_PMC_PENDING Request accepted. SME will enable WOWL after
5462 BMPS mode is entered.
5463 ---------------------------------------------------------------------------*/
5464eHalStatus sme_EnterWowl (
5465 tHalHandle hHal,
5466 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
5467 void *enterWowlCallbackContext,
5468#ifdef WLAN_WAKEUP_EVENTS
5469 void (*wakeIndicationCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
5470 void *wakeIndicationCBContext,
5471#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005472 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005473{
5474 eHalStatus status = eHAL_STATUS_FAILURE;
5475 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05305476 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005477 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 status = sme_AcquireGlobalLock( &pMac->sme );
5479 if ( HAL_STATUS_SUCCESS( status ) )
5480 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07005481 status = pmcEnterWowl (hHal, enterWowlCallbackRoutine, enterWowlCallbackContext,
Jeff Johnson295189b2012-06-20 16:38:30 -07005482#ifdef WLAN_WAKEUP_EVENTS
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07005483 wakeIndicationCB, wakeIndicationCBContext,
Jeff Johnson295189b2012-06-20 16:38:30 -07005484#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005485 wowlEnterParams, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 sme_ReleaseGlobalLock( &pMac->sme );
5487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 return (status);
5489}
5490/* ---------------------------------------------------------------------------
5491 \fn sme_ExitWowl
5492 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
5493 SME will initiate exit from WoWLAN mode and device will be put in BMPS
5494 mode.
5495 \param hHal - The handle returned by macOpen.
5496 \return eHalStatus
5497 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
5498 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
5499 ---------------------------------------------------------------------------*/
c_hpothu01484c02014-05-16 14:05:15 +05305500eHalStatus sme_ExitWowl (tHalHandle hHal, tWowlExitSource wowlExitSrc)
Jeff Johnson295189b2012-06-20 16:38:30 -07005501{
5502 eHalStatus status = eHAL_STATUS_FAILURE;
5503 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05305504 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005505 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005506 status = sme_AcquireGlobalLock( &pMac->sme );
5507 if ( HAL_STATUS_SUCCESS( status ) )
5508 {
c_hpothu01484c02014-05-16 14:05:15 +05305509 status = pmcExitWowl (hHal, wowlExitSrc);
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 sme_ReleaseGlobalLock( &pMac->sme );
5511 }
5512
5513 return (status);
5514}
5515
5516/* ---------------------------------------------------------------------------
5517
5518 \fn sme_RoamSetKey
5519
5520 \brief To set encryption key. This function should be called only when connected
5521 This is an asynchronous API.
5522
5523 \param pSetKeyInfo - pointer to a caller allocated object of tCsrSetContextInfo
5524
5525 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
5526
5527 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
5528
5529 FAILURE or RESOURCES The API finished and failed.
5530
5531 -------------------------------------------------------------------------------*/
5532eHalStatus sme_RoamSetKey(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 *pRoamId)
5533{
5534 eHalStatus status = eHAL_STATUS_FAILURE;
5535 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5536 tANI_U32 roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 tANI_U32 i;
5538 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005539
Katya Nigambcb705f2013-12-26 14:26:22 +05305540 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005541 TRACE_CODE_SME_RX_HDD_SET_KEY, sessionId, 0));
Jeff Johnsonf89f4b52013-03-27 10:32:44 -07005542 if (pSetKey->keyLength > CSR_MAX_KEY_LEN)
5543 {
5544 smsLog(pMac, LOGE, FL("Invalid key length %d"), pSetKey->keyLength);
5545 return eHAL_STATUS_FAILURE;
5546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 status = sme_AcquireGlobalLock( &pMac->sme );
5548 if ( HAL_STATUS_SUCCESS( status ) )
5549 {
5550 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5551 if(pRoamId)
5552 {
5553 *pRoamId = roamId;
5554 }
5555
Jeff Johnsonf89f4b52013-03-27 10:32:44 -07005556 smsLog(pMac, LOG2, FL("keyLength %d"), pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005557
5558 for(i=0; i<pSetKey->keyLength; i++)
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005559 smsLog(pMac, LOG2, FL("%02x"), pSetKey->Key[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005560
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005561 smsLog(pMac, LOG2, "\n sessionId=%d roamId=%d", sessionId, roamId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005562
5563 pSession = CSR_GET_SESSION(pMac, sessionId);
5564
Jeff Johnson32d95a32012-09-10 13:15:23 -07005565 if(!pSession)
5566 {
5567 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08005568 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005569 return eHAL_STATUS_FAILURE;
5570 }
5571
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
5573 {
Agrawal Ashish65ab9552017-01-05 15:29:17 +05305574#ifdef SAP_AUTH_OFFLOAD
5575 if (pMac->sap_auth_offload_sec_type)
5576 {
5577 smsLog(pMac, LOGE,
5578 FL("No set key is required in sap auth offload enable"));
5579 sme_ReleaseGlobalLock(&pMac->sme);
5580 return eHAL_STATUS_SUCCESS;
5581 }
5582#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
5584 {
5585 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
5586 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
5587 {
5588 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5589 }
5590 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
5591 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
5592 {
5593 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5594 }
5595 }
5596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005597
5598 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
5599 sme_ReleaseGlobalLock( &pMac->sme );
5600 }
Girish Gowli1c2fc802015-01-19 16:18:07 +05305601 if (pMac->roam.configParam.roamDelayStatsEnabled)
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05305602 {
Girish Gowli1c2fc802015-01-19 16:18:07 +05305603 //Store sent PTK key time
5604 if(pSetKey->keyDirection == eSIR_TX_RX)
5605 {
5606 vos_record_roam_event(e_HDD_SET_PTK_REQ, NULL, 0);
5607 }
5608 else if(pSetKey->keyDirection == eSIR_RX_ONLY)
5609 {
5610 vos_record_roam_event(e_HDD_SET_GTK_REQ, NULL, 0);
5611 }
5612 else
5613 {
5614 return (status);
5615 }
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05305616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005617
5618 return (status);
5619}
5620
5621
5622/* ---------------------------------------------------------------------------
5623
5624 \fn sme_RoamRemoveKey
5625
5626 \brief To set encryption key. This is an asynchronous API.
5627
5628 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
5629
5630 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
5631
5632 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
5633
5634 FAILURE or RESOURCES The API finished and failed.
5635
5636 -------------------------------------------------------------------------------*/
5637eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
5638 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
5639{
5640 eHalStatus status = eHAL_STATUS_FAILURE;
5641 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5642 tANI_U32 roamId;
5643
Katya Nigambcb705f2013-12-26 14:26:22 +05305644 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005645 TRACE_CODE_SME_RX_HDD_REMOVE_KEY, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 status = sme_AcquireGlobalLock( &pMac->sme );
5647 if ( HAL_STATUS_SUCCESS( status ) )
5648 {
5649 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5650 if(pRoamId)
5651 {
5652 *pRoamId = roamId;
5653 }
5654 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
5655 sme_ReleaseGlobalLock( &pMac->sme );
5656 }
5657
5658 return (status);
5659}
5660
5661/* ---------------------------------------------------------------------------
5662 \fn sme_GetRssi
5663 \brief a wrapper function that client calls to register a callback to get RSSI
5664
5665 \param callback - SME sends back the requested stats using the callback
5666 \param staId - The station ID for which the stats is requested for
5667 \param pContext - user context to be passed back along with the callback
5668 \param pVosContext - vos context
5669 \return eHalStatus
5670 ---------------------------------------------------------------------------*/
5671eHalStatus sme_GetRssi(tHalHandle hHal,
5672 tCsrRssiCallback callback,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07005673 tANI_U8 staId, tCsrBssid bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 void *pContext, void* pVosContext)
5675{
5676 eHalStatus status = eHAL_STATUS_FAILURE;
5677 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5678
5679 status = sme_AcquireGlobalLock( &pMac->sme );
5680 if ( HAL_STATUS_SUCCESS( status ) )
5681 {
5682 status = csrGetRssi( pMac, callback,
5683 staId, bssId, pContext, pVosContext);
5684 sme_ReleaseGlobalLock( &pMac->sme );
5685 }
5686 return (status);
5687}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305688
5689/* ---------------------------------------------------------------------------
5690 \fn sme_GetSnr
5691 \brief a wrapper function that client calls to register a callback to
5692 get SNR
5693
5694 \param callback - SME sends back the requested stats using the callback
5695 \param staId - The station ID for which the stats is requested for
5696 \param pContext - user context to be passed back along with the callback
5697 \param pVosContext - vos context
5698 \return eHalStatus
5699 ---------------------------------------------------------------------------*/
5700eHalStatus sme_GetSnr(tHalHandle hHal,
5701 tCsrSnrCallback callback,
5702 tANI_U8 staId, tCsrBssid bssId,
5703 void *pContext)
5704{
5705 eHalStatus status = eHAL_STATUS_FAILURE;
5706 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5707
5708 status = sme_AcquireGlobalLock( &pMac->sme );
5709 if ( HAL_STATUS_SUCCESS( status ) )
5710 {
5711 status = csrGetSnr(pMac, callback,
5712 staId, bssId, pContext);
5713 sme_ReleaseGlobalLock( &pMac->sme );
5714 }
5715 return status;
5716}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005717#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005718/* ---------------------------------------------------------------------------
5719 \fn sme_GetRoamRssi
5720 \brief a wrapper function that client calls to register a callback to get Roam RSSI
5721
5722 \param callback - SME sends back the requested stats using the callback
5723 \param staId - The station ID for which the stats is requested for
5724 \param pContext - user context to be passed back along with the callback
5725 \param pVosContext - vos context
5726 \return eHalStatus
5727 ---------------------------------------------------------------------------*/
5728eHalStatus sme_GetRoamRssi(tHalHandle hHal,
5729 tCsrRssiCallback callback,
5730 tANI_U8 staId, tCsrBssid bssId,
5731 void *pContext, void* pVosContext)
5732{
5733 eHalStatus status = eHAL_STATUS_FAILURE;
5734 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5735
5736 status = sme_AcquireGlobalLock( &pMac->sme );
5737 if ( HAL_STATUS_SUCCESS( status ) )
5738 {
5739 status = csrGetRoamRssi( pMac, callback,
5740 staId, bssId, pContext, pVosContext);
5741 sme_ReleaseGlobalLock( &pMac->sme );
5742 }
5743 return (status);
5744}
5745#endif
5746
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005747#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005748/* ---------------------------------------------------------------------------
5749 \fn sme_GetTsmStats
5750 \brief a wrapper function that client calls to register a callback to get TSM Stats
5751
5752 \param callback - SME sends back the requested stats using the callback
5753 \param staId - The station ID for which the stats is requested for
5754 \param pContext - user context to be passed back along with the callback
5755 \param pVosContext - vos context
5756 \return eHalStatus
5757 ---------------------------------------------------------------------------*/
5758eHalStatus sme_GetTsmStats(tHalHandle hHal,
5759 tCsrTsmStatsCallback callback,
5760 tANI_U8 staId, tCsrBssid bssId,
5761 void *pContext, void* pVosContext, tANI_U8 tid)
5762{
5763 eHalStatus status = eHAL_STATUS_FAILURE;
5764 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5765
5766 status = sme_AcquireGlobalLock( &pMac->sme );
5767 if ( HAL_STATUS_SUCCESS( status ) )
5768 {
5769 status = csrGetTsmStats( pMac, callback,
5770 staId, bssId, pContext, pVosContext, tid);
5771 sme_ReleaseGlobalLock( &pMac->sme );
5772 }
5773 return (status);
5774}
5775#endif
5776
5777
Jeff Johnson295189b2012-06-20 16:38:30 -07005778/* ---------------------------------------------------------------------------
5779 \fn sme_GetStatistics
5780 \brief a wrapper function that client calls to register a callback to get
5781 different PHY level statistics from CSR.
5782
5783 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
5784 \param statsMask - The different category/categories of stats requester is looking for
5785 \param callback - SME sends back the requested stats using the callback
5786 \param periodicity - If requester needs periodic update in millisec, 0 means
5787 it's an one time request
5788 \param cache - If requester is happy with cached stats
5789 \param staId - The station ID for which the stats is requested for
5790 \param pContext - user context to be passed back along with the callback
5791 \return eHalStatus
5792 ---------------------------------------------------------------------------*/
5793eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
5794 tANI_U32 statsMask,
5795 tCsrStatsCallback callback,
5796 tANI_U32 periodicity, tANI_BOOLEAN cache,
5797 tANI_U8 staId, void *pContext)
5798{
5799 eHalStatus status = eHAL_STATUS_FAILURE;
5800 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5801
Katya Nigambcb705f2013-12-26 14:26:22 +05305802 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005803 TRACE_CODE_SME_RX_HDD_GET_STATS, NO_SESSION, periodicity));
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 status = sme_AcquireGlobalLock( &pMac->sme );
5805 if ( HAL_STATUS_SUCCESS( status ) )
5806 {
5807 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
5808 periodicity, cache, staId, pContext);
5809 sme_ReleaseGlobalLock( &pMac->sme );
5810 }
5811
5812 return (status);
5813
5814}
5815
Abhishek Singh08aa7762014-12-16 13:59:03 +05305816eHalStatus sme_GetFwStats(tHalHandle hHal, tANI_U32 stats,
5817 void *pContext, tSirFWStatsCallback callback)
Abhishek Singh3ae443b2014-10-08 11:49:27 +05305818{
5819 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5820 vos_msg_t msg;
5821 tSirFWStatsGetReq *pGetFWStatsReq;
5822
5823 smsLog(pMac, LOG1, FL(" ENTER stats = %d "),stats);
5824
5825 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ))
5826 {
5827 pGetFWStatsReq = (tSirFWStatsGetReq *)vos_mem_malloc(sizeof(tSirFWStatsGetReq));
5828 if ( NULL == pGetFWStatsReq)
5829 {
5830 smsLog(pMac, LOGE, FL("Not able to allocate memory for "
5831 "WDA_FW_STATS_GET_REQ"));
5832 sme_ReleaseGlobalLock( &pMac->sme );
5833 return eHAL_STATUS_FAILURE;
5834 }
5835 pGetFWStatsReq->stats = stats;
5836 pGetFWStatsReq->callback = (tSirFWStatsCallback)callback;
Abhishek Singh08aa7762014-12-16 13:59:03 +05305837 pGetFWStatsReq->data = pContext;
Abhishek Singh3ae443b2014-10-08 11:49:27 +05305838
5839 msg.type = WDA_FW_STATS_GET_REQ;
5840 msg.reserved = 0;
5841 msg.bodyptr = pGetFWStatsReq;
5842 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_WDA, &msg))
5843 {
5844 smsLog(pMac, LOGE,
5845 FL("Not able to post WDA_FW_STATS_GET_REQ message to HAL"));
5846 vos_mem_free(pGetFWStatsReq);
5847 sme_ReleaseGlobalLock( &pMac->sme );
5848 return eHAL_STATUS_FAILURE;
5849 }
5850 sme_ReleaseGlobalLock( &pMac->sme );
5851 return eHAL_STATUS_SUCCESS;
5852 }
5853 return eHAL_STATUS_FAILURE;
5854}
5855
Jeff Johnson295189b2012-06-20 16:38:30 -07005856/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305857 \fn smeGetTLSTAState
5858 \helper function to get the TL STA State whenever the function is called.
5859
5860 \param staId - The staID to be passed to the TL
5861 to get the relevant TL STA State
5862 \return the state as tANI_U16
5863 ---------------------------------------------------------------------------*/
5864tANI_U16 smeGetTLSTAState(tHalHandle hHal, tANI_U8 staId)
5865{
5866 tANI_U16 tlSTAState = TL_INIT_STATE;
5867 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5868 eHalStatus status = eHAL_STATUS_FAILURE;
5869
5870 status = sme_AcquireGlobalLock( &pMac->sme );
5871 if ( HAL_STATUS_SUCCESS( status ) )
5872 {
5873 tlSTAState = csrGetTLSTAState( pMac, staId);
5874 sme_ReleaseGlobalLock( &pMac->sme );
5875 }
5876
5877 return tlSTAState;
5878}
5879
5880/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07005881
5882 \fn sme_GetCountryCode
5883
5884 \brief To return the current country code. If no country code is applied, default country code is
5885 used to fill the buffer.
5886 If 11d supported is turned off, an error is return and the last applied/default country code is used.
5887 This is a synchronous API.
5888
5889 \param pBuf - pointer to a caller allocated buffer for returned country code.
5890
5891 \param pbLen For input, this parameter indicates how big is the buffer.
5892 Upon return, this parameter has the number of bytes for country. If pBuf
5893 doesn't have enough space, this function returns
5894 fail status and this parameter contains the number that is needed.
5895
5896 \return eHalStatus SUCCESS.
5897
5898 FAILURE or RESOURCES The API finished and failed.
5899
5900 -------------------------------------------------------------------------------*/
5901eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
5902{
5903 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5904
Katya Nigambcb705f2013-12-26 14:26:22 +05305905 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005906 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
5907
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
5909}
5910
5911
5912/* ---------------------------------------------------------------------------
5913
5914 \fn sme_SetCountryCode
5915
5916 \brief To change the current/default country code.
5917 If 11d supported is turned off, an error is return.
5918 This is a synchronous API.
5919
5920 \param pCountry - pointer to a caller allocated buffer for the country code.
5921
5922 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
5923 whether a reset is required.
5924
5925 \return eHalStatus SUCCESS.
5926
5927 FAILURE or RESOURCES The API finished and failed.
5928
5929 -------------------------------------------------------------------------------*/
5930eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
5931{
5932 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5933
Katya Nigambcb705f2013-12-26 14:26:22 +05305934 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07005935 TRACE_CODE_SME_RX_HDD_SET_CNTRYCODE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
5937}
5938
5939
5940/* ---------------------------------------------------------------------------
5941 \fn sme_ResetCountryCodeInformation
5942 \brief this function is to reset the country code current being used back to EEPROM default
5943 this includes channel list and power setting. This is a synchronous API.
5944 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
5945 a restart is needed to apply the change
5946 \return eHalStatus
5947 -------------------------------------------------------------------------------*/
5948eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
5949{
5950 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5951
5952 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
5953}
5954
5955
5956/* ---------------------------------------------------------------------------
5957 \fn sme_GetSupportedCountryCode
5958 \brief this function is to get a list of the country code current being supported
5959 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
5960 this has the country code list. 3 bytes for each country code. This may be NULL if
5961 caller wants to know the needed byte count.
5962 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
5963 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
5964 \return eHalStatus
5965 -------------------------------------------------------------------------------*/
5966eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
5967{
5968 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5969
5970 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
5971}
5972
5973
5974/* ---------------------------------------------------------------------------
5975 \fn sme_GetCurrentRegulatoryDomain
5976 \brief this function is to get the current regulatory domain. This is a synchronous API.
5977 This function must be called after CFG is downloaded and all the band/mode setting already passed into
5978 SME. The function fails if 11d support is turned off.
5979 \param pDomain - Caller allocated buffer to return the current domain.
5980 \return eHalStatus SUCCESS.
5981
5982 FAILURE or RESOURCES The API finished and failed.
5983 -------------------------------------------------------------------------------*/
5984eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
5985{
5986 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5987 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
5988
5989 if( pDomain )
5990 {
5991 if( csrIs11dSupported( pMac ) )
5992 {
5993 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
5994 status = eHAL_STATUS_SUCCESS;
5995 }
5996 else
5997 {
5998 status = eHAL_STATUS_FAILURE;
5999 }
6000 }
6001
6002 return ( status );
6003}
6004
6005
6006/* ---------------------------------------------------------------------------
6007 \fn sme_SetRegulatoryDomain
6008 \brief this function is to set the current regulatory domain.
6009 This function must be called after CFG is downloaded and all the band/mode setting already passed into
6010 SME. This is a synchronous API.
6011 \param domainId - indicate the domain (defined in the driver) needs to set to.
6012 See v_REGDOMAIN_t for definition
6013 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
6014 a restart is needed to apply the change
6015 \return eHalStatus
6016 -------------------------------------------------------------------------------*/
6017eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6018{
6019 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6020
6021 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
6022}
6023
6024
6025/* ---------------------------------------------------------------------------
6026
6027 \fn sme_GetRegulatoryDomainForCountry
6028
6029 \brief To return a regulatory domain base on a country code. This is a synchronous API.
6030
6031 \param pCountry - pointer to a caller allocated buffer for input country code.
6032
6033 \param pDomainId Upon successful return, it is the domain that country belongs to.
6034 If it is NULL, returning success means that the country code is known.
6035
6036 \return eHalStatus SUCCESS.
6037
6038 FAILURE or RESOURCES The API finished and failed.
6039
6040 -------------------------------------------------------------------------------*/
6041eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
6042{
6043 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6044
Kiet Lam6c583332013-10-14 05:37:09 +05306045 return csrGetRegulatoryDomainForCountry(pMac, pCountry, pDomainId,
6046 COUNTRY_QUERY);
Jeff Johnson295189b2012-06-20 16:38:30 -07006047}
6048
6049
6050
6051
6052/* ---------------------------------------------------------------------------
6053
6054 \fn sme_GetSupportedRegulatoryDomains
6055
6056 \brief To return a list of supported regulatory domains. This is a synchronous API.
6057
6058 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
6059
6060 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
6061 Upon return, this parameter has the number for supported domains. If pDomains
6062 doesn't have enough space for all the supported domains, this function returns
6063 fail status and this parameter contains the number that is needed.
6064
6065 \return eHalStatus SUCCESS.
6066
6067 FAILURE or RESOURCES The API finished and failed.
6068
6069 -------------------------------------------------------------------------------*/
6070eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
6071{
6072 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6073
6074 //We support all domains for now
6075 if( pNumDomains )
6076 {
6077 if( NUM_REG_DOMAINS <= *pNumDomains )
6078 {
6079 status = eHAL_STATUS_SUCCESS;
6080 }
6081 *pNumDomains = NUM_REG_DOMAINS;
6082 }
6083 if( HAL_STATUS_SUCCESS( status ) )
6084 {
6085 if( pDomains )
6086 {
6087 pDomains[0] = REGDOMAIN_FCC;
6088 pDomains[1] = REGDOMAIN_ETSI;
6089 pDomains[2] = REGDOMAIN_JAPAN;
6090 pDomains[3] = REGDOMAIN_WORLD;
6091 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
6092 pDomains[5] = REGDOMAIN_APAC;
6093 pDomains[6] = REGDOMAIN_KOREA;
6094 pDomains[7] = REGDOMAIN_HI_5GHZ;
6095 pDomains[8] = REGDOMAIN_NO_5GHZ;
6096 }
6097 else
6098 {
6099 status = eHAL_STATUS_INVALID_PARAMETER;
6100 }
6101 }
6102
6103 return ( status );
6104}
6105
6106
6107//some support functions
6108tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
6109{
6110 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6111
6112 return ( csrIs11dSupported( pMac ) );
6113}
6114
6115
6116tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
6117{
6118 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6119
6120 return ( csrIs11hSupported( pMac ) );
6121}
6122
6123
6124tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
6125{
6126 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6127
6128 return ( csrIsWmmSupported( pMac ) );
6129}
6130
6131//Upper layer to get the list of the base channels to scan for passively 11d info from csr
6132eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
6133{
6134 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6135
6136 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
6137}
6138
6139/* ---------------------------------------------------------------------------
6140
6141 \fn sme_ChangeCountryCode
6142
6143 \brief Change Country code from upperlayer during WLAN driver operation.
6144 This is a synchronous API.
6145
6146 \param hHal - The handle returned by macOpen.
6147
6148 \param pCountry New Country Code String
6149
Abhishek Singha306a442013-11-07 18:39:01 +05306150 \param sendRegHint If we want to send reg hint to nl80211
6151
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 \return eHalStatus SUCCESS.
6153
6154 FAILURE or RESOURCES The API finished and failed.
6155
6156 -------------------------------------------------------------------------------*/
6157eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
6158 tSmeChangeCountryCallback callback,
6159 tANI_U8 *pCountry,
6160 void *pContext,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05306161 void* pVosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05306162 tAniBool countryFromUserSpace,
6163 tAniBool sendRegHint )
Jeff Johnson295189b2012-06-20 16:38:30 -07006164{
6165 eHalStatus status = eHAL_STATUS_FAILURE;
6166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6167 vos_msg_t msg;
6168 tAniChangeCountryCodeReq *pMsg;
6169
Katya Nigambcb705f2013-12-26 14:26:22 +05306170 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006171 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 status = sme_AcquireGlobalLock( &pMac->sme );
6173 if ( HAL_STATUS_SUCCESS( status ) )
6174 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006175 smsLog(pMac, LOG1, FL(" called"));
Amar Singhal97a2d992013-11-19 10:58:07 -08006176
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05306177 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true) &&
Amar Singhal97a2d992013-11-19 10:58:07 -08006178 (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
6179 {
6180
6181 smsLog(pMac, LOGW, "Set Country Code Fail since the STA is associated and userspace does not have priority ");
6182
6183 sme_ReleaseGlobalLock( &pMac->sme );
6184 status = eHAL_STATUS_FAILURE;
6185 return status;
6186 }
6187
Kiet Lam64c1b492013-07-12 13:56:44 +05306188 pMsg = vos_mem_malloc(sizeof(tAniChangeCountryCodeReq));
6189 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006191 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req");
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08006192 sme_ReleaseGlobalLock( &pMac->sme );
Kiet Lam64c1b492013-07-12 13:56:44 +05306193 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 }
6195
6196 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
6197 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
Kiet Lam64c1b492013-07-12 13:56:44 +05306198 vos_mem_copy(pMsg->countryCode, pCountry, 3);
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05306199 pMsg->countryFromUserSpace = countryFromUserSpace;
Abhishek Singha306a442013-11-07 18:39:01 +05306200 pMsg->sendRegHint = sendRegHint;
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 pMsg->changeCCCallback = callback;
6202 pMsg->pDevContext = pContext;
6203 pMsg->pVosContext = pVosContext;
6204
6205 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
6206 msg.bodyptr = pMsg;
6207 msg.reserved = 0;
6208
6209 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
6210 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006211 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +05306212 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 status = eHAL_STATUS_FAILURE;
6214 }
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006215 smsLog(pMac, LOG1, FL(" returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 sme_ReleaseGlobalLock( &pMac->sme );
6217 }
6218
6219 return (status);
6220}
Amar Singhal0d15bd52013-10-12 23:13:13 -07006221
6222/*--------------------------------------------------------------------------
6223
6224 \fn sme_GenericChangeCountryCode
6225
6226 \brief Change Country code from upperlayer during WLAN driver operation.
6227 This is a synchronous API.
6228
6229 \param hHal - The handle returned by macOpen.
6230
6231 \param pCountry New Country Code String
6232
6233 \param reg_domain regulatory domain
6234
6235 \return eHalStatus SUCCESS.
6236
6237 FAILURE or RESOURCES The API finished and failed.
6238
6239-----------------------------------------------------------------------------*/
6240eHalStatus sme_GenericChangeCountryCode( tHalHandle hHal,
6241 tANI_U8 *pCountry,
6242 v_REGDOMAIN_t reg_domain)
6243{
6244 eHalStatus status = eHAL_STATUS_FAILURE;
6245 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6246 vos_msg_t msg;
6247 tAniGenericChangeCountryCodeReq *pMsg;
6248
Kiet Lamcffc5862013-10-30 16:28:45 +05306249 if (NULL == pMac)
6250 {
6251 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
6252 "%s: pMac is null", __func__);
6253 return status;
6254 }
6255
Amar Singhal0d15bd52013-10-12 23:13:13 -07006256 status = sme_AcquireGlobalLock( &pMac->sme );
6257 if ( HAL_STATUS_SUCCESS( status ) )
6258 {
6259 smsLog(pMac, LOG1, FL(" called"));
Kiet Lamf2f201e2013-11-16 21:24:16 +05306260 pMsg = vos_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
6261 if (NULL == pMsg)
Amar Singhal0d15bd52013-10-12 23:13:13 -07006262 {
6263 smsLog(pMac, LOGE, " sme_GenericChangeCountryCode: failed to allocate mem for req");
6264 sme_ReleaseGlobalLock( &pMac->sme );
Kiet Lamf2f201e2013-11-16 21:24:16 +05306265 return eHAL_STATUS_FAILURE;
Amar Singhal0d15bd52013-10-12 23:13:13 -07006266 }
6267
6268 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE);
6269 pMsg->msgLen = (tANI_U16)sizeof(tAniGenericChangeCountryCodeReq);
Sameer Thalappil7324e8b2014-01-15 10:32:54 -08006270 vos_mem_copy(pMsg->countryCode, pCountry, 2);
Dino Mycle6c77a962014-08-19 15:34:23 +05306271
6272 pMsg->countryCode[2] = ' '; /* For ASCII space */
6273
Amar Singhal0d15bd52013-10-12 23:13:13 -07006274 pMsg->domain_index = reg_domain;
6275
6276 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
6277 msg.bodyptr = pMsg;
6278 msg.reserved = 0;
6279
6280 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
6281 {
6282 smsLog(pMac, LOGE, "sme_GenericChangeCountryCode failed to post msg to self");
Kiet Lamf2f201e2013-11-16 21:24:16 +05306283 vos_mem_free(pMsg);
Amar Singhal0d15bd52013-10-12 23:13:13 -07006284 status = eHAL_STATUS_FAILURE;
6285 }
6286 smsLog(pMac, LOG1, FL(" returned"));
6287 sme_ReleaseGlobalLock( &pMac->sme );
6288 }
6289
6290 return (status);
6291}
Mihir Shetee1093ba2014-01-21 20:13:32 +05306292
6293/* ---------------------------------------------------------------------------
6294
6295 \fn sme_InitChannels
6296
6297 \brief Used to initialize CSR channel lists while driver loading
6298
6299 \param hHal - global pMac structure
6300
6301 \return eHalStatus SUCCESS.
6302
6303 FAILURE or RESOURCES The API finished and failed.
6304
6305 -------------------------------------------------------------------------------*/
6306eHalStatus sme_InitChannels(tHalHandle hHal)
6307{
6308 eHalStatus status = eHAL_STATUS_FAILURE;
6309 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6310
6311 if (NULL == pMac)
6312 {
6313 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
6314 "%s: pMac is null", __func__);
6315 return status;
6316 }
6317
Vinay Krishna Erannab9295ae2014-05-09 13:43:23 +05306318 status = csrInitChannels(pMac);
6319
Mihir Shetee1093ba2014-01-21 20:13:32 +05306320 return status;
6321}
6322
Mihir Shete04206452014-11-20 17:50:58 +05306323#ifdef CONFIG_ENABLE_LINUX_REG
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05306324/*-------------------------------------------------------------------------
6325 \fn sme_InitChannelsForCC
6326
6327 \brief Used to issue regulatory hint to user
6328
6329 \param hHal - global pMac structure
6330
6331 \return eHalStatus SUCCESS.
6332
6333 FAILURE or RESOURCES The API finished and failed.
6334--------------------------------------------------------------------------*/
6335
Agarwal Ashish6db9d532014-09-30 18:19:10 +05306336eHalStatus sme_InitChannelsForCC(tHalHandle hHal, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05306337{
6338 eHalStatus status = eHAL_STATUS_FAILURE;
6339 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6340
6341 if (NULL == pMac)
6342 {
6343 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
6344 "%s: pMac is null", __func__);
6345 return status;
6346 }
Agarwal Ashish6db9d532014-09-30 18:19:10 +05306347 status = csrInitChannelsForCC(pMac, init);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05306348
6349 return status;
6350}
Mihir Shete04206452014-11-20 17:50:58 +05306351#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05306352
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306353/* ---------------------------------------------------------------------------
6354
6355 \fn sme_DHCPStartInd
6356
6357 \brief API to signal the FW about the DHCP Start event.
6358
6359 \param hHal - HAL handle for device.
6360
6361 \param device_mode - mode(AP,SAP etc) of the device.
6362
6363 \param macAddr - MAC address of the device.
6364
6365 \return eHalStatus SUCCESS.
6366
6367 FAILURE or RESOURCES The API finished and failed.
6368 --------------------------------------------------------------------------*/
6369eHalStatus sme_DHCPStartInd( tHalHandle hHal,
6370 tANI_U8 device_mode,
c_hpothu0b0cab72014-02-13 21:52:40 +05306371 tANI_U8 sessionId )
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306372{
6373 eHalStatus status;
6374 VOS_STATUS vosStatus;
6375 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6376 vos_msg_t vosMessage;
6377 tAniDHCPInd *pMsg;
c_hpothu0b0cab72014-02-13 21:52:40 +05306378 tCsrRoamSession *pSession;
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306379
6380 status = sme_AcquireGlobalLock(&pMac->sme);
6381 if ( eHAL_STATUS_SUCCESS == status)
6382 {
c_hpothu0b0cab72014-02-13 21:52:40 +05306383 pSession = CSR_GET_SESSION( pMac, sessionId );
6384
6385 if (!pSession)
6386 {
6387 smsLog(pMac, LOGE, FL("session %d not found "), sessionId);
6388 sme_ReleaseGlobalLock( &pMac->sme );
6389 return eHAL_STATUS_FAILURE;
6390 }
Arif Hussaine709d372016-12-06 19:49:31 +05306391 pSession->dhcp_done = false;
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306392 pMsg = (tAniDHCPInd*)vos_mem_malloc(sizeof(tAniDHCPInd));
6393 if (NULL == pMsg)
6394 {
6395 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6396 "%s: Not able to allocate memory for dhcp start", __func__);
6397 sme_ReleaseGlobalLock( &pMac->sme );
6398 return eHAL_STATUS_FAILURE;
6399 }
6400 pMsg->msgType = WDA_DHCP_START_IND;
6401 pMsg->msgLen = (tANI_U16)sizeof(tAniDHCPInd);
6402 pMsg->device_mode = device_mode;
c_hpothu0b0cab72014-02-13 21:52:40 +05306403 vos_mem_copy(pMsg->macAddr, pSession->connectedProfile.bssid,
6404 sizeof(tSirMacAddr));
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306405 vosMessage.type = WDA_DHCP_START_IND;
6406 vosMessage.bodyptr = pMsg;
6407 vosMessage.reserved = 0;
6408
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05306409 MTRACE(vos_trace(VOS_MODULE_ID_SME,
6410 TRACE_CODE_SME_TX_WDA_MSG, sessionId, vosMessage.type));
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306411 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6412 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6413 {
6414 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6415 "%s: Post DHCP Start MSG fail", __func__);
6416 vos_mem_free(pMsg);
6417 status = eHAL_STATUS_FAILURE;
6418 }
6419 sme_ReleaseGlobalLock( &pMac->sme );
6420 }
6421 return (status);
6422}
6423/* ---------------------------------------------------------------------------
6424 \fn sme_DHCPStopInd
6425
6426 \brief API to signal the FW about the DHCP complete event.
6427
6428 \param hHal - HAL handle for device.
6429
6430 \param device_mode - mode(AP, SAP etc) of the device.
6431
6432 \param macAddr - MAC address of the device.
6433
6434 \return eHalStatus SUCCESS.
6435 FAILURE or RESOURCES The API finished and failed.
6436 --------------------------------------------------------------------------*/
6437eHalStatus sme_DHCPStopInd( tHalHandle hHal,
6438 tANI_U8 device_mode,
c_hpothu0b0cab72014-02-13 21:52:40 +05306439 tANI_U8 sessionId )
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306440{
6441 eHalStatus status;
6442 VOS_STATUS vosStatus;
6443 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6444 vos_msg_t vosMessage;
6445 tAniDHCPInd *pMsg;
c_hpothu0b0cab72014-02-13 21:52:40 +05306446 tCsrRoamSession *pSession;
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306447
6448 status = sme_AcquireGlobalLock(&pMac->sme);
6449 if ( eHAL_STATUS_SUCCESS == status)
6450 {
c_hpothu0b0cab72014-02-13 21:52:40 +05306451 pSession = CSR_GET_SESSION( pMac, sessionId );
6452
6453 if (!pSession)
6454 {
6455 smsLog(pMac, LOGE, FL("session %d not found "), sessionId);
6456 sme_ReleaseGlobalLock( &pMac->sme );
6457 return eHAL_STATUS_FAILURE;
6458 }
Arif Hussaine709d372016-12-06 19:49:31 +05306459 pSession->dhcp_done = true;
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306460 pMsg = (tAniDHCPInd*)vos_mem_malloc(sizeof(tAniDHCPInd));
6461 if (NULL == pMsg)
6462 {
6463 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6464 "%s: Not able to allocate memory for dhcp stop", __func__);
6465 sme_ReleaseGlobalLock( &pMac->sme );
6466 return eHAL_STATUS_FAILURE;
6467 }
6468
6469 pMsg->msgType = WDA_DHCP_STOP_IND;
6470 pMsg->msgLen = (tANI_U16)sizeof(tAniDHCPInd);
6471 pMsg->device_mode = device_mode;
c_hpothu0b0cab72014-02-13 21:52:40 +05306472 vos_mem_copy(pMsg->macAddr, pSession->connectedProfile.bssid,
6473 sizeof(tSirMacAddr));
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306474
6475 vosMessage.type = WDA_DHCP_STOP_IND;
6476 vosMessage.bodyptr = pMsg;
6477 vosMessage.reserved = 0;
6478
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05306479 MTRACE(vos_trace(VOS_MODULE_ID_SME,
6480 TRACE_CODE_SME_TX_WDA_MSG, sessionId, vosMessage.type));
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05306481 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6482 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6483 {
6484 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6485 "%s: Post DHCP Stop MSG fail", __func__);
6486 vos_mem_free(pMsg);
6487 status = eHAL_STATUS_FAILURE;
6488 }
6489
6490 sme_ReleaseGlobalLock( &pMac->sme );
6491 }
6492 return (status);
6493}
6494
Abhishek Singh00b71972016-01-07 10:51:04 +05306495#ifdef WLAN_FEATURE_RMC
6496/*---------------------------------------------------------------------------
6497
6498 \fn sme_TXFailMonitorStopInd
6499
6500 \brief API to signal the FW to start monitoring TX failures
6501
6502 \return eHalStatus SUCCESS.
6503
6504 FAILURE or RESOURCES The API finished and failed.
6505 --------------------------------------------------------------------------*/
6506eHalStatus sme_TXFailMonitorStartStopInd(tHalHandle hHal, tANI_U8 tx_fail_count,
6507 void * txFailIndCallback)
6508{
6509 eHalStatus status;
6510 VOS_STATUS vosStatus;
6511 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6512 vos_msg_t vosMessage;
6513 tAniTXFailMonitorInd *pMsg;
6514
6515 status = sme_AcquireGlobalLock(&pMac->sme);
6516 if ( eHAL_STATUS_SUCCESS == status)
6517 {
6518 pMsg = (tAniTXFailMonitorInd*)
6519 vos_mem_malloc(sizeof(tAniTXFailMonitorInd));
6520 if (NULL == pMsg)
6521 {
6522 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6523 "%s: Failed to allocate memory", __func__);
6524 sme_ReleaseGlobalLock( &pMac->sme );
6525 return eHAL_STATUS_FAILURE;
6526 }
6527
6528 pMsg->msgType = WDA_TX_FAIL_MONITOR_IND;
6529 pMsg->msgLen = (tANI_U16)sizeof(tAniTXFailMonitorInd);
6530
6531 //tx_fail_count = 0 should disable the Monitoring in FW
6532 pMsg->tx_fail_count = tx_fail_count;
6533 pMsg->txFailIndCallback = txFailIndCallback;
6534
6535 vosMessage.type = WDA_TX_FAIL_MONITOR_IND;
6536 vosMessage.bodyptr = pMsg;
6537 vosMessage.reserved = 0;
6538
6539 MTRACE(vos_trace(VOS_MODULE_ID_SME,
6540 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
6541 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage );
6542 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6543 {
6544 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6545 "%s: Post TX Fail monitor Start MSG fail", __func__);
6546 vos_mem_free(pMsg);
6547 status = eHAL_STATUS_FAILURE;
6548 }
6549 sme_ReleaseGlobalLock( &pMac->sme );
6550 }
6551 return (status);
6552}
6553#endif /* WLAN_FEATURE_RMC */
Jeff Johnson295189b2012-06-20 16:38:30 -07006554
Kapil Gupta04ab1992016-06-26 13:36:51 +05306555#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
6556void sme_PERRoamScanStartStop(void *hHal, tANI_U8 start)
6557{
6558 eHalStatus status;
6559 VOS_STATUS vosStatus;
6560 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6561 vos_msg_t vosMessage;
6562 tPERRoamScanStart *pMsg;
6563
6564 status = sme_AcquireGlobalLock(&pMac->sme);
6565 if ( eHAL_STATUS_SUCCESS == status)
6566 {
6567 pMsg = (tPERRoamScanStart *)
6568 vos_mem_malloc(sizeof(tPERRoamScanStart));
6569 if (NULL == pMsg)
6570 {
6571 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6572 "%s: Failed to allocate memory", __func__);
6573 sme_ReleaseGlobalLock( &pMac->sme );
6574 return;
6575 }
6576
6577 pMsg->msgType = WDA_PER_ROAM_SCAN_TRIGGER_REQ;
6578 pMsg->msgLen = (tANI_U16)sizeof(*pMsg);
6579
6580 pMsg->start = start;
6581
6582 vosMessage.type = WDA_PER_ROAM_SCAN_TRIGGER_REQ;
6583 vosMessage.bodyptr = pMsg;
6584 vosMessage.reserved = 0;
6585
6586 MTRACE(vos_trace(VOS_MODULE_ID_SME,
6587 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
6588 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage );
6589 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6590 {
6591 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6592 "%s: Post TX Fail monitor Start MSG fail", __func__);
6593 vos_mem_free(pMsg);
6594 status = eHAL_STATUS_FAILURE;
6595 }
6596 sme_ReleaseGlobalLock(&pMac->sme);
6597 }
6598}
6599
6600/* sme_set_per_roam_rxconfig : set PER config for Rx monitoring
6601 * @hHal: hal pointer
6602 * @staId: station id
6603 * @minRate : rate at which to start monitoring
6604 * @maxRate : Rate at which to stop monitoring
6605 * @minPercentage: minimum % of packets required in minRate to trigger a scan
6606 * @minPktRequired: minimum number of packets required to trigger a scan
6607 * @waitPeriodForNextPERScan: time to wait before start monitoring again once
6608 * roam scan is triggered
6609 * */
6610
6611VOS_STATUS sme_set_per_roam_rxconfig (tHalHandle hHal, v_U8_t staId,
6612 v_U16_t minRate, v_U16_t maxRate,
6613 v_U8_t minPercentage, v_U16_t minPktRequired,
6614 v_U64_t waitPeriodForNextPERScan)
6615{
6616 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6617 v_VOID_t * pVosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
6618 WLANTL_StartRxRateMonitor(pVosContext, staId, minRate, maxRate,
6619 minPercentage, minPktRequired,
6620 (void *) hHal, waitPeriodForNextPERScan,
6621 sme_PERRoamScanStartStop);
6622 pMac->PERroamCandidatesCnt = 0;
6623 return eHAL_STATUS_SUCCESS;
6624}
6625
6626/* sme_unset_per_roam_rxconfig : unset PER config for Rx monitoring
6627 * */
6628VOS_STATUS sme_unset_per_roam_rxconfig (tHalHandle hHal)
6629{
6630 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6631 v_VOID_t * pVosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
6632 vos_mem_set(pMac->previousRoamApInfo,
6633 sizeof(tSirRoamAPInfo) * SIR_PER_ROAM_MAX_CANDIDATE_CNT, 0);
6634 WLANTL_StopRxRateMonitor(pVosContext);
6635 return eHAL_STATUS_SUCCESS;
6636}
6637#endif
6638
Jeff Johnson295189b2012-06-20 16:38:30 -07006639/* ---------------------------------------------------------------------------
6640 \fn sme_BtcSignalBtEvent
6641 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
6642 BT event type and the current operating mode of Libra (full power,
6643 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
6644 would be employed.
6645 \param hHal - The handle returned by macOpen.
6646 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
6647 Caller owns the memory and is responsible for freeing it.
6648 \return VOS_STATUS
6649 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
6650 if BTC execution mode is set to BTC_WLAN_ONLY
6651 or BTC_PTA_ONLY.
6652 VOS_STATUS_SUCCESS BT Event passed to HAL
6653 ---------------------------------------------------------------------------*/
6654VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
6655{
6656 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006657
Jeff Johnson295189b2012-06-20 16:38:30 -07006658#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6659 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6660
Katya Nigambcb705f2013-12-26 14:26:22 +05306661 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006662 TRACE_CODE_SME_RX_HDD_BTC_SIGNALEVENT, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6664 {
6665 status = btcSignalBTEvent (hHal, pBtEvent);
6666 sme_ReleaseGlobalLock( &pMac->sme );
6667 }
6668#endif
6669 return (status);
6670}
6671
6672/* ---------------------------------------------------------------------------
6673 \fn sme_BtcSetConfig
6674 \brief API to change the current Bluetooth Coexistence (BTC) configuration
6675 This function should be invoked only after CFG download has completed.
6676 Calling it after sme_HDDReadyInd is recommended.
6677 \param hHal - The handle returned by macOpen.
6678 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
6679 Caller owns the memory and is responsible for freeing it.
6680 \return VOS_STATUS
6681 VOS_STATUS_E_FAILURE Config not passed to HAL.
6682 VOS_STATUS_SUCCESS Config passed to HAL
6683 ---------------------------------------------------------------------------*/
6684VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
6685{
6686 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6687#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6688 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05306689 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006690 TRACE_CODE_SME_RX_HDD_BTC_SETCONFIG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6692 {
6693 status = btcSetConfig (hHal, pSmeBtcConfig);
6694 sme_ReleaseGlobalLock( &pMac->sme );
6695 }
6696#endif
6697 return (status);
6698}
6699
6700/* ---------------------------------------------------------------------------
6701 \fn sme_BtcGetConfig
6702 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
6703 \param hHal - The handle returned by macOpen.
6704 \param pSmeBtcConfig - Pointer to a caller allocated object of type
6705 tSmeBtcConfig. Caller owns the memory and is responsible
6706 for freeing it.
6707 \return VOS_STATUS
6708 VOS_STATUS_E_FAILURE - failure
6709 VOS_STATUS_SUCCESS success
6710 ---------------------------------------------------------------------------*/
6711VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
6712{
6713 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6714#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6715 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6716
Katya Nigambcb705f2013-12-26 14:26:22 +05306717 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006718 TRACE_CODE_SME_RX_HDD_BTC_GETCONFIG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6720 {
6721 status = btcGetConfig (hHal, pSmeBtcConfig);
6722 sme_ReleaseGlobalLock( &pMac->sme );
6723 }
6724#endif
6725 return (status);
6726}
6727/* ---------------------------------------------------------------------------
6728 \fn sme_SetCfgPrivacy
6729 \brief API to set configure privacy parameters
6730 \param hHal - The handle returned by macOpen.
6731 \param pProfile - Pointer CSR Roam profile.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006732 \param fPrivacy - This parameter indicates status of privacy
Jeff Johnson295189b2012-06-20 16:38:30 -07006733
6734 \return void
6735 ---------------------------------------------------------------------------*/
6736void sme_SetCfgPrivacy( tHalHandle hHal,
6737 tCsrRoamProfile *pProfile,
6738 tANI_BOOLEAN fPrivacy
6739 )
6740{
6741 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05306742 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006743 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006744 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6745 {
6746 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
6747 sme_ReleaseGlobalLock( &pMac->sme );
6748 }
6749}
6750
6751#if defined WLAN_FEATURE_VOWIFI
6752/* ---------------------------------------------------------------------------
6753 \fn sme_NeighborReportRequest
6754 \brief API to request neighbor report.
6755 \param hHal - The handle returned by macOpen.
6756 \param pRrmNeighborReq - Pointer to a caller allocated object of type
6757 tRrmNeighborReq. Caller owns the memory and is responsible
6758 for freeing it.
6759 \return VOS_STATUS
6760 VOS_STATUS_E_FAILURE - failure
6761 VOS_STATUS_SUCCESS success
6762 ---------------------------------------------------------------------------*/
6763VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
6764 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
6765{
6766 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6767 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +05306768 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006769 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006770
6771 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6772 {
6773 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
6774 sme_ReleaseGlobalLock( &pMac->sme );
6775 }
6776
6777 return (status);
6778}
6779#endif
6780
6781//The following are debug APIs to support direct read/write register/memory
6782//They are placed in SME because HW cannot be access when in LOW_POWER state
6783//AND not connected. The knowledge and synchronization is done in SME
6784
6785//sme_DbgReadRegister
6786//Caller needs to validate the input values
6787VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
6788{
6789 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6790 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006791 tPmcPowerState PowerState;
6792 tANI_U32 sessionId = 0;
Katya Nigambcb705f2013-12-26 14:26:22 +05306793 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006794 TRACE_CODE_SME_RX_HDD_DBG_READREG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006795
6796 /* 1) To make Quarky work in FTM mode **************************************/
6797
6798 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
6799 {
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08006800 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 {
6802 return VOS_STATUS_SUCCESS;
6803 }
6804 return VOS_STATUS_E_FAILURE;
6805 }
6806
6807 /* 2) NON FTM mode driver *************************************************/
6808
6809 /* Acquire SME global lock */
6810 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
6811 {
6812 return VOS_STATUS_E_FAILURE;
6813 }
6814
6815 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
6816 {
6817 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
6818 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
6819 {
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08006820 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 {
6822 status = VOS_STATUS_SUCCESS;
6823 }
6824 else
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006825 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 status = VOS_STATUS_E_FAILURE;
6827 }
6828 }
6829 else
6830 {
6831 status = VOS_STATUS_E_FAILURE;
6832 }
6833 }
6834
6835 /* This is a hack for Qualky/pttWniSocket
6836 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
6837 if ( VOS_STATUS_SUCCESS != status )
6838 {
6839 *pRegValue = 0xDEADBEEF;
6840 status = VOS_STATUS_SUCCESS;
6841 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006842
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 /* Release SME global lock */
6844 sme_ReleaseGlobalLock(&pMac->sme);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006845
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 return (status);
6847}
6848
6849
6850//sme_DbgWriteRegister
6851//Caller needs to validate the input values
6852VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
6853{
6854 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6855 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 tPmcPowerState PowerState;
6857 tANI_U32 sessionId = 0;
6858
6859 /* 1) To make Quarky work in FTM mode **************************************/
6860
Katya Nigambcb705f2013-12-26 14:26:22 +05306861 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006862 TRACE_CODE_SME_RX_HDD_DBG_WRITEREG, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
6864 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 {
6867 return VOS_STATUS_SUCCESS;
6868 }
6869 return VOS_STATUS_E_FAILURE;
6870 }
6871
6872 /* 2) NON FTM mode driver *************************************************/
6873
6874 /* Acquire SME global lock */
6875 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
6876 {
6877 return VOS_STATUS_E_FAILURE;
6878 }
6879
6880 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
6881 {
6882 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
6883 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
6884 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 {
6887 status = VOS_STATUS_SUCCESS;
6888 }
6889 else
6890 {
6891 status = VOS_STATUS_E_FAILURE;
6892 }
6893 }
6894 else
6895 {
6896 status = VOS_STATUS_E_FAILURE;
6897 }
6898 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006899
Jeff Johnson295189b2012-06-20 16:38:30 -07006900 /* Release SME global lock */
6901 sme_ReleaseGlobalLock(&pMac->sme);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006902
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 return (status);
6904}
6905
6906
6907
6908//sme_DbgReadMemory
6909//Caller needs to validate the input values
6910//pBuf caller allocated buffer has the length of nLen
6911VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
6912{
6913 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6914 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07006915 tPmcPowerState PowerState;
6916 tANI_U32 sessionId = 0;
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08006917 tANI_U32 cmd = READ_MEMORY_DUMP_CMD;
6918 tANI_U32 arg1 = memAddr;
6919 tANI_U32 arg2 = nLen/4;
6920 tANI_U32 arg3 = 4;
6921 tANI_U32 arg4 = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 /* 1) To make Quarky work in FTM mode **************************************/
6923
Katya Nigambcb705f2013-12-26 14:26:22 +05306924 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006925 TRACE_CODE_SME_RX_HDD_DBG_READMEM, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
6927 {
Siddharth Bhal68115602015-01-18 20:44:55 +05306928 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8*)pBuf, 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 {
6930 return VOS_STATUS_SUCCESS;
6931 }
6932 return VOS_STATUS_E_FAILURE;
6933 }
6934
6935 /* 2) NON FTM mode driver *************************************************/
6936
6937 /* Acquire SME global lock */
6938 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
6939 {
6940 return VOS_STATUS_E_FAILURE;
6941 }
6942
6943 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
6944 {
6945 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
6946 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
6947 {
Siddharth Bhal68115602015-01-18 20:44:55 +05306948 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8 *)pBuf, 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006949 {
6950 status = VOS_STATUS_SUCCESS;
6951 }
6952 else
6953 {
6954 status = VOS_STATUS_E_FAILURE;
6955 }
6956 }
6957 else
6958 {
6959 status = VOS_STATUS_E_FAILURE;
6960 }
6961 }
6962
6963 /* This is a hack for Qualky/pttWniSocket
6964 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
6965 if (VOS_STATUS_SUCCESS != status)
6966 {
6967 vos_mem_set(pBuf, nLen, 0xCD);
6968 status = VOS_STATUS_SUCCESS;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006969 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 }
6971
6972 /* Release SME lock */
6973 sme_ReleaseGlobalLock(&pMac->sme);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07006974
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 return (status);
6976}
6977
6978
6979//sme_DbgWriteMemory
6980//Caller needs to validate the input values
6981VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
6982{
6983 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6984 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006985 tPmcPowerState PowerState;
6986 tANI_U32 sessionId = 0;
6987
6988 /* 1) To make Quarky work in FTM mode **************************************/
6989
Katya Nigambcb705f2013-12-26 14:26:22 +05306990 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07006991 TRACE_CODE_SME_RX_HDD_DBG_WRITEMEM, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006992 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
6993 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 {
6995 return VOS_STATUS_SUCCESS;
6996 }
6997 return VOS_STATUS_E_FAILURE;
6998 }
6999
7000 /* 2) NON FTM mode driver *************************************************/
7001
7002 /* Acquire SME global lock */
7003 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
7004 {
7005 return VOS_STATUS_E_FAILURE;
7006 }
7007
7008 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
7009 {
7010 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
7011 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
7012 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 {
7015 status = VOS_STATUS_SUCCESS;
7016 }
7017 else
7018 {
7019 status = VOS_STATUS_E_FAILURE;
7020 }
7021 }
7022 else
7023 {
7024 status = VOS_STATUS_E_FAILURE;
7025 }
7026 }
7027
7028 /* Release Global lock */
7029 sme_ReleaseGlobalLock(&pMac->sme);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007030
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 return (status);
7032}
7033
7034
Katya Nigam70d68332013-09-16 16:49:45 +05307035void pmcLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString, ...)
7036{
7037 VOS_TRACE_LEVEL vosDebugLevel;
7038 char logBuffer[LOG_SIZE];
7039 va_list marker;
7040
7041 /* getting proper Debug level */
7042 vosDebugLevel = getVosDebugLevel(loglevel);
7043
7044 /* extracting arguments from pstring */
7045 va_start( marker, pString );
7046 vsnprintf(logBuffer, LOG_SIZE, pString, marker);
7047
7048 VOS_TRACE(VOS_MODULE_ID_PMC, vosDebugLevel, "%s", logBuffer);
7049 va_end( marker );
7050}
7051
7052
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007053void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
Jeff Johnson295189b2012-06-20 16:38:30 -07007054{
7055#ifdef WLAN_DEBUG
7056 // Verify against current log level
7057 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
7058 return;
7059 else
7060 {
7061 va_list marker;
7062
7063 va_start( marker, pString ); /* Initialize variable arguments. */
7064
7065 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
7066
7067 va_end( marker ); /* Reset variable arguments. */
7068 }
7069#endif
7070}
Jeff Johnson295189b2012-06-20 16:38:30 -07007071
Jeff Johnson295189b2012-06-20 16:38:30 -07007072/* ---------------------------------------------------------------------------
7073 \fn sme_GetWcnssWlanCompiledVersion
7074 \brief This API returns the version of the WCNSS WLAN API with
7075 which the HOST driver was built
7076 \param hHal - The handle returned by macOpen.
7077 \param pVersion - Points to the Version structure to be filled
7078 \return VOS_STATUS
7079 VOS_STATUS_E_INVAL - failure
7080 VOS_STATUS_SUCCESS success
7081 ---------------------------------------------------------------------------*/
7082VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
7083 tSirVersionType *pVersion)
7084{
7085 VOS_STATUS status = VOS_STATUS_SUCCESS;
7086 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7087 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
7088
7089 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
7090 {
7091 if( pVersion != NULL )
7092 {
7093 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
7094 }
7095 else
7096 {
7097 status = VOS_STATUS_E_INVAL;
7098 }
7099 sme_ReleaseGlobalLock( &pMac->sme );
7100 }
7101
7102 return (status);
7103}
7104
7105
7106/* ---------------------------------------------------------------------------
7107 \fn sme_GetWcnssWlanReportedVersion
7108 \brief This API returns the version of the WCNSS WLAN API with
7109 which the WCNSS driver reports it was built
7110 \param hHal - The handle returned by macOpen.
7111 \param pVersion - Points to the Version structure to be filled
7112 \return VOS_STATUS
7113 VOS_STATUS_E_INVAL - failure
7114 VOS_STATUS_SUCCESS success
7115 ---------------------------------------------------------------------------*/
7116VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
7117 tSirVersionType *pVersion)
7118{
7119 VOS_STATUS status = VOS_STATUS_SUCCESS;
7120 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7121 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
7122
7123 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
7124 {
7125 if( pVersion != NULL )
7126 {
7127 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
7128 }
7129 else
7130 {
7131 status = VOS_STATUS_E_INVAL;
7132 }
7133 sme_ReleaseGlobalLock( &pMac->sme );
7134 }
7135
7136 return (status);
7137}
7138
7139
7140/* ---------------------------------------------------------------------------
7141 \fn sme_GetWcnssSoftwareVersion
7142 \brief This API returns the version string of the WCNSS driver
7143 \param hHal - The handle returned by macOpen.
7144 \param pVersion - Points to the Version string buffer to be filled
7145 \param versionBufferSize - THe size of the Version string buffer
7146 \return VOS_STATUS
7147 VOS_STATUS_E_INVAL - failure
7148 VOS_STATUS_SUCCESS success
7149 ---------------------------------------------------------------------------*/
7150VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
7151 tANI_U8 *pVersion,
7152 tANI_U32 versionBufferSize)
7153{
7154 VOS_STATUS status = VOS_STATUS_SUCCESS;
7155 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7156 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
7157
7158 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
7159 {
7160 if( pVersion != NULL )
7161 {
7162 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
7163 versionBufferSize);
7164 }
7165 else
7166 {
7167 status = VOS_STATUS_E_INVAL;
7168 }
7169 sme_ReleaseGlobalLock( &pMac->sme );
7170 }
7171
7172 return (status);
7173}
7174
7175
7176/* ---------------------------------------------------------------------------
7177 \fn sme_GetWcnssHardwareVersion
7178 \brief This API returns the version string of the WCNSS hardware
7179 \param hHal - The handle returned by macOpen.
7180 \param pVersion - Points to the Version string buffer to be filled
7181 \param versionBufferSize - THe size of the Version string buffer
7182 \return VOS_STATUS
7183 VOS_STATUS_E_INVAL - failure
7184 VOS_STATUS_SUCCESS success
7185 ---------------------------------------------------------------------------*/
7186VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
7187 tANI_U8 *pVersion,
7188 tANI_U32 versionBufferSize)
7189{
7190 VOS_STATUS status = VOS_STATUS_SUCCESS;
7191 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7192 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
7193
7194 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
7195 {
7196 if( pVersion != NULL )
7197 {
7198 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
7199 versionBufferSize);
7200 }
7201 else
7202 {
7203 status = VOS_STATUS_E_INVAL;
7204 }
7205 sme_ReleaseGlobalLock( &pMac->sme );
7206 }
7207
7208 return (status);
7209}
Jeff Johnson4824d4c2013-02-12 14:23:57 -08007210
Jeff Johnson295189b2012-06-20 16:38:30 -07007211
7212#ifdef FEATURE_WLAN_WAPI
7213/* ---------------------------------------------------------------------------
7214 \fn sme_RoamSetBKIDCache
7215 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
7216 candidate list.
7217 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
7218 it is opened (by calling halOpen).
7219 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
7220 \param numItems - a variable that has the number of tBkidCacheInfo allocated
7221 when retruning, this is the number of items put into pBKIDCache
7222 \return eHalStatus - when fail, it usually means the buffer allocated is not
7223 big enough and pNumItems has the number of tBkidCacheInfo.
7224 ---------------------------------------------------------------------------*/
7225eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
7226 tANI_U32 numItems )
7227{
7228 eHalStatus status = eHAL_STATUS_FAILURE;
7229 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7230
7231 status = sme_AcquireGlobalLock( &pMac->sme );
7232 if ( HAL_STATUS_SUCCESS( status ) )
7233 {
7234 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
7235 sme_ReleaseGlobalLock( &pMac->sme );
7236 }
7237
7238 return (status);
7239}
7240
7241/* ---------------------------------------------------------------------------
7242 \fn sme_RoamGetBKIDCache
7243 \brief The SME API exposed to HDD to allow HDD to request SME to return its
7244 BKID cache.
7245 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
7246 it is opened (by calling halOpen).
7247 \param pNum - caller allocated memory that has the space of the number of
7248 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
7249 in SME cache.
7250 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
7251 upon return
7252 \return eHalStatus - when fail, it usually means the buffer allocated is not
7253 big enough.
7254 ---------------------------------------------------------------------------*/
7255eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
7256 tBkidCacheInfo *pBkidCache)
7257{
7258 eHalStatus status = eHAL_STATUS_FAILURE;
7259 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7260
7261 status = sme_AcquireGlobalLock( &pMac->sme );
7262 if ( HAL_STATUS_SUCCESS( status ) )
7263 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007264 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
7266 sme_ReleaseGlobalLock( &pMac->sme );
7267 }
7268
7269 return (status);
7270}
7271
7272/* ---------------------------------------------------------------------------
7273 \fn sme_RoamGetNumBKIDCache
7274 \brief The SME API exposed to HDD to allow HDD to request SME to return the
7275 number of BKID cache entries.
7276 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
7277 it is opened (by calling halOpen).
7278 \return tANI_U32 - the number of BKID cache entries.
7279 ---------------------------------------------------------------------------*/
7280tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
7281{
7282 eHalStatus status = eHAL_STATUS_FAILURE;
7283 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7284 tANI_U32 numBkidCache = 0;
7285
7286 status = sme_AcquireGlobalLock( &pMac->sme );
7287 if ( HAL_STATUS_SUCCESS( status ) )
7288 {
7289 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
7290 sme_ReleaseGlobalLock( &pMac->sme );
7291 }
7292
7293 return (numBkidCache);
7294}
7295
7296/* ---------------------------------------------------------------------------
7297 \fn sme_ScanGetBKIDCandidateList
7298 \brief a wrapper function to return the BKID candidate list
7299 \param pBkidList - caller allocated buffer point to an array of
7300 tBkidCandidateInfo
7301 \param pNumItems - pointer to a variable that has the number of
7302 tBkidCandidateInfo allocated when retruning, this is
7303 either the number needed or number of items put into
7304 pPmkidList
7305 \return eHalStatus - when fail, it usually means the buffer allocated is not
7306 big enough and pNumItems
7307 has the number of tBkidCandidateInfo.
7308 \Note: pNumItems is a number of tBkidCandidateInfo,
7309 not sizeof(tBkidCandidateInfo) * something
7310 ---------------------------------------------------------------------------*/
7311eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
7312 tBkidCandidateInfo *pBkidList,
7313 tANI_U32 *pNumItems )
7314{
7315 eHalStatus status = eHAL_STATUS_FAILURE;
7316 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7317
7318 status = sme_AcquireGlobalLock( &pMac->sme );
7319 if ( HAL_STATUS_SUCCESS( status ) )
7320 {
7321 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
7322 sme_ReleaseGlobalLock( &pMac->sme );
7323 }
7324
7325 return (status);
7326}
7327#endif /* FEATURE_WLAN_WAPI */
7328
Jeff Johnsone7245742012-09-05 17:12:55 -07007329#ifdef FEATURE_OEM_DATA_SUPPORT
7330
7331/*****************************************************************************
7332 OEM DATA related modifications and function additions
7333 *****************************************************************************/
7334
7335/* ---------------------------------------------------------------------------
7336 \fn sme_getOemDataRsp
7337 \brief a wrapper function to obtain the OEM DATA RSP
7338 \param pOemDataRsp - A pointer to the response object
7339 \param pContext - a pointer passed in for the callback
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007340 \return eHalStatus
Jeff Johnsone7245742012-09-05 17:12:55 -07007341 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007342eHalStatus sme_getOemDataRsp(tHalHandle hHal,
Jeff Johnsone7245742012-09-05 17:12:55 -07007343 tOemDataRsp **pOemDataRsp)
7344{
7345 eHalStatus status = eHAL_STATUS_SUCCESS;
7346 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7347
7348 do
7349 {
7350 //acquire the lock for the sme object
7351 status = sme_AcquireGlobalLock(&pMac->sme);
7352
7353 if(!HAL_STATUS_SUCCESS(status))
7354 {
7355 break;
7356 }
7357
7358 if(pMac->oemData.pOemDataRsp != NULL)
7359 {
7360 *pOemDataRsp = pMac->oemData.pOemDataRsp;
7361 }
7362 else
7363 {
7364 status = eHAL_STATUS_FAILURE;
7365 }
7366
7367 //release the lock for the sme object
7368 sme_ReleaseGlobalLock( &pMac->sme );
7369
7370 } while(0);
7371
7372 return status;
7373}
7374
7375/* ---------------------------------------------------------------------------
7376 \fn sme_OemDataReq
7377 \brief a wrapper function for OEM DATA REQ
7378 \param sessionId - session id to be used.
7379 \param pOemDataReqId - pointer to an object to get back the request ID
7380 \param callback - a callback function that is called upon finish
7381 \param pContext - a pointer passed in for the callback
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007382 \return eHalStatus
Jeff Johnsone7245742012-09-05 17:12:55 -07007383 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007384eHalStatus sme_OemDataReq(tHalHandle hHal,
Jeff Johnsone7245742012-09-05 17:12:55 -07007385 tANI_U8 sessionId,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007386 tOemDataReqConfig *pOemDataReqConfig,
7387 tANI_U32 *pOemDataReqID,
7388 oemData_OemDataReqCompleteCallback callback,
Jeff Johnsone7245742012-09-05 17:12:55 -07007389 void *pContext)
7390{
7391 eHalStatus status = eHAL_STATUS_SUCCESS;
7392 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7393
7394 do
7395 {
7396 //acquire the lock for the sme object
7397 status = sme_AcquireGlobalLock(&pMac->sme);
7398 if(HAL_STATUS_SUCCESS(status))
7399 {
7400 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
7401
7402 if(pOemDataReqID)
7403 {
7404 *pOemDataReqID = lOemDataReqId;
7405 }
7406 else
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08007407 {
7408 sme_ReleaseGlobalLock( &pMac->sme );
7409 return eHAL_STATUS_FAILURE;
7410 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007411
7412 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
7413
7414 //release the lock for the sme object
7415 sme_ReleaseGlobalLock( &pMac->sme );
7416 }
7417 } while(0);
7418
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007419 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07007420
7421 return(status);
7422}
7423
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +05307424/* ---------------------------------------------------------------------------
7425 \fn sme_OemDataReqNew
7426 \brief a wrapper function for OEM DATA REQ NEW
7427 \param pOemDataReqNewConfig - Data to be passed to FW
7428 ---------------------------------------------------------------------------*/
7429void sme_OemDataReqNew(tHalHandle hHal,
7430 tOemDataReqNewConfig *pOemDataReqNewConfig)
7431{
7432 eHalStatus status = eHAL_STATUS_SUCCESS;
7433 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7434 tOemDataReqNewConfig *pLocalOemDataReqNewConfig;
7435 vos_msg_t vosMessage = {0};
7436
7437 pLocalOemDataReqNewConfig =
7438 vos_mem_malloc(sizeof(*pLocalOemDataReqNewConfig));
7439
7440 if (!pLocalOemDataReqNewConfig)
7441 {
7442 smsLog(pMac, LOGE,
7443 "Failed to allocate memory for WDA_START_OEM_DATA_REQ_IND_NEW");
7444 return;
7445 }
7446
7447 vos_mem_zero(pLocalOemDataReqNewConfig, sizeof(tOemDataReqNewConfig));
7448 vos_mem_copy(pLocalOemDataReqNewConfig, pOemDataReqNewConfig,
7449 sizeof(tOemDataReqNewConfig));
7450
7451 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
7452 /* Serialize the req through MC thread */
7453 vosMessage.bodyptr = pLocalOemDataReqNewConfig;
7454 vosMessage.type = WDA_START_OEM_DATA_REQ_IND_NEW;
7455 MTRACE(vos_trace(VOS_MODULE_ID_SME,
7456 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
7457
7458 if(VOS_STATUS_SUCCESS !=
7459 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage)) {
7460 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s:"
7461 "Failed to post WDA_START_OEM_DATA_REQ_IND_NEW msg to WDA",
7462 __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +05307463 vos_mem_free(pLocalOemDataReqNewConfig);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +05307464 }
7465 sme_ReleaseGlobalLock(&pMac->sme);
7466 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +05307467 else
7468 {
7469 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
7470 "sme_AcquireGlobalLock error", __func__);
7471 vos_mem_free(pLocalOemDataReqNewConfig);
7472 }
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +05307473}
7474
Jeff Johnsone7245742012-09-05 17:12:55 -07007475#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07007476
7477/*--------------------------------------------------------------------------
7478
7479 \brief sme_OpenSession() - Open a session for scan/roam operation.
7480
7481 This is a synchronous API.
7482
7483
7484 \param hHal - The handle returned by macOpen.
7485 \param callback - A pointer to the function caller specifies for roam/connect status indication
7486 \param pContext - The context passed with callback
7487 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
7488 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
7489
7490 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
7491
7492 Other status means SME is failed to open the session.
7493 eHAL_STATUS_RESOURCES - no more session available.
7494 \sa
7495
7496 --------------------------------------------------------------------------*/
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07007497eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback,
7498 void *pContext, tANI_U8 *pSelfMacAddr,
7499 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007500{
7501 eHalStatus status;
7502 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7503
7504 if( NULL == pbSessionId )
7505 {
7506 status = eHAL_STATUS_INVALID_PARAMETER;
7507 }
7508 else
7509 {
7510 status = sme_AcquireGlobalLock( &pMac->sme );
7511 if ( HAL_STATUS_SUCCESS( status ) )
7512 {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07007513 status = csrRoamOpenSession(pMac, callback, pContext,
7514 pSelfMacAddr, pbSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007515
7516 sme_ReleaseGlobalLock( &pMac->sme );
7517 }
7518 }
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007519 if( NULL != pbSessionId )
Katya Nigambcb705f2013-12-26 14:26:22 +05307520 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007521 TRACE_CODE_SME_RX_HDD_OPEN_SESSION,*pbSessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007522
7523 return ( status );
7524}
7525
7526
7527/*--------------------------------------------------------------------------
7528
7529 \brief sme_CloseSession() - Open a session for scan/roam operation.
7530
7531 This is a synchronous API.
7532
7533
7534 \param hHal - The handle returned by macOpen.
7535
7536 \param sessionId - A previous opened session's ID.
7537
7538 \return eHAL_STATUS_SUCCESS - session is closed.
7539
7540 Other status means SME is failed to open the session.
7541 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
7542 \sa
7543
7544 --------------------------------------------------------------------------*/
7545eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
Agrawal Ashish5a3522c2016-03-02 15:08:28 +05307546 tANI_BOOLEAN fSync,
mukul sharmabab477d2015-06-11 17:14:55 +05307547 tANI_U8 bPurgeSmeCmdList,
7548 csrRoamSessionCloseCallback callback,
7549 void *pContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07007550{
7551 eHalStatus status;
7552 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7553
Katya Nigambcb705f2013-12-26 14:26:22 +05307554 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007555 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, sessionId, 0));
Agrawal Ashish5a3522c2016-03-02 15:08:28 +05307556 status = sme_AcquireGlobalLock(&pMac->sme);
7557 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007558 {
Agrawal Ashish5a3522c2016-03-02 15:08:28 +05307559 status = csrRoamCloseSession(pMac, sessionId, fSync, bPurgeSmeCmdList,
7560 callback, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07007561
7562 sme_ReleaseGlobalLock( &pMac->sme );
7563 }
7564
7565 return ( status );
7566}
7567
Jeff Johnson295189b2012-06-20 16:38:30 -07007568/* ---------------------------------------------------------------------------
7569
7570 \fn sme_RoamUpdateAPWPSIE
7571
7572 \brief To update AP's WPS IE. This function should be called after SME AP session is created
7573 This is an asynchronous API.
7574
7575 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
7576
7577 \return eHalStatus – SUCCESS –
7578
7579 FAILURE or RESOURCES – The API finished and failed.
7580
7581 -------------------------------------------------------------------------------*/
7582eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
7583{
7584
7585 eHalStatus status = eHAL_STATUS_FAILURE;
7586 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7587
7588 status = sme_AcquireGlobalLock( &pMac->sme );
7589 if ( HAL_STATUS_SUCCESS( status ) )
7590 {
7591
7592 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
7593
7594 sme_ReleaseGlobalLock( &pMac->sme );
7595 }
7596
7597 return (status);
7598}
7599/* ---------------------------------------------------------------------------
7600
7601 \fn sme_RoamUpdateAPWPARSNIEs
7602
7603 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
7604 This is an asynchronous API.
7605
7606 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
7607
7608 \return eHalStatus – SUCCESS –
7609
7610 FAILURE or RESOURCES – The API finished and failed.
7611
7612 -------------------------------------------------------------------------------*/
7613eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
7614{
7615
7616 eHalStatus status = eHAL_STATUS_FAILURE;
7617 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7618
7619 status = sme_AcquireGlobalLock( &pMac->sme );
7620 if ( HAL_STATUS_SUCCESS( status ) )
7621 {
7622
7623 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
7624
7625 sme_ReleaseGlobalLock( &pMac->sme );
7626 }
7627
7628 return (status);
7629}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007630/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07007631
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007632 \fn sme_ChangeMCCBeaconInterval
7633
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007634 \brief To update P2P-GO beaconInterval. This function should be called after
7635 disassociating all the station is done
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007636 This is an asynchronous API.
7637
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007638 \param
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007639
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007640 \return eHalStatus SUCCESS
7641 FAILURE or RESOURCES
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007642 The API finished and failed.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007643
7644 -------------------------------------------------------------------------------*/
7645eHalStatus sme_ChangeMCCBeaconInterval(tHalHandle hHal, tANI_U8 sessionId)
7646{
7647 eHalStatus status = eHAL_STATUS_FAILURE;
7648 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7649
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007650 smsLog(pMac, LOG1, FL("Update Beacon PARAMS "));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08007651 status = sme_AcquireGlobalLock( &pMac->sme );
7652 if ( HAL_STATUS_SUCCESS( status ) )
7653 {
7654 status = csrSendChngMCCBeaconInterval( pMac, sessionId);
7655 sme_ReleaseGlobalLock( &pMac->sme );
7656 }
7657 return (status);
7658}
Jeff Johnson295189b2012-06-20 16:38:30 -07007659
7660/*-------------------------------------------------------------------------------*
7661
7662 \fn sme_sendBTAmpEvent
7663
7664 \brief to receive the coex priorty request from BT-AMP PAL
7665 and send the BT_AMP link state to HAL
7666
7667 \param btAmpEvent - btAmpEvent
7668
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007669 \return eHalStatus: SUCCESS : BTAmp event successfully sent to HAL
Jeff Johnson295189b2012-06-20 16:38:30 -07007670
7671 FAILURE: API failed
7672
7673-------------------------------------------------------------------------------*/
7674
7675eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
7676{
7677 vos_msg_t msg;
7678 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
7679 eHalStatus status = eHAL_STATUS_FAILURE;
7680
Leela Venkata Kiran Kumar Reddy Chiralaf7ea5432013-11-15 11:03:04 -08007681 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tSmeBtAmpEvent));
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 if (NULL == ptrSmeBtAmpEvent)
7683 {
7684 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007685 "Not able to allocate memory for BTAmp event", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007686 return status;
7687 }
7688
7689 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
7690 msg.type = WDA_SIGNAL_BTAMP_EVENT;
7691 msg.reserved = 0;
7692 msg.bodyptr = ptrSmeBtAmpEvent;
7693
7694 //status = halFW_SendBTAmpEventMesg(pMac, event);
7695
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05307696 MTRACE(vos_trace(VOS_MODULE_ID_SME,
7697 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
7699 {
7700 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007701 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007702 vos_mem_free(ptrSmeBtAmpEvent);
7703 return status;
7704 }
7705
7706 return eHAL_STATUS_SUCCESS;
7707
7708}
7709
7710/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05307711 \fn smeIssueFastRoamNeighborAPEvent
7712 \brief API to trigger fast BSS roam independent of RSSI triggers
7713 \param hHal - The handle returned by macOpen.
7714 \param bssid - Pointer to the BSSID to roam to.
7715 \param fastRoamTrig - Trigger to Scan or roam
Mukul Sharma9e4e0f92015-02-13 18:45:20 +05307716 \param channel - channel number on which fastroam is requested
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05307717 \return eHalStatus
7718 ---------------------------------------------------------------------------*/
7719eHalStatus smeIssueFastRoamNeighborAPEvent (tHalHandle hHal,
7720 tANI_U8 *bssid,
Mukul Sharma9e4e0f92015-02-13 18:45:20 +05307721 tSmeFastRoamTrigger fastRoamTrig,
7722 tANI_U8 channel)
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05307723{
7724 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7725 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7726 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7727 eHalStatus status = eHAL_STATUS_SUCCESS;
7728
7729 status = sme_AcquireGlobalLock( &pMac->sme );
7730 if ( HAL_STATUS_SUCCESS( status ) )
7731 {
7732 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7733 "%s: invoked", __func__);
7734
7735 if (eSME_ROAM_TRIGGER_SCAN == fastRoamTrig)
7736 {
7737 smsLog(pMac, LOG1, FL("CFG Channel list scan... "));
7738 pNeighborRoamInfo->cfgRoamEn = eSME_ROAM_TRIGGER_SCAN;
7739 vos_mem_copy((void *)(&pNeighborRoamInfo->cfgRoambssId),
7740 (void *)bssid, sizeof(tSirMacAddr));
Mukul Sharma9e4e0f92015-02-13 18:45:20 +05307741 smsLog(pMac, LOG1, "Calling Roam Look Up down Event BSSID"
Arif Hussaina7c8e412013-11-20 11:06:42 -08007742 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pNeighborRoamInfo->cfgRoambssId));
Mukul Sharma9e4e0f92015-02-13 18:45:20 +05307743 /*
7744 * As FastReassoc is based on assumption that roamable AP should be
7745 * present into the occupied channel list.We shd add i/p channel
7746 * in occupied channel list if roamable-ap(BSSID in fastreassoc cmd)
7747 * aged out prior to connection and there is no scan from aged out
7748 * to till connection indication.
7749 */
7750 csrAddChannelToOccupiedChannelList(pMac, channel);
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05307751 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
7752 if (VOS_STATUS_SUCCESS != vosStatus)
7753 {
7754 smsLog(pMac, LOGE,
7755 FL("CFG Channel list scan state failed with status %d "),
7756 vosStatus);
7757 }
7758 }
7759 else if (eSME_ROAM_TRIGGER_FAST_ROAM == fastRoamTrig)
7760 {
7761 vos_mem_copy((void *)(&pNeighborRoamInfo->cfgRoambssId),
7762 (void *)bssid, sizeof(tSirMacAddr));
7763 pNeighborRoamInfo->cfgRoamEn = eSME_ROAM_TRIGGER_FAST_ROAM;
Arif Hussaina7c8e412013-11-20 11:06:42 -08007764 smsLog(pMac, LOG1, "Roam to BSSID "MAC_ADDRESS_STR,
7765 MAC_ADDR_ARRAY(pNeighborRoamInfo->cfgRoambssId));
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05307766
7767 vosStatus = csrNeighborRoamReassocIndCallback(pMac->roam.gVosContext,
7768 0,
7769 pMac,
7770 0);
7771
7772 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
7773 {
7774 smsLog(pMac,
7775 LOGE,
7776 FL(" Call to csrNeighborRoamReassocIndCallback failed, status = %d"),
7777 vosStatus);
7778 }
7779 }
7780 sme_ReleaseGlobalLock( &pMac->sme );
7781 }
7782 return vosStatus;
7783}
7784/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07007785 \fn sme_SetHostOffload
7786 \brief API to set the host offload feature.
7787 \param hHal - The handle returned by macOpen.
7788 \param pRequest - Pointer to the offload request.
7789 \return eHalStatus
7790 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007791eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07007792 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07007793{
7794 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07007795 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007796
Katya Nigambcb705f2013-12-26 14:26:22 +05307797 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007798 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007799 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7800 {
7801#ifdef WLAN_NS_OFFLOAD
7802 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
7803 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007804 status = pmcSetNSOffload( hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007805 }
7806 else
7807#endif //WLAN_NS_OFFLOAD
7808 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007809 status = pmcSetHostOffload (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 }
7811 sme_ReleaseGlobalLock( &pMac->sme );
7812 }
7813
7814 return (status);
7815}
7816
7817#ifdef WLAN_FEATURE_GTK_OFFLOAD
7818/* ---------------------------------------------------------------------------
7819 \fn sme_SetGTKOffload
7820 \brief API to set GTK offload information.
7821 \param hHal - The handle returned by macOpen.
7822 \param pRequest - Pointer to the GTK offload request.
7823 \return eHalStatus
7824 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007825eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007826 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007827{
7828 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7829 eHalStatus status;
7830
Katya Nigambcb705f2013-12-26 14:26:22 +05307831 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007832 TRACE_CODE_SME_RX_HDD_SET_GTKOFFLOAD, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7834 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007835 status = pmcSetGTKOffload( hHal, pRequest, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007836 sme_ReleaseGlobalLock( &pMac->sme );
7837 }
7838
7839 return (status);
7840}
7841
7842/* ---------------------------------------------------------------------------
7843 \fn sme_GetGTKOffload
7844 \brief API to get GTK offload information.
7845 \param hHal - The handle returned by macOpen.
7846 \param pRequest - Pointer to the GTK offload response.
7847 \return eHalStatus
7848 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007849eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007850 void *callbackContext, tANI_U8 sessionId )
Jeff Johnson295189b2012-06-20 16:38:30 -07007851{
7852 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7853 eHalStatus status;
7854
Katya Nigambcb705f2013-12-26 14:26:22 +05307855 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007856 TRACE_CODE_SME_RX_HDD_GET_GTKOFFLOAD, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7858 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007859 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007860 sme_ReleaseGlobalLock( &pMac->sme );
7861 }
7862
7863 return (status);
7864}
7865#endif // WLAN_FEATURE_GTK_OFFLOAD
7866
7867/* ---------------------------------------------------------------------------
7868 \fn sme_SetKeepAlive
7869 \brief API to set the Keep Alive feature.
7870 \param hHal - The handle returned by macOpen.
7871 \param pRequest - Pointer to the Keep Alive request.
7872 \return eHalStatus
7873 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007874eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07007875 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07007876{
7877 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7878 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7880 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007881 status = pmcSetKeepAlive (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007882 sme_ReleaseGlobalLock( &pMac->sme );
7883 }
7884
7885 return (status);
7886}
7887
7888#ifdef FEATURE_WLAN_SCAN_PNO
7889/* ---------------------------------------------------------------------------
7890 \fn sme_SetPreferredNetworkList
7891 \brief API to set the Preferred Network List Offload feature.
7892 \param hHal - The handle returned by macOpen.
7893 \param pRequest - Pointer to the offload request.
7894 \return eHalStatus
7895 ---------------------------------------------------------------------------*/
7896eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
7897{
7898 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7899 eHalStatus status;
7900
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +05307901 MTRACE(vos_trace(VOS_MODULE_ID_SME,
7902 TRACE_CODE_SME_RX_HDD_PREF_NET_LIST,
7903 sessionId, pRequest->ucNetworksCount));
Jeff Johnson295189b2012-06-20 16:38:30 -07007904 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7905 {
7906 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
7907 sme_ReleaseGlobalLock( &pMac->sme );
7908 }
7909
7910 return (status);
7911}
7912
7913eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
7914{
7915 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7916 eHalStatus status;
7917
7918 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7919 {
7920 pmcSetRssiFilter(hHal, rssiThreshold);
7921 sme_ReleaseGlobalLock( &pMac->sme );
7922 }
7923
7924 return (status);
7925}
7926
7927#endif // FEATURE_WLAN_SCAN_PNO
7928
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007929eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams, tANI_BOOLEAN forced)
Jeff Johnson295189b2012-06-20 16:38:30 -07007930{
7931 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7932 eHalStatus status;
7933
Katya Nigambcb705f2013-12-26 14:26:22 +05307934 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007935 TRACE_CODE_SME_RX_HDD_SET_POWERPARAMS, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007936 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7937 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007938 pmcSetPowerParams(hHal, pwParams, forced);
Jeff Johnson295189b2012-06-20 16:38:30 -07007939 sme_ReleaseGlobalLock( &pMac->sme );
7940 }
7941
7942 return (status);
7943}
7944
7945/* ---------------------------------------------------------------------------
7946 \fn sme_AbortMacScan
7947 \brief API to cancel MAC scan.
7948 \param hHal - The handle returned by macOpen.
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307949 \param sessionId - sessionId on which we need to abort scan.
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307950 \param reason - Reason to abort the scan.
c_hpothua3d45d52015-01-05 14:11:17 +05307951 \return tSirAbortScanStatus Abort scan status
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 ---------------------------------------------------------------------------*/
c_hpothua3d45d52015-01-05 14:11:17 +05307953tSirAbortScanStatus sme_AbortMacScan(tHalHandle hHal, tANI_U8 sessionId,
7954 eCsrAbortReason reason)
Jeff Johnson295189b2012-06-20 16:38:30 -07007955{
c_hpothua3d45d52015-01-05 14:11:17 +05307956 tSirAbortScanStatus scanAbortStatus = eSIR_ABORT_SCAN_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007957 eHalStatus status;
7958 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7959
Katya Nigambcb705f2013-12-26 14:26:22 +05307960 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07007961 TRACE_CODE_SME_RX_HDD_ABORT_MACSCAN, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 status = sme_AcquireGlobalLock( &pMac->sme );
7963 if ( HAL_STATUS_SUCCESS( status ) )
7964 {
c_hpothua3d45d52015-01-05 14:11:17 +05307965 scanAbortStatus = csrScanAbortMacScan(pMac, sessionId, reason);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007966
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 sme_ReleaseGlobalLock( &pMac->sme );
7968 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007969
c_hpothua3d45d52015-01-05 14:11:17 +05307970 return ( scanAbortStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07007971}
7972
7973/* ----------------------------------------------------------------------------
7974 \fn sme_GetOperationChannel
7975 \brief API to get current channel on which STA is parked
7976 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007977 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07007978 \returns eHAL_STATUS_SUCCESS
7979 eHAL_STATUS_FAILURE
7980-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007981eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007982{
Jeff Johnson295189b2012-06-20 16:38:30 -07007983 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7984 tCsrRoamSession *pSession;
7985
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007986 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007987 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007988 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007989
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07007990 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007991 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007992 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007993 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
7994 {
7995 *pChannel =pSession->connectedProfile.operationChannel;
7996 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 }
7998 }
7999 return eHAL_STATUS_FAILURE;
8000}// sme_GetOperationChannel ends here
8001
Abhishek Singh7d624e12015-11-30 14:29:27 +05308002/**
8003 * sme_register_mgmt_frame_ind_callback() - Register a callback for
8004 * management frame indication to PE.
8005 * @hHal: hal pointer
8006 * @callback: callback pointer to be registered
8007 *
8008 * This function is used to register a callback for management
8009 * frame indication to PE.
8010 *
8011 * Return: Success if msg is posted to PE else Failure.
8012 */
8013eHalStatus sme_register_mgmt_frame_ind_callback(tHalHandle hHal,
8014 sir_mgmt_frame_ind_callback callback)
8015{
8016 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8017 struct sir_sme_mgmt_frame_cb_req *msg;
8018 eHalStatus status = eHAL_STATUS_SUCCESS;
8019
8020 smsLog(pMac, LOG1, FL(": ENTER"));
8021
8022 if (eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock(&pMac->sme))
8023 {
8024 msg = vos_mem_malloc(sizeof(*msg));
8025 if (NULL == msg)
8026 {
8027 smsLog(pMac, LOGE,
8028 FL("Not able to allocate memory for eWNI_SME_REGISTER_MGMT_FRAME_CB"));
8029 sme_ReleaseGlobalLock( &pMac->sme );
8030 return eHAL_STATUS_FAILURE;
8031 }
8032 vos_mem_set(msg, sizeof(*msg), 0);
8033 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
8034 msg->length = sizeof(*msg);
8035
8036 msg->callback = callback;
8037 status = palSendMBMessage(pMac->hHdd, msg);
8038 sme_ReleaseGlobalLock( &pMac->sme );
8039 return status;
8040 }
8041 return eHAL_STATUS_FAILURE;
8042}
8043
Jeff Johnson295189b2012-06-20 16:38:30 -07008044/* ---------------------------------------------------------------------------
8045
8046 \fn sme_RegisterMgtFrame
8047
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008048 \brief To register managment frame of specified type and subtype.
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 \param frameType - type of the frame that needs to be passed to HDD.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008050 \param matchData - data which needs to be matched before passing frame
8051 to HDD.
Jeff Johnson295189b2012-06-20 16:38:30 -07008052 \param matchDataLen - Length of matched data.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008053 \return eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -07008054 -------------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008055eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
8057{
8058 eHalStatus status = eHAL_STATUS_SUCCESS;
8059 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8060
Katya Nigambcb705f2013-12-26 14:26:22 +05308061 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008062 TRACE_CODE_SME_RX_HDD_REGISTER_MGMTFR, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008063 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8064 {
8065 tSirRegisterMgmtFrame *pMsg;
8066 tANI_U16 len;
8067 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008068
8069 if(!pSession)
8070 {
8071 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08008072 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008073 return eHAL_STATUS_FAILURE;
8074 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008075
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 if( !pSession->sessionActive )
8077 {
8078 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008079 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 sme_ReleaseGlobalLock( &pMac->sme );
8081 return eHAL_STATUS_FAILURE;
8082 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008083
Jeff Johnson295189b2012-06-20 16:38:30 -07008084 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
8085
Kiet Lam64c1b492013-07-12 13:56:44 +05308086 pMsg = vos_mem_malloc(len);
8087 if ( NULL == pMsg )
8088 status = eHAL_STATUS_FAILURE;
8089 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008090 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308091 vos_mem_set(pMsg, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008092 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
8093 pMsg->length = len;
8094 pMsg->sessionId = sessionId;
8095 pMsg->registerFrame = VOS_TRUE;
8096 pMsg->frameType = frameType;
8097 pMsg->matchLen = matchLen;
Kiet Lam64c1b492013-07-12 13:56:44 +05308098 vos_mem_copy(pMsg->matchData, matchData, matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008099 status = palSendMBMessage(pMac->hHdd, pMsg);
8100 }
8101 sme_ReleaseGlobalLock( &pMac->sme );
8102 }
8103 return status;
8104}
8105
8106/* ---------------------------------------------------------------------------
8107
8108 \fn sme_DeregisterMgtFrame
8109
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008110 \brief To De-register managment frame of specified type and subtype.
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 \param frameType - type of the frame that needs to be passed to HDD.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008112 \param matchData - data which needs to be matched before passing frame
8113 to HDD.
Jeff Johnson295189b2012-06-20 16:38:30 -07008114 \param matchDataLen - Length of matched data.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008115 \return eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -07008116 -------------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008117eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
8119{
8120 eHalStatus status = eHAL_STATUS_SUCCESS;
8121 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8122
Katya Nigambcb705f2013-12-26 14:26:22 +05308123 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008124 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8126 {
8127 tSirRegisterMgmtFrame *pMsg;
8128 tANI_U16 len;
8129 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008130
8131 if(!pSession)
8132 {
8133 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08008134 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008135 return eHAL_STATUS_FAILURE;
8136 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008137
8138 if( !pSession->sessionActive )
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 {
8140 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008141 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008142 sme_ReleaseGlobalLock( &pMac->sme );
8143 return eHAL_STATUS_FAILURE;
8144 }
8145
8146 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
8147
Kiet Lam64c1b492013-07-12 13:56:44 +05308148 pMsg = vos_mem_malloc(len);
8149 if ( NULL == pMsg )
8150 status = eHAL_STATUS_FAILURE;
8151 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308153 vos_mem_set(pMsg, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008154 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008155 pMsg->length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 pMsg->registerFrame = VOS_FALSE;
8157 pMsg->frameType = frameType;
8158 pMsg->matchLen = matchLen;
Kiet Lam64c1b492013-07-12 13:56:44 +05308159 vos_mem_copy(pMsg->matchData, matchData, matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 status = palSendMBMessage(pMac->hHdd, pMsg);
8161 }
8162 sme_ReleaseGlobalLock( &pMac->sme );
8163 }
8164 return status;
8165}
8166
8167/* ---------------------------------------------------------------------------
8168 \fn sme_RemainOnChannel
8169 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
8170 \param hHal - The handle returned by macOpen.
8171 \param pRequest - channel
8172 \param duration - duration in ms
8173 \param callback - HDD registered callback to process reaminOnChannelRsp
8174 \param context - HDD Callback param
8175 \return eHalStatus
8176 ---------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008177eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
8178 tANI_U8 channel, tANI_U32 duration,
Gopichand Nakkala924e4552013-05-08 19:18:14 +05308179 remainOnChanCallback callback,
8180 void *pContext,
8181 tANI_U8 isP2PProbeReqAllowed)
Jeff Johnson295189b2012-06-20 16:38:30 -07008182{
8183 eHalStatus status = eHAL_STATUS_SUCCESS;
8184 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8185
Katya Nigambcb705f2013-12-26 14:26:22 +05308186 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008187 TRACE_CODE_SME_RX_HDD_REMAIN_ONCHAN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008188 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8189 {
Gopichand Nakkala924e4552013-05-08 19:18:14 +05308190 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext,
8191 isP2PProbeReqAllowed
Jeff Johnson295189b2012-06-20 16:38:30 -07008192#ifdef WLAN_FEATURE_P2P_INTERNAL
8193 , eP2PRemainOnChnReasonUnknown
8194#endif
8195 );
8196 sme_ReleaseGlobalLock( &pMac->sme );
8197 }
8198 return(status);
8199}
8200
8201/* ---------------------------------------------------------------------------
8202 \fn sme_ReportProbeReq
8203 \brief API to enable/disable forwarding of probeReq to apps in p2p.
8204 \param hHal - The handle returned by macOpen.
8205 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
8206 \return eHalStatus
8207 ---------------------------------------------------------------------------*/
8208
8209#ifndef WLAN_FEATURE_CONCURRENT_P2P
8210eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
8211{
8212 eHalStatus status = eHAL_STATUS_SUCCESS;
8213 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8214
8215 do
8216 {
8217 //acquire the lock for the sme object
8218 status = sme_AcquireGlobalLock(&pMac->sme);
8219 if(HAL_STATUS_SUCCESS(status))
8220 {
8221 /* call set in context */
8222 pMac->p2pContext.probeReqForwarding = flag;
8223 //release the lock for the sme object
8224 sme_ReleaseGlobalLock( &pMac->sme );
8225 }
8226 } while(0);
8227
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008228 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008229
8230 return(status);
8231}
8232
8233/* ---------------------------------------------------------------------------
8234 \fn sme_updateP2pIe
8235 \brief API to set the P2p Ie in p2p context
8236 \param hHal - The handle returned by macOpen.
8237 \param p2pIe - Ptr to p2pIe from HDD.
8238 \param p2pIeLength: length of p2pIe
8239 \return eHalStatus
8240 ---------------------------------------------------------------------------*/
8241
8242eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
8243{
8244 eHalStatus status = eHAL_STATUS_SUCCESS;
8245 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8246
8247 //acquire the lock for the sme object
8248 status = sme_AcquireGlobalLock(&pMac->sme);
8249 if(HAL_STATUS_SUCCESS(status))
8250 {
8251 if(NULL != pMac->p2pContext.probeRspIe){
8252 vos_mem_free(pMac->p2pContext.probeRspIe);
8253 pMac->p2pContext.probeRspIeLength = 0;
8254 }
8255
8256 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
8257 if (NULL == pMac->p2pContext.probeRspIe)
8258 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008259 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 pMac->p2pContext.probeRspIeLength = 0;
8261 status = eHAL_STATUS_FAILURE;
8262 }
8263 else
8264 {
8265 pMac->p2pContext.probeRspIeLength = p2pIeLength;
8266
8267 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
8268 pMac->p2pContext.probeRspIe,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008269 pMac->p2pContext.probeRspIeLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008270 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
8271 p2pIeLength);
8272 }
8273
8274 //release the lock for the sme object
8275 sme_ReleaseGlobalLock( &pMac->sme );
8276 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008277
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008278 smsLog(pMac, LOG2, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008279
8280 return(status);
8281}
8282#endif
8283
8284/* ---------------------------------------------------------------------------
8285 \fn sme_sendAction
8286 \brief API to send action frame from supplicant.
8287 \param hHal - The handle returned by macOpen.
8288 \return eHalStatus
8289 ---------------------------------------------------------------------------*/
8290
8291eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07008292 const tANI_U8 *pBuf, tANI_U32 len,
8293 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07008294{
8295 eHalStatus status = eHAL_STATUS_SUCCESS;
8296 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8297
Katya Nigambcb705f2013-12-26 14:26:22 +05308298 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008299 TRACE_CODE_SME_RX_HDD_SEND_ACTION, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008300 //acquire the lock for the sme object
8301 status = sme_AcquireGlobalLock(&pMac->sme);
8302 if(HAL_STATUS_SUCCESS(status))
8303 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008304 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 //release the lock for the sme object
8306 sme_ReleaseGlobalLock( &pMac->sme );
8307 }
8308
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008309 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008310
8311 return(status);
8312}
8313
8314eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
8315{
8316 eHalStatus status = eHAL_STATUS_SUCCESS;
8317 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8318
Katya Nigambcb705f2013-12-26 14:26:22 +05308319 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008320 TRACE_CODE_SME_RX_HDD_CANCEL_REMAIN_ONCHAN, sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008321 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8322 {
8323 status = p2pCancelRemainOnChannel (hHal, sessionId);
8324 sme_ReleaseGlobalLock( &pMac->sme );
8325 }
8326 return(status);
8327}
8328
8329//Power Save Related
8330eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
8331{
8332 eHalStatus status = eHAL_STATUS_SUCCESS;
8333 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8334
8335 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8336 {
8337 status = p2pSetPs (hHal, data);
8338 sme_ReleaseGlobalLock( &pMac->sme );
8339 }
8340 return(status);
8341}
8342
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308343/* ---------------------------------------------------------------------------
Siddharth Bhal64246172015-02-27 01:04:37 +05308344 \fn sme_GetFramesLog
8345 \brief a wrapper function that client calls to register a callback to get
8346 mgmt frames logged
Siddharth Bhal64246172015-02-27 01:04:37 +05308347 \param flag - flag tells to clear OR send the frame log buffer
Siddharth Bhal64246172015-02-27 01:04:37 +05308348 \return eHalStatus
8349 ---------------------------------------------------------------------------*/
Abhishek Singh611295e2015-07-09 11:11:54 +05308350eHalStatus sme_GetFramesLog(tHalHandle hHal, tANI_U8 flag)
Siddharth Bhal64246172015-02-27 01:04:37 +05308351{
8352 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8353 eHalStatus status = eHAL_STATUS_SUCCESS;
8354 tSmeCmd *pGetFrameLogCmd;
8355
mukul sharmaca8e4322015-07-20 18:33:43 +05308356 status = sme_AcquireGlobalLock( &pMac->sme );
8357 if ( HAL_STATUS_SUCCESS( status ) )
8358 {
8359 pGetFrameLogCmd = csrGetCommandBuffer(pMac);
8360 if (pGetFrameLogCmd)
Siddharth Bhal64246172015-02-27 01:04:37 +05308361 {
mukul sharmaca8e4322015-07-20 18:33:43 +05308362 pGetFrameLogCmd->command = eSmeCommandGetFrameLogRequest;
8363 pGetFrameLogCmd->u.getFramelogCmd.getFrameLogCmdFlag= flag;
Siddharth Bhal64246172015-02-27 01:04:37 +05308364
mukul sharmaca8e4322015-07-20 18:33:43 +05308365 status = csrQueueSmeCommand(pMac, pGetFrameLogCmd, eANI_BOOLEAN_TRUE);
8366 if ( !HAL_STATUS_SUCCESS( status ) )
8367 {
8368 smsLog( pMac, LOGE, FL("fail to send msg status = %d\n"), status );
8369 csrReleaseCommandScan(pMac, pGetFrameLogCmd);
8370 }
8371 }
8372 else
8373 {
8374 //log error
8375 smsLog(pMac, LOGE, FL("can not obtain a common buffer\n"));
8376 status = eHAL_STATUS_RESOURCES;
8377 }
8378 sme_ReleaseGlobalLock( &pMac->sme);
8379 }
Siddharth Bhal64246172015-02-27 01:04:37 +05308380 return (status);
8381}
8382
8383/* ---------------------------------------------------------------------------
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308384
8385 \fn sme_InitMgmtFrameLogging
8386
8387 \brief
8388 SME will pass this request to lower mac to initialize Frame Logging.
8389
8390 \param
8391
8392 hHal - The handle returned by macOpen.
8393
Siddharth Bhald1be97f2015-05-27 22:39:59 +05308394 wlanFWLoggingInitParam - Params to initialize frame logging
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308395
8396 \return eHalStatus
8397
8398
8399--------------------------------------------------------------------------- */
8400eHalStatus sme_InitMgmtFrameLogging( tHalHandle hHal,
Siddharth Bhald1be97f2015-05-27 22:39:59 +05308401 tSirFWLoggingInitParam *wlanFWLoggingInitParam)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308402{
8403 eHalStatus status = eHAL_STATUS_SUCCESS;
8404 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8405 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8406 vos_msg_t vosMessage;
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05308407 tpSirFWLoggingInitParam msg;
8408
8409 msg = vos_mem_malloc(sizeof(tSirFWLoggingInitParam));
8410
8411 if (NULL == msg)
8412 {
8413 smsLog(pMac, LOGE, FL("Failed to alloc mem of size %zu for msg"),
8414 sizeof(*msg));
8415 return eHAL_STATUS_FAILED_ALLOC;
8416 }
8417 *msg = *wlanFWLoggingInitParam;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308418
8419 if ( eHAL_STATUS_SUCCESS == ( status =
8420 sme_AcquireGlobalLock( &pMac->sme ) ) )
8421 {
8422 /* serialize the req through MC thread */
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05308423 vosMessage.bodyptr = msg;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308424 vosMessage.type = WDA_MGMT_LOGGING_INIT_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05308425 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8426 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308427 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8428 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8429 {
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05308430 vos_mem_free(msg);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308431 status = eHAL_STATUS_FAILURE;
8432 }
8433 sme_ReleaseGlobalLock( &pMac->sme );
8434 }
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05308435 else
8436 {
8437 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock error"));
8438 vos_mem_free(msg);
8439 }
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05308440 return(status);
8441}
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308442/* ---------------------------------------------------------------------------
8443
8444 \fn sme_StartRssiMonitoring
8445
8446 \brief
8447 SME will pass this request to lower mac to start monitoring rssi range on
8448 a bssid.
8449
8450 \param
8451
8452 hHal - The handle returned by macOpen.
8453
8454 tSirRssiMonitorReq req- depict the monitor req params.
8455
8456 \return eHalStatus
8457
8458--------------------------------------------------------------------------- */
8459eHalStatus sme_StartRssiMonitoring( tHalHandle hHal,
8460 tSirRssiMonitorReq *req)
8461{
8462 eHalStatus status = eHAL_STATUS_SUCCESS;
8463 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8464 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8465 vos_msg_t vosMessage;
8466
8467 if ( eHAL_STATUS_SUCCESS == ( status =
8468 sme_AcquireGlobalLock( &pMac->sme ) ) )
8469 {
8470 /* serialize the req through MC thread */
8471 vosMessage.bodyptr = req;
8472 vosMessage.type = WDA_START_RSSI_MONITOR_REQ;
8473 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8474 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
8475 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8476 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8477 {
8478 status = eHAL_STATUS_FAILURE;
8479 }
8480 sme_ReleaseGlobalLock( &pMac->sme );
8481 }
8482 return(status);
8483}
8484
8485/* ---------------------------------------------------------------------------
8486
8487 \fn sme_StopRssiMonitoring
8488
8489 \brief
8490 SME will pass this request to lower mac to stop monitoring rssi range on
8491 a bssid.
8492
8493 \param
8494
8495 hHal - The handle returned by macOpen.
8496
8497 tSirRssiMonitorReq req- depict the monitor req params.
8498
8499 \return eHalStatus
8500
8501--------------------------------------------------------------------------- */
8502eHalStatus sme_StopRssiMonitoring(tHalHandle hHal,
8503 tSirRssiMonitorReq *req)
8504{
8505 eHalStatus status = eHAL_STATUS_SUCCESS;
8506 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8507 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8508 vos_msg_t vosMessage;
8509
8510 if ( eHAL_STATUS_SUCCESS == ( status =
8511 sme_AcquireGlobalLock( &pMac->sme ) ) )
8512 {
8513 /* serialize the req through MC thread */
8514 vosMessage.bodyptr = req;
8515 vosMessage.type = WDA_STOP_RSSI_MONITOR_REQ;
8516 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8517 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
8518 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8519 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8520 {
8521 status = eHAL_STATUS_FAILURE;
8522 }
8523 sme_ReleaseGlobalLock( &pMac->sme );
8524 }
8525 return(status);
8526}
Jeff Johnson295189b2012-06-20 16:38:30 -07008527
8528/* ---------------------------------------------------------------------------
8529
8530 \fn sme_ConfigureRxpFilter
8531
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008532 \brief
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 SME will pass this request to lower mac to set/reset the filter on RXP for
8534 multicast & broadcast traffic.
8535
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008536 \param
Jeff Johnson295189b2012-06-20 16:38:30 -07008537
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008538 hHal - The handle returned by macOpen.
8539
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
8541 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
8542 on this param. In future we can use this as a mask to set various types of
8543 filters as suggested below:
8544 FILTER_ALL_MULTICAST:
8545 FILTER_ALL_BROADCAST:
8546 FILTER_ALL_MULTICAST_BROADCAST:
8547
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008548
8549 \return eHalStatus
8550
8551
Jeff Johnson295189b2012-06-20 16:38:30 -07008552--------------------------------------------------------------------------- */
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008553eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07008554 tpSirWlanSetRxpFilters wlanRxpFilterParam)
8555{
8556 eHalStatus status = eHAL_STATUS_SUCCESS;
8557 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8558 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8559 vos_msg_t vosMessage;
8560
Katya Nigambcb705f2013-12-26 14:26:22 +05308561 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008562 TRACE_CODE_SME_RX_HDD_CONFIG_RXPFIL, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008563 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8564 {
8565 /* serialize the req through MC thread */
8566 vosMessage.bodyptr = wlanRxpFilterParam;
8567 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05308568 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8569 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07008570 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8571 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8572 {
8573 status = eHAL_STATUS_FAILURE;
8574 }
8575 sme_ReleaseGlobalLock( &pMac->sme );
8576 }
8577 return(status);
8578}
8579
Jeff Johnson295189b2012-06-20 16:38:30 -07008580/* ---------------------------------------------------------------------------
8581
mukul sharma6b53e202016-11-23 19:29:18 +05308582 \fn sme_update_hal_int_param
8583
8584 \brief
8585 SME will pass this request to lower mac to indicate that the host needs to
8586 update the cfg item
8587
8588 \param
8589
8590 hHal - The handle returned by macOpen.
8591
8592 cfg_id- cfg param id
8593
8594
8595 \return eHalStatus
8596
8597
8598--------------------------------------------------------------------------- */
8599
8600eHalStatus sme_update_cfg_int_param(tHalHandle hHal,
8601 tANI_U32 cfg_id)
8602{
8603 eHalStatus status = eHAL_STATUS_SUCCESS;
8604 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8605 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8606 vos_msg_t vosMessage;
8607 tpSirUpdateCfgIntParam updateCfgIntParam =
8608 vos_mem_malloc(sizeof(tSirUpdateCfgIntParam));
8609
8610 if (updateCfgIntParam == NULL)
8611 {
8612 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8613 "%s: vos_mem_alloc for updateCfgIntParam", __func__);
8614 return eHAL_STATUS_FAILURE;
8615 }
8616
8617 updateCfgIntParam->cfgId = cfg_id;
8618 /*
8619 * This API expect user must have updated cfg item using cfg API's.
8620 * Hence it just need the cfg param id not the cfg value.
8621 */
8622 status = sme_AcquireGlobalLock(&pMac->sme);
8623 if (eHAL_STATUS_SUCCESS == status)
8624 {
8625 /* serialize the req through MC thread */
8626 vosMessage.bodyptr = updateCfgIntParam;
8627 vosMessage.type = WDA_UPDATE_CFG_INT_PARAM;
8628 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
8629 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8630 {
8631 status = eHAL_STATUS_FAILURE;
8632 vos_mem_free(updateCfgIntParam);
8633 }
8634 sme_ReleaseGlobalLock(&pMac->sme);
8635 }
8636 else
8637 {
8638 status = eHAL_STATUS_FAILURE;
8639 vos_mem_free(updateCfgIntParam);
8640 }
8641 return(status);
8642}
8643
8644/* ---------------------------------------------------------------------------
8645
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 \fn sme_ConfigureSuspendInd
8647
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008648 \brief
8649 SME will pass this request to lower mac to Indicate that the wlan needs to
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 be suspended
8651
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008652 \param
Jeff Johnson295189b2012-06-20 16:38:30 -07008653
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008654 hHal - The handle returned by macOpen.
8655
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 wlanSuspendParam- Depicts the wlan suspend params
8657
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008658
8659 \return eHalStatus
8660
8661
Jeff Johnson295189b2012-06-20 16:38:30 -07008662--------------------------------------------------------------------------- */
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008663eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07008664 tpSirWlanSuspendParam wlanSuspendParam)
8665{
8666 eHalStatus status = eHAL_STATUS_SUCCESS;
8667 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8668 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8669 vos_msg_t vosMessage;
8670
Katya Nigambcb705f2013-12-26 14:26:22 +05308671 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008672 TRACE_CODE_SME_RX_HDD_CONFIG_SUSPENDIND, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008673 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8674 {
8675 /* serialize the req through MC thread */
8676 vosMessage.bodyptr = wlanSuspendParam;
8677 vosMessage.type = WDA_WLAN_SUSPEND_IND;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05308678 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8679 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07008680 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8681 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8682 {
8683 status = eHAL_STATUS_FAILURE;
8684 }
8685 sme_ReleaseGlobalLock( &pMac->sme );
8686 }
8687 return(status);
8688}
8689
8690/* ---------------------------------------------------------------------------
8691
8692 \fn sme_ConfigureResumeReq
8693
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008694 \brief
8695 SME will pass this request to lower mac to Indicate that the wlan needs to
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 be Resumed
8697
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008698 \param
Jeff Johnson295189b2012-06-20 16:38:30 -07008699
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008700 hHal - The handle returned by macOpen.
8701
Jeff Johnson295189b2012-06-20 16:38:30 -07008702 wlanResumeParam- Depicts the wlan resume params
8703
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008704
8705 \return eHalStatus
8706
8707
Jeff Johnson295189b2012-06-20 16:38:30 -07008708--------------------------------------------------------------------------- */
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008709eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 tpSirWlanResumeParam wlanResumeParam)
8711{
8712 eHalStatus status = eHAL_STATUS_SUCCESS;
8713 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8714 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8715 vos_msg_t vosMessage;
8716
Katya Nigambcb705f2013-12-26 14:26:22 +05308717 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -07008718 TRACE_CODE_SME_RX_HDD_CONFIG_RESUMEREQ, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
8720 {
8721 /* serialize the req through MC thread */
8722 vosMessage.bodyptr = wlanResumeParam;
8723 vosMessage.type = WDA_WLAN_RESUME_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05308724 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8725 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8727 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
8728 {
8729 status = eHAL_STATUS_FAILURE;
8730 }
8731 sme_ReleaseGlobalLock( &pMac->sme );
8732 }
8733 return(status);
8734}
8735
Jeff Johnson295189b2012-06-20 16:38:30 -07008736/* ---------------------------------------------------------------------------
8737
8738 \fn sme_GetInfraSessionId
8739
8740 \brief To get the session ID for infra session, if connected
8741 This is a synchronous API.
8742
8743 \param hHal - The handle returned by macOpen.
8744
8745 \return sessionid, -1 if infra session is not connected
8746
8747 -------------------------------------------------------------------------------*/
8748tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
8749{
8750 eHalStatus status = eHAL_STATUS_FAILURE;
8751 tANI_S8 sessionid = -1;
8752 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008753
Jeff Johnson295189b2012-06-20 16:38:30 -07008754 status = sme_AcquireGlobalLock( &pMac->sme );
8755 if ( HAL_STATUS_SUCCESS( status ) )
8756 {
8757
8758 sessionid = csrGetInfraSessionId( pMac);
8759
8760 sme_ReleaseGlobalLock( &pMac->sme );
8761 }
8762
8763 return (sessionid);
8764}
8765
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +05308766tANI_U32 sme_get_sessionid_from_activeList(tpAniSirGlobal mac)
8767{
8768 tListElem *entry = NULL;
8769 tSmeCmd *command = NULL;
8770 tANI_U32 session_id = 0;
8771
8772 entry = csrLLPeekHead( &mac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8773 if ( entry ) {
8774 command = GET_BASE_ADDR( entry, tSmeCmd, Link );
8775 session_id = command->sessionId;
8776 }
8777
8778 return (session_id);
8779}
8780
Jeff Johnson295189b2012-06-20 16:38:30 -07008781/* ---------------------------------------------------------------------------
8782
8783 \fn sme_GetInfraOperationChannel
8784
8785 \brief To get the operating channel for infra session, if connected
8786 This is a synchronous API.
8787
8788 \param hHal - The handle returned by macOpen.
8789 \param sessionId - the sessionId returned by sme_OpenSession.
8790
8791 \return operating channel, 0 if infra session is not connected
8792
8793 -------------------------------------------------------------------------------*/
8794tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
8795{
8796 eHalStatus status = eHAL_STATUS_FAILURE;
8797 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8798 tANI_U8 channel = 0;
8799 status = sme_AcquireGlobalLock( &pMac->sme );
8800 if ( HAL_STATUS_SUCCESS( status ) )
8801 {
8802
8803 channel = csrGetInfraOperationChannel( pMac, sessionId);
8804
8805 sme_ReleaseGlobalLock( &pMac->sme );
8806 }
8807
8808 return (channel);
8809}
8810
8811//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 -07008812//If other BSS is not up or not connected it will return 0
Jeff Johnson295189b2012-06-20 16:38:30 -07008813tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
8814{
8815 eHalStatus status = eHAL_STATUS_FAILURE;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008816 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07008817 tANI_U8 channel = 0;
8818 status = sme_AcquireGlobalLock( &pMac->sme );
8819 if ( HAL_STATUS_SUCCESS( status ) )
8820 {
8821
8822 channel = csrGetConcurrentOperationChannel( pMac );
8823 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008824 " Other Concurrent Channel = %d", __func__,channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07008825 sme_ReleaseGlobalLock( &pMac->sme );
8826 }
8827
8828 return (channel);
8829}
8830
8831#ifdef FEATURE_WLAN_SCAN_PNO
8832/******************************************************************************
8833*
8834* Name: sme_PreferredNetworkFoundInd
8835*
8836* Description:
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008837* Invoke Preferred Network Found Indication
Jeff Johnson295189b2012-06-20 16:38:30 -07008838*
8839* Parameters:
8840* hHal - HAL handle for device
8841* pMsg - found network description
8842*
8843* Returns: eHalStatus
8844*
8845******************************************************************************/
8846eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
8847{
8848 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8849 eHalStatus status = eHAL_STATUS_SUCCESS;
8850 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
Srikant Kuppa066904f2013-05-07 13:56:02 -07008851 v_U8_t dumpSsId[SIR_MAC_MAX_SSID_LENGTH + 1];
8852 tANI_U8 ssIdLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008853
8854 if (NULL == pMsg)
8855 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008856 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 status = eHAL_STATUS_FAILURE;
8858 }
8859 else
8860 {
8861 if (pPrefNetworkFoundInd->ssId.length > 0)
8862 {
Srikant Kuppa066904f2013-05-07 13:56:02 -07008863 ssIdLength = CSR_MIN(SIR_MAC_MAX_SSID_LENGTH,
8864 pPrefNetworkFoundInd->ssId.length);
8865 vos_mem_copy(dumpSsId, pPrefNetworkFoundInd->ssId.ssId, ssIdLength);
8866 dumpSsId[ssIdLength] = 0;
Abhishek Singh195c03e2014-05-14 17:21:30 +05308867 smsLog(pMac, LOG1, FL(" SSID=%s frame length %d"),
8868 dumpSsId, pPrefNetworkFoundInd->frameLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008869
Vinay Krishna Erannab13043b2013-12-06 11:50:21 +05308870 /* Flush scan results, So as to avoid indication/updation of
8871 * stale entries, which may not have aged out during APPS collapse
8872 */
8873 sme_ScanFlushResult(hHal,0);
8874
Srikant Kuppa066904f2013-05-07 13:56:02 -07008875 //Save the frame to scan result
8876 if (pPrefNetworkFoundInd->mesgLen > sizeof(tSirPrefNetworkFoundInd))
8877 {
8878 //we may have a frame
8879 status = csrScanSavePreferredNetworkFound(pMac,
8880 pPrefNetworkFoundInd);
8881 if (!HAL_STATUS_SUCCESS(status))
8882 {
8883 smsLog(pMac, LOGE, FL(" fail to save preferred network"));
8884 }
8885 }
8886 else
8887 {
Jeff Johnsonafeb9582013-11-22 18:39:00 -08008888 smsLog(pMac, LOGE, FL(" not enough data length %u needed %zu"),
Srikant Kuppa066904f2013-05-07 13:56:02 -07008889 pPrefNetworkFoundInd->mesgLen, sizeof(tSirPrefNetworkFoundInd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 }
8891
Srikant Kuppa066904f2013-05-07 13:56:02 -07008892 /* Call Preferred Netowrk Found Indication callback routine. */
8893 if (HAL_STATUS_SUCCESS(status) && (pMac->pmc.prefNetwFoundCB != NULL))
8894 {
8895 pMac->pmc.prefNetwFoundCB(
8896 pMac->pmc.preferredNetworkFoundIndCallbackContext,
8897 pPrefNetworkFoundInd);
8898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008899 }
8900 else
8901 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008902 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008903 status = eHAL_STATUS_FAILURE;
8904 }
8905 }
8906
8907
8908 return(status);
8909}
8910
8911#endif // FEATURE_WLAN_SCAN_PNO
8912
8913
8914eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
8915{
8916 eHalStatus status = eHAL_STATUS_FAILURE;
8917 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008918
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 status = sme_AcquireGlobalLock( &pMac->sme );
8920 if ( HAL_STATUS_SUCCESS( status ) )
8921 {
8922 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
8923 sme_ReleaseGlobalLock( &pMac->sme );
8924 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008925
Jeff Johnson295189b2012-06-20 16:38:30 -07008926 return (status);
8927}
8928
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05308929eHalStatus sme_SetCfgScanControlList(tHalHandle hHal, tANI_U8 *countryCode, tCsrChannel *pChannelList)
8930{
8931 eHalStatus status = eHAL_STATUS_SUCCESS;
8932 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8933
8934 status = sme_AcquireGlobalLock( &pMac->sme );
8935 if ( HAL_STATUS_SUCCESS( status ) )
8936 {
8937 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
8938 sme_ReleaseGlobalLock( &pMac->sme );
8939 }
8940
8941 return (status);
8942}
Jeff Johnson295189b2012-06-20 16:38:30 -07008943
8944/* ---------------------------------------------------------------------------
8945
8946 \fn sme_SetTxPerTracking
8947
8948 \brief Set Tx PER tracking configuration parameters
8949
8950 \param hHal - The handle returned by macOpen.
8951 \param pTxPerTrackingConf - Tx PER configuration parameters
8952
8953 \return eHalStatus
8954
8955 -------------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008956eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
8957 void (*pCallbackfn) (void *pCallbackContext),
Jeff Johnson295189b2012-06-20 16:38:30 -07008958 void *pCallbackContext,
8959 tpSirTxPerTrackingParam pTxPerTrackingParam)
8960{
8961 vos_msg_t msg;
8962 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
8963 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8964
8965 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
8966 {
8967 pMac->sme.pTxPerHitCallback = pCallbackfn;
8968 pMac->sme.pTxPerHitCbContext = pCallbackContext;
8969 sme_ReleaseGlobalLock( &pMac->sme );
8970 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07008971
Jeff Johnson295189b2012-06-20 16:38:30 -07008972 // free this memory in failure case or WDA request callback function
8973 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
8974 if (NULL == pTxPerTrackingParamReq)
8975 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008976 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 -07008977 return eHAL_STATUS_FAILURE;
8978 }
8979
Kiet Lam64c1b492013-07-12 13:56:44 +05308980 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam,
8981 sizeof(tSirTxPerTrackingParam));
Jeff Johnson295189b2012-06-20 16:38:30 -07008982 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
8983 msg.reserved = 0;
8984 msg.bodyptr = pTxPerTrackingParamReq;
8985
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05308986 MTRACE(vos_trace(VOS_MODULE_ID_SME,
8987 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
8989 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008990 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 -07008991 vos_mem_free(pTxPerTrackingParamReq);
8992 return eHAL_STATUS_FAILURE;
8993 }
8994
8995 return eHAL_STATUS_SUCCESS;
8996}
8997
8998/* ---------------------------------------------------------------------------
8999
9000 \fn sme_HandleChangeCountryCode
9001
9002 \brief Change Country code, Reg Domain and channel list
9003
9004 \details Country Code Priority
9005 0 = 11D > Configured Country > NV
9006 1 = Configured Country > 11D > NV
9007 If Supplicant country code is priority than 11d is disabled.
9008 If 11D is enabled, we update the country code after every scan.
9009 Hence when Supplicant country code is priority, we don't need 11D info.
9010 Country code from Supplicant is set as current courtry code.
9011 User can send reset command XX (instead of country code) to reset the
9012 country code to default values which is read from NV.
9013 In case of reset, 11D is enabled and default NV code is Set as current country code
9014 If 11D is priority,
9015 Than Supplicant country code code is set to default code. But 11D code is set as current country code
9016
9017 \param pMac - The handle returned by macOpen.
9018 \param pMsgBuf - MSG Buffer
9019
9020 \return eHalStatus
9021
9022 -------------------------------------------------------------------------------*/
9023eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
9024{
9025 eHalStatus status = eHAL_STATUS_SUCCESS;
9026 tAniChangeCountryCodeReq *pMsg;
Amar Singhal0d15bd52013-10-12 23:13:13 -07009027 v_REGDOMAIN_t domainIdIoctl;
Jeff Johnson295189b2012-06-20 16:38:30 -07009028 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9029 static uNvTables nvTables;
9030 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
9031
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +05309032 if (pMac->scan.fcc_constraint)
9033 {
9034 pMac->scan.fcc_constraint = false;
9035 if (VOS_TRUE== vos_mem_compare(pMac->scan.countryCodeCurrent,
9036 pMsg->countryCode, 2))
9037 {
9038 csrInitGetChannels(pMac);
9039 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
9040 csrScanFilterResults(pMac);
9041 return status ;
9042 }
9043 }
9044
Jeff Johnson295189b2012-06-20 16:38:30 -07009045
9046 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
9047 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
9048 {
9049 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
9050
9051 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
9052
9053 /* read the country code from NV and use it */
9054 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
9055 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309056 vos_mem_copy(pMsg->countryCode,
9057 nvTables.defaultCountryTable.countryCode,
9058 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009059 }
9060 else
9061 {
9062 status = eHAL_STATUS_FAILURE;
9063 return status;
9064 }
Abhishek Singh4d6b54c2014-10-14 12:31:00 +05309065 /* Update the 11d country to default country from NV bin so that when
9066 * callback is received for this default country, driver will not
9067 * disable the 11d taking it as valid country by user.
9068 */
9069 smsLog(pMac, LOG1,
9070 FL("Set default country code (%c%c) from NV as invalid country received"),
9071 pMsg->countryCode[0],pMsg->countryCode[1]);
9072 vos_mem_copy(pMac->scan.countryCode11d, pMsg->countryCode,
9073 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 }
9075 else
9076 {
9077 /* if Supplicant country code has priority, disable 11d */
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05309078 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
9079 pMsg->countryFromUserSpace)
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 {
9081 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
9082 }
9083 }
9084
9085 /* WEXT set country code means
9086 * 11D should be supported?
9087 * 11D Channel should be enforced?
9088 * 11D Country code should be matched?
9089 * 11D Reg Domian should be matched?
9090 * Country string changed */
9091 if(pMac->roam.configParam.Is11dSupportEnabled &&
9092 pMac->roam.configParam.fEnforce11dChannels &&
9093 pMac->roam.configParam.fEnforceCountryCodeMatch &&
9094 pMac->roam.configParam.fEnforceDefaultDomain &&
9095 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
9096 {
9097 /* All 11D related options are already enabled
9098 * Country string is not changed
9099 * Do not need do anything for country code change request */
9100 return eHAL_STATUS_SUCCESS;
9101 }
9102
9103 /* Set Current Country code and Current Regulatory domain */
9104 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
9105 if(eHAL_STATUS_SUCCESS != status)
9106 {
9107 /* Supplicant country code failed. So give 11D priority */
9108 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
9109 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009110 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009111 }
9112
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 /* overwrite the defualt country code */
Kiet Lam64c1b492013-07-12 13:56:44 +05309114 vos_mem_copy(pMac->scan.countryCodeDefault,
9115 pMac->scan.countryCodeCurrent,
9116 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009117
9118 /* Get Domain ID from country code */
Kiet Lam6c583332013-10-14 05:37:09 +05309119 status = csrGetRegulatoryDomainForCountry(pMac,
9120 pMac->scan.countryCodeCurrent,
9121 (v_REGDOMAIN_t *) &domainIdIoctl,
9122 COUNTRY_QUERY);
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 if ( status != eHAL_STATUS_SUCCESS )
9124 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009125 smsLog( pMac, LOGE, FL(" fail to get regId %d"), domainIdIoctl );
Jeff Johnson295189b2012-06-20 16:38:30 -07009126 return status;
9127 }
Tushnim Bhattacharyya796ffe82013-11-05 16:31:36 -08009128 else if (REGDOMAIN_WORLD == domainIdIoctl)
9129 {
9130 /* Supplicant country code is invalid, so we are on world mode now. So
9131 give 11D chance to update */
9132 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
9133 smsLog(pMac, LOG1, FL("Country Code unrecognized by driver"));
9134 }
9135
Jeff Johnson295189b2012-06-20 16:38:30 -07009136
Abhishek Singha306a442013-11-07 18:39:01 +05309137 status = WDA_SetRegDomain(pMac, domainIdIoctl, pMsg->sendRegHint);
Jeff Johnson295189b2012-06-20 16:38:30 -07009138
9139 if ( status != eHAL_STATUS_SUCCESS )
9140 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009141 smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainIdIoctl );
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 return status;
9143 }
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009144 else
9145 {
9146 //if 11d has priority, clear currentCountryBssid & countryCode11d to get
9147 //set again if we find AP with 11d info during scan
Sachin Ahujacb64fc82015-01-12 17:01:05 +05309148 status = csrSetRegulatoryDomain(pMac, domainIdIoctl, NULL);
9149 if (status != eHAL_STATUS_SUCCESS)
9150 {
9151 smsLog( pMac, LOGE, FL("fail to set regId.status : %d"), status);
9152 }
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009153 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority)
9154 {
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009155 smsLog( pMac, LOGW, FL("Clearing currentCountryBssid, countryCode11d"));
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009156 vos_mem_zero(&pMac->scan.currentCountryBssid, sizeof(tCsrBssid));
9157 vos_mem_zero( pMac->scan.countryCode11d, sizeof( pMac->scan.countryCode11d ) );
9158 }
9159 }
Kiet Lam6c583332013-10-14 05:37:09 +05309160#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 /* set to default domain ID */
9162 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
9163
9164 /* get the channels based on new cc */
9165 status = csrInitGetChannels( pMac );
9166
9167 if ( status != eHAL_STATUS_SUCCESS )
9168 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009169 smsLog( pMac, LOGE, FL(" fail to get Channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 return status;
9171 }
9172
9173 /* reset info based on new cc, and we are done */
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08009174 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Agarwal Ashishfaef6692014-01-29 19:40:30 +05309175 /* Country code Changed, Purge Only scan result
9176 * which does not have channel number belong to 11d
9177 * channel list
9178 */
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05309179 csrScanFilterResults(pMac);
Agarwal Ashishfaef6692014-01-29 19:40:30 +05309180
Kiet Lam6c583332013-10-14 05:37:09 +05309181#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009182 if( pMsg->changeCCCallback )
9183 {
9184 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
9185 }
9186
9187 return eHAL_STATUS_SUCCESS;
9188}
9189
Amar Singhal0d15bd52013-10-12 23:13:13 -07009190/* ---------------------------------------------------------------------------
9191
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009192 \fn sme_HandleChangeCountryCodeByUser
Amar Singhal0d15bd52013-10-12 23:13:13 -07009193
9194 \brief Change Country code, Reg Domain and channel list
9195
9196 If Supplicant country code is priority than 11d is disabled.
9197 If 11D is enabled, we update the country code after every scan.
9198 Hence when Supplicant country code is priority, we don't need 11D info.
9199 Country code from Supplicant is set as current country code.
9200
9201 \param pMac - The handle returned by macOpen.
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009202 \param pMsg - Carrying new CC & domain set in kernel by user
Amar Singhal0d15bd52013-10-12 23:13:13 -07009203
9204 \return eHalStatus
9205
9206 -------------------------------------------------------------------------------*/
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009207eHalStatus sme_HandleChangeCountryCodeByUser(tpAniSirGlobal pMac,
9208 tAniGenericChangeCountryCodeReq *pMsg)
Amar Singhal0d15bd52013-10-12 23:13:13 -07009209{
9210 eHalStatus status = eHAL_STATUS_SUCCESS;
Amar Singhal0d15bd52013-10-12 23:13:13 -07009211 v_REGDOMAIN_t reg_domain_id;
Kiet Lam6c583332013-10-14 05:37:09 +05309212 v_BOOL_t is11dCountry = VOS_FALSE;
Amar Singhal0d15bd52013-10-12 23:13:13 -07009213
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009214 smsLog(pMac, LOG1, FL(" called"));
Amar Singhal0d15bd52013-10-12 23:13:13 -07009215 reg_domain_id = (v_REGDOMAIN_t)pMsg->domain_index;
9216
Kiet Lam6c583332013-10-14 05:37:09 +05309217 if (memcmp(pMsg->countryCode, pMac->scan.countryCode11d,
9218 VOS_COUNTRY_CODE_LEN) == 0)
9219 {
9220 is11dCountry = VOS_TRUE;
9221 }
Amar Singhal0d15bd52013-10-12 23:13:13 -07009222
Sachin Ahuja120bf632015-02-24 18:06:34 +05309223 smsLog( pMac, LOG1, FL("pMsg->countryCode : %c%c,"
9224 "pMac->scan.countryCode11d : %c%c\n"),
9225 pMsg->countryCode[0], pMsg->countryCode[1],
9226 pMac->scan.countryCode11d[0], pMac->scan.countryCode11d[1]);
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05309227 /* Set the country code given by userspace when 11dOriginal is FALSE
9228 * when 11doriginal is True,is11dCountry =0 and
9229 * fSupplicantCountryCodeHasPriority = 0, then revert the country code,
9230 * and return failure
9231 */
9232 if (pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
Amar Singhal97a2d992013-11-19 10:58:07 -08009233 {
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309234 if ((!is11dCountry) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority)&&
9235 (!pMac->roam.configParam.fEnforceCountryCode) )
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05309236 {
Amar Singhal97a2d992013-11-19 10:58:07 -08009237
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05309238 smsLog( pMac, LOGW, FL(" incorrect country being set, nullify this request"));
Amar Singhal97a2d992013-11-19 10:58:07 -08009239
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05309240 status = csrGetRegulatoryDomainForCountry(pMac,
Amar Singhal97a2d992013-11-19 10:58:07 -08009241 pMac->scan.countryCode11d,
9242 (v_REGDOMAIN_t *) &reg_domain_id,
9243 COUNTRY_IE);
9244
Agarwal Ashish04dd7c72014-04-24 14:25:28 +05309245 return eHAL_STATUS_FAILURE;
9246 }
Amar Singhal97a2d992013-11-19 10:58:07 -08009247 }
Amar Singhal0d15bd52013-10-12 23:13:13 -07009248 /* if Supplicant country code has priority, disable 11d */
Sachin Ahuja120bf632015-02-24 18:06:34 +05309249 if ((!is11dCountry) &&
9250 (pMac->roam.configParam.fSupplicantCountryCodeHasPriority) &&
9251 (!pMac->roam.configParam.fEnforceCountryCode))
Amar Singhal0d15bd52013-10-12 23:13:13 -07009252 {
9253 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +05309254 smsLog( pMac, LOG1, FL(" 11d is being disabled"));
Amar Singhal0d15bd52013-10-12 23:13:13 -07009255 }
9256
Sachin Ahuja120bf632015-02-24 18:06:34 +05309257 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Kiet Lamf2f201e2013-11-16 21:24:16 +05309258 vos_mem_copy(pMac->scan.countryCodeCurrent, pMsg->countryCode,
Amar Singhal0d15bd52013-10-12 23:13:13 -07009259 WNI_CFG_COUNTRY_CODE_LEN);
Sachin Ahuja120bf632015-02-24 18:06:34 +05309260 vos_mem_copy(pMac->scan.countryCode11d, pMsg->countryCode,
9261 WNI_CFG_COUNTRY_CODE_LEN);
9262
Amar Singhal0d15bd52013-10-12 23:13:13 -07009263
Sachin Ahujacb64fc82015-01-12 17:01:05 +05309264 status = csrSetRegulatoryDomain(pMac, reg_domain_id, NULL);
9265 if (status != eHAL_STATUS_SUCCESS)
9266 {
9267 smsLog( pMac, LOGE, FL("fail to set regId.status : %d"), status);
9268 }
Abhishek Singha306a442013-11-07 18:39:01 +05309269 status = WDA_SetRegDomain(pMac, reg_domain_id, eSIR_TRUE);
Amar Singhal0d15bd52013-10-12 23:13:13 -07009270
Kiet Lam6c583332013-10-14 05:37:09 +05309271 if (VOS_FALSE == is11dCountry )
9272 {
9273 /* overwrite the defualt country code */
Kiet Lamf2f201e2013-11-16 21:24:16 +05309274 vos_mem_copy(pMac->scan.countryCodeDefault,
Kiet Lam6c583332013-10-14 05:37:09 +05309275 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
9276 /* set to default domain ID */
9277 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
9278 }
9279
Amar Singhal0d15bd52013-10-12 23:13:13 -07009280 if ( status != eHAL_STATUS_SUCCESS )
9281 {
9282 smsLog( pMac, LOGE, FL(" fail to set regId %d"), reg_domain_id );
Kiet Lam6c583332013-10-14 05:37:09 +05309283 return status;
Amar Singhal0d15bd52013-10-12 23:13:13 -07009284 }
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009285 else
9286 {
9287 //if 11d has priority, clear currentCountryBssid & countryCode11d to get
9288 //set again if we find AP with 11d info during scan
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009289 if((!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) &&
9290 (VOS_FALSE == is11dCountry ))
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009291 {
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009292 smsLog( pMac, LOGW, FL("Clearing currentCountryBssid, countryCode11d"));
Tushnim Bhattacharyyac3022ef2013-10-24 15:58:56 -07009293 vos_mem_zero(&pMac->scan.currentCountryBssid, sizeof(tCsrBssid));
9294 vos_mem_zero( pMac->scan.countryCode11d, sizeof( pMac->scan.countryCode11d ) );
9295 }
9296 }
Amar Singhal0d15bd52013-10-12 23:13:13 -07009297
Amar Singhal0d15bd52013-10-12 23:13:13 -07009298 /* get the channels based on new cc */
9299 status = csrInitGetChannels(pMac);
9300
9301 if ( status != eHAL_STATUS_SUCCESS )
9302 {
9303 smsLog( pMac, LOGE, FL(" fail to get Channels "));
9304 return status;
9305 }
9306
9307 /* reset info based on new cc, and we are done */
9308 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Kiet Lam6c583332013-10-14 05:37:09 +05309309 if (VOS_TRUE == is11dCountry)
9310 {
Kiet Lam6c583332013-10-14 05:37:09 +05309311 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_TRUE;
9312 pMac->scan.f11dInfoReset = eANI_BOOLEAN_FALSE;
9313 }
Agarwal Ashishfaef6692014-01-29 19:40:30 +05309314 /* Country code Changed, Purge Only scan result
9315 * which does not have channel number belong to 11d
9316 * channel list
9317 */
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05309318 csrScanFilterResults(pMac);
Kiet Lambd5cd9b2013-11-11 19:01:45 +05309319 // Do active scans after the country is set by User hints or Country IE
9320 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
Sushant Kaushik1d732562014-05-21 14:15:37 +05309321 sme_DisconnectConnectedSessions(pMac);
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009322 smsLog(pMac, LOG1, FL(" returned"));
9323 return eHAL_STATUS_SUCCESS;
9324}
9325
9326/* ---------------------------------------------------------------------------
9327
Kiet Lamcffc5862013-10-30 16:28:45 +05309328 \fn sme_HandleChangeCountryCodeByCore
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009329
9330 \brief Update Country code in the driver if set by kernel as world
9331
9332 If 11D is enabled, we update the country code after every scan & notify kernel.
9333 This is to make sure kernel & driver are in sync in case of CC found in
9334 driver but not in kernel database
9335
9336 \param pMac - The handle returned by macOpen.
9337 \param pMsg - Carrying new CC set in kernel
9338
9339 \return eHalStatus
9340
9341 -------------------------------------------------------------------------------*/
Kiet Lamcffc5862013-10-30 16:28:45 +05309342eHalStatus sme_HandleChangeCountryCodeByCore(tpAniSirGlobal pMac, tAniGenericChangeCountryCodeReq *pMsg)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009343{
Kiet Lamcffc5862013-10-30 16:28:45 +05309344 eHalStatus status;
9345
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009346 smsLog(pMac, LOG1, FL(" called"));
9347
9348 //this is to make sure kernel & driver are in sync in case of CC found in
9349 //driver but not in kernel database
9350 if (('0' == pMsg->countryCode[0]) && ('0' == pMsg->countryCode[1]))
9351 {
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08009352 smsLog( pMac, LOGW, FL("Setting countryCode11d & countryCodeCurrent to world CC"));
Kiet Lamf2f201e2013-11-16 21:24:16 +05309353 vos_mem_copy(pMac->scan.countryCode11d, pMsg->countryCode,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009354 WNI_CFG_COUNTRY_CODE_LEN);
Kiet Lamf2f201e2013-11-16 21:24:16 +05309355 vos_mem_copy(pMac->scan.countryCodeCurrent, pMsg->countryCode,
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08009356 WNI_CFG_COUNTRY_CODE_LEN);
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009357 }
Kiet Lamcffc5862013-10-30 16:28:45 +05309358
Abhishek Singha306a442013-11-07 18:39:01 +05309359 status = WDA_SetRegDomain(pMac, REGDOMAIN_WORLD, eSIR_TRUE);
Kiet Lamcffc5862013-10-30 16:28:45 +05309360
9361 if ( status != eHAL_STATUS_SUCCESS )
9362 {
9363 smsLog( pMac, LOGE, FL(" fail to set regId") );
9364 return status;
9365 }
9366 else
9367 {
Sachin Ahujacb64fc82015-01-12 17:01:05 +05309368 status = csrSetRegulatoryDomain(pMac, REGDOMAIN_WORLD, NULL);
9369 if (status != eHAL_STATUS_SUCCESS)
9370 {
9371 smsLog( pMac, LOGE, FL("fail to set regId.status : %d"), status);
9372 }
Kiet Lamcffc5862013-10-30 16:28:45 +05309373 status = csrInitGetChannels(pMac);
9374 if ( status != eHAL_STATUS_SUCCESS )
9375 {
9376 smsLog( pMac, LOGE, FL(" fail to get Channels "));
9377 }
9378 else
9379 {
9380 csrInitChannelList(pMac);
9381 }
9382 }
Agarwal Ashishfaef6692014-01-29 19:40:30 +05309383 /* Country code Changed, Purge Only scan result
9384 * which does not have channel number belong to 11d
9385 * channel list
9386 */
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05309387 csrScanFilterResults(pMac);
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009388 smsLog(pMac, LOG1, FL(" returned"));
9389 return eHAL_STATUS_SUCCESS;
9390}
9391
9392/* ---------------------------------------------------------------------------
9393
Sushant Kaushik1d732562014-05-21 14:15:37 +05309394 \fn sme_DisconnectConnectedSessions
9395
9396 \brief Disconnect STA and P2P client session if channel is not supported
9397
9398 If new country code does not support the channel on which STA/P2P client
9399 is connetced, it sends the disconnect to the AP/P2P GO
9400
9401 \param pMac - The handle returned by macOpen
9402
9403 \return eHalStatus
9404
9405 -------------------------------------------------------------------------------*/
9406
9407void sme_DisconnectConnectedSessions(tpAniSirGlobal pMac)
9408{
9409 v_U8_t i, sessionId, isChanFound = false;
9410 tANI_U8 currChannel;
9411
9412 for (sessionId=0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
9413 {
9414 if (csrIsSessionClientAndConnected(pMac, sessionId))
9415 {
9416 isChanFound = false;
9417 //Session is connected.Check the channel
9418 currChannel = csrGetInfraOperationChannel(pMac, sessionId);
9419 smsLog(pMac, LOGW, "Current Operating channel : %d, session :%d",
9420 currChannel, sessionId);
9421 for (i=0; i < pMac->scan.base20MHzChannels.numChannels; i++)
9422 {
9423 if (pMac->scan.base20MHzChannels.channelList[i] == currChannel)
9424 {
9425 isChanFound = true;
9426 break;
9427 }
9428 }
9429
9430 if (!isChanFound)
9431 {
9432 for (i=0; i < pMac->scan.base40MHzChannels.numChannels; i++)
9433 {
9434 if (pMac->scan.base40MHzChannels.channelList[i] == currChannel)
9435 {
9436 isChanFound = true;
9437 break;
9438 }
9439 }
9440 }
9441 if (!isChanFound)
9442 {
9443 smsLog(pMac, LOGW, "%s : Disconnect Session :%d", __func__, sessionId);
9444 csrRoamDisconnect(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9445 }
9446 }
9447 }
9448}
9449/* ---------------------------------------------------------------------------
9450
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009451 \fn sme_HandleGenericChangeCountryCode
9452
9453 \brief Change Country code, Reg Domain and channel list
9454
9455 If Supplicant country code is priority than 11d is disabled.
9456 If 11D is enabled, we update the country code after every scan.
9457 Hence when Supplicant country code is priority, we don't need 11D info.
9458 Country code from kernel is set as current country code.
9459
9460 \param pMac - The handle returned by macOpen.
9461 \param pMsgBuf - message buffer
9462
9463 \return eHalStatus
9464
9465 -------------------------------------------------------------------------------*/
9466eHalStatus sme_HandleGenericChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
9467{
9468 tAniGenericChangeCountryCodeReq *pMsg;
9469 v_REGDOMAIN_t reg_domain_id;
9470
9471 smsLog(pMac, LOG1, FL(" called"));
9472 pMsg = (tAniGenericChangeCountryCodeReq *)pMsgBuf;
9473 reg_domain_id = (v_REGDOMAIN_t)pMsg->domain_index;
9474
9475 if (REGDOMAIN_COUNT == reg_domain_id)
9476 {
Kiet Lamcffc5862013-10-30 16:28:45 +05309477 sme_HandleChangeCountryCodeByCore(pMac, pMsg);
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07009478 }
9479 else
9480 {
9481 sme_HandleChangeCountryCodeByUser(pMac, pMsg);
9482 }
9483 smsLog(pMac, LOG1, FL(" returned"));
Amar Singhal0d15bd52013-10-12 23:13:13 -07009484 return eHAL_STATUS_SUCCESS;
9485}
9486
Jeff Johnson295189b2012-06-20 16:38:30 -07009487#ifdef WLAN_FEATURE_PACKET_FILTERING
Amar Singhalf3a6e762013-02-19 15:06:50 -08009488eHalStatus sme_8023MulticastList (tHalHandle hHal, tANI_U8 sessionId, tpSirRcvFltMcAddrList pMulticastAddrs)
Jeff Johnson295189b2012-06-20 16:38:30 -07009489{
9490 tpSirRcvFltMcAddrList pRequestBuf;
9491 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07009492 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnsone7245742012-09-05 17:12:55 -07009493 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009494
9495 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
Jeff Johnson89477502017-09-19 08:35:23 -07009496 "ulMulticastAddrCnt=%d, multicastAddr[0]=%pK", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 pMulticastAddrs->ulMulticastAddrCnt,
9498 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07009499
9500 /*
9501 *Find the connected Infra / P2P_client connected session
Amar Singhalf3a6e762013-02-19 15:06:50 -08009502 */
9503 if (CSR_IS_SESSION_VALID(pMac, sessionId) &&
9504 csrIsConnStateInfra(pMac, sessionId))
9505 {
9506 pSession = CSR_GET_SESSION( pMac, sessionId );
9507 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009508
9509 if(pSession == NULL )
9510 {
Anurag Chouhan65ea6dc2016-10-25 19:59:14 +05309511 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN, "%s: Unable to find "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009512 "the right session", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07009513 return eHAL_STATUS_FAILURE;
9514 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08009515
Jeff Johnson295189b2012-06-20 16:38:30 -07009516 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9517 if (NULL == pRequestBuf)
9518 {
9519 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009520 "allocate memory for 8023 Multicast List request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 return eHAL_STATUS_FAILED_ALLOC;
9522 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08009523
9524 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
9525 {
9526 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
9527 "indication as we are not connected", __func__);
9528 vos_mem_free(pRequestBuf);
9529 return eHAL_STATUS_FAILURE;
9530 }
9531
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
9533
Kiet Lam64c1b492013-07-12 13:56:44 +05309534 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr,
9535 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07009536 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
9537 sizeof(tSirMacAddr));
9538
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 msg.type = WDA_8023_MULTICAST_LIST_REQ;
9540 msg.reserved = 0;
9541 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05309542 MTRACE(vos_trace(VOS_MODULE_ID_SME,
9543 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
9545 {
9546 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009547 "post WDA_8023_MULTICAST_LIST message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 vos_mem_free(pRequestBuf);
9549 return eHAL_STATUS_FAILURE;
9550 }
9551
9552 return eHAL_STATUS_SUCCESS;
9553}
9554
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009555eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
Jeff Johnsone7245742012-09-05 17:12:55 -07009556 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07009557{
9558 tpSirRcvPktFilterCfgType pRequestBuf;
9559 v_SINT_t allocSize;
9560 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07009561 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9562 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009563 v_U8_t idx=0;
9564
9565 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009566 "filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009567 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009568
Madan Mohan Koyyalamudid4029622012-10-18 20:30:17 -07009569 allocSize = sizeof(tSirRcvPktFilterCfgType);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009570
Jeff Johnson295189b2012-06-20 16:38:30 -07009571 pRequestBuf = vos_mem_malloc(allocSize);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009572
9573 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 {
9575 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009576 "allocate memory for Receive Filter Set Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009577 return eHAL_STATUS_FAILED_ALLOC;
9578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009579
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009580 if( NULL == pSession )
9581 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009582 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Session Not found ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009583 vos_mem_free(pRequestBuf);
9584 return eHAL_STATUS_FAILURE;
9585 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009586
Kiet Lam64c1b492013-07-12 13:56:44 +05309587 vos_mem_copy(pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr,
9588 sizeof(tSirMacAddr));
9589 vos_mem_copy(pRcvPktFilterCfg->bssId, pSession->connectedProfile.bssid,
9590 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009591 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
9592
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
9594 msg.reserved = 0;
9595 msg.bodyptr = pRequestBuf;
9596
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05309597 MTRACE(vos_trace(VOS_MODULE_ID_SME,
9598 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07009599 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009600 "FT %d FID %d ",
9601 pRequestBuf->filterType, pRequestBuf->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009602
9603 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009604 "params %d CT %d",
9605 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07009606
9607 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
9608 {
9609
9610 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009611 "Proto %d Comp Flag %d ",
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 pRequestBuf->paramsData[idx].protocolLayer,
9613 pRequestBuf->paramsData[idx].cmpFlag);
9614
9615 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009616 "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009617 pRequestBuf->paramsData[idx].dataOffset,
9618 pRequestBuf->paramsData[idx].dataLength);
9619
9620 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009621 "CData: %d:%d:%d:%d:%d:%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 pRequestBuf->paramsData[idx].compareData[0],
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009623 pRequestBuf->paramsData[idx].compareData[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07009624 pRequestBuf->paramsData[idx].compareData[2],
9625 pRequestBuf->paramsData[idx].compareData[3],
9626 pRequestBuf->paramsData[idx].compareData[4],
9627 pRequestBuf->paramsData[idx].compareData[5]);
9628
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009629 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009630 "MData: %d:%d:%d:%d:%d:%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009631 pRequestBuf->paramsData[idx].dataMask[0],
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009632 pRequestBuf->paramsData[idx].dataMask[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 pRequestBuf->paramsData[idx].dataMask[2],
9634 pRequestBuf->paramsData[idx].dataMask[3],
9635 pRequestBuf->paramsData[idx].dataMask[4],
9636 pRequestBuf->paramsData[idx].dataMask[5]);
9637
9638 }
9639
9640 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
9641 {
9642 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009643 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 vos_mem_free(pRequestBuf);
9645 return eHAL_STATUS_FAILURE;
9646 }
9647
9648 return eHAL_STATUS_SUCCESS;
9649}
9650
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009651eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009652 FilterMatchCountCallback callbackRoutine,
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009653 void *callbackContext,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009654 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07009655{
9656 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9657 eHalStatus status;
9658
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009659 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009660
9661 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
9662 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009663 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009664 sme_ReleaseGlobalLock( &pMac->sme );
9665 }
9666
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009667 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009668
9669 return (status);
9670}
9671
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009672eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
Jeff Johnsone7245742012-09-05 17:12:55 -07009673 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07009674{
9675 tpSirRcvFltPktClearParam pRequestBuf;
9676 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07009677 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9678 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009679
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009680 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009681 pRcvFltPktClearParam->filterId);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009682
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009684 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 {
9686 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9687 "%s: Not able to allocate memory for Receive Filter "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009688 "Clear Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009689 return eHAL_STATUS_FAILED_ALLOC;
9690 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009691 if( NULL == pSession )
9692 {
9693 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009694 "%s: Session Not find ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009695 vos_mem_free(pRequestBuf);
9696 return eHAL_STATUS_FAILURE;
9697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009698
Kiet Lam64c1b492013-07-12 13:56:44 +05309699 vos_mem_copy(pRcvFltPktClearParam->selfMacAddr, pSession->selfMacAddr,
9700 sizeof(tSirMacAddr));
9701 vos_mem_copy(pRcvFltPktClearParam->bssId, pSession->connectedProfile.bssid,
9702 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07009703
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009704 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
9705
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
9707 msg.reserved = 0;
9708 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05309709 MTRACE(vos_trace(VOS_MODULE_ID_SME,
9710 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07009711 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
9712 {
9713 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009714 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009715 vos_mem_free(pRequestBuf);
9716 return eHAL_STATUS_FAILURE;
9717 }
9718
9719 return eHAL_STATUS_SUCCESS;
9720}
9721#endif // WLAN_FEATURE_PACKET_FILTERING
9722
9723/* ---------------------------------------------------------------------------
9724 \fn sme_PreChannelSwitchIndFullPowerCB
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009725 \brief call back function for the PMC full power request because of pre
Jeff Johnson295189b2012-06-20 16:38:30 -07009726 channel switch.
9727 \param callbackContext
9728 \param status
9729 ---------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009730void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
Jeff Johnson295189b2012-06-20 16:38:30 -07009731 eHalStatus status)
9732{
9733 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
9734 tSirMbMsg *pMsg;
9735 tANI_U16 msgLen;
9736
9737 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
Kiet Lam64c1b492013-07-12 13:56:44 +05309738 pMsg = vos_mem_malloc(msgLen);
9739 if ( NULL != pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309741 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009742 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
9743 pMsg->msgLen = pal_cpu_to_be16(msgLen);
9744 status = palSendMBMessage(pMac->hHdd, pMsg);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009745 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009746
9747 return;
9748}
9749
9750/* ---------------------------------------------------------------------------
9751 \fn sme_HandlePreChannelSwitchInd
9752 \brief Processes the indcation from PE for pre-channel switch.
9753 \param hHal
9754 \- The handle returned by macOpen. return eHalStatus
9755 ---------------------------------------------------------------------------*/
9756eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
9757{
9758 eHalStatus status = eHAL_STATUS_FAILURE;
9759 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9760 status = sme_AcquireGlobalLock( &pMac->sme );
9761 if ( HAL_STATUS_SUCCESS( status ) )
9762 {
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009763 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
9764 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 sme_ReleaseGlobalLock( &pMac->sme );
9766 }
9767
9768 return (status);
9769}
9770
9771/* ---------------------------------------------------------------------------
9772 \fn sme_HandlePostChannelSwitchInd
9773 \brief Processes the indcation from PE for post-channel switch.
9774 \param hHal
9775 \- The handle returned by macOpen. return eHalStatus
9776 ---------------------------------------------------------------------------*/
9777eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
9778{
9779 eHalStatus status = eHAL_STATUS_FAILURE;
9780 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9781
9782 status = sme_AcquireGlobalLock( &pMac->sme );
9783 if ( HAL_STATUS_SUCCESS( status ) )
9784 {
9785 status = pmcRequestBmps(hHal, NULL, NULL);
9786 sme_ReleaseGlobalLock( &pMac->sme );
9787 }
9788
9789 return (status);
9790}
9791
9792/* ---------------------------------------------------------------------------
9793
9794 \fn sme_IsChannelValid
9795
9796 \brief To check if the channel is valid for currently established domain
9797 This is a synchronous API.
9798
9799 \param hHal - The handle returned by macOpen.
9800 \param channel - channel to verify
9801
9802 \return TRUE/FALSE, TRUE if channel is valid
9803
9804 -------------------------------------------------------------------------------*/
9805tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
9806{
9807 eHalStatus status = eHAL_STATUS_FAILURE;
9808 tANI_BOOLEAN valid = FALSE;
9809 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009810
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 status = sme_AcquireGlobalLock( &pMac->sme );
9812 if ( HAL_STATUS_SUCCESS( status ) )
9813 {
9814
9815 valid = csrRoamIsChannelValid( pMac, channel);
9816
9817 sme_ReleaseGlobalLock( &pMac->sme );
9818 }
9819
9820 return (valid);
9821}
9822
9823/* ---------------------------------------------------------------------------
9824 \fn sme_SetFreqBand
9825 \brief Used to set frequency band.
9826 \param hHal
9827 \eBand band value to be configured
9828 \- return eHalStatus
9829 -------------------------------------------------------------------------*/
9830eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
9831{
9832 eHalStatus status = eHAL_STATUS_FAILURE;
9833 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9834
9835 status = sme_AcquireGlobalLock( &pMac->sme );
9836 if ( HAL_STATUS_SUCCESS( status ) )
9837 {
9838 status = csrSetBand(hHal, eBand);
9839 sme_ReleaseGlobalLock( &pMac->sme );
9840 }
9841 return status;
9842}
9843
9844/* ---------------------------------------------------------------------------
9845 \fn sme_GetFreqBand
9846 \brief Used to get the current band settings.
9847 \param hHal
9848 \pBand pointer to hold band value
9849 \- return eHalStatus
9850 -------------------------------------------------------------------------*/
9851eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
9852{
9853 eHalStatus status = eHAL_STATUS_FAILURE;
9854 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9855
9856 status = sme_AcquireGlobalLock( &pMac->sme );
9857 if ( HAL_STATUS_SUCCESS( status ) )
9858 {
9859 *pBand = csrGetCurrentBand( hHal );
9860 sme_ReleaseGlobalLock( &pMac->sme );
9861 }
9862 return status;
9863}
9864
9865#ifdef WLAN_WAKEUP_EVENTS
9866/******************************************************************************
9867 \fn sme_WakeReasonIndCallback
9868
9869 \brief
9870 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
9871
9872 \param hHal - HAL handle for device
9873 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
9874
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009875 \return eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -07009876******************************************************************************/
9877eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
9878{
9879 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9880 eHalStatus status = eHAL_STATUS_SUCCESS;
9881 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
9882
9883 if (NULL == pMsg)
9884 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009885 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 status = eHAL_STATUS_FAILURE;
9887 }
9888 else
9889 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08009890 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback");
Jeff Johnson295189b2012-06-20 16:38:30 -07009891
9892 /* Call Wake Reason Indication callback routine. */
9893 if (pMac->pmc.wakeReasonIndCB != NULL)
9894 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
Kalikinkar Dharaa4988972013-10-28 13:39:54 -07009895
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009896 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __func__, pWakeReasonInd->ulReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 }
9898
9899 return(status);
9900}
9901#endif // WLAN_WAKEUP_EVENTS
9902
9903
Abhishek Singh99a31be2015-12-10 10:37:44 +05309904/**
9905 * sme_SetMaxTxPower() - Set the Maximum Transmit Power
9906 *
9907 * @hHal: hal pointer.
9908 * @bssid: bssid to set the power cap for
9909 * @self_mac_addr:self mac address
9910 * @db: power to set in dB
9911 *
9912 * Set the maximum transmit power dynamically.
9913 *
9914 * Return: eHalStatus
9915 *
9916 */
9917eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr bssid,
9918 tSirMacAddr self_mac_addr, v_S7_t db)
Jeff Johnson295189b2012-06-20 16:38:30 -07009919{
Abhishek Singh99a31be2015-12-10 10:37:44 +05309920 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9921 eHalStatus status = eHAL_STATUS_SUCCESS;
9922 tSmeCmd *set_max_tx_pwr;
9923
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +05309924 if (pMac->max_power_cmd_pending)
9925 {
9926 smsLog(pMac, LOG1,
9927 FL("set max tx power already in progress"));
9928 return eHAL_STATUS_RESOURCES;
9929 }
9930
Abhishek Singh99a31be2015-12-10 10:37:44 +05309931 MTRACE(vos_trace(VOS_MODULE_ID_SME,
9932 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
9933 smsLog(pMac, LOG1,
9934 FL("bssid :" MAC_ADDRESS_STR " self addr: "MAC_ADDRESS_STR" power %d Db"),
9935 MAC_ADDR_ARRAY(bssid), MAC_ADDR_ARRAY(self_mac_addr), db);
9936
9937 status = sme_AcquireGlobalLock( &pMac->sme );
9938 if ( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009939 {
Abhishek Singh99a31be2015-12-10 10:37:44 +05309940 set_max_tx_pwr = csrGetCommandBuffer(pMac);
9941 if (set_max_tx_pwr)
9942 {
9943 set_max_tx_pwr->command = eSmeCommandSetMaxTxPower;
9944 vos_mem_copy(set_max_tx_pwr->u.set_tx_max_pwr.bssid,
9945 bssid, SIR_MAC_ADDR_LENGTH);
9946 vos_mem_copy(set_max_tx_pwr->u.set_tx_max_pwr.self_sta_mac_addr,
9947 self_mac_addr, SIR_MAC_ADDR_LENGTH);
9948 set_max_tx_pwr->u.set_tx_max_pwr.power = db;
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +05309949 pMac->max_power_cmd_pending = true;
Abhishek Singh99a31be2015-12-10 10:37:44 +05309950 status = csrQueueSmeCommand(pMac, set_max_tx_pwr, eANI_BOOLEAN_TRUE);
9951 if ( !HAL_STATUS_SUCCESS( status ) )
9952 {
9953 smsLog( pMac, LOGE, FL("fail to send msg status = %d"), status );
9954 csrReleaseCommandScan(pMac, set_max_tx_pwr);
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +05309955 pMac->max_power_cmd_pending = false;
Abhishek Singh99a31be2015-12-10 10:37:44 +05309956 }
9957 }
9958 else
9959 {
9960 smsLog(pMac, LOGE, FL("can not obtain a common buffer"));
9961 status = eHAL_STATUS_RESOURCES;
9962 }
9963 sme_ReleaseGlobalLock( &pMac->sme);
9964 }
9965 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009966}
9967
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05309968/**
9969 * sme_SetMaxTxPowerPerBand() - Set the Maximum Transmit Power
9970 * specific to band dynamically
9971 * @band: Band for which power needs to be applied
9972 * @dB: power to set in dB
9973 * @hal: HAL handle
9974 *
9975 * Set the maximum transmit power dynamically per band
9976 *
9977 * Return: eHalStatus
9978 */
9979eHalStatus sme_SetMaxTxPowerPerBand(eCsrBand band, v_S7_t dB,
9980 tHalHandle hal)
Arif Hussaina5ebce02013-08-09 15:09:58 -07009981{
9982 vos_msg_t msg;
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05309983 eHalStatus status;
9984 tSmeCmd *set_max_tx_pwr_per_band;
9985 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussaina5ebce02013-08-09 15:09:58 -07009986
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +05309987 if (mac_ctx->max_power_cmd_pending)
9988 {
9989 smsLog(mac_ctx, LOG1,
9990 FL("set max tx power already in progress"));
9991 return eHAL_STATUS_RESOURCES;
9992 }
9993
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05309994 smsLog(mac_ctx, LOG1,
9995 FL("band : %d power %d dB"),
9996 band, dB);
9997
9998 MTRACE(vos_trace(VOS_MODULE_ID_SME,
9999 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
10000
10001 status = sme_AcquireGlobalLock(&mac_ctx->sme);
10002 if (HAL_STATUS_SUCCESS(status)) {
10003 set_max_tx_pwr_per_band = csrGetCommandBuffer(mac_ctx);
10004 if (set_max_tx_pwr_per_band) {
10005 set_max_tx_pwr_per_band->command = eSmeCommandSetMaxTxPowerPerBand;
10006 set_max_tx_pwr_per_band->u.set_tx_max_pwr_per_band.band = band;
10007 set_max_tx_pwr_per_band->u.set_tx_max_pwr_per_band.power = dB;
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +053010008 mac_ctx->max_power_cmd_pending = true;
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +053010009 status = csrQueueSmeCommand(mac_ctx, set_max_tx_pwr_per_band,
10010 eANI_BOOLEAN_TRUE);
10011 if (!HAL_STATUS_SUCCESS(status)) {
10012 smsLog(mac_ctx, LOGE, FL("fail to send msg status = %d"), status);
10013 csrReleaseCommand(mac_ctx, set_max_tx_pwr_per_band);
Aggarwal, Nishank2dbbd3d2017-01-05 15:32:47 +053010014 mac_ctx->max_power_cmd_pending = false;
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +053010015 }
10016 } else {
10017 smsLog(mac_ctx, LOGE, FL("can not obtain a common buffer"));
10018 status = eHAL_STATUS_RESOURCES;
10019 }
10020 sme_ReleaseGlobalLock(&mac_ctx->sme);
Arif Hussaina5ebce02013-08-09 15:09:58 -070010021 }
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +053010022 return status;
Arif Hussaina5ebce02013-08-09 15:09:58 -070010023}
10024
10025/* ---------------------------------------------------------------------------
10026
schang86c22c42013-03-13 18:41:24 -070010027 \fn sme_SetTxPower
10028
10029 \brief Set Transmit Power dynamically. Note: this setting will
10030 not persist over reboots.
10031
10032 \param hHal
10033 \param sessionId Target Session ID
10034 \param mW power to set in mW
10035 \- return eHalStatus
10036
10037 -------------------------------------------------------------------------------*/
10038eHalStatus sme_SetTxPower(tHalHandle hHal, v_U8_t sessionId, v_U8_t mW)
10039{
10040
10041 eHalStatus status = eHAL_STATUS_FAILURE;
10042 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10043
Katya Nigambcb705f2013-12-26 14:26:22 +053010044 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010045 TRACE_CODE_SME_RX_HDD_SET_TXPOW, NO_SESSION, 0));
schang86c22c42013-03-13 18:41:24 -070010046 smsLog(pMac, LOG1, FL("set tx power %dmW"), mW);
10047 status = sme_AcquireGlobalLock(&pMac->sme);
10048 if (HAL_STATUS_SUCCESS(status))
10049 {
10050 status = csrSetTxPower(pMac, sessionId, mW);
10051 sme_ReleaseGlobalLock(&pMac->sme);
10052 }
10053 return status;
10054}
10055
10056/* ---------------------------------------------------------------------------
10057
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 \fn sme_HideSSID
10059
10060 \brief hide/show SSID dynamically. Note: this setting will
10061 not persist over reboots.
10062
10063 \param hHal
10064 \param sessionId
10065 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
10066 \- return eHalStatus
10067
10068 -------------------------------------------------------------------------------*/
10069eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
10070{
10071 eHalStatus status = eHAL_STATUS_SUCCESS;
10072 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10073 tANI_U16 len;
10074
10075 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
10076 {
10077 tpSirUpdateParams pMsg;
10078 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010079
10080 if(!pSession)
10081 {
10082 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -080010083 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010084 return eHAL_STATUS_FAILURE;
10085 }
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010086
10087 if( !pSession->sessionActive )
Jeff Johnson295189b2012-06-20 16:38:30 -070010088 VOS_ASSERT(0);
10089
10090 /* Create the message and send to lim */
10091 len = sizeof(tSirUpdateParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053010092 pMsg = vos_mem_malloc(len);
10093 if ( NULL == pMsg )
10094 status = eHAL_STATUS_FAILURE;
10095 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010096 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010097 vos_mem_set(pMsg, sizeof(tSirUpdateParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
10099 pMsg->length = len;
10100 /* Data starts from here */
10101 pMsg->sessionId = sessionId;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010102 pMsg->ssidHidden = ssidHidden;
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 status = palSendMBMessage(pMac->hHdd, pMsg);
10104 }
10105 sme_ReleaseGlobalLock( &pMac->sme );
10106 }
10107 return status;
10108}
Jeff Johnson295189b2012-06-20 16:38:30 -070010109
10110/* ---------------------------------------------------------------------------
10111
10112 \fn sme_SetTmLevel
10113 \brief Set Thermal Mitigation Level to RIVA
10114 \param hHal - The handle returned by macOpen.
10115 \param newTMLevel - new Thermal Mitigation Level
10116 \param tmMode - Thermal Mitigation handle mode, default 0
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010117 \return eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -070010118 ---------------------------------------------------------------------------*/
10119eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
10120{
10121 eHalStatus status = eHAL_STATUS_SUCCESS;
10122 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10123 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10124 vos_msg_t vosMessage;
10125 tAniSetTmLevelReq *setTmLevelReq = NULL;
10126
Katya Nigambcb705f2013-12-26 14:26:22 +053010127 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010128 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010129 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
10130 {
10131 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
Kiet Lam64c1b492013-07-12 13:56:44 +053010132 if (NULL == setTmLevelReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 {
10134 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010135 "%s: Not able to allocate memory for sme_SetTmLevel", __func__);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -080010136 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson295189b2012-06-20 16:38:30 -070010137 return eHAL_STATUS_FAILURE;
10138 }
10139
10140 setTmLevelReq->tmMode = tmMode;
10141 setTmLevelReq->newTmLevel = newTMLevel;
10142
10143 /* serialize the req through MC thread */
10144 vosMessage.bodyptr = setTmLevelReq;
10145 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053010146 MTRACE(vos_trace(VOS_MODULE_ID_SME,
10147 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
10149 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
10150 {
10151 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010152 "%s: Post Set TM Level MSG fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010153 vos_mem_free(setTmLevelReq);
10154 status = eHAL_STATUS_FAILURE;
10155 }
10156 sme_ReleaseGlobalLock( &pMac->sme );
10157 }
10158 return(status);
10159}
10160
10161/*---------------------------------------------------------------------------
10162
10163 \brief sme_featureCapsExchange() - SME interface to exchange capabilities between
10164 Host and FW.
10165
10166 \param hHal - HAL handle for device
10167
10168 \return NONE
10169
10170---------------------------------------------------------------------------*/
10171void sme_featureCapsExchange( tHalHandle hHal)
10172{
10173 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
Katya Nigambcb705f2013-12-26 14:26:22 +053010174 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010175 TRACE_CODE_SME_RX_HDD_CAPS_EXCH, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010176 WDA_featureCapsExchange(vosContext);
10177}
Jeff Johnsond13512a2012-07-17 11:42:19 -070010178
Yathish9f22e662012-12-10 14:21:35 -080010179/*---------------------------------------------------------------------------
10180
10181 \brief sme_disableFeatureCapablity() - SME interface to disable Active mode offload capablity
10182 in Host.
10183
10184 \param hHal - HAL handle for device
10185
10186 \return NONE
10187
10188---------------------------------------------------------------------------*/
10189void sme_disableFeatureCapablity(tANI_U8 feature_index)
10190{
10191 WDA_disableCapablityFeature(feature_index);
10192}
10193
Jeff Johnsond13512a2012-07-17 11:42:19 -070010194/* ---------------------------------------------------------------------------
10195
10196 \fn sme_GetDefaultCountryCode
10197
10198 \brief Get the default country code from NV
10199
10200 \param hHal
10201 \param pCountry
10202 \- return eHalStatus
10203
10204 -------------------------------------------------------------------------------*/
10205eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
10206{
10207 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +053010208 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010209 TRACE_CODE_SME_RX_HDD_GET_DEFCCNV, NO_SESSION, 0));
Jeff Johnsond13512a2012-07-17 11:42:19 -070010210 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
10211}
10212
10213/* ---------------------------------------------------------------------------
10214
10215 \fn sme_GetCurrentCountryCode
10216
10217 \brief Get the current country code
10218
10219 \param hHal
10220 \param pCountry
10221 \- return eHalStatus
10222
10223 -------------------------------------------------------------------------------*/
10224eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
10225{
10226 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +053010227 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010228 TRACE_CODE_SME_RX_HDD_GET_CURCC, NO_SESSION, 0));
Jeff Johnsond13512a2012-07-17 11:42:19 -070010229 return csrGetCurrentCountryCode(pMac, pCountry);
10230}
10231
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010232/* ---------------------------------------------------------------------------
10233 \fn sme_transportDebug
10234 \brief Dynamically monitoring Transport channels
10235 Private IOCTL will querry transport channel status if driver loaded
schang6295e542013-03-12 15:31:23 -070010236 \param hHal Upper MAC context
Jeff Johnsonb88db982012-12-10 13:34:59 -080010237 \param displaySnapshot Display transport channel snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010238 \param toggleStallDetect Enable stall detect feature
10239 This feature will take effect to data performance
10240 Not integrate till fully verification
10241 \- return NONE
10242 -------------------------------------------------------------------------*/
schang6295e542013-03-12 15:31:23 -070010243void sme_transportDebug(tHalHandle hHal, v_BOOL_t displaySnapshot, v_BOOL_t toggleStallDetect)
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010244{
schang6295e542013-03-12 15:31:23 -070010245 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10246
10247 if (NULL == pMac)
10248 {
10249 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10250 "%s: invalid context", __func__);
10251 return;
10252 }
10253 WDA_TransportChannelDebug(pMac, displaySnapshot, toggleStallDetect);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010254}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -080010255
Kiran4a17ebe2013-01-31 10:43:43 -080010256/* ---------------------------------------------------------------------------
10257 \fn sme_ResetPowerValuesFor5G
10258 \brief Reset the power values for 5G band with NV power values.
10259 \param hHal - HAL handle for device
10260 \- return NONE
10261 -------------------------------------------------------------------------*/
10262void sme_ResetPowerValuesFor5G (tHalHandle hHal)
10263{
10264 tpAniSirGlobal pMac = PMAC_STRUCT (hHal);
Katya Nigambcb705f2013-12-26 14:26:22 +053010265 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010266 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
Kiran4a17ebe2013-01-31 10:43:43 -080010267 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
10268 csrApplyPower2Current(pMac); // Store the channel+power info in the global place: Cfg
10269}
10270
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010271#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -080010272/* ---------------------------------------------------------------------------
10273 \fn sme_UpdateRoamPrefer5GHz
10274 \brief enable/disable Roam prefer 5G runtime option
10275 This function is called through dynamic setConfig callback function
10276 to configure the Roam prefer 5G runtime option
10277 \param hHal - HAL handle for device
10278 \param nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
10279 \- return Success or failure
10280 -------------------------------------------------------------------------*/
10281
10282eHalStatus sme_UpdateRoamPrefer5GHz(tHalHandle hHal, v_BOOL_t nRoamPrefer5GHz)
10283{
10284 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -080010285 eHalStatus status = eHAL_STATUS_SUCCESS;
10286
Katya Nigambcb705f2013-12-26 14:26:22 +053010287 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010288 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010289 status = sme_AcquireGlobalLock( &pMac->sme );
10290 if ( HAL_STATUS_SUCCESS( status ) )
10291 {
10292 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10293 "%s: gRoamPrefer5GHz is changed from %d to %d", __func__,
10294 pMac->roam.configParam.nRoamPrefer5GHz,
10295 nRoamPrefer5GHz);
10296 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
10297 sme_ReleaseGlobalLock( &pMac->sme );
10298 }
10299
10300 return status ;
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -080010301}
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -080010302
10303/* ---------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010304 \fn sme_setRoamIntraBand
10305 \brief enable/disable Intra band roaming
10306 This function is called through dynamic setConfig callback function
10307 to configure the intra band roaming
10308 \param hHal - HAL handle for device
10309 \param nRoamIntraBand Enable/Disable Intra band roaming
10310 \- return Success or failure
10311 -------------------------------------------------------------------------*/
10312eHalStatus sme_setRoamIntraBand(tHalHandle hHal, const v_BOOL_t nRoamIntraBand)
10313{
10314 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10315 eHalStatus status = eHAL_STATUS_SUCCESS;
10316
Katya Nigambcb705f2013-12-26 14:26:22 +053010317 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010318 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010319 status = sme_AcquireGlobalLock( &pMac->sme );
10320 if ( HAL_STATUS_SUCCESS( status ) )
10321 {
10322 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10323 "%s: gRoamIntraBand is changed from %d to %d", __func__,
10324 pMac->roam.configParam.nRoamIntraBand,
10325 nRoamIntraBand);
10326 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
10327 sme_ReleaseGlobalLock( &pMac->sme );
10328 }
10329
10330 return status ;
10331}
10332
10333/* ---------------------------------------------------------------------------
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010334 \fn sme_UpdateRoamScanNProbes
10335 \brief function to update roam scan N probes
10336 This function is called through dynamic setConfig callback function
10337 to update roam scan N probes
10338 \param hHal - HAL handle for device
10339 \param nProbes number of probe requests to be sent out
10340 \- return Success or failure
10341 -------------------------------------------------------------------------*/
10342eHalStatus sme_UpdateRoamScanNProbes(tHalHandle hHal, const v_U8_t nProbes)
10343{
10344 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10345 eHalStatus status = eHAL_STATUS_SUCCESS;
10346
10347 status = sme_AcquireGlobalLock( &pMac->sme );
10348 if ( HAL_STATUS_SUCCESS( status ) )
10349 {
10350 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10351 "%s: gRoamScanNProbes is changed from %d to %d", __func__,
10352 pMac->roam.configParam.nProbes,
10353 nProbes);
10354 pMac->roam.configParam.nProbes = nProbes;
10355 sme_ReleaseGlobalLock( &pMac->sme );
10356 }
10357#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10358 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
10359 {
10360 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10361 REASON_NPROBES_CHANGED);
10362 }
10363#endif
10364 return status ;
10365}
10366
10367/* ---------------------------------------------------------------------------
10368 \fn sme_UpdateRoamScanHomeAwayTime
10369 \brief function to update roam scan Home away time
10370 This function is called through dynamic setConfig callback function
10371 to update roam scan home away time
10372 \param hHal - HAL handle for device
10373 \param nRoamScanAwayTime Scan home away time
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070010374 \param bSendOffloadCmd If TRUE then send offload command to firmware
10375 If FALSE then command is not sent to firmware
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010376 \- return Success or failure
10377 -------------------------------------------------------------------------*/
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070010378eHalStatus sme_UpdateRoamScanHomeAwayTime(tHalHandle hHal, const v_U16_t nRoamScanHomeAwayTime,
10379 const eAniBoolean bSendOffloadCmd)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010380{
10381 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10382 eHalStatus status = eHAL_STATUS_SUCCESS;
10383
10384 status = sme_AcquireGlobalLock( &pMac->sme );
10385 if ( HAL_STATUS_SUCCESS( status ) )
10386 {
10387 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10388 "%s: gRoamScanHomeAwayTime is changed from %d to %d", __func__,
10389 pMac->roam.configParam.nRoamScanHomeAwayTime,
10390 nRoamScanHomeAwayTime);
10391 pMac->roam.configParam.nRoamScanHomeAwayTime = nRoamScanHomeAwayTime;
10392 sme_ReleaseGlobalLock( &pMac->sme );
10393 }
10394
10395#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070010396 if (pMac->roam.configParam.isRoamOffloadScanEnabled && bSendOffloadCmd)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010397 {
10398 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10399 REASON_HOME_AWAY_TIME_CHANGED);
10400 }
10401#endif
10402 return status;
10403}
10404
10405
10406/* ---------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010407 \fn sme_getRoamIntraBand
10408 \brief get Intra band roaming
10409 \param hHal - HAL handle for device
10410 \- return Success or failure
10411 -------------------------------------------------------------------------*/
10412v_BOOL_t sme_getRoamIntraBand(tHalHandle hHal)
10413{
10414 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Katya Nigambcb705f2013-12-26 14:26:22 +053010415 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010416 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010417 return pMac->roam.configParam.nRoamIntraBand;
10418}
10419
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010420/* ---------------------------------------------------------------------------
10421 \fn sme_getRoamScanNProbes
10422 \brief get N Probes
10423 \param hHal - HAL handle for device
10424 \- return Success or failure
10425 -------------------------------------------------------------------------*/
10426v_U8_t sme_getRoamScanNProbes(tHalHandle hHal)
10427{
10428 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10429 return pMac->roam.configParam.nProbes;
10430}
10431
10432/* ---------------------------------------------------------------------------
10433 \fn sme_getRoamScanHomeAwayTime
10434 \brief get Roam scan home away time
10435 \param hHal - HAL handle for device
10436 \- return Success or failure
10437 -------------------------------------------------------------------------*/
10438v_U16_t sme_getRoamScanHomeAwayTime(tHalHandle hHal)
10439{
10440 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10441 return pMac->roam.configParam.nRoamScanHomeAwayTime;
10442}
10443
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010444
10445/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -080010446 \fn sme_UpdateImmediateRoamRssiDiff
10447 \brief Update nImmediateRoamRssiDiff
10448 This function is called through dynamic setConfig callback function
10449 to configure nImmediateRoamRssiDiff
10450 Usage: adb shell iwpriv wlan0 setConfig gImmediateRoamRssiDiff=[0 .. 125]
10451 \param hHal - HAL handle for device
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010452 \param nImmediateRoamRssiDiff - minimum rssi difference between potential
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -080010453 candidate and current AP.
10454 \- return Success or failure
10455 -------------------------------------------------------------------------*/
10456
10457eHalStatus sme_UpdateImmediateRoamRssiDiff(tHalHandle hHal, v_U8_t nImmediateRoamRssiDiff)
10458{
10459 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -080010460 eHalStatus status = eHAL_STATUS_SUCCESS;
10461
Katya Nigambcb705f2013-12-26 14:26:22 +053010462 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010463 TRACE_CODE_SME_RX_HDD_UPDATE_IMMRSSIDIFF, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010464 status = sme_AcquireGlobalLock( &pMac->sme );
10465 if ( HAL_STATUS_SUCCESS( status ) )
10466 {
10467 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010468 "LFR runtime successfully set immediate roam rssi diff to"
10469 "%d - old value is %d - roam state is %s",
Srinivas Girigowdade697412013-02-14 16:31:48 -080010470 nImmediateRoamRssiDiff,
10471 pMac->roam.configParam.nImmediateRoamRssiDiff,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010472 macTraceGetNeighbourRoamState(
10473 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010474 pMac->roam.configParam.nImmediateRoamRssiDiff = nImmediateRoamRssiDiff;
10475 sme_ReleaseGlobalLock( &pMac->sme );
10476 }
10477
10478 return status ;
10479}
10480
10481/* ---------------------------------------------------------------------------
10482 \fn sme_UpdateRoamRssiDiff
10483 \brief Update RoamRssiDiff
10484 This function is called through dynamic setConfig callback function
10485 to configure RoamRssiDiff
10486 Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
10487 \param hHal - HAL handle for device
10488 \param RoamRssiDiff - minimum rssi difference between potential
10489 candidate and current AP.
10490 \- return Success or failure
10491 -------------------------------------------------------------------------*/
10492
10493eHalStatus sme_UpdateRoamRssiDiff(tHalHandle hHal, v_U8_t RoamRssiDiff)
10494{
10495 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10496 eHalStatus status = eHAL_STATUS_SUCCESS;
10497
10498 status = sme_AcquireGlobalLock( &pMac->sme );
Katya Nigambcb705f2013-12-26 14:26:22 +053010499 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010500 TRACE_CODE_SME_RX_HDD_UPDATE_RSSIDIFF, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010501 if ( HAL_STATUS_SUCCESS( status ) )
10502 {
10503 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010504 "LFR runtime successfully set roam rssi diff to %d"
10505 " - old value is %d - roam state is %s",
Srinivas Girigowdade697412013-02-14 16:31:48 -080010506 RoamRssiDiff,
10507 pMac->roam.configParam.RoamRssiDiff,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010508 macTraceGetNeighbourRoamState(
10509 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010510 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
10511 sme_ReleaseGlobalLock( &pMac->sme );
10512 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010513#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10514 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
10515 {
10516 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_RSSI_DIFF_CHANGED);
10517 }
10518#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -080010519 return status ;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -080010520}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010521
10522/*--------------------------------------------------------------------------
10523 \brief sme_UpdateFastTransitionEnabled() - enable/disable Fast Transition support at runtime
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010524 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010525 isFastTransitionEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -080010526 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010527 \param hHal - The handle returned by macOpen.
10528 \return eHAL_STATUS_SUCCESS - SME update isFastTransitionEnabled config successfully.
10529 Other status means SME is failed to update isFastTransitionEnabled.
10530 \sa
10531 --------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010532eHalStatus sme_UpdateFastTransitionEnabled(tHalHandle hHal,
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010533 v_BOOL_t isFastTransitionEnabled)
10534{
10535 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -080010536 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010537
Katya Nigambcb705f2013-12-26 14:26:22 +053010538 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010539 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION, 0));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010540 status = sme_AcquireGlobalLock( &pMac->sme );
10541 if ( HAL_STATUS_SUCCESS( status ) )
10542 {
10543 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10544 "%s: FastTransitionEnabled is changed from %d to %d", __func__,
10545 pMac->roam.configParam.isFastTransitionEnabled,
10546 isFastTransitionEnabled);
10547 pMac->roam.configParam.isFastTransitionEnabled = isFastTransitionEnabled;
10548 sme_ReleaseGlobalLock( &pMac->sme );
10549 }
10550
10551 return status ;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010552}
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010553
10554/* ---------------------------------------------------------------------------
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -070010555 \fn sme_UpdateWESMode
10556 \brief Update WES Mode
10557 This function is called through dynamic setConfig callback function
10558 to configure isWESModeEnabled
10559 \param hHal - HAL handle for device
10560 \return eHAL_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
10561 Other status means SME is failed to update isWESModeEnabled.
10562 -------------------------------------------------------------------------*/
10563
10564eHalStatus sme_UpdateWESMode(tHalHandle hHal, v_BOOL_t isWESModeEnabled)
10565{
10566 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10567 eHalStatus status = eHAL_STATUS_SUCCESS;
10568
10569 status = sme_AcquireGlobalLock( &pMac->sme );
10570 if ( HAL_STATUS_SUCCESS( status ) )
10571 {
10572 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010573 "LFR runtime successfully set WES Mode to %d"
10574 "- old value is %d - roam state is %s",
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -070010575 isWESModeEnabled,
10576 pMac->roam.configParam.isWESModeEnabled,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010577 macTraceGetNeighbourRoamState(
10578 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -070010579 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
10580 sme_ReleaseGlobalLock( &pMac->sme );
10581 }
10582
10583 return status ;
10584}
10585
10586/* ---------------------------------------------------------------------------
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010587 \fn sme_SetRoamScanControl
10588 \brief Set roam scan control
10589 This function is called to set roam scan control
10590 if roam scan control is set to 0, roaming scan cache is cleared
10591 any value other than 0 is treated as invalid value
10592 \param hHal - HAL handle for device
10593 \return eHAL_STATUS_SUCCESS - SME update config successfully.
10594 Other status means SME failure to update
10595 -------------------------------------------------------------------------*/
10596eHalStatus sme_SetRoamScanControl(tHalHandle hHal, v_BOOL_t roamScanControl)
10597{
10598 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10599 eHalStatus status = eHAL_STATUS_SUCCESS;
10600
Katya Nigambcb705f2013-12-26 14:26:22 +053010601 MTRACE(vos_trace(VOS_MODULE_ID_SME,
Leela Venkata Kiran Kumar Reddy Chirala7367c202013-04-10 22:39:51 -070010602 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010603 status = sme_AcquireGlobalLock( &pMac->sme );
10604 if ( HAL_STATUS_SUCCESS( status ) )
10605 {
10606 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010607 "LFR runtime successfully set roam scan control to %d"
10608 " - old value is %d - roam state is %s",
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010609 roamScanControl,
10610 pMac->roam.configParam.nRoamScanControl,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010611 macTraceGetNeighbourRoamState(
10612 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010613 pMac->roam.configParam.nRoamScanControl = roamScanControl;
10614 if ( 0 == roamScanControl)
10615 {
10616 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
10617 "LFR runtime successfully cleared roam scan cache");
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010618 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -070010619#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10620 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
10621 {
10622 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_FLUSH_CHANNEL_LIST);
10623 }
10624#endif
10625 }
10626 sme_ReleaseGlobalLock( &pMac->sme );
10627 }
10628 return status ;
10629}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010630#endif /* (WLAN_FEATURE_VOWIFI_11R) || (FEATURE_WLAN_ESE) || (FEATURE_WLAN_LFR) */
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010631
10632#ifdef FEATURE_WLAN_LFR
10633/*--------------------------------------------------------------------------
10634 \brief sme_UpdateIsFastRoamIniFeatureEnabled() - enable/disable LFR support at runtime
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010635 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010636 isFastRoamIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -080010637 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010638 \param hHal - The handle returned by macOpen.
10639 \return eHAL_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config successfully.
10640 Other status means SME is failed to update isFastRoamIniFeatureEnabled.
10641 \sa
10642 --------------------------------------------------------------------------*/
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070010643eHalStatus sme_UpdateIsFastRoamIniFeatureEnabled(tHalHandle hHal,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010644 const v_BOOL_t isFastRoamIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010645{
10646 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10647
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010648 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled == isFastRoamIniFeatureEnabled)
10649 {
10650 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10651 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)", __func__,
10652 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
10653 isFastRoamIniFeatureEnabled);
10654 return eHAL_STATUS_SUCCESS;
10655 }
Padma, Santhosh Kumardccd6232017-05-10 16:18:00 +053010656 if (smeNeighborMiddleOfRoaming(hHal))
10657 {
10658 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10659 "%s: In middle of roaming isFastRoamIniFeatureEnabled %d",
10660 __func__, isFastRoamIniFeatureEnabled);
10661 if (!isFastRoamIniFeatureEnabled)
10662 pMac->roam.pending_roam_disable = TRUE;
10663
10664 return eHAL_STATUS_SUCCESS;
10665 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010666
Srinivas Girigowdade697412013-02-14 16:31:48 -080010667 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10668 "%s: FastRoamEnabled is changed from %d to %d", __func__,
10669 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
10670 isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010671 pMac->roam.configParam.isFastRoamIniFeatureEnabled = isFastRoamIniFeatureEnabled;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010672 csrNeighborRoamUpdateFastRoamingEnabled(pMac, isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010673
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010674 return eHAL_STATUS_SUCCESS;
10675}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070010676
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080010677/*--------------------------------------------------------------------------
Mukul Sharma2a271632014-10-13 14:59:01 +053010678 \brief sme_ConfigFwrRoaming() - enable/disable LFR support at runtime
10679 When Supplicant issue enabled / disable fwr based roaming on the basis
10680 of the Bssid modification in network block ( e.g. AutoJoin mody N/W block)
10681
10682 This is a synchronous call
10683 \param hHal - The handle returned by macOpen.
10684 \return eHAL_STATUS_SUCCESS - SME (enabled/disabled) offload scan successfully.
10685 Other status means SME is failed to (enabled/disabled) offload scan.
10686 \sa
10687 --------------------------------------------------------------------------*/
10688
10689eHalStatus sme_ConfigFwrRoaming(tHalHandle hHal,
10690 const v_BOOL_t isFastRoamEnabled)
10691{
10692 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10693 if (!pMac->roam.configParam.isFastRoamIniFeatureEnabled)
10694 {
10695 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10696 "%s: FastRoam is disabled through ini", __func__);
10697 return eHAL_STATUS_FAILURE;
10698 }
10699 csrNeighborRoamUpdateFastRoamingEnabled(pMac, isFastRoamEnabled);
10700 return eHAL_STATUS_SUCCESS;
10701}
10702
10703/*--------------------------------------------------------------------------
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080010704 \brief sme_UpdateIsMAWCIniFeatureEnabled() -
10705 Enable/disable LFR MAWC support at runtime
10706 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
10707 isMAWCIniFeatureEnabled.
10708 This is a synchronous call
10709 \param hHal - The handle returned by macOpen.
10710 \return eHAL_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
10711 Other status means SME is failed to update MAWCEnabled.
10712 \sa
10713 --------------------------------------------------------------------------*/
10714eHalStatus sme_UpdateIsMAWCIniFeatureEnabled(tHalHandle hHal,
10715 const v_BOOL_t MAWCEnabled)
10716{
10717 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10718 eHalStatus status = eHAL_STATUS_SUCCESS;
10719
10720 status = sme_AcquireGlobalLock( &pMac->sme );
10721 if ( HAL_STATUS_SUCCESS( status ) )
10722 {
10723 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10724 "%s: MAWCEnabled is changed from %d to %d", __func__,
10725 pMac->roam.configParam.MAWCEnabled,
10726 MAWCEnabled);
10727 pMac->roam.configParam.MAWCEnabled = MAWCEnabled;
10728 sme_ReleaseGlobalLock( &pMac->sme );
10729 }
10730
10731 return status ;
10732
10733}
10734
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070010735#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10736/*--------------------------------------------------------------------------
10737 \brief sme_UpdateEnableFastRoamInConcurrency() - enable/disable LFR if Concurrent session exists
10738 This is a synchronuous call
10739 \param hHal - The handle returned by macOpen.
10740 \return eHAL_STATUS_SUCCESS
10741 Other status means SME is failed
10742 \sa
10743 --------------------------------------------------------------------------*/
10744
10745eHalStatus sme_UpdateEnableFastRoamInConcurrency(tHalHandle hHal,
10746 v_BOOL_t bFastRoamInConIniFeatureEnabled)
10747{
10748
10749 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10750 eHalStatus status = eHAL_STATUS_SUCCESS;
10751
10752 status = sme_AcquireGlobalLock( &pMac->sme );
10753 if ( HAL_STATUS_SUCCESS( status ) )
10754 {
10755 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = bFastRoamInConIniFeatureEnabled;
10756 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled)
10757 {
10758 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = 0;
10759 }
10760 sme_ReleaseGlobalLock( &pMac->sme );
10761 }
10762
10763 return status;
10764}
10765#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010766#endif /* FEATURE_WLAN_LFR */
10767
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010768#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010769/*--------------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010770 \brief sme_UpdateIsEseFeatureEnabled() - enable/disable Ese support at runtime
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010771 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010772 isEseIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -080010773 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010774 \param hHal - The handle returned by macOpen.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010775 \return eHAL_STATUS_SUCCESS - SME update isEseIniFeatureEnabled config successfully.
10776 Other status means SME is failed to update isEseIniFeatureEnabled.
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010777 \sa
10778 --------------------------------------------------------------------------*/
10779
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010780eHalStatus sme_UpdateIsEseFeatureEnabled(tHalHandle hHal,
10781 const v_BOOL_t isEseIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010782{
10783 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10784
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010785 if (pMac->roam.configParam.isEseIniFeatureEnabled == isEseIniFeatureEnabled)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010786 {
10787 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010788 "%s: Ese Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)", __func__,
10789 pMac->roam.configParam.isEseIniFeatureEnabled,
10790 isEseIniFeatureEnabled);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010791 return eHAL_STATUS_SUCCESS;
10792 }
10793
Srinivas Girigowdade697412013-02-14 16:31:48 -080010794 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010795 "%s: EseEnabled is changed from %d to %d", __func__,
10796 pMac->roam.configParam.isEseIniFeatureEnabled,
10797 isEseIniFeatureEnabled);
10798 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
10799 csrNeighborRoamUpdateEseModeEnabled(pMac, isEseIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010800
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010801 if(TRUE == isEseIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010802 {
10803 sme_UpdateFastTransitionEnabled(hHal, TRUE);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010804 }
Srinivas Girigowdaba173692013-08-07 11:55:38 -070010805
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010806#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10807 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
10808 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010809 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_ESE_INI_CFG_CHANGED);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010810 }
10811#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010812 return eHAL_STATUS_SUCCESS;
10813}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010814#endif /* FEATURE_WLAN_ESE */
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010815
10816/*--------------------------------------------------------------------------
10817 \brief sme_UpdateConfigFwRssiMonitoring() - enable/disable firmware RSSI Monitoring at runtime
10818 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
10819 fEnableFwRssiMonitoring.
Srinivas Girigowdade697412013-02-14 16:31:48 -080010820 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010821 \param hHal - The handle returned by macOpen.
10822 \return eHAL_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring. config successfully.
10823 Other status means SME is failed to update fEnableFwRssiMonitoring.
10824 \sa
10825 --------------------------------------------------------------------------*/
10826
10827eHalStatus sme_UpdateConfigFwRssiMonitoring(tHalHandle hHal,
10828 v_BOOL_t fEnableFwRssiMonitoring)
10829{
10830 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
10831
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010832 if (ccmCfgSetInt(hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR, fEnableFwRssiMonitoring,
10833 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
10834 {
10835 halStatus = eHAL_STATUS_FAILURE;
10836 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -080010837 "Failure: Could not pass on WNI_CFG_PS_RSSI_MONITOR configuration info to CCM");
Gopichand Nakkala98a98af2012-12-31 14:38:47 -080010838 }
10839
10840 return (halStatus);
10841}
10842
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010843#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srinivas Girigowdade697412013-02-14 16:31:48 -080010844/*--------------------------------------------------------------------------
10845 \brief sme_setNeighborLookupRssiThreshold() - update neighbor lookup rssi threshold
10846 This is a synchronous call
10847 \param hHal - The handle returned by macOpen.
10848 \return eHAL_STATUS_SUCCESS - SME update config successful.
10849 Other status means SME is failed to update
10850 \sa
10851 --------------------------------------------------------------------------*/
10852eHalStatus sme_setNeighborLookupRssiThreshold(tHalHandle hHal,
10853 v_U8_t neighborLookupRssiThreshold)
10854{
10855 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10856 eHalStatus status = eHAL_STATUS_SUCCESS;
10857
10858 status = sme_AcquireGlobalLock( &pMac->sme );
10859 if ( HAL_STATUS_SUCCESS( status ) )
10860 {
10861 status = csrNeighborRoamSetLookupRssiThreshold(pMac, neighborLookupRssiThreshold);
10862 if (HAL_STATUS_SUCCESS(status))
10863 {
10864 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010865 "LFR runtime successfully set Lookup threshold to %d"
10866 " - old value is %d - roam state is %s",
10867 neighborLookupRssiThreshold,
10868 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold,
10869 macTraceGetNeighbourRoamState(
10870 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010871 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
10872 neighborLookupRssiThreshold;
10873 }
10874 sme_ReleaseGlobalLock( &pMac->sme );
10875 }
Srinivas Girigowdade697412013-02-14 16:31:48 -080010876 return status;
10877}
10878
10879/*--------------------------------------------------------------------------
10880 \brief sme_setNeighborReassocRssiThreshold() - update neighbor reassoc rssi threshold
10881 This is a synchronous call
10882 \param hHal - The handle returned by macOpen.
10883 \return eHAL_STATUS_SUCCESS - SME update config successful.
10884 Other status means SME is failed to update
10885 \sa
10886 --------------------------------------------------------------------------*/
10887eHalStatus sme_setNeighborReassocRssiThreshold(tHalHandle hHal,
10888 v_U8_t neighborReassocRssiThreshold)
10889{
10890 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10891 eHalStatus status = eHAL_STATUS_SUCCESS;
10892
10893 status = sme_AcquireGlobalLock( &pMac->sme );
10894 if ( HAL_STATUS_SUCCESS( status ) )
10895 {
10896 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010897 "LFR runtime successfully set Reassoc threshold to %d"
10898 "- old value is %d - roam state is %s",
Srinivas Girigowdade697412013-02-14 16:31:48 -080010899 neighborReassocRssiThreshold,
10900 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010901 macTraceGetNeighbourRoamState(
10902 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010903 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold =
10904 neighborReassocRssiThreshold;
10905 pMac->roam.neighborRoamInfo.cfgParams.neighborReassocThreshold =
10906 neighborReassocRssiThreshold;
10907 sme_ReleaseGlobalLock( &pMac->sme );
10908 }
10909
10910 return status ;
10911}
10912
10913
10914/*--------------------------------------------------------------------------
10915 \brief sme_getNeighborLookupRssiThreshold() - get neighbor lookup rssi threshold
10916 This is a synchronous call
10917 \param hHal - The handle returned by macOpen.
10918 \return eHAL_STATUS_SUCCESS - SME update config successful.
10919 Other status means SME is failed to update
10920 \sa
10921 --------------------------------------------------------------------------*/
10922v_U8_t sme_getNeighborLookupRssiThreshold(tHalHandle hHal)
10923{
10924 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10925 return pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
10926}
10927
10928/*--------------------------------------------------------------------------
10929 \brief sme_setNeighborScanRefreshPeriod() - set neighbor scan results refresh period
10930 This is a synchronous call
10931 \param hHal - The handle returned by macOpen.
10932 \return eHAL_STATUS_SUCCESS - SME update config successful.
10933 Other status means SME is failed to update
10934 \sa
10935 --------------------------------------------------------------------------*/
10936eHalStatus sme_setNeighborScanRefreshPeriod(tHalHandle hHal,
10937 v_U16_t neighborScanResultsRefreshPeriod)
10938{
10939 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10940 eHalStatus status = eHAL_STATUS_SUCCESS;
10941
10942 status = sme_AcquireGlobalLock( &pMac->sme );
10943 if ( HAL_STATUS_SUCCESS( status ) )
10944 {
10945 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010946 "LFR runtime successfully set roam scan refresh period to %d"
10947 " - old value is %d - roam state is %s",
Srinivas Girigowdade697412013-02-14 16:31:48 -080010948 neighborScanResultsRefreshPeriod,
10949 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053010950 macTraceGetNeighbourRoamState(
10951 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080010952 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod =
10953 neighborScanResultsRefreshPeriod;
10954 pMac->roam.neighborRoamInfo.cfgParams.neighborResultsRefreshPeriod =
10955 neighborScanResultsRefreshPeriod;
10956
10957 sme_ReleaseGlobalLock( &pMac->sme );
10958 }
10959
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010960#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10961 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
10962 {
10963 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10964 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
10965 }
10966#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -080010967 return status ;
10968}
10969
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010970#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10971/*--------------------------------------------------------------------------
10972 \brief sme_UpdateRoamScanOffloadEnabled() - enable/disable roam scan offload feaure
10973 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
10974 gRoamScanOffloadEnabled.
10975 This is a synchronous call
10976 \param hHal - The handle returned by macOpen.
10977 \return eHAL_STATUS_SUCCESS - SME update config successfully.
10978 Other status means SME is failed to update.
10979 \sa
10980 --------------------------------------------------------------------------*/
10981
10982eHalStatus sme_UpdateRoamScanOffloadEnabled(tHalHandle hHal,
10983 v_BOOL_t nRoamScanOffloadEnabled)
10984{
10985 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
10986 eHalStatus status = eHAL_STATUS_SUCCESS;
10987
10988 status = sme_AcquireGlobalLock( &pMac->sme );
10989 if ( HAL_STATUS_SUCCESS( status ) )
10990 {
10991 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
10992 "%s: gRoamScanOffloadEnabled is changed from %d to %d", __func__,
10993 pMac->roam.configParam.isRoamOffloadScanEnabled,
10994 nRoamScanOffloadEnabled);
10995 pMac->roam.configParam.isRoamOffloadScanEnabled = nRoamScanOffloadEnabled;
10996 sme_ReleaseGlobalLock( &pMac->sme );
10997 }
10998
10999 return status ;
11000}
11001#endif
11002
Srinivas Girigowdade697412013-02-14 16:31:48 -080011003/*--------------------------------------------------------------------------
11004 \brief sme_getNeighborScanRefreshPeriod() - get neighbor scan results refresh period
11005 This is a synchronous call
11006 \param hHal - The handle returned by macOpen.
11007 \return v_U16_t - Neighbor scan results refresh period value
11008 \sa
11009 --------------------------------------------------------------------------*/
11010v_U16_t sme_getNeighborScanRefreshPeriod(tHalHandle hHal)
11011{
11012 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11013 return pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
11014}
11015
11016/*--------------------------------------------------------------------------
11017 \brief sme_getEmptyScanRefreshPeriod() - get empty scan refresh period
11018 This is a synchronuous call
11019 \param hHal - The handle returned by macOpen.
11020 \return eHAL_STATUS_SUCCESS - SME update config successful.
11021 Other status means SME is failed to update
11022 \sa
11023 --------------------------------------------------------------------------*/
11024v_U16_t sme_getEmptyScanRefreshPeriod(tHalHandle hHal)
11025{
11026 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11027 return pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
11028}
11029
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011030/* ---------------------------------------------------------------------------
11031 \fn sme_UpdateEmptyScanRefreshPeriod
11032 \brief Update nEmptyScanRefreshPeriod
11033 This function is called through dynamic setConfig callback function
11034 to configure nEmptyScanRefreshPeriod
11035 Usage: adb shell iwpriv wlan0 setConfig nEmptyScanRefreshPeriod=[0 .. 60]
11036 \param hHal - HAL handle for device
11037 \param nEmptyScanRefreshPeriod - scan period following empty scan results.
11038 \- return Success or failure
11039 -------------------------------------------------------------------------*/
11040
11041eHalStatus sme_UpdateEmptyScanRefreshPeriod(tHalHandle hHal, v_U16_t nEmptyScanRefreshPeriod)
11042{
11043 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11044 eHalStatus status = eHAL_STATUS_SUCCESS;
11045
11046 status = sme_AcquireGlobalLock( &pMac->sme );
11047 if ( HAL_STATUS_SUCCESS( status ) )
11048 {
11049 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011050 "LFR runtime successfully set roam scan period to %d -"
11051 "old value is %d - roam state is %s",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011052 nEmptyScanRefreshPeriod,
11053 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011054 macTraceGetNeighbourRoamState(
11055 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011056 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
11057 pMac->roam.neighborRoamInfo.cfgParams.emptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
11058 sme_ReleaseGlobalLock( &pMac->sme );
11059 }
11060
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -070011061#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11062 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
11063 {
11064 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11065 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
11066 }
11067#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011068 return status ;
11069}
11070
11071/* ---------------------------------------------------------------------------
11072 \fn sme_setNeighborScanMinChanTime
11073 \brief Update nNeighborScanMinChanTime
11074 This function is called through dynamic setConfig callback function
11075 to configure gNeighborScanChannelMinTime
11076 Usage: adb shell iwpriv wlan0 setConfig gNeighborScanChannelMinTime=[0 .. 60]
11077 \param hHal - HAL handle for device
11078 \param nNeighborScanMinChanTime - Channel minimum dwell time
11079 \- return Success or failure
11080 -------------------------------------------------------------------------*/
11081eHalStatus sme_setNeighborScanMinChanTime(tHalHandle hHal, const v_U16_t nNeighborScanMinChanTime)
11082{
11083 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11084 eHalStatus status = eHAL_STATUS_SUCCESS;
11085
11086 status = sme_AcquireGlobalLock( &pMac->sme );
11087 if ( HAL_STATUS_SUCCESS( status ) )
11088 {
11089 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011090 "LFR runtime successfully set channel min dwell time to %d"
11091 " - old value is %d - roam state is %s",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011092 nNeighborScanMinChanTime,
11093 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011094 macTraceGetNeighbourRoamState(
11095 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011096 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = nNeighborScanMinChanTime;
11097 pMac->roam.neighborRoamInfo.cfgParams.minChannelScanTime = nNeighborScanMinChanTime;
11098 sme_ReleaseGlobalLock( &pMac->sme );
11099 }
11100
11101 return status ;
11102}
11103
11104/* ---------------------------------------------------------------------------
11105 \fn sme_setNeighborScanMaxChanTime
11106 \brief Update nNeighborScanMaxChanTime
11107 This function is called through dynamic setConfig callback function
11108 to configure gNeighborScanChannelMaxTime
11109 Usage: adb shell iwpriv wlan0 setConfig gNeighborScanChannelMaxTime=[0 .. 60]
11110 \param hHal - HAL handle for device
11111 \param nNeighborScanMinChanTime - Channel maximum dwell time
11112 \- return Success or failure
11113 -------------------------------------------------------------------------*/
11114eHalStatus sme_setNeighborScanMaxChanTime(tHalHandle hHal, const v_U16_t nNeighborScanMaxChanTime)
11115{
11116 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11117 eHalStatus status = eHAL_STATUS_SUCCESS;
11118
11119 status = sme_AcquireGlobalLock( &pMac->sme );
11120 if ( HAL_STATUS_SUCCESS( status ) )
11121 {
11122 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011123 "LFR runtime successfully set channel max dwell time to %d"
11124 " - old value is %d - roam state is %s",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011125 nNeighborScanMaxChanTime,
11126 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011127 macTraceGetNeighbourRoamState(
11128 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011129 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = nNeighborScanMaxChanTime;
11130 pMac->roam.neighborRoamInfo.cfgParams.maxChannelScanTime = nNeighborScanMaxChanTime;
11131 sme_ReleaseGlobalLock( &pMac->sme );
11132 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -070011133#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11134 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
11135 {
11136 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11137 REASON_SCAN_CH_TIME_CHANGED);
11138 }
11139#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011140
11141 return status ;
11142}
11143
11144/* ---------------------------------------------------------------------------
11145 \fn sme_getNeighborScanMinChanTime
11146 \brief get neighbor scan min channel time
11147 \param hHal - The handle returned by macOpen.
11148 \return v_U16_t - channel min time value
11149 -------------------------------------------------------------------------*/
11150v_U16_t sme_getNeighborScanMinChanTime(tHalHandle hHal)
11151{
11152 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11153 return pMac->roam.neighborRoamInfo.cfgParams.minChannelScanTime;
11154}
11155
11156/* ---------------------------------------------------------------------------
11157 \fn sme_getNeighborScanMaxChanTime
11158 \brief get neighbor scan max channel time
11159 \param hHal - The handle returned by macOpen.
11160 \return v_U16_t - channel max time value
11161 -------------------------------------------------------------------------*/
11162v_U16_t sme_getNeighborScanMaxChanTime(tHalHandle hHal)
11163{
11164 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11165 return pMac->roam.neighborRoamInfo.cfgParams.maxChannelScanTime;
11166}
11167
11168/* ---------------------------------------------------------------------------
11169 \fn sme_setNeighborScanPeriod
11170 \brief Update nNeighborScanPeriod
11171 This function is called through dynamic setConfig callback function
11172 to configure nNeighborScanPeriod
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -070011173 Usage: adb shell iwpriv wlan0 setConfig nNeighborScanPeriod=[0 .. 1000]
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011174 \param hHal - HAL handle for device
11175 \param nNeighborScanPeriod - neighbor scan period
11176 \- return Success or failure
11177 -------------------------------------------------------------------------*/
11178eHalStatus sme_setNeighborScanPeriod(tHalHandle hHal, const v_U16_t nNeighborScanPeriod)
11179{
11180 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11181 eHalStatus status = eHAL_STATUS_SUCCESS;
11182
11183 status = sme_AcquireGlobalLock( &pMac->sme );
11184 if ( HAL_STATUS_SUCCESS( status ) )
11185 {
11186 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011187 "LFR runtime successfully set neighbor scan period to %d"
11188 " - old value is %d - roam state is %s",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011189 nNeighborScanPeriod,
11190 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011191 macTraceGetNeighbourRoamState(
11192 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011193 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = nNeighborScanPeriod;
11194 pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod = nNeighborScanPeriod;
11195 sme_ReleaseGlobalLock( &pMac->sme );
11196 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -070011197#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11198 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
11199 {
11200 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11201 REASON_SCAN_HOME_TIME_CHANGED);
11202 }
11203#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011204
11205 return status ;
11206}
11207
11208/* ---------------------------------------------------------------------------
11209 \fn sme_getNeighborScanPeriod
11210 \brief get neighbor scan period
11211 \param hHal - The handle returned by macOpen.
11212 \return v_U16_t - neighbor scan period
11213 -------------------------------------------------------------------------*/
11214v_U16_t sme_getNeighborScanPeriod(tHalHandle hHal)
11215{
11216 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11217 return pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
11218}
11219
11220#endif
11221
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011222#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011223
Srinivas Girigowdade697412013-02-14 16:31:48 -080011224/*--------------------------------------------------------------------------
11225 \brief sme_getRoamRssiDiff() - get Roam rssi diff
11226 This is a synchronous call
11227 \param hHal - The handle returned by macOpen.
11228 \return v_U16_t - Rssi diff value
11229 \sa
11230 --------------------------------------------------------------------------*/
11231v_U8_t sme_getRoamRssiDiff(tHalHandle hHal)
11232{
11233 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11234 return pMac->roam.configParam.RoamRssiDiff;
11235}
11236
11237/*--------------------------------------------------------------------------
11238 \brief sme_ChangeRoamScanChannelList() - Change roam scan channel list
11239 This is a synchronous call
11240 \param hHal - The handle returned by macOpen.
11241 \return eHAL_STATUS_SUCCESS - SME update config successful.
11242 Other status means SME is failed to update
11243 \sa
11244 --------------------------------------------------------------------------*/
11245eHalStatus sme_ChangeRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
11246 tANI_U8 numChannels)
11247{
11248 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11249 eHalStatus status = eHAL_STATUS_SUCCESS;
11250 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011251 tANI_U8 oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
Kiet Lam600d3ca2013-08-31 16:33:32 +053011252 tANI_U8 newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
Srinivas Girigowdade697412013-02-14 16:31:48 -080011253 tANI_U8 i = 0, j = 0;
11254
11255 status = sme_AcquireGlobalLock( &pMac->sme );
11256 if ( HAL_STATUS_SUCCESS( status ) )
11257 {
11258 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
11259 {
11260 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
11261 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011262 if (j < sizeof(oldChannelList))
11263 {
11264 j += snprintf(oldChannelList + j, sizeof(oldChannelList) - j," %d",
11265 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
11266 }
11267 else
11268 {
11269 break;
11270 }
Srinivas Girigowdade697412013-02-14 16:31:48 -080011271 }
11272 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011273 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011274 csrCreateBgScanRoamChannelList(pMac, pChannelList, numChannels);
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080011275 sme_SetRoamScanControl(hHal, 1);
11276 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -080011277 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080011278 j = 0;
11279 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
Srinivas Girigowdade697412013-02-14 16:31:48 -080011280 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011281 if (j < sizeof(oldChannelList))
11282 {
11283 j += snprintf(newChannelList + j, sizeof(newChannelList) - j," %d",
11284 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
11285 }
11286 else
11287 {
11288 break;
11289 }
Srinivas Girigowdade697412013-02-14 16:31:48 -080011290 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011291 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080011292
11293 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053011294 "LFR runtime successfully set roam scan channels to %s"
11295 "- old value is %s - roam state is %s",
11296 newChannelList, oldChannelList,
11297 macTraceGetNeighbourRoamState(
11298 pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -080011299 sme_ReleaseGlobalLock( &pMac->sme );
11300 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011301#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11302 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
11303 {
11304 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
11305 }
11306#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -080011307
11308 return status ;
11309}
11310
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011311
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011312#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011313/*--------------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011314 \brief sme_SetEseRoamScanChannelList() - set ese roam scan channel list
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011315 This is a synchronuous call
11316 \param hHal - The handle returned by macOpen.
11317 \return eHAL_STATUS_SUCCESS - SME update config successful.
11318 Other status means SME is failed to update
11319 \sa
11320 --------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011321eHalStatus sme_SetEseRoamScanChannelList(tHalHandle hHal,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011322 tANI_U8 *pChannelList,
11323 tANI_U8 numChannels)
11324{
11325 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11326 eHalStatus status = eHAL_STATUS_SUCCESS;
11327 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
11328 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
11329 tANI_U8 oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
11330 tANI_U8 newChannelList[128] = {0};
11331 tANI_U8 i = 0, j = 0;
11332
11333 status = sme_AcquireGlobalLock( &pMac->sme );
11334 if ( HAL_STATUS_SUCCESS( status ) )
11335 {
11336 if (NULL != currChannelListInfo->ChannelList)
11337 {
11338 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
11339 {
11340 j += snprintf(oldChannelList + j, sizeof(oldChannelList) - j," %d",
11341 currChannelListInfo->ChannelList[i]);
11342 }
11343 }
11344 status = csrCreateRoamScanChannelList(pMac, pChannelList, numChannels, csrGetCurrentBand(hHal));
11345
11346 if ( HAL_STATUS_SUCCESS( status ))
11347 {
11348 if (NULL != currChannelListInfo->ChannelList)
11349 {
11350 j = 0;
11351 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
11352 {
11353 j += snprintf(newChannelList + j, sizeof(newChannelList) - j," %d",
11354 currChannelListInfo->ChannelList[i]);
11355 }
11356 }
11357
11358 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011359 "ESE roam scan channel list successfully set to %s - old value is %s - roam state is %s",
11360 newChannelList, oldChannelList,
11361 macTraceGetNeighbourRoamState(pMac->roam.neighborRoamInfo.neighborRoamState));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011362 }
11363 sme_ReleaseGlobalLock( &pMac->sme );
11364 }
11365#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11366 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
11367 {
11368 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
11369 }
11370#endif
11371
11372 return status ;
11373}
11374#endif
11375
Srinivas Girigowdade697412013-02-14 16:31:48 -080011376/*--------------------------------------------------------------------------
Srinivas Girigowdade697412013-02-14 16:31:48 -080011377 \brief sme_getRoamScanChannelList() - get roam scan channel list
11378 This is a synchronous call
11379 \param hHal - The handle returned by macOpen.
11380 \return eHAL_STATUS_SUCCESS - SME update config successful.
11381 Other status means SME is failed to update
11382 \sa
11383 --------------------------------------------------------------------------*/
11384eHalStatus sme_getRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
11385 tANI_U8 *pNumChannels)
11386{
11387 int i = 0;
11388 tANI_U8 *pOutPtr = pChannelList;
11389 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11390 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
11391 eHalStatus status = eHAL_STATUS_SUCCESS;
11392
11393 status = sme_AcquireGlobalLock( &pMac->sme );
11394 if ( HAL_STATUS_SUCCESS( status ) )
11395 {
11396 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
11397 {
11398 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
11399 "Roam Scan channel list is NOT yet initialized");
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011400 *pNumChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -080011401 sme_ReleaseGlobalLock( &pMac->sme );
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011402 return status;
Srinivas Girigowdade697412013-02-14 16:31:48 -080011403 }
11404
11405 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
11406 for (i = 0; i < (*pNumChannels); i++)
11407 {
11408 pOutPtr[i] = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
11409 }
11410 pOutPtr[i] = '\0';
11411 sme_ReleaseGlobalLock( &pMac->sme );
11412 }
Srinivas Girigowdade697412013-02-14 16:31:48 -080011413 return status ;
11414}
11415
11416/*--------------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011417 \brief sme_getIsEseFeatureEnabled() - get Ese feature enabled or not
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011418 This is a synchronuous call
11419 \param hHal - The handle returned by macOpen.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011420 \return TRUE (1) - if the Ese feature is enabled
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011421 FALSE (0) - if feature is disabled (compile or runtime)
11422 \sa
11423 --------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011424tANI_BOOLEAN sme_getIsEseFeatureEnabled(tHalHandle hHal)
Srinivas Girigowdade697412013-02-14 16:31:48 -080011425{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011426#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdade697412013-02-14 16:31:48 -080011427 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011428 return csrRoamIsEseIniFeatureEnabled(pMac);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011429#else
11430 return eANI_BOOLEAN_FALSE;
11431#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -080011432}
11433
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011434/*--------------------------------------------------------------------------
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -070011435 \brief sme_GetWESMode() - get WES Mode
11436 This is a synchronous call
11437 \param hHal - The handle returned by macOpen
11438 \return v_U8_t - WES Mode Enabled(1)/Disabled(0)
11439 \sa
11440 --------------------------------------------------------------------------*/
11441v_BOOL_t sme_GetWESMode(tHalHandle hHal)
11442{
11443 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11444 return pMac->roam.configParam.isWESModeEnabled;
11445}
11446
11447/*--------------------------------------------------------------------------
Srinivas Girigowda100eb322013-03-15 16:48:20 -070011448 \brief sme_GetRoamScanControl() - get scan control
11449 This is a synchronous call
11450 \param hHal - The handle returned by macOpen.
11451 \return v_BOOL_t - Enabled(1)/Disabled(0)
11452 \sa
11453 --------------------------------------------------------------------------*/
11454v_BOOL_t sme_GetRoamScanControl(tHalHandle hHal)
11455{
11456 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11457 return pMac->roam.configParam.nRoamScanControl;
11458}
11459#endif
11460
11461/*--------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011462 \brief sme_getIsLfrFeatureEnabled() - get LFR feature enabled or not
11463 This is a synchronuous call
11464 \param hHal - The handle returned by macOpen.
11465 \return TRUE (1) - if the feature is enabled
11466 FALSE (0) - if feature is disabled (compile or runtime)
11467 \sa
11468 --------------------------------------------------------------------------*/
11469tANI_BOOLEAN sme_getIsLfrFeatureEnabled(tHalHandle hHal)
11470{
11471#ifdef FEATURE_WLAN_LFR
11472 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11473 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
11474#else
11475 return eANI_BOOLEAN_FALSE;
11476#endif
11477}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -080011478
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011479/*--------------------------------------------------------------------------
11480 \brief sme_getIsFtFeatureEnabled() - get FT feature enabled or not
11481 This is a synchronuous call
11482 \param hHal - The handle returned by macOpen.
11483 \return TRUE (1) - if the feature is enabled
11484 FALSE (0) - if feature is disabled (compile or runtime)
11485 \sa
11486 --------------------------------------------------------------------------*/
11487tANI_BOOLEAN sme_getIsFtFeatureEnabled(tHalHandle hHal)
11488{
11489#ifdef WLAN_FEATURE_VOWIFI_11R
11490 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11491 return pMac->roam.configParam.isFastTransitionEnabled;
11492#else
11493 return eANI_BOOLEAN_FALSE;
11494#endif
11495}
11496
Abhishek Singh00b71972016-01-07 10:51:04 +053011497
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011498/* ---------------------------------------------------------------------------
11499 \fn sme_IsFeatureSupportedByFW
Kiet Lam0f320422013-11-21 19:29:17 +053011500 \brief Check if a feature is enabled by FW
11501
11502 \param featEnumValue - Enumeration value from placeHolderInCapBitmap
11503 \- return 1/0 (TRUE/FALSE)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011504 -------------------------------------------------------------------------*/
11505tANI_U8 sme_IsFeatureSupportedByFW(tANI_U8 featEnumValue)
11506{
11507 return IS_FEATURE_SUPPORTED_BY_FW(featEnumValue);
11508}
Kiet Lam0f320422013-11-21 19:29:17 +053011509
11510/* ---------------------------------------------------------------------------
11511 \fn sme_IsFeatureSupportedByDriver
11512 \brief Check if a feature is enabled by Driver
11513
11514 \param featEnumValue - Enumeration value from placeHolderInCapBitmap
11515 \- return 1/0 (TRUE/FALSE)
11516 -------------------------------------------------------------------------*/
11517
11518tANI_U8 sme_IsFeatureSupportedByDriver(tANI_U8 featEnumValue)
11519{
11520 return IS_FEATURE_SUPPORTED_BY_DRIVER(featEnumValue);
11521}
11522
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011523#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011524
11525/* ---------------------------------------------------------------------------
11526 \fn sme_SendTdlsMgmtFrame
11527 \brief API to send TDLS management frames.
11528
11529 \param peerMac - peer's Mac Adress.
11530 \param tdlsLinkEstablishParams - TDLS Peer Link Establishment Parameters
11531 \- return VOS_STATUS_SUCCES
11532 -------------------------------------------------------------------------*/
11533VOS_STATUS sme_SendTdlsLinkEstablishParams(tHalHandle hHal,
Anand N Sunkadc205d952015-07-30 15:36:03 +053011534 tANI_U8 sessionId,
11535#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11536 const tSirMacAddr peerMac,
11537#else
11538 tSirMacAddr peerMac,
11539#endif
11540 tCsrTdlsLinkEstablishParams *tdlsLinkEstablishParams)
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011541{
11542 eHalStatus status = eHAL_STATUS_SUCCESS;
11543 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11544
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011545 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11546 TRACE_CODE_SME_RX_HDD_TDLS_LINK_ESTABLISH_PARAM,
11547 sessionId, tdlsLinkEstablishParams->isOffChannelSupported));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011548 status = sme_AcquireGlobalLock( &pMac->sme );
11549
11550 if ( HAL_STATUS_SUCCESS( status ) )
11551 {
11552 status = csrTdlsSendLinkEstablishParams(hHal, sessionId, peerMac, tdlsLinkEstablishParams) ;
11553 sme_ReleaseGlobalLock( &pMac->sme );
11554 }
11555 return status ;
11556}
11557
Atul Mittalc0f739f2014-07-31 13:47:47 +053011558// tdlsoffchan
11559
11560/* ---------------------------------------------------------------------------
11561 \fn sme_SendTdlsChanSwitchReq
11562 \brief API to send TDLS management frames.
11563
11564 \param peerMac - peer's Mac Adress.
11565 \param tdlsLinkEstablishParams - TDLS Peer Link Establishment Parameters
11566 \- return VOS_STATUS_SUCCES
11567 -------------------------------------------------------------------------*/
11568VOS_STATUS sme_SendTdlsChanSwitchReq(tHalHandle hHal,
11569 tANI_U8 sessionId,
11570 tSirMacAddr peerMac,
11571 tANI_S32 tdlsOffCh,
11572 tANI_S32 tdlsOffChBwOffset,
11573 tANI_U8 tdlsSwMode)
11574{
11575 eHalStatus status = eHAL_STATUS_SUCCESS;
11576 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11577
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011578 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11579 TRACE_CODE_SME_RX_HDD_TDLS_CHAN_SWITCH_REQ,
11580 sessionId, tdlsOffCh));
Atul Mittalc0f739f2014-07-31 13:47:47 +053011581 status = sme_AcquireGlobalLock( &pMac->sme );
11582
11583 if ( HAL_STATUS_SUCCESS( status ) )
11584 {
11585 status = csrTdlsSendChanSwitchReq(hHal, sessionId, peerMac,
11586 tdlsOffCh, tdlsOffChBwOffset,
11587 tdlsSwMode);
11588 }
11589 sme_ReleaseGlobalLock( &pMac->sme );
11590 return status ;
11591}
11592
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011593/* ---------------------------------------------------------------------------
11594 \fn sme_SendTdlsMgmtFrame
11595 \brief API to send TDLS management frames.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070011596
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011597 \param peerMac - peer's Mac Adress.
11598 \param frame_type - Type of TDLS mgmt frame to be sent.
11599 \param dialog - dialog token used in the frame.
11600 \param status - status to be incuded in the frame.
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053011601 \param peerCapability - peer cpabilities
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011602 \param buf - additional IEs to be included
11603 \param len - lenght of additional Ies
Hoonki Leea34dd892013-02-05 22:56:02 -080011604 \param responder - Tdls request type
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011605 \- return VOS_STATUS_SUCCES
11606 -------------------------------------------------------------------------*/
Anand N Sunkadc205d952015-07-30 15:36:03 +053011607VOS_STATUS sme_SendTdlsMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
11608#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11609 const tSirMacAddr peerMac,
11610#else
11611 tSirMacAddr peerMac,
11612#endif
11613 tANI_U8 frame_type, tANI_U8 dialog,
11614 tANI_U16 statusCode, tANI_U32 peerCapability,
11615 tANI_U8 *buf, tANI_U8 len, tANI_U8 responder)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011616{
11617 eHalStatus status = eHAL_STATUS_SUCCESS;
11618 tCsrTdlsSendMgmt sendTdlsReq = {{0}} ;
11619 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11620
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011621 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11622 TRACE_CODE_SME_RX_HDD_TDLS_SEND_MGMT_FRAME,
11623 sessionId, statusCode));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011624 status = sme_AcquireGlobalLock( &pMac->sme );
11625 if ( HAL_STATUS_SUCCESS( status ) )
11626 {
11627 vos_mem_copy(sendTdlsReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
11628 sendTdlsReq.frameType = frame_type;
11629 sendTdlsReq.buf = buf;
11630 sendTdlsReq.len = len;
11631 sendTdlsReq.dialog = dialog;
11632 sendTdlsReq.statusCode = statusCode;
Hoonki Leea34dd892013-02-05 22:56:02 -080011633 sendTdlsReq.responder = responder;
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053011634 sendTdlsReq.peerCapability = peerCapability;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011635
11636 status = csrTdlsSendMgmtReq(hHal, sessionId, &sendTdlsReq) ;
11637
11638 sme_ReleaseGlobalLock( &pMac->sme );
11639 }
11640
11641 return status ;
11642
11643}
11644/* ---------------------------------------------------------------------------
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011645 \fn sme_ChangeTdlsPeerSta
11646 \brief API to Update TDLS peer sta parameters.
11647
11648 \param peerMac - peer's Mac Adress.
11649 \param staParams - Peer Station Parameters
11650 \- return VOS_STATUS_SUCCES
11651 -------------------------------------------------------------------------*/
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011652VOS_STATUS sme_ChangeTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId,
11653#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11654 const tSirMacAddr peerMac,
11655#else
11656 tSirMacAddr peerMac,
11657#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011658 tCsrStaParams *pstaParams)
11659{
11660 eHalStatus status = eHAL_STATUS_SUCCESS;
11661 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11662
Sushant Kaushikd62d9782014-02-19 15:39:40 +053011663 if (NULL == pstaParams)
11664 {
11665 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
11666 "%s :pstaParams is NULL",__func__);
11667 return eHAL_STATUS_FAILURE;
11668 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011669
11670 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11671 TRACE_CODE_SME_RX_HDD_TDLS_CHANGE_PEER_STA, sessionId,
11672 pstaParams->capability));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011673 status = sme_AcquireGlobalLock( &pMac->sme );
11674 if ( HAL_STATUS_SUCCESS( status ) )
11675 {
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011676 status = csrTdlsChangePeerSta(hHal, sessionId, peerMac, pstaParams);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011677
11678 sme_ReleaseGlobalLock( &pMac->sme );
11679 }
11680
11681 return status ;
11682
11683}
11684
11685/* ---------------------------------------------------------------------------
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011686 \fn sme_AddTdlsPeerSta
11687 \brief API to Add TDLS peer sta entry.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070011688
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011689 \param peerMac - peer's Mac Adress.
11690 \- return VOS_STATUS_SUCCES
11691 -------------------------------------------------------------------------*/
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011692VOS_STATUS sme_AddTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId,
11693#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11694 const tSirMacAddr peerMac
11695#else
11696 tSirMacAddr peerMac
11697#endif
11698 )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011699{
11700 eHalStatus status = eHAL_STATUS_SUCCESS;
11701 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11702
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011703 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11704 TRACE_CODE_SME_RX_HDD_TDLS_ADD_PEER_STA,
11705 sessionId, 0));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011706 status = sme_AcquireGlobalLock( &pMac->sme );
11707 if ( HAL_STATUS_SUCCESS( status ) )
11708 {
11709 status = csrTdlsAddPeerSta(hHal, sessionId, peerMac);
11710
11711 sme_ReleaseGlobalLock( &pMac->sme );
11712 }
11713
11714 return status ;
11715
11716}
11717/* ---------------------------------------------------------------------------
11718 \fn sme_DeleteTdlsPeerSta
11719 \brief API to Delete TDLS peer sta entry.
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070011720
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011721 \param peerMac - peer's Mac Adress.
11722 \- return VOS_STATUS_SUCCES
11723 -------------------------------------------------------------------------*/
Anand N Sunkadc205d952015-07-30 15:36:03 +053011724VOS_STATUS sme_DeleteTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId,
11725#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11726 const tSirMacAddr peerMac
11727#else
11728 tSirMacAddr peerMac
11729#endif
11730)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011731{
11732 eHalStatus status = eHAL_STATUS_SUCCESS;
11733 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11734
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053011735 MTRACE(vos_trace(VOS_MODULE_ID_SME,
11736 TRACE_CODE_SME_RX_HDD_TDLS_DEL_PEER_STA,
11737 sessionId, 0));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011738 status = sme_AcquireGlobalLock( &pMac->sme );
11739 if ( HAL_STATUS_SUCCESS( status ) )
11740 {
11741 status = csrTdlsDelPeerSta(hHal, sessionId, peerMac) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011742 sme_ReleaseGlobalLock( &pMac->sme );
11743 }
11744
11745 return status ;
11746
11747}
Gopichand Nakkala75e7b282013-03-15 18:37:13 -070011748/* ---------------------------------------------------------------------------
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070011749 \fn sme_SetTdlsPowerSaveProhibited
11750 \API to set/reset the isTdlsPowerSaveProhibited.
11751
11752 \- return void
11753 -------------------------------------------------------------------------*/
11754void sme_SetTdlsPowerSaveProhibited(tHalHandle hHal, v_BOOL_t val)
11755{
11756 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11757
11758 pMac->isTdlsPowerSaveProhibited = val;
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053011759 smsLog(pMac, LOG1, FL("isTdlsPowerSaveProhibited is %d"),
11760 pMac->isTdlsPowerSaveProhibited);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070011761 return;
11762}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011763#endif
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +053011764/* ---------------------------------------------------------------------------
11765 \fn sme_IsPmcBmps
11766 \API to Check if PMC state is BMPS.
11767
11768 \- return v_BOOL_t
11769 -------------------------------------------------------------------------*/
11770v_BOOL_t sme_IsPmcBmps(tHalHandle hHal)
11771{
11772 return (BMPS == pmcGetPmcState(hHal));
11773}
11774
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -070011775eHalStatus sme_UpdateDfsSetting(tHalHandle hHal, tANI_U8 fUpdateEnableDFSChnlScan)
11776{
11777 eHalStatus status = eHAL_STATUS_FAILURE;
11778 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11779
11780 smsLog(pMac, LOG2, FL("enter"));
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053011781
11782 if (pMac->fActiveScanOnDFSChannels)
11783 {
11784 smsLog(pMac, LOG1, FL("Skip updating fEnableDFSChnlScan"
11785 " as DFS feature is triggered"));
11786 return (status);
11787 }
11788
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -070011789 status = sme_AcquireGlobalLock( &pMac->sme );
11790 if ( HAL_STATUS_SUCCESS( status ) )
11791 {
11792 pMac->scan.fEnableDFSChnlScan = fUpdateEnableDFSChnlScan;
11793 sme_ReleaseGlobalLock( &pMac->sme );
11794 }
11795 smsLog(pMac, LOG2, FL("exit status %d"), status);
11796
11797 return (status);
11798}
11799
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053011800/* ---------------------------------------------------------------------------
11801 \fn sme_UpdateDFSRoamMode
11802 \brief Update DFS roam scan mode
11803 This function is called to configure allowDFSChannelRoam
11804 dynamically
11805 \param hHal - HAL handle for device
11806 \param allowDFSChannelRoam - DFS roaming scan mode
11807 mode 0 disable roam scan on DFS channels
11808 mode 1 enables roam scan (passive/active) on DFS channels
11809 \return eHAL_STATUS_SUCCESS - SME update DFS roaming scan config
11810 successfully.
11811 Other status means SME failed to update DFS roaming scan config.
11812 \sa
11813 -------------------------------------------------------------------------*/
11814eHalStatus sme_UpdateDFSRoamMode(tHalHandle hHal, tANI_U8 allowDFSChannelRoam)
11815{
11816 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11817 eHalStatus status = eHAL_STATUS_SUCCESS;
11818
11819 status = sme_AcquireGlobalLock( &pMac->sme );
11820 if ( HAL_STATUS_SUCCESS( status ) )
11821 {
11822 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
11823 "LFR runtime successfully set AllowDFSChannelRoam Mode to "
11824 "%d - old value is %d",
11825 allowDFSChannelRoam,
11826 pMac->roam.configParam.allowDFSChannelRoam);
11827 pMac->roam.configParam.allowDFSChannelRoam = allowDFSChannelRoam;
11828 sme_ReleaseGlobalLock( &pMac->sme );
11829 }
11830#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11831 if (csrRoamIsRoamOffloadScanEnabled(pMac))
11832 {
11833 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11834 REASON_CHANNEL_LIST_CHANGED);
11835 }
11836#endif
11837
11838 return status ;
11839}
11840
11841/* ---------------------------------------------------------------------------
11842 \fn sme_UpdateDFSScanMode
11843 \brief Update DFS scan mode
11844 This function is called to configure fEnableDFSChnlScan.
11845 \param hHal - HAL handle for device
11846 \param dfsScanMode - DFS scan mode
11847 mode 0 disable scan on DFS channels
11848 mode 1 enables passive scan on DFS channels
11849 mode 2 enables active scan on DFS channels for static list
11850 \return eHAL_STATUS_SUCCESS - SME update DFS roaming scan config
11851 successfully.
11852 Other status means SME failed to update DFS scan config.
11853 \sa
11854 -------------------------------------------------------------------------*/
11855eHalStatus sme_UpdateDFSScanMode(tHalHandle hHal, tANI_U8 dfsScanMode)
11856{
11857 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11858 eHalStatus status = eHAL_STATUS_SUCCESS;
11859
11860 status = sme_AcquireGlobalLock( &pMac->sme );
11861 if ( HAL_STATUS_SUCCESS( status ) )
11862 {
11863 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
11864 "DFS scan Mode changed to %d, old value is %d ",
11865 dfsScanMode,
11866 pMac->scan.fEnableDFSChnlScan);
11867 pMac->scan.fEnableDFSChnlScan = dfsScanMode;
11868 sme_ReleaseGlobalLock( &pMac->sme );
11869 }
11870
11871 sme_FilterScanDFSResults(hHal);
11872 sme_UpdateChannelList( hHal );
11873
11874 return status ;
11875}
11876
11877/*--------------------------------------------------------------------------
11878 \brief sme_GetDFSScanMode() - get DFS scan mode
11879 \param hHal - The handle returned by macOpen.
11880 \return DFS scan mode
11881 mode 0 disable scan on DFS channels
11882 mode 1 enables passive scan on DFS channels
11883 mode 2 enables active scan on DFS channels for static list
11884 \sa
11885 --------------------------------------------------------------------------*/
11886v_U8_t sme_GetDFSScanMode(tHalHandle hHal)
11887{
11888 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11889 return pMac->scan.fEnableDFSChnlScan;
11890}
11891
11892/* ---------------------------------------------------------------------------
11893 \fn sme_HandleDFSChanScan
11894 \brief Gets Valid channel list and updates scan control list according to
11895 dfsScanMode
11896 \param hHal - HAL handle for device
11897 \return eHAL_STATUS_FAILURE when failed to get valid channel list
11898 Otherwise eHAL_STATUS_SUCCESS -
11899 \sa
11900 -------------------------------------------------------------------------*/
11901eHalStatus sme_HandleDFSChanScan(tHalHandle hHal)
11902{
11903 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
11904 eHalStatus status = eHAL_STATUS_SUCCESS;
11905 tCsrChannel ChannelList;
11906
Abhishek Singh5f391bd2016-05-04 12:52:45 +053011907 /*
11908 * Set Flag to block driver scan type conversion from active to passive
11909 * and vice versa in case if fEnableDFSChnlScan is
11910 * DFS_CHNL_SCAN_ENABLED_ACTIVE
11911 */
11912 if (DFS_CHNL_SCAN_ENABLED_ACTIVE ==
11913 pMac->scan.fEnableDFSChnlScan)
11914 pMac->fActiveScanOnDFSChannels = 1;
11915 else
11916 pMac->fActiveScanOnDFSChannels = 0;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053011917
11918 ChannelList.numChannels = sizeof(ChannelList.channelList);
11919 status = sme_GetCfgValidChannels(hHal, (tANI_U8 *)ChannelList.channelList,
11920 (tANI_U32*)&ChannelList.numChannels);
11921 if (!HAL_STATUS_SUCCESS(status))
11922 {
11923 smsLog(pMac, LOGE,
11924 FL("Failed to get valid channel list (err=%d)"), status);
11925 return status;
11926 }
11927
11928 smsLog(pMac, LOG1, FL("Valid Channel list:"));
11929 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
11930 ChannelList.channelList, ChannelList.numChannels);
11931
11932 sme_SetCfgScanControlList(hHal, pMac->scan.countryCodeCurrent,
11933 &ChannelList);
11934 return status ;
11935}
11936
Gopichand Nakkalae620d5a2013-04-26 05:45:57 -070011937/*
11938 * SME API to enable/disable WLAN driver initiated SSR
11939 */
11940void sme_UpdateEnableSSR(tHalHandle hHal, tANI_BOOLEAN enableSSR)
11941{
11942 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11943 eHalStatus status = eHAL_STATUS_SUCCESS;
11944
11945 status = sme_AcquireGlobalLock(&pMac->sme);
11946 if (HAL_STATUS_SUCCESS(status))
11947 {
11948 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
11949 "SSR level is changed %d", enableSSR);
11950 /* not serializing this messsage, as this is only going
11951 * to set a variable in WDA/WDI
11952 */
11953 WDA_SetEnableSSR(enableSSR);
11954 sme_ReleaseGlobalLock(&pMac->sme);
11955 }
11956 return;
11957}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011958
11959/*
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053011960 * SME API to stringify bonding mode. (hostapd convention)
11961 */
11962
11963static const char* sme_CBMode2String( tANI_U32 mode)
11964{
11965 switch (mode)
11966 {
11967 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
11968 return "HT20";
11969 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
11970 return "HT40-"; /* lower secondary channel */
11971 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
11972 return "HT40+"; /* upper secondary channel */
11973#ifdef WLAN_FEATURE_11AC
11974 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
11975 return "VHT80+40+"; /* upper secondary channels */
11976 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
11977 return "VHT80+40-"; /* 1 lower and 2 upper secondary channels */
11978 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
11979 return "VHT80-40+"; /* 2 lower and 1 upper secondary channels */
11980 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
11981 return "VHT80-40-"; /* lower secondary channels */
11982#endif
11983 default:
11984 VOS_ASSERT(0);
11985 return "Unknown";
11986 }
11987}
11988
11989/*
Abhishek Singh6b27f072015-09-10 14:46:33 +053011990 * SME API to adjust bonding mode to regulatory .. etc.
11991 *
11992 */
11993static VOS_STATUS sme_AdjustCBMode(tAniSirGlobal* pMac,
11994 tSmeConfigParams *smeConfig,
11995 tANI_U8 channel)
11996{
11997 const tANI_U8 step = SME_START_CHAN_STEP;
11998 tANI_U8 i, startChan = channel, chanCnt = 0, chanBitmap = 0;
11999 tANI_BOOLEAN violation = VOS_FALSE;
12000 tANI_U32 newMode, mode;
12001 tANI_U8 centerChan = channel;
12002 /* to validate 40MHz channels against the regulatory domain */
12003 tANI_BOOLEAN ht40PhyMode = VOS_FALSE;
12004
12005 /* get the bonding mode */
12006 mode = (channel <= 14) ? smeConfig->csrConfig.channelBondingMode24GHz :
12007 smeConfig->csrConfig.channelBondingMode5GHz;
12008 newMode = mode;
12009
12010 /* get the channels */
12011 switch (mode)
12012 {
12013 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
12014 startChan = channel;
12015 chanCnt = 1;
12016 break;
12017 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
12018 startChan = channel - step;
12019 chanCnt = 2;
12020 centerChan = channel - CSR_CB_CENTER_CHANNEL_OFFSET;
12021 ht40PhyMode = VOS_TRUE;
12022 break;
12023 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
12024 startChan = channel;
12025 chanCnt=2;
12026 centerChan = channel + CSR_CB_CENTER_CHANNEL_OFFSET;
12027 ht40PhyMode = VOS_TRUE;
12028 break;
12029#ifdef WLAN_FEATURE_11AC
12030 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
12031 startChan = channel;
12032 chanCnt = 4;
12033 break;
12034 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
12035 startChan = channel - step;
12036 chanCnt = 4;
12037 break;
12038 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
12039 startChan = channel - 2*step;
12040 chanCnt = 4;
12041 break;
12042 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
12043 startChan = channel - 3*step;
12044 chanCnt = 4;
12045 break;
12046#endif
12047 default:
12048 VOS_ASSERT(0);
12049 return VOS_STATUS_E_FAILURE;
12050 }
12051
12052 /* find violation; also map valid channels to a bitmap */
12053 for (i = 0; i < chanCnt; i++)
12054 {
12055 if (csrIsValidChannel(pMac, (startChan + (i * step))) ==
12056 eHAL_STATUS_SUCCESS)
12057 chanBitmap = chanBitmap | 1 << i;
12058 else
12059 violation = VOS_TRUE;
12060 }
12061 /* validate if 40MHz channel is allowed */
12062 if (ht40PhyMode)
12063 {
12064 if (!csrRoamIsValid40MhzChannel(pMac, centerChan))
12065 violation = VOS_TRUE;
12066 }
12067
12068 /* no channels are valid */
12069 if (chanBitmap == 0)
12070 {
12071 /* never be in this case */
12072 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12073 FL("channel %d %s is not supported"),
12074 channel,
12075 sme_CBMode2String(mode));
12076 return VOS_STATUS_E_INVAL;
12077 }
12078
12079 /* fix violation */
12080 if (violation)
12081 {
12082 const tANI_U8 lowerMask = 0x03, upperMask = 0x0c;
12083 /* fall back to single channel in all exception cases */
12084 newMode = eCSR_INI_SINGLE_CHANNEL_CENTERED;
12085
12086 switch (mode)
12087 {
12088 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
12089 /* fall thru */
12090 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
12091 /* fall thru */
12092 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
12093 break;
12094#ifdef WLAN_FEATURE_11AC
12095 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
12096 if ((chanBitmap & lowerMask) == lowerMask)
12097 newMode = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
12098 break;
12099 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
12100 if ((chanBitmap & lowerMask) == lowerMask)
12101 newMode = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
12102 break;
12103 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
12104 if ((chanBitmap & upperMask) == upperMask)
12105 newMode = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
12106 break;
12107 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
12108 if ((chanBitmap & upperMask) == upperMask)
12109 newMode = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
12110 break;
12111#endif
12112 default:
12113 return VOS_STATUS_E_NOSUPPORT;
12114 break;
12115 }
12116
12117 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
12118 FL("bonding mode adjust: %s to %s"),
12119 sme_CBMode2String(mode),
12120 sme_CBMode2String(newMode));
12121
12122 }
12123
12124 /* check for mode change */
12125 if (newMode != mode)
12126 {
12127 if (channel <= 14)
12128 smeConfig->csrConfig.channelBondingMode24GHz = newMode;
12129 else
12130 smeConfig->csrConfig.channelBondingMode5GHz = newMode;
12131 }
12132
12133 return VOS_STATUS_SUCCESS;
12134
12135}
12136
12137/*
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012138 * SME API to determine the channel bonding mode
12139 */
Abhishek Singh02b823e2017-10-30 17:53:20 +053012140VOS_STATUS sme_SelectCBMode(tHalHandle hHal,
12141 eCsrPhyMode eCsrPhyMode, tANI_U8 channel,
12142 enum eSirMacHTChannelWidth max_bw)
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012143{
12144 tSmeConfigParams smeConfig;
12145 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Abhishek Singh4fe2b6b2015-09-15 17:13:27 +053012146#ifdef WLAN_FEATURE_11AC
12147 tANI_U8 vht80Allowed;
12148#endif
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012149
12150 if (
12151#ifdef WLAN_FEATURE_11AC
12152 eCSR_DOT11_MODE_11ac != eCsrPhyMode &&
12153 eCSR_DOT11_MODE_11ac_ONLY != eCsrPhyMode &&
12154#endif
12155 eCSR_DOT11_MODE_11n != eCsrPhyMode &&
krunal soni634aba32014-03-06 17:46:50 -080012156 eCSR_DOT11_MODE_11n_ONLY != eCsrPhyMode &&
12157
12158 eCSR_DOT11_MODE_11a != eCsrPhyMode &&
12159 eCSR_DOT11_MODE_11a_ONLY != eCsrPhyMode &&
12160
12161 eCSR_DOT11_MODE_abg != eCsrPhyMode
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012162 )
12163 {
12164 return VOS_STATUS_SUCCESS;
12165 }
12166
Kaushik, Sushant553a06c2014-11-26 15:29:40 +053012167 vos_mem_zero(&smeConfig, sizeof (tSmeConfigParams));
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012168 sme_GetConfigParam(pMac, &smeConfig);
12169
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012170 /* If channel bonding mode is not required */
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012171#ifdef WLAN_FEATURE_AP_HT40_24G
12172 if ( !pMac->roam.configParam.channelBondingMode5GHz
12173 && !smeConfig.csrConfig.apHT40_24GEnabled ) {
12174#else
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012175 if ( !pMac->roam.configParam.channelBondingMode5GHz ) {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012176#endif
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012177 return VOS_STATUS_SUCCESS;
12178 }
12179
Abhishek Singh02b823e2017-10-30 17:53:20 +053012180/* Check if VHT80 is allowed for the channel*/
12181 vht80Allowed = vos_is_channel_valid_for_vht80(channel);
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012182
12183#ifdef WLAN_FEATURE_11AC
Abhishek Singh02b823e2017-10-30 17:53:20 +053012184 if ((eCSR_DOT11_MODE_11ac == eCsrPhyMode ||
12185 eCSR_DOT11_MODE_11ac_ONLY == eCsrPhyMode) &&
12186 vht80Allowed && (max_bw >= eHT_CHANNEL_WIDTH_80MHZ)) {
12187 if (channel== 36 || channel == 52 || channel == 100 ||
12188 channel == 116 || channel == 149 || channel == 132) {
12189 smeConfig.csrConfig.channelBondingMode5GHz =
12190 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
12191 } else if (channel == 40 || channel == 56 || channel == 104 ||
12192 channel == 120 || channel == 153 || channel == 136) {
12193 smeConfig.csrConfig.channelBondingMode5GHz =
12194 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
12195 } else if (channel == 44 || channel == 60 || channel == 108 ||
12196 channel == 124 || channel == 157 || channel == 140) {
12197 smeConfig.csrConfig.channelBondingMode5GHz =
12198 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
12199 } else if (channel == 48 || channel == 64 || channel == 112 ||
12200 channel == 128 || channel == 144 || channel == 161) {
12201 smeConfig.csrConfig.channelBondingMode5GHz =
12202 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
12203 } else if (channel == 165) {
12204 smeConfig.csrConfig.channelBondingMode5GHz =
12205 eCSR_INI_SINGLE_CHANNEL_CENTERED;
12206 }
Abhishek Singh4fe2b6b2015-09-15 17:13:27 +053012207
Abhishek Singh02b823e2017-10-30 17:53:20 +053012208#ifdef WLAN_FEATURE_AP_HT40_24G
12209 if (smeConfig.csrConfig.apHT40_24GEnabled &&
12210 max_bw >= eHT_CHANNEL_WIDTH_40MHZ)
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012211 {
Abhishek Singh02b823e2017-10-30 17:53:20 +053012212 if (channel >= 1 && channel <= 7)
12213 smeConfig.csrConfig.channelBondingAPMode24GHz =
Abhishek Singh4fe2b6b2015-09-15 17:13:27 +053012214 eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Abhishek Singh02b823e2017-10-30 17:53:20 +053012215 else if (channel >= 8 && channel <= 13)
12216 smeConfig.csrConfig.channelBondingAPMode24GHz =
12217 eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
12218 else if (channel ==14)
12219 smeConfig.csrConfig.channelBondingAPMode24GHz =
Abhishek Singh4fe2b6b2015-09-15 17:13:27 +053012220 eCSR_INI_SINGLE_CHANNEL_CENTERED;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012221 }
Abhishek Singh02b823e2017-10-30 17:53:20 +053012222#endif
12223 } else
12224#endif
12225 if ((eCSR_DOT11_MODE_11n == eCsrPhyMode ||
12226 eCSR_DOT11_MODE_11n_ONLY == eCsrPhyMode ||
12227 eCSR_DOT11_MODE_11ac == eCsrPhyMode ||
12228 eCSR_DOT11_MODE_11ac_ONLY == eCsrPhyMode) &&
12229 (max_bw >= eHT_CHANNEL_WIDTH_40MHZ)) {
12230 if (channel== 40 || channel == 48 || channel == 56 ||
12231 channel == 64 || channel == 104 || channel == 112 ||
12232 channel == 120 || channel == 128 || channel == 136 ||
12233 channel == 153 || channel == 161 || channel == 144) {
12234 smeConfig.csrConfig.channelBondingMode5GHz =
12235 eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
12236 } else if (channel== 36 || channel == 44 || channel == 52 ||
12237 channel == 60 || channel == 100 || channel == 108 ||
12238 channel == 116 || channel == 124 || channel == 132 ||
12239 channel == 149 || channel == 157 || channel == 140) {
12240 smeConfig.csrConfig.channelBondingMode5GHz =
12241 eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
12242 } else if (channel == 165) {
12243 smeConfig.csrConfig.channelBondingMode5GHz =
12244 eCSR_INI_SINGLE_CHANNEL_CENTERED;
12245 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012246
12247#ifdef WLAN_FEATURE_AP_HT40_24G
12248 if (smeConfig.csrConfig.apHT40_24GEnabled)
12249 {
12250 if (channel >= 1 && channel <= 7)
12251 smeConfig.csrConfig.channelBondingAPMode24GHz =
12252 eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
12253 else if (channel >= 8 && channel <= 13)
12254 smeConfig.csrConfig.channelBondingAPMode24GHz =
12255 eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
12256 else if (channel ==14)
12257 smeConfig.csrConfig.channelBondingAPMode24GHz =
12258 eCSR_INI_SINGLE_CHANNEL_CENTERED;
12259 }
12260#endif
Abhishek Singh02b823e2017-10-30 17:53:20 +053012261 } else {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012262#ifdef WLAN_FEATURE_AP_HT40_24G
Abhishek Singh02b823e2017-10-30 17:53:20 +053012263 if (CSR_IS_CHANNEL_24GHZ(channel)) {
12264 smeConfig.csrConfig.channelBondingMode24GHz =
12265 eCSR_INI_SINGLE_CHANNEL_CENTERED;
12266 } else
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012267#endif
Abhishek Singh02b823e2017-10-30 17:53:20 +053012268 {
12269 smeConfig.csrConfig.channelBondingMode5GHz =
12270 eCSR_INI_SINGLE_CHANNEL_CENTERED;
12271 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012272 }
krunal soni634aba32014-03-06 17:46:50 -080012273
Abhishek Singh6b27f072015-09-10 14:46:33 +053012274 sme_AdjustCBMode(pMac, &smeConfig, channel);
12275
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012276#ifdef WLAN_FEATURE_AP_HT40_24G
12277 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12278 FL("%s cbmode selected=%d bonding mode:%s"),
12279 (channel <= 14) ? "2G" : "5G",
12280 (channel <= 14) ? smeConfig.csrConfig.channelBondingAPMode24GHz :
12281 smeConfig.csrConfig.channelBondingMode5GHz,
12282 (channel <= 14) ?
12283 sme_CBMode2String(smeConfig.csrConfig.channelBondingAPMode24GHz) :
12284 sme_CBMode2String(smeConfig.csrConfig.channelBondingMode5GHz));
12285#else
Agarwal Ashishbf98caf2014-03-25 13:29:11 +053012286 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012287 "cbmode selected=%d", smeConfig.csrConfig.channelBondingMode5GHz);
12288#endif
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012289
12290 sme_UpdateConfig (pMac, &smeConfig);
12291 return VOS_STATUS_SUCCESS;
12292}
12293
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070012294/*--------------------------------------------------------------------------
12295
12296 \brief sme_SetCurrDeviceMode() - Sets the current operating device mode.
12297 \param hHal - The handle returned by macOpen.
12298 \param currDeviceMode - Current operating device mode.
12299 --------------------------------------------------------------------------*/
12300
12301void sme_SetCurrDeviceMode (tHalHandle hHal, tVOS_CON_MODE currDeviceMode)
12302{
12303 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12304 pMac->sme.currDeviceMode = currDeviceMode;
12305 return;
12306}
12307
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070012308#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
12309/*--------------------------------------------------------------------------
12310 \brief sme_HandoffRequest() - a wrapper function to Request a handoff
12311 from CSR.
12312 This is a synchronous call
12313 \param hHal - The handle returned by macOpen
12314 \param pHandoffInfo - info provided by HDD with the handoff request (namely:
12315 BSSID, channel etc.)
12316 \return eHAL_STATUS_SUCCESS - SME passed the request to CSR successfully.
12317 Other status means SME is failed to send the request.
12318 \sa
12319 --------------------------------------------------------------------------*/
12320
12321eHalStatus sme_HandoffRequest(tHalHandle hHal,
12322 tCsrHandoffRequest *pHandoffInfo)
12323{
12324 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12325 eHalStatus status = eHAL_STATUS_SUCCESS;
12326
12327 status = sme_AcquireGlobalLock( &pMac->sme );
12328 if ( HAL_STATUS_SUCCESS( status ) )
12329 {
12330 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
12331 "%s: invoked", __func__);
12332 status = csrHandoffRequest(pMac, pHandoffInfo);
12333 sme_ReleaseGlobalLock( &pMac->sme );
12334 }
12335
12336 return status ;
12337}
12338#endif
12339
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -070012340/*
12341 * SME API to check if there is any infra station or
12342 * P2P client is connected
12343 */
12344VOS_STATUS sme_isSta_p2p_clientConnected(tHalHandle hHal)
12345{
12346 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12347 if(csrIsInfraConnected(pMac))
12348 {
12349 return VOS_STATUS_SUCCESS;
12350 }
12351 return VOS_STATUS_E_FAILURE;
12352}
12353
Agarwal Ashish57e84372014-12-05 18:26:53 +053012354/*
12355 * SME API to check if any sessoion connected.
12356 */
12357VOS_STATUS sme_is_any_session_connected(tHalHandle hHal)
12358{
12359 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12360 if(csrIsAnySessionConnected(pMac))
12361 {
12362
12363 return VOS_STATUS_SUCCESS;
12364 }
12365 return VOS_STATUS_E_FAILURE;
12366}
12367
Leo Chang9056f462013-08-01 19:21:11 -070012368
12369#ifdef FEATURE_WLAN_LPHB
12370/* ---------------------------------------------------------------------------
12371 \fn sme_LPHBConfigReq
12372 \API to make configuration LPHB within FW.
12373 \param hHal - The handle returned by macOpen
12374 \param lphdReq - LPHB request argument by client
12375 \param pCallbackfn - LPHB timeout notification callback function pointer
12376 \- return Configuration message posting status, SUCCESS or Fail
12377 -------------------------------------------------------------------------*/
12378eHalStatus sme_LPHBConfigReq
12379(
12380 tHalHandle hHal,
12381 tSirLPHBReq *lphdReq,
12382 void (*pCallbackfn)(void *pAdapter, void *indParam)
12383)
12384{
12385 eHalStatus status = eHAL_STATUS_SUCCESS;
12386 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12387 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12388 vos_msg_t vosMessage;
12389
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053012390 MTRACE(vos_trace(VOS_MODULE_ID_SME,
12391 TRACE_CODE_SME_RX_HDD_LPHB_CONFIG_REQ,
12392 NO_SESSION, lphdReq->cmd));
Leo Chang9056f462013-08-01 19:21:11 -070012393 status = sme_AcquireGlobalLock(&pMac->sme);
12394 if (eHAL_STATUS_SUCCESS == status)
12395 {
12396 if ((LPHB_SET_EN_PARAMS_INDID == lphdReq->cmd) &&
12397 (NULL == pCallbackfn) &&
Leo Changd9df8aa2013-09-26 13:32:26 -070012398 (NULL == pMac->sme.pLphbIndCb))
Leo Chang9056f462013-08-01 19:21:11 -070012399 {
12400 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12401 "%s: Indication Call back did not registered", __func__);
12402 sme_ReleaseGlobalLock(&pMac->sme);
12403 return eHAL_STATUS_FAILURE;
12404 }
12405 else if (NULL != pCallbackfn)
12406 {
Leo Changd9df8aa2013-09-26 13:32:26 -070012407 pMac->sme.pLphbIndCb = pCallbackfn;
Leo Chang9056f462013-08-01 19:21:11 -070012408 }
12409
12410 /* serialize the req through MC thread */
12411 vosMessage.bodyptr = lphdReq;
12412 vosMessage.type = WDA_LPHB_CONF_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053012413 MTRACE(vos_trace(VOS_MODULE_ID_SME,
12414 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Leo Chang9056f462013-08-01 19:21:11 -070012415 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
12416 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12417 {
12418 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12419 "%s: Post Config LPHB MSG fail", __func__);
12420 status = eHAL_STATUS_FAILURE;
12421 }
12422 sme_ReleaseGlobalLock(&pMac->sme);
12423 }
12424
12425 return(status);
12426}
12427#endif /* FEATURE_WLAN_LPHB */
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -070012428/*--------------------------------------------------------------------------
12429 \brief sme_enable_disable_split_scan() - a wrapper function to set the split
12430 scan parameter.
12431 This is a synchronous call
12432 \param hHal - The handle returned by macOpen
12433 \return NONE.
12434 \sa
12435 --------------------------------------------------------------------------*/
12436void sme_enable_disable_split_scan (tHalHandle hHal, tANI_U8 nNumStaChan,
12437 tANI_U8 nNumP2PChan)
12438{
12439 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12440
12441 pMac->roam.configParam.nNumStaChanCombinedConc = nNumStaChan;
12442 pMac->roam.configParam.nNumP2PChanCombinedConc = nNumP2PChan;
12443
12444 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
12445 "%s: SCAN nNumStaChanCombinedConc : %d,"
12446 "nNumP2PChanCombinedConc : %d ",
12447 __func__, nNumStaChan, nNumP2PChan);
12448
12449 return;
12450
12451}
Leo Chang9056f462013-08-01 19:21:11 -070012452
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012453/**
12454 * sme_AddPeriodicTxPtrn() - Add Periodic TX Pattern
12455 * @hal: global hal handle
12456 * @addPeriodicTxPtrnParams: request message
12457 *
12458 * Return: eHalStatus enumeration
12459 */
12460eHalStatus
12461sme_AddPeriodicTxPtrn(tHalHandle hal,
12462 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
Yue Mab9c86f42013-08-14 15:59:08 -070012463{
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012464 eHalStatus status = eHAL_STATUS_SUCCESS;
12465 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
12466 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12467 struct sSirAddPeriodicTxPtrn *req_msg;
Yue Mab9c86f42013-08-14 15:59:08 -070012468 vos_msg_t msg;
12469
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012470 smsLog(mac, LOG1, FL("enter"));
12471
12472 req_msg = vos_mem_malloc(sizeof(*req_msg));
12473 if (!req_msg)
Yue Mab9c86f42013-08-14 15:59:08 -070012474 {
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012475 smsLog(mac, LOGE, FL("vos_mem_malloc failed"));
12476 return eHAL_STATUS_FAILED_ALLOC;
Yue Mab9c86f42013-08-14 15:59:08 -070012477 }
12478
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012479 *req_msg = *addPeriodicTxPtrnParams;
12480
12481 status = sme_AcquireGlobalLock(&mac->sme);
12482 if (status != eHAL_STATUS_SUCCESS)
12483 {
12484 smsLog(mac, LOGE,
12485 FL("sme_AcquireGlobalLock failed!(status=%d)"),
12486 status);
12487 vos_mem_free(req_msg);
12488 return status;
12489 }
12490
12491 /* Serialize the req through MC thread */
12492 msg.bodyptr = req_msg;
12493 msg.type = WDA_ADD_PERIODIC_TX_PTRN_IND;
12494 vos_status = vos_mq_post_message(VOS_MQ_ID_WDA, &msg);
12495 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12496 {
12497 smsLog(mac, LOGE,
12498 FL("vos_mq_post_message failed!(err=%d)"),
12499 vos_status);
12500 vos_mem_free(req_msg);
12501 status = eHAL_STATUS_FAILURE;
12502 }
12503 sme_ReleaseGlobalLock(&mac->sme);
Yue Mab9c86f42013-08-14 15:59:08 -070012504 return status;
12505}
12506
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012507
12508/**
12509 * sme_DelPeriodicTxPtrn() - Delete Periodic TX Pattern
12510 * @hal: global hal handle
12511 * @delPeriodicTxPtrnParams: request message
12512 *
12513 * Return: eHalStatus enumeration
12514 */
12515eHalStatus
12516sme_DelPeriodicTxPtrn(tHalHandle hal,
12517 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
Yue Mab9c86f42013-08-14 15:59:08 -070012518{
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012519
12520 eHalStatus status = eHAL_STATUS_SUCCESS;
12521 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
12522 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12523 struct sSirDelPeriodicTxPtrn *req_msg;
Yue Mab9c86f42013-08-14 15:59:08 -070012524 vos_msg_t msg;
12525
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012526 smsLog(mac, LOG1, FL("enter"));
12527
12528 req_msg = vos_mem_malloc(sizeof(*req_msg));
12529
12530 if (!req_msg)
Yue Mab9c86f42013-08-14 15:59:08 -070012531 {
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012532 smsLog(mac, LOGE, FL("vos_mem_malloc failed"));
12533 return eHAL_STATUS_FAILED_ALLOC;
Yue Mab9c86f42013-08-14 15:59:08 -070012534 }
12535
Srinivas Girigowdad882a852015-09-29 19:26:23 +053012536 *req_msg = *delPeriodicTxPtrnParams;
12537
12538 status = sme_AcquireGlobalLock(&mac->sme);
12539 if (status != eHAL_STATUS_SUCCESS)
12540 {
12541 smsLog(mac, LOGE,
12542 FL("sme_AcquireGlobalLock failed!(status=%d)"),
12543 status);
12544 vos_mem_free(req_msg);
12545 return status;
12546 }
12547
12548 /* Serialize the req through MC thread */
12549 msg.bodyptr = req_msg;
12550 msg.type = WDA_DEL_PERIODIC_TX_PTRN_IND;
12551 vos_status = vos_mq_post_message(VOS_MQ_ID_WDA, &msg);
12552 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12553 {
12554 smsLog(mac, LOGE,
12555 FL("vos_mq_post_message failed!(err=%d)"),
12556 vos_status);
12557 vos_mem_free(req_msg);
12558 status = eHAL_STATUS_FAILURE;
12559 }
12560 sme_ReleaseGlobalLock(&mac->sme);
Yue Mab9c86f42013-08-14 15:59:08 -070012561 return status;
12562}
12563
Abhishek Singh00b71972016-01-07 10:51:04 +053012564#ifdef WLAN_FEATURE_RMC
12565/* ---------------------------------------------------------------------------
12566 \fn sme_EnableRMC
12567 \brief Used to enable RMC
12568 setting will not persist over reboots
12569 \param hHal
12570 \param sessionId
12571 \- return eHalStatus
12572 -------------------------------------------------------------------------*/
12573eHalStatus sme_EnableRMC(tHalHandle hHal, tANI_U32 sessionId)
12574{
12575 eHalStatus status = eHAL_STATUS_FAILURE;
12576 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12577
12578 smsLog(pMac, LOG1, FL("enable RMC"));
12579 status = sme_AcquireGlobalLock(&pMac->sme);
12580 if (HAL_STATUS_SUCCESS(status))
12581 {
12582 status = csrEnableRMC(pMac, sessionId);
12583 sme_ReleaseGlobalLock(&pMac->sme);
12584 }
12585 return status;
12586}
12587
12588/* ---------------------------------------------------------------------------
12589 \fn sme_DisableRMC
12590 \brief Used to disable RMC
12591 setting will not persist over reboots
12592 \param hHal
12593 \param sessionId
12594 \- return eHalStatus
12595 -------------------------------------------------------------------------*/
12596eHalStatus sme_DisableRMC(tHalHandle hHal, tANI_U32 sessionId)
12597{
12598 eHalStatus status = eHAL_STATUS_FAILURE;
12599 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12600
12601 smsLog(pMac, LOG1, FL("disable RMC"));
12602 status = sme_AcquireGlobalLock(&pMac->sme);
12603 if (HAL_STATUS_SUCCESS(status))
12604 {
12605 status = csrDisableRMC(pMac, sessionId);
12606 sme_ReleaseGlobalLock(&pMac->sme);
12607 }
12608 return status;
12609}
12610#endif /* WLAN_FEATURE_RMC */
12611
12612/* ---------------------------------------------------------------------------
12613 \fn sme_SendRateUpdateInd
12614 \brief API to Update rate
12615 \param hHal - The handle returned by macOpen
12616 \param rateUpdateParams - Pointer to rate update params
12617 \return eHalStatus
12618 ---------------------------------------------------------------------------*/
12619eHalStatus sme_SendRateUpdateInd(tHalHandle hHal, tSirRateUpdateInd *rateUpdateParams)
12620{
12621 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12622 eHalStatus status;
12623 vos_msg_t msg;
12624
12625 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
12626 {
12627 msg.type = WDA_RATE_UPDATE_IND;
12628 msg.bodyptr = rateUpdateParams;
12629
12630 MTRACE(vos_trace(VOS_MODULE_ID_SME,
12631 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
12632 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
12633 {
12634 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,"%s: Not able "
12635 "to post WDA_SET_RMC_RATE_IND to WDA!",
12636 __func__);
12637
12638 sme_ReleaseGlobalLock(&pMac->sme);
12639 return eHAL_STATUS_FAILURE;
12640 }
12641
12642 sme_ReleaseGlobalLock(&pMac->sme);
12643 return eHAL_STATUS_SUCCESS;
12644 }
12645
12646 return status;
12647}
12648
12649#ifdef WLAN_FEATURE_RMC
12650/* ---------------------------------------------------------------------------
12651 \fn sme_GetIBSSPeerInfo
12652 \brief Used to disable RMC
12653 setting will not persist over reboots
12654 \param hHal
12655 \param ibssPeerInfoReq multicast Group IP address
12656 \- return eHalStatus
12657 -------------------------------------------------------------------------*/
12658eHalStatus sme_RequestIBSSPeerInfo(tHalHandle hHal, void *pUserData,
12659 pIbssPeerInfoCb peerInfoCbk,
12660 tANI_BOOLEAN allPeerInfoReqd,
12661 tANI_U8 staIdx)
12662{
12663 eHalStatus status = eHAL_STATUS_FAILURE;
12664 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
12665 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12666 vos_msg_t vosMessage;
12667 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
12668
12669 status = sme_AcquireGlobalLock(&pMac->sme);
12670 if ( eHAL_STATUS_SUCCESS == status)
12671 {
12672 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
12673 pMac->sme.peerInfoParams.pUserData = pUserData;
12674
12675 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
12676 vos_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
12677 if (NULL == pIbssInfoReqParams)
12678 {
12679 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12680 "%s: Not able to allocate memory for dhcp start", __func__);
12681 sme_ReleaseGlobalLock( &pMac->sme );
12682 return eHAL_STATUS_FAILURE;
12683 }
12684 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
12685 pIbssInfoReqParams->staIdx = staIdx;
12686
12687 vosMessage.type = WDA_GET_IBSS_PEER_INFO_REQ;
12688 vosMessage.bodyptr = pIbssInfoReqParams;
12689 vosMessage.reserved = 0;
12690
12691 MTRACE(vos_trace(VOS_MODULE_ID_SME,
12692 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
12693 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
12694 if ( VOS_STATUS_SUCCESS != vosStatus )
12695 {
12696 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12697 "%s: Post WDA_GET_IBSS_PEER_INFO_REQ MSG failed", __func__);
12698 vos_mem_free(pIbssInfoReqParams);
12699 vosStatus = eHAL_STATUS_FAILURE;
12700 }
12701 sme_ReleaseGlobalLock( &pMac->sme );
12702 }
12703
12704 return (vosStatus);
12705}
12706#endif
12707
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -070012708void smeGetCommandQStatus( tHalHandle hHal )
12709{
12710 tSmeCmd *pTempCmd = NULL;
12711 tListElem *pEntry;
12712 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12713
12714 if (NULL == pMac)
12715 {
Kiet Lamcffc5862013-10-30 16:28:45 +053012716 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
12717 "%s: pMac is null", __func__);
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -070012718 return;
12719 }
12720
12721 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12722 if( pEntry )
12723 {
12724 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12725 }
12726 smsLog( pMac, LOGE, "Currently smeCmdActiveList has command (0x%X)",
12727 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
12728 if(pTempCmd)
12729 {
12730 if( eSmeCsrCommandMask & pTempCmd->command )
12731 {
12732 //CSR command is stuck. See what the reason code is for that command
12733 dumpCsrCommandInfo(pMac, pTempCmd);
12734 }
12735 } //if(pTempCmd)
12736
12737 smsLog( pMac, LOGE, "Currently smeCmdPendingList has %d commands",
12738 csrLLCount(&pMac->sme.smeCmdPendingList));
12739
12740 smsLog( pMac, LOGE, "Currently roamCmdPendingList has %d commands",
12741 csrLLCount(&pMac->roam.roamCmdPendingList));
12742
12743 return;
12744}
Rajeev79dbe4c2013-10-05 11:03:42 +053012745
12746#ifdef FEATURE_WLAN_BATCH_SCAN
12747/* ---------------------------------------------------------------------------
12748 \fn sme_SetBatchScanReq
12749 \brief API to set batch scan request in FW
12750 \param hHal - The handle returned by macOpen.
12751 \param pRequest - Pointer to the batch request.
12752 \param sessionId - session ID
12753 \param callbackRoutine - HDD callback which needs to be invoked after
12754 getting set batch scan response from FW
12755 \param callbackContext - pAdapter context
12756 \return eHalStatus
12757 ---------------------------------------------------------------------------*/
12758eHalStatus sme_SetBatchScanReq
12759(
12760 tHalHandle hHal, tSirSetBatchScanReq *pRequest, tANI_U8 sessionId,
12761 void (*callbackRoutine) (void *callbackCtx, tSirSetBatchScanRsp *pRsp),
12762 void *callbackContext
12763)
12764{
12765 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12766 eHalStatus status;
12767
Yue Mae36e3552014-03-05 17:06:20 -080012768 if (!pMac)
12769 {
12770 return eHAL_STATUS_FAILURE;
12771 }
12772
Rajeev79dbe4c2013-10-05 11:03:42 +053012773 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
12774 {
12775 status = pmcSetBatchScanReq(hHal, pRequest, sessionId, callbackRoutine,
12776 callbackContext);
12777 sme_ReleaseGlobalLock( &pMac->sme );
12778 }
12779
12780 return status;
12781}
12782
12783/* ---------------------------------------------------------------------------
12784 \fn sme_TriggerBatchScanResultInd
12785 \brief API to trigger batch scan result indications from FW
12786 \param hHal - The handle returned by macOpen.
12787 \param pRequest - Pointer to get batch request.
12788 \param sessionId - session ID
12789 \param callbackRoutine - HDD callback which needs to be invoked after
12790 getting batch scan result indication from FW
12791 \param callbackContext - pAdapter context
12792 \return eHalStatus
12793 ---------------------------------------------------------------------------*/
12794eHalStatus sme_TriggerBatchScanResultInd
12795(
12796 tHalHandle hHal, tSirTriggerBatchScanResultInd *pRequest, tANI_U8 sessionId,
12797 void (*callbackRoutine) (void *callbackCtx, void *pRsp),
12798 void *callbackContext
12799)
12800{
12801 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12802 eHalStatus status;
12803
12804 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
12805 {
12806 status = pmcTriggerBatchScanResultInd(hHal, pRequest, sessionId,
12807 callbackRoutine, callbackContext);
12808 sme_ReleaseGlobalLock( &pMac->sme );
12809 }
12810
12811 return status;
12812}
12813
12814
12815/* ---------------------------------------------------------------------------
12816 \fn sme_StopBatchScanInd
12817 \brief API to stop batch scan request in FW
12818 \param hHal - The handle returned by macOpen.
12819 \param pRequest - Pointer to the batch request.
12820 \param sessionId - session ID
12821 \return eHalStatus
12822 ---------------------------------------------------------------------------*/
12823eHalStatus sme_StopBatchScanInd
12824(
12825 tHalHandle hHal, tSirStopBatchScanInd *pRequest, tANI_U8 sessionId
12826)
12827{
12828 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12829 eHalStatus status;
12830
12831 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
12832 {
12833 status = pmcStopBatchScanInd(hHal, pRequest, sessionId);
12834 sme_ReleaseGlobalLock( &pMac->sme );
12835 }
12836
12837 return status;
12838}
12839
12840#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -080012841
Abhishek Singh30fd58c2015-07-15 14:19:21 +053012842void activeListCmdTimeoutHandle(void *userData)
12843{
Abhishek Singh837adf22015-10-01 17:37:37 +053012844 tHalHandle hHal= (tHalHandle) userData;
12845 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Abhishek Singh55a24422016-02-04 18:18:04 +053012846 tListElem *pEntry;
12847 tSmeCmd *pTempCmd = NULL;
Abhishek Singh837adf22015-10-01 17:37:37 +053012848
12849 if (NULL == pMac)
12850 {
12851 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
12852 "%s: pMac is null", __func__);
12853 return;
12854 }
Abhishek Singh30fd58c2015-07-15 14:19:21 +053012855 /* Return if no cmd pending in active list as
12856 * in this case we should not be here.
12857 */
12858 if ((NULL == userData) ||
Abhishek Singh837adf22015-10-01 17:37:37 +053012859 (0 == csrLLCount(&pMac->sme.smeCmdActiveList)))
Abhishek Singh30fd58c2015-07-15 14:19:21 +053012860 return;
12861 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12862 "%s: Active List command timeout Cmd List Count %d", __func__,
Abhishek Singh837adf22015-10-01 17:37:37 +053012863 csrLLCount(&pMac->sme.smeCmdActiveList) );
12864 smeGetCommandQStatus(hHal);
Abhishek Singh30fd58c2015-07-15 14:19:21 +053012865
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +053012866 vos_state_info_dump_all();
12867
Abhishek Singh55a24422016-02-04 18:18:04 +053012868
12869 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
12870 if (pEntry) {
12871 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
12872 }
12873 /* If user initiated scan took more than active list timeout
12874 * abort it.
12875 */
12876 if (pTempCmd && (eSmeCommandScan == pTempCmd->command) &&
12877 (eCsrScanUserRequest == pTempCmd->u.scanCmd.reason)) {
12878 sme_AbortMacScan(hHal, pTempCmd->sessionId,
12879 eCSR_SCAN_ABORT_DEFAULT);
12880 return;
Gupta, Kapil35756d62016-03-17 14:19:32 +053012881 } else if (pTempCmd &&
12882 (eSmeCommandRemainOnChannel == pTempCmd->command)) {
12883 /* Ignore if ROC took more than 120 sec */
12884 return;
Abhishek Singh55a24422016-02-04 18:18:04 +053012885 }
Abhishek Singh837adf22015-10-01 17:37:37 +053012886 if (pMac->roam.configParam.enableFatalEvent)
12887 {
12888 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
12889 WLAN_LOG_INDICATOR_HOST_DRIVER,
12890 WLAN_LOG_REASON_SME_COMMAND_STUCK,
Abhishek Singh4eaf6792016-02-04 12:36:39 +053012891 FALSE, FALSE);
Abhishek Singh837adf22015-10-01 17:37:37 +053012892 }
12893 else
12894 {
Abhishek Singh1fb64af2015-10-05 18:12:48 +053012895 /* Initiate SSR to recover */
Abhishek Singh837adf22015-10-01 17:37:37 +053012896 if (!(vos_isLoadUnloadInProgress() ||
12897 vos_is_logp_in_progress(VOS_MODULE_ID_SME, NULL)))
Abhishek Singhc7d6fbc2015-10-19 12:14:41 +053012898 {
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +053012899 vos_wlanRestart(VOS_ACTIVE_LIST_TIMEOUT);
Abhishek Singhc7d6fbc2015-10-19 12:14:41 +053012900 }
Abhishek Singh837adf22015-10-01 17:37:37 +053012901 }
Abhishek Singh30fd58c2015-07-15 14:19:21 +053012902}
12903
Leo Chang0b0e45a2013-12-15 15:18:55 -080012904#ifdef FEATURE_WLAN_CH_AVOID
12905/* ---------------------------------------------------------------------------
12906 \fn sme_AddChAvoidCallback
12907 \brief Used to plug in callback function
12908 Which notify channel may not be used with SAP or P2PGO mode.
12909 Notification come from FW.
12910 \param hHal
12911 \param pCallbackfn : callback function pointer should be plugged in
12912 \- return eHalStatus
12913 -------------------------------------------------------------------------*/
12914eHalStatus sme_AddChAvoidCallback
12915(
12916 tHalHandle hHal,
12917 void (*pCallbackfn)(void *pAdapter, void *indParam)
12918)
12919{
12920 eHalStatus status = eHAL_STATUS_SUCCESS;
12921 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12922
12923 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
12924 "%s: Plug in CH AVOID CB", __func__);
12925
12926 status = sme_AcquireGlobalLock(&pMac->sme);
12927 if (eHAL_STATUS_SUCCESS == status)
12928 {
12929 if (NULL != pCallbackfn)
12930 {
12931 pMac->sme.pChAvoidNotificationCb = pCallbackfn;
12932 }
12933 sme_ReleaseGlobalLock(&pMac->sme);
12934 }
12935
12936 return(status);
12937}
12938#endif /* FEATURE_WLAN_CH_AVOID */
12939
Gupta, Kapil7c34b322015-09-30 13:12:35 +053012940
12941/**
12942 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
12943 * @hal: global hal handle
12944 * @cb: callback function pointer
12945 *
12946 * This function stores the rssi threshold breached callback function.
12947 *
12948 * Return: eHalStatus enumeration.
12949 */
12950eHalStatus sme_set_rssi_threshold_breached_cb(tHalHandle hal,
12951 void (*cb)(void *, struct rssi_breach_event *))
12952{
12953 eHalStatus status = eHAL_STATUS_SUCCESS;
12954 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12955
12956 status = sme_AcquireGlobalLock(&mac->sme);
12957 if (status != eHAL_STATUS_SUCCESS) {
12958 smsLog(mac, LOGE,
12959 FL("sme_AcquireGlobalLock failed!(status=%d)"),
12960 status);
12961 return status;
12962 }
12963
12964 mac->sme.rssiThresholdBreachedCb = cb;
12965 sme_ReleaseGlobalLock(&mac->sme);
12966 return status;
12967}
12968
Sunil Duttc69bccb2014-05-26 21:30:20 +053012969#ifdef WLAN_FEATURE_LINK_LAYER_STATS
12970
12971/* ---------------------------------------------------------------------------
12972 \fn sme_LLStatsSetReq
12973 \brief API to set link layer stats request to FW
12974 \param hHal - The handle returned by macOpen.
12975
12976 \Param pStatsReq - a pointer to a caller allocated object of
12977 typedef struct tSirLLStatsSetReq, signifying the parameters to link layer
12978 stats set.
12979
12980 \return eHalStatus
12981 ---------------------------------------------------------------------------*/
12982eHalStatus sme_LLStatsSetReq(tHalHandle hHal,
12983 tSirLLStatsSetReq *pLinkLayerStatsSetReq)
12984{
12985 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
12986 vos_msg_t msg;
12987 eHalStatus status = eHAL_STATUS_FAILURE;
Dino Mycledf0a5d92014-07-04 09:41:55 +053012988 tSirLLStatsSetReq *plinkLayerSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053012989
Dino Mycledf0a5d92014-07-04 09:41:55 +053012990 plinkLayerSetReq = vos_mem_malloc(sizeof(*plinkLayerSetReq));
12991 if ( !plinkLayerSetReq)
12992 {
12993 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
12994 "%s: Not able to allocate memory for "
12995 "WDA_LINK_LAYER_STATS_SET_REQ",
12996 __func__);
12997 return eHAL_STATUS_FAILURE;
12998 }
Sunil Duttc69bccb2014-05-26 21:30:20 +053012999
Dino Mycledf0a5d92014-07-04 09:41:55 +053013000 *plinkLayerSetReq = *pLinkLayerStatsSetReq;
13001
Sunil Duttc69bccb2014-05-26 21:30:20 +053013002
13003 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
13004 {
13005 msg.type = WDA_LINK_LAYER_STATS_SET_REQ;
13006 msg.reserved = 0;
Dino Mycledf0a5d92014-07-04 09:41:55 +053013007 msg.bodyptr = plinkLayerSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013008
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013009 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13010 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Sunil Duttc69bccb2014-05-26 21:30:20 +053013011 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
13012 {
13013 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13014 "Not able to post SIR_HAL_LL_STATS_SET message to HAL", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013015 vos_mem_free(plinkLayerSetReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +053013016 status = eHAL_STATUS_FAILURE;
13017 }
13018 sme_ReleaseGlobalLock( &pMac->sme );
13019 }
13020 else
13021 {
13022 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13023 "sme_AcquireGlobalLock error", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013024 vos_mem_free(plinkLayerSetReq);
13025 status = eHAL_STATUS_FAILURE;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013026 }
13027 return status;
13028}
13029
13030/* ---------------------------------------------------------------------------
13031 \fn sme_LLStatsGetReq
13032 \brief API to get link layer stats request to FW
13033 \param hHal - The handle returned by macOpen.
13034
13035 \Param pStatsReq - a pointer to a caller allocated object of
13036 typedef struct tSirLLStatsGetReq, signifying the parameters to link layer
13037 stats get.
13038
13039 \return eHalStatus
13040 ---------------------------------------------------------------------------*/
13041eHalStatus sme_LLStatsGetReq(tHalHandle hHal,
13042 tSirLLStatsGetReq *pLinkLayerStatsGetReq)
13043{
13044 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
13045 vos_msg_t msg;
13046 eHalStatus status = eHAL_STATUS_FAILURE;
Dino Mycledf0a5d92014-07-04 09:41:55 +053013047 tSirLLStatsGetReq *pGetStatsReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013048
Dino Mycledf0a5d92014-07-04 09:41:55 +053013049 pGetStatsReq = vos_mem_malloc(sizeof(*pGetStatsReq));
13050 if ( !pGetStatsReq)
13051 {
13052 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13053 "%s: Not able to allocate memory for "
13054 "WDA_LINK_LAYER_STATS_GET_REQ",
13055 __func__);
13056 return eHAL_STATUS_FAILURE;
13057 }
13058 *pGetStatsReq = *pLinkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013059
13060 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
13061 {
13062 msg.type = WDA_LINK_LAYER_STATS_GET_REQ;
13063 msg.reserved = 0;
Dino Mycledf0a5d92014-07-04 09:41:55 +053013064 msg.bodyptr = pGetStatsReq;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013065 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13066 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Sunil Duttc69bccb2014-05-26 21:30:20 +053013067 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
13068 {
13069 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13070 "Not able to post SIR_HAL_LL_STATS_GET message to HAL", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013071 vos_mem_free(pGetStatsReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +053013072 status = eHAL_STATUS_FAILURE;
13073 }
13074 sme_ReleaseGlobalLock( &pMac->sme );
13075 }
13076 else
13077 {
13078 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13079 "sme_AcquireGlobalLock error", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013080 vos_mem_free(pGetStatsReq);
13081 status = eHAL_STATUS_FAILURE;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013082 }
13083 return status;
13084}
13085
13086/* ---------------------------------------------------------------------------
13087 \fn sme_LLStatsClearReq
13088 \brief API to clear link layer stats request to FW
13089 \param hHal - The handle returned by macOpen.
13090
13091 \Param pStatsReq - a pointer to a caller allocated object of
13092 typedef struct tSirLLStatsClearReq, signifying the parameters to link layer
13093 stats clear.
13094
13095 \return eHalStatus
13096 ---------------------------------------------------------------------------*/
13097eHalStatus sme_LLStatsClearReq(tHalHandle hHal,
13098 tSirLLStatsClearReq *pLinkLayerStatsClear)
13099{
13100 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
13101 vos_msg_t msg;
13102 eHalStatus status = eHAL_STATUS_FAILURE;
Dino Mycledf0a5d92014-07-04 09:41:55 +053013103 tSirLLStatsClearReq *pClearStatsReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013104
13105
Sunil Duttc69bccb2014-05-26 21:30:20 +053013106
Dino Mycledf0a5d92014-07-04 09:41:55 +053013107 pClearStatsReq = vos_mem_malloc(sizeof(*pClearStatsReq));
13108 if ( !pClearStatsReq)
13109 {
13110 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13111 "%s: Not able to allocate memory for "
13112 "WDA_LINK_LAYER_STATS_CLEAR_REQ",
13113 __func__);
13114 return eHAL_STATUS_FAILURE;
13115 }
13116
13117 *pClearStatsReq = *pLinkLayerStatsClear;
13118
Sunil Duttc69bccb2014-05-26 21:30:20 +053013119 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
13120 {
13121 msg.type = WDA_LINK_LAYER_STATS_CLEAR_REQ;
13122 msg.reserved = 0;
Dino Mycledf0a5d92014-07-04 09:41:55 +053013123 msg.bodyptr = pClearStatsReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013124
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013125 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13126 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Sunil Duttc69bccb2014-05-26 21:30:20 +053013127 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
13128 {
13129 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13130 "Not able to post SIR_HAL_LL_STATS_CLEAR message to HAL", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013131 vos_mem_free(pClearStatsReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +053013132 status = eHAL_STATUS_FAILURE;
13133 }
13134 sme_ReleaseGlobalLock( &pMac->sme );
13135 }
13136 else
13137 {
13138 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13139 "sme_AcquireGlobalLock error", __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013140 vos_mem_free(pClearStatsReq);
13141 status = eHAL_STATUS_FAILURE;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013142 }
13143
13144 return status;
13145}
13146
13147/* ---------------------------------------------------------------------------
13148 \fn sme_SetLinkLayerStatsIndCB
13149 \brief API to trigger Link Layer Statistic indications from FW
13150 \param hHal - The handle returned by macOpen.
13151 \param sessionId - session ID
13152 \param callbackRoutine - HDD callback which needs to be invoked after
13153 getting Link Layer Statistics from FW
13154 \param callbackContext - pAdapter context
13155 \return eHalStatus
13156 ---------------------------------------------------------------------------*/
13157eHalStatus sme_SetLinkLayerStatsIndCB
13158(
Dino Mycled3d50022014-07-07 12:58:25 +053013159 tHalHandle hHal,
13160 void (*callbackRoutine) (void *callbackCtx, int indType, void *pRsp,
13161 tANI_U8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +053013162)
13163{
13164 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
13165 eHalStatus status;
13166
13167 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
13168 {
13169 if (NULL != callbackRoutine)
13170 {
13171 pMac->sme.pLinkLayerStatsIndCallback = callbackRoutine;
Sunil Duttc69bccb2014-05-26 21:30:20 +053013172 }
13173 sme_ReleaseGlobalLock( &pMac->sme );
13174 }
13175
13176 return status;
13177}
13178#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
13179
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +053013180
Tushnim Bhattacharyyaed4d0c22014-01-30 11:56:44 -080013181eHalStatus sme_UpdateConnectDebug(tHalHandle hHal, tANI_U32 set_value)
13182{
13183 eHalStatus status = eHAL_STATUS_SUCCESS;
13184 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13185 pMac->fEnableDebugLog = set_value;
13186 return (status);
13187}
13188
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013189VOS_STATUS sme_UpdateDSCPtoUPMapping( tHalHandle hHal,
Kumar Anand82c009f2014-05-29 00:29:42 -070013190 sme_QosWmmUpType *dscpmapping,
13191 v_U8_t sessionId )
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013192{
13193 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Kumar Anand82c009f2014-05-29 00:29:42 -070013194 eHalStatus status = eHAL_STATUS_SUCCESS;
13195 v_U8_t i, j, peSessionId;
13196 tCsrRoamSession *pCsrSession = NULL;
13197 tpPESession pSession = NULL;
13198
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013199 status = sme_AcquireGlobalLock( &pMac->sme );
13200 if ( HAL_STATUS_SUCCESS( status ) )
13201 {
Kumar Anand82c009f2014-05-29 00:29:42 -070013202 pCsrSession = CSR_GET_SESSION( pMac, sessionId );
13203
13204 if (pCsrSession == NULL)
13205 {
13206 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13207 "%s: CSR Session lookup fails %u", __func__, sessionId);
13208 sme_ReleaseGlobalLock( &pMac->sme);
13209 return eHAL_STATUS_FAILURE;
13210 }
13211
Ratheesh S Pe8f00c62015-08-20 13:03:01 +053013212 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13213 {
13214 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13215 "%s: Invalid session Id %u", __func__, sessionId);
13216 sme_ReleaseGlobalLock( &pMac->sme);
13217 return eHAL_STATUS_FAILURE;
13218 }
13219
Kumar Anand82c009f2014-05-29 00:29:42 -070013220 pSession = peFindSessionByBssid( pMac,
13221 pCsrSession->connectedProfile.bssid, &peSessionId );
13222
13223 if (pSession == NULL)
13224 {
13225 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13226 "%s: Session lookup fails for BSSID", __func__);
13227 sme_ReleaseGlobalLock( &pMac->sme);
13228 return eHAL_STATUS_FAILURE;
13229 }
13230
13231 if ( !pSession->QosMapSet.present )
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013232 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053013233 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013234 "%s: QOS Mapping IE not present", __func__);
13235 sme_ReleaseGlobalLock( &pMac->sme);
13236 return eHAL_STATUS_FAILURE;
13237 }
13238 else
13239 {
Kumar Anand82c009f2014-05-29 00:29:42 -070013240 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++)
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013241 {
Kumar Anand82c009f2014-05-29 00:29:42 -070013242 for (j = pSession->QosMapSet.dscp_range[i][0];
13243 j <= pSession->QosMapSet.dscp_range[i][1]; j++)
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013244 {
Kumar Anand82c009f2014-05-29 00:29:42 -070013245 if ((pSession->QosMapSet.dscp_range[i][0] == 255) &&
13246 (pSession->QosMapSet.dscp_range[i][1] == 255))
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013247 {
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013248 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Deepthi Gowri942d3e82016-06-10 18:32:37 +053013249 "%s: User Priority %d is not used in mapping",
13250 __func__, i);
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013251 break;
13252 }
13253 else
13254 {
13255 dscpmapping[j]= i;
13256 }
13257 }
13258 }
Kumar Anand82c009f2014-05-29 00:29:42 -070013259 for (i = 0; i< pSession->QosMapSet.num_dscp_exceptions; i++)
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013260 {
Kumar Anand82c009f2014-05-29 00:29:42 -070013261 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013262 {
Kumar Anand82c009f2014-05-29 00:29:42 -070013263 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0] ] =
13264 pSession->QosMapSet.dscp_exceptions[i][1];
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070013265 }
13266 }
13267 }
13268 }
13269 sme_ReleaseGlobalLock( &pMac->sme);
13270 return status;
13271}
Agarwal Ashish5e414792014-06-08 15:25:23 +053013272
Agarwal Ashish5e414792014-06-08 15:25:23 +053013273tANI_BOOLEAN sme_Is11dCountrycode(tHalHandle hHal)
13274{
13275 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
13276
13277 if (VOS_TRUE == vos_mem_compare(pMac->scan.countryCodeCurrent,
13278 pMac->scan.countryCode11d, 2))
13279 {
13280 return eANI_BOOLEAN_TRUE;
13281 }
13282 else
13283 {
13284 return eANI_BOOLEAN_FALSE;
13285 }
13286}
Dino Mycle2c198072014-06-10 10:15:52 +053013287
Siddharth Bhald8a95e82015-02-12 20:14:52 +053013288eHalStatus sme_SpoofMacAddrReq(tHalHandle hHal, v_MACADDR_t *macaddr)
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +053013289{
Siddharth Bhald8a95e82015-02-12 20:14:52 +053013290 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13291 eHalStatus status = eHAL_STATUS_SUCCESS;
13292 tSmeCmd *pMacSpoofCmd;
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +053013293
mukul sharmaca8e4322015-07-20 18:33:43 +053013294 status = sme_AcquireGlobalLock( &pMac->sme );
13295 if ( HAL_STATUS_SUCCESS( status ) )
13296 {
13297 pMacSpoofCmd = csrGetCommandBuffer(pMac);
13298 if (pMacSpoofCmd)
Siddharth Bhald8a95e82015-02-12 20:14:52 +053013299 {
mukul sharmaca8e4322015-07-20 18:33:43 +053013300 pMacSpoofCmd->command = eSmeCommandMacSpoofRequest;
13301 vos_mem_set(&pMacSpoofCmd->u.macAddrSpoofCmd,
13302 sizeof(tSirSpoofMacAddrReq), 0);
13303 vos_mem_copy(pMacSpoofCmd->u.macAddrSpoofCmd.macAddr,
13304 macaddr->bytes, VOS_MAC_ADDRESS_LEN);
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +053013305
Abhishek Singh06c4b8b2016-04-05 10:27:07 +053013306 status = csrQueueSmeCommand(pMac, pMacSpoofCmd, false);
mukul sharmaca8e4322015-07-20 18:33:43 +053013307 if ( !HAL_STATUS_SUCCESS( status ) )
13308 {
13309 smsLog( pMac, LOGE, FL("fail to send msg status = %d\n"), status );
Abhishek Singh06c4b8b2016-04-05 10:27:07 +053013310 csrReleaseCommand(pMac, pMacSpoofCmd);
mukul sharmaca8e4322015-07-20 18:33:43 +053013311 }
13312 }
13313 else
13314 {
13315 //log error
13316 smsLog(pMac, LOGE, FL("can not obtain a common buffer\n"));
13317 status = eHAL_STATUS_RESOURCES;
13318 }
13319 sme_ReleaseGlobalLock( &pMac->sme);
13320 }
Siddharth Bhald8a95e82015-02-12 20:14:52 +053013321 return (status);
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +053013322}
13323
Dino Mycle2c198072014-06-10 10:15:52 +053013324#ifdef WLAN_FEATURE_EXTSCAN
13325/* ---------------------------------------------------------------------------
13326 \fn sme_GetValidChannelsByBand
13327 \brief SME API to fetch all valid channel filtered by band
13328 \param hHal
13329 \param wifiBand: RF band information
13330 \param aValidChannels: Array to store channel info
13331 \param len: number of channels
13332 \- return eHalStatus
13333 -------------------------------------------------------------------------*/
13334eHalStatus sme_GetValidChannelsByBand (tHalHandle hHal, tANI_U8 wifiBand,
13335 tANI_U32 *aValidChannels, tANI_U8 *pNumChannels)
13336{
13337 eHalStatus status = eHAL_STATUS_SUCCESS;
13338 tANI_U8 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
13339 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13340 tANI_U8 numChannels = 0;
13341 tANI_U8 i = 0;
13342 tANI_U32 totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
13343
13344 if (!aValidChannels || !pNumChannels) {
13345 smsLog(pMac, VOS_TRACE_LEVEL_ERROR,
13346 FL("Output channel list/NumChannels is NULL"));
13347 return eHAL_STATUS_INVALID_PARAMETER;
13348 }
13349
13350 if ((wifiBand < WIFI_BAND_UNSPECIFIED) || (wifiBand >= WIFI_BAND_MAX)) {
13351 smsLog(pMac, VOS_TRACE_LEVEL_ERROR,
13352 FL("Invalid wifiBand (%d)"), wifiBand);
13353 return eHAL_STATUS_INVALID_PARAMETER;
13354 }
13355
13356 status = sme_GetCfgValidChannels(hHal, &chanList[0],
13357 &totValidChannels);
13358 if (!HAL_STATUS_SUCCESS(status)) {
13359 smsLog(pMac, VOS_TRACE_LEVEL_ERROR,
13360 FL("Failed to get valid channel list (err=%d)"), status);
13361 return status;
13362 }
13363
13364 switch (wifiBand) {
13365 case WIFI_BAND_UNSPECIFIED:
13366 smsLog(pMac, VOS_TRACE_LEVEL_INFO, FL("Unspecified wifiBand, "
13367 "return all (%d) valid channels"), totValidChannels);
13368 numChannels = totValidChannels;
13369 for (i = 0; i < numChannels; i++)
13370 aValidChannels[i] = vos_chan_to_freq(chanList[i]);
13371 break;
13372
13373 case WIFI_BAND_BG:
13374 smsLog(pMac, VOS_TRACE_LEVEL_INFO, FL("WIFI_BAND_BG (2.4 GHz)"));
13375 for (i = 0; i < totValidChannels; i++)
13376 if (CSR_IS_CHANNEL_24GHZ(chanList[i]))
13377 aValidChannels[numChannels++] =
13378 vos_chan_to_freq(chanList[i]);
13379 break;
13380
13381 case WIFI_BAND_A:
13382 smsLog(pMac, VOS_TRACE_LEVEL_INFO,
13383 FL("WIFI_BAND_A (5 GHz without DFS)"));
13384 for (i = 0; i < totValidChannels; i++)
13385 if (CSR_IS_CHANNEL_5GHZ(chanList[i]) &&
13386 !CSR_IS_CHANNEL_DFS(chanList[i]))
13387 aValidChannels[numChannels++] =
13388 vos_chan_to_freq(chanList[i]);
13389 break;
13390
13391 case WIFI_BAND_ABG:
13392 smsLog(pMac, VOS_TRACE_LEVEL_INFO,
13393 FL("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)"));
13394 for (i = 0; i < totValidChannels; i++)
13395 if ((CSR_IS_CHANNEL_24GHZ(chanList[i]) ||
13396 CSR_IS_CHANNEL_5GHZ(chanList[i])) &&
13397 !CSR_IS_CHANNEL_DFS(chanList[i]))
13398 aValidChannels[numChannels++] =
13399 vos_chan_to_freq(chanList[i]);
13400 break;
13401
13402 case WIFI_BAND_A_DFS_ONLY:
13403 smsLog(pMac, VOS_TRACE_LEVEL_INFO,
13404 FL("WIFI_BAND_A_DFS (5 GHz DFS only)"));
13405 for (i = 0; i < totValidChannels; i++)
13406 if (CSR_IS_CHANNEL_5GHZ(chanList[i]) &&
13407 CSR_IS_CHANNEL_DFS(chanList[i]))
13408 aValidChannels[numChannels++] =
13409 vos_chan_to_freq(chanList[i]);
13410 break;
13411
13412 case WIFI_BAND_A_WITH_DFS:
13413 smsLog(pMac, VOS_TRACE_LEVEL_INFO,
13414 FL("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)"));
13415 for (i = 0; i < totValidChannels; i++)
13416 if (CSR_IS_CHANNEL_5GHZ(chanList[i]))
13417 aValidChannels[numChannels++] =
13418 vos_chan_to_freq(chanList[i]);
13419 break;
13420
13421 case WIFI_BAND_ABG_WITH_DFS:
13422 smsLog(pMac, VOS_TRACE_LEVEL_INFO,
13423 FL("WIFI_BAND_ABG_WITH_DFS (2.4 GHz + 5 GHz with DFS)"));
13424 for (i = 0; i < totValidChannels; i++)
13425 if (CSR_IS_CHANNEL_24GHZ(chanList[i]) ||
13426 CSR_IS_CHANNEL_5GHZ(chanList[i]))
13427 aValidChannels[numChannels++] =
13428 vos_chan_to_freq(chanList[i]);
13429 break;
13430
13431 default:
13432 smsLog(pMac, VOS_TRACE_LEVEL_ERROR,
13433 FL("Unknown wifiBand (%d))"), wifiBand);
13434 return eHAL_STATUS_INVALID_PARAMETER;
13435 break;
13436 }
13437 *pNumChannels = numChannels;
13438
13439 return status;
13440}
13441/* ---------------------------------------------------------------------------
13442 \fn sme_EXTScanGetCapabilities
13443 \brief SME API to fetch Extended Scan capabilities
13444 \param hHal
13445 \param pReq: Extended Scan capabilities structure
13446 \- return eHalStatus
13447 -------------------------------------------------------------------------*/
13448eHalStatus sme_EXTScanGetCapabilities (tHalHandle hHal,
13449 tSirGetEXTScanCapabilitiesReqParams *pReq)
13450{
13451 eHalStatus status = eHAL_STATUS_SUCCESS;
13452 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13453 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13454 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013455 tSirGetEXTScanCapabilitiesReqParams *pGetEXTScanCapabilitiesReq;
13456
13457 pGetEXTScanCapabilitiesReq =
13458 vos_mem_malloc(sizeof(*pGetEXTScanCapabilitiesReq));
13459 if ( !pGetEXTScanCapabilitiesReq)
13460 {
13461 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13462 "%s: Not able to allocate memory for "
13463 "WDA_EXTSCAN_GET_CAPABILITIES_REQ",
13464 __func__);
13465 return eHAL_STATUS_FAILURE;
13466 }
13467
13468 *pGetEXTScanCapabilitiesReq = *pReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013469
Dino Mycle2c198072014-06-10 10:15:52 +053013470 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13471 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013472 vosMessage.bodyptr = pGetEXTScanCapabilitiesReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013473 vosMessage.type = WDA_EXTSCAN_GET_CAPABILITIES_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013474 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13475 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013476 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013477 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13478 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13479 "failed to post WDA_EXTSCAN_GET_CAPABILITIES_REQ ",
13480 __func__);
13481 vos_mem_free(pGetEXTScanCapabilitiesReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013482 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013483 }
Dino Mycle2c198072014-06-10 10:15:52 +053013484
13485 sme_ReleaseGlobalLock(&pMac->sme);
13486 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013487 else
13488 {
13489 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13490 "sme_AcquireGlobalLock error", __func__);
13491 vos_mem_free(pGetEXTScanCapabilitiesReq);
13492 status = eHAL_STATUS_FAILURE;
13493 }
Dino Mycle2c198072014-06-10 10:15:52 +053013494 return(status);
13495}
13496
13497/* ---------------------------------------------------------------------------
13498 \fn sme_EXTScanStart
13499 \brief SME API to issue Extended Scan start
13500 \param hHal
13501 \param pStartCmd: Extended Scan start structure
13502 \- return eHalStatus
13503 -------------------------------------------------------------------------*/
13504eHalStatus sme_EXTScanStart (tHalHandle hHal,
13505 tSirEXTScanStartReqParams *pStartCmd)
13506{
13507 eHalStatus status = eHAL_STATUS_SUCCESS;
13508 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13509 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13510 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013511 tSirEXTScanStartReqParams *pextScanStartReq;
13512
13513 pextScanStartReq = vos_mem_malloc(sizeof(*pextScanStartReq));
13514 if ( !pextScanStartReq)
13515 {
13516 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13517 "%s: Not able to allocate memory for "
13518 "WDA_EXTSCAN_START_REQ",
13519 __func__);
13520 return eHAL_STATUS_FAILURE;
13521 }
13522
13523 *pextScanStartReq = *pStartCmd;
13524
Dino Mycle2c198072014-06-10 10:15:52 +053013525
13526 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13527 TRACE_CODE_SME_RX_HDD_EXTSCAN_START, NO_SESSION, 0));
13528 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13529 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013530 vosMessage.bodyptr = pextScanStartReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013531 vosMessage.type = WDA_EXTSCAN_START_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013532 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13533 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013534 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013535 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13536 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13537 "%s: failed to post WDA_EXTSCAN_START_REQ", __func__);
13538 vos_mem_free(pextScanStartReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013539 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013540 }
Dino Mycle2c198072014-06-10 10:15:52 +053013541 sme_ReleaseGlobalLock(&pMac->sme);
13542 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013543 else
13544 {
13545 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13546 "sme_AcquireGlobalLock error", __func__);
13547 vos_mem_free(pextScanStartReq);
13548 status = eHAL_STATUS_FAILURE;
13549 }
Dino Mycle2c198072014-06-10 10:15:52 +053013550 return(status);
13551}
13552
13553/* ---------------------------------------------------------------------------
13554 \fn sme_EXTScanStop
13555 \brief SME API to issue Extended Scan stop
13556 \param hHal
13557 \param pStopReq: Extended Scan stop structure
13558 \- return eHalStatus
13559 -------------------------------------------------------------------------*/
13560eHalStatus sme_EXTScanStop(tHalHandle hHal, tSirEXTScanStopReqParams *pStopReq)
13561{
13562 eHalStatus status = eHAL_STATUS_SUCCESS;
13563 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13564 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13565 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013566 tSirEXTScanStopReqParams *pEXTScanStopReq;
13567
13568 pEXTScanStopReq = vos_mem_malloc(sizeof(*pEXTScanStopReq));
13569 if ( !pEXTScanStopReq)
13570 {
13571 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13572 "%s: Not able to allocate memory for "
13573 "WDA_EXTSCAN_STOP_REQ",
13574 __func__);
13575 return eHAL_STATUS_FAILURE;
13576 }
13577
13578 *pEXTScanStopReq = *pStopReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013579
13580 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13581 TRACE_CODE_SME_RX_HDD_EXTSCAN_STOP, NO_SESSION, 0));
13582 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
13583 {
13584 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013585 vosMessage.bodyptr = pEXTScanStopReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013586 vosMessage.type = WDA_EXTSCAN_STOP_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013587 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13588 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013589 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
13590 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
13591 {
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013592 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13593 "%s: failed to post WDA_EXTSCAN_STOP_REQ", __func__);
13594 vos_mem_free(pEXTScanStopReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013595 status = eHAL_STATUS_FAILURE;
13596 }
13597 sme_ReleaseGlobalLock(&pMac->sme);
13598 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013599 else
13600 {
13601 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13602 "sme_AcquireGlobalLock error", __func__);
13603 vos_mem_free(pEXTScanStopReq);
13604 status = eHAL_STATUS_FAILURE;
13605 }
Dino Mycle2c198072014-06-10 10:15:52 +053013606 return(status);
13607}
13608
13609/* ---------------------------------------------------------------------------
13610 \fn sme_SetBssHotlist
13611 \brief SME API to set BSSID hotlist
13612 \param hHal
13613 \param pSetHotListReq: Extended Scan set hotlist structure
13614 \- return eHalStatus
13615 -------------------------------------------------------------------------*/
13616eHalStatus sme_SetBssHotlist (tHalHandle hHal,
13617 tSirEXTScanSetBssidHotListReqParams *pSetHotListReq)
13618{
13619 eHalStatus status = eHAL_STATUS_SUCCESS;
13620 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13621 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13622 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013623 tSirEXTScanSetBssidHotListReqParams *pEXTScanSetBssidHotlistReq;
13624
13625 pEXTScanSetBssidHotlistReq =
13626 vos_mem_malloc(sizeof(*pEXTScanSetBssidHotlistReq));
13627 if ( !pEXTScanSetBssidHotlistReq)
13628 {
13629 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13630 "%s: Not able to allocate memory for "
13631 "WDA_EXTSCAN_SET_BSSID_HOTLIST_REQ",
13632 __func__);
13633 return eHAL_STATUS_FAILURE;
13634 }
13635
13636 *pEXTScanSetBssidHotlistReq = *pSetHotListReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013637
13638 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13639 TRACE_CODE_SME_RX_HDD_EXTSCAN_SET_BSS_HOTLIST, NO_SESSION, 0));
13640 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13641 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013642 vosMessage.bodyptr = pEXTScanSetBssidHotlistReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013643 vosMessage.type = WDA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013644 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13645 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013646 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013647 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13648 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13649 "%s: failed to post WDA_EXTSCAN_STOP_REQ", __func__);
13650 vos_mem_free(pEXTScanSetBssidHotlistReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013651 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013652 }
Dino Mycle2c198072014-06-10 10:15:52 +053013653 sme_ReleaseGlobalLock(&pMac->sme);
13654 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013655 else
13656 {
13657 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13658 "sme_AcquireGlobalLock error", __func__);
13659 vos_mem_free(pEXTScanSetBssidHotlistReq);
13660 status = eHAL_STATUS_FAILURE;
13661 }
Dino Mycle2c198072014-06-10 10:15:52 +053013662
13663 return(status);
13664}
13665
13666/* ---------------------------------------------------------------------------
13667 \fn sme_ResetBssHotlist
13668 \brief SME API to reset BSSID hotlist
13669 \param hHal
13670 \param pSetHotListReq: Extended Scan set hotlist structure
13671 \- return eHalStatus
13672 -------------------------------------------------------------------------*/
13673eHalStatus sme_ResetBssHotlist (tHalHandle hHal,
13674 tSirEXTScanResetBssidHotlistReqParams *pResetReq)
13675{
13676 eHalStatus status = eHAL_STATUS_SUCCESS;
13677 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13678 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13679 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013680 tSirEXTScanResetBssidHotlistReqParams *pEXTScanHotlistResetReq;
13681
13682 pEXTScanHotlistResetReq = vos_mem_malloc(sizeof(*pEXTScanHotlistResetReq));
13683 if ( !pEXTScanHotlistResetReq)
13684 {
13685 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13686 "%s: Not able to allocate memory for "
13687 "WDA_EXTSCAN_RESET_BSSID_HOTLIST_REQ",
13688 __func__);
13689 return eHAL_STATUS_FAILURE;
13690 }
13691
13692 *pEXTScanHotlistResetReq = *pResetReq;
13693
Dino Mycle2c198072014-06-10 10:15:52 +053013694
13695 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13696 TRACE_CODE_SME_RX_HDD_EXTSCAN_RESET_BSS_HOTLIST, NO_SESSION, 0));
13697 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13698 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013699 vosMessage.bodyptr = pEXTScanHotlistResetReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013700 vosMessage.type = WDA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013701 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13702 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013703 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013704 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13705 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13706 "%s: failed to post WDA_EXTSCAN_RESET_BSSID_HOTLIST_REQ",
13707 __func__);
13708 vos_mem_free(pEXTScanHotlistResetReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013709 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013710 }
Dino Mycle2c198072014-06-10 10:15:52 +053013711 sme_ReleaseGlobalLock(&pMac->sme);
13712 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013713 else
13714 {
13715 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13716 "sme_AcquireGlobalLock error", __func__);
13717 vos_mem_free(pEXTScanHotlistResetReq);
13718 status = eHAL_STATUS_FAILURE;
13719 }
Dino Mycle2c198072014-06-10 10:15:52 +053013720 return(status);
13721}
13722
13723/* ---------------------------------------------------------------------------
Dino Mycle2c198072014-06-10 10:15:52 +053013724 \fn sme_getCachedResults
13725 \brief SME API to get cached results
13726 \param hHal
13727 \param pCachedResultsReq: Extended Scan get cached results structure
13728 \- return eHalStatus
13729 -------------------------------------------------------------------------*/
13730eHalStatus sme_getCachedResults (tHalHandle hHal,
13731 tSirEXTScanGetCachedResultsReqParams *pCachedResultsReq)
13732{
13733 eHalStatus status = eHAL_STATUS_SUCCESS;
13734 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13735 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13736 vos_msg_t vosMessage;
Dino Myclee8843b32014-07-04 14:21:45 +053013737 tSirEXTScanGetCachedResultsReqParams *pEXTScanCachedResultsReq;
13738
13739 pEXTScanCachedResultsReq =
13740 vos_mem_malloc(sizeof(*pEXTScanCachedResultsReq));
13741 if ( !pEXTScanCachedResultsReq)
13742 {
13743 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13744 "%s: Not able to allocate memory for "
13745 "WDA_EXTSCAN_GET_CACHED_RESULTS_REQ",
13746 __func__);
13747 return eHAL_STATUS_FAILURE;
13748 }
13749
13750 *pEXTScanCachedResultsReq = *pCachedResultsReq;
13751
Dino Mycle2c198072014-06-10 10:15:52 +053013752
13753 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13754 TRACE_CODE_SME_RX_HDD_EXTSCAN_GET_CACHED_RESULTS, NO_SESSION, 0));
13755 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13756 /* Serialize the req through MC thread */
Dino Myclee8843b32014-07-04 14:21:45 +053013757 vosMessage.bodyptr = pEXTScanCachedResultsReq;
Dino Mycle2c198072014-06-10 10:15:52 +053013758 vosMessage.type = WDA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013759 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13760 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Dino Mycle2c198072014-06-10 10:15:52 +053013761 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013762 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13763 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13764 "%s: failed tp post WDA_EXTSCAN_GET_CACHED_RESULTS_REQ",
13765 __func__);
13766 vos_mem_free(pEXTScanCachedResultsReq);
Dino Mycle2c198072014-06-10 10:15:52 +053013767 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013768 }
Dino Mycle2c198072014-06-10 10:15:52 +053013769 sme_ReleaseGlobalLock(&pMac->sme);
13770 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013771 else
13772 {
13773 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13774 FL("Failed to acquire SME Global Lock"));
13775 vos_mem_free(pEXTScanCachedResultsReq);
13776 status = eHAL_STATUS_FAILURE;
13777 }
Dino Mycle2c198072014-06-10 10:15:52 +053013778 return(status);
13779}
13780
13781eHalStatus sme_EXTScanRegisterCallback (tHalHandle hHal,
13782 void (*pEXTScanIndCb)(void *, const tANI_U16, void *),
13783 void *callbackContext)
13784{
13785 eHalStatus status = eHAL_STATUS_SUCCESS;
13786 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13787
13788 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13789 pMac->sme.pEXTScanIndCb = pEXTScanIndCb;
13790 pMac->sme.pEXTScanCallbackContext = callbackContext;
13791 sme_ReleaseGlobalLock(&pMac->sme);
13792 }
13793 return(status);
13794}
13795
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053013796#ifdef FEATURE_OEM_DATA_SUPPORT
13797eHalStatus sme_OemDataRegisterCallback (tHalHandle hHal,
Padma, Santhosh Kumaree7c3d22016-01-25 10:36:08 +053013798 void (*pOemDataIndCb)(void *, const tANI_U16, void *, tANI_U32),
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053013799 void *callbackContext)
13800{
13801 eHalStatus status = eHAL_STATUS_SUCCESS;
13802 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13803
13804 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13805 pMac->sme.pOemDataIndCb = pOemDataIndCb;
13806 pMac->sme.pOemDataCallbackContext = callbackContext;
13807 sme_ReleaseGlobalLock(&pMac->sme);
13808 }
13809 return(status);
13810}
13811#endif
13812
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +053013813void sme_SetMiracastMode (tHalHandle hHal,tANI_U8 mode)
13814{
13815 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Padma, Santhosh Kumarc1f7f052015-08-26 12:29:01 +053013816 eHalStatus status = eHAL_STATUS_SUCCESS;
13817 vos_msg_t vosMessage = {0};
13818 tSirHighPriorityDataInfoInd *phighPriorityDataInfo;
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +053013819
13820 pMac->miracast_mode = mode;
Padma, Santhosh Kumarc1f7f052015-08-26 12:29:01 +053013821
13822 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
13823 "%s: miracast_mode: %d", __func__, mode);
13824
13825 phighPriorityDataInfo =
13826 vos_mem_malloc(sizeof(*phighPriorityDataInfo));
13827 if ( !phighPriorityDataInfo)
13828 {
13829 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s:"
13830 "Failed to allocate memory for WDA_HIGH_PRIORITY_DATA_INFO_IND",
13831 __func__);
13832 return;
13833 }
13834
13835 if (mode)
13836 phighPriorityDataInfo->pause = TRUE;
13837 else
13838 phighPriorityDataInfo->pause = FALSE;
13839
13840 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13841 /* Serialize the req through MC thread */
13842 vosMessage.bodyptr = phighPriorityDataInfo;
13843 vosMessage.type = WDA_HIGH_PRIORITY_DATA_INFO_IND;
13844 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13845 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
13846
13847 if(VOS_STATUS_SUCCESS !=
13848 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage)) {
13849 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s:"
13850 "Failed to post WDA_HIGH_PRIORITY_DATA_INFO_IND msg to WDA",
13851 __func__);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013852 vos_mem_free(phighPriorityDataInfo);
Padma, Santhosh Kumarc1f7f052015-08-26 12:29:01 +053013853 }
13854 sme_ReleaseGlobalLock(&pMac->sme);
13855 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013856 else
13857 {
13858 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13859 "sme_AcquireGlobalLock error", __func__);
13860 vos_mem_free(phighPriorityDataInfo);
13861 }
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +053013862}
Dino Mycle2c198072014-06-10 10:15:52 +053013863#endif /* WLAN_FEATURE_EXTSCAN */
c_hpothuef45bc32014-09-11 10:10:18 +053013864
13865void sme_resetCoexEevent(tHalHandle hHal)
13866{
13867 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13868
13869 if (pMac == NULL)
13870 {
13871 printk("btc: %s pMac is NULL \n",__func__);
13872 return;
13873 }
13874
13875 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
13876 FL("isCoexScoIndSet: %d"), pMac->isCoexScoIndSet);
13877
13878 if (pMac->isCoexScoIndSet)
13879 {
13880 pMac->isCoexScoIndSet = 0;
13881 ccmCfgSetInt(pMac, WNI_CFG_DEL_ALL_RX_TX_BA_SESSIONS_2_4_G_BTC, 0,
13882 NULL, eANI_BOOLEAN_FALSE);
13883 }
13884
13885 return;
13886}
Agarwal Ashish738843c2014-09-25 12:27:56 +053013887
13888void sme_disable_dfs_channel(tHalHandle hHal, bool disbale_dfs)
13889{
13890 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13891 pMac->scan.fEnableDFSChnlScan = !disbale_dfs;
13892 csrDisableDfsChannel(pMac);
13893
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053013894 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
13895 "%s: Modified fEnableDFSChnlScan: %d", __func__,
13896 pMac->scan.fEnableDFSChnlScan);
Agarwal Ashish738843c2014-09-25 12:27:56 +053013897}
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053013898
13899/* ---------------------------------------------------------------------------
13900 \fn sme_Encryptmsgsend
13901 \brief SME API to issue encrypt message request
13902 \param hHal
13903 \param pCmd: Data to be encrypted
13904 \- return eHalStatus
13905 -------------------------------------------------------------------------*/
13906eHalStatus sme_Encryptmsgsend (tHalHandle hHal,
13907 u8 *pCmd,
13908 int length,
13909 pEncryptMsgRSPCb encMsgCbk)
13910{
13911 eHalStatus status = eHAL_STATUS_SUCCESS;
13912 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13913 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13914 vos_msg_t vosMessage;
13915 u8 *pEncryptMsg;
13916
13917 pEncryptMsg = vos_mem_malloc(length);
13918 if ( !pEncryptMsg)
13919 {
13920 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13921 "%s: Not able to allocate memory for "
13922 "SIR_HAL_ENCRYPT_MSG_REQ",
13923 __func__);
13924 return eHAL_STATUS_FAILURE;
13925 }
13926
13927 vos_mem_copy(pEncryptMsg, pCmd, length);
13928
13929 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme))) {
13930
13931 pMac->sme.pEncMsgInfoParams.pEncMsgCbk = encMsgCbk;
13932 pMac->sme.pEncMsgInfoParams.pUserData = hHal;
13933 /* Serialize the req through MC thread */
13934 vosMessage.bodyptr = pEncryptMsg;
13935 vosMessage.type = SIR_HAL_ENCRYPT_MSG_REQ;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053013936 MTRACE(vos_trace(VOS_MODULE_ID_SME,
13937 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, vosMessage.type));
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053013938 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013939 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
13940 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
13941 "%s: failed to post SIR_HAL_ENCRYPT_MSG_REQ", __func__);
13942 vos_mem_free(pEncryptMsg);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053013943 status = eHAL_STATUS_FAILURE;
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013944 }
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053013945 sme_ReleaseGlobalLock(&pMac->sme);
13946 }
Hanumantha Reddy Pothula692171d2016-02-10 20:16:16 +053013947 else
13948 {
13949 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
13950 "sme_AcquireGlobalLock error", __func__);
13951 vos_mem_free(pEncryptMsg);
13952 status = eHAL_STATUS_FAILURE;
13953 }
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053013954 return(status);
13955}
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +053013956
13957/* ---------------------------------------------------------------------------
13958 \fn sme_RegisterBtCoexTDLSCallback
13959 \brief Used to plug in callback function
13960 Which notify btcoex on or off.
13961 Notification come from FW.
13962 \param hHal
13963 \param pCallbackfn : callback function pointer should be plugged in
13964 \- return eHalStatus
13965 -------------------------------------------------------------------------*/
13966eHalStatus sme_RegisterBtCoexTDLSCallback
13967(
13968 tHalHandle hHal,
13969 void (*pCallbackfn)(void *pAdapter, int )
13970)
13971{
13972 eHalStatus status = eHAL_STATUS_SUCCESS;
13973 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13974
13975 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
13976 "%s: Plug in BtCoex TDLS CB", __func__);
13977
13978 status = sme_AcquireGlobalLock(&pMac->sme);
13979 if (eHAL_STATUS_SUCCESS == status)
13980 {
13981 if (NULL != pCallbackfn)
13982 {
13983 pMac->sme.pBtCoexTDLSNotification = pCallbackfn;
13984 }
13985 sme_ReleaseGlobalLock(&pMac->sme);
13986 }
13987 return(status);
13988}
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013989
13990/* ---------------------------------------------------------------------------
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013991 \fn smeNeighborMiddleOfRoaming
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013992
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013993 \brief This function is a wrapper to call csrNeighborMiddleOfRoaming
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013994
13995 \param hHal - The handle returned by macOpen.
13996
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013997 \return eANI_BOOLEAN_TRUE if reassoc in progress,
13998 eANI_BOOLEAN_FALSE otherwise
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013999---------------------------------------------------------------------------*/
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053014000
14001tANI_BOOLEAN smeNeighborMiddleOfRoaming(tHalHandle hHal)
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053014002{
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053014003 return (csrNeighborMiddleOfRoaming(PMAC_STRUCT(hHal)));
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053014004}
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +053014005
14006/* ---------------------------------------------------------------------------
14007
14008 \fn sme_IsTdlsOffChannelValid
14009
14010 \brief To check if the channel is valid for currently established domain
14011 This is a synchronous API.
14012
14013 \param hHal - The handle returned by macOpen.
14014 \param channel - channel to verify
14015
14016 \return TRUE/FALSE, TRUE if channel is valid
14017
14018 -------------------------------------------------------------------------------*/
14019tANI_BOOLEAN sme_IsTdlsOffChannelValid(tHalHandle hHal, tANI_U8 channel)
14020{
14021 eHalStatus status = eHAL_STATUS_FAILURE;
14022 tANI_BOOLEAN valid = FALSE;
14023 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14024
14025 status = sme_AcquireGlobalLock( &pMac->sme );
14026 if ( HAL_STATUS_SUCCESS( status ) )
14027 {
14028 /* check whether off channel is valid and non DFS */
Pradeep Reddy POTTETIb9c5f992015-02-18 14:15:55 +053014029 if (csrRoamIsChannelValid(pMac, channel))
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +053014030 {
Pradeep Reddy POTTETIb9c5f992015-02-18 14:15:55 +053014031 if (!CSR_IS_CHANNEL_DFS(channel))
14032 valid = TRUE;
14033 else {
14034 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14035 "%s: configured channel is DFS", __func__);
14036 }
14037 }
14038 else {
14039 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14040 "%s: configured channel is not valid", __func__);
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +053014041 }
14042 sme_ReleaseGlobalLock( &pMac->sme );
14043 }
Pradeep Reddy POTTETIb9c5f992015-02-18 14:15:55 +053014044 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14045 "%s: current country code %c%c channel %d valid %d",
14046 __func__, pMac->scan.countryCodeCurrent[0],
14047 pMac->scan.countryCodeCurrent[1], channel, valid);
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +053014048 return (valid);
14049}
Mukul Sharma4be88422015-03-09 20:29:07 +053014050
14051tANI_BOOLEAN sme_IsCoexScoIndicationSet(tHalHandle hHal)
14052{
14053 eHalStatus status = eHAL_STATUS_FAILURE;
14054 tANI_BOOLEAN valid = FALSE;
14055 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14056
14057 status = sme_AcquireGlobalLock( &pMac->sme );
14058 if ( HAL_STATUS_SUCCESS( status ) )
14059 {
14060 valid = pMac->isCoexScoIndSet;
14061 }
14062 sme_ReleaseGlobalLock( &pMac->sme );
14063 return (valid);
14064}
Abhishek Singh01c73d12015-03-12 15:13:44 +053014065eHalStatus sme_SetMiracastVendorConfig(tHalHandle hHal,
14066 tANI_U32 iniNumBuffAdvert , tANI_U32 set_value)
14067{
14068 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14069 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
14070 tANI_U32 val = SIZE_OF_SUPPORTED_MCS_SET;
14071
14072 if (ccmCfgGetStr(hHal, WNI_CFG_SUPPORTED_MCS_SET, mcsSet, &val)
14073 != eHAL_STATUS_SUCCESS)
14074 {
14075 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14076 FL("failed to get ini param, WNI_CFG_SUPPORTED_MCS_SET"));
14077 return eHAL_STATUS_FAILURE;
14078 }
14079
14080 if (set_value)
14081 {
14082 if (pMac->miracastVendorConfig)
14083 {
14084 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14085 FL(" Miracast tuning already enabled!!"));
14086 return eHAL_STATUS_SUCCESS;
14087 }
14088
14089 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14090 FL("Enable Miracast tuning by disabling 64QAM rates, setting 4 blocks for aggregation and disabling probe response for broadcast probe in P2P-GO mode"));
14091
14092 if (ccmCfgSetInt(hHal, WNI_CFG_NUM_BUFF_ADVERT, 4,
14093 NULL, eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14094 {
14095 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14096 FL("Failure: Could not set WNI_CFG_NUM_BUFF_ADVERT"));
14097 return eHAL_STATUS_FAILURE;
14098 }
14099 /* Disable 64QAM rates ie (MCS 5,6 and 7)
14100 */
14101 mcsSet[0]=0x1F;
14102 }
14103 else
14104 {
14105 if (!pMac->miracastVendorConfig)
14106 {
14107 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14108 FL(" Miracast tuning already disabled!!"));
14109 return eHAL_STATUS_SUCCESS;
14110 }
14111
14112 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14113 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"),
14114 iniNumBuffAdvert);
14115
14116 if (ccmCfgSetInt(hHal, WNI_CFG_NUM_BUFF_ADVERT, iniNumBuffAdvert,
14117 NULL, eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14118 {
14119 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14120 FL("Failure: Could not set WNI_CFG_NUM_BUFF_ADVERT"));
14121 return eHAL_STATUS_FAILURE;
14122 }
14123 /* Enable all MCS rates)
14124 */
14125 mcsSet[0]=0xFF;
14126 }
14127
14128 if (ccmCfgSetStr(hHal, WNI_CFG_SUPPORTED_MCS_SET, mcsSet,
14129 val, NULL, eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14130 {
14131 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14132 FL("Failure: Could not set WNI_CFG_SUPPORTED_MCS_SET"));
14133 return eHAL_STATUS_FAILURE;
14134 }
14135
14136 pMac->miracastVendorConfig = set_value;
14137 return eHAL_STATUS_SUCCESS;
14138}
Mukul Sharma4be88422015-03-09 20:29:07 +053014139
Mukul Sharma45063942015-04-01 20:07:59 +053014140void sme_SetDefDot11Mode(tHalHandle hHal)
14141{
14142 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14143 csrSetDefaultDot11Mode(pMac);
14144}
14145
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053014146/* ---------------------------------------------------------------------------
14147 \fn sme_SetTdls2040BSSCoexistence
14148 \brief API to enable or disable 20_40 BSS Coexistence IE in TDLS frames.
14149
14150 \param isEnabled - Enable or Disable.
14151 \- return VOS_STATUS_SUCCES
14152 -------------------------------------------------------------------------*/
14153eHalStatus sme_SetTdls2040BSSCoexistence(tHalHandle hHal,
14154 tANI_S32 isTdls2040BSSCoexEnabled)
14155{
14156 eHalStatus status = eHAL_STATUS_SUCCESS;
14157 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14158 vos_msg_t msg;
14159 tAniSetTdls2040BSSCoex *pMsg;
14160
14161 status = sme_AcquireGlobalLock( &pMac->sme );
14162 if (HAL_STATUS_SUCCESS( status ))
14163 {
14164 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14165 "%s: is2040BSSCoexEnabled %d ",
14166 __func__, isTdls2040BSSCoexEnabled);
14167 pMsg = vos_mem_malloc(sizeof(tAniSetTdls2040BSSCoex));
14168 if (NULL == pMsg )
14169 {
14170 smsLog(pMac, LOGE, "failed to allocate mem for SetTdls2040BSSCoex");
14171 sme_ReleaseGlobalLock( &pMac->sme );
14172 return eHAL_STATUS_FAILURE;
14173 }
14174
14175 pMsg->msgType = pal_cpu_to_be16(
14176 (tANI_U16)eWNI_SME_SET_TDLS_2040_BSSCOEX_REQ);
14177 pMsg->msgLen = (tANI_U16)sizeof(tAniSetTdls2040BSSCoex);
14178 pMsg->SetTdls2040BSSCoex = isTdls2040BSSCoexEnabled;
14179
14180 msg.type = eWNI_SME_SET_TDLS_2040_BSSCOEX_REQ;
14181 msg.reserved = 0;
14182 msg.bodyptr = pMsg;
14183 msg.bodyval = 0;
14184
14185 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_PE, &msg))
14186 {
14187 smsLog(pMac, LOGE,
14188 "sme_SetTdls2040BSSCoexistence failed to post msg to PE ");
14189 vos_mem_free((void *)pMsg);
14190 status = eHAL_STATUS_FAILURE;
14191 }
14192 smsLog(pMac, LOG1, FL(" returned"));
14193 sme_ReleaseGlobalLock( &pMac->sme );
14194 }
14195 return status;
14196}
Abhishek Singh41988ba2015-05-25 19:42:29 +053014197
14198/* ---------------------------------------------------------------------------
14199 \fn sme_SetRtsCtsHtVht
14200 \brief API to to enable/disable RTS/CTS for different modes.
14201
14202 \param set_value - Bit mask value to enable RTS/CTS for different modes.
14203 \- return VOS_STATUS_SUCCES if INdication is posted to
14204 WDA else return eHAL_STATUS_FAILURE
14205 -------------------------------------------------------------------------*/
14206eHalStatus sme_SetRtsCtsHtVht(tHalHandle hHal, tANI_U32 set_value)
14207{
14208 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14209 vos_msg_t msg;
14210
14211 smsLog(pMac, LOG1, FL(" set_value = %d"), set_value);
14212
14213 if (ccmCfgSetInt(hHal, WNI_CFG_ENABLE_RTSCTS_HTVHT, set_value,
14214 NULL, eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14215 {
14216 smsLog(pMac, LOGE,
14217 FL("Failure: Could not set WNI_CFG_ENABLE_RTSCTS_HTVHT"));
14218 return eHAL_STATUS_FAILURE;
14219 }
14220 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ))
14221 {
14222 vos_mem_zero(&msg, sizeof(vos_msg_t));
14223 msg.type = WDA_SET_RTS_CTS_HTVHT;
14224 msg.reserved = 0;
14225 msg.bodyval = set_value;
14226 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_WDA, &msg))
14227 {
14228 smsLog(pMac, LOGE,
14229 FL("Not able to post WDA_SET_RTS_CTS_HTVHT message to HAL"));
14230 sme_ReleaseGlobalLock( &pMac->sme );
14231 return eHAL_STATUS_FAILURE;
14232 }
14233 sme_ReleaseGlobalLock( &pMac->sme );
14234 return eHAL_STATUS_SUCCESS;
14235 }
14236 return eHAL_STATUS_FAILURE;
14237
14238}
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +053014239
Sachin Ahuja715aafc2015-07-21 23:35:10 +053014240
14241/* ---------------------------------------------------------------------------
14242 \fn sme_fatal_event_logs_req
14243 \brief API to to send flush log command to FW..
14244
14245 \param hHal - Mac Context Handle
14246 \- return VOS_STATUS_SUCCES if command is posted to
14247 WDA else return eHAL_STATUS_FAILURE
14248 -------------------------------------------------------------------------*/
14249eHalStatus sme_fatal_event_logs_req(tHalHandle hHal, tANI_U32 is_fatal,
Abhishek Singh837adf22015-10-01 17:37:37 +053014250 tANI_U32 indicator, tANI_U32 reason_code,
14251 tANI_BOOLEAN dump_vos_trace)
Sachin Ahuja715aafc2015-07-21 23:35:10 +053014252{
14253 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14254 vos_msg_t msg;
14255 eHalStatus status = eHAL_STATUS_SUCCESS;
14256 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
14257 tpSirFatalEventLogsReqParam pFatalEventLogsReqParams;
14258
Abhishek Singh4eaf6792016-02-04 12:36:39 +053014259 /* Dump last 500 VosTrace */
Abhishek Singh837adf22015-10-01 17:37:37 +053014260 if (dump_vos_trace)
Abhishek Singh4eaf6792016-02-04 12:36:39 +053014261 vosTraceDumpAll(pMac, 0, 0, 500, 0);
Abhishek Singh837adf22015-10-01 17:37:37 +053014262
14263 if (WLAN_LOG_INDICATOR_HOST_ONLY == indicator)
14264 {
14265 vos_flush_host_logs_for_fatal();
14266 return VOS_STATUS_SUCCESS;
14267 }
14268
Sachin Ahuja715aafc2015-07-21 23:35:10 +053014269 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ))
14270 {
Hanumantha Reddy Pothula368eefb2016-01-22 15:36:40 +053014271 pFatalEventLogsReqParams =
14272 vos_mem_malloc(sizeof(*pFatalEventLogsReqParams));
Sachin Ahuja715aafc2015-07-21 23:35:10 +053014273 if(NULL == pFatalEventLogsReqParams)
14274 {
14275 smsLog(pMac, LOGE,
14276 FL("vos_mem_alloc failed "));
14277 return eHAL_STATUS_FAILED_ALLOC;
14278 }
Hanumantha Reddy Pothula368eefb2016-01-22 15:36:40 +053014279 vos_mem_set(pFatalEventLogsReqParams,
14280 sizeof(*pFatalEventLogsReqParams), 0);
Sachin Ahuja715aafc2015-07-21 23:35:10 +053014281 pFatalEventLogsReqParams->reason_code = reason_code;
14282
14283 vos_mem_zero(&msg, sizeof(vos_msg_t));
14284 msg.type = WDA_FATAL_EVENT_LOGS_REQ;
14285 msg.reserved = 0;
14286 msg.bodyptr = pFatalEventLogsReqParams;
14287 msg.bodyval = 0;
14288 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &msg);
14289 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
14290 {
14291 vos_mem_free(pFatalEventLogsReqParams);
14292 status = eHAL_STATUS_FAILURE;
14293 }
14294 sme_ReleaseGlobalLock( &pMac->sme );
14295 return status;
14296
14297 }
14298 return eHAL_STATUS_FAILURE;
14299}
14300
14301
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +053014302/**
14303 * sme_handleSetFccChannel() - handle fcc constraint request
14304 * @hal: HAL pointer
14305 * @fcc_constraint: whether to apply or remove fcc constraint
14306 *
14307 * Return: tANI_BOOLEAN.
14308 */
Agrawal Ashish842eea82016-02-04 17:56:16 +053014309tANI_BOOLEAN sme_handleSetFccChannel(tHalHandle hHal, tANI_U8 fcc_constraint,
14310 v_U32_t scan_pending)
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +053014311{
14312 eHalStatus status = eHAL_STATUS_SUCCESS;
14313 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14314
14315 status = sme_AcquireGlobalLock(&pMac->sme);
14316
14317 if (eHAL_STATUS_SUCCESS == status &&
14318 (!sme_Is11dSupported(hHal)) )
14319 {
Agrawal Ashish842eea82016-02-04 17:56:16 +053014320 pMac->scan.fcc_constraint = !fcc_constraint;
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +053014321
Agrawal Ashish842eea82016-02-04 17:56:16 +053014322 if (scan_pending == TRUE) {
14323 pMac->scan.defer_update_channel_list = true;
14324 } else {
14325 /* update the channel list to the firmware */
Sourav Mohapatra3dd5dba2018-03-26 15:12:47 +053014326 csrUpdateFCCChannelList(pMac);
Agrawal Ashish842eea82016-02-04 17:56:16 +053014327 }
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +053014328 }
14329
14330 sme_ReleaseGlobalLock(&pMac->sme);
14331
14332 return status;
14333}
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +053014334
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +053014335eHalStatus sme_enableDisableChanAvoidIndEvent(tHalHandle hHal, tANI_U8 set_value)
14336{
14337 eHalStatus status = eHAL_STATUS_SUCCESS;
14338 VOS_STATUS vosStatus;
14339 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14340 vos_msg_t msg;
14341
14342 smsLog(pMac, LOG1, FL("set_value: %d"), set_value);
14343 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ))
14344 {
14345 vos_mem_zero(&msg, sizeof(vos_msg_t));
14346 msg.type = WDA_SEND_FREQ_RANGE_CONTROL_IND;
14347 msg.reserved = 0;
14348 msg.bodyval = set_value;
14349 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &msg);
14350 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
14351 {
14352 status = eHAL_STATUS_FAILURE;
14353 }
14354 sme_ReleaseGlobalLock( &pMac->sme );
14355 return status;
14356 }
14357
14358 return eHAL_STATUS_FAILURE;
14359}
14360
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +053014361eHalStatus sme_DeleteAllTDLSPeers(tHalHandle hHal, uint8_t sessionId)
14362{
14363 tSirDelAllTdlsPeers *pMsg;
14364 eHalStatus status = eHAL_STATUS_SUCCESS;
14365 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14366 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14367
14368 pMsg = vos_mem_malloc(sizeof(tSirDelAllTdlsPeers));
14369 if (NULL == pMsg)
14370 {
14371 smsLog(pMac, LOGE, FL("memory alloc failed"));
14372 return eHAL_STATUS_FAILURE;
14373 }
14374 vos_mem_set(pMsg, sizeof( tSirDelAllTdlsPeers ), 0);
14375 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_ALL_TDLS_PEERS);
14376 pMsg->mesgLen = pal_cpu_to_be16((tANI_U16)sizeof( tSirDelAllTdlsPeers ));
14377 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
14378 sizeof(tSirMacAddr));
14379 status = palSendMBMessage( pMac->hHdd, pMsg );
14380 return status;
14381}
c_manjeecfd1efb2015-09-25 19:32:34 +053014382
14383
14384/**
14385 * sme_FwMemDumpReq() - Send Fwr mem Dump Request
14386 * @hal: HAL pointer
14387 *
14388 * Return: eHalStatus
14389 */
14390
14391eHalStatus sme_FwMemDumpReq(tHalHandle hHal, tAniFwrDumpReq *recv_req)
14392{
14393
14394 eHalStatus status = eHAL_STATUS_SUCCESS;
14395 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14396 vos_msg_t msg;
14397 tAniFwrDumpReq * send_req;
14398
14399 send_req = vos_mem_malloc(sizeof(*send_req));
14400 if(!send_req) {
14401 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14402 FL("Mem allo failed for FW_MEM_DUMP"));
14403 return eHAL_STATUS_FAILURE;
14404 }
14405
14406 send_req->fwMemDumpReqCallback = recv_req->fwMemDumpReqCallback;
14407 send_req->fwMemDumpReqContext = recv_req->fwMemDumpReqContext;
14408
14409 if (eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock(&pMac->sme))
14410 {
14411 msg.bodyptr = send_req;
14412 msg.type = WDA_FW_MEM_DUMP_REQ;
14413 msg.reserved = 0;
14414
14415 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
14416 {
14417 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14418 FL("Not able to post WDA_FW_MEM_DUMP"));
14419 vos_mem_free(send_req);
14420 status = eHAL_STATUS_FAILURE;
14421 }
14422 sme_ReleaseGlobalLock(&pMac->sme);
14423 }
14424 else
14425 {
14426 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14427 FL("Failed to acquire SME Global Lock"));
14428 vos_mem_free(send_req);
14429 status = eHAL_STATUS_FAILURE;
14430 }
14431
14432 return status;
14433}
14434
Arun Khandavalli7eeb1592015-10-19 21:36:57 +053014435eHalStatus sme_set_wificonfig_params(tHalHandle hHal, tSetWifiConfigParams *req)
14436{
14437 eHalStatus status = eHAL_STATUS_SUCCESS;
14438 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14439 vos_msg_t msg;
14440
14441 status = sme_AcquireGlobalLock(&pMac->sme);
14442
14443 if (eHAL_STATUS_SUCCESS == status){
14444
14445 /* serialize the req through MC thread */
14446 msg.type = WDA_WIFI_CONFIG_REQ;
14447 msg.reserved = 0;
14448 msg.bodyptr = req;
14449
14450 MTRACE(vos_trace(VOS_MODULE_ID_SME,
14451 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
14452
14453 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
14454 {
14455 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
14456 "Not able to post SIR_HAL_WIFI_CONFIG_PARAMS message to HAL", __func__);
14457 status = eHAL_STATUS_FAILURE;
14458 }
14459 sme_ReleaseGlobalLock( &pMac->sme );
14460 }
14461 else
14462 {
14463 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
14464 "sme_AcquireGlobalLock error", __func__);
14465 }
14466 return status;
14467}
Padma, Santhosh Kumar2762e9d2015-10-20 15:02:57 +053014468
14469eHalStatus sme_getRegInfo(tHalHandle hHal, tANI_U8 chanId,
14470 tANI_U32 *regInfo1, tANI_U32 *regInfo2)
14471{
14472 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14473 eHalStatus status;
14474 tANI_U8 i;
14475 eAniBoolean found = false;
14476
14477 status = sme_AcquireGlobalLock(&pMac->sme);
14478 *regInfo1 = 0;
14479 *regInfo2 = 0;
14480 if (HAL_STATUS_SUCCESS(status))
14481 {
14482 for (i = 0 ; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++)
14483 {
14484 if (pMac->scan.defaultPowerTable[i].chanId == chanId)
14485 {
14486 SME_SET_CHANNEL_REG_POWER(*regInfo1,
14487 pMac->scan.defaultPowerTable[i].pwr);
14488
14489 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
14490 pMac->scan.defaultPowerTable[i].pwr);
14491
14492
14493 found = true;
14494 break;
14495 }
14496 }
14497
14498 if (!found)
14499 status = eHAL_STATUS_FAILURE;
14500
14501 sme_ReleaseGlobalLock(&pMac->sme);
14502 }
14503 return status;
14504}
Mahesh A Saptasagarcfc65ae2015-12-22 15:06:10 +053014505
14506eHalStatus sme_GetCurrentAntennaIndex(tHalHandle hHal,
14507 tCsrAntennaIndexCallback callback,
14508 void *pContext, tANI_U8 sessionId)
14509{
14510 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14511 eHalStatus status = eHAL_STATUS_SUCCESS;
14512 tSirAntennaDiversitySelectionReq *pMsg;
14513 tCsrRoamSession *pSession;
14514 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
14515 vos_msg_t vosMessage;
14516
14517 status = sme_AcquireGlobalLock(&pMac->sme);
14518 if (HAL_STATUS_SUCCESS(status))
14519 {
14520 pSession = CSR_GET_SESSION( pMac, sessionId );
14521 if (!pSession)
14522 {
14523 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
14524 sme_ReleaseGlobalLock( &pMac->sme );
14525 return eHAL_STATUS_FAILURE;
14526 }
14527
14528 pMsg = (tSirAntennaDiversitySelectionReq*)vos_mem_malloc(sizeof(*pMsg));
14529 if (NULL == pMsg)
14530 {
14531 smsLog(pMac, LOGE, FL("failed to allocated memory"));
14532 sme_ReleaseGlobalLock( &pMac->sme );
14533 return eHAL_STATUS_FAILURE;
14534 }
14535 pMsg->callback = callback;
14536 pMsg->data = pContext;
14537
14538 vosMessage.type = WDA_ANTENNA_DIVERSITY_SELECTION_REQ;
14539 vosMessage.bodyptr = pMsg;
14540 vosMessage.reserved = 0;
14541
14542 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
14543 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
14544 {
14545 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14546 "%s: Failed to post message to WDA", __func__);
14547 vos_mem_free(pMsg);
14548 sme_ReleaseGlobalLock( &pMac->sme );
14549 return eHAL_STATUS_FAILURE;
14550 }
14551 sme_ReleaseGlobalLock( &pMac->sme);
14552 return eHAL_STATUS_SUCCESS;
14553 }
14554 return eHAL_STATUS_FAILURE;
14555}
Mahesh A Saptasagar7d432952016-02-09 14:01:03 +053014556
14557eHalStatus sme_setBcnMissPenaltyCount(tHalHandle hHal,
14558 tModifyRoamParamsReqParams *pModifyRoamReqParams)
14559{
14560 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14561 eHalStatus status = eHAL_STATUS_SUCCESS;
14562 VOS_STATUS vosStatus;
14563 tModifyRoamParamsReqParams *pMsg;
14564 vos_msg_t msg;
14565
14566 status = sme_AcquireGlobalLock(&pMac->sme);
14567 if (HAL_STATUS_SUCCESS(status))
14568 {
14569 pMsg = (tModifyRoamParamsReqParams*)vos_mem_malloc(sizeof(*pMsg));
14570 if (NULL == pMsg)
14571 {
14572 smsLog(pMac, LOGE, FL("failed to allocated memory"));
14573 sme_ReleaseGlobalLock( &pMac->sme );
14574 return eHAL_STATUS_FAILURE;
14575 }
14576 if (NULL == pModifyRoamReqParams)
14577 {
14578 smsLog(pMac, LOGE, FL("Invalid memory"));
14579 vos_mem_free(pMsg);
14580 sme_ReleaseGlobalLock( &pMac->sme );
14581 return eHAL_STATUS_FAILURE;
14582 }
14583 pMsg->param = pModifyRoamReqParams->param;
14584 pMsg->value = pModifyRoamReqParams->value;
14585 vos_mem_zero(&msg, sizeof(vos_msg_t));
14586 msg.type = WDA_MODIFY_ROAM_PARAMS_IND;
14587 msg.reserved = 0;
14588 msg.bodyptr = pMsg;
14589 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &msg);
14590 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
14591 {
14592 status = eHAL_STATUS_FAILURE;
14593 vos_mem_free(pMsg);
14594 }
14595 sme_ReleaseGlobalLock( &pMac->sme );
14596 return status;
14597 }
14598
14599 return eHAL_STATUS_FAILURE;
14600}
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +053014601
14602/**
14603 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
14604 * scan list
14605 * @hal: hal context.
14606 * @bssid: bssid to be removed
14607 *
14608 * This function remove the given bssid from scan list.
14609 *
14610 * Return: hal status.
14611 */
14612eHalStatus sme_remove_bssid_from_scan_list(tHalHandle hal,
14613 tSirMacAddr bssid)
14614{
14615 eHalStatus status = eHAL_STATUS_FAILURE;
14616 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
14617
14618 status = sme_AcquireGlobalLock(&pMac->sme);
14619 if (HAL_STATUS_SUCCESS(status)) {
14620 csr_remove_bssid_from_scan_list(pMac, bssid);
14621 sme_ReleaseGlobalLock(&pMac->sme);
14622 }
14623
14624 return status;
14625}
14626
Agrawal Ashish0552be02016-03-02 18:03:43 +053014627/**
14628 * sme_set_mgmt_frm_via_wq5() - Set INI params sendMgmtPktViaWQ5 to WDA.
14629 * @hal: HAL pointer
14630 * @sendMgmtPktViaWQ5: INI params to enable/disable sending mgmt pkt via WQ5.
14631 *
14632 * Return: void
14633 */
14634void sme_set_mgmt_frm_via_wq5(tHalHandle hHal, tANI_BOOLEAN sendMgmtPktViaWQ5)
14635{
14636 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14637 eHalStatus status = eHAL_STATUS_SUCCESS;
14638
14639 status = sme_AcquireGlobalLock(&pMac->sme);
14640 if (HAL_STATUS_SUCCESS(status))
14641 {
14642 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14643 "sendMgmtPktViaWQ5 is %d", sendMgmtPktViaWQ5);
14644 /* not serializing this messsage, as this is only going
14645 * to set a variable in WDA/WDI
14646 */
14647 WDA_SetMgmtPktViaWQ5(sendMgmtPktViaWQ5);
14648 sme_ReleaseGlobalLock(&pMac->sme);
14649 }
14650 return;
14651}
Agrawal Ashish17ef5082016-10-17 18:33:21 +053014652
Anurag Chouhan6ee81542017-02-09 18:09:27 +053014653/* ARP DEBUG STATS */
14654
14655/**
14656 * sme_set_nud_debug_stats() - sme api to set nud debug stats
14657 * @hHal: handle to hal
14658 * @pSetStatsParam: pointer to set stats param
14659 */
14660eHalStatus sme_set_nud_debug_stats(tHalHandle hHal,
14661 setArpStatsParams *pSetStatsParam)
14662{
14663 setArpStatsParams *arp_set_param;
14664 vos_msg_t msg;
14665
14666 arp_set_param = vos_mem_malloc(sizeof(*arp_set_param));
14667 if (arp_set_param == NULL) {
14668 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14669 FL("Memory allocation failure"));
14670 return VOS_STATUS_E_NOMEM;
14671 }
14672
14673 vos_mem_copy(arp_set_param, pSetStatsParam, sizeof(*arp_set_param));
14674
14675 msg.type = WDA_SET_ARP_STATS_REQ;
14676 msg.reserved = 0;
14677 msg.bodyptr = arp_set_param;
14678
14679 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)) {
14680 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14681 FL("Not able to post message to WDA"));
14682 vos_mem_free(arp_set_param);
14683 return VOS_STATUS_E_FAILURE;
14684 }
14685
14686 return VOS_STATUS_SUCCESS;
14687}
14688
14689/**
14690 * sme_get_nud_debug_stats() - sme api to get nud debug stats
14691 * @hHal: handle to hal
14692 * @pGetStatsParam: pointer to set stats param
14693 */
14694eHalStatus sme_get_nud_debug_stats(tHalHandle hHal,
14695 getArpStatsParams *pGetStatsParam)
14696{
14697 getArpStatsParams *arpGetParams;
14698 vos_msg_t msg;
14699
14700 arpGetParams = vos_mem_malloc(sizeof(*arpGetParams));
14701 if (arpGetParams == NULL) {
14702 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14703 FL("Memory allocation failure"));
14704 return VOS_STATUS_E_NOMEM;
14705 }
14706
14707 vos_mem_copy(arpGetParams, pGetStatsParam, sizeof(*arpGetParams));
14708
14709 msg.type = WDA_GET_ARP_STATS_REQ;
14710 msg.reserved = 0;
14711 msg.bodyptr = arpGetParams;
14712
14713 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)) {
14714 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14715 FL("Not able to post message to WDA"));
14716 vos_mem_free(arpGetParams);
14717 return VOS_STATUS_E_FAILURE;
14718 }
14719
14720 return VOS_STATUS_SUCCESS;
14721}
14722
14723
Agrawal Ashish17ef5082016-10-17 18:33:21 +053014724#ifdef SAP_AUTH_OFFLOAD
14725/**
14726 * sme_set_sap_auth_offload() enable/disable Software AP Auth Offload
14727 * @hHal: hal layer handler
14728 * @sap_auth_offload_info: the information of Software AP Auth offload
14729 *
14730 * This function provide enable/disable Software AP authenticaiton offload
14731 * feature on target firmware
14732 *
14733 * Return: Return eHalStatus.
14734 */
14735eHalStatus sme_set_sap_auth_offload(tHalHandle hHal,
14736 struct tSirSapOffloadInfo *sap_auth_offload_info)
14737{
14738 vos_msg_t vosMessage;
14739 struct tSirSapOffloadInfo *sme_sap_auth_offload_info;
14740 eHalStatus status = eHAL_STATUS_SUCCESS;
14741 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14742
14743 pMac->sap_auth_offload_sec_type =
14744 sap_auth_offload_info->sap_auth_offload_sec_type;
14745 pMac->sap_auth_offload = sap_auth_offload_info->sap_auth_offload_enable;
14746
14747 sme_sap_auth_offload_info =
14748 vos_mem_malloc(sizeof(*sme_sap_auth_offload_info));
14749
14750 if (!sme_sap_auth_offload_info)
14751 {
14752 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14753 "%s: Not able to allocate memory for WDA_SET_SAP_AUTH_OFL",
14754 __func__);
14755 return eHAL_STATUS_E_MALLOC_FAILED;
14756 }
14757 vos_mem_copy(sme_sap_auth_offload_info, sap_auth_offload_info,
14758 sizeof(*sap_auth_offload_info));
14759
14760 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
14761 {
14762 /* serialize the req through MC thread */
14763 vosMessage.type = WDA_SET_SAP_AUTH_OFL;
14764 vosMessage.bodyptr = sme_sap_auth_offload_info;
14765
14766 if (!VOS_IS_STATUS_SUCCESS(
14767 vos_mq_post_message(VOS_MODULE_ID_WDA, &vosMessage)))
14768 {
14769 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14770 "%s: Not able to post WDA_SET_SAP_AUTH_OFL to WDA!",
14771 __func__);
14772 vos_mem_free(sme_sap_auth_offload_info);
14773 status = eHAL_STATUS_FAILURE;
14774 }
14775 sme_ReleaseGlobalLock(&pMac->sme);
14776 }
14777 else
14778 {
14779 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14780 "%s: sme_AcquireGlobalLock error!",
14781 __func__);
14782 vos_mem_free(sme_sap_auth_offload_info);
14783 status = eHAL_STATUS_FAILURE;
14784 }
14785
14786 return (status);
14787}
14788#endif
Anurag Chouhan83026002016-12-13 22:46:21 +053014789
14790#ifdef DHCP_SERVER_OFFLOAD
14791/**
14792 * sme_set_dhcp_srv_offload() - sme api to set dhcp server offload info
14793 * @hal: handle to hal
14794 * @dhcp_srv_info: pointer to dhcp server info
14795 *
14796 * Return: eHalStatus
14797 * eHAL_STATUS_SUCCESS - success or else failure code
14798 */
14799eHalStatus sme_set_dhcp_srv_offload(tHalHandle hal,
14800 sir_dhcp_srv_offload_info_t *dhcp_srv_info)
14801{
14802 vos_msg_t vos_msg;
14803 eHalStatus status = eHAL_STATUS_SUCCESS;
14804 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14805 sir_dhcp_srv_offload_info_t *dhcp_serv_info = NULL;
14806
14807 dhcp_serv_info =
14808 vos_mem_malloc(sizeof(*dhcp_serv_info));
14809 if (NULL == dhcp_serv_info) {
14810 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14811 "Failed to alloc memory");
14812 return VOS_STATUS_E_NOMEM;
14813 }
14814
14815 vos_mem_copy(dhcp_serv_info, dhcp_srv_info,
14816 sizeof(*dhcp_serv_info));
14817
Sachin Ahujae4c6fac2016-12-29 10:30:15 +053014818 dhcp_serv_info->bssidx = peFindBssIdxFromSmeSessionId(mac, dhcp_srv_info->bssidx);
Anurag Chouhan83026002016-12-13 22:46:21 +053014819 status = sme_AcquireGlobalLock(&mac->sme);
14820 if (eHAL_STATUS_SUCCESS == status) {
14821 /* serialize the req through MC thread */
14822 vos_msg.type = WDA_SET_DHCP_SERVER_OFFLOAD_REQ;
14823 vos_msg.bodyptr = dhcp_serv_info;
14824
14825 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message
14826 (VOS_MODULE_ID_WDA, &vos_msg))) {
14827 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14828 "%s: Not able to post WDA_SET_DHCP_SERVER_OFFLOAD_REQ to WDA!",
14829 __func__);
14830 vos_mem_free(dhcp_serv_info);
14831 status = eHAL_STATUS_FAILURE;
14832 }
14833 sme_ReleaseGlobalLock(&mac->sme);
14834 } else {
14835 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14836 "%s: sme_AcquireGlobalLock error!",
14837 __func__);
14838 vos_mem_free(dhcp_serv_info);
14839 }
14840
14841 return status;
14842}
14843#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +053014844
14845#ifdef MDNS_OFFLOAD
14846/**
14847 * sme_set_mdns_offload() - sme API to set mdns offload enable/disable
14848 * @hal: handle to hal pointer
14849 * @mdns_info: pointer to mdns offload info
14850 *
14851 * Return - eHalStatus
14852 */
14853eHalStatus sme_set_mdns_offload(tHalHandle hal,
14854 sir_mdns_offload_info_t *mdns_info)
14855{
14856 vos_msg_t vos_msg;
14857 sir_mdns_offload_info_t *mdns_offload;
14858 eHalStatus status = eHAL_STATUS_SUCCESS;
14859 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14860
14861 mdns_offload = vos_mem_malloc(sizeof(*mdns_offload));
14862
14863 if (!mdns_offload) {
14864 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14865 "%s: Not able to allocate memory for WDA_SET_MDNS_OFFLOAD_CMD",
14866 __func__);
14867 return eHAL_STATUS_E_MALLOC_FAILED;
14868 }
14869
14870 vos_mem_copy(mdns_offload, mdns_info, sizeof(*mdns_offload));
Sachin Ahujae4c6fac2016-12-29 10:30:15 +053014871 mdns_offload->bss_idx =
14872 peFindBssIdxFromSmeSessionId(mac, mdns_info->bss_idx);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053014873 status = sme_AcquireGlobalLock(&mac->sme);
14874 if (eHAL_STATUS_SUCCESS == status) {
14875 /* serialize the req through MC thread */
14876 vos_msg.type = WDA_SET_MDNS_OFFLOAD_CMD;
14877 vos_msg.bodyptr = mdns_offload;
14878
14879 if (!VOS_IS_STATUS_SUCCESS(
14880 vos_mq_post_message(VOS_MODULE_ID_WDA,
14881 &vos_msg))) {
14882 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14883 "%s: Not able to post WDA_SET_MDNS_OFFLOAD_CMD to WDA!",
14884 __func__);
14885 vos_mem_free(mdns_offload);
14886 status = eHAL_STATUS_FAILURE;
14887 }
14888 sme_ReleaseGlobalLock(&mac->sme);
14889 } else {
14890 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14891 "%s: sme_AcquireGlobalLock error!",
14892 __func__);
14893 vos_mem_free(mdns_offload);
14894 }
14895
14896 return (status);
14897}
14898
14899/**
14900 * sme_set_mdns_fqdn() - SME API to set mDNS Fqdn info
14901 * @hal: hal handle
14902 * @mdns_fqdn: mDNS Fqdn info struct
14903 *
14904 * Return - return eHalStatus
14905 */
14906eHalStatus sme_set_mdns_fqdn(tHalHandle hal,
14907 sir_mdns_fqdn_info_t *mdns_fqdn)
14908{
14909 vos_msg_t vos_msg;
14910 sir_mdns_fqdn_info_t *fqdn_info;
14911 eHalStatus status = eHAL_STATUS_SUCCESS;
14912 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14913
14914 fqdn_info = vos_mem_malloc(sizeof(*fqdn_info));
14915
14916 if (!fqdn_info) {
14917 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14918 "%s: Not able to allocate memory for WDA_SET_MDNS_FQDN_CMD",
14919 __func__);
14920 return eHAL_STATUS_E_MALLOC_FAILED;
14921 }
14922
14923 vos_mem_copy(fqdn_info, mdns_fqdn, sizeof(*fqdn_info));
Sachin Ahujae4c6fac2016-12-29 10:30:15 +053014924 fqdn_info->bss_idx = peFindBssIdxFromSmeSessionId(mac, mdns_fqdn->bss_idx);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053014925 status = sme_AcquireGlobalLock(&mac->sme);
14926 if (eHAL_STATUS_SUCCESS == status) {
14927 /* serialize the req through MC thread */
14928 vos_msg.type = WDA_SET_MDNS_FQDN_CMD;
14929 vos_msg.bodyptr = fqdn_info;
14930
14931 if (!VOS_IS_STATUS_SUCCESS(
14932 vos_mq_post_message(VOS_MODULE_ID_WDA,
14933 &vos_msg))) {
14934 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14935 "%s: Not able to post WDA_SET_MDNS_FQDN_CMD to WDA!",
14936 __func__);
14937 vos_mem_free(fqdn_info);
14938 status = eHAL_STATUS_FAILURE;
14939 }
14940 sme_ReleaseGlobalLock(&mac->sme);
14941 } else {
14942 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14943 "%s: sme_AcquireGlobalLock error!",
14944 __func__);
14945 vos_mem_free(fqdn_info);
14946 }
14947
14948 return (status);
14949}
14950
14951/**
14952 * sme_set_mdns_resp() - SME API to set mDNS response info
14953 * @hal: hal handle
14954 * @mdns_resp : mDNS response info struct
14955 *
14956 * Return - eHalStatus
14957 */
14958eHalStatus sme_set_mdns_resp(tHalHandle hal,
14959 sir_mdns_resp_info_t *mdns_resp)
14960{
14961 vos_msg_t vos_msg;
14962 sir_mdns_resp_info_t *resp_info;
14963 eHalStatus status = eHAL_STATUS_SUCCESS;
14964 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14965
14966 resp_info = vos_mem_malloc(sizeof(*resp_info));
14967
14968 if (!resp_info) {
14969 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14970 "%s: Not able to allocate memory for WDA_SET_MDNS_RESPONSE_CMD",
14971 __func__);
14972 return eHAL_STATUS_E_MALLOC_FAILED;
14973 }
14974
14975 vos_mem_copy(resp_info, mdns_resp, sizeof(*resp_info));
Sachin Ahujae4c6fac2016-12-29 10:30:15 +053014976 resp_info->bss_idx = peFindBssIdxFromSmeSessionId(mac, mdns_resp->bss_idx);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053014977 status = sme_AcquireGlobalLock(&mac->sme);
14978 if (eHAL_STATUS_SUCCESS == status) {
14979 /* serialize the req through MC thread */
14980 vos_msg.type = WDA_SET_MDNS_RESPONSE_CMD;
14981 vos_msg.bodyptr = resp_info;
14982
14983 if (!VOS_IS_STATUS_SUCCESS(
14984 vos_mq_post_message(VOS_MODULE_ID_WDA,
14985 &vos_msg))) {
14986 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14987 "%s: Not able to post WDA_SET_MDNS_RESPONSE_CMD to WDA!",
14988 __func__);
14989 vos_mem_free(resp_info);
14990 status = eHAL_STATUS_FAILURE;
14991 }
14992 sme_ReleaseGlobalLock(&mac->sme);
14993 } else {
14994 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14995 "%s: sme_AcquireGlobalLock error!",
14996 __func__);
14997 vos_mem_free(resp_info);
14998 }
14999
15000 return (status);
15001}
15002#endif /* MDNS_OFFLOAD */
Ravi Kumar bokka7d032762016-12-12 23:33:01 +053015003
15004/**
15005 * sme_update_hb_threshold() - Set heartbeat Threshold value.
15006 * @hal: HAL pointer
15007 * @cfgId: cfg param id
15008 * @hbThresh: heartbeat threshold value.
15009 *
15010 * Return: Success/Failure
15011 */
15012eHalStatus sme_update_hb_threshold(tHalHandle hHal, tANI_U32 cfgId,
15013 tANI_U8 hbThresh, eCsrBand eBand)
15014{
15015 eHalStatus status = eHAL_STATUS_SUCCESS;
15016 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15017
15018 if ((hbThresh < WNI_CFG_HEART_BEAT_THRESHOLD_STAMIN) ||
15019 (hbThresh > WNI_CFG_HEART_BEAT_THRESHOLD_STAMAX)) {
15020 smsLog(pMac, LOGE, FL("invalid heartbeat threshold %hhu"), hbThresh);
15021 return eHAL_STATUS_FAILURE;
15022 }
15023
15024 if(eBand == eCSR_BAND_24)
15025 pMac->roam.configParam.HeartbeatThresh24 = hbThresh;
15026
15027 if(eBand == eCSR_BAND_5G)
15028 pMac->roam.configParam.HeartbeatThresh50 = hbThresh;
15029
15030 status = sme_update_cfg_int_param(hHal, WNI_CFG_HEART_BEAT_THRESHOLD);
15031 if (eHAL_STATUS_SUCCESS != status) {
15032 smsLog(pMac, LOGE, FL("WLAN set heartbeat threshold FAILED"));
15033 status = eHAL_STATUS_FAILURE;
15034 }
15035 return status;
15036}
Kapil Gupta3d923fb2016-12-20 18:59:27 +053015037
15038#ifdef WLAN_FEATURE_APFIND
15039/**
15040 * sme_apfind_set_cmd() - set apfind configuration to firmware
15041 * @input: pointer to apfind request data.
15042 *
15043 * SME API to set APFIND configuations to firmware.
15044 *
15045 * Return: VOS_STATUS.
15046 */
15047VOS_STATUS sme_apfind_set_cmd(struct sme_ap_find_request_req *input)
15048{
15049 vos_msg_t msg;
15050 struct hal_apfind_request *data;
15051 size_t data_len;
15052
15053 data_len = sizeof(struct hal_apfind_request) + input->request_data_len;
15054 data = vos_mem_malloc(data_len);
15055
15056 if (data == NULL) {
15057 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15058 FL("Memory allocation failure"));
15059 return VOS_STATUS_E_NOMEM;
15060 }
15061
15062 vos_mem_zero(data, data_len);
15063 data->request_data_len = input->request_data_len;
15064 if (input->request_data_len) {
15065 vos_mem_copy(data->request_data,
15066 input->request_data, input->request_data_len);
15067 }
15068
15069 msg.type = WDA_APFIND_SET_CMD;
15070 msg.reserved = 0;
15071 msg.bodyptr = data;
15072
15073 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)) {
15074 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15075 FL("Not able to post WDA_APFIND_SET_CMD message to WDA"));
15076 vos_mem_free(data);
15077 return VOS_STATUS_E_FAILURE;
15078 }
15079
15080 return VOS_STATUS_SUCCESS;
15081}
Manjeet Singh3ed79242017-01-11 19:04:32 +053015082
Kapil Gupta3d923fb2016-12-20 18:59:27 +053015083#endif /* WLAN_FEATURE_APFIND */
Manjeet Singh3ed79242017-01-11 19:04:32 +053015084
15085/**
15086 * sme_capture_tsf_req() - send tsf capture request to firmware
15087 * @hHal: hal handle.
15088 * @cap_tsf_params: capture tsf request params.
15089 *
15090 * Return: hal status.
15091 */
15092eHalStatus sme_capture_tsf_req(tHalHandle hHal, tSirCapTsfParams cap_tsf_params)
15093{
15094 eHalStatus status = eHAL_STATUS_SUCCESS;
15095 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15096 vos_msg_t vosMessage;
15097 tpSirCapTsfParams tsf_params = NULL;
15098 VOS_STATUS vos_status;
15099 tCsrRoamSession *pSession;
15100
15101 MTRACE(vos_trace(VOS_MODULE_ID_SME,
15102 TRACE_CODE_SME_TX_HDD_CAP_TSF_REQ, NO_SESSION, 0));
15103 if (eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock(&pMac->sme)))
15104 {
15105 pSession = CSR_GET_SESSION(pMac, cap_tsf_params.session_id);
15106 if (!pSession)
15107 {
15108 smsLog(pMac, LOGE, FL("session %d not found"),
15109 cap_tsf_params.bss_idx);
15110 sme_ReleaseGlobalLock( &pMac->sme );
15111 return eHAL_STATUS_FAILURE;
15112 }
15113
15114 tsf_params = (tpSirCapTsfParams)
15115 vos_mem_malloc(sizeof(*tsf_params));
15116
15117 if (NULL == tsf_params)
15118 {
15119 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15120 "%s: Not able to allocate memory for sme_capture_tsf_req",
15121 __func__);
15122 sme_ReleaseGlobalLock( &pMac->sme );
15123 return eHAL_STATUS_FAILURE;
15124 }
15125 vos_mem_copy(&tsf_params->bssid, &pSession->connectedProfile.bssid,
15126 sizeof(tsf_params->bssid));
15127
15128 tsf_params->tsf_rsp_cb_func = cap_tsf_params.tsf_rsp_cb_func;
15129 tsf_params->tsf_rsp_cb_ctx = cap_tsf_params.tsf_rsp_cb_ctx;
15130
15131 /* serialize the req through MC thread */
15132 /* TODO: check if callback is required */
15133 vosMessage.bodyptr = tsf_params;
15134 vosMessage.type = eWNI_SME_CAP_TSF_REQ;
15135
15136 vos_status = vos_mq_post_message(VOS_MQ_ID_PE, &vosMessage);
15137
15138 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15139 {
15140 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15141 "%s: Post Set TM Level MSG fail", __func__);
15142 vos_mem_free(tsf_params);
15143 status = eHAL_STATUS_FAILURE;
15144 }
15145 sme_ReleaseGlobalLock( &pMac->sme );
15146 }
15147 return(status);
15148}
15149
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053015150eHalStatus sme_del_sta_ba_session_req(tHalHandle hHal,
15151 tDelBaParams sta_del_params)
15152{
15153 eHalStatus status = eHAL_STATUS_SUCCESS;
15154 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15155 vos_msg_t vosMessage;
15156 ptDelBaParams del_params = NULL;
15157 VOS_STATUS vos_status;
15158 tCsrRoamSession *pSession;
15159
15160 MTRACE(vos_trace(VOS_MODULE_ID_SME,
15161 TRACE_CODE_SME_DEL_STA_BA_SESSION_REQ, NO_SESSION, 0));
15162 if (eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock(&pMac->sme)))
15163 {
15164 pSession = CSR_GET_SESSION(pMac, sta_del_params.session_id);
15165 if (!pSession)
15166 {
15167 smsLog(pMac, LOGE, FL("session not found"));
15168 sme_ReleaseGlobalLock( &pMac->sme );
15169 return eHAL_STATUS_FAILURE;
15170 }
15171
15172 del_params = (ptDelBaParams) vos_mem_malloc(sizeof(*del_params));
15173
15174 if (NULL == del_params)
15175 {
15176 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15177 "%s: Not able to allocate memory for sme_del_sta_ba_session_req", __func__);
15178 sme_ReleaseGlobalLock( &pMac->sme );
15179 return eHAL_STATUS_FAILURE;
15180 }
15181 vos_mem_copy(&del_params->session_id, &pSession->sessionId,
15182 sizeof(del_params->session_id));
15183
15184 vosMessage.bodyptr = del_params;
15185 vosMessage.type = eWNI_SME_DEL_BA_SES_REQ;
15186
15187 vos_status = vos_mq_post_message(VOS_MQ_ID_PE, &vosMessage);
15188
15189 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15190 {
15191 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15192 "%s: Post Set TM Level MSG fail", __func__);
15193 vos_mem_free(del_params);
15194 status = eHAL_STATUS_FAILURE;
15195 }
15196 sme_ReleaseGlobalLock( &pMac->sme );
15197 }
15198 return(status);
15199}
15200
Manjeet Singh3ed79242017-01-11 19:04:32 +053015201/**
15202 * sme_get_tsf_req() - send tsf get request to firmware
15203 * @hHal: hal handle.
15204 * @cap_tsf_params: capture tsf request params.
15205 *
15206 * Return: hal status.
15207 */
15208eHalStatus sme_get_tsf_req(tHalHandle hHal, tSirCapTsfParams cap_tsf_params)
15209{
15210 eHalStatus status = eHAL_STATUS_SUCCESS;
15211 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15212 vos_msg_t vosMessage;
15213 tpSirCapTsfParams tsf_params = NULL;
15214 VOS_STATUS vosStatus;
15215 tCsrRoamSession *pSession;
15216
15217 MTRACE(vos_trace(VOS_MODULE_ID_SME,
15218 TRACE_CODE_SME_TX_HDD_GET_TSF_REQ, NO_SESSION, 0));
15219
15220 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
15221 {
15222 pSession = CSR_GET_SESSION(pMac, cap_tsf_params.session_id);
15223
15224 if (!pSession)
15225 {
15226 smsLog(pMac, LOGE, FL("session %d not found"),
15227 cap_tsf_params.bss_idx);
15228 sme_ReleaseGlobalLock(&pMac->sme);
15229 return eHAL_STATUS_FAILURE;
15230 }
15231
15232 tsf_params = (tpSirCapTsfParams)
15233 vos_mem_malloc(sizeof(*tsf_params));
15234 if (NULL == tsf_params)
15235 {
15236 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15237 "%s: Not able to allocate memory for sme_capture_tsf_req",
15238 __func__);
15239 sme_ReleaseGlobalLock(&pMac->sme);
15240 return eHAL_STATUS_FAILURE;
15241 }
15242
15243 vos_mem_copy(&tsf_params->bssid, &pSession->connectedProfile.bssid,
15244 sizeof(tsf_params->bssid));
15245 tsf_params->tsf_rsp_cb_func = cap_tsf_params.tsf_rsp_cb_func;
15246 tsf_params->tsf_rsp_cb_ctx = cap_tsf_params.tsf_rsp_cb_ctx;
15247
15248 /* serialize the req through MC thread */
15249 /* TODO: check if callback is required */
15250 vosMessage.bodyptr = tsf_params;
15251 vosMessage.type = eWNI_SME_GET_TSF_REQ;
15252
15253 vosStatus = vos_mq_post_message(VOS_MQ_ID_PE, &vosMessage);
15254 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
15255 {
15256 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15257 "%s: Post Set TM Level MSG fail", __func__);
15258 vos_mem_free(tsf_params);
15259 status = eHAL_STATUS_FAILURE;
15260 }
15261 sme_ReleaseGlobalLock(&pMac->sme);
15262 }
15263 return(status);
15264}
Abhishek Singh02605092017-10-25 14:06:12 +053015265
15266VOS_STATUS sme_roam_csa_ie_request(tHalHandle hal, tCsrBssid bssid,
Abhishek Singh02b823e2017-10-30 17:53:20 +053015267 uint8_t new_chan, uint32_t phy_mode,
15268 uint8_t sme_session_id)
Abhishek Singh02605092017-10-25 14:06:12 +053015269{
15270 VOS_STATUS status = VOS_STATUS_E_FAILURE;
15271 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15272 uint8_t cb_mode = 0;
Abhishek Singh02b823e2017-10-30 17:53:20 +053015273 tCsrRoamSession *session;
15274
15275 session = CSR_GET_SESSION(mac_ctx, sme_session_id);
15276
15277 if (!session) {
15278 smsLog(mac_ctx, LOGE, FL("session %d not found"), sme_session_id);
15279 return VOS_STATUS_E_FAILURE;
15280 }
Abhishek Singh02605092017-10-25 14:06:12 +053015281
15282 status = sme_AcquireGlobalLock(&mac_ctx->sme);
15283 if (VOS_IS_STATUS_SUCCESS(status)) {
15284 if (CSR_IS_CHANNEL_5GHZ(new_chan)) {
Abhishek Singh02b823e2017-10-30 17:53:20 +053015285 sme_SelectCBMode(hal, phy_mode, new_chan,
15286 session->bssParams.orig_ch_width);
Abhishek Singh02605092017-10-25 14:06:12 +053015287 cb_mode = mac_ctx->roam.configParam.channelBondingMode5GHz;
15288 }
15289 status = csr_roam_send_chan_sw_ie_request(mac_ctx, bssid,
15290 new_chan, cb_mode);
15291 sme_ReleaseGlobalLock(&mac_ctx->sme);
15292 }
15293 return status;
15294}
15295
Abhishek Singh550aa8c2017-10-30 17:34:53 +053015296
15297VOS_STATUS sme_roam_channel_change_req(tHalHandle hal, tCsrBssid bssid,
Abhishek Singh02b823e2017-10-30 17:53:20 +053015298 uint8_t new_chan, tCsrRoamProfile *profile,
15299 uint8_t sme_session_id)
Abhishek Singh550aa8c2017-10-30 17:34:53 +053015300{
15301 VOS_STATUS status;
15302 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15303 uint8_t cb_mode = 0;
Abhishek Singh02b823e2017-10-30 17:53:20 +053015304 tCsrRoamSession *session;
15305
15306 session = CSR_GET_SESSION(mac_ctx, sme_session_id);
15307
15308 if (!session) {
15309 smsLog(mac_ctx, LOGE, FL("session %d not found"), sme_session_id);
15310 return VOS_STATUS_E_FAILURE;
15311 }
Abhishek Singh550aa8c2017-10-30 17:34:53 +053015312
15313 status = sme_AcquireGlobalLock(&mac_ctx->sme);
15314 if (VOS_IS_STATUS_SUCCESS(status)) {
15315 if (CSR_IS_CHANNEL_5GHZ(new_chan)) {
Abhishek Singh02b823e2017-10-30 17:53:20 +053015316 sme_SelectCBMode(hal, profile->phyMode, new_chan,
15317 session->bssParams.orig_ch_width);
Abhishek Singh550aa8c2017-10-30 17:34:53 +053015318 cb_mode = mac_ctx->roam.configParam.channelBondingMode5GHz;
15319 }
15320 status = csr_roam_channel_change_req(mac_ctx, bssid, new_chan, cb_mode,
15321 profile);
15322 sme_ReleaseGlobalLock(&mac_ctx->sme);
15323 }
15324 return status;
15325}
15326
Abhishek Singh78c691f2017-11-30 13:48:44 +053015327v_TIME_t
15328sme_get_connect_strt_time(tHalHandle hal, uint8_t session_id)
15329{
15330 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15331 tCsrRoamSession *session;
15332
15333 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15334 smsLog(mac_ctx, LOGE, FL("session id %d not valid"), session_id);
15335 return vos_timer_get_system_time();
15336 }
15337 session = CSR_GET_SESSION(mac_ctx, session_id);
15338 return session->connect_req_start_time;
15339}
Yeshwanth Sriram Guntukab973f1c2018-03-29 19:35:49 +053015340
15341void sme_request_imps(tHalHandle hal)
15342{
15343 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15344
15345 csrScanStartIdleScan(mac_ctx);
15346}