blob: 2cf8fbb92381f319febe790c0abb517cd3ec7b93 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**=========================================================================
29
30 \file smeApi.c
31
32 \brief Definitions for SME APIs
33
34 ========================================================================*/
35
36/*--------------------------------------------------------------------------
37 Include Files
38 ------------------------------------------------------------------------*/
39
40#include "sms_debug.h"
41#include "sme_api.h"
42#include "csr_inside_api.h"
43#include "sme_inside.h"
44#include "csr_internal.h"
45#include "wma_types.h"
46#include "wma_if.h"
47#include "cdf_trace.h"
48#include "sme_trace.h"
49#include "cdf_types.h"
50#include "cdf_trace.h"
51#include "cds_utils.h"
52#include "sap_api.h"
53#include "mac_trace.h"
54#ifdef WLAN_FEATURE_NAN
55#include "nan_api.h"
56#endif
57#include "cds_regdomain_common.h"
58#include "cfg_api.h"
59#include "sme_power_save_api.h"
60#include "wma.h"
Naveen Rawatb4d37622015-11-13 16:15:25 -080061#include "sch_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062
63extern tSirRetStatus u_mac_post_ctrl_msg(void *pSirGlobal, tSirMbMsg *pMb);
64
65#define LOG_SIZE 256
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
67static tSelfRecoveryStats g_self_recovery_stats;
68/* TxMB Functions */
69extern CDF_STATUS pmc_prepare_command(tpAniSirGlobal pMac, uint32_t sessionId,
70 eSmeCommandType cmdType, void *pvParam,
71 uint32_t size, tSmeCmd **ppCmd);
72extern void pmc_release_command(tpAniSirGlobal pMac, tSmeCmd *pCommand);
73extern void qos_release_command(tpAniSirGlobal pMac, tSmeCmd *pCommand);
74extern CDF_STATUS p2p_process_remain_on_channel_cmd(tpAniSirGlobal pMac,
75 tSmeCmd *p2pRemainonChn);
76extern CDF_STATUS sme_remain_on_chn_rsp(tpAniSirGlobal pMac, uint8_t *pMsg);
77extern CDF_STATUS sme_mgmt_frm_ind(tHalHandle hHal,
78 tpSirSmeMgmtFrameInd pSmeMgmtFrm);
79extern CDF_STATUS sme_remain_on_chn_ready(tHalHandle hHal, uint8_t *pMsg);
80extern CDF_STATUS sme_send_action_cnf(tHalHandle hHal, uint8_t *pMsg);
81
82static CDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac);
83static void sme_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
84 bool fStopping);
85
86eCsrPhyMode sme_get_phy_mode(tHalHandle hHal);
87
88CDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac, void *pMsgBuf);
89
90void sme_disconnect_connected_sessions(tpAniSirGlobal pMac);
91
92CDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
93 void *pMsgBuf);
94
95CDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg);
96
97#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
98bool csr_is_supported_channel(tpAniSirGlobal pMac, uint8_t channelId);
99#endif
100
101#ifdef WLAN_FEATURE_11W
102CDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
103 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm);
104#endif
105
106/* Message processor for events from DFS */
107CDF_STATUS dfs_msg_processor(tpAniSirGlobal pMac,
108 uint16_t msg_type, void *pMsgBuf);
109
110/* Channel Change Response Indication Handler */
111CDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
112 uint16_t msg_type, void *pMsgBuf);
113
114/* Internal SME APIs */
115CDF_STATUS sme_acquire_global_lock(tSmeStruct *psSme)
116{
117 CDF_STATUS status = CDF_STATUS_E_INVAL;
118
119 if (psSme) {
120 if (CDF_IS_STATUS_SUCCESS
121 (cdf_mutex_acquire(&psSme->lkSmeGlobalLock))) {
122 status = CDF_STATUS_SUCCESS;
123 }
124 }
125
126 return status;
127}
128
129CDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
130{
131 CDF_STATUS status = CDF_STATUS_E_INVAL;
132
133 if (psSme) {
134 if (CDF_IS_STATUS_SUCCESS
135 (cdf_mutex_release(&psSme->lkSmeGlobalLock))) {
136 status = CDF_STATUS_SUCCESS;
137 }
138 }
139
140 return status;
141}
142
143/**
144 * sme_process_set_hw_mode_resp() - Process set HW mode response
145 * @mac: Global MAC pointer
146 * @msg: HW mode response
147 *
148 * Processes the HW mode response and invokes the HDD callback
149 * to process further
150 */
151static CDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
152{
153 tListElem *entry = NULL;
154 tSmeCmd *command = NULL;
155 bool found;
156 hw_mode_cb callback = NULL;
157 struct sir_set_hw_mode_resp *param;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530158 enum cds_conn_update_reason reason;
159 tSmeCmd *saved_cmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530161 sms_log(mac, LOG1, FL("%s"), __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162 param = (struct sir_set_hw_mode_resp *)msg;
163 if (!param) {
164 sms_log(mac, LOGE, FL("HW mode resp param is NULL"));
165 /* Not returning. Need to check if active command list
166 * needs to be freed
167 */
168 }
169
170 entry = csr_ll_peek_head(&mac->sme.smeCmdActiveList,
171 LL_ACCESS_LOCK);
172 if (!entry) {
173 sms_log(mac, LOGE, FL("No cmd found in active list"));
174 return CDF_STATUS_E_FAILURE;
175 }
176
177 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
178 if (!command) {
179 sms_log(mac, LOGE, FL("Base address is NULL"));
180 return CDF_STATUS_E_FAILURE;
181 }
182
183 if (e_sme_command_set_hw_mode != command->command) {
184 sms_log(mac, LOGE, FL("Command mismatch!"));
185 return CDF_STATUS_E_FAILURE;
186 }
187
188 callback = command->u.set_hw_mode_cmd.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530189 reason = command->u.set_hw_mode_cmd.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800190 if (callback) {
191 if (!param) {
192 sms_log(mac, LOGE,
193 FL("Callback failed since HW mode params is NULL"));
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530194 } else if (reason == CDS_UPDATE_REASON_HIDDEN_STA) {
195 /* In the case of hidden SSID, connection update
196 * (set hw mode) is done after the scan with reason
197 * code eCsrScanForSsid completes. The connect/failure
198 * needs to be handled after the response of set hw
199 * mode
200 */
201 saved_cmd = (tSmeCmd *)mac->sme.saved_scan_cmd;
202 if (!saved_cmd) {
203 sms_log(mac, LOGP,
204 FL("saved cmd is NULL, Check this"));
205 goto end;
206 }
207 if (param->status == SET_HW_MODE_STATUS_OK) {
208 sms_log(mac, LOG1,
209 FL("search for ssid success"));
210 csr_scan_handle_search_for_ssid(mac,
211 saved_cmd);
212 } else {
213 sms_log(mac, LOG1,
214 FL("search for ssid failure"));
215 csr_scan_handle_search_for_ssid_failure(mac,
216 saved_cmd);
217 }
218 if (saved_cmd->u.roamCmd.pRoamBssEntry)
219 cdf_mem_free(
220 saved_cmd->u.roamCmd.pRoamBssEntry);
221 if (saved_cmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList)
222 cdf_mem_free(saved_cmd->u.scanCmd.u.
223 scanRequest.SSIDs.SSIDList);
224 if (saved_cmd->u.scanCmd.pToRoamProfile)
225 cdf_mem_free(saved_cmd->u.scanCmd.
226 pToRoamProfile);
227 if (saved_cmd) {
228 cdf_mem_free(saved_cmd);
229 saved_cmd = NULL;
Chandrasekaran, Manishekar49d21a42015-11-19 09:57:58 +0530230 mac->sme.saved_scan_cmd = NULL;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530231 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232 } else {
233 sms_log(mac, LOGE,
234 FL("Calling HDD callback for HW mode response"));
235 callback(param->status,
236 param->cfgd_hw_mode_index,
237 param->num_vdev_mac_entries,
238 param->vdev_mac_map);
239 }
240 } else {
241 sms_log(mac, LOGE, FL("Callback does not exist"));
242 }
243
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530244end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 found = csr_ll_remove_entry(&mac->sme.smeCmdActiveList, entry,
246 LL_ACCESS_LOCK);
247 if (found) {
248 /* Now put this command back on the avilable command list */
249 sme_release_command(mac, command);
250 }
251 sme_process_pending_queue(mac);
252 return CDF_STATUS_SUCCESS;
253}
254
255/**
256 * sme_process_hw_mode_trans_ind() - Process HW mode transition indication
257 * @mac: Global MAC pointer
258 * @msg: HW mode transition response
259 *
260 * Processes the HW mode transition indication and invoke the HDD callback
261 * to process further
262 */
263static CDF_STATUS sme_process_hw_mode_trans_ind(tpAniSirGlobal mac,
264 uint8_t *msg)
265{
266 hw_mode_transition_cb callback = NULL;
267 struct sir_hw_mode_trans_ind *param;
268
269 param = (struct sir_hw_mode_trans_ind *)msg;
270 if (!param) {
271 sms_log(mac, LOGE, FL("HW mode trans ind param is NULL"));
272 return CDF_STATUS_E_FAILURE;
273 }
274
275 callback = mac->sme.sme_hw_mode_trans_cb;
276 if (callback) {
277 sms_log(mac, LOGE, FL("Calling registered callback..."));
278 callback(param->old_hw_mode_index,
279 param->new_hw_mode_index,
280 param->num_vdev_mac_entries,
281 param->vdev_mac_map);
282 }
283
284 return CDF_STATUS_SUCCESS;
285}
286
Naveen Rawate7d86052015-11-13 12:01:43 -0800287/**
288 * free_sme_cmds() - This function frees memory allocated for SME commands
289 * @mac_ctx: Pointer to Global MAC structure
290 *
291 * This function frees memory allocated for SME commands
292 *
293 * @Return: void
294 */
295static void free_sme_cmds(tpAniSirGlobal mac_ctx)
296{
297 uint32_t idx;
298 if (NULL == mac_ctx->sme.pSmeCmdBufAddr)
299 return;
300
301 for (idx = 0; idx < mac_ctx->sme.totalSmeCmd; idx++)
302 cdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr[idx]);
303
304 cdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr);
305 mac_ctx->sme.pSmeCmdBufAddr = NULL;
306}
307
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308static CDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
309{
310 CDF_STATUS status;
311 tSmeCmd *pCmd;
312 uint32_t cmd_idx;
313 CDF_STATUS cdf_status;
314 cdf_mc_timer_t *cmdTimeoutTimer = NULL;
Naveen Rawate7d86052015-11-13 12:01:43 -0800315 uint32_t sme_cmd_ptr_ary_sz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316
317 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
318
319 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdActiveList);
320 if (!CDF_IS_STATUS_SUCCESS(status))
321 goto end;
322
323 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdPendingList);
324 if (!CDF_IS_STATUS_SUCCESS(status))
325 goto end;
326
327 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeScanCmdActiveList);
328 if (!CDF_IS_STATUS_SUCCESS(status))
329 goto end;
330
331 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeScanCmdPendingList);
332 if (!CDF_IS_STATUS_SUCCESS(status))
333 goto end;
334
335 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdFreeList);
336 if (!CDF_IS_STATUS_SUCCESS(status))
337 goto end;
338
Naveen Rawate7d86052015-11-13 12:01:43 -0800339 /* following pointer contains array of pointers for tSmeCmd* */
340 sme_cmd_ptr_ary_sz = sizeof(void *) * pMac->sme.totalSmeCmd;
341 pMac->sme.pSmeCmdBufAddr = cdf_mem_malloc(sme_cmd_ptr_ary_sz);
342 if (NULL == pMac->sme.pSmeCmdBufAddr) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343 status = CDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800344 goto end;
345 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346
Naveen Rawate7d86052015-11-13 12:01:43 -0800347 status = CDF_STATUS_SUCCESS;
348 cdf_mem_set(pMac->sme.pSmeCmdBufAddr, sme_cmd_ptr_ary_sz, 0);
349 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++) {
350 /*
351 * Since total size of all commands together can be huge chunk
352 * of memory, allocate SME cmd individually. These SME CMDs are
353 * moved between pending and active queues. And these freeing of
354 * these queues just manipulates the list but does not actually
355 * frees SME CMD pointers. Hence store each SME CMD address in
356 * the array, sme.pSmeCmdBufAddr. This will later facilitate
357 * freeing up of all SME CMDs with just a for loop.
358 */
359 pMac->sme.pSmeCmdBufAddr[cmd_idx] =
360 cdf_mem_malloc(sizeof(tSmeCmd));
361 if (NULL == pMac->sme.pSmeCmdBufAddr[cmd_idx]) {
362 status = CDF_STATUS_E_NOMEM;
363 free_sme_cmds(pMac);
364 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 }
Naveen Rawate7d86052015-11-13 12:01:43 -0800366 pCmd = (tSmeCmd *)pMac->sme.pSmeCmdBufAddr[cmd_idx];
367 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList,
368 &pCmd->Link, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 }
370
371 /* This timer is only to debug the active list command timeout */
372
373 cmdTimeoutTimer =
374 (cdf_mc_timer_t *) cdf_mem_malloc(sizeof(cdf_mc_timer_t));
375 if (cmdTimeoutTimer) {
376 pMac->sme.smeCmdActiveList.cmdTimeoutTimer = cmdTimeoutTimer;
377 cdf_status =
378 cdf_mc_timer_init(pMac->sme.smeCmdActiveList.
379 cmdTimeoutTimer, CDF_TIMER_TYPE_SW,
380 active_list_cmd_timeout_handle, (void *)pMac);
381
382 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
383 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
384 "Init Timer fail for active list command process time out");
385 cdf_mem_free(pMac->sme.smeCmdActiveList.
386 cmdTimeoutTimer);
387 pMac->sme.smeCmdActiveList.cmdTimeoutTimer = NULL;
388 } else {
389 pMac->sme.smeCmdActiveList.cmdTimeoutDuration =
390 CSR_ACTIVE_LIST_CMD_TIMEOUT_VALUE;
391 }
392 }
393
394end:
395 if (!CDF_IS_STATUS_SUCCESS(status))
396 sms_log(pMac, LOGE, "failed to initialize sme command list:%d\n",
397 status);
398
399 return status;
400}
401
402void sme_release_command(tpAniSirGlobal pMac, tSmeCmd *pCmd)
403{
404 pCmd->command = eSmeNoCommand;
405 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList, &pCmd->Link, LL_ACCESS_LOCK);
406}
407
408static void sme_release_cmd_list(tpAniSirGlobal pMac, tDblLinkList *pList)
409{
410 tListElem *pEntry;
411 tSmeCmd *pCommand;
412
413 while ((pEntry = csr_ll_remove_head(pList, LL_ACCESS_LOCK)) != NULL) {
414 /* TODO: base on command type to call release functions */
415 /* reinitialize different command types so they can be reused */
416 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
417 sme_abort_command(pMac, pCommand, true);
418 }
419}
420
421static void purge_sme_cmd_list(tpAniSirGlobal pMac)
422{
423 /* release any out standing commands back to free command list */
424 sme_release_cmd_list(pMac, &pMac->sme.smeCmdPendingList);
425 sme_release_cmd_list(pMac, &pMac->sme.smeCmdActiveList);
426 sme_release_cmd_list(pMac, &pMac->sme.smeScanCmdPendingList);
427 sme_release_cmd_list(pMac, &pMac->sme.smeScanCmdActiveList);
428}
429
430void purge_sme_session_cmd_list(tpAniSirGlobal pMac, uint32_t sessionId,
431 tDblLinkList *pList)
432{
433 /* release any out standing commands back to free command list */
434 tListElem *pEntry, *pNext;
435 tSmeCmd *pCommand;
436 tDblLinkList localList;
437
438 cdf_mem_zero(&localList, sizeof(tDblLinkList));
439 if (!CDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) {
440 sms_log(pMac, LOGE, FL(" failed to open list"));
441 return;
442 }
443
444 csr_ll_lock(pList);
445 pEntry = csr_ll_peek_head(pList, LL_ACCESS_NOLOCK);
446 while (pEntry != NULL) {
447 pNext = csr_ll_next(pList, pEntry, LL_ACCESS_NOLOCK);
448 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
449 if (pCommand->sessionId == sessionId) {
450 if (csr_ll_remove_entry(pList, pEntry, LL_ACCESS_NOLOCK)) {
451 csr_ll_insert_tail(&localList, pEntry,
452 LL_ACCESS_NOLOCK);
453 }
454 }
455 pEntry = pNext;
456 }
457 csr_ll_unlock(pList);
458
459 while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) {
460 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
461 sme_abort_command(pMac, pCommand, true);
462 }
463 csr_ll_close(&localList);
464}
465
466static CDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
467{
468 CDF_STATUS status = CDF_STATUS_SUCCESS;
469
470 purge_sme_cmd_list(pMac);
471 csr_ll_close(&pMac->sme.smeCmdPendingList);
472 csr_ll_close(&pMac->sme.smeCmdActiveList);
473 csr_ll_close(&pMac->sme.smeScanCmdPendingList);
474 csr_ll_close(&pMac->sme.smeScanCmdActiveList);
475 csr_ll_close(&pMac->sme.smeCmdFreeList);
476
477 /*destroy active list command time out timer */
478 cdf_mc_timer_destroy(pMac->sme.smeCmdActiveList.cmdTimeoutTimer);
479 cdf_mem_free(pMac->sme.smeCmdActiveList.cmdTimeoutTimer);
480 pMac->sme.smeCmdActiveList.cmdTimeoutTimer = NULL;
481
482 status = cdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
483 if (status != CDF_STATUS_SUCCESS) {
484 sms_log(pMac, LOGE,
485 FL("Failed to acquire the lock status = %d"), status);
486 goto done;
487 }
488
Naveen Rawate7d86052015-11-13 12:01:43 -0800489 free_sme_cmds(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490
491 status = cdf_mutex_release(&pMac->sme.lkSmeGlobalLock);
492 if (status != CDF_STATUS_SUCCESS) {
493 sms_log(pMac, LOGE,
494 FL("Failed to release the lock status = %d"), status);
495 }
496done:
497 return status;
498}
499
500void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
501{
502 switch (pCmd->command) {
503 case eSmeCommandScan:
504 sms_log(pMac, LOGE, " scan command reason is %d",
505 pCmd->u.scanCmd.reason);
506 break;
507
508 case eSmeCommandRoam:
509 sms_log(pMac, LOGE, " roam command reason is %d",
510 pCmd->u.roamCmd.roamReason);
511 break;
512
513 case eSmeCommandWmStatusChange:
514 sms_log(pMac, LOGE, " WMStatusChange command type is %d",
515 pCmd->u.wmStatusChangeCmd.Type);
516 break;
517
518 case eSmeCommandSetKey:
519 sms_log(pMac, LOGE, " setKey command auth(%d) enc(%d)",
520 pCmd->u.setKeyCmd.authType, pCmd->u.setKeyCmd.encType);
521 break;
522
523 default:
524 sms_log(pMac, LOGE, " default: Unhandled command %d",
525 pCmd->command);
526 break;
527 }
528}
529
530tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
531{
532 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
533 tListElem *pEntry;
534 static int sme_command_queue_full;
535
536 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
537
538 /* If we can get another MS Msg buffer, then we are ok. Just link */
539 /* the entry onto the linked list. (We are using the linked list */
540 /* to keep track of tfhe message buffers). */
541 if (pEntry) {
542 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
543 /* reset when free list is available */
544 sme_command_queue_full = 0;
545 } else {
546 int idx = 1;
547
548 /* Cannot change pRetCmd here since it needs to return later. */
549 pEntry =
550 csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
551 if (pEntry) {
552 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
553 }
554 sms_log(pMac, LOGE,
555 "Out of command buffer.... command (0x%X) stuck",
556 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
557 if (pTempCmd) {
558 if (eSmeCsrCommandMask & pTempCmd->command) {
559 /* CSR command is stuck. See what the reason code is for that command */
560 dump_csr_command_info(pMac, pTempCmd);
561 }
562 } /* if(pTempCmd) */
563
564 /* dump what is in the pending queue */
565 csr_ll_lock(&pMac->sme.smeCmdPendingList);
566 pEntry =
567 csr_ll_peek_head(&pMac->sme.smeCmdPendingList,
568 LL_ACCESS_NOLOCK);
569 while (pEntry && !sme_command_queue_full) {
570 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
571 /* Print only 1st five commands from pending queue. */
572 if (idx <= 5)
573 sms_log(pMac, LOGE,
574 "Out of command buffer.... SME pending command #%d (0x%X)",
575 idx, pTempCmd->command);
576 idx++;
577 if (eSmeCsrCommandMask & pTempCmd->command) {
578 /* CSR command is stuck. See what the reason code is for that command */
579 dump_csr_command_info(pMac, pTempCmd);
580 }
581 pEntry =
582 csr_ll_next(&pMac->sme.smeCmdPendingList, pEntry,
583 LL_ACCESS_NOLOCK);
584 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 csr_ll_unlock(&pMac->sme.smeCmdPendingList);
586
DARAM SUDHAf6c3f972015-05-26 19:26:16 +0530587 idx = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588 /* There may be some more command in CSR's own pending queue */
589 csr_ll_lock(&pMac->roam.roamCmdPendingList);
590 pEntry =
591 csr_ll_peek_head(&pMac->roam.roamCmdPendingList,
592 LL_ACCESS_NOLOCK);
DARAM SUDHAf6c3f972015-05-26 19:26:16 +0530593 while (pEntry && !sme_command_queue_full) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
DARAM SUDHAf6c3f972015-05-26 19:26:16 +0530595 /* Print only 1st five commands from CSR pending queue */
596 if (idx <= 5)
597 sms_log(pMac, LOGE,
598 "Out of command buffer.... "
599 "CSR roamCmdPendingList command #%d (0x%X)",
600 idx, pTempCmd->command);
601 idx++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800602 dump_csr_command_info(pMac, pTempCmd);
603 pEntry =
604 csr_ll_next(&pMac->roam.roamCmdPendingList, pEntry,
605 LL_ACCESS_NOLOCK);
606 }
DARAM SUDHAf6c3f972015-05-26 19:26:16 +0530607
608 /* Increment static variable so that it prints
609 * pending command only once
610 */
611 sme_command_queue_full++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 csr_ll_unlock(&pMac->roam.roamCmdPendingList);
DARAM SUDHAf6c3f972015-05-26 19:26:16 +0530613
614 /* panic with out-of-command */
615 CDF_BUG(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616 }
617
618 /* memset to zero */
619 if (pRetCmd) {
620 cdf_mem_set((uint8_t *)&pRetCmd->command,
621 sizeof(pRetCmd->command), 0);
622 cdf_mem_set((uint8_t *)&pRetCmd->sessionId,
623 sizeof(pRetCmd->sessionId), 0);
624 cdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
625 }
626
627 return pRetCmd;
628}
629
630void sme_push_command(tpAniSirGlobal pMac, tSmeCmd *pCmd, bool fHighPriority)
631{
632 if (!SME_IS_START(pMac)) {
633 sms_log(pMac, LOGE, FL("Sme in stop state"));
634 CDF_ASSERT(0);
635 return;
636 }
637
638 if (fHighPriority) {
639 csr_ll_insert_head(&pMac->sme.smeCmdPendingList, &pCmd->Link,
640 LL_ACCESS_LOCK);
641 } else {
642 csr_ll_insert_tail(&pMac->sme.smeCmdPendingList, &pCmd->Link,
643 LL_ACCESS_LOCK);
644 }
645
646 /* process the command queue... */
647 sme_process_pending_queue(pMac);
648
649 return;
650}
651
652/* For commands that need to do extra cleanup. */
653static void sme_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
654 bool fStopping)
655{
656 if (eSmePmcCommandMask & pCommand->command) {
657 sms_log(pMac, LOG1,
658 "No need to process PMC commands");
659 return;
660 }
661 if (eSmeCsrCommandMask & pCommand->command) {
662 csr_abort_command(pMac, pCommand, fStopping);
663 return;
664 }
665 switch (pCommand->command) {
666 case eSmeCommandRemainOnChannel:
667 if (NULL != pCommand->u.remainChlCmd.callback) {
668 remainOnChanCallback callback =
669 pCommand->u.remainChlCmd.callback;
670 /* process the msg */
671 if (callback) {
672 callback(pMac, pCommand->u.remainChlCmd.
673 callbackCtx, eCSR_SCAN_ABORT,
674 pCommand->u.remainChlCmd.scan_id);
675 }
676 }
677 sme_release_command(pMac, pCommand);
678 break;
679 default:
680 sme_release_command(pMac, pCommand);
681 break;
682 }
683
684}
685
686tListElem *csr_get_cmd_to_process(tpAniSirGlobal pMac, tDblLinkList *pList,
687 uint8_t sessionId, bool fInterlocked)
688{
689 tListElem *pCurEntry = NULL;
690 tSmeCmd *pCommand;
691
692 /* Go through the list and return the command whose session id is not
693 * matching with the current ongoing scan cmd sessionId */
694 pCurEntry = csr_ll_peek_head(pList, LL_ACCESS_LOCK);
695 while (pCurEntry) {
696 pCommand = GET_BASE_ADDR(pCurEntry, tSmeCmd, Link);
697 if (pCommand->sessionId != sessionId) {
698 sms_log(pMac, LOG1,
699 "selected the command with different sessionId");
700 return pCurEntry;
701 }
702
703 pCurEntry = csr_ll_next(pList, pCurEntry, fInterlocked);
704 }
705
706 sms_log(pMac, LOG1, "No command pending with different sessionId");
707 return NULL;
708}
709
710bool sme_process_scan_queue(tpAniSirGlobal pMac)
711{
712 tListElem *pEntry;
713 tSmeCmd *pCommand;
714 tListElem *pSmeEntry = NULL;
715 tSmeCmd *pSmeCommand = NULL;
716 bool status = true;
717
718 if ((!csr_ll_is_list_empty(&pMac->sme.smeCmdActiveList,
719 LL_ACCESS_LOCK))) {
720 pSmeEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList,
721 LL_ACCESS_LOCK);
722 if (pSmeEntry)
723 pSmeCommand = GET_BASE_ADDR(pSmeEntry, tSmeCmd, Link);
724 }
725 csr_ll_lock(&pMac->sme.smeScanCmdActiveList);
726 if (csr_ll_is_list_empty(&pMac->sme.smeScanCmdPendingList,
727 LL_ACCESS_LOCK))
728 goto end;
729 pEntry = csr_ll_peek_head(&pMac->sme.smeScanCmdPendingList,
730 LL_ACCESS_LOCK);
731 if (!pEntry)
732 goto end;
733
734 sms_log(pMac, LOGE,
735 FL("scan_count in active scanlist %d "),
736 pMac->sme.smeScanCmdActiveList.Count);
737
738 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
739 if (pSmeCommand != NULL) {
740 /*
741 * if scan is running on one interface and SME receives
742 * the next command on the same interface then
743 * dont the allow the command to be queued to
744 * smeCmdPendingList. If next scan is allowed on
745 * the same interface the CSR state machine will
746 * get screwed up.
747 */
748 if (pSmeCommand->sessionId == pCommand->sessionId) {
749 status = false;
750 goto end;
751 }
752 }
753 /*
754 * We cannot execute any command in wait-for-key state until setKey is
755 * through.
756 */
757 if (CSR_IS_WAIT_FOR_KEY(pMac, pCommand->sessionId)) {
758 if (!CSR_IS_SET_KEY_COMMAND(pCommand)) {
759 sms_log(pMac, LOGE,
760 FL("Can't process cmd(%d), waiting for key"),
761 pCommand->command);
762 status = false;
763 goto end;
764 }
765 }
766 if (csr_ll_remove_entry(&pMac->sme.smeScanCmdPendingList, pEntry,
767 LL_ACCESS_LOCK)) {
768 csr_ll_insert_head(&pMac->sme.smeScanCmdActiveList,
769 &pCommand->Link, LL_ACCESS_NOLOCK);
770 switch (pCommand->command) {
771 case eSmeCommandScan:
772 sms_log(pMac, LOG1, FL("Processing scan offload cmd."));
773 cdf_mc_timer_start(&pCommand->u.scanCmd.csr_scan_timer,
774 CSR_ACTIVE_SCAN_LIST_CMD_TIMEOUT);
775 csr_process_scan_command(pMac, pCommand);
776 break;
777 case eSmeCommandRemainOnChannel:
778 sms_log(pMac, LOG1,
779 FL("Processing remain on channel offload cmd"));
780 p2p_process_remain_on_channel_cmd(pMac, pCommand);
781 break;
782 default:
783 sms_log(pMac, LOGE,
784 FL("Wrong cmd enqueued to ScanCmdPendingList"));
785 pEntry = csr_ll_remove_head(
786 &pMac->sme.smeScanCmdActiveList,
787 LL_ACCESS_NOLOCK);
788 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
789 sme_release_command(pMac, pCommand);
790 break;
791 }
792 }
793end:
794 csr_ll_unlock(&pMac->sme.smeScanCmdActiveList);
795 return status;
796}
797
798/**
799 * sme_process_command() - processes SME commnd
800 * @mac_ctx: mac global context
801 *
802 * This function is called by sme_process_pending_queue() in a while loop
803 *
804 * Return: true indicates that caller function can proceed to next cmd
805 * false otherwise.
806 */
807bool sme_process_command(tpAniSirGlobal pMac)
808{
809 bool fContinue = false;
810 CDF_STATUS status = CDF_STATUS_SUCCESS;
811 tListElem *pEntry;
812 tSmeCmd *pCommand;
813 tListElem *pSmeEntry;
814 tSmeCmd *pSmeCommand;
815
816 /*
817 * if the ActiveList is empty, then nothing is active so we can process
818 * a pending command...
819 * alwasy lock active list before locking pending list
820 */
821 csr_ll_lock(&pMac->sme.smeCmdActiveList);
822 if (!csr_ll_is_list_empty(&pMac->sme.smeCmdActiveList,
823 LL_ACCESS_NOLOCK)) {
824 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
825 goto process_scan_q;
826 }
827
828 if (csr_ll_is_list_empty(&pMac->sme.smeCmdPendingList,
829 LL_ACCESS_LOCK)) {
830 /* No command waiting */
831 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
832 goto process_scan_q;
833 }
834
835 /*
836 * If scan command is pending in the smeScanCmdActive list then pick the
837 * command from smeCmdPendingList which is not matching with the scan
838 * command session id. At any point of time only one command will be
839 * allowed on a single session.
840 */
841 if (!csr_ll_is_list_empty(
842 &pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK)) {
843 pSmeEntry = csr_ll_peek_head(&pMac->sme.smeScanCmdActiveList,
844 LL_ACCESS_LOCK);
845 if (pSmeEntry) {
846 pSmeCommand = GET_BASE_ADDR(pSmeEntry, tSmeCmd, Link);
847 pEntry = csr_get_cmd_to_process(pMac,
848 &pMac->sme.smeCmdPendingList,
849 pSmeCommand->sessionId,
850 LL_ACCESS_LOCK);
851 goto sme_process_cmd;
852 }
853 }
854
855 /* Peek the command */
856 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
857sme_process_cmd:
858 if (!pEntry) {
859 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
860 goto process_scan_q;
861 }
862 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
863 /*
864 * Allow only disconnect command in wait-for-key state until setKey is
865 * through.
866 */
867 if (CSR_IS_WAIT_FOR_KEY(pMac, pCommand->sessionId)
868 && !CSR_IS_DISCONNECT_COMMAND(pCommand)
869 && !CSR_IS_SET_KEY_COMMAND(pCommand)) {
870 if (CSR_IS_CLOSE_SESSION_COMMAND(pCommand)) {
871 tSmeCmd *sme_cmd = NULL;
872
873 sms_log(pMac, LOGE,
874 FL("SessionId %d: close session command issued while waiting for key, issue disconnect first"),
875 pCommand->sessionId);
876 status = csr_prepare_disconnect_command(pMac,
877 pCommand->sessionId, &sme_cmd);
878 if (status == CDF_STATUS_SUCCESS && sme_cmd) {
879 csr_ll_lock(&pMac->sme.smeCmdPendingList);
880 csr_ll_insert_head(&pMac->sme.smeCmdPendingList,
881 &sme_cmd->Link, LL_ACCESS_NOLOCK);
882 pEntry = csr_ll_peek_head(
883 &pMac->sme.smeCmdPendingList,
884 LL_ACCESS_NOLOCK);
885 csr_ll_unlock(&pMac->sme.smeCmdPendingList);
886 goto sme_process_cmd;
887 }
888 }
889
890 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
891 sms_log(pMac, LOGE,
892 FL("SessionId %d: Can't process cmd(%d), waiting for key"),
893 pCommand->sessionId, pCommand->command);
894 fContinue = false;
895 goto process_scan_q;
896 }
897
898 if (!csr_ll_remove_entry(&pMac->sme.smeCmdPendingList, pEntry,
899 LL_ACCESS_LOCK)) {
900 /* This is odd. Some one else pull off the command. */
901 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
902 goto process_scan_q;
903 }
904 /* we can reuse the pCommand. Insert the command onto the ActiveList */
905 csr_ll_insert_head(&pMac->sme.smeCmdActiveList, &pCommand->Link,
906 LL_ACCESS_NOLOCK);
907 /* .... and process the command. */
908 MTRACE(cdf_trace(CDF_MODULE_ID_SME, TRACE_CODE_SME_COMMAND,
909 pCommand->sessionId, pCommand->command));
910
911 switch (pCommand->command) {
912 case eSmeCommandScan:
913 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
914 status = csr_process_scan_command(pMac, pCommand);
915 break;
916 case eSmeCommandRoam:
917 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
918 status = csr_roam_process_command(pMac, pCommand);
919 if (!CDF_IS_STATUS_SUCCESS(status)
920 && csr_ll_remove_entry(&pMac->sme.smeCmdActiveList,
921 &pCommand->Link, LL_ACCESS_LOCK))
922 csr_release_command_roam(pMac, pCommand);
923 break;
924 case eSmeCommandWmStatusChange:
925 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
926 csr_roam_process_wm_status_change_command(pMac, pCommand);
927 break;
928 case eSmeCommandSetKey:
929 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
930 status = csr_roam_process_set_key_command(pMac, pCommand);
931 if (!CDF_IS_STATUS_SUCCESS(status)
932 && csr_ll_remove_entry(&pMac->sme.smeCmdActiveList,
933 &pCommand->Link, LL_ACCESS_LOCK)) {
934 csr_release_command_set_key(pMac, pCommand);
935 }
936 break;
937 case eSmeCommandAddStaSession:
938 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
939 csr_process_add_sta_session_command(pMac, pCommand);
940 break;
941 case eSmeCommandDelStaSession:
942 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
943 csr_process_del_sta_session_command(pMac, pCommand);
944 break;
945#ifdef FEATURE_OEM_DATA_SUPPORT
946 case eSmeCommandOemDataReq:
947 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
948 oem_data_process_oem_data_req_command(pMac, pCommand);
949 break;
950#endif
951 case eSmeCommandRemainOnChannel:
952 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
953 p2p_process_remain_on_channel_cmd(pMac, pCommand);
954 break;
955 /*
956 * Treat standby differently here because caller may not be able
957 * to handle the failure so we do our best here
958 */
959 case eSmeCommandEnterStandby:
960 break;
961 case eSmeCommandAddTs:
962 case eSmeCommandDelTs:
963 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
964#ifndef WLAN_MDM_CODE_REDUCTION_OPT
965 fContinue = qos_process_command(pMac, pCommand);
966 if (fContinue && csr_ll_remove_entry(
967 &pMac->sme.smeCmdActiveList,
968 &pCommand->Link, LL_ACCESS_NOLOCK)) {
969 /* The command failed, remove it */
970 qos_release_command(pMac, pCommand);
971 }
972#endif
973 break;
974#ifdef FEATURE_WLAN_TDLS
975 case eSmeCommandTdlsSendMgmt:
976 case eSmeCommandTdlsAddPeer:
977 case eSmeCommandTdlsDelPeer:
978 case eSmeCommandTdlsLinkEstablish:
979 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
980 FL("sending TDLS Command 0x%x to PE"),
981 pCommand->command);
982 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
983 status = csr_tdls_process_cmd(pMac, pCommand);
984 break;
985#endif
986 case e_sme_command_set_hw_mode:
987 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
988 csr_process_set_hw_mode(pMac, pCommand);
989 break;
990 case e_sme_command_nss_update:
991 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
992 csr_process_nss_update_req(pMac, pCommand);
993 break;
994 case e_sme_command_set_dual_mac_config:
995 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
996 csr_process_set_dual_mac_config(pMac, pCommand);
997 break;
998 default:
999 /* something is wrong */
1000 /* remove it from the active list */
1001 sms_log(pMac, LOGE, FL("unknown command %d"),
1002 pCommand->command);
1003 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdActiveList,
1004 LL_ACCESS_NOLOCK);
1005 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
1006 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
1007 sme_release_command(pMac, pCommand);
1008 status = CDF_STATUS_E_FAILURE;
1009 break;
1010 }
1011 if (!CDF_IS_STATUS_SUCCESS(status))
1012 fContinue = true;
1013process_scan_q:
1014 if (!(sme_process_scan_queue(pMac)))
1015 fContinue = false;
1016 return fContinue;
1017}
1018
1019void sme_process_pending_queue(tpAniSirGlobal pMac)
1020{
1021 while (sme_process_command(pMac))
1022 ;
1023}
1024
1025bool sme_command_pending(tpAniSirGlobal pMac)
1026{
1027 return !csr_ll_is_list_empty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK)
1028 || !csr_ll_is_list_empty(&pMac->sme.smeCmdPendingList,
1029 LL_ACCESS_NOLOCK);
1030}
1031
1032/* Global APIs */
1033
1034/**
1035 * sme_open() - Initialze all SME modules and put them at idle state
1036 * @hHal: The handle returned by mac_open
1037 *
1038 * The function initializes each module inside SME, PMC, CSR, etc. Upon
1039 * successfully return, all modules are at idle state ready to start.
1040 * smeOpen must be called before any other SME APIs can be involved.
1041 * smeOpen must be called after mac_open.
1042 *
1043 * Return: CDF_STATUS_SUCCESS - SME is successfully initialized.
1044 * Other status means SME is failed to be initialized
1045 */
1046CDF_STATUS sme_open(tHalHandle hHal)
1047{
1048 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1049 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1050#ifndef WLAN_FEATURE_MBSSID
1051 void *p_cds_gctx = cds_get_global_context();
1052#endif
1053
1054 pMac->sme.state = SME_STATE_STOP;
1055 pMac->sme.currDeviceMode = CDF_STA_MODE;
1056 if (!CDF_IS_STATUS_SUCCESS(cdf_mutex_init(
1057 &pMac->sme.lkSmeGlobalLock))) {
1058 sms_log(pMac, LOGE, FL("sme_open failed init lock"));
1059 return CDF_STATUS_E_FAILURE;
1060 }
1061 status = csr_open(pMac);
1062 if (!CDF_IS_STATUS_SUCCESS(status)) {
1063 sms_log(pMac, LOGE, FL("csr_open failed, status=%d"), status);
1064 return status;
1065 }
1066
1067 status = sme_ps_open(hHal);
1068 if (!CDF_IS_STATUS_SUCCESS(status)) {
1069 sms_log(pMac, LOGE,
1070 FL("sme_ps_open failed during initialization with status=%d"),
1071 status);
1072 return status;
1073 }
1074#ifdef FEATURE_WLAN_TDLS
1075 pMac->is_tdls_power_save_prohibited = 0;
1076#endif
1077
1078#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1079 status = sme_qos_open(pMac);
1080 if (!CDF_IS_STATUS_SUCCESS(status)) {
1081 sms_log(pMac, LOGE, FL("Qos open, status=%d"), status);
1082 return status;
1083 }
1084#endif
1085#ifdef FEATURE_OEM_DATA_SUPPORT
1086 status = oem_data_oem_data_req_open(pMac);
1087 if (!CDF_IS_STATUS_SUCCESS(status)) {
1088 sms_log(pMac, LOGE,
1089 FL("oem_data_oem_data_req_open, status=%d"),
1090 status);
1091 return status;
1092 }
1093#endif
1094 status = init_sme_cmd_list(pMac);
1095 if (!CDF_IS_STATUS_SUCCESS(status))
1096 return status;
1097#ifndef WLAN_FEATURE_MBSSID
1098 if (NULL == p_cds_gctx) {
1099 sms_log(pMac, LOGE, FL("p_cds_gctx is NULL"));
1100 return CDF_STATUS_E_FAILURE;
1101 }
1102 status = wlansap_open(p_cds_gctx);
1103 if (!CDF_IS_STATUS_SUCCESS(status)) {
1104 sms_log(pMac, LOGE, FL("wlansap_open failed, status=%d"),
1105 status);
1106 return status;
1107 }
1108#endif
1109
1110#if defined WLAN_FEATURE_VOWIFI
1111 status = rrm_open(pMac);
1112 if (!CDF_IS_STATUS_SUCCESS(status)) {
1113 sms_log(pMac, LOGE, FL("rrm_open failed, status=%d"), status);
1114 return status;
1115 }
1116#endif
1117 sme_p2p_open(pMac);
1118 sme_trace_init(pMac);
1119 return status;
1120}
1121
1122/*
1123 * sme_init_chan_list, triggers channel setup based on country code.
1124 */
1125CDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
1126 COUNTRY_CODE_SOURCE cc_src)
1127{
1128 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
1129
1130 if ((cc_src == COUNTRY_CODE_SET_BY_USER) &&
1131 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
1132 pmac->roam.configParam.Is11dSupportEnabled = false;
1133 }
1134
1135 return csr_init_chan_list(pmac, alpha2);
1136}
1137
1138/*--------------------------------------------------------------------------
1139
1140 \brief sme_set11dinfo() - Set the 11d information about valid channels
1141 and there power using information from nvRAM
1142 This function is called only for AP.
1143
1144 This is a synchronous call
1145
1146 \param hHal - The handle returned by mac_open.
1147 \Param pSmeConfigParams - a pointer to a caller allocated object of
1148 typedef struct _smeConfigParams.
1149
1150 \return CDF_STATUS_SUCCESS - SME update the config parameters successfully.
1151
1152 Other status means SME is failed to update the config parameters.
1153 \sa
1154 --------------------------------------------------------------------------*/
1155
1156CDF_STATUS sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1157{
1158 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1159 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1160
1161 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
1162 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
1163 if (NULL == pSmeConfigParams) {
1164 sms_log(pMac, LOGE,
1165 "Empty config param structure for SME, nothing to update");
1166 return status;
1167 }
1168
1169 status = csr_set_channels(hHal, &pSmeConfigParams->csrConfig);
1170 if (!CDF_IS_STATUS_SUCCESS(status)) {
1171 sms_log(pMac, LOGE,
1172 "csr_change_default_config_param failed with status=%d",
1173 status);
1174 }
1175 return status;
1176}
1177
1178/**
1179 * sme_set_scan_disable() - Dynamically enable/disable scan
1180 * @h_hal: Handle to HAL
1181 *
1182 * This command gives the user an option to dynamically
1183 * enable or disable scans.
1184 *
1185 * Return: None
1186 */
1187void sme_set_scan_disable(tHalHandle h_hal, int value)
1188{
1189 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
1190 mac_ctx->lim.scan_disabled = value;
1191 sms_log(mac_ctx, LOG1, FL("value=%d"), value);
1192}
1193/*--------------------------------------------------------------------------
1194
1195 \brief sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
1196
1197 This is a synchronous call
1198
1199 \param hHal - The handle returned by HostapdAdapter.
1200 \Param v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
1201
1202 \return CDF_STATUS_SUCCESS - SME successfully completed the request.
1203
1204 Other status means, failed to get the current regulatory domain.
1205 \sa
1206 --------------------------------------------------------------------------*/
1207
1208CDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t *domainIdSoftAp)
1209{
1210 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1211 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1212
1213 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
1214 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
1215 NO_SESSION, 0));
1216 if (NULL == domainIdSoftAp) {
1217 sms_log(pMac, LOGE, "Uninitialized domain Id");
1218 return status;
1219 }
1220
1221 *domainIdSoftAp = pMac->scan.domainIdCurrent;
1222 status = CDF_STATUS_SUCCESS;
1223
1224 return status;
1225}
1226
1227CDF_STATUS sme_set_reg_info(tHalHandle hHal, uint8_t *apCntryCode)
1228{
1229 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1230 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1231
1232 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
1233 TRACE_CODE_SME_RX_HDD_MSG_SET_REGINFO, NO_SESSION, 0));
1234 if (NULL == apCntryCode) {
1235 sms_log(pMac, LOGE, "Empty Country Code, nothing to update");
1236 return status;
1237 }
1238
1239 status = csr_set_reg_info(hHal, apCntryCode);
1240 if (!CDF_IS_STATUS_SUCCESS(status)) {
1241 sms_log(pMac, LOGE, "csr_set_reg_info failed with status=%d",
1242 status);
1243 }
1244 return status;
1245}
1246
1247#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1248CDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1249{
1250 CDF_STATUS status;
1251 bool ret = false;
1252 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1253 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST] = { 0 };
1254 uint8_t count, valid_count = 0;
1255 cds_msg_t msg;
1256 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, pPlmReq->sessionId);
1257
1258 status = sme_acquire_global_lock(&pMac->sme);
1259 if (!CDF_IS_STATUS_SUCCESS(status))
1260 return status;
1261
1262 if (!pSession) {
1263 sms_log(pMac, LOGE, FL("session %d not found"),
1264 pPlmReq->sessionId);
1265 sme_release_global_lock(&pMac->sme);
1266 return CDF_STATUS_E_FAILURE;
1267 }
1268
1269 if (!pSession->sessionActive) {
1270 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
1271 FL("Invalid Sessionid"));
1272 sme_release_global_lock(&pMac->sme);
1273 return CDF_STATUS_E_FAILURE;
1274 }
1275
1276 if (!pPlmReq->enable)
1277 goto send_plm_start;
1278 /* validating channel numbers */
1279 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1280 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1281 if (ret && pPlmReq->plmChList[count] > 14) {
1282 if (CHANNEL_STATE_DFS == cds_get_channel_state(
1283 pPlmReq->plmChList[count])) {
1284 /* DFS channel is provided, no PLM bursts can be
1285 * transmitted. Ignoring these channels.
1286 */
1287 CDF_TRACE(CDF_MODULE_ID_SME,
1288 CDF_TRACE_LEVEL_INFO,
1289 FL("DFS channel %d ignored for PLM"),
1290 pPlmReq->plmChList[count]);
1291 continue;
1292 }
1293 } else if (!ret) {
1294 /* Not supported, ignore the channel */
1295 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
1296 FL("Unsupported channel %d ignored for PLM"),
1297 pPlmReq->plmChList[count]);
1298 continue;
1299 }
1300 ch_list[valid_count] = pPlmReq->plmChList[count];
1301 valid_count++;
1302 } /* End of for () */
1303
1304 /* Copying back the valid channel list to plm struct */
1305 cdf_mem_set((void *)pPlmReq->plmChList,
1306 pPlmReq->plmNumCh, 0);
1307 if (valid_count)
1308 cdf_mem_copy(pPlmReq->plmChList, ch_list,
1309 valid_count);
1310 /* All are invalid channels, FW need to send the PLM
1311 * report with "incapable" bit set.
1312 */
1313 pPlmReq->plmNumCh = valid_count;
1314
1315send_plm_start:
1316 /* PLM START */
1317 msg.type = WMA_SET_PLM_REQ;
1318 msg.reserved = 0;
1319 msg.bodyptr = pPlmReq;
1320
1321 if (!CDF_IS_STATUS_SUCCESS(cds_mq_post_message(CDF_MODULE_ID_WMA,
1322 &msg))) {
1323 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
1324 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1325 sme_release_global_lock(&pMac->sme);
1326 return CDF_STATUS_E_FAILURE;
1327 }
1328
1329 sme_release_global_lock(&pMac->sme);
1330 return status;
1331}
1332#endif
1333
1334/*--------------------------------------------------------------------------
1335
1336 \brief sme_update_config() - Change configurations for all SME moduels
1337
1338 The function updates some configuration for modules in SME, CSR, etc
1339 during SMEs close open sequence.
1340
1341 Modules inside SME apply the new configuration at the next transaction.
1342
1343 This is a synchronous call
1344
1345 \param hHal - The handle returned by mac_open.
1346 \Param pSmeConfigParams - a pointer to a caller allocated object of
1347 typedef struct _smeConfigParams.
1348
1349 \return CDF_STATUS_SUCCESS - SME update the config parameters successfully.
1350
1351 Other status means SME is failed to update the config parameters.
1352 \sa
1353
1354 --------------------------------------------------------------------------*/
1355CDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1356{
1357 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1358 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1359
1360 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
1361 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
1362 0));
1363 if (NULL == pSmeConfigParams) {
1364 sms_log(pMac, LOGE,
1365 "Empty config param structure for SME, nothing to update");
1366 return status;
1367 }
1368
1369 status =
1370 csr_change_default_config_param(pMac, &pSmeConfigParams->csrConfig);
1371
1372 if (!CDF_IS_STATUS_SUCCESS(status)) {
1373 sms_log(pMac, LOGE,
1374 "csr_change_default_config_param failed with status=%d",
1375 status);
1376 }
1377#if defined WLAN_FEATURE_VOWIFI
1378 status =
1379 rrm_change_default_config_param(hHal, &pSmeConfigParams->rrmConfig);
1380
1381 if (!CDF_IS_STATUS_SUCCESS(status)) {
1382 sms_log(pMac, LOGE,
1383 "rrm_change_default_config_param failed with status=%d",
1384 status);
1385 }
1386#endif
1387 /* For SOC, CFG is set before start */
1388 /* We don't want to apply global CFG in connect state because that may cause some side affect */
1389 if (csr_is_all_session_disconnected(pMac)) {
1390 csr_set_global_cfgs(pMac);
1391 }
1392
1393 /*
1394 * If scan offload is enabled then lim has allow the sending of
1395 * scan request to firmware even in powersave mode. The firmware has
1396 * to take care of exiting from power save mode
1397 */
1398 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
1399
1400 if (CDF_STATUS_SUCCESS != status) {
1401 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
1402 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
1403 }
1404 pMac->isCoalesingInIBSSAllowed =
1405 pSmeConfigParams->csrConfig.isCoalesingInIBSSAllowed;
1406
1407 /* update p2p offload status */
1408 pMac->pnoOffload = pSmeConfigParams->pnoOffload;
1409
1410 pMac->fEnableDebugLog = pSmeConfigParams->fEnableDebugLog;
1411
1412 /* update interface configuration */
1413 pMac->sme.max_intf_count = pSmeConfigParams->max_intf_count;
1414
1415 pMac->enable5gEBT = pSmeConfigParams->enable5gEBT;
1416 pMac->sme.enableSelfRecovery = pSmeConfigParams->enableSelfRecovery;
1417
1418 pMac->f_sta_miracast_mcc_rest_time_val =
1419 pSmeConfigParams->f_sta_miracast_mcc_rest_time_val;
1420
1421#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
1422 pMac->sap.sap_channel_avoidance =
1423 pSmeConfigParams->sap_channel_avoidance;
1424#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
1425
1426 pMac->f_prefer_non_dfs_on_radar =
1427 pSmeConfigParams->f_prefer_non_dfs_on_radar;
1428
1429 pMac->sme.ps_global_info.ps_enabled =
1430 pSmeConfigParams->is_ps_enabled;
1431
1432 pMac->policy_manager_enabled = pSmeConfigParams->policy_manager_enabled;
1433 pMac->fine_time_meas_cap = pSmeConfigParams->fine_time_meas_cap;
1434 pMac->dual_mac_feature_disable =
1435 pSmeConfigParams->dual_mac_feature_disable;
Varun Reddy Yeturub43fda12015-09-10 18:16:21 -07001436 sme_update_roam_pno_channel_prediction_config(pMac, pSmeConfigParams,
1437 SME_CONFIG_TO_ROAM_CONFIG);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07001438 pMac->roam.configParam.early_stop_scan_enable =
1439 pSmeConfigParams->early_stop_scan_enable;
1440 pMac->roam.configParam.early_stop_scan_min_threshold =
1441 pSmeConfigParams->early_stop_scan_min_threshold;
1442 pMac->roam.configParam.early_stop_scan_max_threshold =
1443 pSmeConfigParams->early_stop_scan_max_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444
1445 return status;
1446}
1447
1448/**
1449 * sme_update_roam_params() - Store/Update the roaming params
1450 * @hal: Handle for Hal layer
1451 * @session_id: SME Session ID
1452 * @roam_params_src: The source buffer to copy
1453 * @update_param: Type of parameter to be updated
1454 *
1455 * Return: Return the status of the updation.
1456 */
1457CDF_STATUS sme_update_roam_params(tHalHandle hal,
1458 uint8_t session_id, struct roam_ext_params roam_params_src,
1459 int update_param)
1460{
1461 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
1462 struct roam_ext_params *roam_params_dst;
1463 uint8_t i;
1464
1465 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
1466 switch (update_param) {
1467 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
1468 roam_params_dst->raise_rssi_thresh_5g =
1469 roam_params_src.raise_rssi_thresh_5g;
1470 roam_params_dst->drop_rssi_thresh_5g =
1471 roam_params_src.drop_rssi_thresh_5g;
1472 roam_params_dst->raise_factor_5g =
1473 roam_params_src.raise_factor_5g;
1474 roam_params_dst->drop_factor_5g =
1475 roam_params_src.drop_factor_5g;
1476 roam_params_dst->max_raise_rssi_5g =
1477 roam_params_src.max_raise_rssi_5g;
1478 roam_params_dst->max_drop_rssi_5g =
1479 roam_params_src.max_drop_rssi_5g;
1480 roam_params_dst->alert_rssi_threshold =
1481 roam_params_src.alert_rssi_threshold;
1482 roam_params_dst->is_5g_pref_enabled = true;
1483 break;
1484 case REASON_ROAM_SET_SSID_ALLOWED:
1485 cdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
1486 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1487 roam_params_dst->num_ssid_allowed_list =
1488 roam_params_src.num_ssid_allowed_list;
1489 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1490 roam_params_dst->ssid_allowed_list[i].length =
1491 roam_params_src.ssid_allowed_list[i].length;
1492 cdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
1493 roam_params_src.ssid_allowed_list[i].ssId,
1494 roam_params_dst->ssid_allowed_list[i].length);
1495 }
1496 break;
1497 case REASON_ROAM_SET_FAVORED_BSSID:
1498 cdf_mem_set(&roam_params_dst->bssid_favored, 0,
1499 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1500 roam_params_dst->num_bssid_favored =
1501 roam_params_src.num_bssid_favored;
1502 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
1503 cdf_mem_copy(&roam_params_dst->bssid_favored[i],
1504 &roam_params_src.bssid_favored[i],
1505 sizeof(tSirMacAddr));
1506 roam_params_dst->bssid_favored_factor[i] =
1507 roam_params_src.bssid_favored_factor[i];
1508 }
1509 break;
1510 case REASON_ROAM_SET_BLACKLIST_BSSID:
1511 cdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Srinivas Girigowdab0532392015-11-24 11:50:16 -08001512 CDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 roam_params_dst->num_bssid_avoid_list =
1514 roam_params_src.num_bssid_avoid_list;
1515 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Srinivas Girigowdab0532392015-11-24 11:50:16 -08001516 cdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
1517 &roam_params_src.bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 }
1519 break;
1520 case REASON_ROAM_GOOD_RSSI_CHANGED:
1521 roam_params_dst->good_rssi_roam =
1522 roam_params_src.good_rssi_roam;
1523 break;
1524 default:
1525 break;
1526 }
1527 csr_roam_offload_scan(mac_ctx, session_id, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1528 update_param);
1529 return 0;
1530}
1531
1532#ifdef WLAN_FEATURE_GTK_OFFLOAD
1533void sme_process_get_gtk_info_rsp(tHalHandle hHal,
1534 tpSirGtkOffloadGetInfoRspParams
1535 pGtkOffloadGetInfoRsp)
1536{
1537 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1538
1539 if (NULL == pMac) {
1540 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_FATAL,
1541 "%s: pMac is null", __func__);
1542 return;
1543 }
1544 if (pMac->sme.gtk_offload_get_info_cb == NULL) {
1545 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
1546 "%s: HDD callback is null", __func__);
1547 return;
1548 }
1549 pMac->sme.gtk_offload_get_info_cb(
1550 pMac->sme.gtk_offload_get_info_cb_context,
1551 pGtkOffloadGetInfoRsp);
1552}
1553#endif
1554
1555/*--------------------------------------------------------------------------
1556
1557 \fn - sme_process_ready_to_suspend
1558 \brief - On getting ready to suspend indication, this function calls
1559 callback registered (HDD callbacks) with SME to inform
1560 ready to suspend indication.
1561
1562 \param hHal - Handle returned by mac_open.
1563 pReadyToSuspend - Parameter received along with ready to suspend
1564 indication from WMA.
1565
1566 \return None
1567
1568 \sa
1569
1570 --------------------------------------------------------------------------*/
1571void sme_process_ready_to_suspend(tHalHandle hHal,
1572 tpSirReadyToSuspendInd pReadyToSuspend)
1573{
1574 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1575
1576 if (NULL == pMac) {
1577 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_FATAL,
1578 "%s: pMac is null", __func__);
1579 return;
1580 }
1581
1582 if (NULL != pMac->readyToSuspendCallback) {
1583 pMac->readyToSuspendCallback(pMac->readyToSuspendContext,
1584 pReadyToSuspend->suspended);
1585 pMac->readyToSuspendCallback = NULL;
1586 }
1587}
1588
1589#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001591/**
1592 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
1593 * @hHal - Handle returned by mac_open.
1594 * @pReadyToExtWoW - Parameter received along with ready to Ext WoW
1595 * indication from WMA.
1596 *
1597 * On getting ready to Ext WoW indication, this function calls callback
1598 * registered (HDD callback)with SME to inform ready to ExtWoW indication.
1599 *
1600 * Return: None
1601 */
1602void sme_process_ready_to_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 tpSirReadyToExtWoWInd pReadyToExtWoW)
1604{
1605 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1606
1607 if (NULL == pMac) {
1608 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_FATAL,
1609 "%s: pMac is null", __func__);
1610 return;
1611 }
1612
1613 if (NULL != pMac->readyToExtWoWCallback) {
1614 pMac->readyToExtWoWCallback(pMac->readyToExtWoWContext,
1615 pReadyToExtWoW->status);
1616 pMac->readyToExtWoWCallback = NULL;
1617 pMac->readyToExtWoWContext = NULL;
1618 }
1619
1620}
1621#endif
1622
1623/* ---------------------------------------------------------------------------
1624 \fn sme_change_config_params
1625 \brief The SME API exposed for HDD to provide config params to SME during
1626 SMEs stop -> start sequence.
1627
1628 If HDD changed the domain that will cause a reset. This function will
1629 provide the new set of 11d information for the new domain. Currrently this
1630 API provides info regarding 11d only at reset but we can extend this for
1631 other params (PMC, QoS) which needs to be initialized again at reset.
1632
1633 This is a synchronous call
1634
1635 \param hHal - The handle returned by mac_open.
1636
1637 \Param
1638 pUpdateConfigParam - a pointer to a structure (tCsrUpdateConfigParam) that
1639 currently provides 11d related information like Country code,
1640 Regulatory domain, valid channel list, Tx power per channel, a
1641 list with active/passive scan allowed per valid channel.
1642
1643 \return CDF_STATUS
1644 ---------------------------------------------------------------------------*/
1645CDF_STATUS sme_change_config_params(tHalHandle hHal,
1646 tCsrUpdateConfigParam *pUpdateConfigParam)
1647{
1648 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1649 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1650
1651 if (NULL == pUpdateConfigParam) {
1652 sms_log(pMac, LOGE,
1653 "Empty config param structure for SME, nothing to reset");
1654 return status;
1655 }
1656
1657 status = csr_change_config_params(pMac, pUpdateConfigParam);
1658
1659 if (!CDF_IS_STATUS_SUCCESS(status)) {
1660 sms_log(pMac, LOGE, "csrUpdateConfigParam failed with status=%d",
1661 status);
1662 }
1663
1664 return status;
1665
1666}
1667
1668/*--------------------------------------------------------------------------
1669
1670 \brief sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1671 that the NIC is ready tio run.
1672
1673 The function is called by HDD at the end of initialization stage so PE/HAL can
1674 enable the NIC to running state.
1675
1676 This is a synchronous call
1677 \param hHal - The handle returned by mac_open.
1678
1679 \return CDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1680 successfully.
1681
1682 Other status means SME failed to send the message to PE.
1683 \sa
1684
1685 --------------------------------------------------------------------------*/
1686CDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
1687{
1688 tSirSmeReadyReq Msg;
1689 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1690 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1691
1692 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
1693 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1694 do {
1695
1696 Msg.messageType = eWNI_SME_SYS_READY_IND;
1697 Msg.length = sizeof(tSirSmeReadyReq);
1698 Msg.add_bssdescr_cb = csr_scan_process_single_bssdescr;
1699
1700
1701 if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *) &Msg)) {
1702 status = CDF_STATUS_SUCCESS;
1703 } else {
1704 sms_log(pMac, LOGE,
1705 "u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
1706 break;
1707 }
1708
1709 status = csr_ready(pMac);
1710 if (!CDF_IS_STATUS_SUCCESS(status)) {
1711 sms_log(pMac, LOGE,
1712 "csr_ready failed with status=%d",
1713 status);
1714 break;
1715 }
1716
1717#if defined WLAN_FEATURE_VOWIFI
1718 if (CDF_STATUS_SUCCESS != rrm_ready(hHal)) {
1719 status = CDF_STATUS_E_FAILURE;
1720 sms_log(pMac, LOGE, "rrm_ready failed");
1721 break;
1722 }
1723#endif
1724 pMac->sme.state = SME_STATE_READY;
1725 } while (0);
1726
1727 return status;
1728}
1729
1730/*--------------------------------------------------------------------------
1731
1732 \brief sme_start() - Put all SME modules at ready state.
1733
1734 The function starts each module in SME, PMC, CSR, etc. . Upon
1735 successfully return, all modules are ready to run.
1736 This is a synchronous call
1737 \param hHal - The handle returned by mac_open.
1738
1739 \return CDF_STATUS_SUCCESS - SME is ready.
1740
1741 Other status means SME is failed to start
1742 \sa
1743
1744 --------------------------------------------------------------------------*/
1745CDF_STATUS sme_start(tHalHandle hHal)
1746{
1747 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1748 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1749
1750 do {
1751 status = csr_start(pMac);
1752 if (!CDF_IS_STATUS_SUCCESS(status)) {
1753 sms_log(pMac, LOGE,
1754 "csr_start failed during smeStart with status=%d",
1755 status);
1756 break;
1757 }
1758
1759#ifndef WLAN_FEATURE_MBSSID
1760 status = wlansap_start(cds_get_global_context());
1761 if (!CDF_IS_STATUS_SUCCESS(status)) {
1762 sms_log(pMac, LOGE,
1763 "wlansap_start failed during smeStart with status=%d",
1764 status);
1765 break;
1766 }
1767#endif
1768
1769 pMac->sme.state = SME_STATE_START;
1770 } while (0);
1771
1772 return status;
1773}
1774
1775/**
1776 * sme_handle_scan_req() - Scan request handler
1777 * @mac_ctx: MAC global context
1778 * @msg: message buffer
1779 *
1780 * Scan request message from upper layer is handled as
1781 * part of this API
1782 *
1783 * Return: CDF_STATUS
1784 */
1785static CDF_STATUS sme_handle_scan_req(tpAniSirGlobal mac_ctx,
1786 void *msg)
1787{
1788 struct ani_scan_req *scan_msg;
1789 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1790 uint16_t session_id;
1791 csr_scan_completeCallback callback;
1792
1793 scan_msg = msg;
1794 session_id = scan_msg->session_id;
1795 callback = scan_msg->callback;
1796 status = csr_scan_request(mac_ctx, session_id,
1797 scan_msg->scan_param,
1798 callback, scan_msg->ctx);
1799 if (!CDF_IS_STATUS_SUCCESS(status)) {
1800 sms_log(mac_ctx, LOGE,
1801 FL("scan request failed. session_id %d"), session_id);
1802 }
1803 csr_scan_free_request(mac_ctx, scan_msg->scan_param);
1804 return status;
1805}
1806
1807/**
1808 * sme_handle_roc_req() - Roc request handler
1809 * @mac_ctx: MAC global context
1810 * @msg: message buffer
1811 *
1812 * Roc request message from upper layer is handled as
1813 * part of this API
1814 *
1815 * Return: CDF_STATUS
1816 */
1817static CDF_STATUS sme_handle_roc_req(tHalHandle hal,
1818 void *msg)
1819{
1820 struct ani_roc_req *roc_msg;
1821 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1822 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
1823 remainOnChanCallback callback;
1824
1825 if (msg == NULL) {
1826 sms_log(mac_ctx, LOGE, FL("ROC request is NULL"));
1827 return status;
1828 }
1829
1830 roc_msg = msg;
1831 callback = roc_msg->callback;
1832 status = p2p_remain_on_channel(hal, roc_msg->session_id,
1833 roc_msg->channel, roc_msg->duration, callback,
1834 roc_msg->ctx, roc_msg->is_p2pprobe_allowed,
1835 roc_msg->scan_id);
1836 if (!CDF_IS_STATUS_SUCCESS(status)) {
1837 sms_log(mac_ctx, LOGE,
1838 FL("scan request failed. session_id %d scan_id %d"),
1839 roc_msg->session_id, roc_msg->scan_id);
1840 }
1841 return status;
1842}
1843
1844#ifdef WLAN_FEATURE_11W
1845/*------------------------------------------------------------------
1846 *
1847 * Handle the unprotected management frame indication from LIM and
1848 * forward it to HDD.
1849 *
1850 *------------------------------------------------------------------*/
1851
1852CDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
1853 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1854{
1855 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1856 CDF_STATUS status = CDF_STATUS_SUCCESS;
1857 tCsrRoamInfo pRoamInfo = { 0 };
1858 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1859
1860 pRoamInfo.nFrameLength = pSmeMgmtFrm->frameLen;
1861 pRoamInfo.pbFrames = pSmeMgmtFrm->frameBuf;
1862 pRoamInfo.frameType = pSmeMgmtFrm->frameType;
1863
1864 /* forward the mgmt frame to HDD */
1865 csr_roam_call_callback(pMac, SessionId, &pRoamInfo, 0,
1866 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1867
1868 return status;
1869}
1870#endif
1871
1872/*------------------------------------------------------------------
1873 *
1874 * Handle the DFS Radar Event and indicate it to the SAP
1875 *
1876 *------------------------------------------------------------------*/
1877CDF_STATUS dfs_msg_processor(tpAniSirGlobal pMac, uint16_t msgType, void *pMsgBuf)
1878{
1879 CDF_STATUS status = CDF_STATUS_SUCCESS;
1880 tCsrRoamInfo roamInfo = { 0 };
1881 tSirSmeDfsEventInd *dfs_event;
1882 tSirSmeCSAIeTxCompleteRsp *csaIeTxCompleteRsp;
1883 uint32_t sessionId = 0;
1884 eRoamCmdStatus roamStatus;
1885 eCsrRoamResult roamResult;
1886 int i;
1887
1888 switch (msgType) {
1889 case eWNI_SME_DFS_RADAR_FOUND:
1890 {
1891 /* Radar found !! */
1892 dfs_event = (tSirSmeDfsEventInd *) pMsgBuf;
1893 if (NULL == dfs_event) {
1894 sms_log(pMac, LOGE,
1895 "%s: pMsg is NULL for eWNI_SME_DFS_RADAR_FOUND message",
1896 __func__);
1897 return CDF_STATUS_E_FAILURE;
1898 }
1899 sessionId = dfs_event->sessionId;
1900 roamInfo.dfs_event.sessionId = sessionId;
1901 roamInfo.dfs_event.chan_list.nchannels =
1902 dfs_event->chan_list.nchannels;
1903 for (i = 0; i < dfs_event->chan_list.nchannels; i++) {
1904 roamInfo.dfs_event.chan_list.channels[i] =
1905 dfs_event->chan_list.channels[i];
1906 }
1907
1908 roamInfo.dfs_event.dfs_radar_status =
1909 dfs_event->dfs_radar_status;
1910 roamInfo.dfs_event.use_nol = dfs_event->use_nol;
1911
1912 roamStatus = eCSR_ROAM_DFS_RADAR_IND;
1913 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
1914 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_MED,
1915 "sapdfs: Radar indication event occurred");
1916 break;
1917 }
1918 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1919 {
1920 csaIeTxCompleteRsp =
1921 (tSirSmeCSAIeTxCompleteRsp *) pMsgBuf;
1922 if (NULL == csaIeTxCompleteRsp) {
1923 sms_log(pMac, LOGE,
1924 "%s: pMsg is NULL for eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND",
1925 __func__);
1926 return CDF_STATUS_E_FAILURE;
1927 }
1928 sessionId = csaIeTxCompleteRsp->sessionId;
1929 roamStatus = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1930 roamResult = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
1931 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_MED,
1932 "sapdfs: Received eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND for session id [%d]",
1933 sessionId);
1934 break;
1935 }
1936 default:
1937 {
1938 sms_log(pMac, LOG1, "%s: Invalid DFS message = 0x%x",
1939 __func__, msgType);
1940 status = CDF_STATUS_E_FAILURE;
1941 return status;
1942 }
1943 }
1944
1945 /* Indicate Radar Event to SAP */
1946 csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
1947 roamStatus, roamResult);
1948 return status;
1949}
1950
Abhishek Singh518323d2015-10-19 17:42:01 +05301951/**
1952 * sme_extended_change_channel_ind()- function to indicate ECSA
1953 * action frame is received in lim to SAP
1954 * @mac_ctx: pointer to global mac structure
1955 * @msg_buf: contain new channel and session id.
1956 *
1957 * This function is called to post ECSA action frame
1958 * receive event to SAP.
1959 *
1960 * Return: success if msg indicated to SAP else return failure
1961 */
1962static CDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
1963 void *msg_buf)
1964{
1965 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
1966 CDF_STATUS status = CDF_STATUS_SUCCESS;
1967 uint32_t session_id = 0;
1968 tCsrRoamInfo roamInfo = {0};
1969 eRoamCmdStatus roam_status;
1970 eCsrRoamResult roam_result;
1971
1972
1973 ext_chan_ind = msg_buf;
1974 if (NULL == ext_chan_ind) {
1975 sms_log(mac_ctx, LOGE,
1976 FL("pMsg is NULL for eWNI_SME_EXT_CHANGE_CHANNEL_IND"));
1977 return CDF_STATUS_E_FAILURE;
1978 }
1979 session_id = ext_chan_ind->session_id;
1980 roamInfo.target_channel = ext_chan_ind->new_channel;
1981 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1982 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
1983 sms_log(mac_ctx, LOG1,
1984 FL("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]"),
1985 session_id);
1986
1987 /* Indicate Ext Channel Change event to SAP */
1988 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1989 roam_status, roam_result);
1990 return status;
1991}
1992
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1994/*------------------------------------------------------------------
1995 *
1996 * Handle the tsm ie indication from LIM and forward it to HDD.
1997 *
1998 *------------------------------------------------------------------*/
1999CDF_STATUS sme_tsm_ie_ind(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
2000{
2001 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2002 CDF_STATUS status = CDF_STATUS_SUCCESS;
2003 tCsrRoamInfo pRoamInfo = { 0 };
2004 uint32_t SessionId = pSmeTsmIeInd->sessionId;
2005 pRoamInfo.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
2006 pRoamInfo.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
2007 pRoamInfo.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
2008 /* forward the tsm ie information to HDD */
2009 csr_roam_call_callback(pMac,
2010 SessionId, &pRoamInfo, 0, eCSR_ROAM_TSM_IE_IND, 0);
2011 return status;
2012}
2013
2014/* ---------------------------------------------------------------------------
2015 \fn sme_set_cckm_ie
2016 \brief function to store the CCKM IE passed from supplicant and use
2017 it while packing reassociation request
2018 \param hHal - HAL handle for device
2019 \param sessionId - Session Identifier
2020 \param pCckmIe - pointer to CCKM IE data
2021 \param pCckmIeLen - length of the CCKM IE
2022 \- return Success or failure
2023 -------------------------------------------------------------------------*/
2024CDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
2025 uint8_t *pCckmIe, uint8_t cckmIeLen)
2026{
2027 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2028 CDF_STATUS status = CDF_STATUS_SUCCESS;
2029 status = sme_acquire_global_lock(&pMac->sme);
2030 if (CDF_IS_STATUS_SUCCESS(status)) {
2031 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
2032 sme_release_global_lock(&pMac->sme);
2033 }
2034 return status;
2035}
2036
2037/* ---------------------------------------------------------------------------
2038 \fn sme_set_ese_beacon_request
2039 \brief function to set ESE beacon request parameters
2040 \param hHal - HAL handle for device
2041 \param sessionId - Session id
2042 \param pEseBcnReq - pointer to ESE beacon request
2043 \- return Success or failure
2044 -------------------------------------------------------------------------*/
2045CDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
2046 const tCsrEseBeaconReq *pEseBcnReq)
2047{
2048 CDF_STATUS status = eSIR_SUCCESS;
2049 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2050 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
2051 tCsrEseBeaconReqParams *pBeaconReq = NULL;
2052 uint8_t counter = 0;
2053 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
2054 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
2055
2056 if (pSmeRrmContext->eseBcnReqInProgress == true) {
2057 sms_log(pMac, LOGE,
2058 "A Beacon Report Req is already in progress");
2059 return CDF_STATUS_E_RESOURCES;
2060 }
2061
2062 /* Store the info in RRM context */
2063 cdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
2064 sizeof(tCsrEseBeaconReq));
2065
2066 /* Prepare the request to send to SME. */
2067 pSmeBcnReportReq = cdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
2068 if (NULL == pSmeBcnReportReq) {
2069 sms_log(pMac, LOGP,
2070 "Memory Allocation Failure!!! ESE BcnReq Ind to SME");
2071 return CDF_STATUS_E_NOMEM;
2072 }
2073
2074 pSmeRrmContext->eseBcnReqInProgress = true;
2075
2076 sms_log(pMac, LOGE, "Sending Beacon Report Req to SME");
2077 cdf_mem_zero(pSmeBcnReportReq, sizeof(tSirBeaconReportReqInd));
2078
2079 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
2080 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
2081 cdf_mem_copy(pSmeBcnReportReq->bssId,
2082 pSession->connectedProfile.bssid.bytes,
2083 sizeof(tSirMacAddr));
2084 pSmeBcnReportReq->channelInfo.channelNum = 255;
2085 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
2086 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
2087
2088 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
2089 pBeaconReq =
2090 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
2091 pSmeBcnReportReq->fMeasurementtype[counter] =
2092 pBeaconReq->scanMode;
2093 pSmeBcnReportReq->measurementDuration[counter] =
2094 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
2095 pSmeBcnReportReq->channelList.channelNumber[counter] =
2096 pBeaconReq->channel;
2097 }
2098
2099 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
2100
2101 if (status != CDF_STATUS_SUCCESS)
2102 pSmeRrmContext->eseBcnReqInProgress = false;
2103
2104 return status;
2105}
2106
2107#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
2108
2109/**
2110 * sme_process_fw_mem_dump_rsp - process fw memory dump response from WMA
2111 *
2112 * @mac_ctx: pointer to MAC handle.
2113 * @msg: pointer to received SME msg.
2114 *
2115 * This function process the received SME message and calls the corresponding
2116 * callback which was already registered with SME.
2117 *
2118 * Return: None
2119 */
2120#ifdef WLAN_FEATURE_MEMDUMP
2121static void sme_process_fw_mem_dump_rsp(tpAniSirGlobal mac_ctx, cds_msg_t *msg)
2122{
2123 if (msg->bodyptr) {
2124 if (mac_ctx->sme.fw_dump_callback)
2125 mac_ctx->sme.fw_dump_callback(mac_ctx->hHdd,
2126 (struct fw_dump_rsp *) msg->bodyptr);
2127 cdf_mem_free(msg->bodyptr);
2128 }
2129}
2130#else
2131static void sme_process_fw_mem_dump_rsp(tpAniSirGlobal mac_ctx, cds_msg_t *msg)
2132{
2133}
2134#endif
2135
2136/**
2137 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
2138 * @mac: Global MAC pointer
2139 * @msg: Dual mac config response
2140 *
2141 * Processes the dual mac configuration response and invokes the HDD callback
2142 * to process further
2143 */
2144static CDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
2145 uint8_t *msg)
2146{
2147 tListElem *entry = NULL;
2148 tSmeCmd *command = NULL;
2149 bool found;
2150 dual_mac_cb callback = NULL;
2151 struct sir_dual_mac_config_resp *param;
2152
2153 param = (struct sir_dual_mac_config_resp *)msg;
2154 if (!param) {
2155 sms_log(mac, LOGE, FL("Dual mac config resp param is NULL"));
2156 /* Not returning. Need to check if active command list
2157 * needs to be freed
2158 */
2159 }
2160
2161 entry = csr_ll_peek_head(&mac->sme.smeCmdActiveList,
2162 LL_ACCESS_LOCK);
2163 if (!entry) {
2164 sms_log(mac, LOGE, FL("No cmd found in active list"));
2165 return CDF_STATUS_E_FAILURE;
2166 }
2167
2168 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2169 if (!command) {
2170 sms_log(mac, LOGE, FL("Base address is NULL"));
2171 return CDF_STATUS_E_FAILURE;
2172 }
2173
2174 if (e_sme_command_set_dual_mac_config != command->command) {
2175 sms_log(mac, LOGE, FL("Command mismatch!"));
2176 return CDF_STATUS_E_FAILURE;
2177 }
2178
2179 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
2180 if (callback) {
2181 if (!param) {
2182 sms_log(mac, LOGE,
2183 FL("Callback failed-Dual mac config is NULL"));
2184 } else {
2185 sms_log(mac, LOG1,
2186 FL("Calling HDD callback for Dual mac config"));
2187 callback(param->status,
2188 command->u.set_dual_mac_cmd.scan_config,
2189 command->u.set_dual_mac_cmd.fw_mode_config);
2190 }
2191 } else {
2192 sms_log(mac, LOGE, FL("Callback does not exist"));
2193 }
2194
2195 found = csr_ll_remove_entry(&mac->sme.smeCmdActiveList, entry,
2196 LL_ACCESS_LOCK);
2197 if (found)
2198 /* Now put this command back on the available command list */
2199 sme_release_command(mac, command);
2200
2201 sme_process_pending_queue(mac);
2202 return CDF_STATUS_SUCCESS;
2203}
2204
2205/*--------------------------------------------------------------------------
2206
2207 \brief sme_process_msg() - The main message processor for SME.
2208
2209 The function is called by a message dispatcher when to process a message
2210 targeted for SME.
2211
2212 This is a synchronous call
2213 \param hHal - The handle returned by mac_open.
2214 \param pMsg - A pointer to a caller allocated object of tSirMsgQ.
2215
2216 \return CDF_STATUS_SUCCESS - SME successfully process the message.
2217
2218 Other status means SME failed to process the message to HAL.
2219 \sa
2220
2221 --------------------------------------------------------------------------*/
2222CDF_STATUS sme_process_msg(tHalHandle hHal, cds_msg_t *pMsg)
2223{
2224 CDF_STATUS status = CDF_STATUS_E_FAILURE;
2225 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2226
2227 if (pMsg == NULL) {
2228 sms_log(pMac, LOGE, "Empty message for SME");
2229 return status;
2230 }
2231 status = sme_acquire_global_lock(&pMac->sme);
2232 if (!CDF_IS_STATUS_SUCCESS(status)) {
2233 sms_log(pMac, LOGW, FL("Locking failed, bailing out"));
2234 if (pMsg->bodyptr)
2235 cdf_mem_free(pMsg->bodyptr);
2236 return status;
2237 }
2238 if (!SME_IS_START(pMac)) {
2239 sms_log(pMac, LOGW, FL("message type %d in stop state ignored"),
2240 pMsg->type);
2241 if (pMsg->bodyptr)
2242 cdf_mem_free(pMsg->bodyptr);
2243 goto release_lock;
2244 }
2245 switch (pMsg->type) {
2246#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2247 case eWNI_SME_ROAM_OFFLOAD_SYNCH_IND:
2248 csr_process_roam_offload_synch_ind(pMac,
2249 (roam_offload_synch_ind *) pMsg->bodyptr);
2250 cdf_mem_free(pMsg->bodyptr);
2251 break;
2252 case eWNI_SME_HO_FAIL_IND:
2253 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
2254 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
2255 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
2256 cdf_mem_free(pMsg->bodyptr);
2257 break;
2258#endif
2259 case eWNI_PMC_SMPS_STATE_IND:
2260 break;
2261 case WNI_CFG_SET_CNF:
2262 case WNI_CFG_DNLD_CNF:
2263 case WNI_CFG_GET_RSP:
2264 case WNI_CFG_ADD_GRP_ADDR_CNF:
2265 case WNI_CFG_DEL_GRP_ADDR_CNF:
2266 break;
2267 case eWNI_SME_ADDTS_RSP:
2268 case eWNI_SME_DELTS_RSP:
2269 case eWNI_SME_DELTS_IND:
2270#ifdef WLAN_FEATURE_VOWIFI_11R
2271 case eWNI_SME_FT_AGGR_QOS_RSP:
2272#endif
2273 /* QoS */
2274 if (pMsg->bodyptr) {
2275#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2276 status = sme_qos_msg_processor(pMac, pMsg->type,
2277 pMsg->bodyptr);
2278 cdf_mem_free(pMsg->bodyptr);
2279#endif
2280 } else {
2281 sms_log(pMac, LOGE, FL("Empty message for %d"),
2282 pMsg->type);
2283 }
2284 break;
2285#if defined WLAN_FEATURE_VOWIFI
2286 case eWNI_SME_NEIGHBOR_REPORT_IND:
2287 case eWNI_SME_BEACON_REPORT_REQ_IND:
2288#if defined WLAN_VOWIFI_DEBUG
2289 sms_log(pMac, LOGE, FL("Received RRM message. Message Id = %d"),
2290 pMsg->type);
2291#endif
2292 if (pMsg->bodyptr) {
2293 status = sme_rrm_msg_processor(pMac, pMsg->type,
2294 pMsg->bodyptr);
2295 cdf_mem_free(pMsg->bodyptr);
2296 } else {
2297 sms_log(pMac, LOGE, FL("Empty message for %d"),
2298 pMsg->type);
2299 }
2300 break;
2301#endif
2302#ifdef FEATURE_OEM_DATA_SUPPORT
2303 /* Handle the eWNI_SME_OEM_DATA_RSP: */
2304 case eWNI_SME_OEM_DATA_RSP:
2305 if (pMsg->bodyptr) {
2306 status = sme_handle_oem_data_rsp(pMac, pMsg->bodyptr);
2307 cdf_mem_free(pMsg->bodyptr);
2308 } else {
2309 sms_log(pMac, LOGE, FL("Empty message for %d"),
2310 pMsg->type);
2311 }
2312 sme_process_pending_queue(pMac);
2313 break;
2314#endif
2315 case eWNI_SME_ADD_STA_SELF_RSP:
2316 if (pMsg->bodyptr) {
2317 status = csr_process_add_sta_session_rsp(pMac,
2318 pMsg->bodyptr);
2319 cdf_mem_free(pMsg->bodyptr);
2320 } else {
2321 sms_log(pMac, LOGE, FL("Empty message for %d"),
2322 pMsg->type);
2323 }
2324 break;
2325 case eWNI_SME_DEL_STA_SELF_RSP:
2326 if (pMsg->bodyptr) {
2327 status = csr_process_del_sta_session_rsp(pMac,
2328 pMsg->bodyptr);
2329 cdf_mem_free(pMsg->bodyptr);
2330 } else {
2331 sms_log(pMac, LOGE, FL("Empty message for %d"),
2332 pMsg->type);
2333 }
2334 break;
2335 case eWNI_SME_REMAIN_ON_CHN_RSP:
2336 if (pMsg->bodyptr) {
2337 status = sme_remain_on_chn_rsp(pMac, pMsg->bodyptr);
2338 cdf_mem_free(pMsg->bodyptr);
2339 } else {
2340 sms_log(pMac, LOGE, FL("Empty message for %d"),
2341 pMsg->type);
2342 }
2343 break;
2344 case eWNI_SME_REMAIN_ON_CHN_RDY_IND:
2345 if (pMsg->bodyptr) {
2346 status = sme_remain_on_chn_ready(pMac, pMsg->bodyptr);
2347 cdf_mem_free(pMsg->bodyptr);
2348 } else {
2349 sms_log(pMac, LOGE, FL("Empty message for %d"),
2350 pMsg->type);
2351 }
2352 break;
2353 case eWNI_SME_MGMT_FRM_IND:
2354 if (pMsg->bodyptr) {
2355 sme_mgmt_frm_ind(pMac, pMsg->bodyptr);
2356 cdf_mem_free(pMsg->bodyptr);
2357 } else {
2358 sms_log(pMac, LOGE, FL("Empty message for %d"),
2359 pMsg->type);
2360 }
2361 break;
2362 case eWNI_SME_ACTION_FRAME_SEND_CNF:
2363 if (pMsg->bodyptr) {
2364 status = sme_send_action_cnf(pMac, pMsg->bodyptr);
2365 cdf_mem_free(pMsg->bodyptr);
2366 } else {
2367 sms_log(pMac, LOGE, FL("Empty message for %d"),
2368 pMsg->type);
2369 }
2370 break;
2371#ifdef FEATURE_WLAN_SCAN_PNO
2372 case eWNI_SME_PREF_NETWORK_FOUND_IND:
2373 if (pMsg->bodyptr) {
2374 status = sme_preferred_network_found_ind((void *)pMac,
2375 pMsg->bodyptr);
2376 cdf_mem_free(pMsg->bodyptr);
2377 } else {
2378 sms_log(pMac, LOGE, FL("Empty message for %d"),
2379 pMsg->type);
2380 }
2381 break;
2382#endif /* FEATURE_WLAN_SCAN_PNO */
2383 case eWNI_SME_CHANGE_COUNTRY_CODE:
2384 if (pMsg->bodyptr) {
2385 status = sme_handle_change_country_code((void *)pMac,
2386 pMsg->bodyptr);
2387 cdf_mem_free(pMsg->bodyptr);
2388 } else {
2389 sms_log(pMac, LOGE, FL("Empty message for %d"),
2390 pMsg->type);
2391 }
2392 break;
2393 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2394 if (pMsg->bodyptr) {
2395 status = sme_handle_generic_change_country_code(
2396 (void *)pMac, pMsg->bodyptr);
2397 cdf_mem_free(pMsg->bodyptr);
2398 } else {
2399 sms_log(pMac, LOGE, FL("Empty message for %d"),
2400 pMsg->type);
2401 }
2402 break;
2403 case eWNI_SME_SCAN_CMD:
2404 if (pMsg->bodyptr) {
2405 status = sme_handle_scan_req(pMac, pMsg->bodyptr);
2406 cdf_mem_free(pMsg->bodyptr);
2407 } else {
2408 sms_log(pMac, LOGE, FL("Empty message for %d"),
2409 pMsg->type);
2410 }
2411 break;
2412 case eWNI_SME_ROC_CMD:
2413 if (pMsg->bodyptr) {
2414 status = sme_handle_roc_req(hHal, pMsg->bodyptr);
2415 cdf_mem_free(pMsg->bodyptr);
2416 } else {
2417 sms_log(pMac, LOGE, FL("Empty message for %d"),
2418 pMsg->type);
2419 }
2420 break;
2421#ifdef FEATURE_WLAN_TDLS
2422 /*
2423 * command rescived from PE, SME tdls msg processor shall be called
2424 * to process commands recieved from PE
2425 */
2426 case eWNI_SME_TDLS_SEND_MGMT_RSP:
2427 case eWNI_SME_TDLS_ADD_STA_RSP:
2428 case eWNI_SME_TDLS_DEL_STA_RSP:
2429 case eWNI_SME_TDLS_DEL_STA_IND:
2430 case eWNI_SME_TDLS_DEL_ALL_PEER_IND:
2431 case eWNI_SME_MGMT_FRM_TX_COMPLETION_IND:
2432 case eWNI_SME_TDLS_LINK_ESTABLISH_RSP:
2433 case eWNI_SME_TDLS_SHOULD_DISCOVER:
2434 case eWNI_SME_TDLS_SHOULD_TEARDOWN:
2435 case eWNI_SME_TDLS_PEER_DISCONNECTED:
2436 if (pMsg->bodyptr) {
2437 status = tdls_msg_processor(pMac, pMsg->type,
2438 pMsg->bodyptr);
2439 cdf_mem_free(pMsg->bodyptr);
2440 } else {
2441 sms_log(pMac, LOGE, FL("Empty message for %d"),
2442 pMsg->type);
2443 }
2444 break;
2445#endif
2446#ifdef WLAN_FEATURE_11W
2447 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2448 if (pMsg->bodyptr) {
2449 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
2450 cdf_mem_free(pMsg->bodyptr);
2451 } else {
2452 sms_log(pMac, LOGE, FL("Empty message for %d"),
2453 pMsg->type);
2454 }
2455 break;
2456#endif
2457#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
2458 case eWNI_SME_TSM_IE_IND:
2459 if (pMsg->bodyptr) {
2460 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
2461 cdf_mem_free(pMsg->bodyptr);
2462 } else {
2463 sms_log(pMac, LOGE, FL("Empty message for %d"),
2464 pMsg->type);
2465 }
2466 break;
2467#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
2468 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2469 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2470 pMsg->bodyptr);
2471 cdf_mem_free(pMsg->bodyptr);
2472 break;
2473#ifdef WLAN_FEATURE_GTK_OFFLOAD
2474 case eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP:
2475 if (pMsg->bodyptr) {
2476 sme_process_get_gtk_info_rsp(pMac, pMsg->bodyptr);
2477 cdf_mem_free(pMsg->bodyptr);
2478 } else {
2479 sms_log(pMac, LOGE, FL("Empty message for %d"),
2480 pMsg->type);
2481 }
2482 break;
2483#endif
2484#ifdef FEATURE_WLAN_LPHB
2485 /* LPHB timeout indication arrived, send IND to client */
2486 case eWNI_SME_LPHB_IND:
2487 if (pMac->sme.pLphbIndCb)
2488 pMac->sme.pLphbIndCb(pMac->hHdd, pMsg->bodyptr);
2489 cdf_mem_free(pMsg->bodyptr);
2490 break;
2491#endif /* FEATURE_WLAN_LPHB */
2492
2493 case eWNI_SME_READY_TO_SUSPEND_IND:
2494 if (pMsg->bodyptr) {
2495 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
2496 cdf_mem_free(pMsg->bodyptr);
2497 } else {
2498 sms_log(pMac, LOGE, FL("Empty message for %d"),
2499 pMsg->type);
2500 }
2501 break;
2502#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2503 case eWNI_SME_READY_TO_EXTWOW_IND:
2504 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002505 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506 cdf_mem_free(pMsg->bodyptr);
2507 } else {
2508 sms_log(pMac, LOGE, FL("Empty message for %d"),
2509 pMsg->type);
2510 }
2511 break;
2512#endif
2513#ifdef FEATURE_WLAN_CH_AVOID
2514 /* channel avoid message arrived, send IND to client */
2515 case eWNI_SME_CH_AVOID_IND:
2516 if (pMac->sme.pChAvoidNotificationCb) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08002517 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518 FL("CH avoid notification"));
2519 pMac->sme.pChAvoidNotificationCb(pMac->hHdd,
2520 pMsg->bodyptr);
2521 }
2522 cdf_mem_free(pMsg->bodyptr);
2523 break;
2524#endif /* FEATURE_WLAN_CH_AVOID */
2525#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2526 case eWNI_SME_AUTO_SHUTDOWN_IND:
2527 if (pMac->sme.pAutoShutdownNotificationCb) {
2528 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
2529 FL("Auto shutdown notification"));
2530 pMac->sme.pAutoShutdownNotificationCb();
2531 }
2532 cdf_mem_free(pMsg->bodyptr);
2533 break;
2534#endif
2535 case eWNI_SME_DFS_RADAR_FOUND:
2536 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
2537 status = dfs_msg_processor(pMac, pMsg->type, pMsg->bodyptr);
2538 cdf_mem_free(pMsg->bodyptr);
2539 break;
2540 case eWNI_SME_CHANNEL_CHANGE_RSP:
2541 if (pMsg->bodyptr) {
2542 status = sme_process_channel_change_resp(pMac,
2543 pMsg->type,
2544 pMsg->bodyptr);
2545 cdf_mem_free(pMsg->bodyptr);
2546 } else {
2547 sms_log(pMac, LOGE, FL("Empty message for %d"),
2548 pMsg->type);
2549 }
2550 break;
2551#ifdef WLAN_FEATURE_STATS_EXT
2552 case eWNI_SME_STATS_EXT_EVENT:
2553 if (pMsg->bodyptr) {
2554 status = sme_stats_ext_event(hHal, pMsg->bodyptr);
2555 cdf_mem_free(pMsg->bodyptr);
2556 } else {
2557 sms_log(pMac, LOGE, FL("Empty message for %d"),
2558 pMsg->type);
2559 }
2560 break;
2561#endif
2562 case eWNI_SME_LINK_SPEED_IND:
2563 if (pMac->sme.pLinkSpeedIndCb)
2564 pMac->sme.pLinkSpeedIndCb(pMsg->bodyptr,
2565 pMac->sme.pLinkSpeedCbContext);
2566 if (pMsg->bodyptr)
2567 cdf_mem_free(pMsg->bodyptr);
2568 break;
2569 case eWNI_SME_CSA_OFFLOAD_EVENT:
2570 if (pMsg->bodyptr) {
2571 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
2572 cdf_mem_free(pMsg->bodyptr);
2573 }
2574 break;
2575#ifdef WLAN_FEATURE_NAN
2576 case eWNI_SME_NAN_EVENT:
2577 if (pMsg->bodyptr) {
2578 sme_nan_event(hHal, pMsg->bodyptr);
2579 cdf_mem_free(pMsg->bodyptr);
2580 }
2581 break;
2582#endif /* WLAN_FEATURE_NAN */
2583 case eWNI_SME_LINK_STATUS_IND:
2584 {
2585 tAniGetLinkStatus *pLinkStatus =
2586 (tAniGetLinkStatus *) pMsg->bodyptr;
2587 if (pLinkStatus) {
2588 if (pMac->sme.linkStatusCallback) {
2589 pMac->sme.linkStatusCallback(
2590 pLinkStatus->linkStatus,
2591 pMac->sme.linkStatusContext);
2592 }
2593 pMac->sme.linkStatusCallback = NULL;
2594 pMac->sme.linkStatusContext = NULL;
2595 cdf_mem_free(pLinkStatus);
2596 }
2597 break;
2598 }
2599 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
2600 if (pMac->sme.pGetTemperatureCb) {
2601 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2602 pMac->sme.pTemperatureCbContext);
2603 }
2604 break;
2605 case eWNI_SME_SNR_IND:
2606 {
2607 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
2608 if (pSnrReq) {
2609 if (pSnrReq->snrCallback) {
2610 ((tCsrSnrCallback)
2611 (pSnrReq->snrCallback))
2612 (pSnrReq->snr, pSnrReq->staId,
2613 pSnrReq->pDevContext);
2614 }
2615 cdf_mem_free(pSnrReq);
2616 }
2617 break;
2618 }
2619#ifdef FEATURE_WLAN_EXTSCAN
2620 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2621 if (pMac->sme.pExtScanIndCb)
2622 pMac->sme.pExtScanIndCb(pMac->hHdd,
2623 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2624 pMsg->bodyptr);
2625 else
2626 sms_log(pMac, LOGE,
2627 FL("callback not registered to process %d"),
2628 pMsg->type);
2629
2630 cdf_mem_free(pMsg->bodyptr);
2631 break;
2632 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2633 if (pMac->sme.pExtScanIndCb)
2634 pMac->sme.pExtScanIndCb(pMac->hHdd,
2635 eSIR_EPNO_NETWORK_FOUND_IND,
2636 pMsg->bodyptr);
2637 else
2638 sms_log(pMac, LOGE,
2639 FL("callback not registered to process %d"),
2640 pMsg->type);
2641
2642 cdf_mem_free(pMsg->bodyptr);
2643 break;
2644#endif
2645 case eWNI_SME_FW_DUMP_IND:
2646 sme_process_fw_mem_dump_rsp(pMac, pMsg);
2647 break;
2648 case eWNI_SME_SET_HW_MODE_RESP:
2649 if (pMsg->bodyptr) {
2650 status = sme_process_set_hw_mode_resp(pMac,
2651 pMsg->bodyptr);
2652 cdf_mem_free(pMsg->bodyptr);
2653 } else {
2654 sms_log(pMac, LOGE, FL("Empty message for %d"),
2655 pMsg->type);
2656 }
2657 break;
2658 case eWNI_SME_HW_MODE_TRANS_IND:
2659 if (pMsg->bodyptr) {
2660 status = sme_process_hw_mode_trans_ind(pMac,
2661 pMsg->bodyptr);
2662 cdf_mem_free(pMsg->bodyptr);
2663 } else {
2664 sms_log(pMac, LOGE, FL("Empty message for %d"),
2665 pMsg->type);
2666 }
2667 break;
2668 case eWNI_SME_NSS_UPDATE_RSP:
2669 if (pMsg->bodyptr) {
2670 status = sme_process_nss_update_resp(pMac,
2671 pMsg->bodyptr);
2672 cdf_mem_free(pMsg->bodyptr);
2673 } else {
2674 sms_log(pMac, LOGE, FL("Empty message for %d"),
2675 pMsg->type);
2676 }
2677 break;
2678 case eWNI_SME_OCB_SET_CONFIG_RSP:
2679 if (pMac->sme.ocb_set_config_callback) {
2680 pMac->sme.ocb_set_config_callback(
2681 pMac->sme.ocb_set_config_context,
2682 pMsg->bodyptr);
2683 } else {
2684 sms_log(pMac, LOGE, FL(
2685 "Message error. The callback is NULL."));
2686 }
2687 pMac->sme.ocb_set_config_callback = NULL;
2688 pMac->sme.ocb_set_config_context = NULL;
2689 cdf_mem_free(pMsg->bodyptr);
2690 break;
2691 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
2692 if (pMac->sme.ocb_get_tsf_timer_callback) {
2693 pMac->sme.ocb_get_tsf_timer_callback(
2694 pMac->sme.ocb_get_tsf_timer_context,
2695 pMsg->bodyptr);
2696 } else {
2697 sms_log(pMac, LOGE, FL(
2698 "Message error. The callback is NULL."));
2699 }
2700 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2701 pMac->sme.ocb_get_tsf_timer_context = NULL;
2702 cdf_mem_free(pMsg->bodyptr);
2703 break;
2704 case eWNI_SME_DCC_GET_STATS_RSP:
2705 if (pMac->sme.dcc_get_stats_callback) {
2706 pMac->sme.dcc_get_stats_callback(
2707 pMac->sme.dcc_get_stats_context,
2708 pMsg->bodyptr);
2709 } else {
2710 sms_log(pMac, LOGE, FL(
2711 "Message error. The callback is NULL."));
2712 }
2713 pMac->sme.dcc_get_stats_callback = NULL;
2714 pMac->sme.dcc_get_stats_context = NULL;
2715 cdf_mem_free(pMsg->bodyptr);
2716 break;
2717 case eWNI_SME_DCC_UPDATE_NDL_RSP:
2718 if (pMac->sme.dcc_update_ndl_callback) {
2719 pMac->sme.dcc_update_ndl_callback(
2720 pMac->sme.dcc_update_ndl_context,
2721 pMsg->bodyptr);
2722 } else {
2723 sms_log(pMac, LOGE, FL(
2724 "Message error. The callback is NULL."));
2725 }
2726 pMac->sme.dcc_update_ndl_callback = NULL;
2727 pMac->sme.dcc_update_ndl_context = NULL;
2728 cdf_mem_free(pMsg->bodyptr);
2729 break;
2730 case eWNI_SME_DCC_STATS_EVENT:
2731 if (pMac->sme.dcc_stats_event_callback) {
2732 pMac->sme.dcc_stats_event_callback(
2733 pMac->sme.dcc_stats_event_context,
2734 pMsg->bodyptr);
2735 } else {
2736 sms_log(pMac, LOGE, FL(
2737 "Message error. The callback is NULL."));
2738 }
2739 cdf_mem_free(pMsg->bodyptr);
2740 break;
2741 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2742 if (pMsg->bodyptr) {
2743 status = sme_process_dual_mac_config_resp(pMac,
2744 pMsg->bodyptr);
2745 cdf_mem_free(pMsg->bodyptr);
2746 } else {
2747 sms_log(pMac, LOGE, FL("Empty message for %d"),
2748 pMsg->type);
2749 }
2750 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2751 if (pMac->sme.set_thermal_level_cb)
2752 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2753 pMsg->bodyval);
2754 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302755 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2756 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
2757 cdf_mem_free(pMsg->bodyptr);
2758 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 default:
2760
2761 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2762 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2763 /* CSR */
2764 if (pMsg->bodyptr) {
2765 status = csr_msg_processor(hHal, pMsg->bodyptr);
2766 cdf_mem_free(pMsg->bodyptr);
2767 } else {
2768 sms_log(pMac, LOGE, FL("Empty message for %d"),
2769 pMsg->type);
2770 }
2771 } else {
2772 sms_log(pMac, LOGW, FL("Unknown message type %d"),
2773 pMsg->type);
2774 if (pMsg->bodyptr)
2775 cdf_mem_free(pMsg->bodyptr);
2776 }
2777 } /* switch */
2778release_lock:
2779 sme_release_global_lock(&pMac->sme);
2780 return status;
2781}
2782
2783/**
2784 * sme_process_nss_update_resp() - Process nss update response
2785 * @mac: Global MAC pointer
2786 * @msg: nss update response
2787 *
2788 * Processes the nss update response and invokes the HDD
2789 * callback to process further
2790 */
2791CDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
2792{
2793 tListElem *entry = NULL;
2794 tSmeCmd *command = NULL;
2795 bool found;
2796 nss_update_cb callback = NULL;
2797 struct sir_beacon_tx_complete_rsp *param;
2798
2799 param = (struct sir_beacon_tx_complete_rsp *)msg;
2800 if (!param) {
2801 sms_log(mac, LOGE, FL("nss update resp param is NULL"));
2802 /* Not returning. Need to check if active command list
2803 * needs to be freed
2804 */
2805 }
2806
2807 entry = csr_ll_peek_head(&mac->sme.smeCmdActiveList,
2808 LL_ACCESS_LOCK);
2809 if (!entry) {
2810 sms_log(mac, LOGE, FL("No cmd found in active list"));
2811 return CDF_STATUS_E_FAILURE;
2812 }
2813
2814 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2815 if (!command) {
2816 sms_log(mac, LOGE, FL("Base address is NULL"));
2817 return CDF_STATUS_E_FAILURE;
2818 }
2819
2820 if (e_sme_command_nss_update != command->command) {
2821 sms_log(mac, LOGE, FL("Command mismatch!"));
2822 return CDF_STATUS_E_FAILURE;
2823 }
2824
2825 callback = command->u.nss_update_cmd.nss_update_cb;
2826 if (callback) {
2827 if (!param) {
2828 sms_log(mac, LOGE,
2829 FL("Callback failed since nss update params is NULL"));
2830 } else {
2831 sms_log(mac, LOGE,
2832 FL("Calling HDD callback for nss update response"));
2833 callback(command->u.nss_update_cmd.context,
2834 param->tx_status,
2835 param->session_id,
2836 command->u.nss_update_cmd.next_action);
2837 }
2838 } else {
2839 sms_log(mac, LOGE, FL("Callback does not exisit"));
2840 }
2841
2842 found = csr_ll_remove_entry(&mac->sme.smeCmdActiveList, entry,
2843 LL_ACCESS_LOCK);
2844 if (found) {
2845 /* Now put this command back on the avilable command list */
2846 sme_release_command(mac, command);
2847 }
2848 sme_process_pending_queue(mac);
2849 return CDF_STATUS_SUCCESS;
2850}
2851
2852/* No need to hold the global lock here because this function can only be called */
2853/* after sme_stop. */
2854void sme_free_msg(tHalHandle hHal, cds_msg_t *pMsg)
2855{
2856 if (pMsg) {
2857 if (pMsg->bodyptr) {
2858 cdf_mem_free(pMsg->bodyptr);
2859 }
2860 }
2861
2862}
2863
2864/*--------------------------------------------------------------------------
2865
2866 \brief sme_stop() - Stop all SME modules and put them at idle state
2867
2868 The function stops each module in SME, PMC, CSR, etc. . Upon
2869 return, all modules are at idle state ready to start.
2870
2871 This is a synchronous call
2872 \param hHal - The handle returned by mac_open
2873 \param tHalStopType - reason for stopping
2874
2875 \return CDF_STATUS_SUCCESS - SME is stopped.
2876
2877 Other status means SME is failed to stop but caller should still
2878 consider SME is stopped.
2879 \sa
2880
2881 --------------------------------------------------------------------------*/
2882CDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
2883{
2884 CDF_STATUS status = CDF_STATUS_E_FAILURE;
2885 CDF_STATUS fail_status = CDF_STATUS_SUCCESS;
2886 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2887
2888#ifndef WLAN_FEATURE_MBSSID
2889 status = wlansap_stop(cds_get_global_context());
2890 if (!CDF_IS_STATUS_SUCCESS(status)) {
2891 sms_log(pMac, LOGE,
2892 "wlansap_stop failed during smeStop with status=%d",
2893 status);
2894 fail_status = status;
2895 }
2896#endif
2897
2898 p2p_stop(hHal);
2899
2900 status = csr_stop(pMac, stopType);
2901 if (!CDF_IS_STATUS_SUCCESS(status)) {
2902 sms_log(pMac, LOGE,
2903 "csr_stop failed during smeStop with status=%d", status);
2904 fail_status = status;
2905 }
2906
2907 purge_sme_cmd_list(pMac);
2908
2909 if (!CDF_IS_STATUS_SUCCESS(fail_status)) {
2910 status = fail_status;
2911 }
2912
2913 pMac->sme.state = SME_STATE_STOP;
2914
2915 return status;
2916}
2917
2918/*--------------------------------------------------------------------------
2919
2920 \brief sme_close() - Release all SME modules and their resources.
2921
2922 The function release each module in SME, PMC, CSR, etc. . Upon
2923 return, all modules are at closed state.
2924
2925 No SME APIs can be involved after smeClose except smeOpen.
2926 smeClose must be called before mac_close.
2927 This is a synchronous call
2928 \param hHal - The handle returned by mac_open
2929
2930 \return CDF_STATUS_SUCCESS - SME is successfully close.
2931
2932 Other status means SME is failed to be closed but caller still cannot
2933 call any other SME functions except smeOpen.
2934 \sa
2935
2936 --------------------------------------------------------------------------*/
2937CDF_STATUS sme_close(tHalHandle hHal)
2938{
2939 CDF_STATUS status = CDF_STATUS_E_FAILURE;
2940 CDF_STATUS fail_status = CDF_STATUS_SUCCESS;
2941 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2942
2943 if (!pMac)
2944 return CDF_STATUS_E_FAILURE;
2945
2946 /* Note: pSession will be invalid from here on, do not access */
2947 status = csr_close(pMac);
2948 if (!CDF_IS_STATUS_SUCCESS(status)) {
2949 sms_log(pMac, LOGE,
2950 "csr_close failed during sme close with status=%d",
2951 status);
2952 fail_status = status;
2953 }
2954#ifndef WLAN_FEATURE_MBSSID
2955 status = wlansap_close(cds_get_global_context());
2956 if (!CDF_IS_STATUS_SUCCESS(status)) {
2957 sms_log(pMac, LOGE,
2958 "WLANSAP_close failed during sme close with status=%d",
2959 status);
2960 fail_status = status;
2961 }
2962#endif
2963
2964#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2965 status = sme_qos_close(pMac);
2966 if (!CDF_IS_STATUS_SUCCESS(status)) {
2967 sms_log(pMac, LOGE,
2968 "Qos close failed during sme close with status=%d",
2969 status);
2970 fail_status = status;
2971 }
2972#endif
2973#ifdef FEATURE_OEM_DATA_SUPPORT
2974 status = oem_data_oem_data_req_close(hHal);
2975 if (!CDF_IS_STATUS_SUCCESS(status)) {
2976 sms_log(pMac, LOGE,
2977 "OEM DATA REQ close failed during sme close with status=%d",
2978 status);
2979 fail_status = status;
2980 }
2981#endif
2982 status = sme_ps_close(hHal);
2983 if (!CDF_IS_STATUS_SUCCESS(status)) {
2984 sms_log(pMac, LOGE,
2985 "sme_ps_close failed during smeClose status=%d",
2986 status);
2987 fail_status = status;
2988 }
2989
2990#if defined WLAN_FEATURE_VOWIFI
2991 status = rrm_close(hHal);
2992 if (!CDF_IS_STATUS_SUCCESS(status)) {
2993 sms_log(pMac, LOGE,
2994 "RRM close failed during sme close with status=%d",
2995 status);
2996 fail_status = status;
2997 }
2998#endif
2999
3000 sme_p2p_close(hHal);
3001
3002 free_sme_cmd_list(pMac);
3003
3004 if (!CDF_IS_STATUS_SUCCESS
3005 (cdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock))) {
3006 fail_status = CDF_STATUS_E_FAILURE;
3007 }
3008
3009 if (!CDF_IS_STATUS_SUCCESS(fail_status)) {
3010 status = fail_status;
3011 }
3012
3013 pMac->sme.state = SME_STATE_STOP;
3014
3015 return status;
3016}
3017
3018/**
3019 * sme_scan_request() - wrapper function to Request a 11d or full scan from CSR.
3020 * @hal: hal global context
3021 * @session_id: session id
3022 * @scan_req: scan req
3023 * @callback: a callback function that scan calls upon finish, will not
3024 * be called if csr_scan_request returns error
3025 * @ctx: a pointer passed in for the callback
3026 *
3027 * This is a wrapper function to Request a 11d or full scan from CSR. This is
3028 * an asynchronous call
3029 *
3030 * Return: Status of operation
3031 */
3032CDF_STATUS sme_scan_request(tHalHandle hal, uint8_t session_id,
3033 tCsrScanRequest *scan_req,
3034 csr_scan_completeCallback callback, void *ctx)
3035{
3036 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3037 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
3038 struct ani_scan_req *scan_msg;
3039 cds_msg_t msg;
3040 uint32_t scan_req_id, scan_count;
3041
3042 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3043 TRACE_CODE_SME_RX_HDD_MSG_SCAN_REQ, session_id,
3044 scan_req->scanType));
3045 if (!mac_ctx->scan.fScanEnable) {
3046 sms_log(mac_ctx, LOGE, FL("fScanEnable false"));
3047 return status;
3048 }
3049
3050 scan_count = csr_ll_count(&mac_ctx->sme.smeScanCmdActiveList);
3051 if (scan_count >= mac_ctx->scan.max_scan_count) {
3052 sms_log(mac_ctx, LOGE, FL("Max scan reached"));
3053 return CDF_STATUS_E_FAILURE;
3054 }
3055 wma_get_scan_id(&scan_req_id);
3056 scan_req->scan_id = scan_req_id;
3057
3058 status = sme_acquire_global_lock(&mac_ctx->sme);
3059 if (!CDF_IS_STATUS_SUCCESS(status)) {
3060 sms_log(mac_ctx, LOGE, FL("Unable to acquire lock"));
3061 return status;
3062 }
3063 sms_log(mac_ctx, LOG1, FL(" called"));
3064 scan_msg = cdf_mem_malloc(sizeof(struct ani_scan_req));
3065 if (NULL == scan_msg) {
3066 sms_log(mac_ctx, LOGE,
3067 " scan_req: failed to allocate mem for msg");
3068 sme_release_global_lock(&mac_ctx->sme);
3069 return CDF_STATUS_E_NOMEM;
3070 }
3071 scan_msg->msg_type = eWNI_SME_SCAN_CMD;
3072 scan_msg->msg_len = (uint16_t) sizeof(struct ani_scan_req);
3073 scan_msg->session_id = session_id;
3074 scan_msg->callback = callback;
3075 scan_msg->ctx = ctx;
3076 scan_msg->scan_param = cdf_mem_malloc(sizeof(tCsrScanRequest));
3077 if (NULL == scan_msg->scan_param) {
3078 sms_log(mac_ctx, LOGE,
3079 "scan_req:failed to allocate mem for scanreq");
3080 sme_release_global_lock(&mac_ctx->sme);
3081 cdf_mem_free(scan_msg);
3082 return CDF_STATUS_E_NOMEM;
3083 }
3084 csr_scan_copy_request(mac_ctx, scan_msg->scan_param, scan_req);
3085 msg.type = eWNI_SME_SCAN_CMD;
3086 msg.bodyptr = scan_msg;
3087 msg.reserved = 0;
3088 msg.bodyval = 0;
3089 if (CDF_STATUS_SUCCESS !=
3090 cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
3091 sms_log(mac_ctx, LOGE,
3092 " sme_scan_req failed to post msg");
3093 csr_scan_free_request(mac_ctx, scan_msg->scan_param);
3094 cdf_mem_free(scan_msg);
3095 status = CDF_STATUS_E_FAILURE;
3096 }
3097 sme_release_global_lock(&mac_ctx->sme);
3098 return status;
3099}
3100
3101/* ---------------------------------------------------------------------------
3102 \fn sme_scan_get_result
3103 \brief a wrapper function to request scan results from CSR.
3104 This is a synchronous call
3105 \param pFilter - If pFilter is NULL, all cached results are returned
3106 \param phResult - an object for the result.
3107 \return CDF_STATUS
3108 ---------------------------------------------------------------------------*/
3109CDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
3110 tCsrScanResultFilter *pFilter,
3111 tScanResultHandle *phResult)
3112{
3113 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3114 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3115
3116 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3117 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
3118 0));
3119 sms_log(pMac, LOG2, FL("enter"));
3120 status = sme_acquire_global_lock(&pMac->sme);
3121 if (CDF_IS_STATUS_SUCCESS(status)) {
3122 status = csr_scan_get_result(hHal, pFilter, phResult);
3123 sme_release_global_lock(&pMac->sme);
3124 }
3125 sms_log(pMac, LOG2, FL("exit status %d"), status);
3126
3127 return status;
3128}
3129
3130/**
3131 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
3132 * channel id from CSR by filtering the
3133 * result which matches our roam profile.
3134 * @profile: SAP adapter
3135 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
3136 * best ap from scan cache.
3137 *
3138 * This function is written to get AP's channel id from CSR by filtering
3139 * the result which matches our roam profile. This is a synchronous call.
3140 *
3141 * Return: CDF_STATUS.
3142 */
3143CDF_STATUS sme_get_ap_channel_from_scan_cache(tHalHandle hal_handle,
3144 tCsrRoamProfile *profile,
3145 tScanResultHandle *scan_cache,
3146 uint8_t *ap_chnl_id)
3147{
3148 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3149 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
3150 tCsrScanResultFilter *scan_filter = NULL;
3151 tScanResultHandle filtered_scan_result = NULL;
3152 tSirBssDescription first_ap_profile;
3153
3154 if (NULL == mac_ctx) {
3155 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3156 FL("mac_ctx is NULL"));
3157 return CDF_STATUS_E_FAILURE;
3158 }
3159 scan_filter = cdf_mem_malloc(sizeof(tCsrScanResultFilter));
3160 if (NULL == scan_filter) {
3161 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3162 FL("scan_filter mem alloc failed"));
3163 return CDF_STATUS_E_FAILURE;
3164 } else {
3165 cdf_mem_set(scan_filter, sizeof(tCsrScanResultFilter), 0);
3166 cdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
3167
3168 if (NULL == profile) {
3169 scan_filter->EncryptionType.numEntries = 1;
3170 scan_filter->EncryptionType.encryptionType[0]
3171 = eCSR_ENCRYPT_TYPE_NONE;
3172 } else {
3173 /* Here is the profile we need to connect to */
3174 status = csr_roam_prepare_filter_from_profile(mac_ctx,
3175 profile,
3176 scan_filter);
3177 }
3178
3179 if (CDF_STATUS_SUCCESS == status) {
3180 /* Save the WPS info */
3181 if (NULL != profile) {
3182 scan_filter->bWPSAssociation =
3183 profile->bWPSAssociation;
3184 scan_filter->bOSENAssociation =
3185 profile->bOSENAssociation;
3186 } else {
3187 scan_filter->bWPSAssociation = 0;
3188 scan_filter->bOSENAssociation = 0;
3189 }
3190 } else {
3191 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3192 FL("Preparing the profile filter failed"));
3193 cdf_mem_free(scan_filter);
3194 return CDF_STATUS_E_FAILURE;
3195 }
3196 }
3197 status = sme_acquire_global_lock(&mac_ctx->sme);
3198 if (CDF_STATUS_SUCCESS == status) {
3199 status = csr_scan_get_result(hal_handle, scan_filter,
3200 &filtered_scan_result);
3201 if (CDF_STATUS_SUCCESS == status) {
3202 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
3203 &first_ap_profile);
3204 *scan_cache = filtered_scan_result;
3205 if (0 != first_ap_profile.channelId) {
3206 *ap_chnl_id = first_ap_profile.channelId;
3207 CDF_TRACE(CDF_MODULE_ID_SME,
3208 CDF_TRACE_LEVEL_ERROR,
3209 FL("Found best AP & its on chnl[%d]"),
3210 first_ap_profile.channelId);
3211 } else {
3212 /*
3213 * This means scan result is empty
3214 * so set the channel to zero, caller should
3215 * take of zero channel id case.
3216 */
3217 *ap_chnl_id = 0;
3218 CDF_TRACE(CDF_MODULE_ID_SME,
3219 CDF_TRACE_LEVEL_ERROR,
3220 FL("Scan is empty, set chnl to 0"));
3221 status = CDF_STATUS_E_FAILURE;
3222 }
3223 } else {
3224 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3225 FL("Failed to get scan get result"));
3226 status = CDF_STATUS_E_FAILURE;
3227 }
3228 csr_free_scan_filter(mac_ctx, scan_filter);
3229 sme_release_global_lock(&mac_ctx->sme);
3230 } else {
3231 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3232 FL("Aquiring lock failed"));
3233 status = CDF_STATUS_E_FAILURE;
3234 }
3235
3236 cdf_mem_free(scan_filter);
3237
3238 return status;
3239}
3240
3241/**
3242 * sme_store_joinreq_param() - This function will pass station's join
3243 * request to store to csr.
3244 * @hal_handle: pointer to hal context.
3245 * @profile: pointer to station's roam profile.
3246 * @scan_cache: pointer to station's scan cache.
3247 * @roam_id: reference to roam_id variable being passed.
3248 * @session_id: station's session id.
3249 *
3250 * This function will pass station's join request further down to csr
3251 * to store it. this stored parameter will be used later.
3252 *
3253 * Return: true or false based on function's overall success.
3254 **/
3255bool sme_store_joinreq_param(tHalHandle hal_handle,
3256 tCsrRoamProfile *profile,
3257 tScanResultHandle scan_cache,
3258 uint32_t *roam_id,
3259 uint32_t session_id)
3260{
3261 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
3262 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3263 bool ret_status = true;
3264
3265 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3266 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
3267 session_id, 0));
3268 status = sme_acquire_global_lock(&mac_ctx->sme);
3269 if (CDF_STATUS_SUCCESS == status) {
3270 if (false == csr_store_joinreq_param(mac_ctx, profile,
3271 scan_cache, roam_id, session_id)) {
3272 ret_status = false;
3273 }
3274 sme_release_global_lock(&mac_ctx->sme);
3275 } else {
3276 ret_status = false;
3277 }
3278
3279 return ret_status;
3280}
3281
3282/**
3283 * sme_clear_joinreq_param() - This function will pass station's clear
3284 * the join request to csr.
3285 * @hal_handle: pointer to hal context.
3286 * @session_id: station's session id.
3287 *
3288 * This function will pass station's clear join request further down to csr
3289 * to cleanup.
3290 *
3291 * Return: true or false based on function's overall success.
3292 **/
3293bool sme_clear_joinreq_param(tHalHandle hal_handle,
3294 uint32_t session_id)
3295{
3296 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
3297 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3298 bool ret_status = true;
3299
3300 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3301 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
3302 session_id, 0));
3303 status = sme_acquire_global_lock(&mac_ctx->sme);
3304 if (CDF_STATUS_SUCCESS == status) {
3305 if (false == csr_clear_joinreq_param(mac_ctx,
3306 session_id)) {
3307 ret_status = false;
3308 }
3309 sme_release_global_lock(&mac_ctx->sme);
3310 } else {
3311 ret_status = false;
3312 }
3313
3314 return ret_status;
3315}
3316
3317/**
3318 * sme_issue_stored_joinreq() - This function will issues station's stored
3319 * the join request to csr.
3320 * @hal_handle: pointer to hal context.
3321 * @roam_id: reference to roam_id variable being passed.
3322 * @session_id: station's session id.
3323 *
3324 * This function will issue station's stored join request further down to csr
3325 * to proceed forward.
3326 *
3327 * Return: CDF_STATUS_SUCCESS or CDF_STATUS_E_FAILURE.
3328 **/
3329CDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
3330 uint32_t *roam_id,
3331 uint32_t session_id)
3332{
3333 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
3334 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3335 CDF_STATUS ret_status = CDF_STATUS_SUCCESS;
3336
3337 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3338 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
3339 session_id, 0));
3340 status = sme_acquire_global_lock(&mac_ctx->sme);
3341 if (CDF_STATUS_SUCCESS == status) {
3342 if (CDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
3343 roam_id,
3344 session_id)) {
3345 ret_status = CDF_STATUS_E_FAILURE;
3346 }
3347 sme_release_global_lock(&mac_ctx->sme);
3348 } else {
3349 csr_clear_joinreq_param(mac_ctx, session_id);
3350 ret_status = CDF_STATUS_E_FAILURE;
3351 }
3352 return ret_status;
3353}
3354
3355/* ---------------------------------------------------------------------------
3356 \fn sme_scan_flush_result
3357 \brief a wrapper function to request CSR to clear scan results.
3358 This is a synchronous call
3359 \return CDF_STATUS
3360 ---------------------------------------------------------------------------*/
3361CDF_STATUS sme_scan_flush_result(tHalHandle hHal)
3362{
3363 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3364 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3365
3366 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3367 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
3368 0, 0));
3369 status = sme_acquire_global_lock(&pMac->sme);
3370 if (CDF_IS_STATUS_SUCCESS(status)) {
3371 status = csr_scan_flush_result(hHal);
3372 sme_release_global_lock(&pMac->sme);
3373 }
3374
3375 return status;
3376}
3377
3378/* ---------------------------------------------------------------------------
3379 \fn sme_filter_scan_results
3380 \brief a wrapper function to request CSR to clear scan results.
3381 This is a synchronous call
3382 \param tHalHandle - HAL context handle
3383 \param sessionId - session id
3384 \return CDF_STATUS
3385 ---------------------------------------------------------------------------*/
3386CDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
3387{
3388 CDF_STATUS status = CDF_STATUS_SUCCESS;
3389 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3390
3391 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3392 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
3393 sessionId, 0));
3394 status = sme_acquire_global_lock(&pMac->sme);
3395 if (CDF_IS_STATUS_SUCCESS(status)) {
3396 csr_scan_filter_results(pMac);
3397 sme_release_global_lock(&pMac->sme);
3398 }
3399
3400 return status;
3401}
3402
3403CDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
3404{
3405 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3406 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3407
3408 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3409 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
3410 sessionId, 0));
3411 status = sme_acquire_global_lock(&pMac->sme);
3412 if (CDF_IS_STATUS_SUCCESS(status)) {
3413 status = csr_scan_flush_selective_result(hHal, true);
3414 sme_release_global_lock(&pMac->sme);
3415 }
3416
3417 return status;
3418}
3419
3420/* ---------------------------------------------------------------------------
3421 \fn sme_scan_result_get_first
3422 \brief a wrapper function to request CSR to returns the first element of
3423 scan result.
3424 This is a synchronous call
3425 \param hScanResult - returned from csr_scan_get_result
3426 \return tCsrScanResultInfo * - NULL if no result
3427 ---------------------------------------------------------------------------*/
3428tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
3429 tScanResultHandle hScanResult)
3430{
3431 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3432 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3433 tCsrScanResultInfo *pRet = NULL;
3434
3435 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3436 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
3437 NO_SESSION, 0));
3438 status = sme_acquire_global_lock(&pMac->sme);
3439 if (CDF_IS_STATUS_SUCCESS(status)) {
3440 pRet = csr_scan_result_get_first(pMac, hScanResult);
3441 sme_release_global_lock(&pMac->sme);
3442 }
3443
3444 return pRet;
3445}
3446
3447/* ---------------------------------------------------------------------------
3448 \fn sme_scan_result_get_next
3449 \brief a wrapper function to request CSR to returns the next element of
3450 scan result. It can be called without calling csr_scan_result_get_first
3451 first
3452 This is a synchronous call
3453 \param hScanResult - returned from csr_scan_get_result
3454 \return Null if no result or reach the end
3455 ---------------------------------------------------------------------------*/
3456tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
3457 tScanResultHandle hScanResult)
3458{
3459 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3460 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3461 tCsrScanResultInfo *pRet = NULL;
3462
3463 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3464 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETNEXT,
3465 NO_SESSION, 0));
3466 status = sme_acquire_global_lock(&pMac->sme);
3467 if (CDF_IS_STATUS_SUCCESS(status)) {
3468 pRet = csr_scan_result_get_next(pMac, hScanResult);
3469 sme_release_global_lock(&pMac->sme);
3470 }
3471
3472 return pRet;
3473}
3474
3475/* ---------------------------------------------------------------------------
3476 \fn sme_scan_result_purge
3477 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
3478 in the list and free memory for each item
3479 This is a synchronous call
3480 \param hScanResult - returned from csr_scan_get_result. hScanResult is
3481 considered gone by
3482 calling this function and even before this function reutrns.
3483 \return CDF_STATUS
3484 ---------------------------------------------------------------------------*/
3485CDF_STATUS sme_scan_result_purge(tHalHandle hHal, tScanResultHandle hScanResult)
3486{
3487 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3488 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3489
3490 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3491 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3492 NO_SESSION, 0));
3493 status = sme_acquire_global_lock(&pMac->sme);
3494 if (CDF_IS_STATUS_SUCCESS(status)) {
3495 status = csr_scan_result_purge(hHal, hScanResult);
3496 sme_release_global_lock(&pMac->sme);
3497 }
3498
3499 return status;
3500}
3501
3502/* ---------------------------------------------------------------------------
3503 \fn sme_scan_get_pmkid_candidate_list
3504 \brief a wrapper function to return the PMKID candidate list
3505 This is a synchronous call
3506 \param pPmkidList - caller allocated buffer point to an array of
3507 tPmkidCandidateInfo
3508 \param pNumItems - pointer to a variable that has the number of
3509 tPmkidCandidateInfo allocated when retruning, this is
3510 either the number needed or number of items put into
3511 pPmkidList
3512 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
3513 big enough and pNumItems
3514 has the number of tPmkidCandidateInfo.
3515 \Note: pNumItems is a number of tPmkidCandidateInfo,
3516 not sizeof(tPmkidCandidateInfo) * something
3517 ---------------------------------------------------------------------------*/
3518CDF_STATUS sme_scan_get_pmkid_candidate_list(tHalHandle hHal, uint8_t sessionId,
3519 tPmkidCandidateInfo *pPmkidList,
3520 uint32_t *pNumItems)
3521{
3522 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3523 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3524
3525 status = sme_acquire_global_lock(&pMac->sme);
3526 if (CDF_IS_STATUS_SUCCESS(status)) {
3527 status =
3528 csr_scan_get_pmkid_candidate_list(pMac, sessionId,
3529 pPmkidList,
3530 pNumItems);
3531 sme_release_global_lock(&pMac->sme);
3532 }
3533
3534 return status;
3535}
3536
3537eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3538{
3539 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3540 return pMac->roam.configParam.phyMode;
3541}
3542
3543/* ---------------------------------------------------------------------------
3544 \fn sme_get_channel_bonding_mode5_g
3545 \brief get the channel bonding mode for 5G band
3546 \param hHal - HAL handle
3547 \return channel bonding mode for 5G
3548 ---------------------------------------------------------------------------*/
3549uint32_t sme_get_channel_bonding_mode5_g(tHalHandle hHal)
3550{
3551 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3552 tSmeConfigParams smeConfig;
3553
3554 sme_get_config_param(pMac, &smeConfig);
3555
3556 return smeConfig.csrConfig.channelBondingMode5GHz;
3557}
3558
3559/* ---------------------------------------------------------------------------
3560 \fn sme_get_channel_bonding_mode24_g
3561 \brief get the channel bonding mode for 2.4G band
3562 \param hHal - HAL handle
3563 \return channel bonding mode for 2.4G
3564 ---------------------------------------------------------------------------*/
3565uint32_t sme_get_channel_bonding_mode24_g(tHalHandle hHal)
3566{
3567 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3568 tSmeConfigParams smeConfig;
3569
3570 sme_get_config_param(pMac, &smeConfig);
3571
3572 return smeConfig.csrConfig.channelBondingMode24GHz;
3573}
3574
3575/* ---------------------------------------------------------------------------
3576 \fn sme_roam_connect
3577 \brief a wrapper function to request CSR to inititiate an association
3578 This is an asynchronous call.
3579 \param sessionId - the sessionId returned by sme_open_session.
3580 \param pProfile - description of the network to which to connect
3581 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
3582 from csr_scan_get_result
3583 \param pRoamId - to get back the request ID
3584 \return CDF_STATUS
3585 ---------------------------------------------------------------------------*/
3586CDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
3587 tCsrRoamProfile *pProfile, uint32_t *pRoamId)
3588{
3589 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3590 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3591
3592 if (!pMac) {
3593 return CDF_STATUS_E_FAILURE;
3594 }
3595
3596 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3597 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
3598 sms_log(pMac, LOG2, FL("enter"));
3599 status = sme_acquire_global_lock(&pMac->sme);
3600 if (CDF_IS_STATUS_SUCCESS(status)) {
3601 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3602 status =
3603 csr_roam_connect(pMac, sessionId, pProfile,
3604 pRoamId);
3605 } else {
3606 sms_log(pMac, LOGE, FL("invalid sessionID %d"),
3607 sessionId);
3608 status = CDF_STATUS_E_INVAL;
3609 }
3610 sme_release_global_lock(&pMac->sme);
3611 } else {
3612 sms_log(pMac, LOGE, FL("sme_acquire_global_lock failed"));
3613 }
3614
3615 return status;
3616}
3617
3618/* ---------------------------------------------------------------------------
3619
3620 \fn sme_set_phy_mode
3621
3622 \brief Changes the PhyMode.
3623
3624 \param hHal - The handle returned by mac_open.
3625
3626 \param phyMode new phyMode which is to set
3627
3628 \return CDF_STATUS SUCCESS.
3629
3630 -------------------------------------------------------------------------------*/
3631CDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
3632{
3633 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3634
3635 if (NULL == pMac) {
3636 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3637 "%s: invalid context", __func__);
3638 return CDF_STATUS_E_FAILURE;
3639 }
3640
3641 pMac->roam.configParam.phyMode = phyMode;
3642 pMac->roam.configParam.uCfgDot11Mode =
3643 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
3644 pMac->roam.configParam.phyMode,
3645 pMac->roam.configParam.
3646 ProprietaryRatesEnabled);
3647
3648 return CDF_STATUS_SUCCESS;
3649}
3650
3651/* ---------------------------------------------------------------------------
3652 \fn sme_roam_reassoc
3653 \brief a wrapper function to request CSR to inititiate a re-association
3654 \param pProfile - can be NULL to join the currently connected AP. In that
3655 case modProfileFields should carry the modified field(s) which could trigger
3656 reassoc
3657 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
3658 that might need modification dynamically once STA is up & running and this
3659 could trigger a reassoc
3660 \param pRoamId - to get back the request ID
3661 \return CDF_STATUS
3662 -------------------------------------------------------------------------------*/
3663CDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
3664 tCsrRoamProfile *pProfile,
3665 tCsrRoamModifyProfileFields modProfileFields,
3666 uint32_t *pRoamId, bool fForce)
3667{
3668 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3669 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3670
3671 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3672 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
3673 sms_log(pMac, LOG2, FL("enter"));
3674 status = sme_acquire_global_lock(&pMac->sme);
3675 if (CDF_IS_STATUS_SUCCESS(status)) {
3676 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3677 if ((NULL == pProfile) && (fForce == 1)) {
3678 status =
3679 csr_reassoc(pMac, sessionId,
3680 &modProfileFields, pRoamId,
3681 fForce);
3682 } else {
3683 status =
3684 csr_roam_reassoc(pMac, sessionId, pProfile,
3685 modProfileFields, pRoamId);
3686 }
3687 } else {
3688 status = CDF_STATUS_E_INVAL;
3689 }
3690 sme_release_global_lock(&pMac->sme);
3691 }
3692
3693 return status;
3694}
3695
3696/* ---------------------------------------------------------------------------
3697 \fn sme_roam_connect_to_last_profile
3698 \brief a wrapper function to request CSR to disconnect and reconnect with
3699 the same profile
3700 This is an asynchronous call.
3701 \return CDF_STATUS. It returns fail if currently connected
3702 ---------------------------------------------------------------------------*/
3703CDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
3704{
3705 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3706 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3707
3708 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3709 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3710 sessionId, 0));
3711 status = sme_acquire_global_lock(&pMac->sme);
3712 if (CDF_IS_STATUS_SUCCESS(status)) {
3713 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3714 status = csr_roam_connect_to_last_profile(pMac, sessionId);
3715 } else {
3716 status = CDF_STATUS_E_INVAL;
3717 }
3718 sme_release_global_lock(&pMac->sme);
3719 }
3720
3721 return status;
3722}
3723
3724/* ---------------------------------------------------------------------------
3725 \fn sme_roam_disconnect
3726 \brief a wrapper function to request CSR to disconnect from a network
3727 This is an asynchronous call.
3728 \param reason -- To indicate the reason for disconnecting. Currently, only
3729 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
3730 \return CDF_STATUS
3731 ---------------------------------------------------------------------------*/
3732CDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
3733 eCsrRoamDisconnectReason reason)
3734{
3735 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3736 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3737
3738 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3739 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId,
3740 reason));
3741 sms_log(pMac, LOG2, FL("enter"));
3742 status = sme_acquire_global_lock(&pMac->sme);
3743 if (CDF_IS_STATUS_SUCCESS(status)) {
3744 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3745 status = csr_roam_disconnect(pMac, sessionId, reason);
3746 } else {
3747 status = CDF_STATUS_E_INVAL;
3748 }
3749 sme_release_global_lock(&pMac->sme);
3750 }
3751
3752 return status;
3753}
3754
3755/* ---------------------------------------------------------------------------
3756 \fn sme_roam_stop_bss
3757 \brief To stop BSS for Soft AP. This is an asynchronous API.
3758 \param hHal - Global structure
3759 \param sessionId - sessionId of SoftAP
3760 \return CDF_STATUS SUCCESS Roam callback will be called to indicate actual results
3761 -------------------------------------------------------------------------------*/
3762CDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
3763{
3764 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3765 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3766
3767 sms_log(pMac, LOG2, FL("enter"));
3768 status = sme_acquire_global_lock(&pMac->sme);
3769 if (CDF_IS_STATUS_SUCCESS(status)) {
3770 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3771 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId, true);
3772 } else {
3773 status = CDF_STATUS_E_INVAL;
3774 }
3775 sme_release_global_lock(&pMac->sme);
3776 }
3777
3778 return status;
3779}
3780
3781/* ---------------------------------------------------------------------------
3782 \fn sme_roam_disconnect_sta
3783 \brief To disassociate a station. This is an asynchronous API.
3784 \param hHal - Global structure
3785 \param sessionId - sessionId of SoftAP
3786 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
3787 \return CDF_STATUS SUCCESS Roam callback will be called to indicate actual results
3788 -------------------------------------------------------------------------------*/
3789CDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
3790 const uint8_t *pPeerMacAddr)
3791{
3792 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3793 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3794
3795 if (NULL == pMac) {
3796 CDF_ASSERT(0);
3797 return status;
3798 }
3799
3800 status = sme_acquire_global_lock(&pMac->sme);
3801 if (CDF_IS_STATUS_SUCCESS(status)) {
3802 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3803 status = csr_roam_issue_disassociate_sta_cmd(pMac,
3804 sessionId, pPeerMacAddr,
3805 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
3806 } else {
3807 status = CDF_STATUS_E_INVAL;
3808 }
3809 sme_release_global_lock(&pMac->sme);
3810 }
3811
3812 return status;
3813}
3814
3815/**
3816 * sme_roam_deauth_sta() - deauthenticate a station
3817 * @hHal: Global structure
3818 * @sessionId: SessionId of SoftAP
3819 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3820 *
3821 * To disassociate a station. This is an asynchronous API.
3822 *
3823 * Return: CDF_STATUS_SUCCESS on success or another CDF_STATUS error
3824 * code on error. Roam callback will be called to indicate actual
3825 * result
3826 */
3827CDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
3828 struct tagCsrDelStaParams *pDelStaParams)
3829{
3830 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3831 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3832
3833 if (NULL == pMac) {
3834 CDF_ASSERT(0);
3835 return status;
3836 }
3837
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303838 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3839 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3840 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841 status = sme_acquire_global_lock(&pMac->sme);
3842 if (CDF_IS_STATUS_SUCCESS(status)) {
3843 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3844 status =
3845 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3846 pDelStaParams);
3847 } else {
3848 status = CDF_STATUS_E_INVAL;
3849 }
3850 sme_release_global_lock(&pMac->sme);
3851 }
3852
3853 return status;
3854}
3855
3856/* ---------------------------------------------------------------------------
3857 \fn sme_roam_tkip_counter_measures
3858 \brief To start or stop TKIP counter measures. This is an asynchronous API.
3859 \param sessionId - sessionId of SoftAP
3860 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
3861 \return CDF_STATUS
3862 -------------------------------------------------------------------------------*/
3863CDF_STATUS sme_roam_tkip_counter_measures(tHalHandle hHal, uint8_t sessionId,
3864 bool bEnable)
3865{
3866 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3867 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3868
3869 if (NULL == pMac) {
3870 CDF_ASSERT(0);
3871 return status;
3872 }
3873
3874 status = sme_acquire_global_lock(&pMac->sme);
3875 if (CDF_IS_STATUS_SUCCESS(status)) {
3876 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3877 status =
3878 csr_roam_issue_tkip_counter_measures(pMac, sessionId,
3879 bEnable);
3880 } else {
3881 status = CDF_STATUS_E_INVAL;
3882 }
3883 sme_release_global_lock(&pMac->sme);
3884 }
3885
3886 return status;
3887}
3888
3889/* ---------------------------------------------------------------------------
3890 \fn sme_roam_get_associated_stas
3891 \brief To probe the list of associated stations from various modules
3892 of CORE stack.
3893 \This is an asynchronous API.
3894 \param sessionId - sessionId of SoftAP
3895 \param modId - Module from whom list of associtated stations is
3896 to be probed. If an invalid module is passed then
3897 by default CDF_MODULE_ID_PE will be probed.
3898 \param pUsrContext - Opaque HDD context
3899 \param pfnSapEventCallback - Sap event callback in HDD
3900 \param pAssocBuf - Caller allocated memory to be filled with associatd
3901 stations info
3902 \return CDF_STATUS
3903 -------------------------------------------------------------------------------*/
3904CDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
3905 CDF_MODULE_ID modId, void *pUsrContext,
3906 void *pfnSapEventCallback,
3907 uint8_t *pAssocStasBuf)
3908{
3909 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3910 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3911
3912 if (NULL == pMac) {
3913 CDF_ASSERT(0);
3914 return status;
3915 }
3916
3917 status = sme_acquire_global_lock(&pMac->sme);
3918 if (CDF_IS_STATUS_SUCCESS(status)) {
3919 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3920 status =
3921 csr_roam_get_associated_stas(pMac, sessionId, modId,
3922 pUsrContext,
3923 pfnSapEventCallback,
3924 pAssocStasBuf);
3925 } else {
3926 status = CDF_STATUS_E_INVAL;
3927 }
3928 sme_release_global_lock(&pMac->sme);
3929 }
3930
3931 return status;
3932}
3933
3934/* ---------------------------------------------------------------------------
3935 \fn sme_roam_get_wps_session_overlap
3936 \brief To get the WPS PBC session overlap information.
3937 \This is an asynchronous API.
3938 \param sessionId - sessionId of SoftAP
3939 \param pUsrContext - Opaque HDD context
3940 \param pfnSapEventCallback - Sap event callback in HDD
3941 \pRemoveMac - pointer to Mac address which needs to be removed from session
3942 \return CDF_STATUS
3943 -------------------------------------------------------------------------------*/
3944CDF_STATUS sme_roam_get_wps_session_overlap(tHalHandle hHal, uint8_t sessionId,
3945 void *pUsrContext, void
3946 *pfnSapEventCallback,
3947 struct cdf_mac_addr pRemoveMac)
3948{
3949 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3950 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3951
3952 if (NULL == pMac) {
3953 CDF_ASSERT(0);
3954 return status;
3955 }
3956
3957 status = sme_acquire_global_lock(&pMac->sme);
3958 if (CDF_IS_STATUS_SUCCESS(status)) {
3959 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3960 status =
3961 csr_roam_get_wps_session_overlap(pMac, sessionId,
3962 pUsrContext,
3963 pfnSapEventCallback,
3964 pRemoveMac);
3965 } else {
3966 status = CDF_STATUS_E_INVAL;
3967 }
3968 sme_release_global_lock(&pMac->sme);
3969 }
3970
3971 return status;
3972}
3973
3974/* ---------------------------------------------------------------------------
3975 \fn sme_roam_get_connect_state
3976 \brief a wrapper function to request CSR to return the current connect state
3977 of Roaming
3978 This is a synchronous call.
3979 \return CDF_STATUS
3980 ---------------------------------------------------------------------------*/
3981CDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
3982 eCsrConnectState *pState)
3983{
3984 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3985 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3986
3987 status = sme_acquire_global_lock(&pMac->sme);
3988 if (CDF_IS_STATUS_SUCCESS(status)) {
3989 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3990 status =
3991 csr_roam_get_connect_state(pMac, sessionId, pState);
3992 } else {
3993 status = CDF_STATUS_E_INVAL;
3994 }
3995 sme_release_global_lock(&pMac->sme);
3996 }
3997
3998 return status;
3999}
4000
4001/* ---------------------------------------------------------------------------
4002 \fn sme_roam_get_connect_profile
4003 \brief a wrapper function to request CSR to return the current connect
4004 profile. Caller must call csr_roam_free_connect_profile after it is done
4005 and before reuse for another csr_roam_get_connect_profile call.
4006 This is a synchronous call.
4007 \param pProfile - pointer to a caller allocated structure
4008 tCsrRoamConnectedProfile
4009 \return CDF_STATUS. Failure if not connected
4010 ---------------------------------------------------------------------------*/
4011CDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
4012 tCsrRoamConnectedProfile *pProfile)
4013{
4014 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4015 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4016
4017 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4018 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
4019 sessionId, 0));
4020 status = sme_acquire_global_lock(&pMac->sme);
4021 if (CDF_IS_STATUS_SUCCESS(status)) {
4022 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4023 status =
4024 csr_roam_get_connect_profile(pMac, sessionId, pProfile);
4025 } else {
4026 status = CDF_STATUS_E_INVAL;
4027 }
4028 sme_release_global_lock(&pMac->sme);
4029 }
4030
4031 return status;
4032}
4033
4034/* ---------------------------------------------------------------------------
4035 \fn sme_roam_free_connect_profile
4036 \brief a wrapper function to request CSR to free and reinitialize the
4037 profile returned previously by csr_roam_get_connect_profile.
4038 This is a synchronous call.
4039 \param pProfile - pointer to a caller allocated structure
4040 tCsrRoamConnectedProfile
4041 \return CDF_STATUS.
4042 ---------------------------------------------------------------------------*/
4043CDF_STATUS sme_roam_free_connect_profile(tHalHandle hHal,
4044 tCsrRoamConnectedProfile *pProfile)
4045{
4046 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4047 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4048
4049 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4050 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
4051 NO_SESSION, 0));
4052 status = sme_acquire_global_lock(&pMac->sme);
4053 if (CDF_IS_STATUS_SUCCESS(status)) {
4054 status = csr_roam_free_connect_profile(pMac, pProfile);
4055 sme_release_global_lock(&pMac->sme);
4056 }
4057
4058 return status;
4059}
4060
4061/* ---------------------------------------------------------------------------
4062 \fn sme_roam_set_pmkid_cache
4063 \brief a wrapper function to request CSR to return the PMKID candidate list
4064 This is a synchronous call.
4065 \param pPMKIDCache - caller allocated buffer point to an array of
4066 tPmkidCacheInfo
4067 \param numItems - a variable that has the number of tPmkidCacheInfo
4068 allocated when retruning, this is either the number needed
4069 or number of items put into pPMKIDCache
4070 \param update_entire_cache - this bool value specifies if the entire pmkid
4071 cache should be overwritten or should it be
4072 updated entry by entry.
4073 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
4074 big enough and pNumItems has the number of
4075 tPmkidCacheInfo.
4076 \Note: pNumItems is a number of tPmkidCacheInfo,
4077 not sizeof(tPmkidCacheInfo) * something
4078 ---------------------------------------------------------------------------*/
4079CDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
4080 tPmkidCacheInfo *pPMKIDCache,
4081 uint32_t numItems, bool update_entire_cache)
4082{
4083 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4084 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4085
4086 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4087 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
4088 numItems));
4089 status = sme_acquire_global_lock(&pMac->sme);
4090 if (CDF_IS_STATUS_SUCCESS(status)) {
4091 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4092 status =
4093 csr_roam_set_pmkid_cache(pMac, sessionId, pPMKIDCache,
4094 numItems, update_entire_cache);
4095 } else {
4096 status = CDF_STATUS_E_INVAL;
4097 }
4098 sme_release_global_lock(&pMac->sme);
4099 }
4100
4101 return status;
4102}
4103
4104CDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
4105 const uint8_t *pBSSId, bool flush_cache)
4106{
4107 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4108 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05304109
4110 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4111 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
4112 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 status = sme_acquire_global_lock(&pMac->sme);
4114 if (CDF_IS_STATUS_SUCCESS(status)) {
4115 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4116 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
4117 pBSSId, flush_cache);
4118 } else {
4119 status = CDF_STATUS_E_INVAL;
4120 }
4121 sme_release_global_lock(&pMac->sme);
4122 }
4123 return status;
4124}
4125
4126#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4127/* ---------------------------------------------------------------------------
4128 * \fn sme_roam_set_psk_pmk
4129 * \brief a wrapper function to request CSR to save PSK/PMK
4130 * This is a synchronous call.
4131 * \param hHal - Global structure
4132 * \param sessionId - SME sessionId
4133 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
4134 * \param pmk_len - Length could be only 16 bytes in case if LEAP
4135 * connections. Need to pass this information to
4136 * firmware.
4137 * \return CDF_STATUS -status whether PSK/PMK is set or not
4138 *---------------------------------------------------------------------------
4139 */
4140CDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
4141 uint8_t *pPSK_PMK, size_t pmk_len)
4142{
4143 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4144 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4145 status = sme_acquire_global_lock(&pMac->sme);
4146 if (CDF_IS_STATUS_SUCCESS(status)) {
4147 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4148 status =
4149 csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
4150 pmk_len);
4151 } else {
4152 status = CDF_STATUS_E_INVAL;
4153 }
4154 sme_release_global_lock(&pMac->sme);
4155 }
4156 return status;
4157}
4158#endif
4159/* ---------------------------------------------------------------------------
4160 \fn sme_roam_get_security_req_ie
4161 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
4162 passes to PE to JOIN request or START_BSS request
4163 This is a synchronous call.
4164 \param pLen - caller allocated memory that has the length of pBuf as input.
4165 Upon returned, *pLen has the needed or IE length in pBuf.
4166 \param pBuf - Caller allocated memory that contain the IE field, if any,
4167 upon return
4168 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
4169 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
4170 big enough
4171 ---------------------------------------------------------------------------*/
4172CDF_STATUS sme_roam_get_security_req_ie(tHalHandle hHal, uint8_t sessionId,
4173 uint32_t *pLen, uint8_t *pBuf,
4174 eCsrSecurityType secType)
4175{
4176 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4177 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4178
4179 status = sme_acquire_global_lock(&pMac->sme);
4180 if (CDF_IS_STATUS_SUCCESS(status)) {
4181 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4182 status =
4183 csr_roam_get_wpa_rsn_req_ie(hHal, sessionId, pLen, pBuf);
4184 } else {
4185 status = CDF_STATUS_E_INVAL;
4186 }
4187 sme_release_global_lock(&pMac->sme);
4188 }
4189
4190 return status;
4191}
4192
4193/* ---------------------------------------------------------------------------
4194 \fn sme_roam_get_security_rsp_ie
4195 \brief a wrapper function to request CSR to return the WPA or RSN or
4196 WAPI IE from the beacon or probe rsp if connected
4197 This is a synchronous call.
4198 \param pLen - caller allocated memory that has the length of pBuf as input.
4199 Upon returned, *pLen has the needed or IE length in pBuf.
4200 \param pBuf - Caller allocated memory that contain the IE field, if any,
4201 upon return
4202 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
4203 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
4204 big enough
4205 ---------------------------------------------------------------------------*/
4206CDF_STATUS sme_roam_get_security_rsp_ie(tHalHandle hHal, uint8_t sessionId,
4207 uint32_t *pLen, uint8_t *pBuf,
4208 eCsrSecurityType secType)
4209{
4210 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4211 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4212
4213 status = sme_acquire_global_lock(&pMac->sme);
4214 if (CDF_IS_STATUS_SUCCESS(status)) {
4215 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4216 status =
4217 csr_roam_get_wpa_rsn_rsp_ie(pMac, sessionId, pLen, pBuf);
4218 } else {
4219 status = CDF_STATUS_E_INVAL;
4220 }
4221 sme_release_global_lock(&pMac->sme);
4222 }
4223
4224 return status;
4225
4226}
4227
4228/* ---------------------------------------------------------------------------
4229 \fn sme_roam_get_num_pmkid_cache
4230 \brief a wrapper function to request CSR to return number of PMKID cache
4231 entries
4232 This is a synchronous call.
4233 \return uint32_t - the number of PMKID cache entries
4234 ---------------------------------------------------------------------------*/
4235uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
4236{
4237 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4238 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4239 uint32_t numPmkidCache = 0;
4240
4241 status = sme_acquire_global_lock(&pMac->sme);
4242 if (CDF_IS_STATUS_SUCCESS(status)) {
4243 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4244 numPmkidCache =
4245 csr_roam_get_num_pmkid_cache(pMac, sessionId);
4246 status = CDF_STATUS_SUCCESS;
4247 } else {
4248 status = CDF_STATUS_E_INVAL;
4249 }
4250 sme_release_global_lock(&pMac->sme);
4251 }
4252
4253 return numPmkidCache;
4254}
4255
4256/* ---------------------------------------------------------------------------
4257 \fn sme_roam_get_pmkid_cache
4258 \brief a wrapper function to request CSR to return PMKID cache from CSR
4259 This is a synchronous call.
4260 \param pNum - caller allocated memory that has the space of the number of
4261 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
4262 needed or actually number in tPmkidCacheInfo.
4263 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
4264 any, upon return
4265 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
4266 big enough
4267 ---------------------------------------------------------------------------*/
4268CDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
4269 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
4270{
4271 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4272 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4273
4274 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4275 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
4276 0));
4277 status = sme_acquire_global_lock(&pMac->sme);
4278 if (CDF_IS_STATUS_SUCCESS(status)) {
4279 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4280 status =
4281 csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
4282 pPmkidCache);
4283 } else {
4284 status = CDF_STATUS_E_INVAL;
4285 }
4286 sme_release_global_lock(&pMac->sme);
4287 }
4288
4289 return status;
4290}
4291
4292/* ---------------------------------------------------------------------------
4293 \fn sme_get_config_param
4294 \brief a wrapper function that HDD calls to get the global settings
4295 currently maintained by CSR.
4296 This is a synchronous call.
4297 \param pParam - caller allocated memory
4298 \return CDF_STATUS
4299 ---------------------------------------------------------------------------*/
4300CDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
4301{
4302 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4303 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4304
4305 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4306 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
4307 status = sme_acquire_global_lock(&pMac->sme);
4308 if (CDF_IS_STATUS_SUCCESS(status)) {
4309 status = csr_get_config_param(pMac, &pParam->csrConfig);
4310 if (status != CDF_STATUS_SUCCESS) {
4311 sms_log(pMac, LOGE, "%s csr_get_config_param failed",
4312 __func__);
4313 sme_release_global_lock(&pMac->sme);
4314 return status;
4315 }
4316#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
4317 pParam->sap_channel_avoidance = pMac->sap.sap_channel_avoidance;
4318#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
4319 pParam->max_intf_count = pMac->sme.max_intf_count;
4320 pParam->enableSelfRecovery = pMac->sme.enableSelfRecovery;
Gupta, Kapile1044062015-10-26 14:56:30 +05304321 pParam->pnoOffload = pMac->pnoOffload;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 pParam->f_prefer_non_dfs_on_radar =
4323 pMac->f_prefer_non_dfs_on_radar;
4324 pParam->policy_manager_enabled = pMac->policy_manager_enabled;
4325 pParam->fine_time_meas_cap = pMac->fine_time_meas_cap;
4326 pParam->dual_mac_feature_disable =
4327 pMac->dual_mac_feature_disable;
4328 pParam->is_ps_enabled = pMac->sme.ps_global_info.ps_enabled;
4329 pParam->pnoOffload = pMac->pnoOffload;
4330 pParam->fEnableDebugLog = pMac->fEnableDebugLog;
4331 pParam->enable5gEBT = pMac->enable5gEBT;
4332 pParam->f_sta_miracast_mcc_rest_time_val =
4333 pMac->f_sta_miracast_mcc_rest_time_val;
Varun Reddy Yeturub43fda12015-09-10 18:16:21 -07004334 sme_update_roam_pno_channel_prediction_config(pMac, pParam,
4335 ROAM_CONFIG_TO_SME_CONFIG);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07004336 pParam->early_stop_scan_enable =
4337 pMac->roam.configParam.early_stop_scan_enable;
4338 pParam->early_stop_scan_min_threshold =
4339 pMac->roam.configParam.early_stop_scan_min_threshold;
4340 pParam->early_stop_scan_max_threshold =
4341 pMac->roam.configParam.early_stop_scan_max_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342 sme_release_global_lock(&pMac->sme);
4343 }
4344
4345 return status;
4346}
4347
4348/**
4349 * sme_cfg_set_int() - Sets the cfg parameter value.
4350 * @hal: Handle to hal.
4351 * @cfg_id: Configuration parameter ID.
4352 * @value: value to be saved in the cfg parameter.
4353 *
4354 * This function sets the string value in cfg parameter.
4355 *
4356 * Return: CDF_STATUS
4357 */
4358CDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
4359{
4360 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4361 CDF_STATUS status = CDF_STATUS_SUCCESS;
4362
4363 if (eSIR_SUCCESS != cfg_set_int(pmac, cfg_id, value))
4364 status = CDF_STATUS_E_FAILURE;
4365
4366 return status;
4367}
4368
4369/**
4370 * sme_cfg_set_str() - Sets the cfg parameter string.
4371 * @hal: Handle to hal.
4372 * @cfg_id: Configuration parameter ID.
4373 * @str: Pointer to the string buffer.
4374 * @length: Length of the string.
4375 *
4376 * This function sets the string value in cfg parameter.
4377 *
4378 * Return: CDF_STATUS
4379 */
4380CDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
4381 uint32_t length)
4382{
4383 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4384 CDF_STATUS status = CDF_STATUS_SUCCESS;
4385
4386 if (eSIR_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
4387 status = CDF_STATUS_E_FAILURE;
4388
4389 return status;
4390}
4391
4392/**
4393 * sme_cfg_get_int() - Gets the cfg parameter value.
4394 * @hal: Handle to hal.
4395 * @cfg_id: Configuration parameter ID.
4396 * @cfg_value: Pointer to variable in which cfg value
4397 * will be saved.
4398 *
4399 * This function gets the value of the cfg parameter.
4400 *
4401 * Return: CDF_STATUS
4402 */
4403CDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
4404{
4405 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4406 CDF_STATUS status = CDF_STATUS_SUCCESS;
4407
4408 if (eSIR_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
4409 status = CDF_STATUS_E_FAILURE;
4410
4411 return status;
4412}
4413
4414/**
4415 * sme_cfg_get_str() - Gets the cfg parameter string.
4416 * @hal: Handle to hal.
4417 * @cfg_id: Configuration parameter ID.
4418 * @str: Pointer to the string buffer.
4419 * @length: Pointer to length of the string.
4420 *
4421 * This function gets the string value of the cfg parameter.
4422 *
4423 * Return: CDF_STATUS
4424 */
4425CDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
4426 uint32_t *length)
4427{
4428 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4429 CDF_STATUS status = CDF_STATUS_SUCCESS;
4430
4431 if (eSIR_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
4432 status = CDF_STATUS_E_INVAL;
4433
4434 return status;
4435}
4436
4437/* ---------------------------------------------------------------------------
4438 \fn sme_get_modify_profile_fields
4439 \brief HDD or SME - QOS calls this function to get the current values of
4440 connected profile fields, changing which can cause reassoc.
4441 This function must be called after CFG is downloaded and STA is in connected
4442 state. Also, make sure to call this function to get the current profile
4443 fields before calling the reassoc. So that pModifyProfileFields will have
4444 all the latest values plus the one(s) has been updated as part of reassoc
4445 request.
4446 \param pModifyProfileFields - pointer to the connected profile fields
4447 changing which can cause reassoc
4448
4449 \return CDF_STATUS
4450 -------------------------------------------------------------------------------*/
4451CDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
4452 tCsrRoamModifyProfileFields *
4453 pModifyProfileFields)
4454{
4455 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4456 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4457
4458 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4459 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
4460 0));
4461 status = sme_acquire_global_lock(&pMac->sme);
4462 if (CDF_IS_STATUS_SUCCESS(status)) {
4463 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4464 status =
4465 csr_get_modify_profile_fields(pMac, sessionId,
4466 pModifyProfileFields);
4467 } else {
4468 status = CDF_STATUS_E_INVAL;
4469 }
4470 sme_release_global_lock(&pMac->sme);
4471 }
4472
4473 return status;
4474}
4475
4476/* ---------------------------------------------------------------------------
4477 \fn sme_set_dhcp_till_power_active_flag
4478 \brief Sets/Clears DHCP related flag to disable/enable auto PS
4479 \param hal - The handle returned by mac_open.
4480 ---------------------------------------------------------------------------*/
4481void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
4482{
4483 tpAniSirGlobal mac = PMAC_STRUCT(hal);
4484 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
4485
4486 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4487 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
4488 flag));
4489 /* Set/Clear the DHCP flag which will disable/enable auto PS */
4490 ps_global_info->remain_in_power_active_till_dhcp = flag;
4491}
4492
4493/* ---------------------------------------------------------------------------
4494 \fn sme_register11d_scan_done_callback
4495 \brief Register a routine of type csr_scan_completeCallback which is
4496 called whenever an 11d scan is done
4497 \param hHal - The handle returned by mac_open.
4498 \param callback - 11d scan complete routine to be registered
4499 \return CDF_STATUS
4500 ---------------------------------------------------------------------------*/
4501CDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
4502 csr_scan_completeCallback callback)
4503{
4504 CDF_STATUS status = CDF_STATUS_SUCCESS;
4505 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4506
4507 pMac->scan.callback11dScanDone = callback;
4508
4509 return status;
4510}
4511
4512#ifdef FEATURE_OEM_DATA_SUPPORT
4513/**
4514 * sme_register_oem_data_rsp_callback() - Register a routine of
4515 * type send_oem_data_rsp_msg
4516 * @h_hal: Handle returned by mac_open.
4517 * @callback: Callback to send response
4518 * to oem application.
4519 *
4520 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
4521 * callback function.
4522 *
4523 * Return: CDF_STATUS.
4524 */
4525CDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
4526 sme_send_oem_data_rsp_msg callback)
4527{
4528 CDF_STATUS status = CDF_STATUS_SUCCESS;
4529 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
4530
4531 pmac->oemData.oem_data_rsp_callback = callback;
4532
4533 return status;
4534
4535}
4536#endif
4537
4538/**
4539 * sme_register_ftm_msg_processor() - registers hdd ftm message processor
4540 * function to MAC/SYS
4541 *
4542 * @hal: hal handle
4543 * @callback: hdd function that has to be registered
4544 *
4545 * Return: void
4546 */
4547void sme_register_ftm_msg_processor(tHalHandle hal,
4548 hdd_ftm_msg_processor callback)
4549{
4550 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4551
4552 if (mac_ctx == NULL) {
4553 sms_log(mac_ctx, LOGE, FL("mac_ctx is NULL"));
4554 return;
4555 }
4556 mac_ctx->ftm_msg_processor_callback = callback;
4557 return;
4558}
4559
4560/**
4561 * sme_wow_add_pattern() - add a wow pattern in fw
4562 * @hHal: handle returned by mac_open
4563 * @pattern: pointer to input pattern
4564 *
4565 * Add a pattern for Pattern Byte Matching in WoW mode. Firmware will
4566 * do a pattern match on these patterns when WoW is enabled during system
4567 * suspend.
4568 *
4569 * Return: CDF_STATUS
4570 */
4571CDF_STATUS sme_wow_add_pattern(tHalHandle hal,
4572 struct wow_add_pattern *pattern,
4573 uint8_t session_id)
4574{
4575 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
4576 struct wow_add_pattern *ptrn;
4577 tSirRetStatus ret_code = eSIR_SUCCESS;
4578 tSirMsgQ msg_q;
4579 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4580 TRACE_CODE_SME_RX_HDD_WOWL_ADDBCAST_PATTERN, session_id,
4581 0));
4582 ptrn = cdf_mem_malloc(sizeof(*ptrn));
4583 if (NULL == ptrn) {
4584 sms_log(pMac, LOGP,
4585 FL("Fail to allocate memory for WoWLAN Add Bcast Pattern "));
4586 return CDF_STATUS_E_NOMEM;
4587 }
4588 (void)cdf_mem_copy(ptrn, pattern, sizeof(*ptrn));
4589
4590 msg_q.type = WMA_WOW_ADD_PTRN;
4591 msg_q.reserved = 0;
4592 msg_q.bodyptr = ptrn;
4593 msg_q.bodyval = 0;
4594
4595 sms_log(pMac, LOG1, FL("Sending WMA_WOWL_ADD_BCAST_PTRN to HAL"));
4596 ret_code = wma_post_ctrl_msg(pMac, &msg_q);
4597 if (eSIR_SUCCESS != ret_code) {
4598 sms_log(pMac, LOGE,
4599 FL("Posting WMA_WOWL_ADD_BCAST_PTRN failed, reason=%X"),
4600 ret_code);
4601 }
4602 return ret_code;
4603}
4604
4605/**
4606 * sme_wow_delete_pattern() - delete user configured wow pattern in target
4607 * @hHal: handle returned by mac_open.
4608 * @pattern: pointer to delete pattern parameter
4609 * @sessionId: session id
4610 *
4611 * Return: CDF_STATUS
4612 */
4613CDF_STATUS sme_wow_delete_pattern(tHalHandle hal,
4614 struct wow_delete_pattern *pattern, uint8_t sessionId)
4615{
4616 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
4617 struct wow_delete_pattern *delete_ptrn;
4618 tSirRetStatus ret_code = eSIR_SUCCESS;
4619 tSirMsgQ msg_q;
4620 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4621 TRACE_CODE_SME_RX_HDD_WOWL_DELBCAST_PATTERN, sessionId,
4622 0));
4623 delete_ptrn = cdf_mem_malloc(sizeof(*delete_ptrn));
4624 if (NULL == delete_ptrn) {
4625 sms_log(pMac, LOGP,
4626 FL("Fail to allocate memory for WoWLAN Delete Bcast Pattern "));
4627 return CDF_STATUS_E_NOMEM;
4628 }
4629 (void)cdf_mem_copy(delete_ptrn, pattern, sizeof(*delete_ptrn));
4630 msg_q.type = WMA_WOW_DEL_PTRN;
4631 msg_q.reserved = 0;
4632 msg_q.bodyptr = delete_ptrn;
4633 msg_q.bodyval = 0;
4634
4635 sms_log(pMac, LOG1, FL("Sending WMA_WOWL_DEL_BCAST_PTRN"));
4636
4637 ret_code = wma_post_ctrl_msg(pMac, &msg_q);
4638 if (eSIR_SUCCESS != ret_code) {
4639 sms_log(pMac, LOGE,
4640 FL("Posting WMA_WOWL_DEL_BCAST_PTRN failed, reason=%X"),
4641 ret_code);
4642 }
4643 return ret_code;
4644}
4645
4646/**
4647 * sme_enter_wowl(): SME API exposed to HDD to request enabling of WOWL mode.
4648 * @hal_ctx - The handle returned by mac_open.
4649 * @enter_wowl_callback_routine - Callback routine provided by HDD.
4650 * Used for success/failure notification by SME
4651 * @enter_wowl_callback_context - A cookie passed by HDD, that is passed
4652 * back to HDD at the time of callback.
4653 * @wake_reason_ind_cb - Callback routine provided by HDD.
4654 * Used for Wake Reason Indication by SME
4655 * @wake_reason_ind_cb_ctx - A cookie passed by HDD, that is passed
4656 * back to HDD at the time of callback.
4657 *
4658 * WoWLAN works on top of BMPS mode.
4659 * If the device is not in BMPS mode,
4660 * SME will will cache the information that
4661 * WOWL has been enabled and attempt to put the device
4662 * in BMPS. On entry into BMPS, SME will enable the
4663 * WOWL mode.
4664 * Note 1: If we exit BMPS mode (someone requests full power),
4665 * we will NOT resume WOWL when we go back to BMPS again.
4666 * Request for full power (while in WOWL mode) means disable
4667 * WOWL and go to full power.
4668 * Note 2: Both UAPSD and WOWL work on top of BMPS.
4669 * On entry into BMPS, SME will give priority to UAPSD and
4670 * enable only UAPSD if both UAPSD and WOWL are required.
4671 * Currently there is no requirement or use case to support
4672 * UAPSD and WOWL at the same time.
4673 *
4674 * Return: CDF_STATUS
4675 * CDF_STATUS_SUCCESS Device is already in WoWLAN mode
4676 * CDF_STATUS_E_FAILURE Device cannot enter WoWLAN mode.
4677 * CDF_STATUS_PMC_PENDING Request accepted. SME will enable
4678 * WOWL after BMPS mode is entered.
4679 */
4680CDF_STATUS sme_enter_wowl(tHalHandle hal_ctx,
4681 void (*enter_wowl_callback_routine)(void
4682 *callback_context,
4683 CDF_STATUS status),
4684 void *enter_wowl_callback_context,
4685#ifdef WLAN_WAKEUP_EVENTS
4686 void (*wakeIndicationCB)(void *callback_context,
4687 tpSirWakeReasonInd
4688 wake_reason_ind),
4689 void *wakeIndicationCBContext,
4690#endif /* WLAN_WAKEUP_EVENTS */
4691 tpSirSmeWowlEnterParams wowl_enter_params,
4692 uint8_t session_id)
4693{
4694 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4695 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4696 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4697 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4698 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, session_id, 0));
4699
4700 /* cache the WOWL information */
4701 ps_global_info->ps_params[session_id].wowl_enter_params =
4702 *wowl_enter_params;
4703 ps_global_info->ps_params[session_id].enter_wowl_callback_routine =
4704 enter_wowl_callback_routine;
4705 ps_global_info->ps_params[session_id].enter_wowl_callback_context =
4706 enter_wowl_callback_context;
4707#ifdef WLAN_WAKEUP_EVENTS
4708 /* Cache the Wake Reason Indication callback information */
4709 ps_global_info->ps_params[session_id].wake_reason_ind_cb =
4710 wakeIndicationCB;
4711 ps_global_info->ps_params[session_id].wake_reason_ind_cb_ctx =
4712 wakeIndicationCBContext;
4713#endif /* WLAN_WAKEUP_EVENTS */
4714
4715 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_ENTER);
4716 return status;
4717}
4718/**
4719 *sme_exit_wowl(): SME API exposed to HDD to request exit from WoWLAN mode.
4720 * @hal_ctx - The handle returned by mac_open.
4721 * @wowl_exit_params - Carries info on which smesession
4722 * wowl exit is requested.
4723 *
4724 * SME will initiate exit from WoWLAN mode and device will be
4725 * put in BMPS mode.
4726 * Return CDF_STATUS
4727 * CDF_STATUS_E_FAILURE Device cannot exit WoWLAN mode.
4728 * CDF_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
4729 */
4730CDF_STATUS sme_exit_wowl(tHalHandle hal_ctx,
4731 tpSirSmeWowlExitParams wowl_exit_params)
4732{
4733 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4734 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4735 uint8_t session_id;
4736 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4737 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
4738 session_id = wowl_exit_params->sessionId;
4739 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_EXIT);
4740 return status;
4741}
4742
4743/**
4744 * sme_roam_set_key() - To set encryption key.
4745 * @hal: hal global context
4746 * @session_id: session id
4747 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4748 * @ptr_roam_id: Upon success return, this is the id caller can use to
4749 * identify the request in roamcallback
4750 *
4751 * This function should be called only when connected. This is an asynchronous
4752 * API.
4753 *
4754 * Return: Status of operation
4755 */
4756CDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
4757 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4758{
4759 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4760 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4761 uint32_t roam_id;
4762 uint32_t i;
4763 tCsrRoamSession *session = NULL;
4764 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4765
4766 MTRACE(cdf_trace(CDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
4767 session_id, 0));
4768 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
4769 sms_log(mac_ctx, LOGE, FL("Invalid key length %d"),
4770 set_key->keyLength);
4771 return CDF_STATUS_E_FAILURE;
4772 }
4773 /*Once Setkey is done, we can go in BMPS */
4774 if (set_key->keyLength)
4775 ps_global_info->remain_in_power_active_till_dhcp = false;
4776
4777 status = sme_acquire_global_lock(&mac_ctx->sme);
4778 if (!CDF_IS_STATUS_SUCCESS(status))
4779 return status;
4780
4781 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4782 if (ptr_roam_id)
4783 *ptr_roam_id = roam_id;
4784
4785 sms_log(mac_ctx, LOG2, FL("keyLength %d"), set_key->keyLength);
4786 for (i = 0; i < set_key->keyLength; i++)
4787 sms_log(mac_ctx, LOG2, FL("%02x"), set_key->Key[i]);
4788
4789 sms_log(mac_ctx, LOG2, "\n session_id=%d roam_id=%d", session_id,
4790 roam_id);
4791 session = CSR_GET_SESSION(mac_ctx, session_id);
4792 if (!session) {
4793 sms_log(mac_ctx, LOGE, FL("session %d not found"), session_id);
4794 sme_release_global_lock(&mac_ctx->sme);
4795 return CDF_STATUS_E_FAILURE;
4796 }
4797 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4798 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4799 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4800 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4801 set_key->encType)) {
4802 session->pCurRoamProfile->negotiatedUCEncryptionType =
4803 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4804 }
4805 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4806 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4807 set_key->encType)) {
4808 session->pCurRoamProfile->negotiatedUCEncryptionType =
4809 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4810 }
4811 }
4812 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4813 sme_release_global_lock(&mac_ctx->sme);
4814 return status;
4815}
4816
4817/* ---------------------------------------------------------------------------
4818 \fn sme_get_rssi
4819 \brief a wrapper function that client calls to register a callback to get
4820 RSSI
4821
4822 \param hHal - HAL handle for device
4823 \param callback - SME sends back the requested stats using the callback
4824 \param staId - The station ID for which the stats is requested for
4825 \param bssid - The bssid of the connected session
4826 \param lastRSSI - RSSI value at time of request. In case fw cannot provide
4827 RSSI, do not hold up but return this value.
4828 \param pContext - user context to be passed back along with the callback
4829 \param p_cds_context - cds context
4830 \return CDF_STATUS
4831 ---------------------------------------------------------------------------*/
4832CDF_STATUS sme_get_rssi(tHalHandle hHal,
4833 tCsrRssiCallback callback,
4834 uint8_t staId, struct cdf_mac_addr bssId, int8_t lastRSSI,
4835 void *pContext, void *p_cds_context)
4836{
4837 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4838 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4839
4840 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4841 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4842 status = sme_acquire_global_lock(&pMac->sme);
4843 if (CDF_IS_STATUS_SUCCESS(status)) {
4844 status = csr_get_rssi(pMac, callback,
4845 staId, bssId, lastRSSI,
4846 pContext, p_cds_context);
4847 sme_release_global_lock(&pMac->sme);
4848 }
4849 return status;
4850}
4851
4852/* ---------------------------------------------------------------------------
4853 \fn sme_get_snr
4854 \brief a wrapper function that client calls to register a callback to
4855 get SNR
4856
4857 \param callback - SME sends back the requested stats using the callback
4858 \param staId - The station ID for which the stats is requested for
4859 \param pContext - user context to be passed back along with the callback
4860 \param p_cds_context - cds context
4861 \return CDF_STATUS
4862 ---------------------------------------------------------------------------*/
4863CDF_STATUS sme_get_snr(tHalHandle hHal,
4864 tCsrSnrCallback callback,
4865 uint8_t staId, struct cdf_mac_addr bssId, void *pContext)
4866{
4867 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4868 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4869
4870 status = sme_acquire_global_lock(&pMac->sme);
4871 if (CDF_IS_STATUS_SUCCESS(status)) {
4872 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4873 sme_release_global_lock(&pMac->sme);
4874 }
4875 return status;
4876}
4877
4878#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4879/* ---------------------------------------------------------------------------
4880 \fn sme_get_tsm_stats
4881 \brief a wrapper function that client calls to register a callback to
4882 get TSM Stats
4883 \param callback - SME sends back the requested stats using the callback
4884 \param staId - The station ID for which the stats is requested for
4885 \param pContext - user context to be passed back along with the callback
4886 \param p_cds_context - cds context
4887 \return CDF_STATUS
4888 ---------------------------------------------------------------------------*/
4889CDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
4890 tCsrTsmStatsCallback callback,
4891 uint8_t staId, struct cdf_mac_addr bssId,
4892 void *pContext, void *p_cds_context, uint8_t tid)
4893{
4894 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4895 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4896 status = sme_acquire_global_lock(&pMac->sme);
4897 if (CDF_IS_STATUS_SUCCESS(status)) {
4898 status = csr_get_tsm_stats(pMac, callback,
4899 staId, bssId, pContext, p_cds_context,
4900 tid);
4901 sme_release_global_lock(&pMac->sme);
4902 }
4903 return status;
4904}
4905#endif
4906
4907/* ---------------------------------------------------------------------------
4908 \fn sme_get_statistics
4909 \brief a wrapper function that client calls to register a callback to get
4910 different PHY level statistics from CSR.
4911
4912 \param requesterId - different client requesting for statistics,
4913 HDD, UMA/GAN etc
4914 \param statsMask - The different category/categories of stats requester
4915 is looking for
4916 \param callback - SME sends back the requested stats using the callback
4917 \param periodicity - If requester needs periodic update in millisec, 0 means
4918 it's an one time request
4919 \param cache - If requester is happy with cached stats
4920 \param staId - The station ID for which the stats is requested for
4921 \param pContext - user context to be passed back along with the callback
4922 \param sessionId - sme session interface
4923 \return CDF_STATUS
4924 ---------------------------------------------------------------------------*/
4925CDF_STATUS sme_get_statistics(tHalHandle hHal,
4926 eCsrStatsRequesterType requesterId,
4927 uint32_t statsMask, tCsrStatsCallback callback,
4928 uint32_t periodicity, bool cache, uint8_t staId,
4929 void *pContext, uint8_t sessionId)
4930{
4931 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4932 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4933
4934 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4935 TRACE_CODE_SME_RX_HDD_GET_STATS, NO_SESSION,
4936 periodicity));
4937 status = sme_acquire_global_lock(&pMac->sme);
4938 if (CDF_IS_STATUS_SUCCESS(status)) {
4939 status =
4940 csr_get_statistics(pMac, requesterId, statsMask, callback,
4941 periodicity, cache, staId, pContext,
4942 sessionId);
4943 sme_release_global_lock(&pMac->sme);
4944 }
4945
4946 return status;
4947
4948}
4949
4950CDF_STATUS sme_get_link_status(tHalHandle hHal,
4951 tCsrLinkStatusCallback callback,
4952 void *pContext, uint8_t sessionId)
4953{
4954 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4955 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4956 tAniGetLinkStatus *pMsg;
4957 cds_msg_t cds_message;
4958
4959 status = sme_acquire_global_lock(&pMac->sme);
4960 if (CDF_IS_STATUS_SUCCESS(status)) {
4961 pMsg = cdf_mem_malloc(sizeof(tAniGetLinkStatus));
4962 if (NULL == pMsg) {
4963 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
4964 "%s: Not able to allocate memory for link status",
4965 __func__);
4966 sme_release_global_lock(&pMac->sme);
4967 return CDF_STATUS_E_NOMEM;
4968 }
4969
4970 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4971 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4972 pMsg->sessionId = sessionId;
4973 pMac->sme.linkStatusContext = pContext;
4974 pMac->sme.linkStatusCallback = callback;
4975
4976 cds_message.type = WMA_LINK_STATUS_GET_REQ;
4977 cds_message.bodyptr = pMsg;
4978 cds_message.reserved = 0;
4979
4980 if (!CDF_IS_STATUS_SUCCESS
4981 (cds_mq_post_message(CDF_MODULE_ID_WMA, &cds_message))) {
4982 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
4983 "%s: Post LINK STATUS MSG fail", __func__);
4984 cdf_mem_free(pMsg);
4985 pMac->sme.linkStatusContext = NULL;
4986 pMac->sme.linkStatusCallback = NULL;
4987 status = CDF_STATUS_E_FAILURE;
4988 }
4989
4990 sme_release_global_lock(&pMac->sme);
4991 }
4992
4993 return status;
4994}
4995
4996/* ---------------------------------------------------------------------------
4997
4998 \fn sme_get_country_code
4999
5000 \brief To return the current country code. If no country code is applied,
5001 default country code is used to fill the buffer.
5002 If 11d supported is turned off, an error is return and the last
5003 applied/default country code is used.
5004 This is a synchronous API.
5005
5006 \param pBuf - pointer to a caller allocated buffer for returned country code.
5007
5008 \param pbLen For input, this parameter indicates how big is the buffer.
5009 Upon return, this parameter has the number of bytes for
5010 country. If pBuf doesn't have enough space, this function
5011 returns fail status and this parameter contains the number
5012 that is needed.
5013
5014 \return CDF_STATUS SUCCESS.
5015
5016 FAILURE or RESOURCES The API finished and failed.
5017
5018 -------------------------------------------------------------------------------*/
5019CDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
5020{
5021 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5022
5023 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5024 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
5025
5026 return csr_get_country_code(pMac, pBuf, pbLen);
5027}
5028
5029/**
5030 * sme_apply_channel_power_info_to_fw() - sends channel info to fw
5031 * @hHal: hal handle
5032 *
5033 * This function sends the channel power info to firmware
5034 *
5035 * Return: none
5036 */
5037void sme_apply_channel_power_info_to_fw(tHalHandle hHal)
5038{
5039 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5040
5041 csr_apply_channel_power_info_wrapper(pMac);
5042}
5043
5044/* some support functions */
5045bool sme_is11d_supported(tHalHandle hHal)
5046{
5047 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5048
5049 return csr_is11d_supported(pMac);
5050}
5051
5052bool sme_is11h_supported(tHalHandle hHal)
5053{
5054 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5055
5056 return csr_is11h_supported(pMac);
5057}
5058
5059bool sme_is_wmm_supported(tHalHandle hHal)
5060{
5061 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5062
5063 return csr_is_wmm_supported(pMac);
5064}
5065
5066/* ---------------------------------------------------------------------------
5067
5068 \fn sme_change_country_code
5069
5070 \brief Change Country code from upperlayer during WLAN driver operation.
5071 This is a synchronous API.
5072
5073 \param hHal - The handle returned by mac_open.
5074
5075 \param pCountry New Country Code String
5076
5077 \param sendRegHint If we want to send reg hint to nl80211
5078
5079 \return CDF_STATUS SUCCESS.
5080
5081 FAILURE or RESOURCES The API finished and failed.
5082
5083 -------------------------------------------------------------------------------*/
5084CDF_STATUS sme_change_country_code(tHalHandle hHal,
5085 tSmeChangeCountryCallback callback,
5086 uint8_t *pCountry,
5087 void *pContext,
5088 void *p_cds_context,
5089 tAniBool countryFromUserSpace,
5090 tAniBool sendRegHint)
5091{
5092 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5093 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5094 cds_msg_t msg;
5095 tAniChangeCountryCodeReq *pMsg;
5096
5097 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5098 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION,
5099 0));
5100 status = sme_acquire_global_lock(&pMac->sme);
5101 if (CDF_IS_STATUS_SUCCESS(status)) {
5102 sms_log(pMac, LOG1, FL(" called"));
5103
5104 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
5105 && (!pMac->roam.configParam.
5106 fSupplicantCountryCodeHasPriority)) {
5107
5108 sms_log(pMac, LOGW,
5109 "Set Country Code Fail since the STA is associated and userspace does not have priority ");
5110
5111 sme_release_global_lock(&pMac->sme);
5112 status = CDF_STATUS_E_FAILURE;
5113 return status;
5114 }
5115
5116 pMsg = cdf_mem_malloc(sizeof(tAniChangeCountryCodeReq));
5117 if (NULL == pMsg) {
5118 sms_log(pMac, LOGE,
5119 " csrChangeCountryCode: failed to allocate mem for req");
5120 sme_release_global_lock(&pMac->sme);
5121 return CDF_STATUS_E_NOMEM;
5122 }
5123
5124 pMsg->msgType = eWNI_SME_CHANGE_COUNTRY_CODE;
5125 pMsg->msgLen = (uint16_t) sizeof(tAniChangeCountryCodeReq);
5126 cdf_mem_copy(pMsg->countryCode, pCountry, 3);
5127 pMsg->countryFromUserSpace = countryFromUserSpace;
5128 pMsg->sendRegHint = sendRegHint;
5129 pMsg->changeCCCallback = callback;
5130 pMsg->pDevContext = pContext;
5131 pMsg->p_cds_context = p_cds_context;
5132
5133 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
5134 msg.bodyptr = pMsg;
5135 msg.reserved = 0;
5136
5137 if (CDF_STATUS_SUCCESS !=
5138 cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
5139 sms_log(pMac, LOGE,
5140 " sme_change_country_code failed to post msg to self ");
5141 cdf_mem_free((void *)pMsg);
5142 status = CDF_STATUS_E_FAILURE;
5143 }
5144 sms_log(pMac, LOG1, FL(" returned"));
5145 sme_release_global_lock(&pMac->sme);
5146 }
5147
5148 return status;
5149}
5150
5151/*--------------------------------------------------------------------------
5152
5153 \fn sme_generic_change_country_code
5154
5155 \brief Change Country code from upperlayer during WLAN driver operation.
5156 This is a synchronous API.
5157
5158 \param hHal - The handle returned by mac_open.
5159
5160 \param pCountry New Country Code String
5161
5162 \param reg_domain regulatory domain
5163
5164 \return CDF_STATUS SUCCESS.
5165
5166 FAILURE or RESOURCES The API finished and failed.
5167
5168 -----------------------------------------------------------------------------*/
5169CDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
5170 uint8_t *pCountry,
5171 v_REGDOMAIN_t reg_domain)
5172{
5173 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5174 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5175 cds_msg_t msg;
5176 tAniGenericChangeCountryCodeReq *pMsg;
5177
5178 if (NULL == pMac) {
5179 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_FATAL,
5180 "%s: pMac is null", __func__);
5181 return status;
5182 }
5183
5184 status = sme_acquire_global_lock(&pMac->sme);
5185 if (CDF_IS_STATUS_SUCCESS(status)) {
5186 sms_log(pMac, LOG1, FL(" called"));
5187 pMsg = cdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
5188
5189 if (NULL == pMsg) {
5190 sms_log(pMac, LOGE,
5191 " sme_generic_change_country_code: failed to allocate mem for req");
5192 sme_release_global_lock(&pMac->sme);
5193 return CDF_STATUS_E_NOMEM;
5194 }
5195
5196 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
5197 pMsg->msgLen =
5198 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
5199 cdf_mem_copy(pMsg->countryCode, pCountry, 2);
5200 pMsg->domain_index = reg_domain;
5201 pMsg->countryCode[2] = ' '; /* For ASCII space */
5202
5203 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
5204 msg.bodyptr = pMsg;
5205 msg.reserved = 0;
5206
5207 if (CDF_STATUS_SUCCESS !=
5208 cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
5209 sms_log(pMac, LOGE,
5210 "sme_generic_change_country_code failed to post msg to self");
5211 cdf_mem_free(pMsg);
5212 status = CDF_STATUS_E_FAILURE;
5213 }
5214 sms_log(pMac, LOG1, FL(" returned"));
5215 sme_release_global_lock(&pMac->sme);
5216 }
5217
5218 return status;
5219}
5220
5221/* ---------------------------------------------------------------------------
5222
5223 \fn sme_dhcp_start_ind
5224
5225 \brief API to signal the FW about the DHCP Start event.
5226
5227 \param hHal - HAL handle for device.
5228
5229 \param device_mode - mode(AP,SAP etc) of the device.
5230
5231 \param macAddr - MAC address of the adapter.
5232
5233 \param sessionId - session ID.
5234
5235 \return CDF_STATUS SUCCESS.
5236
5237 FAILURE or RESOURCES The API finished and failed.
5238 --------------------------------------------------------------------------*/
5239CDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
5240 uint8_t device_mode,
5241 uint8_t *macAddr, uint8_t sessionId)
5242{
5243 CDF_STATUS status;
5244 CDF_STATUS cdf_status;
5245 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5246 cds_msg_t cds_message;
5247 tAniDHCPInd *pMsg;
5248 tCsrRoamSession *pSession;
5249
5250 status = sme_acquire_global_lock(&pMac->sme);
5251 if (CDF_STATUS_SUCCESS == status) {
5252 pSession = CSR_GET_SESSION(pMac, sessionId);
5253
5254 if (!pSession) {
5255 sms_log(pMac, LOGE, FL("session %d not found "),
5256 sessionId);
5257 sme_release_global_lock(&pMac->sme);
5258 return CDF_STATUS_E_FAILURE;
5259 }
5260
5261 pMsg = (tAniDHCPInd *) cdf_mem_malloc(sizeof(tAniDHCPInd));
5262 if (NULL == pMsg) {
5263 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5264 "%s: Not able to allocate memory for dhcp start",
5265 __func__);
5266 sme_release_global_lock(&pMac->sme);
5267 return CDF_STATUS_E_NOMEM;
5268 }
5269 pMsg->msgType = WMA_DHCP_START_IND;
5270 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
5271 pMsg->device_mode = device_mode;
Srinivas Girigowda296105a2015-09-24 16:31:16 -07005272 cdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
5273 CDF_MAC_ADDR_SIZE);
5274 cdf_copy_macaddr(&pMsg->peerMacAddr,
5275 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276
5277 cds_message.type = WMA_DHCP_START_IND;
5278 cds_message.bodyptr = pMsg;
5279 cds_message.reserved = 0;
5280
5281 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
5282 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
5283 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5284 "%s: Post DHCP Start MSG fail", __func__);
5285 cdf_mem_free(pMsg);
5286 status = CDF_STATUS_E_FAILURE;
5287 }
5288 sme_release_global_lock(&pMac->sme);
5289 }
5290 return status;
5291}
5292
5293/* ---------------------------------------------------------------------------
5294 \fn sme_dhcp_stop_ind
5295
5296 \brief API to signal the FW about the DHCP complete event.
5297
5298 \param hHal - HAL handle for device.
5299
5300 \param device_mode - mode(AP, SAP etc) of the device.
5301
5302 \param macAddr - MAC address of the adapter.
5303
5304 \param sessionId - session ID.
5305
5306 \return CDF_STATUS SUCCESS.
5307 FAILURE or RESOURCES The API finished and failed.
5308 --------------------------------------------------------------------------*/
5309CDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
5310 uint8_t device_mode,
5311 uint8_t *macAddr, uint8_t sessionId)
5312{
5313 CDF_STATUS status;
5314 CDF_STATUS cdf_status;
5315 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5316 cds_msg_t cds_message;
5317 tAniDHCPInd *pMsg;
5318 tCsrRoamSession *pSession;
5319
5320 status = sme_acquire_global_lock(&pMac->sme);
5321 if (CDF_STATUS_SUCCESS == status) {
5322 pSession = CSR_GET_SESSION(pMac, sessionId);
5323
5324 if (!pSession) {
5325 sms_log(pMac, LOGE, FL("session %d not found "),
5326 sessionId);
5327 sme_release_global_lock(&pMac->sme);
5328 return CDF_STATUS_E_FAILURE;
5329 }
5330
5331 pMsg = (tAniDHCPInd *) cdf_mem_malloc(sizeof(tAniDHCPInd));
5332 if (NULL == pMsg) {
5333 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5334 "%s: Not able to allocate memory for dhcp stop",
5335 __func__);
5336 sme_release_global_lock(&pMac->sme);
5337 return CDF_STATUS_E_NOMEM;
5338 }
5339
5340 pMsg->msgType = WMA_DHCP_STOP_IND;
5341 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
5342 pMsg->device_mode = device_mode;
Srinivas Girigowda296105a2015-09-24 16:31:16 -07005343 cdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
5344 CDF_MAC_ADDR_SIZE);
5345 cdf_copy_macaddr(&pMsg->peerMacAddr,
5346 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347
5348 cds_message.type = WMA_DHCP_STOP_IND;
5349 cds_message.bodyptr = pMsg;
5350 cds_message.reserved = 0;
5351
5352 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
5353 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
5354 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5355 "%s: Post DHCP Stop MSG fail", __func__);
5356 cdf_mem_free(pMsg);
5357 status = CDF_STATUS_E_FAILURE;
5358 }
5359
5360 sme_release_global_lock(&pMac->sme);
5361 }
5362 return status;
5363}
5364
5365/* ---------------------------------------------------------------------------
5366 \fn sme_set_cfg_privacy
5367 \brief API to set configure privacy parameters
5368 \param hHal - The handle returned by mac_open.
5369 \param pProfile - Pointer CSR Roam profile.
5370 \param fPrivacy - This parameter indicates status of privacy
5371
5372 \return void
5373 ---------------------------------------------------------------------------*/
5374void sme_set_cfg_privacy(tHalHandle hHal,
5375 tCsrRoamProfile *pProfile, bool fPrivacy)
5376{
5377 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5378 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5379 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
5380 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5381 csr_set_cfg_privacy(pMac, pProfile, fPrivacy);
5382 sme_release_global_lock(&pMac->sme);
5383 }
5384}
5385
5386#if defined WLAN_FEATURE_VOWIFI
5387/* ---------------------------------------------------------------------------
5388 \fn sme_neighbor_report_request
5389 \brief API to request neighbor report.
5390 \param hHal - The handle returned by mac_open.
5391 \param pRrmNeighborReq - Pointer to a caller allocated object of type
5392 tRrmNeighborReq. Caller owns the memory and is
5393 responsible for freeing it.
5394 \return CDF_STATUS
5395 CDF_STATUS_E_FAILURE - failure
5396 CDF_STATUS_SUCCESS success
5397 ---------------------------------------------------------------------------*/
5398CDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
5399 tpRrmNeighborReq pRrmNeighborReq,
5400 tpRrmNeighborRspCallbackInfo callbackInfo)
5401{
5402 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5403 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5404 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5405 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
5406 0));
5407
5408 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5409 status =
5410 sme_rrm_neighbor_report_request(hHal, sessionId,
5411 pRrmNeighborReq, callbackInfo);
5412 sme_release_global_lock(&pMac->sme);
5413 }
5414
5415 return status;
5416}
5417#endif
5418
5419void sms_log(tpAniSirGlobal pMac, uint32_t loglevel, const char *pString, ...)
5420{
5421#ifdef WLAN_DEBUG
5422 /* Verify against current log level */
5423 if (loglevel >
5424 pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE(SIR_SMS_MODULE_ID)])
5425 return;
5426 else {
5427 va_list marker;
5428
5429 va_start(marker, pString); /* Initialize variable arguments. */
5430
5431 log_debug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
5432
5433 va_end(marker); /* Reset variable arguments. */
5434 }
5435#endif
5436}
5437
5438/* ---------------------------------------------------------------------------
5439 \fn sme_get_wcnss_wlan_compiled_version
5440 \brief This API returns the version of the WCNSS WLAN API with
5441 which the HOST driver was built
5442 \param hHal - The handle returned by mac_open.
5443 \param pVersion - Points to the Version structure to be filled
5444 \return CDF_STATUS
5445 CDF_STATUS_E_INVAL - failure
5446 CDF_STATUS_SUCCESS success
5447 ---------------------------------------------------------------------------*/
5448CDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
5449 tSirVersionType *pVersion)
5450{
5451 CDF_STATUS status = CDF_STATUS_SUCCESS;
5452 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5453
5454 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5455 if (pVersion != NULL)
5456 status = CDF_STATUS_SUCCESS;
5457 else
5458 status = CDF_STATUS_E_INVAL;
5459
5460 sme_release_global_lock(&pMac->sme);
5461 }
5462
5463 return status;
5464}
5465
5466/* ---------------------------------------------------------------------------
5467 \fn sme_get_wcnss_wlan_reported_version
5468 \brief This API returns the version of the WCNSS WLAN API with
5469 which the WCNSS driver reports it was built
5470 \param hHal - The handle returned by mac_open.
5471 \param pVersion - Points to the Version structure to be filled
5472 \return CDF_STATUS
5473 CDF_STATUS_E_INVAL - failure
5474 CDF_STATUS_SUCCESS success
5475 ---------------------------------------------------------------------------*/
5476CDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
5477 tSirVersionType *pVersion)
5478{
5479 CDF_STATUS status = CDF_STATUS_SUCCESS;
5480 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5481
5482 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5483 if (pVersion != NULL)
5484 status = CDF_STATUS_SUCCESS;
5485 else
5486 status = CDF_STATUS_E_INVAL;
5487
5488 sme_release_global_lock(&pMac->sme);
5489 }
5490
5491 return status;
5492}
5493
5494/* ---------------------------------------------------------------------------
5495 \fn sme_get_wcnss_software_version
5496 \brief This API returns the version string of the WCNSS driver
5497 \param hHal - The handle returned by mac_open.
5498 \param pVersion - Points to the Version string buffer to be filled
5499 \param versionBufferSize - THe size of the Version string buffer
5500 \return CDF_STATUS
5501 CDF_STATUS_E_INVAL - failure
5502 CDF_STATUS_SUCCESS success
5503 ---------------------------------------------------------------------------*/
5504CDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
5505 uint8_t *pVersion,
5506 uint32_t versionBufferSize)
5507{
5508 CDF_STATUS status = CDF_STATUS_SUCCESS;
5509 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5510 v_CONTEXT_t cds_context = cds_get_global_context();
5511
5512 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5513 if (pVersion != NULL) {
5514 status =
5515 wma_get_wcnss_software_version(cds_context,
5516 pVersion,
5517 versionBufferSize);
5518 } else {
5519 status = CDF_STATUS_E_INVAL;
5520 }
5521 sme_release_global_lock(&pMac->sme);
5522 }
5523
5524 return status;
5525}
5526
5527/* ---------------------------------------------------------------------------
5528 \fn sme_get_wcnss_hardware_version
5529 \brief This API returns the version string of the WCNSS hardware
5530 \param hHal - The handle returned by mac_open.
5531 \param pVersion - Points to the Version string buffer to be filled
5532 \param versionBufferSize - THe size of the Version string buffer
5533 \return CDF_STATUS
5534 CDF_STATUS_E_INVAL - failure
5535 CDF_STATUS_SUCCESS success
5536 ---------------------------------------------------------------------------*/
5537CDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
5538 uint8_t *pVersion,
5539 uint32_t versionBufferSize)
5540{
5541 CDF_STATUS status = CDF_STATUS_SUCCESS;
5542 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5543
5544 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5545 if (pVersion != NULL)
5546 status = CDF_STATUS_SUCCESS;
5547 else
5548 status = CDF_STATUS_E_INVAL;
5549
5550 sme_release_global_lock(&pMac->sme);
5551 }
5552
5553 return status;
5554}
5555
5556#ifdef FEATURE_WLAN_WAPI
5557
5558/* ---------------------------------------------------------------------------
5559 \fn sme_scan_get_bkid_candidate_list
5560 \brief a wrapper function to return the BKID candidate list
5561 \param pBkidList - caller allocated buffer point to an array of
5562 tBkidCandidateInfo
5563 \param pNumItems - pointer to a variable that has the number of
5564 tBkidCandidateInfo allocated when retruning, this is
5565 either the number needed or number of items put into
5566 pPmkidList
5567 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
5568 big enough and pNumItems
5569 has the number of tBkidCandidateInfo.
5570 \Note: pNumItems is a number of tBkidCandidateInfo,
5571 not sizeof(tBkidCandidateInfo) * something
5572 ---------------------------------------------------------------------------*/
5573CDF_STATUS sme_scan_get_bkid_candidate_list(tHalHandle hHal, uint32_t sessionId,
5574 tBkidCandidateInfo *pBkidList,
5575 uint32_t *pNumItems)
5576{
5577 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5578 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5579
5580 status = sme_acquire_global_lock(&pMac->sme);
5581 if (CDF_IS_STATUS_SUCCESS(status)) {
5582 status =
5583 csr_scan_get_bkid_candidate_list(pMac, sessionId, pBkidList,
5584 pNumItems);
5585 sme_release_global_lock(&pMac->sme);
5586 }
5587
5588 return status;
5589}
5590#endif /* FEATURE_WLAN_WAPI */
5591
5592#ifdef FEATURE_OEM_DATA_SUPPORT
5593
5594/*****************************************************************************
5595 OEM DATA related modifications and function additions
5596*****************************************************************************/
5597
5598/* ---------------------------------------------------------------------------
5599 \fn sme_oem_data_req
5600 \brief a wrapper function for OEM DATA REQ
5601 \param sessionId - session id to be used.
5602 \param pOemDataReqId - pointer to an object to get back the request ID
5603 \param callback - a callback function that is called upon finish
5604 \param pContext - a pointer passed in for the callback
5605 \return CDF_STATUS
5606 ---------------------------------------------------------------------------*/
5607CDF_STATUS sme_oem_data_req(tHalHandle hHal,
5608 uint8_t sessionId,
5609 tOemDataReqConfig *pOemDataReqConfig,
5610 uint32_t *pOemDataReqID,
5611 oem_data_oem_data_reqCompleteCallback callback,
5612 void *pContext)
5613{
5614 CDF_STATUS status = CDF_STATUS_SUCCESS;
5615 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5616
5617 do {
5618 /* acquire the lock for the sme object */
5619 status = sme_acquire_global_lock(&pMac->sme);
5620 if (CDF_IS_STATUS_SUCCESS(status)) {
5621 uint32_t lOemDataReqId = pMac->oemData.oemDataReqID++; /* let it wrap around */
5622
5623 if (pOemDataReqID) {
5624 *pOemDataReqID = lOemDataReqId;
5625 } else {
5626 sme_release_global_lock(&pMac->sme);
5627 return CDF_STATUS_E_FAILURE;
5628 }
5629
5630 status =
5631 oem_data_oem_data_req(hHal, sessionId,
5632 pOemDataReqConfig, pOemDataReqID,
5633 callback, pContext);
5634
5635 /* release the lock for the sme object */
5636 sme_release_global_lock(&pMac->sme);
5637 }
5638 } while (0);
5639
5640 sms_log(pMac, LOGW, "exiting function %s", __func__);
5641
5642 return status;
5643}
5644
5645#endif /*FEATURE_OEM_DATA_SUPPORT */
5646
5647/*--------------------------------------------------------------------------
5648
5649 \brief sme_open_session() - Open a session for scan/roam operation.
5650
5651 This is a synchronous API.
5652
5653 \param hHal - The handle returned by mac_open.
5654 \param callback - A pointer to the function caller specifies for
5655 roam/connect status indication
5656 \param pContext - The context passed with callback
5657 \param pSelfMacAddr - Caller allocated memory filled with self MAC address
5658 (6 bytes)
5659 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
5660
5661 \return CDF_STATUS_SUCCESS - session is opened. sessionId returned.
5662
5663 Other status means SME is failed to open the session.
5664 CDF_STATUS_E_RESOURCES - no more session available.
5665 \sa
5666
5667 --------------------------------------------------------------------------*/
5668CDF_STATUS sme_open_session(tHalHandle hHal, csr_roam_completeCallback callback,
5669 void *pContext,
5670 uint8_t *pSelfMacAddr, uint8_t *pbSessionId,
5671 uint32_t type, uint32_t subType)
5672{
5673 CDF_STATUS status;
5674 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5675
5676 CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH,
5677 "%s: type=%d, subType=%d", __func__, type, subType);
5678
5679 if (NULL == pbSessionId) {
5680 status = CDF_STATUS_E_INVAL;
5681 } else {
5682 status = sme_acquire_global_lock(&pMac->sme);
5683 if (CDF_IS_STATUS_SUCCESS(status)) {
5684 status =
5685 csr_roam_open_session(pMac, callback, pContext,
5686 pSelfMacAddr, pbSessionId, type,
5687 subType);
5688
5689 sme_release_global_lock(&pMac->sme);
5690 }
5691 }
5692 if (NULL != pbSessionId)
5693 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5694 TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
5695 *pbSessionId, 0));
5696
5697 return status;
5698}
5699
5700/*--------------------------------------------------------------------------
5701
5702 \brief sme_close_session() - Open a session for scan/roam operation.
5703
5704 This is a synchronous API.
5705
5706 \param hHal - The handle returned by mac_open.
5707
5708 \param sessionId - A previous opened session's ID.
5709
5710 \return CDF_STATUS_SUCCESS - session is closed.
5711
5712 Other status means SME is failed to open the session.
5713 CDF_STATUS_E_INVAL - session is not opened.
5714 \sa
5715
5716 --------------------------------------------------------------------------*/
5717CDF_STATUS sme_close_session(tHalHandle hHal, uint8_t sessionId,
5718 csr_roamSessionCloseCallback callback,
5719 void *pContext)
5720{
5721 CDF_STATUS status;
5722 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5723
5724 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5725 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, sessionId, 0));
5726 status = sme_acquire_global_lock(&pMac->sme);
5727 if (CDF_IS_STATUS_SUCCESS(status)) {
5728 status = csr_roam_close_session(pMac, sessionId, false,
5729 callback, pContext);
5730
5731 sme_release_global_lock(&pMac->sme);
5732 }
5733
5734 return status;
5735}
5736
5737/* ---------------------------------------------------------------------------
5738
5739 \fn sme_roam_update_apwpsie
5740
5741 \brief To update AP's WPS IE. This function should be called after SME AP session is created
5742 This is an asynchronous API.
5743
5744 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
5745
5746 \return CDF_STATUS – SUCCESS –
5747
5748 FAILURE or RESOURCES – The API finished and failed.
5749
5750 -------------------------------------------------------------------------------*/
5751CDF_STATUS sme_roam_update_apwpsie(tHalHandle hHal, uint8_t sessionId,
5752 tSirAPWPSIEs *pAPWPSIES)
5753{
5754
5755 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5756 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5757
5758 status = sme_acquire_global_lock(&pMac->sme);
5759 if (CDF_IS_STATUS_SUCCESS(status)) {
5760
5761 status = csr_roam_update_apwpsie(pMac, sessionId, pAPWPSIES);
5762
5763 sme_release_global_lock(&pMac->sme);
5764 }
5765
5766 return status;
5767}
5768
5769/* ---------------------------------------------------------------------------
5770
5771 \fn sme_roam_update_apwparsni_es
5772
5773 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
5774 This is an asynchronous API.
5775
5776 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
5777
5778 \return CDF_STATUS – SUCCESS –
5779
5780 FAILURE or RESOURCES – The API finished and failed.
5781
5782 -------------------------------------------------------------------------------*/
5783CDF_STATUS sme_roam_update_apwparsni_es(tHalHandle hHal, uint8_t sessionId,
5784 tSirRSNie *pAPSirRSNie)
5785{
5786
5787 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5788 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5789
5790 status = sme_acquire_global_lock(&pMac->sme);
5791 if (CDF_IS_STATUS_SUCCESS(status)) {
5792
5793 status = csr_roam_update_wparsni_es(pMac, sessionId, pAPSirRSNie);
5794
5795 sme_release_global_lock(&pMac->sme);
5796 }
5797
5798 return status;
5799}
5800
5801/* ---------------------------------------------------------------------------
5802
5803 \fn sme_change_mcc_beacon_interval
5804
5805 \brief To update P2P-GO beaconInterval. This function should be called after
5806 disassociating all the station is done
5807 This is an asynchronous API.
5808
5809 \param
5810
5811 \return CDF_STATUS SUCCESS
5812 FAILURE or RESOURCES
5813 The API finished and failed.
5814
5815 -------------------------------------------------------------------------------*/
5816CDF_STATUS sme_change_mcc_beacon_interval(tHalHandle hHal, uint8_t sessionId)
5817{
5818 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5819 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5820
5821 sms_log(pMac, LOG1, FL("Update Beacon PARAMS "));
5822 status = sme_acquire_global_lock(&pMac->sme);
5823 if (CDF_IS_STATUS_SUCCESS(status)) {
5824 status = csr_send_chng_mcc_beacon_interval(pMac, sessionId);
5825 sme_release_global_lock(&pMac->sme);
5826 }
5827 return status;
5828}
5829
5830/**
5831 * sme_set_host_offload(): API to set the host offload feature.
5832 * @hHal: The handle returned by mac_open.
5833 * @sessionId: Session Identifier
5834 * @request: Pointer to the offload request.
5835 *
5836 * Return CDF_STATUS
5837 */
5838CDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
5839 tpSirHostOffloadReq request)
5840{
5841 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5842 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5843
5844 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5845 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
5846 status = sme_acquire_global_lock(&pMac->sme);
5847 if (CDF_IS_STATUS_SUCCESS(status)) {
5848#ifdef WLAN_NS_OFFLOAD
5849 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
5850 status = sme_set_ps_ns_offload(hHal, request,
5851 sessionId);
5852 } else
5853#endif /* WLAN_NS_OFFLOAD */
5854 {
5855 status = sme_set_ps_host_offload(hHal, request,
5856 sessionId);
5857 }
5858 sme_release_global_lock(&pMac->sme);
5859 }
5860
5861 return status;
5862}
5863
5864#ifdef WLAN_FEATURE_GTK_OFFLOAD
5865/**
5866 * sme_set_gtk_offload(): API to set GTK offload information.
5867 * @hHal: The handle returned by mac_open.
5868 * @sessionId: Session Identifier
5869 * @pGtkOffload: Pointer to the GTK offload request..
5870 *
5871 * Return CDF_STATUS
5872 */
5873CDF_STATUS sme_set_gtk_offload(tHalHandle hHal,
5874 tpSirGtkOffloadParams pGtkOffload,
5875 uint8_t sessionId)
5876{
5877 tpSirGtkOffloadParams request_buf;
5878 cds_msg_t msg;
5879 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5880 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5881
5882 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_INFO,
5883 "%s: KeyReplayCounter: %lld", __func__,
5884 pGtkOffload->ullKeyReplayCounter);
5885
5886 if (NULL == pSession) {
5887 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5888 "%s: Session not found ", __func__);
5889 return CDF_STATUS_E_FAILURE;
5890 }
5891
5892 request_buf = cdf_mem_malloc(sizeof(*request_buf));
5893 if (NULL == request_buf) {
5894 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5895 FL("Not able to allocate memory for GTK offload request"));
5896 return CDF_STATUS_E_NOMEM;
5897 }
5898
Srinivas Girigowda2213b1d2015-11-20 17:10:11 -08005899 cdf_copy_macaddr(&pGtkOffload->bssid,
5900 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005901
5902 *request_buf = *pGtkOffload;
5903
5904 msg.type = WMA_GTK_OFFLOAD_REQ;
5905 msg.reserved = 0;
5906 msg.bodyptr = request_buf;
5907 if (!CDF_IS_STATUS_SUCCESS
5908 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
5909 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5910 FL("Not able to post SIR_HAL_SET_GTK_OFFLOAD message to HAL"));
5911 cdf_mem_free(request_buf);
5912 return CDF_STATUS_E_FAILURE;
5913 }
5914
5915 return CDF_STATUS_SUCCESS;
5916}
5917
5918/**
5919 * sme_get_gtk_offload(): API to get GTK offload information
5920 * @hHal: The handle returned by mac_open.
5921 * @callback_routine: callback_routine.
5922 * @sessionId: Session Identifier.
5923 * callback_context: callback_context.
5924 *
5925 * Return CDF_STATUS
5926 */
5927CDF_STATUS sme_get_gtk_offload(tHalHandle hHal,
5928 gtk_offload_get_info_callback callback_routine,
5929 void *callback_context, uint8_t session_id)
5930{
5931 tpSirGtkOffloadGetInfoRspParams request_buf;
5932 cds_msg_t msg;
5933 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5934 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, session_id);
5935
5936 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "%s: Entered",
5937 __func__);
5938
5939 if (NULL == pSession) {
5940 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda2213b1d2015-11-20 17:10:11 -08005941 "%s: Session not found", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942 return CDF_STATUS_E_FAILURE;
5943 }
5944
5945 request_buf = cdf_mem_malloc(sizeof(*request_buf));
5946 if (NULL == request_buf) {
5947 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5948 FL("Not able to allocate memory for Get GTK offload request"));
5949 return CDF_STATUS_E_NOMEM;
5950 }
5951
Srinivas Girigowda2213b1d2015-11-20 17:10:11 -08005952 cdf_copy_macaddr(&request_buf->bssid,
5953 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005954
5955 msg.type = WMA_GTK_OFFLOAD_GETINFO_REQ;
5956 msg.reserved = 0;
5957 msg.bodyptr = request_buf;
5958
5959 /* Cache the Get GTK Offload callback information */
5960 if (NULL != pMac->sme.gtk_offload_get_info_cb) {
5961
5962 /* Do we need to check if the callback is in use? */
5963 /* Because we are not sending the same message again
5964 * when it is pending,
5965 * the only case when the callback is not NULL is that
5966 * the previous message was timed out or failed.
5967 * So, it will be safe to set the callback in this case.
5968 */
5969 }
5970
5971 pMac->sme.gtk_offload_get_info_cb = callback_routine;
5972 pMac->sme.gtk_offload_get_info_cb_context = callback_context;
5973
5974 if (!CDF_IS_STATUS_SUCCESS
5975 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
5976 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5977 FL("Not able to post WMA_GTK_OFFLOAD_GETINFO_REQ message to WMA"));
5978 cdf_mem_free(request_buf);
5979 return CDF_STATUS_E_FAILURE;
5980 }
5981
5982 return CDF_STATUS_SUCCESS;
5983}
5984#endif /* WLAN_FEATURE_GTK_OFFLOAD */
5985
5986/* ---------------------------------------------------------------------------
5987 \fn sme_set_keep_alive
5988 \brief API to set the Keep Alive feature.
5989 \param hHal - The handle returned by mac_open.
5990 \param request - Pointer to the Keep Alive request.
5991 \return CDF_STATUS
5992 ---------------------------------------------------------------------------*/
5993CDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
5994 tpSirKeepAliveReq request)
5995{
5996 tpSirKeepAliveReq request_buf;
5997 cds_msg_t msg;
5998 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5999 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, session_id);
6000
6001 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_LOW,
6002 FL("WMA_SET_KEEP_ALIVE message"));
6003
6004 if (pSession == NULL) {
6005 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
6006 FL("Session not Found"));
6007 return CDF_STATUS_E_FAILURE;
6008 }
6009 request_buf = cdf_mem_malloc(sizeof(tSirKeepAliveReq));
6010 if (NULL == request_buf) {
6011 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
6012 FL("Not able to allocate memory for keep alive request"));
6013 return CDF_STATUS_E_NOMEM;
6014 }
6015
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08006016 cdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 cdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
6018
6019 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_LOW,
6020 "buff TP %d input TP %d ", request_buf->timePeriod,
6021 request->timePeriod);
6022 request_buf->sessionId = session_id;
6023
6024 msg.type = WMA_SET_KEEP_ALIVE;
6025 msg.reserved = 0;
6026 msg.bodyptr = request_buf;
6027 if (CDF_STATUS_SUCCESS !=
6028 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
6029 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
6030 FL("Not able to post WMA_SET_KEEP_ALIVE message to WMA"));
6031 cdf_mem_free(request_buf);
6032 return CDF_STATUS_E_FAILURE;
6033 }
6034
6035 return CDF_STATUS_SUCCESS;
6036}
6037
6038#ifdef FEATURE_WLAN_SCAN_PNO
6039/* ---------------------------------------------------------------------------
6040 \fn sme_set_preferred_network_list
6041 \brief API to set the Preferred Network List Offload feature.
6042 \param hHal - The handle returned by mac_open.
6043 \param request - Pointer to the offload request.
6044 \return CDF_STATUS
6045 ---------------------------------------------------------------------------*/
6046CDF_STATUS sme_set_preferred_network_list(tHalHandle hHal,
6047 tpSirPNOScanReq request,
6048 uint8_t sessionId,
6049 void (*callback_routine)(void *callback_context,
6050 tSirPrefNetworkFoundInd
6051 *pPrefNetworkFoundInd),
6052 void *callback_context)
6053{
6054 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6055 CDF_STATUS status;
6056
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05306057 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6058 TRACE_CODE_SME_RX_HDD_PREF_NET_LIST,
6059 sessionId, request->ucNetworksCount));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 status = sme_acquire_global_lock(&pMac->sme);
6061 if (CDF_IS_STATUS_SUCCESS(status)) {
6062 sme_set_ps_preferred_network_list(hHal, request, sessionId,
6063 callback_routine, callback_context);
6064 sme_release_global_lock(&pMac->sme);
6065 }
6066
6067 return status;
6068}
6069
6070#endif /* FEATURE_WLAN_SCAN_PNO */
6071
6072/* ---------------------------------------------------------------------------
6073 \fn sme_abort_mac_scan
6074 \brief API to cancel MAC scan.
6075 \param hHal - The handle returned by mac_open.
6076 \param sessionId - sessionId on which we need to abort scan.
6077 \param reason - Reason to abort the scan.
6078 \return CDF_STATUS
6079 CDF_STATUS_E_FAILURE - failure
6080 CDF_STATUS_SUCCESS success
6081 ---------------------------------------------------------------------------*/
6082CDF_STATUS sme_abort_mac_scan(tHalHandle hHal, uint8_t sessionId,
6083 eCsrAbortReason reason)
6084{
6085 CDF_STATUS status;
6086 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6087
6088 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6089 TRACE_CODE_SME_RX_HDD_ABORT_MACSCAN, NO_SESSION, 0));
6090 status = sme_acquire_global_lock(&pMac->sme);
6091 if (CDF_IS_STATUS_SUCCESS(status)) {
6092 status = csr_scan_abort_mac_scan(pMac, sessionId, reason);
6093
6094 sme_release_global_lock(&pMac->sme);
6095 }
6096
6097 return status;
6098}
6099
6100/* ----------------------------------------------------------------------------
6101 \fn sme_get_operation_channel
6102 \brief API to get current channel on which STA is parked
6103 this function gives channel information only of infra station or IBSS station
6104 \param hHal, pointer to memory location and sessionId
6105 \returns CDF_STATUS_SUCCESS
6106 CDF_STATUS_E_FAILURE
6107 -------------------------------------------------------------------------------*/
6108CDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
6109 uint8_t sessionId)
6110{
6111 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6112 tCsrRoamSession *pSession;
6113
6114 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
6115 pSession = CSR_GET_SESSION(pMac, sessionId);
6116
6117 if ((pSession->connectedProfile.BSSType ==
6118 eCSR_BSS_TYPE_INFRASTRUCTURE)
6119 || (pSession->connectedProfile.BSSType ==
6120 eCSR_BSS_TYPE_IBSS)
6121 || (pSession->connectedProfile.BSSType ==
6122 eCSR_BSS_TYPE_INFRA_AP)
6123 || (pSession->connectedProfile.BSSType ==
6124 eCSR_BSS_TYPE_START_IBSS)) {
6125 *pChannel = pSession->connectedProfile.operationChannel;
6126 return CDF_STATUS_SUCCESS;
6127 }
6128 }
6129 return CDF_STATUS_E_FAILURE;
6130} /* sme_get_operation_channel ends here */
6131
6132/* ---------------------------------------------------------------------------
6133
6134 \fn sme_RegisterMgtFrame
6135
6136 \brief To register managment frame of specified type and subtype.
6137 \param frameType - type of the frame that needs to be passed to HDD.
6138 \param matchData - data which needs to be matched before passing frame
6139 to HDD.
6140 \param matchDataLen - Length of matched data.
6141 \return CDF_STATUS
6142 -------------------------------------------------------------------------------*/
6143CDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
6144 uint16_t frameType, uint8_t *matchData,
6145 uint16_t matchLen)
6146{
6147 CDF_STATUS status = CDF_STATUS_SUCCESS;
6148 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6149
6150 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6151 TRACE_CODE_SME_RX_HDD_REGISTER_MGMTFR, sessionId, 0));
6152 status = sme_acquire_global_lock(&pMac->sme);
6153 if (CDF_IS_STATUS_SUCCESS(status)) {
6154 tSirRegisterMgmtFrame *pMsg;
6155 uint16_t len;
6156 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
6157
6158 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
6159 sms_log(pMac, LOGE, FL(" session %d not found "),
6160 sessionId);
6161 sme_release_global_lock(&pMac->sme);
6162 return CDF_STATUS_E_FAILURE;
6163 }
6164
6165 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession->sessionActive) {
6166 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
6167 "%s Invalid Sessionid", __func__);
6168 sme_release_global_lock(&pMac->sme);
6169 return CDF_STATUS_E_FAILURE;
6170 }
6171
6172 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
6173
6174 pMsg = cdf_mem_malloc(len);
6175 if (NULL == pMsg)
6176 status = CDF_STATUS_E_NOMEM;
6177 else {
6178 cdf_mem_set(pMsg, len, 0);
6179 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
6180 pMsg->length = len;
6181 pMsg->sessionId = sessionId;
6182 pMsg->registerFrame = true;
6183 pMsg->frameType = frameType;
6184 pMsg->matchLen = matchLen;
6185 cdf_mem_copy(pMsg->matchData, matchData, matchLen);
6186 status = cds_send_mb_message_to_mac(pMsg);
6187 }
6188 sme_release_global_lock(&pMac->sme);
6189 }
6190 return status;
6191}
6192
6193/* ---------------------------------------------------------------------------
6194
6195 \fn sme_DeregisterMgtFrame
6196
6197 \brief To De-register managment frame of specified type and subtype.
6198 \param frameType - type of the frame that needs to be passed to HDD.
6199 \param matchData - data which needs to be matched before passing frame
6200 to HDD.
6201 \param matchDataLen - Length of matched data.
6202 \return CDF_STATUS
6203 -------------------------------------------------------------------------------*/
6204CDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
6205 uint16_t frameType, uint8_t *matchData,
6206 uint16_t matchLen)
6207{
6208 CDF_STATUS status = CDF_STATUS_SUCCESS;
6209 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6210
6211 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6212 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
6213 0));
6214 status = sme_acquire_global_lock(&pMac->sme);
6215 if (CDF_IS_STATUS_SUCCESS(status)) {
6216 tSirRegisterMgmtFrame *pMsg;
6217 uint16_t len;
6218 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
6219
6220 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
6221 sms_log(pMac, LOGE, FL(" session %d not found "),
6222 sessionId);
6223 sme_release_global_lock(&pMac->sme);
6224 return CDF_STATUS_E_FAILURE;
6225 }
6226
6227 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession->sessionActive) {
6228 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
6229 "%s Invalid Sessionid", __func__);
6230 sme_release_global_lock(&pMac->sme);
6231 return CDF_STATUS_E_FAILURE;
6232 }
6233
6234 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
6235
6236 pMsg = cdf_mem_malloc(len);
6237 if (NULL == pMsg)
6238 status = CDF_STATUS_E_NOMEM;
6239 else {
6240 cdf_mem_set(pMsg, len, 0);
6241 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
6242 pMsg->length = len;
6243 pMsg->registerFrame = false;
6244 pMsg->frameType = frameType;
6245 pMsg->matchLen = matchLen;
6246 cdf_mem_copy(pMsg->matchData, matchData, matchLen);
6247 status = cds_send_mb_message_to_mac(pMsg);
6248 }
6249 sme_release_global_lock(&pMac->sme);
6250 }
6251 return status;
6252}
6253
6254/**
6255 * sme_remain_on_channel - API to request remain on channel for 'x' duration
6256 *
6257 * @hHal: pointer to MAC handle
6258 * @session_id: Session identifier
6259 * @channel: channel information
6260 * @duration: duration in ms
6261 * @callback: HDD registered callback to process reaminOnChannelRsp
6262 * @context: HDD Callback param
6263 * @scan_id: scan identifier
6264 *
6265 * This function process the roc request and generates scan identifier.s
6266 *
6267 * Return: CDF_STATUS
6268 */
6269CDF_STATUS sme_remain_on_channel(tHalHandle hHal, uint8_t session_id,
6270 uint8_t channel, uint32_t duration,
6271 remainOnChanCallback callback,
6272 void *pContext, uint8_t isP2PProbeReqAllowed,
6273 uint32_t *scan_id)
6274{
6275 CDF_STATUS status = CDF_STATUS_SUCCESS;
6276 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
6277 uint32_t san_req_id, scan_count;
6278 struct ani_roc_req *roc_msg;
6279 cds_msg_t msg;
6280
6281
6282 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6283 TRACE_CODE_SME_RX_HDD_REMAIN_ONCHAN, session_id, 0));
6284
6285 scan_count = csr_ll_count(&mac_ctx->sme.smeScanCmdActiveList);
6286 if (scan_count >= mac_ctx->scan.max_scan_count) {
6287 sms_log(mac_ctx, LOGE, FL("Max scan reached"));
6288 return CDF_STATUS_E_FAILURE;
6289 }
6290
6291 wma_get_scan_id(&san_req_id);
6292 *scan_id = san_req_id;
6293 status = sme_acquire_global_lock(&mac_ctx->sme);
6294
6295 sms_log(mac_ctx, LOG1, FL(" called"));
6296 roc_msg = cdf_mem_malloc(sizeof(struct ani_roc_req));
6297 if (NULL == roc_msg) {
6298 sms_log(mac_ctx, LOGE,
6299 " scan_req: failed to allocate mem for msg");
6300 sme_release_global_lock(&mac_ctx->sme);
6301 return CDF_STATUS_E_NOMEM;
6302 }
6303 roc_msg->msg_type = eWNI_SME_ROC_CMD;
6304 roc_msg->msg_len = (uint16_t) sizeof(struct ani_roc_req);
6305 roc_msg->session_id = session_id;
6306 roc_msg->callback = callback;
6307 roc_msg->duration = duration;
6308 roc_msg->channel = channel;
6309 roc_msg->is_p2pprobe_allowed = isP2PProbeReqAllowed;
6310 roc_msg->ctx = pContext;
6311 roc_msg->scan_id = *scan_id;
6312 msg.type = eWNI_SME_ROC_CMD;
6313 msg.bodyptr = roc_msg;
6314 msg.reserved = 0;
6315 msg.bodyval = 0;
6316 if (CDF_STATUS_SUCCESS !=
6317 cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
6318 sms_log(mac_ctx, LOGE,
6319 " sme_scan_req failed to post msg");
6320 cdf_mem_free(roc_msg);
6321 status = CDF_STATUS_E_FAILURE;
6322 }
6323 sme_release_global_lock(&mac_ctx->sme);
6324 return status;
6325}
6326
6327/* ---------------------------------------------------------------------------
6328 \fn sme_report_probe_req
6329 \brief API to enable/disable forwarding of probeReq to apps in p2p.
6330 \param hHal - The handle returned by mac_open.
6331 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
6332 \return CDF_STATUS
6333 ---------------------------------------------------------------------------*/
6334
6335#ifndef WLAN_FEATURE_CONCURRENT_P2P
6336CDF_STATUS sme_report_probe_req(tHalHandle hHal, uint8_t flag)
6337{
6338 CDF_STATUS status = CDF_STATUS_SUCCESS;
6339 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6340
6341 do {
6342 /* acquire the lock for the sme object */
6343 status = sme_acquire_global_lock(&pMac->sme);
6344 if (CDF_IS_STATUS_SUCCESS(status)) {
6345 /* call set in context */
6346 pMac->p2pContext.probeReqForwarding = flag;
6347 /* release the lock for the sme object */
6348 sme_release_global_lock(&pMac->sme);
6349 }
6350 } while (0);
6351
6352 sms_log(pMac, LOGW, "exiting function %s", __func__);
6353
6354 return status;
6355}
6356
6357/* ---------------------------------------------------------------------------
6358 \fn sme_update_p2p_ie
6359 \brief API to set the P2p Ie in p2p context
6360 \param hHal - The handle returned by mac_open.
6361 \param p2pIe - Ptr to p2pIe from HDD.
6362 \param p2pIeLength: length of p2pIe
6363 \return CDF_STATUS
6364 ---------------------------------------------------------------------------*/
6365
6366CDF_STATUS sme_update_p2p_ie(tHalHandle hHal, void *p2pIe, uint32_t p2pIeLength)
6367{
6368 CDF_STATUS status = CDF_STATUS_SUCCESS;
6369 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6370
6371 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6372 TRACE_CODE_SME_RX_HDD_UPDATE_P2P_IE, NO_SESSION, 0));
6373 /* acquire the lock for the sme object */
6374 status = sme_acquire_global_lock(&pMac->sme);
6375 if (CDF_IS_STATUS_SUCCESS(status)) {
6376 if (NULL != pMac->p2pContext.probeRspIe) {
6377 cdf_mem_free(pMac->p2pContext.probeRspIe);
6378 pMac->p2pContext.probeRspIeLength = 0;
6379 }
6380
6381 pMac->p2pContext.probeRspIe = cdf_mem_malloc(p2pIeLength);
6382 if (NULL == pMac->p2pContext.probeRspIe) {
6383 sms_log(pMac, LOGE, "%s: Unable to allocate P2P IE",
6384 __func__);
6385 pMac->p2pContext.probeRspIeLength = 0;
6386 status = CDF_STATUS_E_NOMEM;
6387 } else {
6388 pMac->p2pContext.probeRspIeLength = p2pIeLength;
6389
6390 sir_dump_buf(pMac, SIR_LIM_MODULE_ID, LOG2,
6391 pMac->p2pContext.probeRspIe,
6392 pMac->p2pContext.probeRspIeLength);
6393 cdf_mem_copy((uint8_t *) pMac->p2pContext.probeRspIe,
6394 p2pIe, p2pIeLength);
6395 }
6396
6397 /* release the lock for the sme object */
6398 sme_release_global_lock(&pMac->sme);
6399 }
6400
6401 sms_log(pMac, LOG2, "exiting function %s", __func__);
6402
6403 return status;
6404}
6405#endif
6406
6407/* ---------------------------------------------------------------------------
6408 \fn sme_send_action
6409 \brief API to send action frame from supplicant.
6410 \param hHal - The handle returned by mac_open.
6411 \return CDF_STATUS
6412 ---------------------------------------------------------------------------*/
6413
6414CDF_STATUS sme_send_action(tHalHandle hHal, uint8_t sessionId,
6415 const uint8_t *pBuf, uint32_t len,
6416 uint16_t wait, bool noack,
6417 uint16_t channel_freq)
6418{
6419 CDF_STATUS status = CDF_STATUS_SUCCESS;
6420 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6421
6422 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6423 TRACE_CODE_SME_RX_HDD_SEND_ACTION, sessionId, 0));
6424 /* acquire the lock for the sme object */
6425 status = sme_acquire_global_lock(&pMac->sme);
6426 if (CDF_IS_STATUS_SUCCESS(status)) {
6427 p2p_send_action(hHal, sessionId, pBuf, len, wait, noack,
6428 channel_freq);
6429 /* release the lock for the sme object */
6430 sme_release_global_lock(&pMac->sme);
6431 }
6432
6433 sms_log(pMac, LOGW, "exiting function %s", __func__);
6434
6435 return status;
6436}
6437
6438CDF_STATUS sme_cancel_remain_on_channel(tHalHandle hHal,
6439 uint8_t sessionId, uint32_t scan_id)
6440{
6441 CDF_STATUS status = CDF_STATUS_SUCCESS;
6442 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6443
6444 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6445 TRACE_CODE_SME_RX_HDD_CANCEL_REMAIN_ONCHAN, sessionId,
6446 0));
6447 status = sme_acquire_global_lock(&pMac->sme);
6448 if (CDF_IS_STATUS_SUCCESS(status)) {
6449 status = p2p_cancel_remain_on_channel(hHal, sessionId, scan_id);
6450 sme_release_global_lock(&pMac->sme);
6451 }
6452 return status;
6453}
6454
6455/* Power Save Related */
6456CDF_STATUS sme_p2p_set_ps(tHalHandle hHal, tP2pPsConfig *data)
6457{
6458 CDF_STATUS status = CDF_STATUS_SUCCESS;
6459 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6460
6461 status = sme_acquire_global_lock(&pMac->sme);
6462 if (CDF_IS_STATUS_SUCCESS(status)) {
6463 status = p2p_set_ps(hHal, data);
6464 sme_release_global_lock(&pMac->sme);
6465 }
6466 return status;
6467}
6468
6469/* ---------------------------------------------------------------------------
6470
6471 \fn sme_configure_rxp_filter
6472
6473 \brief
6474 SME will pass this request to lower mac to set/reset the filter on RXP for
6475 multicast & broadcast traffic.
6476
6477 \param
6478
6479 hHal - The handle returned by mac_open.
6480
6481 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
6482 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
6483 on this param. In future we can use this as a mask to set various types of
6484 filters as suggested below:
6485 FILTER_ALL_MULTICAST:
6486 FILTER_ALL_BROADCAST:
6487 FILTER_ALL_MULTICAST_BROADCAST:
6488
6489 \return CDF_STATUS
6490
6491 --------------------------------------------------------------------------- */
6492CDF_STATUS sme_configure_rxp_filter(tHalHandle hHal,
6493 tpSirWlanSetRxpFilters wlanRxpFilterParam)
6494{
6495 CDF_STATUS status = CDF_STATUS_SUCCESS;
6496 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6497 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6498 cds_msg_t cds_message;
6499
6500 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6501 TRACE_CODE_SME_RX_HDD_CONFIG_RXPFIL, NO_SESSION, 0));
6502 status = sme_acquire_global_lock(&pMac->sme);
6503 if (CDF_IS_STATUS_SUCCESS(status)) {
6504 /* serialize the req through MC thread */
6505 cds_message.bodyptr = wlanRxpFilterParam;
6506 cds_message.type = WMA_CFG_RXP_FILTER_REQ;
6507 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6508 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6509 status = CDF_STATUS_E_FAILURE;
6510 }
6511 sme_release_global_lock(&pMac->sme);
6512 }
6513 return status;
6514}
6515
6516/* ---------------------------------------------------------------------------
6517
6518 \fn sme_configure_suspend_ind
6519
6520 \brief
6521 SME will pass this request to lower mac to Indicate that the wlan needs to
6522 be suspended
6523
6524 \param
6525
6526 hHal - The handle returned by mac_open.
6527
6528 wlanSuspendParam- Depicts the wlan suspend params
6529
6530 csr_readyToSuspendCallback - Callback to be called when ready to suspend
6531 event is received.
6532 callback_context - Context associated with csr_readyToSuspendCallback.
6533
6534 \return CDF_STATUS
6535
6536 --------------------------------------------------------------------------- */
6537CDF_STATUS sme_configure_suspend_ind(tHalHandle hHal,
6538 tpSirWlanSuspendParam wlanSuspendParam,
6539 csr_readyToSuspendCallback callback,
6540 void *callback_context)
6541{
6542 CDF_STATUS status = CDF_STATUS_SUCCESS;
6543 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6544 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6545 cds_msg_t cds_message;
6546
6547 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6548 TRACE_CODE_SME_RX_HDD_CONFIG_SUSPENDIND, NO_SESSION,
6549 0));
6550
6551 pMac->readyToSuspendCallback = callback;
6552 pMac->readyToSuspendContext = callback_context;
6553
6554 status = sme_acquire_global_lock(&pMac->sme);
6555 if (CDF_IS_STATUS_SUCCESS(status)) {
6556 /* serialize the req through MC thread */
6557 cds_message.bodyptr = wlanSuspendParam;
6558 cds_message.type = WMA_WLAN_SUSPEND_IND;
6559 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6560 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6561 pMac->readyToSuspendCallback = NULL;
6562 pMac->readyToSuspendContext = NULL;
6563 status = CDF_STATUS_E_FAILURE;
6564 }
6565 sme_release_global_lock(&pMac->sme);
6566 }
6567
6568 return status;
6569}
6570
6571/* ---------------------------------------------------------------------------
6572
6573 \fn sme_configure_resume_req
6574
6575 \brief
6576 SME will pass this request to lower mac to Indicate that the wlan needs to
6577 be Resumed
6578
6579 \param
6580
6581 hHal - The handle returned by mac_open.
6582
6583 wlanResumeParam- Depicts the wlan resume params
6584
6585 \return CDF_STATUS
6586
6587 --------------------------------------------------------------------------- */
6588CDF_STATUS sme_configure_resume_req(tHalHandle hHal,
6589 tpSirWlanResumeParam wlanResumeParam)
6590{
6591 CDF_STATUS status = CDF_STATUS_SUCCESS;
6592 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6593 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6594 cds_msg_t cds_message;
6595
6596 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6597 TRACE_CODE_SME_RX_HDD_CONFIG_RESUMEREQ, NO_SESSION,
6598 0));
6599 status = sme_acquire_global_lock(&pMac->sme);
6600 if (CDF_IS_STATUS_SUCCESS(status)) {
6601 /* serialize the req through MC thread */
6602 cds_message.bodyptr = wlanResumeParam;
6603 cds_message.type = WMA_WLAN_RESUME_REQ;
6604 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6605 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6606 status = CDF_STATUS_E_FAILURE;
6607 }
6608 sme_release_global_lock(&pMac->sme);
6609 }
6610 return status;
6611}
6612
6613#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07006614/**
6615 * sme_configure_ext_wow() - configure Extr WoW
6616 * @hHal - The handle returned by mac_open.
6617 * @wlanExtParams - Depicts the wlan Ext params.
6618 * @callback - ext_wow callback to be registered.
6619 * @callback_context - ext_wow callback context
6620 *
6621 * SME will pass this request to lower mac to configure Extr WoW
6622 * Return: CDF_STATUS
6623 */
6624CDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006625 tpSirExtWoWParams wlanExtParams,
6626 csr_readyToExtWoWCallback callback,
6627 void *callback_context)
6628{
6629 CDF_STATUS status = CDF_STATUS_SUCCESS;
6630 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6631 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6632 cds_msg_t cds_message;
6633 tpSirExtWoWParams MsgPtr = cdf_mem_malloc(sizeof(*MsgPtr));
6634
6635 if (!MsgPtr)
6636 return CDF_STATUS_E_NOMEM;
6637
6638 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6639 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
6640
6641 pMac->readyToExtWoWCallback = callback;
6642 pMac->readyToExtWoWContext = callback_context;
6643
6644 status = sme_acquire_global_lock(&pMac->sme);
6645 if (CDF_IS_STATUS_SUCCESS(status)) {
6646
6647 /* serialize the req through MC thread */
6648 cdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
6649 cds_message.bodyptr = MsgPtr;
6650 cds_message.type = WMA_WLAN_EXT_WOW;
6651 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6652 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6653 pMac->readyToExtWoWCallback = NULL;
6654 pMac->readyToExtWoWContext = NULL;
6655 cdf_mem_free(MsgPtr);
6656 status = CDF_STATUS_E_FAILURE;
6657 }
6658 sme_release_global_lock(&pMac->sme);
6659 } else {
6660 pMac->readyToExtWoWCallback = NULL;
6661 pMac->readyToExtWoWContext = NULL;
6662 cdf_mem_free(MsgPtr);
6663 }
6664
6665 return status;
6666}
6667
6668/* ---------------------------------------------------------------------------
6669
6670 \fn sme_configure_app_type1_params
6671
6672 \brief
6673 SME will pass this request to lower mac to configure Indoor WoW parameters.
6674
6675 \param
6676
6677 hHal - The handle returned by mac_open.
6678
6679 wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
6680
6681 \return CDF_STATUS
6682
6683 --------------------------------------------------------------------------- */
6684CDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
6685 tpSirAppType1Params wlanAppType1Params)
6686{
6687 CDF_STATUS status = CDF_STATUS_SUCCESS;
6688 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6689 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6690 cds_msg_t cds_message;
6691 tpSirAppType1Params MsgPtr = cdf_mem_malloc(sizeof(*MsgPtr));
6692
6693 if (!MsgPtr)
6694 return CDF_STATUS_E_NOMEM;
6695
6696 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6697 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
6698 0));
6699
6700 status = sme_acquire_global_lock(&pMac->sme);
6701 if (CDF_IS_STATUS_SUCCESS(status)) {
6702 /* serialize the req through MC thread */
6703 cdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
6704 cds_message.bodyptr = MsgPtr;
6705 cds_message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
6706 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6707 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6708 cdf_mem_free(MsgPtr);
6709 status = CDF_STATUS_E_FAILURE;
6710 }
6711 sme_release_global_lock(&pMac->sme);
6712 } else {
6713 cdf_mem_free(MsgPtr);
6714 }
6715
6716 return status;
6717}
6718
6719/* ---------------------------------------------------------------------------
6720
6721 \fn sme_configure_app_type2_params
6722
6723 \brief
6724 SME will pass this request to lower mac to configure Indoor WoW parameters.
6725
6726 \param
6727
6728 hHal - The handle returned by mac_open.
6729
6730 wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
6731
6732 \return CDF_STATUS
6733
6734 --------------------------------------------------------------------------- */
6735CDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
6736 tpSirAppType2Params wlanAppType2Params)
6737{
6738 CDF_STATUS status = CDF_STATUS_SUCCESS;
6739 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6740 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6741 cds_msg_t cds_message;
6742 tpSirAppType2Params MsgPtr = cdf_mem_malloc(sizeof(*MsgPtr));
6743
6744 if (!MsgPtr)
6745 return CDF_STATUS_E_NOMEM;
6746
6747 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6748 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
6749 0));
6750
6751 status = sme_acquire_global_lock(&pMac->sme);
6752 if (CDF_IS_STATUS_SUCCESS(status)) {
6753 /* serialize the req through MC thread */
6754 cdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
6755 cds_message.bodyptr = MsgPtr;
6756 cds_message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
6757 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6758 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6759 cdf_mem_free(MsgPtr);
6760 status = CDF_STATUS_E_FAILURE;
6761 }
6762 sme_release_global_lock(&pMac->sme);
6763 } else {
6764 cdf_mem_free(MsgPtr);
6765 }
6766
6767 return status;
6768}
6769#endif
6770
6771/* ---------------------------------------------------------------------------
6772
6773 \fn sme_get_infra_session_id
6774
6775 \brief To get the session ID for infra session, if connected
6776 This is a synchronous API.
6777
6778 \param hHal - The handle returned by mac_open.
6779
6780 \return sessionid, -1 if infra session is not connected
6781
6782 -------------------------------------------------------------------------------*/
6783int8_t sme_get_infra_session_id(tHalHandle hHal)
6784{
6785 CDF_STATUS status = CDF_STATUS_E_FAILURE;
6786 int8_t sessionid = -1;
6787 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6788
6789 status = sme_acquire_global_lock(&pMac->sme);
6790 if (CDF_IS_STATUS_SUCCESS(status)) {
6791
6792 sessionid = csr_get_infra_session_id(pMac);
6793
6794 sme_release_global_lock(&pMac->sme);
6795 }
6796
6797 return sessionid;
6798}
6799
6800/* ---------------------------------------------------------------------------
6801
6802 \fn sme_get_infra_operation_channel
6803
6804 \brief To get the operating channel for infra session, if connected
6805 This is a synchronous API.
6806
6807 \param hHal - The handle returned by mac_open.
6808 \param sessionId - the sessionId returned by sme_open_session.
6809
6810 \return operating channel, 0 if infra session is not connected
6811
6812 -------------------------------------------------------------------------------*/
6813uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
6814{
6815 CDF_STATUS status = CDF_STATUS_E_FAILURE;
6816 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6817 uint8_t channel = 0;
6818 status = sme_acquire_global_lock(&pMac->sme);
6819 if (CDF_IS_STATUS_SUCCESS(status)) {
6820
6821 channel = csr_get_infra_operation_channel(pMac, sessionId);
6822
6823 sme_release_global_lock(&pMac->sme);
6824 }
6825
6826 return channel;
6827}
6828
6829/* This routine will return poerating channel on which other BSS is operating to be used for concurrency mode. */
6830/* If other BSS is not up or not connected it will return 0 */
6831uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
6832{
6833 CDF_STATUS status = CDF_STATUS_E_FAILURE;
6834 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6835 uint8_t channel = 0;
6836 status = sme_acquire_global_lock(&pMac->sme);
6837 if (CDF_IS_STATUS_SUCCESS(status)) {
6838
6839 channel = csr_get_concurrent_operation_channel(pMac);
6840 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_HIGH, "%s: "
6841 " Other Concurrent Channel = %d", __func__, channel);
6842 sme_release_global_lock(&pMac->sme);
6843 }
6844
6845 return channel;
6846}
6847
6848#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6849uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
6850 eCsrPhyMode sapPhyMode,
6851 uint8_t cc_switch_mode)
6852{
6853 CDF_STATUS status = CDF_STATUS_E_FAILURE;
6854 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6855 uint16_t channel = 0;
6856
6857 status = sme_acquire_global_lock(&pMac->sme);
6858 if (CDF_IS_STATUS_SUCCESS(status)) {
6859 channel =
6860 csr_check_concurrent_channel_overlap(pMac, sap_ch, sapPhyMode,
6861 cc_switch_mode);
6862 sme_release_global_lock(&pMac->sme);
6863 }
6864
6865 return channel;
6866}
6867#endif
6868
6869#ifdef FEATURE_WLAN_SCAN_PNO
Varun Reddy Yeturub43fda12015-09-10 18:16:21 -07006870/**
6871 * sme_update_roam_pno_channel_prediction_config() - Update PNO config
6872 * @sme_config: config from SME context
6873 * @hal: Global Hal handle
6874 * @copy_from_to: Used to specify the source and destination
6875 *
6876 * Copy the PNO channel prediction configuration parameters from
6877 * SME context to MAC context or vice-versa
6878 *
6879 * Return: None
6880 */
6881void sme_update_roam_pno_channel_prediction_config(
6882 tHalHandle hal, tpSmeConfigParams sme_config,
6883 uint8_t copy_from_to)
6884{
6885 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
6886 if (copy_from_to == SME_CONFIG_TO_ROAM_CONFIG) {
6887 mac_ctx->roam.configParam.pno_channel_prediction =
6888 sme_config->pno_channel_prediction;
6889 mac_ctx->roam.configParam.top_k_num_of_channels =
6890 sme_config->top_k_num_of_channels;
6891 mac_ctx->roam.configParam.stationary_thresh =
6892 sme_config->stationary_thresh;
6893 mac_ctx->roam.configParam.channel_prediction_full_scan =
6894 sme_config->channel_prediction_full_scan;
6895 } else if (copy_from_to == ROAM_CONFIG_TO_SME_CONFIG) {
6896 sme_config->pno_channel_prediction =
6897 mac_ctx->roam.configParam.pno_channel_prediction;
6898 sme_config->top_k_num_of_channels =
6899 mac_ctx->roam.configParam.top_k_num_of_channels;
6900 sme_config->stationary_thresh =
6901 mac_ctx->roam.configParam.stationary_thresh;
6902 sme_config->channel_prediction_full_scan =
6903 mac_ctx->roam.configParam.channel_prediction_full_scan;
6904 }
6905
6906}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006907/******************************************************************************
6908*
6909* Name: sme_preferred_network_found_ind
6910*
6911* Description:
6912* Invoke Preferred Network Found Indication
6913*
6914* Parameters:
6915* hHal - HAL handle for device
6916* pMsg - found network description
6917*
6918* Returns: CDF_STATUS
6919*
6920******************************************************************************/
6921CDF_STATUS sme_preferred_network_found_ind(tHalHandle hHal, void *pMsg)
6922{
6923 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6924 CDF_STATUS status = CDF_STATUS_SUCCESS;
6925 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd =
6926 (tSirPrefNetworkFoundInd *) pMsg;
6927 uint8_t dumpSsId[SIR_MAC_MAX_SSID_LENGTH + 1];
6928 uint8_t ssIdLength = 0;
6929
6930 if (NULL == pMsg) {
6931 sms_log(pMac, LOGE, "in %s msg ptr is NULL", __func__);
6932 return CDF_STATUS_E_FAILURE;
6933 }
6934
6935 if (pMac->pnoOffload) {
6936 /* Call Preferred Network Found Indication callback routine. */
6937 if (pMac->sme.pref_netw_found_cb != NULL) {
6938 pMac->sme.pref_netw_found_cb(pMac->sme.
6939 preferred_network_found_ind_cb_ctx,
6940 pPrefNetworkFoundInd);
6941 }
6942 return status;
6943 }
6944
6945 if (pPrefNetworkFoundInd->ssId.length > 0) {
6946 ssIdLength = CSR_MIN(SIR_MAC_MAX_SSID_LENGTH,
6947 pPrefNetworkFoundInd->ssId.length);
6948 cdf_mem_copy(dumpSsId, pPrefNetworkFoundInd->ssId.ssId,
6949 ssIdLength);
6950 dumpSsId[ssIdLength] = 0;
6951 sms_log(pMac, LOG2, "%s:SSID=%s frame length %d",
6952 __func__, dumpSsId, pPrefNetworkFoundInd->frameLength);
6953
6954 /* Flush scan results, So as to avoid indication/updation of
6955 * stale entries, which may not have aged out during APPS collapse
6956 */
6957 sme_scan_flush_result(hHal);
6958
6959 /* Save the frame to scan result */
6960 if (pPrefNetworkFoundInd->mesgLen >
6961 sizeof(tSirPrefNetworkFoundInd)) {
6962 /* we may have a frame */
6963 status = csr_scan_save_preferred_network_found(pMac,
6964 pPrefNetworkFoundInd);
6965 if (!CDF_IS_STATUS_SUCCESS(status)) {
6966 sms_log(pMac, LOGE,
6967 FL(" fail to save preferred network"));
6968 }
6969 } else {
6970 sms_log(pMac, LOGE,
6971 FL(" not enough data length %d needed %zu"),
6972 pPrefNetworkFoundInd->mesgLen,
6973 sizeof(tSirPrefNetworkFoundInd));
6974 }
6975
6976 /* Call Preferred Netowrk Found Indication callback routine. */
6977 if (CDF_IS_STATUS_SUCCESS(status)
6978 && (pMac->sme.pref_netw_found_cb != NULL)) {
6979 pMac->sme.pref_netw_found_cb(pMac->sme.
6980 preferred_network_found_ind_cb_ctx,
6981 pPrefNetworkFoundInd);
6982 }
6983 } else {
6984 sms_log(pMac, LOGE, "%s: callback failed - SSID is NULL",
6985 __func__);
6986 status = CDF_STATUS_E_FAILURE;
6987 }
6988
6989 return status;
6990}
6991
6992#endif /* FEATURE_WLAN_SCAN_PNO */
6993
6994CDF_STATUS sme_get_cfg_valid_channels(tHalHandle hHal, uint8_t *aValidChannels,
6995 uint32_t *len)
6996{
6997 CDF_STATUS status = CDF_STATUS_E_FAILURE;
6998 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6999
7000 status = sme_acquire_global_lock(&pMac->sme);
7001 if (CDF_IS_STATUS_SUCCESS(status)) {
7002 status = csr_get_cfg_valid_channels(pMac, aValidChannels, len);
7003 sme_release_global_lock(&pMac->sme);
7004 }
7005
7006 return status;
7007}
7008
7009/* ---------------------------------------------------------------------------
7010
7011 \fn sme_handle_change_country_code
7012
7013 \brief Change Country code, Reg Domain and channel list
7014
7015 \details Country Code Priority
7016 If Supplicant country code is priority than 11d is disabled.
7017 If 11D is enabled, we update the country code after every scan.
7018 Hence when Supplicant country code is priority, we don't need 11D info.
7019 Country code from Supplicant is set as current courtry code.
7020 User can send reset command XX (instead of country code) to reset the
7021 country code to default values.
7022 If 11D is priority,
7023 Than Supplicant country code code is set to default code. But 11D code is set as current country code
7024
7025 \param pMac - The handle returned by mac_open.
7026 \param pMsgBuf - MSG Buffer
7027
7028 \return CDF_STATUS
7029
7030 -------------------------------------------------------------------------------*/
7031CDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac, void *pMsgBuf)
7032{
7033 CDF_STATUS status = CDF_STATUS_SUCCESS;
7034 tAniChangeCountryCodeReq *pMsg;
7035 v_REGDOMAIN_t domainIdIoctl;
7036 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
7037 static country_code_t default_country;
7038 pMsg = (tAniChangeCountryCodeReq *) pMsgBuf;
7039
7040 /*
7041 * if the reset Supplicant country code command is triggered,
7042 * enable 11D, reset the country code and return
7043 */
7044 if (true ==
7045 cdf_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) {
7046 pMac->roam.configParam.Is11dSupportEnabled =
7047 pMac->roam.configParam.Is11dSupportEnabledOriginal;
7048
7049 cdf_status = cds_read_default_country(default_country);
7050
7051 /* read the country code and use it */
7052 if (CDF_IS_STATUS_SUCCESS(cdf_status)) {
7053 cdf_mem_copy(pMsg->countryCode,
7054 default_country,
7055 WNI_CFG_COUNTRY_CODE_LEN);
7056 } else {
7057 status = CDF_STATUS_E_FAILURE;
7058 return status;
7059 }
7060 /*
7061 * Update the 11d country to default country so that when
7062 * callback is received for this default country, driver will
7063 * not disable the 11d taking it as valid country by user.
7064 */
7065 sms_log(pMac, LOG1,
7066 FL("Set default country code (%c%c) as invalid country received"),
7067 pMsg->countryCode[0], pMsg->countryCode[1]);
7068 cdf_mem_copy(pMac->scan.countryCode11d,
7069 pMsg->countryCode,
7070 WNI_CFG_COUNTRY_CODE_LEN);
7071 } else {
7072 /* if Supplicant country code has priority, disable 11d */
7073 if (pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
7074 pMsg->countryFromUserSpace) {
7075 pMac->roam.configParam.Is11dSupportEnabled = false;
7076 }
7077 }
7078
7079 if (pMac->roam.configParam.Is11dSupportEnabled)
7080 return CDF_STATUS_SUCCESS;
7081
7082 /* Set Current Country code and Current Regulatory domain */
7083 status = csr_set_country_code(pMac, pMsg->countryCode);
7084 if (CDF_STATUS_SUCCESS != status) {
7085 /* Supplicant country code failed. So give 11D priority */
7086 pMac->roam.configParam.Is11dSupportEnabled =
7087 pMac->roam.configParam.Is11dSupportEnabledOriginal;
7088 sms_log(pMac, LOGE, "Set Country Code Fail %d", status);
7089 return status;
7090 }
7091
7092 /* overwrite the defualt country code */
7093 cdf_mem_copy(pMac->scan.countryCodeDefault,
7094 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
7095
7096 /* Get Domain ID from country code */
7097 status = csr_get_regulatory_domain_for_country(pMac,
7098 pMac->scan.countryCodeCurrent,
7099 (v_REGDOMAIN_t *) &
7100 domainIdIoctl, COUNTRY_QUERY);
7101 if (status != CDF_STATUS_SUCCESS) {
7102 sms_log(pMac, LOGE, FL(" fail to get regId %d"), domainIdIoctl);
7103 return status;
7104 } else if (REGDOMAIN_WORLD == domainIdIoctl) {
7105 /* Supplicant country code is invalid, so we are on world mode now. So
7106 give 11D chance to update */
7107 pMac->roam.configParam.Is11dSupportEnabled =
7108 pMac->roam.configParam.Is11dSupportEnabledOriginal;
7109 sms_log(pMac, LOG1, FL("Country Code unrecognized by driver"));
7110 }
7111
7112 status = wma_set_reg_domain(pMac, domainIdIoctl);
7113
7114 if (status != CDF_STATUS_SUCCESS) {
7115 sms_log(pMac, LOGE, FL(" fail to set regId %d"), domainIdIoctl);
7116 return status;
7117 } else {
7118 /* if 11d has priority, clear currentCountryBssid & countryCode11d to get */
7119 /* set again if we find AP with 11d info during scan */
7120 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) {
7121 sms_log(pMac, LOGW,
7122 FL
7123 ("Clearing currentCountryBssid, countryCode11d"));
7124 cdf_mem_zero(&pMac->scan.currentCountryBssid,
7125 sizeof(struct cdf_mac_addr));
7126 cdf_mem_zero(pMac->scan.countryCode11d,
7127 sizeof(pMac->scan.countryCode11d));
7128 }
7129 }
7130
7131 if (pMsg->changeCCCallback) {
7132 ((tSmeChangeCountryCallback) (pMsg->changeCCCallback))((void *)
7133 pMsg->
7134 pDevContext);
7135 }
7136
7137 return CDF_STATUS_SUCCESS;
7138}
7139
7140/**
7141 * sme_handle_change_country_code_by_user() - handles country ch req
7142 * @mac_ctx: mac global context
7143 * @msg: request msg packet
7144 *
7145 * If Supplicant country code is priority than 11d is disabled.
7146 * If 11D is enabled, we update the country code after every scan.
7147 * Hence when Supplicant country code is priority, we don't need 11D info.
7148 * Country code from Supplicant is set as current country code.
7149 *
7150 * Return: status of operation
7151 */
7152CDF_STATUS
7153sme_handle_change_country_code_by_user(tpAniSirGlobal mac_ctx,
7154 tAniGenericChangeCountryCodeReq *msg)
7155{
7156 CDF_STATUS status = CDF_STATUS_SUCCESS;
7157 v_REGDOMAIN_t reg_domain_id;
7158 bool is_11d_country = false;
7159 bool supplicant_priority =
7160 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
7161
7162 sms_log(mac_ctx, LOG1, FL(" called"));
7163 reg_domain_id = (v_REGDOMAIN_t) msg->domain_index;
7164 if (memcmp(msg->countryCode, mac_ctx->scan.countryCode11d,
7165 CDS_COUNTRY_CODE_LEN) == 0) {
7166 is_11d_country = true;
7167 }
7168 /* Set the country code given by userspace when 11dOriginal is false
7169 * when 11doriginal is True,is_11d_country =0 and
7170 * fSupplicantCountryCodeHasPriority = 0, then revert the country code,
7171 * and return failure
7172 */
7173 if (mac_ctx->roam.configParam.Is11dSupportEnabledOriginal == true
7174 && !is_11d_country && !supplicant_priority) {
7175 sms_log(mac_ctx, LOGW,
7176 FL("Incorrect country req, nullify this"));
7177
7178 /* we have got a request for a country that should not have been
7179 * added since the STA is associated; nullify this request. If
7180 * both countryCode11d[0] and countryCode11d[1] are zero, revert
7181 * it to World domain to avoid from causing cfg80211 call trace.
7182 */
7183 if ((mac_ctx->scan.countryCode11d[0] == 0)
7184 && (mac_ctx->scan.countryCode11d[1] == 0))
7185 status = csr_get_regulatory_domain_for_country(mac_ctx,
7186 "00", (v_REGDOMAIN_t *) &reg_domain_id,
7187 COUNTRY_IE);
7188 else
7189 status = csr_get_regulatory_domain_for_country(mac_ctx,
7190 mac_ctx->scan.countryCode11d,
7191 (v_REGDOMAIN_t *) &reg_domain_id,
7192 COUNTRY_IE);
7193
7194 return CDF_STATUS_E_FAILURE;
7195 }
7196 /* if Supplicant country code has priority, disable 11d */
7197 if (!is_11d_country && supplicant_priority)
7198 mac_ctx->roam.configParam.Is11dSupportEnabled = false;
7199 cdf_mem_copy(mac_ctx->scan.countryCodeCurrent, msg->countryCode,
7200 WNI_CFG_COUNTRY_CODE_LEN);
7201 status = wma_set_reg_domain(mac_ctx, reg_domain_id);
7202 if (false == is_11d_country) {
7203 /* overwrite the defualt country code */
7204 cdf_mem_copy(mac_ctx->scan.countryCodeDefault,
7205 mac_ctx->scan.countryCodeCurrent,
7206 WNI_CFG_COUNTRY_CODE_LEN);
7207 /* set to default domain ID */
7208 mac_ctx->scan.domainIdDefault = mac_ctx->scan.domainIdCurrent;
7209 }
7210 if (status != CDF_STATUS_SUCCESS) {
7211 sms_log(mac_ctx, LOGE, FL("fail to set regId %d"),
7212 reg_domain_id);
7213 return status;
7214 } else {
7215 /* if 11d has priority, clear currentCountryBssid &
7216 * countryCode11d to get set again if we find AP with 11d info
7217 * during scan
7218 */
7219 if (!supplicant_priority && (false == is_11d_country)) {
7220 sms_log(mac_ctx, LOGW,
7221 FL("Clearing currentCountryBssid, countryCode11d"));
7222 cdf_mem_zero(&mac_ctx->scan.currentCountryBssid,
7223 sizeof(struct cdf_mac_addr));
7224 cdf_mem_zero(mac_ctx->scan.countryCode11d,
7225 sizeof(mac_ctx->scan.countryCode11d));
7226 }
7227 }
7228 /* get the channels based on new cc */
7229 status = csr_get_channel_and_power_list(mac_ctx);
7230
7231 if (status != CDF_STATUS_SUCCESS) {
7232 sms_log(mac_ctx, LOGE, FL("fail to get Channels"));
7233 return status;
7234 }
7235 /* reset info based on new cc, and we are done */
7236 csr_apply_channel_power_info_wrapper(mac_ctx);
7237
7238 /* Country code Changed, Purge Only scan result
7239 * which does not have channel number belong to 11d
7240 * channel list
7241 */
7242 csr_scan_filter_results(mac_ctx);
7243 /* Do active scans after the country is set by User hints or
7244 * Country IE
7245 */
7246 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
7247 sme_disconnect_connected_sessions(mac_ctx);
7248 sms_log(mac_ctx, LOG1, FL(" returned"));
7249 return CDF_STATUS_SUCCESS;
7250}
7251
7252/* ---------------------------------------------------------------------------
7253
7254 \fn sme_handle_change_country_code_by_core
7255
7256 \brief Update Country code in the driver if set by kernel as world
7257
7258 If 11D is enabled, we update the country code after every scan & notify kernel.
7259 This is to make sure kernel & driver are in sync in case of CC found in
7260 driver but not in kernel database
7261
7262 \param pMac - The handle returned by mac_open.
7263 \param pMsg - Carrying new CC set in kernel
7264
7265 \return CDF_STATUS
7266
7267 -------------------------------------------------------------------------------*/
7268CDF_STATUS sme_handle_change_country_code_by_core(tpAniSirGlobal pMac,
7269 tAniGenericChangeCountryCodeReq *
7270 pMsg)
7271{
7272 CDF_STATUS status;
7273
7274 sms_log(pMac, LOG1, FL(" called"));
7275
7276 /* this is to make sure kernel & driver are in sync in case of CC found in */
7277 /* driver but not in kernel database */
7278 if (('0' == pMsg->countryCode[0]) && ('0' == pMsg->countryCode[1])) {
7279 sms_log(pMac, LOGW,
7280 FL
7281 ("Setting countryCode11d & countryCodeCurrent to world CC"));
7282 cdf_mem_copy(pMac->scan.countryCode11d, pMsg->countryCode,
7283 WNI_CFG_COUNTRY_CODE_LEN);
7284 cdf_mem_copy(pMac->scan.countryCodeCurrent, pMsg->countryCode,
7285 WNI_CFG_COUNTRY_CODE_LEN);
7286 }
7287
7288 status = wma_set_reg_domain(pMac, REGDOMAIN_WORLD);
7289
7290 if (status != CDF_STATUS_SUCCESS) {
7291 sms_log(pMac, LOGE, FL(" fail to set regId"));
7292 return status;
7293 } else {
7294 status = csr_get_channel_and_power_list(pMac);
7295 if (status != CDF_STATUS_SUCCESS) {
7296 sms_log(pMac, LOGE, FL(" fail to get Channels "));
7297 } else {
7298 csr_apply_channel_and_power_list(pMac);
7299 }
7300 }
7301 /* Country code Changed, Purge Only scan result
7302 * which does not have channel number belong to 11d
7303 * channel list
7304 */
7305 csr_scan_filter_results(pMac);
7306 sms_log(pMac, LOG1, FL(" returned"));
7307 return CDF_STATUS_SUCCESS;
7308}
7309
7310static bool
7311sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
7312{
7313 uint8_t i;
7314 tCsrChannel *ch_lst_info;
7315 ch_lst_info = &mac_ctx->scan.base_channels;
7316 for (i = 0; i < ch_lst_info->numChannels; i++) {
7317 if (ch_lst_info->channelList[i] == curr_ch)
7318 return true;
7319 }
7320
7321 ch_lst_info = &mac_ctx->scan.base40MHzChannels;
7322 for (i = 0; i < ch_lst_info->numChannels; i++) {
7323 if (ch_lst_info->channelList[i] == curr_ch)
7324 return true;
7325 }
7326 return false;
7327}
7328/**
7329 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
7330 * if channel is not supported
7331 * @mac_ctx: mac global context
7332 *
7333 * If new country code does not support the channel on which STA/P2P client
7334 * is connetced, it sends the disconnect to the AP/P2P GO
7335 *
7336 * Return: void
7337 */
7338void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
7339{
7340 uint8_t session_id, found = false;
7341 uint8_t curr_ch;
7342
7343 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
7344 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
7345 continue;
7346 found = false;
7347 /* Session is connected.Check the channel */
7348 curr_ch = csr_get_infra_operation_channel(mac_ctx,
7349 session_id);
7350 sms_log(mac_ctx, LOGW,
7351 FL("Current Operating channel : %d, session :%d"),
7352 curr_ch, session_id);
7353 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
7354 if (!found) {
7355 sms_log(mac_ctx, LOGW, FL("Disconnect Session :%d"),
7356 session_id);
7357 csr_roam_disconnect(mac_ctx, session_id,
7358 eCSR_DISCONNECT_REASON_UNSPECIFIED);
7359 }
7360 }
7361}
7362
7363/* ---------------------------------------------------------------------------
7364
7365 \fn sme_handle_generic_change_country_code
7366
7367 \brief Change Country code, Reg Domain and channel list
7368
7369 If Supplicant country code is priority than 11d is disabled.
7370 If 11D is enabled, we update the country code after every scan.
7371 Hence when Supplicant country code is priority, we don't need 11D info.
7372 Country code from kernel is set as current country code.
7373
7374 \param pMac - The handle returned by mac_open.
7375 \param pMsgBuf - message buffer
7376
7377 \return CDF_STATUS
7378
7379 -------------------------------------------------------------------------------*/
7380CDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
7381 void *pMsgBuf)
7382{
7383 tAniGenericChangeCountryCodeReq *pMsg;
7384 v_REGDOMAIN_t reg_domain_id;
7385
7386 sms_log(pMac, LOG1, FL(" called"));
7387 pMsg = (tAniGenericChangeCountryCodeReq *) pMsgBuf;
7388 reg_domain_id = (v_REGDOMAIN_t) pMsg->domain_index;
7389
7390 if (REGDOMAIN_COUNT == reg_domain_id) {
7391 sme_handle_change_country_code_by_core(pMac, pMsg);
7392 } else {
7393 sme_handle_change_country_code_by_user(pMac, pMsg);
7394 }
7395 sms_log(pMac, LOG1, FL(" returned"));
7396 return CDF_STATUS_SUCCESS;
7397}
7398
7399#ifdef WLAN_FEATURE_PACKET_FILTERING
7400CDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
7401 tpSirRcvFltMcAddrList pMulticastAddrs)
7402{
7403 tpSirRcvFltMcAddrList request_buf;
7404 cds_msg_t msg;
7405 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7406 tCsrRoamSession *pSession = NULL;
7407
7408 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "%s: "
7409 "ulMulticastAddrCnt=%d, multicastAddr[0]=%p", __func__,
7410 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08007411 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007412
7413 /*
7414 *Find the connected Infra / P2P_client connected session
7415 */
7416 if (CSR_IS_SESSION_VALID(pMac, sessionId) &&
7417 csr_is_conn_state_infra(pMac, sessionId)) {
7418 pSession = CSR_GET_SESSION(pMac, sessionId);
7419 }
7420
7421 if (pSession == NULL) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08007422 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_WARN,
7423 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007424 sessionId);
7425 return CDF_STATUS_E_FAILURE;
7426 }
7427
7428 request_buf = cdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7429 if (NULL == request_buf) {
7430 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7431 "%s: Not able to "
7432 "allocate memory for 8023 Multicast List request",
7433 __func__);
7434 return CDF_STATUS_E_NOMEM;
7435 }
7436
7437 if (!csr_is_conn_state_connected_infra(pMac, sessionId)) {
7438 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7439 "%s: Ignoring the "
7440 "indication as we are not connected", __func__);
7441 cdf_mem_free(request_buf);
7442 return CDF_STATUS_E_FAILURE;
7443 }
7444
7445 cdf_mem_copy(request_buf, pMulticastAddrs,
7446 sizeof(tSirRcvFltMcAddrList));
7447
Srinivas Girigowda98530492015-11-20 17:39:24 -08007448 cdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
7449 cdf_copy_macaddr(&request_buf->bssid,
7450 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007451
7452 msg.type = WMA_8023_MULTICAST_LIST_REQ;
7453 msg.reserved = 0;
7454 msg.bodyptr = request_buf;
7455 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7456 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7457 "%s: Not able to "
7458 "post WMA_8023_MULTICAST_LIST message to WMA",
7459 __func__);
7460 cdf_mem_free(request_buf);
7461 return CDF_STATUS_E_FAILURE;
7462 }
7463
7464 return CDF_STATUS_SUCCESS;
7465}
7466
7467CDF_STATUS sme_receive_filter_set_filter(tHalHandle hHal,
7468 tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
7469 uint8_t sessionId)
7470{
7471 tpSirRcvPktFilterCfgType request_buf;
7472 int32_t allocSize;
7473 cds_msg_t msg;
7474 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7475 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7476 uint8_t idx = 0;
7477
7478 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "%s: filterType=%d, "
7479 "filterId = %d", __func__,
7480 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
7481
7482 allocSize = sizeof(tSirRcvPktFilterCfgType);
7483
7484 request_buf = cdf_mem_malloc(allocSize);
7485
7486 if (NULL == request_buf) {
7487 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7488 "%s: Not able to "
7489 "allocate memory for Receive Filter Set Filter request",
7490 __func__);
7491 return CDF_STATUS_E_NOMEM;
7492 }
7493
7494 if (NULL == pSession) {
7495 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7496 "%s: Session Not found ", __func__);
7497 cdf_mem_free(request_buf);
7498 return CDF_STATUS_E_FAILURE;
7499 }
7500
Srinivas Girigowda98530492015-11-20 17:39:24 -08007501 cdf_copy_macaddr(&pRcvPktFilterCfg->self_macaddr,
7502 &pSession->selfMacAddr);
7503 cdf_copy_macaddr(&pRcvPktFilterCfg->bssid,
7504 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007505 cdf_mem_copy(request_buf, pRcvPktFilterCfg, allocSize);
7506
7507 msg.type = WMA_RECEIVE_FILTER_SET_FILTER_REQ;
7508 msg.reserved = 0;
7509 msg.bodyptr = request_buf;
7510
7511 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "Pkt Flt Req : "
7512 "FT %d FID %d ",
7513 request_buf->filterType, request_buf->filterId);
7514
7515 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "Pkt Flt Req : "
7516 "params %d CT %d",
7517 request_buf->numFieldParams, request_buf->coalesceTime);
7518
7519 for (idx = 0; idx < request_buf->numFieldParams; idx++) {
7520
7521 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
7522 "Proto %d Comp Flag %d ",
7523 request_buf->paramsData[idx].protocolLayer,
7524 request_buf->paramsData[idx].cmpFlag);
7525
7526 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
7527 "Data Offset %d Data Len %d",
7528 request_buf->paramsData[idx].dataOffset,
7529 request_buf->paramsData[idx].dataLength);
7530
7531 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
7532 "CData: %d:%d:%d:%d:%d:%d",
7533 request_buf->paramsData[idx].compareData[0],
7534 request_buf->paramsData[idx].compareData[1],
7535 request_buf->paramsData[idx].compareData[2],
7536 request_buf->paramsData[idx].compareData[3],
7537 request_buf->paramsData[idx].compareData[4],
7538 request_buf->paramsData[idx].compareData[5]);
7539
7540 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
7541 "MData: %d:%d:%d:%d:%d:%d",
7542 request_buf->paramsData[idx].dataMask[0],
7543 request_buf->paramsData[idx].dataMask[1],
7544 request_buf->paramsData[idx].dataMask[2],
7545 request_buf->paramsData[idx].dataMask[3],
7546 request_buf->paramsData[idx].dataMask[4],
7547 request_buf->paramsData[idx].dataMask[5]);
7548
7549 }
7550
7551 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7552 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7553 "%s: Not able to post "
7554 "WMA_RECEIVE_FILTER_SET_FILTER message to WMA",
7555 __func__);
7556 cdf_mem_free(request_buf);
7557 return CDF_STATUS_E_FAILURE;
7558 }
7559
7560 return CDF_STATUS_SUCCESS;
7561}
7562
7563CDF_STATUS sme_receive_filter_clear_filter(tHalHandle hHal,
7564 tpSirRcvFltPktClearParam
7565 pRcvFltPktClearParam, uint8_t sessionId)
7566{
7567 tpSirRcvFltPktClearParam request_buf;
7568 cds_msg_t msg;
7569 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7570 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7571
7572 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "%s: filterId = %d",
7573 __func__, pRcvFltPktClearParam->filterId);
7574
Srinivas Girigowda98530492015-11-20 17:39:24 -08007575 if (NULL == pSession) {
7576 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7577 "%s: Session Not found", __func__);
7578 return CDF_STATUS_E_FAILURE;
7579 }
7580
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007581 request_buf = cdf_mem_malloc(sizeof(tSirRcvFltPktClearParam));
7582 if (NULL == request_buf) {
7583 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7584 "%s: Not able to allocate memory for Receive Filter "
7585 "Clear Filter request", __func__);
7586 return CDF_STATUS_E_NOMEM;
7587 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007588
Srinivas Girigowda98530492015-11-20 17:39:24 -08007589 cdf_copy_macaddr(&pRcvFltPktClearParam->self_macaddr,
7590 &pSession->selfMacAddr);
7591 cdf_copy_macaddr(&pRcvFltPktClearParam->bssid,
7592 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007593
7594 cdf_mem_copy(request_buf, pRcvFltPktClearParam,
7595 sizeof(tSirRcvFltPktClearParam));
7596
7597 msg.type = WMA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
7598 msg.reserved = 0;
7599 msg.bodyptr = request_buf;
7600 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7601 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7602 "%s: Not able to post "
7603 "WMA_RECEIVE_FILTER_CLEAR_FILTER message to WMA",
7604 __func__);
7605 cdf_mem_free(request_buf);
7606 return CDF_STATUS_E_FAILURE;
7607 }
7608
7609 return CDF_STATUS_SUCCESS;
7610}
7611#endif /* WLAN_FEATURE_PACKET_FILTERING */
7612
7613/* ---------------------------------------------------------------------------
7614
7615 \fn sme_is_channel_valid
7616
7617 \brief To check if the channel is valid for currently established domain
7618 This is a synchronous API.
7619
7620 \param hHal - The handle returned by mac_open.
7621 \param channel - channel to verify
7622
7623 \return true/false, true if channel is valid
7624
7625 -------------------------------------------------------------------------------*/
7626bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
7627{
7628 CDF_STATUS status = CDF_STATUS_E_FAILURE;
7629 bool valid = false;
7630 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7631
7632 status = sme_acquire_global_lock(&pMac->sme);
7633 if (CDF_IS_STATUS_SUCCESS(status)) {
7634
7635 valid = csr_roam_is_channel_valid(pMac, channel);
7636
7637 sme_release_global_lock(&pMac->sme);
7638 }
7639
7640 return valid;
7641}
7642
7643/* ---------------------------------------------------------------------------
7644 \fn sme_set_freq_band
7645 \brief Used to set frequency band.
7646 \param hHal
7647 \param sessionId - Session Identifier
7648 \eBand band value to be configured
7649 \- return CDF_STATUS
7650 -------------------------------------------------------------------------*/
7651CDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId, eCsrBand eBand)
7652{
7653 CDF_STATUS status = CDF_STATUS_E_FAILURE;
7654 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7655
7656 status = sme_acquire_global_lock(&pMac->sme);
7657 if (CDF_IS_STATUS_SUCCESS(status)) {
7658 status = csr_set_band(hHal, sessionId, eBand);
7659 sme_release_global_lock(&pMac->sme);
7660 }
7661 return status;
7662}
7663
7664/* ---------------------------------------------------------------------------
7665 \fn sme_get_freq_band
7666 \brief Used to get the current band settings.
7667 \param hHal
7668 \pBand pointer to hold band value
7669 \- return CDF_STATUS
7670 -------------------------------------------------------------------------*/
7671CDF_STATUS sme_get_freq_band(tHalHandle hHal, eCsrBand *pBand)
7672{
7673 CDF_STATUS status = CDF_STATUS_E_FAILURE;
7674 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7675
7676 status = sme_acquire_global_lock(&pMac->sme);
7677 if (CDF_IS_STATUS_SUCCESS(status)) {
7678 *pBand = csr_get_current_band(hHal);
7679 sme_release_global_lock(&pMac->sme);
7680 }
7681 return status;
7682}
7683
7684/* ---------------------------------------------------------------------------
7685 \fn sme_set_max_tx_power_per_band
7686
7687 \brief Set the Maximum Transmit Power specific to band dynamically.
7688 Note: this setting will not persist over reboots.
7689
7690 \param band
7691 \param power to set in dB
7692 \- return CDF_STATUS
7693
7694 ----------------------------------------------------------------------------*/
7695CDF_STATUS sme_set_max_tx_power_per_band(eCsrBand band, int8_t dB)
7696{
7697 cds_msg_t msg;
7698 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
7699
7700 pMaxTxPowerPerBandParams =
7701 cdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
7702 if (NULL == pMaxTxPowerPerBandParams) {
7703 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7704 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
7705 __func__);
7706 return CDF_STATUS_E_NOMEM;
7707 }
7708
7709 pMaxTxPowerPerBandParams->power = dB;
7710 pMaxTxPowerPerBandParams->bandInfo = band;
7711
7712 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
7713 msg.reserved = 0;
7714 msg.bodyptr = pMaxTxPowerPerBandParams;
7715
7716 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7717 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7718 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
7719 __func__);
7720 cdf_mem_free(pMaxTxPowerPerBandParams);
7721 return CDF_STATUS_E_FAILURE;
7722 }
7723
7724 return CDF_STATUS_SUCCESS;
7725}
7726
7727/* ---------------------------------------------------------------------------
7728
7729 \fn sme_set_max_tx_power
7730
7731 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
7732 not persist over reboots.
7733
7734 \param hHal
7735 \param pBssid BSSID to set the power cap for
7736 \param pBssid pSelfMacAddress self MAC Address
7737 \param pBssid power to set in dB
7738 \- return CDF_STATUS
7739
7740 -------------------------------------------------------------------------------*/
Srinivas Girigowda97215232015-09-24 12:26:28 -07007741CDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct cdf_mac_addr pBssid,
7742 struct cdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007743{
7744 cds_msg_t msg;
7745 tpMaxTxPowerParams pMaxTxParams = NULL;
7746
7747 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
7748 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
7749 pMaxTxParams = cdf_mem_malloc(sizeof(tMaxTxPowerParams));
7750 if (NULL == pMaxTxParams) {
7751 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7752 "%s: Not able to allocate memory for pMaxTxParams",
7753 __func__);
7754 return CDF_STATUS_E_NOMEM;
7755 }
7756
Srinivas Girigowda97215232015-09-24 12:26:28 -07007757 cdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
7758 cdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007759 pMaxTxParams->power = dB;
7760
7761 msg.type = WMA_SET_MAX_TX_POWER_REQ;
7762 msg.reserved = 0;
7763 msg.bodyptr = pMaxTxParams;
7764
7765 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7766 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7767 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
7768 __func__);
7769 cdf_mem_free(pMaxTxParams);
7770 return CDF_STATUS_E_FAILURE;
7771 }
7772
7773 return CDF_STATUS_SUCCESS;
7774}
7775
7776/* ---------------------------------------------------------------------------
7777
7778 \fn sme_set_custom_mac_addr
7779
7780 \brief Set the customer Mac Address.
7781
7782 \param customMacAddr customer MAC Address
7783 \- return CDF_STATUS
7784
7785 ---------------------------------------------------------------------------*/
7786CDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
7787{
7788 cds_msg_t msg;
7789 tSirMacAddr *pBaseMacAddr;
7790
7791 pBaseMacAddr = cdf_mem_malloc(sizeof(tSirMacAddr));
7792 if (NULL == pBaseMacAddr) {
7793 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7794 FL("Not able to allocate memory for pBaseMacAddr"));
7795 return CDF_STATUS_E_NOMEM;
7796 }
7797
7798 cdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
7799
7800 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
7801 msg.reserved = 0;
7802 msg.bodyptr = pBaseMacAddr;
7803
7804 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7805 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7806 FL
7807 ("Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA"));
7808 cdf_mem_free(pBaseMacAddr);
7809 return CDF_STATUS_E_FAILURE;
7810 }
7811
7812 return CDF_STATUS_SUCCESS;
7813}
7814
7815/* ----------------------------------------------------------------------------
7816 \fn sme_set_tx_power
7817 \brief Set Transmit Power dynamically.
7818 \param hHal
7819 \param sessionId Target Session ID
7820 \pBSSId BSSID
7821 \dev_mode dev_mode such as station, P2PGO, SAP
7822 \param dBm power to set
7823 \- return CDF_STATUS
7824 ---------------------------------------------------------------------------*/
7825CDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Srinivas Girigowda97215232015-09-24 12:26:28 -07007826 struct cdf_mac_addr pBSSId,
7827 tCDF_CON_MODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007828{
7829 cds_msg_t msg;
7830 tpMaxTxPowerParams pTxParams = NULL;
7831 int8_t power = (int8_t) dBm;
7832
7833 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
7834 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
7835
7836 /* make sure there is no overflow */
7837 if ((int)power != dBm) {
7838 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7839 "%s: error, invalid power = %d", __func__, dBm);
7840 return CDF_STATUS_E_FAILURE;
7841 }
7842
7843 pTxParams = cdf_mem_malloc(sizeof(tMaxTxPowerParams));
7844 if (NULL == pTxParams) {
7845 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7846 "%s: Not able to allocate memory for pTxParams",
7847 __func__);
7848 return CDF_STATUS_E_NOMEM;
7849 }
7850
Srinivas Girigowda97215232015-09-24 12:26:28 -07007851 cdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007852 pTxParams->power = power; /* unit is dBm */
7853 pTxParams->dev_mode = dev_mode;
7854 msg.type = WMA_SET_TX_POWER_REQ;
7855 msg.reserved = 0;
7856 msg.bodyptr = pTxParams;
7857
7858 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7859 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7860 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
7861 __func__);
7862 cdf_mem_free(pTxParams);
7863 return CDF_STATUS_E_FAILURE;
7864 }
7865
7866 return CDF_STATUS_SUCCESS;
7867}
7868
7869/* ---------------------------------------------------------------------------
7870
7871 \fn sme_hide_ssid
7872
7873 \brief hide/show SSID dynamically. Note: this setting will
7874 not persist over reboots.
7875
7876 \param hHal
7877 \param sessionId
7878 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
7879 \- return CDF_STATUS
7880
7881 -------------------------------------------------------------------------------*/
7882CDF_STATUS sme_hide_ssid(tHalHandle hHal, uint8_t sessionId, uint8_t ssidHidden)
7883{
7884 CDF_STATUS status = CDF_STATUS_SUCCESS;
7885 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7886 uint16_t len;
7887
7888 status = sme_acquire_global_lock(&pMac->sme);
7889 if (CDF_IS_STATUS_SUCCESS(status)) {
7890 tpSirUpdateParams pMsg;
7891 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7892
7893 if (!pSession) {
7894 sms_log(pMac, LOGE, FL(" session %d not found "),
7895 sessionId);
7896 sme_release_global_lock(&pMac->sme);
7897 return CDF_STATUS_E_FAILURE;
7898 }
7899
7900 if (!pSession->sessionActive)
7901 CDF_ASSERT(0);
7902
7903 /* Create the message and send to lim */
7904 len = sizeof(tSirUpdateParams);
7905 pMsg = cdf_mem_malloc(len);
7906 if (NULL == pMsg)
7907 status = CDF_STATUS_E_NOMEM;
7908 else {
7909 cdf_mem_set(pMsg, sizeof(tSirUpdateParams), 0);
7910 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
7911 pMsg->length = len;
7912 /* Data starts from here */
7913 pMsg->sessionId = sessionId;
7914 pMsg->ssidHidden = ssidHidden;
7915 status = cds_send_mb_message_to_mac(pMsg);
7916 }
7917 sme_release_global_lock(&pMac->sme);
7918 }
7919 return status;
7920}
7921
7922/* ---------------------------------------------------------------------------
7923
7924 \fn sme_set_tm_level
7925 \brief Set Thermal Mitigation Level to RIVA
7926 \param hHal - The handle returned by mac_open.
7927 \param newTMLevel - new Thermal Mitigation Level
7928 \param tmMode - Thermal Mitigation handle mode, default 0
7929 \return CDF_STATUS
7930 ---------------------------------------------------------------------------*/
7931CDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t tmMode)
7932{
7933 CDF_STATUS status = CDF_STATUS_SUCCESS;
7934 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
7935 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7936 cds_msg_t cds_message;
7937 tAniSetTmLevelReq *setTmLevelReq = NULL;
7938
7939 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
7940 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
7941 status = sme_acquire_global_lock(&pMac->sme);
7942 if (CDF_IS_STATUS_SUCCESS(status)) {
7943 setTmLevelReq =
7944 (tAniSetTmLevelReq *)
7945 cdf_mem_malloc(sizeof(tAniSetTmLevelReq));
7946 if (NULL == setTmLevelReq) {
7947 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7948 "%s: Not able to allocate memory for sme_set_tm_level",
7949 __func__);
7950 sme_release_global_lock(&pMac->sme);
7951 return CDF_STATUS_E_NOMEM;
7952 }
7953
7954 setTmLevelReq->tmMode = tmMode;
7955 setTmLevelReq->newTmLevel = newTMLevel;
7956
7957 /* serialize the req through MC thread */
7958 cds_message.bodyptr = setTmLevelReq;
7959 cds_message.type = WMA_SET_TM_LEVEL_REQ;
7960 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
7961 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
7962 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7963 "%s: Post Set TM Level MSG fail", __func__);
7964 cdf_mem_free(setTmLevelReq);
7965 status = CDF_STATUS_E_FAILURE;
7966 }
7967 sme_release_global_lock(&pMac->sme);
7968 }
7969 return status;
7970}
7971
7972/*---------------------------------------------------------------------------
7973
7974 \brief sme_feature_caps_exchange() - SME interface to exchange capabilities between
7975 Host and FW.
7976
7977 \param hHal - HAL handle for device
7978
7979 \return NONE
7980
7981 ---------------------------------------------------------------------------*/
7982void sme_feature_caps_exchange(tHalHandle hHal)
7983{
7984 MTRACE(cdf_trace
7985 (CDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH, NO_SESSION,
7986 0));
7987}
7988
7989/*---------------------------------------------------------------------------
7990
7991 \brief sme_disable_feature_capablity() - SME interface to disable Active mode offload capablity
7992 in Host.
7993
7994 \param hHal - HAL handle for device
7995
7996 \return NONE
7997
7998 ---------------------------------------------------------------------------*/
7999void sme_disable_feature_capablity(uint8_t feature_index)
8000{
8001}
8002
8003/* ---------------------------------------------------------------------------
8004 \fn sme_reset_power_values_for5_g
8005 \brief Reset the power values for 5G band with default power values.
8006 \param hHal - HAL handle for device
8007 \- return NONE
8008 -------------------------------------------------------------------------*/
8009void sme_reset_power_values_for5_g(tHalHandle hHal)
8010{
8011 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8012 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8013 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
8014 csr_save_channel_power_for_band(pMac, true);
8015 csr_apply_power2_current(pMac); /* Store the channel+power info in the global place: Cfg */
8016}
8017
8018#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
8019/* ---------------------------------------------------------------------------
8020 \fn sme_update_roam_prefer5_g_hz
8021 \brief enable/disable Roam prefer 5G runtime option
8022 This function is called through dynamic setConfig callback function
8023 to configure the Roam prefer 5G runtime option
8024 \param hHal - HAL handle for device
8025 \param nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
8026 \- return Success or failure
8027 -------------------------------------------------------------------------*/
8028
8029CDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal, bool nRoamPrefer5GHz)
8030{
8031 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8032 CDF_STATUS status = CDF_STATUS_SUCCESS;
8033
8034 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8035 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
8036 status = sme_acquire_global_lock(&pMac->sme);
8037 if (CDF_IS_STATUS_SUCCESS(status)) {
8038 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8039 "%s: gRoamPrefer5GHz is changed from %d to %d",
8040 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
8041 nRoamPrefer5GHz);
8042 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
8043 sme_release_global_lock(&pMac->sme);
8044 }
8045
8046 return status;
8047}
8048
8049/* ---------------------------------------------------------------------------
8050 \fn sme_set_roam_intra_band
8051 \brief enable/disable Intra band roaming
8052 This function is called through dynamic setConfig callback function
8053 to configure the intra band roaming
8054 \param hHal - HAL handle for device
8055 \param nRoamIntraBand Enable/Disable Intra band roaming
8056 \- return Success or failure
8057 -------------------------------------------------------------------------*/
8058CDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
8059{
8060 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8061 CDF_STATUS status = CDF_STATUS_SUCCESS;
8062
8063 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8064 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
8065 status = sme_acquire_global_lock(&pMac->sme);
8066 if (CDF_IS_STATUS_SUCCESS(status)) {
8067 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8068 "%s: gRoamIntraBand is changed from %d to %d",
8069 __func__, pMac->roam.configParam.nRoamIntraBand,
8070 nRoamIntraBand);
8071 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
8072 sme_release_global_lock(&pMac->sme);
8073 }
8074
8075 return status;
8076}
8077
8078/* ---------------------------------------------------------------------------
8079 \fn sme_update_roam_scan_n_probes
8080 \brief function to update roam scan N probes
8081 This function is called through dynamic setConfig callback function
8082 to update roam scan N probes
8083 \param hHal - HAL handle for device
8084 \param sessionId - Session Identifier
8085 \param nProbes number of probe requests to be sent out
8086 \- return Success or failure
8087 -------------------------------------------------------------------------*/
8088CDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
8089 const uint8_t nProbes)
8090{
8091 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8092 CDF_STATUS status = CDF_STATUS_SUCCESS;
8093
8094 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8095 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
8096 NO_SESSION, 0));
8097 status = sme_acquire_global_lock(&pMac->sme);
8098 if (CDF_IS_STATUS_SUCCESS(status)) {
8099 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8100 "%s: gRoamScanNProbes is changed from %d to %d",
8101 __func__, pMac->roam.configParam.nProbes, nProbes);
8102 pMac->roam.configParam.nProbes = nProbes;
8103 sme_release_global_lock(&pMac->sme);
8104 }
8105 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8106 csr_roam_offload_scan(pMac, sessionId,
8107 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8108 REASON_NPROBES_CHANGED);
8109 }
8110 return status;
8111}
8112
8113/* ---------------------------------------------------------------------------
8114 \fn sme_update_roam_scan_home_away_time
8115 \brief function to update roam scan Home away time
8116 This function is called through dynamic setConfig callback function
8117 to update roam scan home away time
8118 \param hHal - HAL handle for device
8119 \param sessionId - Session Identifier
8120 \param nRoamScanAwayTime Scan home away time
8121 \param bSendOffloadCmd If true then send offload command to firmware
8122 If false then command is not sent to firmware
8123 \- return Success or failure
8124 -------------------------------------------------------------------------*/
8125CDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
8126 uint8_t sessionId,
8127 const uint16_t nRoamScanHomeAwayTime,
8128 const bool bSendOffloadCmd)
8129{
8130 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8131 CDF_STATUS status = CDF_STATUS_SUCCESS;
8132
8133 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8134 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
8135 NO_SESSION, 0));
8136 status = sme_acquire_global_lock(&pMac->sme);
8137 if (CDF_IS_STATUS_SUCCESS(status)) {
8138 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8139 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
8140 __func__,
8141 pMac->roam.configParam.nRoamScanHomeAwayTime,
8142 nRoamScanHomeAwayTime);
8143 pMac->roam.configParam.nRoamScanHomeAwayTime =
8144 nRoamScanHomeAwayTime;
8145 sme_release_global_lock(&pMac->sme);
8146 }
8147 if (pMac->roam.configParam.isRoamOffloadScanEnabled && bSendOffloadCmd) {
8148 csr_roam_offload_scan(pMac, sessionId,
8149 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8150 REASON_HOME_AWAY_TIME_CHANGED);
8151 }
8152 return status;
8153}
8154
Abhishek Singh518323d2015-10-19 17:42:01 +05308155/**
8156 * sme_ext_change_channel()- function to post send ECSA
8157 * action frame to csr.
8158 * @hHal: Hal context
8159 * @channel: new channel to switch
8160 * @session_id: senssion it should be sent on.
8161 *
8162 * This function is called to post ECSA frame to csr.
8163 *
8164 * Return: success if msg is sent else return failure
8165 */
8166CDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
8167 uint8_t session_id)
8168{
8169 CDF_STATUS status = CDF_STATUS_SUCCESS;
8170 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
8171 uint8_t channel_state;
8172
8173 sms_log(mac_ctx, LOGE, FL(" Set Channel %d "), channel);
8174 channel_state =
8175 cds_get_channel_state(channel);
8176
8177 if (CHANNEL_STATE_DISABLE == channel_state) {
8178 sms_log(mac_ctx, LOGE, FL(" Invalid channel %d "), channel);
8179 return CDF_STATUS_E_INVAL;
8180 }
8181
8182 status = sme_acquire_global_lock(&mac_ctx->sme);
8183
8184 if (CDF_STATUS_SUCCESS == status) {
8185 /* update the channel list to the firmware */
8186 status = csr_send_ext_change_channel(mac_ctx,
8187 channel, session_id);
8188 sme_release_global_lock(&mac_ctx->sme);
8189 }
8190
8191 return status;
8192}
8193
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008194/* ---------------------------------------------------------------------------
8195 \fn sme_get_roam_intra_band
8196 \brief get Intra band roaming
8197 \param hHal - HAL handle for device
8198 \- return Success or failure
8199 -------------------------------------------------------------------------*/
8200bool sme_get_roam_intra_band(tHalHandle hHal)
8201{
8202 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8203 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8204 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
8205 return pMac->roam.configParam.nRoamIntraBand;
8206}
8207
8208/* ---------------------------------------------------------------------------
8209 \fn sme_get_roam_scan_n_probes
8210 \brief get N Probes
8211 \param hHal - HAL handle for device
8212 \- return Success or failure
8213 -------------------------------------------------------------------------*/
8214uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
8215{
8216 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8217 return pMac->roam.configParam.nProbes;
8218}
8219
8220/* ---------------------------------------------------------------------------
8221 \fn sme_get_roam_scan_home_away_time
8222 \brief get Roam scan home away time
8223 \param hHal - HAL handle for device
8224 \- return Success or failure
8225 -------------------------------------------------------------------------*/
8226uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
8227{
8228 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8229 return pMac->roam.configParam.nRoamScanHomeAwayTime;
8230}
8231
8232/* ---------------------------------------------------------------------------
8233 \fn sme_update_roam_rssi_diff
8234 \brief Update RoamRssiDiff
8235 This function is called through dynamic setConfig callback function
8236 to configure RoamRssiDiff
8237 Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
8238 \param hHal - HAL handle for device
8239 \param sessionId - Session Identifier
8240 \param RoamRssiDiff - minimum rssi difference between potential
8241 candidate and current AP.
8242 \- return Success or failure
8243 -------------------------------------------------------------------------*/
8244
8245CDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
8246 uint8_t RoamRssiDiff)
8247{
8248 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8249 CDF_STATUS status = CDF_STATUS_SUCCESS;
8250
8251 status = sme_acquire_global_lock(&pMac->sme);
8252 if (CDF_IS_STATUS_SUCCESS(status)) {
8253 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8254 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
8255 RoamRssiDiff,
8256 pMac->roam.configParam.RoamRssiDiff,
8257 mac_trace_get_neighbour_roam_state(pMac->roam.
8258 neighborRoamInfo
8259 [sessionId].
8260 neighborRoamState));
8261 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
8262 sme_release_global_lock(&pMac->sme);
8263 }
8264 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8265 csr_roam_offload_scan(pMac, sessionId,
8266 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8267 REASON_RSSI_DIFF_CHANGED);
8268 }
8269 return status;
8270}
8271
8272/*--------------------------------------------------------------------------
8273 \brief sme_update_fast_transition_enabled() - enable/disable Fast Transition
8274 support at runtime
8275 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8276 isFastTransitionEnabled.
8277 This is a synchronous call
8278 \param hHal - The handle returned by mac_open.
8279 \return CDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
8280 successfully.
8281 Other status means SME is failed to update isFastTransitionEnabled.
8282 \sa
8283 --------------------------------------------------------------------------*/
8284CDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
8285 bool isFastTransitionEnabled)
8286{
8287 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8288 CDF_STATUS status = CDF_STATUS_SUCCESS;
8289
8290 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8291 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
8292 0));
8293 status = sme_acquire_global_lock(&pMac->sme);
8294 if (CDF_IS_STATUS_SUCCESS(status)) {
8295 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8296 "%s: FastTransitionEnabled is changed from %d to %d",
8297 __func__,
8298 pMac->roam.configParam.isFastTransitionEnabled,
8299 isFastTransitionEnabled);
8300 pMac->roam.configParam.isFastTransitionEnabled =
8301 isFastTransitionEnabled;
8302 sme_release_global_lock(&pMac->sme);
8303 }
8304
8305 return status;
8306}
8307
8308/* ---------------------------------------------------------------------------
8309 \fn sme_update_wes_mode
8310 \brief Update WES Mode
8311 This function is called through dynamic setConfig callback function
8312 to configure isWESModeEnabled
8313 \param hHal - HAL handle for device
8314 \param isWESModeEnabled - WES mode
8315 \param sessionId - Session Identifier
8316 \return CDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
8317 Other status means SME is failed to update isWESModeEnabled.
8318 -------------------------------------------------------------------------*/
8319
8320CDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
8321 uint8_t sessionId)
8322{
8323 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8324 CDF_STATUS status = CDF_STATUS_SUCCESS;
8325
8326 status = sme_acquire_global_lock(&pMac->sme);
8327 if (CDF_IS_STATUS_SUCCESS(status)) {
8328 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8329 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
8330 isWESModeEnabled,
8331 pMac->roam.configParam.isWESModeEnabled,
8332 mac_trace_get_neighbour_roam_state(pMac->roam.
8333 neighborRoamInfo
8334 [sessionId].
8335 neighborRoamState));
8336 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
8337 sme_release_global_lock(&pMac->sme);
8338 }
8339
8340 return status;
8341}
8342
8343/* ---------------------------------------------------------------------------
8344 \fn sme_set_roam_scan_control
8345 \brief Set roam scan control
8346 This function is called to set roam scan control
8347 if roam scan control is set to 0, roaming scan cache is cleared
8348 any value other than 0 is treated as invalid value
8349 \param hHal - HAL handle for device
8350 \param sessionId - Session Identifier
8351 \return CDF_STATUS_SUCCESS - SME update config successfully.
8352 Other status means SME failure to update
8353 -------------------------------------------------------------------------*/
8354CDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
8355 bool roamScanControl)
8356{
8357 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8358 CDF_STATUS status = CDF_STATUS_SUCCESS;
8359
8360 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8361 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
8362 status = sme_acquire_global_lock(&pMac->sme);
8363 if (CDF_IS_STATUS_SUCCESS(status)) {
8364 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8365 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
8366 roamScanControl,
8367 pMac->roam.configParam.nRoamScanControl,
8368 mac_trace_get_neighbour_roam_state(pMac->roam.
8369 neighborRoamInfo
8370 [sessionId].
8371 neighborRoamState));
8372 pMac->roam.configParam.nRoamScanControl = roamScanControl;
8373 if (0 == roamScanControl) {
8374 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8375 "LFR runtime successfully cleared roam scan cache");
8376 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8377 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8378 csr_roam_offload_scan(pMac, sessionId,
8379 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8380 REASON_FLUSH_CHANNEL_LIST);
8381 }
8382 }
8383 sme_release_global_lock(&pMac->sme);
8384 }
8385 return status;
8386}
8387#endif /* (WLAN_FEATURE_VOWIFI_11R) || (FEATURE_WLAN_ESE) || (FEATURE_WLAN_LFR) */
8388
8389#ifdef FEATURE_WLAN_LFR
8390/*--------------------------------------------------------------------------
8391 \brief sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
8392 support at runtime
8393 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8394 isFastRoamIniFeatureEnabled.
8395 This is a synchronous call
8396 \param hHal - The handle returned by mac_open.
8397 \param sessionId - Session Identifier
8398 \return CDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
8399 successfully.
8400 Other status means SME is failed to update isFastRoamIniFeatureEnabled.
8401 \sa
8402 --------------------------------------------------------------------------*/
8403CDF_STATUS sme_update_is_fast_roam_ini_feature_enabled
8404 (tHalHandle hHal,
8405 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled) {
8406 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8407
8408 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
8409 isFastRoamIniFeatureEnabled) {
8410 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8411 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
8412 __func__,
8413 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
8414 isFastRoamIniFeatureEnabled);
8415 return CDF_STATUS_SUCCESS;
8416 }
8417
8418 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8419 "%s: FastRoamEnabled is changed from %d to %d", __func__,
8420 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
8421 isFastRoamIniFeatureEnabled);
8422 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
8423 isFastRoamIniFeatureEnabled;
8424 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
8425 isFastRoamIniFeatureEnabled);
8426
8427 return CDF_STATUS_SUCCESS;
8428}
8429
8430/*--------------------------------------------------------------------------
8431 \brief sme_update_is_mawc_ini_feature_enabled() -
8432 Enable/disable LFR MAWC support at runtime
8433 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8434 isMAWCIniFeatureEnabled.
8435 This is a synchronous call
8436 \param hHal - The handle returned by mac_open.
8437 \return CDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
8438 Other status means SME is failed to update MAWCEnabled.
8439 \sa
8440 --------------------------------------------------------------------------*/
8441CDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
8442 const bool MAWCEnabled)
8443{
8444 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8445 CDF_STATUS status = CDF_STATUS_SUCCESS;
8446
8447 status = sme_acquire_global_lock(&pMac->sme);
8448 if (CDF_IS_STATUS_SUCCESS(status)) {
8449 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8450 "%s: MAWCEnabled is changed from %d to %d", __func__,
8451 pMac->roam.configParam.MAWCEnabled, MAWCEnabled);
8452 pMac->roam.configParam.MAWCEnabled = MAWCEnabled;
8453 sme_release_global_lock(&pMac->sme);
8454 }
8455
8456 return status;
8457
8458}
8459
8460/*--------------------------------------------------------------------------
8461 \brief sme_stop_roaming() - Stop roaming for a given sessionId
8462 This is a synchronous call
8463 \param hHal - The handle returned by mac_open
8464 \param sessionId - Session Identifier
8465 \return CDF_STATUS_SUCCESS on success
8466 Other status on failure
8467 \sa
8468 --------------------------------------------------------------------------*/
8469CDF_STATUS sme_stop_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
8470{
8471 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8472 CDF_STATUS status = CDF_STATUS_SUCCESS;
8473
8474 status = sme_acquire_global_lock(&pMac->sme);
8475 if (CDF_IS_STATUS_SUCCESS(status)) {
8476 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_STOP,
8477 reason);
8478 sme_release_global_lock(&pMac->sme);
8479 }
8480
8481 return status;
8482}
8483
8484/*--------------------------------------------------------------------------
8485 \brief sme_start_roaming() - Start roaming for a given sessionId
8486 This is a synchronous call
8487 \param hHal - The handle returned by mac_open
8488 \param sessionId - Session Identifier
8489 \return CDF_STATUS_SUCCESS on success
8490 Other status on failure
8491 \sa
8492 --------------------------------------------------------------------------*/
8493CDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
8494{
8495 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8496 CDF_STATUS status = CDF_STATUS_SUCCESS;
8497
8498 status = sme_acquire_global_lock(&pMac->sme);
8499 if (CDF_IS_STATUS_SUCCESS(status)) {
8500 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
8501 reason);
8502 sme_release_global_lock(&pMac->sme);
8503 }
8504
8505 return status;
8506}
8507
8508/*--------------------------------------------------------------------------
8509 \brief sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
8510 Concurrent session exists
8511 This is a synchronuous call
8512 \param hHal - The handle returned by mac_open.
8513 \return CDF_STATUS_SUCCESS
8514 Other status means SME is failed
8515 \sa
8516 --------------------------------------------------------------------------*/
8517
8518CDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
8519 bool
8520 bFastRoamInConIniFeatureEnabled)
8521{
8522
8523 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8524 CDF_STATUS status = CDF_STATUS_SUCCESS;
8525
8526 status = sme_acquire_global_lock(&pMac->sme);
8527 if (CDF_IS_STATUS_SUCCESS(status)) {
8528 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
8529 bFastRoamInConIniFeatureEnabled;
8530 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
8531 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
8532 0;
8533 }
8534 sme_release_global_lock(&pMac->sme);
8535 }
8536
8537 return status;
8538}
8539#endif /* FEATURE_WLAN_LFR */
8540
8541#ifdef FEATURE_WLAN_ESE
8542/*--------------------------------------------------------------------------
8543 \brief sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
8544 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8545 isEseIniFeatureEnabled.
8546 This is a synchronous call
8547 \param hHal - The handle returned by mac_open.
8548 \param sessionId - Session Identifier
8549 \param isEseIniFeatureEnabled - flag to enable/disable
8550 \return CDF_STATUS_SUCCESS - SME update isEseIniFeatureEnabled config
8551 successfully.
8552 Other status means SME is failed to update isEseIniFeatureEnabled.
8553 \sa
8554 --------------------------------------------------------------------------*/
8555CDF_STATUS sme_update_is_ese_feature_enabled
8556 (tHalHandle hHal, uint8_t sessionId, const bool isEseIniFeatureEnabled) {
8557 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8558
8559 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
8560 isEseIniFeatureEnabled) {
8561 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8562 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
8563 __func__,
8564 pMac->roam.configParam.isEseIniFeatureEnabled,
8565 isEseIniFeatureEnabled);
8566 return CDF_STATUS_SUCCESS;
8567 }
8568
8569 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8570 "%s: EseEnabled is changed from %d to %d", __func__,
8571 pMac->roam.configParam.isEseIniFeatureEnabled,
8572 isEseIniFeatureEnabled);
8573 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
8574 csr_neighbor_roam_update_ese_mode_enabled(pMac, sessionId,
8575 isEseIniFeatureEnabled);
8576
8577 if (true == isEseIniFeatureEnabled) {
8578 sme_update_fast_transition_enabled(hHal, true);
8579 }
8580 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8581 csr_roam_offload_scan(pMac, sessionId,
8582 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8583 REASON_ESE_INI_CFG_CHANGED);
8584 }
8585 return CDF_STATUS_SUCCESS;
8586}
8587#endif /* FEATURE_WLAN_ESE */
8588
8589/*--------------------------------------------------------------------------
8590 \brief sme_update_config_fw_rssi_monitoring() - enable/disable firmware RSSI
8591 Monitoring at runtime
8592 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8593 fEnableFwRssiMonitoring.
8594 This is a synchronous call
8595 \param hHal - The handle returned by mac_open.
8596 \return CDF_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring.
8597 config successfully.
8598 Other status means SME is failed to update fEnableFwRssiMonitoring.
8599 \sa
8600 --------------------------------------------------------------------------*/
8601
8602CDF_STATUS sme_update_config_fw_rssi_monitoring(tHalHandle hHal,
8603 bool fEnableFwRssiMonitoring)
8604{
8605 CDF_STATUS cdf_ret_status = CDF_STATUS_SUCCESS;
8606
8607 if (sme_cfg_set_int (hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR,
8608 fEnableFwRssiMonitoring) == CDF_STATUS_E_FAILURE) {
8609 cdf_ret_status = CDF_STATUS_E_FAILURE;
8610 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
8611 "Could not pass on WNI_CFG_PS_RSSI_MONITOR to CFG");
8612 }
8613
8614 return cdf_ret_status;
8615}
8616
8617#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8618/* ---------------------------------------------------------------------------
8619 \fn sme_set_roam_opportunistic_scan_threshold_diff
8620 \brief Update Opportunistic Scan threshold diff
8621 This function is called through dynamic setConfig callback function
8622 to configure nOpportunisticThresholdDiff
8623 \param hHal - HAL handle for device
8624 \param sessionId - Session Identifier
8625 \param nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
8626 \return CDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
8627 successfully.
8628 else SME is failed to update nOpportunisticThresholdDiff.
8629 -------------------------------------------------------------------------*/
8630CDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
8631 uint8_t sessionId,
8632 const uint8_t
8633 nOpportunisticThresholdDiff)
8634{
8635 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8636 CDF_STATUS status = CDF_STATUS_SUCCESS;
8637
8638 status = sme_acquire_global_lock(&pMac->sme);
8639 if (CDF_IS_STATUS_SUCCESS(status)) {
8640 status = csr_neighbor_roam_set_opportunistic_scan_threshold_diff(pMac,
8641 sessionId,
8642 nOpportunisticThresholdDiff);
8643 if (CDF_IS_STATUS_SUCCESS(status)) {
8644 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8645 "LFR runtime successfully set "
8646 "opportunistic threshold diff to %d"
8647 " - old value is %d - roam state is %d",
8648 nOpportunisticThresholdDiff,
8649 pMac->roam.configParam.neighborRoamConfig.
8650 nOpportunisticThresholdDiff,
8651 pMac->roam.neighborRoamInfo[sessionId].
8652 neighborRoamState);
8653 pMac->roam.configParam.neighborRoamConfig.
8654 nOpportunisticThresholdDiff =
8655 nOpportunisticThresholdDiff;
8656 }
8657 sme_release_global_lock(&pMac->sme);
8658 }
8659 return status;
8660}
8661
8662/*--------------------------------------------------------------------------
8663 \fn sme_get_roam_opportunistic_scan_threshold_diff()
8664 \brief gets Opportunistic Scan threshold diff
8665 This is a synchronous call
8666 \param hHal - The handle returned by mac_open
8667 \return uint8_t - nOpportunisticThresholdDiff
8668 \sa
8669 --------------------------------------------------------------------------*/
8670uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
8671{
8672 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8673 return pMac->roam.configParam.neighborRoamConfig.
8674 nOpportunisticThresholdDiff;
8675}
8676
8677/* ---------------------------------------------------------------------------
8678 \fn sme_set_roam_rescan_rssi_diff
8679 \brief Update roam rescan rssi diff
8680 This function is called through dynamic setConfig callback function
8681 to configure nRoamRescanRssiDiff
8682 \param hHal - HAL handle for device
8683 \param sessionId - Session Identifier
8684 \param nRoamRescanRssiDiff - roam rescan rssi diff
8685 \return CDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
8686 successfully.
8687 else SME is failed to update nRoamRescanRssiDiff.
8688 -------------------------------------------------------------------------*/
8689CDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
8690 uint8_t sessionId,
8691 const uint8_t nRoamRescanRssiDiff)
8692{
8693 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8694 CDF_STATUS status = CDF_STATUS_SUCCESS;
8695
8696 status = sme_acquire_global_lock(&pMac->sme);
8697 if (CDF_IS_STATUS_SUCCESS(status)) {
8698 status = csr_neighbor_roam_set_roam_rescan_rssi_diff(pMac, sessionId,
8699 nRoamRescanRssiDiff);
8700 if (CDF_IS_STATUS_SUCCESS(status)) {
8701 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8702 "LFR runtime successfully set "
8703 "opportunistic threshold diff to %d"
8704 " - old value is %d - roam state is %d",
8705 nRoamRescanRssiDiff,
8706 pMac->roam.configParam.neighborRoamConfig.
8707 nRoamRescanRssiDiff,
8708 pMac->roam.neighborRoamInfo[sessionId].
8709 neighborRoamState);
8710 pMac->roam.configParam.neighborRoamConfig.
8711 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
8712 }
8713 sme_release_global_lock(&pMac->sme);
8714 }
8715 return status;
8716}
8717
8718/*--------------------------------------------------------------------------
8719 \fn sme_get_roam_rescan_rssi_diff
8720 \brief gets roam rescan rssi diff
8721 This is a synchronous call
8722 \param hHal - The handle returned by mac_open
8723 \return int8_t - nRoamRescanRssiDiff
8724 \sa
8725 --------------------------------------------------------------------------*/
8726uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
8727{
8728 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8729 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
8730}
8731
8732/* ---------------------------------------------------------------------------
8733 \fn sme_set_roam_bmiss_first_bcnt
8734 \brief Update Roam count for first beacon miss
8735 This function is called through dynamic setConfig callback function
8736 to configure nRoamBmissFirstBcnt
8737 \param hHal - HAL handle for device
8738 \param sessionId - Session Identifier
8739 \param nRoamBmissFirstBcnt - Roam first bmiss count
8740 \return CDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
8741 successfully.
8742 else SME is failed to update nRoamBmissFirstBcnt
8743 -------------------------------------------------------------------------*/
8744CDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
8745 uint8_t sessionId,
8746 const uint8_t nRoamBmissFirstBcnt)
8747{
8748 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8749 CDF_STATUS status = CDF_STATUS_SUCCESS;
8750
8751 status = sme_acquire_global_lock(&pMac->sme);
8752 if (CDF_IS_STATUS_SUCCESS(status)) {
8753 status = csr_neighbor_roam_set_roam_bmiss_first_bcnt(pMac, sessionId,
8754 nRoamBmissFirstBcnt);
8755 if (CDF_IS_STATUS_SUCCESS(status)) {
8756 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8757 "LFR runtime successfully set "
8758 "beacon miss first beacon count to %d"
8759 " - old value is %d - roam state is %d",
8760 nRoamBmissFirstBcnt,
8761 pMac->roam.configParam.neighborRoamConfig.
8762 nRoamBmissFirstBcnt,
8763 pMac->roam.neighborRoamInfo[sessionId].
8764 neighborRoamState);
8765 pMac->roam.configParam.neighborRoamConfig.
8766 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
8767 }
8768 sme_release_global_lock(&pMac->sme);
8769 }
8770 return status;
8771}
8772
8773/* ---------------------------------------------------------------------------
8774 \fn sme_get_roam_bmiss_first_bcnt
8775 \brief get neighbor roam beacon miss first count
8776 \param hHal - The handle returned by mac_open.
8777 \return uint8_t - neighbor roam beacon miss first count
8778 -------------------------------------------------------------------------*/
8779uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
8780{
8781 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8782 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
8783}
8784
8785/* ---------------------------------------------------------------------------
8786 \fn sme_set_roam_bmiss_final_bcnt
8787 \brief Update Roam count for final beacon miss
8788 This function is called through dynamic setConfig callback function
8789 to configure nRoamBmissFinalBcnt
8790 \param hHal - HAL handle for device
8791 \param sessionId - Session Identifier
8792 \param nRoamBmissFinalBcnt - Roam final bmiss count
8793 \return CDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
8794 successfully.
8795 else SME is failed to update nRoamBmissFinalBcnt
8796 -------------------------------------------------------------------------*/
8797CDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
8798 uint8_t sessionId,
8799 const uint8_t nRoamBmissFinalBcnt)
8800{
8801 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8802 CDF_STATUS status = CDF_STATUS_SUCCESS;
8803
8804 status = sme_acquire_global_lock(&pMac->sme);
8805 if (CDF_IS_STATUS_SUCCESS(status)) {
8806 status = csr_neighbor_roam_set_roam_bmiss_final_bcnt(pMac, sessionId,
8807 nRoamBmissFinalBcnt);
8808 if (CDF_IS_STATUS_SUCCESS(status)) {
8809 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8810 "LFR runtime successfully set "
8811 "beacon miss final beacon count to %d"
8812 " - old value is %d - roam state is %d",
8813 nRoamBmissFinalBcnt,
8814 pMac->roam.configParam.neighborRoamConfig.
8815 nRoamBmissFinalBcnt,
8816 pMac->roam.neighborRoamInfo[sessionId].
8817 neighborRoamState);
8818 pMac->roam.configParam.neighborRoamConfig.
8819 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
8820 }
8821 sme_release_global_lock(&pMac->sme);
8822 }
8823 return status;
8824}
8825
8826/*--------------------------------------------------------------------------
8827 \fn sme_get_roam_bmiss_final_bcnt
8828 \brief gets Roam count for final beacon miss
8829 This is a synchronous call
8830 \param hHal - The handle returned by mac_open
8831 \return uint8_t - nRoamBmissFinalBcnt
8832 \sa
8833 --------------------------------------------------------------------------*/
8834uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
8835{
8836 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8837 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
8838}
8839
8840/* ---------------------------------------------------------------------------
8841 \fn sme_set_roam_beacon_rssi_weight
8842 \brief Update Roam beacon rssi weight
8843 This function is called through dynamic setConfig callback function
8844 to configure nRoamBeaconRssiWeight
8845 \param hHal - HAL handle for device
8846 \param sessionId - Session Identifier
8847 \param nRoamBeaconRssiWeight - Roam beacon rssi weight
8848 \return CDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
8849 successfully.
8850 else SME is failed to update nRoamBeaconRssiWeight
8851 -------------------------------------------------------------------------*/
8852CDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
8853 uint8_t sessionId,
8854 const uint8_t nRoamBeaconRssiWeight)
8855{
8856 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8857 CDF_STATUS status = CDF_STATUS_SUCCESS;
8858
8859 status = sme_acquire_global_lock(&pMac->sme);
8860 if (CDF_IS_STATUS_SUCCESS(status)) {
8861 status = csr_neighbor_roam_set_roam_beacon_rssi_weight(pMac, sessionId,
8862 nRoamBeaconRssiWeight);
8863 if (CDF_IS_STATUS_SUCCESS(status)) {
8864 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8865 "LFR runtime successfully set "
8866 "beacon miss final beacon count to %d"
8867 " - old value is %d - roam state is %d",
8868 nRoamBeaconRssiWeight,
8869 pMac->roam.configParam.neighborRoamConfig.
8870 nRoamBeaconRssiWeight,
8871 pMac->roam.neighborRoamInfo[sessionId].
8872 neighborRoamState);
8873 pMac->roam.configParam.neighborRoamConfig.
8874 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
8875 }
8876 sme_release_global_lock(&pMac->sme);
8877 }
8878 return status;
8879}
8880
8881/*--------------------------------------------------------------------------
8882 \fn sme_get_roam_beacon_rssi_weight
8883 \brief gets Roam beacon rssi weight
8884 This is a synchronous call
8885 \param hHal - The handle returned by mac_open
8886 \return uint8_t - nRoamBeaconRssiWeight
8887 \sa
8888 --------------------------------------------------------------------------*/
8889uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
8890{
8891 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8892 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
8893}
8894
8895/*--------------------------------------------------------------------------
8896 \brief sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
8897 rssi threshold
8898 This is a synchronous call
8899 \param hHal - The handle returned by mac_open.
8900 \param sessionId - Session Identifier
8901 \return CDF_STATUS_SUCCESS - SME update config successful.
8902 Other status means SME is failed to update
8903 \sa
8904 --------------------------------------------------------------------------*/
8905CDF_STATUS sme_set_neighbor_lookup_rssi_threshold
8906 (tHalHandle hHal, uint8_t sessionId, uint8_t neighborLookupRssiThreshold) {
8907 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8908 CDF_STATUS status = CDF_STATUS_SUCCESS;
8909
8910 status = sme_acquire_global_lock(&pMac->sme);
8911 if (CDF_IS_STATUS_SUCCESS(status)) {
8912 status = csr_neighbor_roam_set_lookup_rssi_threshold(pMac, sessionId,
8913 neighborLookupRssiThreshold);
8914 if (CDF_IS_STATUS_SUCCESS(status)) {
8915 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8916 "LFR runtime successfully set Lookup threshold to %d - old value is %d - roam state is %s",
8917 neighborLookupRssiThreshold,
8918 pMac->roam.configParam.neighborRoamConfig.
8919 nNeighborLookupRssiThreshold,
8920 mac_trace_get_neighbour_roam_state(pMac->roam.
8921 neighborRoamInfo
8922 [sessionId].
8923 neighborRoamState));
8924 pMac->roam.configParam.neighborRoamConfig.
8925 nNeighborLookupRssiThreshold =
8926 neighborLookupRssiThreshold;
8927 }
8928 sme_release_global_lock(&pMac->sme);
8929 }
8930 return status;
8931}
8932
8933/*--------------------------------------------------------------------------
8934 \brief sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
8935 This is a synchronous call
8936 \param hal - The handle returned by macOpen.
8937 \param session_id - Session Identifier
8938 \param delay_before_vdev_stop - value to be set
8939 \return CDF_STATUS_SUCCESS - SME update config successful.
8940 Other status means SME is failed to update
8941 \sa
8942 --------------------------------------------------------------------------*/
8943CDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
8944 uint8_t session_id,
8945 uint8_t delay_before_vdev_stop)
8946{
8947 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
8948 CDF_STATUS status = CDF_STATUS_SUCCESS;
8949 status = sme_acquire_global_lock(&pMac->sme);
8950 if (CDF_IS_STATUS_SUCCESS(status)) {
8951 CDF_TRACE(CDF_MODULE_ID_SME,
8952 CDF_TRACE_LEVEL_DEBUG,
8953 FL("LFR param delay_before_vdev_stop changed from %d to %d"),
8954 pMac->roam.configParam.neighborRoamConfig.
8955 delay_before_vdev_stop,
8956 delay_before_vdev_stop);
8957 pMac->roam.neighborRoamInfo[session_id].cfgParams.
8958 delay_before_vdev_stop = delay_before_vdev_stop;
8959 pMac->roam.configParam.neighborRoamConfig.
8960 delay_before_vdev_stop = delay_before_vdev_stop;
8961 sme_release_global_lock(&pMac->sme);
8962 }
8963 return status;
8964}
8965
8966/*--------------------------------------------------------------------------
8967 \brief sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
8968 rssi threshold
8969 This is a synchronous call
8970 \param hHal - The handle returned by mac_open.
8971 \return CDF_STATUS_SUCCESS - SME update config successful.
8972 Other status means SME is failed to update
8973 \sa
8974 --------------------------------------------------------------------------*/
8975uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
8976{
8977 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8978 return pMac->roam.configParam.neighborRoamConfig.
8979 nNeighborLookupRssiThreshold;
8980}
8981
8982/*--------------------------------------------------------------------------
8983 \brief sme_set_neighbor_scan_refresh_period() - set neighbor scan results
8984 refresh period
8985 This is a synchronous call
8986 \param hHal - The handle returned by mac_open.
8987 \param sessionId - Session Identifier
8988 \return CDF_STATUS_SUCCESS - SME update config successful.
8989 Other status means SME is failed to update
8990 \sa
8991 --------------------------------------------------------------------------*/
8992CDF_STATUS sme_set_neighbor_scan_refresh_period
8993 (tHalHandle hHal,
8994 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod) {
8995 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8996 CDF_STATUS status = CDF_STATUS_SUCCESS;
8997 tCsrNeighborRoamConfig *pNeighborRoamConfig = NULL;
8998 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8999
9000 status = sme_acquire_global_lock(&pMac->sme);
9001 if (CDF_IS_STATUS_SUCCESS(status)) {
9002 pNeighborRoamConfig =
9003 &pMac->roam.configParam.neighborRoamConfig;
9004 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
9005 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9006 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
9007 neighborScanResultsRefreshPeriod,
9008 pMac->roam.configParam.neighborRoamConfig.
9009 nNeighborResultsRefreshPeriod,
9010 mac_trace_get_neighbour_roam_state(pMac->roam.
9011 neighborRoamInfo
9012 [sessionId].
9013 neighborRoamState));
9014 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
9015 neighborScanResultsRefreshPeriod;
9016 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
9017 neighborScanResultsRefreshPeriod;
9018
9019 sme_release_global_lock(&pMac->sme);
9020 }
9021 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
9022 csr_roam_offload_scan(pMac, sessionId,
9023 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9024 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
9025 }
9026 return status;
9027}
9028
9029/*--------------------------------------------------------------------------
9030 \brief sme_update_roam_scan_offload_enabled() - enable/disable roam scan
9031 offload feaure
9032 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
9033 gRoamScanOffloadEnabled.
9034 This is a synchronous call
9035 \param hHal - The handle returned by mac_open.
9036 \return CDF_STATUS_SUCCESS - SME update config successfully.
9037 Other status means SME is failed to update.
9038 \sa
9039 --------------------------------------------------------------------------*/
9040
9041CDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
9042 bool nRoamScanOffloadEnabled)
9043{
9044 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9045 CDF_STATUS status = CDF_STATUS_SUCCESS;
9046
9047 status = sme_acquire_global_lock(&pMac->sme);
9048 if (CDF_IS_STATUS_SUCCESS(status)) {
9049 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9050 FL
9051 ("gRoamScanOffloadEnabled is changed from %d to %d"),
9052 pMac->roam.configParam.isRoamOffloadScanEnabled,
9053 nRoamScanOffloadEnabled);
9054 pMac->roam.configParam.isRoamOffloadScanEnabled =
9055 nRoamScanOffloadEnabled;
9056 sme_release_global_lock(&pMac->sme);
9057 }
9058
9059 return status;
9060}
9061
9062/*--------------------------------------------------------------------------
9063 \brief sme_get_neighbor_scan_refresh_period() - get neighbor scan results
9064 refresh period
9065 This is a synchronous call
9066 \param hHal - The handle returned by mac_open.
9067 \return uint16_t - Neighbor scan results refresh period value
9068 \sa
9069 --------------------------------------------------------------------------*/
9070uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
9071{
9072 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9073 return pMac->roam.configParam.neighborRoamConfig.
9074 nNeighborResultsRefreshPeriod;
9075}
9076
9077/*--------------------------------------------------------------------------
9078 \brief sme_get_empty_scan_refresh_period() - get empty scan refresh period
9079 This is a synchronuous call
9080 \param hHal - The handle returned by mac_open.
9081 \return CDF_STATUS_SUCCESS - SME update config successful.
9082 Other status means SME is failed to update
9083 \sa
9084 --------------------------------------------------------------------------*/
9085uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
9086{
9087 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9088 return pMac->roam.configParam.neighborRoamConfig.
9089 nEmptyScanRefreshPeriod;
9090}
9091
9092/* ---------------------------------------------------------------------------
9093 \fn sme_update_empty_scan_refresh_period
9094 \brief Update nEmptyScanRefreshPeriod
9095 This function is called through dynamic setConfig callback function
9096 to configure nEmptyScanRefreshPeriod
9097 Usage: adb shell iwpriv wlan0 setConfig
9098 nEmptyScanRefreshPeriod=[0 .. 60]
9099 \param hHal - HAL handle for device
9100 \param sessionId - Session Identifier
9101 \param nEmptyScanRefreshPeriod - scan period following empty scan results.
9102 \- return Success or failure
9103 -------------------------------------------------------------------------*/
9104
9105CDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t sessionId,
9106 uint16_t nEmptyScanRefreshPeriod)
9107{
9108 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9109 CDF_STATUS status = CDF_STATUS_SUCCESS;
9110 tCsrNeighborRoamConfig *pNeighborRoamConfig = NULL;
9111 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
9112
9113 status = sme_acquire_global_lock(&pMac->sme);
9114 if (CDF_IS_STATUS_SUCCESS(status)) {
9115 pNeighborRoamConfig =
9116 &pMac->roam.configParam.neighborRoamConfig;
9117 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
9118 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9119 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
9120 nEmptyScanRefreshPeriod,
9121 pMac->roam.configParam.neighborRoamConfig.
9122 nEmptyScanRefreshPeriod,
9123 mac_trace_get_neighbour_roam_state(pMac->roam.
9124 neighborRoamInfo
9125 [sessionId].
9126 neighborRoamState));
9127 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
9128 nEmptyScanRefreshPeriod;
9129 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
9130 nEmptyScanRefreshPeriod;
9131 sme_release_global_lock(&pMac->sme);
9132 }
9133 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
9134 csr_roam_offload_scan(pMac, sessionId,
9135 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9136 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
9137 }
9138 return status;
9139}
9140
9141/* ---------------------------------------------------------------------------
9142 \fn sme_set_neighbor_scan_min_chan_time
9143 \brief Update nNeighborScanMinChanTime
9144 This function is called through dynamic setConfig callback function
9145 to configure gNeighborScanChannelMinTime
9146 Usage: adb shell iwpriv wlan0 setConfig
9147 gNeighborScanChannelMinTime=[0 .. 60]
9148 \param hHal - HAL handle for device
9149 \param nNeighborScanMinChanTime - Channel minimum dwell time
9150 \param sessionId - Session Identifier
9151 \- return Success or failure
9152 -------------------------------------------------------------------------*/
9153CDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
9154 const uint16_t
9155 nNeighborScanMinChanTime,
9156 uint8_t sessionId)
9157{
9158 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9159 CDF_STATUS status = CDF_STATUS_SUCCESS;
9160
9161 status = sme_acquire_global_lock(&pMac->sme);
9162 if (CDF_IS_STATUS_SUCCESS(status)) {
9163 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9164 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
9165 nNeighborScanMinChanTime,
9166 pMac->roam.configParam.neighborRoamConfig.
9167 nNeighborScanMinChanTime,
9168 mac_trace_get_neighbour_roam_state(pMac->roam.
9169 neighborRoamInfo
9170 [sessionId].
9171 neighborRoamState));
9172
9173 pMac->roam.configParam.neighborRoamConfig.
9174 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
9175 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
9176 minChannelScanTime = nNeighborScanMinChanTime;
9177 sme_release_global_lock(&pMac->sme);
9178 }
9179
9180 return status;
9181}
9182
9183/* ---------------------------------------------------------------------------
9184 \fn sme_set_neighbor_scan_max_chan_time
9185 \brief Update nNeighborScanMaxChanTime
9186 This function is called through dynamic setConfig callback function
9187 to configure gNeighborScanChannelMaxTime
9188 Usage: adb shell iwpriv wlan0 setConfig
9189 gNeighborScanChannelMaxTime=[0 .. 60]
9190 \param hHal - HAL handle for device
9191 \param sessionId - Session Identifier
9192 \param nNeighborScanMinChanTime - Channel maximum dwell time
9193 \- return Success or failure
9194 -------------------------------------------------------------------------*/
9195CDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId,
9196 const uint16_t
9197 nNeighborScanMaxChanTime)
9198{
9199 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9200 CDF_STATUS status = CDF_STATUS_SUCCESS;
9201 tCsrNeighborRoamConfig *pNeighborRoamConfig = NULL;
9202 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
9203
9204 status = sme_acquire_global_lock(&pMac->sme);
9205 if (CDF_IS_STATUS_SUCCESS(status)) {
9206 pNeighborRoamConfig =
9207 &pMac->roam.configParam.neighborRoamConfig;
9208 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
9209 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9210 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
9211 nNeighborScanMaxChanTime,
9212 pMac->roam.configParam.neighborRoamConfig.
9213 nNeighborScanMaxChanTime,
9214 mac_trace_get_neighbour_roam_state(pMac->roam.
9215 neighborRoamInfo
9216 [sessionId].
9217 neighborRoamState));
9218 pNeighborRoamConfig->nNeighborScanMaxChanTime =
9219 nNeighborScanMaxChanTime;
9220 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
9221 nNeighborScanMaxChanTime;
9222 sme_release_global_lock(&pMac->sme);
9223 }
9224 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
9225 csr_roam_offload_scan(pMac, sessionId,
9226 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9227 REASON_SCAN_CH_TIME_CHANGED);
9228 }
9229
9230 return status;
9231}
9232
9233/* ---------------------------------------------------------------------------
9234 \fn sme_get_neighbor_scan_min_chan_time
9235 \brief get neighbor scan min channel time
9236 \param hHal - The handle returned by mac_open.
9237 \param sessionId - Session Identifier
9238 \return uint16_t - channel min time value
9239 -------------------------------------------------------------------------*/
9240uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
9241{
9242 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9243 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
9244 minChannelScanTime;
9245}
9246
9247/* ---------------------------------------------------------------------------
9248 \fn sme_get_neighbor_roam_state
9249 \brief get neighbor roam state
9250 \param hHal - The handle returned by mac_open.
9251 \param sessionId - Session Identifier
9252 \return uint32_t - neighbor roam state
9253 -------------------------------------------------------------------------*/
9254uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
9255{
9256 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9257 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
9258}
9259
9260/* ---------------------------------------------------------------------------
9261 \fn sme_get_current_roam_state
9262 \brief get current roam state
9263 \param hHal - The handle returned by mac_open.
9264 \param sessionId - Session Identifier
9265 \return uint32_t - current roam state
9266 -------------------------------------------------------------------------*/
9267uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
9268{
9269 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9270 return pMac->roam.curState[sessionId];
9271}
9272
9273/* ---------------------------------------------------------------------------
9274 \fn sme_get_current_roam_sub_state
9275 \brief get neighbor roam sub state
9276 \param hHal - The handle returned by mac_open.
9277 \param sessionId - Session Identifier
9278 \return uint32_t - current roam sub state
9279 -------------------------------------------------------------------------*/
9280uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
9281{
9282 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9283 return pMac->roam.curSubState[sessionId];
9284}
9285
9286/* ---------------------------------------------------------------------------
9287 \fn sme_get_lim_sme_state
9288 \brief get Lim Sme state
9289 \param hHal - The handle returned by mac_open.
9290 \return uint32_t - Lim Sme state
9291 -------------------------------------------------------------------------*/
9292uint32_t sme_get_lim_sme_state(tHalHandle hHal)
9293{
9294 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9295 return pMac->lim.gLimSmeState;
9296}
9297
9298/* ---------------------------------------------------------------------------
9299 \fn sme_get_lim_mlm_state
9300 \brief get Lim Mlm state
9301 \param hHal - The handle returned by mac_open.
9302 \return uint32_t - Lim Mlm state
9303 -------------------------------------------------------------------------*/
9304uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
9305{
9306 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9307 return pMac->lim.gLimMlmState;
9308}
9309
9310/* ---------------------------------------------------------------------------
9311 \fn sme_is_lim_session_valid
9312 \brief is Lim session valid
9313 \param hHal - The handle returned by mac_open.
9314 \param sessionId - Session Identifier
9315 \return bool - true or false
9316 -------------------------------------------------------------------------*/
9317bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
9318{
9319 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05309320
9321 if (sessionId > pMac->lim.maxBssId)
9322 return false;
9323
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009324 return pMac->lim.gpSession[sessionId].valid;
9325}
9326
9327/* ---------------------------------------------------------------------------
9328 \fn sme_get_lim_sme_session_state
9329 \brief get Lim Sme session state
9330 \param hHal - The handle returned by mac_open.
9331 \param sessionId - Session Identifier
9332 \return uint32_t - Lim Sme session state
9333 -------------------------------------------------------------------------*/
9334uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
9335{
9336 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9337 return pMac->lim.gpSession[sessionId].limSmeState;
9338}
9339
9340/* ---------------------------------------------------------------------------
9341 \fn sme_get_lim_mlm_session_state
9342 \brief get Lim Mlm session state
9343 \param hHal - The handle returned by mac_open.
9344 \param sessionId - Session Identifier
9345 \return uint32_t - Lim Mlm session state
9346 -------------------------------------------------------------------------*/
9347uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
9348{
9349 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9350 return pMac->lim.gpSession[sessionId].limMlmState;
9351}
9352
9353/* ---------------------------------------------------------------------------
9354 \fn sme_get_neighbor_scan_max_chan_time
9355 \brief get neighbor scan max channel time
9356 \param hHal - The handle returned by mac_open.
9357 \param sessionId - Session Identifier
9358 \return uint16_t - channel max time value
9359 -------------------------------------------------------------------------*/
9360uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
9361{
9362 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9363 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
9364 maxChannelScanTime;
9365}
9366
9367/* ---------------------------------------------------------------------------
9368 \fn sme_set_neighbor_scan_period
9369 \brief Update nNeighborScanPeriod
9370 This function is called through dynamic setConfig callback function
9371 to configure nNeighborScanPeriod
9372 Usage: adb shell iwpriv wlan0 setConfig
9373 nNeighborScanPeriod=[0 .. 1000]
9374 \param hHal - HAL handle for device
9375 \param sessionId - Session Identifier
9376 \param nNeighborScanPeriod - neighbor scan period
9377 \- return Success or failure
9378 -------------------------------------------------------------------------*/
9379CDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
9380 const uint16_t nNeighborScanPeriod)
9381{
9382 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9383 CDF_STATUS status = CDF_STATUS_SUCCESS;
9384 tCsrNeighborRoamConfig *pNeighborRoamConfig = NULL;
9385 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
9386
9387 status = sme_acquire_global_lock(&pMac->sme);
9388 if (CDF_IS_STATUS_SUCCESS(status)) {
9389 pNeighborRoamConfig =
9390 &pMac->roam.configParam.neighborRoamConfig;
9391 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
9392 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9393 "LFR runtime successfully set neighbor scan period to %d"
9394 " - old value is %d - roam state is %s",
9395 nNeighborScanPeriod,
9396 pMac->roam.configParam.neighborRoamConfig.
9397 nNeighborScanTimerPeriod,
9398 mac_trace_get_neighbour_roam_state(pMac->roam.
9399 neighborRoamInfo
9400 [sessionId].
9401 neighborRoamState));
9402 pNeighborRoamConfig->nNeighborScanTimerPeriod =
9403 nNeighborScanPeriod;
9404 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
9405 nNeighborScanPeriod;
9406 sme_release_global_lock(&pMac->sme);
9407 }
9408 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
9409 csr_roam_offload_scan(pMac, sessionId,
9410 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9411 REASON_SCAN_HOME_TIME_CHANGED);
9412 }
9413
9414 return status;
9415}
9416
9417/* ---------------------------------------------------------------------------
9418 \fn sme_get_neighbor_scan_period
9419 \brief get neighbor scan period
9420 \param hHal - The handle returned by mac_open.
9421 \param sessionId - Session Identifier
9422 \return uint16_t - neighbor scan period
9423 -------------------------------------------------------------------------*/
9424uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
9425{
9426 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9427 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
9428 neighborScanPeriod;
9429}
9430
9431#endif
9432
9433#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
9434
9435/*--------------------------------------------------------------------------
9436 \brief sme_get_roam_rssi_diff() - get Roam rssi diff
9437 This is a synchronous call
9438 \param hHal - The handle returned by mac_open.
9439 \return uint16_t - Rssi diff value
9440 \sa
9441 --------------------------------------------------------------------------*/
9442uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
9443{
9444 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9445 return pMac->roam.configParam.RoamRssiDiff;
9446}
9447
9448/**
9449 * sme_change_roam_scan_channel_list() - to change scan channel list
9450 * @hHal: pointer HAL handle returned by mac_open
9451 * @sessionId: sme session id
9452 * @pChannelList: Output channel list
9453 * @numChannels: Output number of channels
9454 *
9455 * This routine is called to Change roam scan channel list.
9456 * This is a synchronous call
9457 *
9458 * Return: CDF_STATUS
9459 */
9460CDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
9461 uint8_t *pChannelList,
9462 uint8_t numChannels)
9463{
9464 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9465 CDF_STATUS status = CDF_STATUS_SUCCESS;
9466 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
9467 &pMac->roam.neighborRoamInfo[sessionId];
9468 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
9469 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
9470 uint8_t i = 0, j = 0;
9471 tCsrChannelInfo *chan_info;
9472
9473
9474 status = sme_acquire_global_lock(&pMac->sme);
9475 if (!CDF_IS_STATUS_SUCCESS(status)) {
9476 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9477 csr_roam_offload_scan(pMac, sessionId,
9478 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9479 REASON_CHANNEL_LIST_CHANGED);
9480 return status;
9481 }
9482 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
9483
9484 if (NULL != chan_info->ChannelList) {
9485 for (i = 0; i < chan_info->numOfChannels; i++) {
9486 if (j < sizeof(oldChannelList))
9487 j += snprintf(oldChannelList + j,
9488 sizeof(oldChannelList) -
9489 j, "%d",
9490 chan_info->ChannelList[i]);
9491 else
9492 break;
9493 }
9494 }
9495 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
9496 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
9497 numChannels);
9498 sme_set_roam_scan_control(hHal, sessionId, 1);
9499 if (NULL != chan_info->ChannelList) {
9500 j = 0;
9501 for (i = 0; i < chan_info->numOfChannels; i++) {
9502 if (j < sizeof(newChannelList))
9503 j += snprintf(newChannelList + j,
9504 sizeof(newChannelList) -
9505 j, " %d",
9506 chan_info->ChannelList[i]);
9507 else
9508 break;
9509 }
9510 }
9511 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9512 FL("LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d"),
9513 newChannelList, oldChannelList,
9514 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
9515 sme_release_global_lock(&pMac->sme);
9516
9517 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9518 csr_roam_offload_scan(pMac, sessionId,
9519 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9520 REASON_CHANNEL_LIST_CHANGED);
9521 return status;
9522}
9523
9524#ifdef FEATURE_WLAN_ESE_UPLOAD
9525/**
9526 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
9527 * @hHal: pointer HAL handle returned by mac_open
9528 * @sessionId: sme session id
9529 * @pChannelList: Output channel list
9530 * @numChannels: Output number of channels
9531 *
9532 * This routine is called to set ese roam scan channel list.
9533 * This is a synchronous call
9534 *
9535 * Return: CDF_STATUS
9536 */
9537CDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
9538 uint8_t sessionId,
9539 uint8_t *pChannelList,
9540 uint8_t numChannels)
9541{
9542 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9543 CDF_STATUS status = CDF_STATUS_SUCCESS;
9544 tpCsrNeighborRoamControlInfo pNeighborRoamInfo
9545 = &pMac->roam.neighborRoamInfo[sessionId];
9546 tpCsrChannelInfo curchnl_list_info
9547 = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
9548 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
9549 uint8_t newChannelList[128] = { 0 };
9550 uint8_t i = 0, j = 0;
9551
9552 status = sme_acquire_global_lock(&pMac->sme);
9553 if (!CDF_IS_STATUS_SUCCESS(status)) {
9554 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9555 csr_roam_offload_scan(pMac, sessionId,
9556 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9557 REASON_CHANNEL_LIST_CHANGED);
9558 return status;
9559 }
9560 if (NULL != curchnl_list_info->ChannelList) {
9561 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
9562 j += snprintf(oldChannelList + j,
9563 sizeof(oldChannelList) - j, "%d",
9564 curchnl_list_info->ChannelList[i]);
9565 }
9566 }
9567 status = csr_create_roam_scan_channel_list(pMac, sessionId,
9568 pChannelList, numChannels,
9569 csr_get_current_band(hHal));
9570 if (CDF_IS_STATUS_SUCCESS(status)) {
9571 if (NULL != curchnl_list_info->ChannelList) {
9572 j = 0;
9573 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
9574 j += snprintf(newChannelList + j,
9575 sizeof(newChannelList) - j, "%d",
9576 curchnl_list_info->ChannelList[i]);
9577 }
9578 }
9579 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9580 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
9581 newChannelList, oldChannelList,
9582 pNeighborRoamInfo->neighborRoamState);
9583 }
9584 sme_release_global_lock(&pMac->sme);
9585 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9586 csr_roam_offload_scan(pMac, sessionId,
9587 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9588 REASON_CHANNEL_LIST_CHANGED);
9589 return status;
9590}
9591#endif
9592
9593/**
9594 * sme_get_roam_scan_channel_list() - To get roam scan channel list
9595 * @hHal: HAL pointer
9596 * @pChannelList: Output channel list
9597 * @pNumChannels: Output number of channels
9598 * @sessionId: Session Identifier
9599 *
9600 * To get roam scan channel list This is a synchronous call
9601 *
9602 * Return: CDF_STATUS
9603 */
9604CDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
9605 uint8_t *pChannelList, uint8_t *pNumChannels,
9606 uint8_t sessionId)
9607{
9608 int i = 0;
9609 uint8_t *pOutPtr = pChannelList;
9610 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9611 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
9612 &pMac->roam.neighborRoamInfo[sessionId];
9613 CDF_STATUS status = CDF_STATUS_SUCCESS;
9614
9615 status = sme_acquire_global_lock(&pMac->sme);
9616 if (!CDF_IS_STATUS_SUCCESS(status))
9617 return status;
9618 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
9619 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_WARN,
9620 FL("Roam Scan channel list is NOT yet initialized"));
9621 *pNumChannels = 0;
9622 sme_release_global_lock(&pMac->sme);
9623 return status;
9624 }
9625
9626 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
9627 for (i = 0; i < (*pNumChannels); i++) {
9628 pOutPtr[i] =
9629 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
9630 }
9631 pOutPtr[i] = '\0';
9632 sme_release_global_lock(&pMac->sme);
9633 return status;
9634}
9635
9636/*--------------------------------------------------------------------------
9637 \brief sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
9638 This is a synchronuous call
9639 \param hHal - The handle returned by mac_open.
9640 \return true (1) - if the ESE feature is enabled
9641 false (0) - if feature is disabled (compile or runtime)
9642 \sa
9643 --------------------------------------------------------------------------*/
9644bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
9645{
9646#ifdef FEATURE_WLAN_ESE
9647 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9648 return csr_roam_is_ese_ini_feature_enabled(pMac);
9649#else
9650 return false;
9651#endif
9652}
9653
9654/*--------------------------------------------------------------------------
9655 \brief sme_get_wes_mode() - get WES Mode
9656 This is a synchronous call
9657 \param hHal - The handle returned by mac_open
9658 \return uint8_t - WES Mode Enabled(1)/Disabled(0)
9659 \sa
9660 --------------------------------------------------------------------------*/
9661bool sme_get_wes_mode(tHalHandle hHal)
9662{
9663 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9664 return pMac->roam.configParam.isWESModeEnabled;
9665}
9666
9667/*--------------------------------------------------------------------------
9668 \brief sme_get_roam_scan_control() - get scan control
9669 This is a synchronous call
9670 \param hHal - The handle returned by mac_open.
9671 \return bool - Enabled(1)/Disabled(0)
9672 \sa
9673 --------------------------------------------------------------------------*/
9674bool sme_get_roam_scan_control(tHalHandle hHal)
9675{
9676 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9677 return pMac->roam.configParam.nRoamScanControl;
9678}
9679#endif
9680
9681/*--------------------------------------------------------------------------
9682 \brief sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
9683 This is a synchronuous call
9684 \param hHal - The handle returned by mac_open.
9685 \return true (1) - if the feature is enabled
9686 false (0) - if feature is disabled (compile or runtime)
9687 \sa
9688 --------------------------------------------------------------------------*/
9689bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
9690{
9691#ifdef FEATURE_WLAN_LFR
9692 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9693 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
9694#else
9695 return false;
9696#endif
9697}
9698
9699/*--------------------------------------------------------------------------
9700 \brief sme_get_is_ft_feature_enabled() - get FT feature enabled or not
9701 This is a synchronuous call
9702 \param hHal - The handle returned by mac_open.
9703 \return true (1) - if the feature is enabled
9704 false (0) - if feature is disabled (compile or runtime)
9705 \sa
9706 --------------------------------------------------------------------------*/
9707bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
9708{
9709#ifdef WLAN_FEATURE_VOWIFI_11R
9710 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9711 return pMac->roam.configParam.isFastTransitionEnabled;
9712#else
9713 return false;
9714#endif
9715}
9716
9717/* ---------------------------------------------------------------------------
9718 \fn sme_is_feature_supported_by_fw
9719 \brief Check if an feature is enabled by FW
9720
9721 \param feattEnumValue - Enumeration value from placeHolderInCapBitmap
9722 \- return 1/0 (true/false)
9723 -------------------------------------------------------------------------*/
9724uint8_t sme_is_feature_supported_by_fw(uint8_t featEnumValue)
9725{
9726 return IS_FEATURE_SUPPORTED_BY_FW(featEnumValue);
9727}
9728
9729#ifdef FEATURE_WLAN_TDLS
9730
9731/* ---------------------------------------------------------------------------
9732 \fn sme_send_tdls_link_establish_params
9733 \brief API to send TDLS Peer Link Establishment Parameters.
9734
9735 \param peerMac - peer's Mac Adress.
9736 \param tdlsLinkEstablishParams - TDLS Peer Link Establishment Parameters
9737 \- return CDF_STATUS_SUCCES
9738 -------------------------------------------------------------------------*/
9739CDF_STATUS sme_send_tdls_link_establish_params(tHalHandle hHal,
9740 uint8_t sessionId,
9741 const tSirMacAddr peerMac,
9742 tCsrTdlsLinkEstablishParams *
9743 tdlsLinkEstablishParams)
9744{
9745 CDF_STATUS status = CDF_STATUS_SUCCESS;
9746 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9747
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05309748 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
9749 TRACE_CODE_SME_RX_HDD_TDLS_LINK_ESTABLISH_PARAM,
9750 sessionId,
9751 tdlsLinkEstablishParams->isOffChannelSupported));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009752 status = sme_acquire_global_lock(&pMac->sme);
9753
9754 if (CDF_IS_STATUS_SUCCESS(status)) {
9755 status = csr_tdls_send_link_establish_params(hHal, sessionId,
9756 peerMac, tdlsLinkEstablishParams);
9757 sme_release_global_lock(&pMac->sme);
9758 }
9759 return status;
9760}
9761
9762/* ---------------------------------------------------------------------------
9763 \fn sme_send_tdls_mgmt_frame
9764 \brief API to send TDLS management frames.
9765
9766 \param peerMac - peer's Mac Adress.
9767 \param frame_type - Type of TDLS mgmt frame to be sent.
9768 \param dialog - dialog token used in the frame.
9769 \param status - status to be incuded in the frame.
9770 \param peerCapability - peer cpabilities
9771 \param buf - additional IEs to be included
9772 \param len - lenght of additional Ies
9773 \param responder - Tdls request type
9774 \- return CDF_STATUS_SUCCES
9775 -------------------------------------------------------------------------*/
9776CDF_STATUS sme_send_tdls_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
9777 const tSirMacAddr peerMac,
9778 uint8_t frame_type,
9779 uint8_t dialog, uint16_t statusCode,
9780 uint32_t peerCapability, uint8_t *buf,
9781 uint8_t len, uint8_t responder)
9782{
9783 CDF_STATUS status = CDF_STATUS_SUCCESS;
9784 tCsrTdlsSendMgmt sendTdlsReq = { {0} };
9785 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9786
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05309787 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
9788 TRACE_CODE_SME_RX_HDD_TDLS_SEND_MGMT_FRAME,
9789 sessionId, statusCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009790 status = sme_acquire_global_lock(&pMac->sme);
9791 if (CDF_IS_STATUS_SUCCESS(status)) {
9792 cdf_mem_copy(sendTdlsReq.peerMac, peerMac, sizeof(tSirMacAddr));
9793 sendTdlsReq.frameType = frame_type;
9794 sendTdlsReq.buf = buf;
9795 sendTdlsReq.len = len;
9796 sendTdlsReq.dialog = dialog;
9797 sendTdlsReq.statusCode = statusCode;
9798 sendTdlsReq.responder = responder;
9799 sendTdlsReq.peerCapability = peerCapability;
9800
9801 status = csr_tdls_send_mgmt_req(hHal, sessionId, &sendTdlsReq);
9802
9803 sme_release_global_lock(&pMac->sme);
9804 }
9805
9806 return status;
9807
9808}
9809
9810/* ---------------------------------------------------------------------------
9811 \fn sme_change_tdls_peer_sta
9812 \brief API to Update TDLS peer sta parameters.
9813
9814 \param peerMac - peer's Mac Adress.
9815 \param staParams - Peer Station Parameters
9816 \- return CDF_STATUS_SUCCES
9817 -------------------------------------------------------------------------*/
9818CDF_STATUS sme_change_tdls_peer_sta(tHalHandle hHal, uint8_t sessionId,
9819 const tSirMacAddr peerMac,
9820 tCsrStaParams *pstaParams)
9821{
9822 CDF_STATUS status = CDF_STATUS_SUCCESS;
9823 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9824
9825 if (NULL == pstaParams) {
9826 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
9827 "%s :pstaParams is NULL", __func__);
9828 return CDF_STATUS_E_FAILURE;
9829 }
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05309830 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
9831 TRACE_CODE_SME_RX_HDD_TDLS_CHANGE_PEER_STA,
9832 sessionId, pstaParams->capability));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009833 status = sme_acquire_global_lock(&pMac->sme);
9834 if (CDF_IS_STATUS_SUCCESS(status)) {
9835 status = csr_tdls_change_peer_sta(hHal, sessionId, peerMac,
9836 pstaParams);
9837
9838 sme_release_global_lock(&pMac->sme);
9839 }
9840
9841 return status;
9842
9843}
9844
9845/* ---------------------------------------------------------------------------
9846 \fn sme_add_tdls_peer_sta
9847 \brief API to Add TDLS peer sta entry.
9848
9849 \param peerMac - peer's Mac Adress.
9850 \- return CDF_STATUS_SUCCES
9851 -------------------------------------------------------------------------*/
9852CDF_STATUS sme_add_tdls_peer_sta(tHalHandle hHal, uint8_t sessionId,
9853 const tSirMacAddr peerMac)
9854{
9855 CDF_STATUS status = CDF_STATUS_SUCCESS;
9856 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9857
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05309858 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
9859 TRACE_CODE_SME_RX_HDD_TDLS_ADD_PEER_STA,
9860 sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009861 status = sme_acquire_global_lock(&pMac->sme);
9862 if (CDF_IS_STATUS_SUCCESS(status)) {
9863 status = csr_tdls_add_peer_sta(hHal, sessionId, peerMac);
9864
9865 sme_release_global_lock(&pMac->sme);
9866 }
9867
9868 return status;
9869
9870}
9871
9872/* ---------------------------------------------------------------------------
9873 \fn sme_delete_tdls_peer_sta
9874 \brief API to Delete TDLS peer sta entry.
9875
9876 \param peerMac - peer's Mac Adress.
9877 \- return CDF_STATUS_SUCCES
9878 -------------------------------------------------------------------------*/
9879CDF_STATUS sme_delete_tdls_peer_sta(tHalHandle hHal, uint8_t sessionId,
9880 const tSirMacAddr peerMac)
9881{
9882 CDF_STATUS status = CDF_STATUS_SUCCESS;
9883 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9884
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05309885 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
9886 TRACE_CODE_SME_RX_HDD_TDLS_DEL_PEER_STA,
9887 sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009888 status = sme_acquire_global_lock(&pMac->sme);
9889 if (CDF_IS_STATUS_SUCCESS(status)) {
9890 status = csr_tdls_del_peer_sta(hHal, sessionId, peerMac);
9891
9892 sme_release_global_lock(&pMac->sme);
9893 }
9894
9895 return status;
9896
9897}
9898
9899/* ---------------------------------------------------------------------------
9900 \fn sme_set_tdls_power_save_prohibited
9901 \API to set/reset the is_tdls_power_save_prohibited.
9902
9903 \- return void
9904 -------------------------------------------------------------------------*/
9905void sme_set_tdls_power_save_prohibited(tHalHandle hHal, uint32_t sessionId,
9906 bool val)
9907{
9908 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9909 struct ps_global_info *ps_global_info = &pMac->sme.ps_global_info;
9910 struct ps_params *ps_param = &ps_global_info->ps_params[sessionId];
9911 ps_param->is_tdls_power_save_prohibited = val;
9912 return;
9913}
9914
9915/* ---------------------------------------------------------------------------
9916 \fn sme_update_fw_tdls_state
9917
9918 \brief
9919 SME will send message to WMA to set TDLS state in f/w
9920
9921 \param
9922
9923 hHal - The handle returned by mac_open
9924
9925 psmeTdlsParams - TDLS state info to update in f/w
9926
9927 useSmeLock - Need to acquire SME Global Lock before state update or not
9928
9929 \return CDF_STATUS
9930 --------------------------------------------------------------------------- */
9931CDF_STATUS sme_update_fw_tdls_state(tHalHandle hHal, void *psmeTdlsParams,
9932 bool useSmeLock)
9933{
9934 CDF_STATUS status = CDF_STATUS_SUCCESS;
9935 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
9936 tpAniSirGlobal pMac = NULL;
9937 cds_msg_t cds_message;
9938
9939 /* only acquire sme global lock before state update if asked to */
9940 if (useSmeLock) {
9941 pMac = PMAC_STRUCT(hHal);
9942 if (NULL == pMac)
9943 return CDF_STATUS_E_FAILURE;
9944
9945 status = sme_acquire_global_lock(&pMac->sme);
9946 if (CDF_STATUS_SUCCESS != status)
9947 return status;
9948 }
9949
9950 /* serialize the req through MC thread */
9951 cds_message.bodyptr = psmeTdlsParams;
9952 cds_message.type = WMA_UPDATE_FW_TDLS_STATE;
9953 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
9954 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
9955 status = CDF_STATUS_E_FAILURE;
9956
9957 /* release the lock if it was acquired */
9958 if (useSmeLock)
9959 sme_release_global_lock(&pMac->sme);
9960
9961 return status;
9962}
9963
9964/**
9965 * sme_update_tdls_peer_state() - to update the state of TDLS peer
9966 * @hHal: The handle returned by mac_open
9967 * @peerStateParams: TDLS Peer state info to update in f/w
9968 *
9969 * SME will send message to WMA to set TDLS Peer state in f/w
9970 *
9971 * Return: CDF_STATUS
9972 */
9973CDF_STATUS sme_update_tdls_peer_state(tHalHandle hHal,
9974 tSmeTdlsPeerStateParams *peerStateParams)
9975{
9976 CDF_STATUS status = CDF_STATUS_SUCCESS;
9977 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
9978 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9979 tTdlsPeerStateParams *pTdlsPeerStateParams = NULL;
9980 tTdlsPeerCapParams *peer_cap = NULL;
9981 cds_msg_t cds_message;
9982 uint8_t num;
9983 uint8_t chanId;
9984 uint8_t i;
9985
9986 status = sme_acquire_global_lock(&pMac->sme);
9987 if (!CDF_IS_STATUS_SUCCESS(status))
9988 return status;
9989 pTdlsPeerStateParams = cdf_mem_malloc(sizeof(*pTdlsPeerStateParams));
9990 if (NULL == pTdlsPeerStateParams) {
9991 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
9992 FL("failed to allocate mem for tdls peer state param"));
9993 sme_release_global_lock(&pMac->sme);
9994 return CDF_STATUS_E_NOMEM;
9995 }
9996
9997 cdf_mem_zero(pTdlsPeerStateParams, sizeof(*pTdlsPeerStateParams));
9998 cdf_mem_copy(&pTdlsPeerStateParams->peerMacAddr,
9999 &peerStateParams->peerMacAddr, sizeof(tSirMacAddr));
10000 pTdlsPeerStateParams->vdevId = peerStateParams->vdevId;
10001 pTdlsPeerStateParams->peerState = peerStateParams->peerState;
10002
10003 switch (peerStateParams->peerState) {
10004 case eSME_TDLS_PEER_STATE_PEERING:
10005 pTdlsPeerStateParams->peerState =
10006 WMA_TDLS_PEER_STATE_PEERING;
10007 break;
10008
10009 case eSME_TDLS_PEER_STATE_CONNECTED:
10010 pTdlsPeerStateParams->peerState =
10011 WMA_TDLS_PEER_STATE_CONNECTED;
10012 break;
10013
10014 case eSME_TDLS_PEER_STATE_TEARDOWN:
10015 pTdlsPeerStateParams->peerState =
10016 WMA_TDLS_PEER_STATE_TEARDOWN;
10017 break;
10018
Kabilan Kannan421714b2015-11-23 04:44:59 -080010019 case eSME_TDLS_PEER_ADD_MAC_ADDR:
10020 pTdlsPeerStateParams->peerState = WMA_TDLS_PEER_ADD_MAC_ADDR;
10021 break;
10022
10023 case eSME_TDLS_PEER_REMOVE_MAC_ADDR:
10024 pTdlsPeerStateParams->peerState = WMA_TDLS_PEER_REMOVE_MAC_ADDR;
10025 break;
10026
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010027 default:
10028 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10029 FL("invalid peer state param (%d)"),
10030 peerStateParams->peerState);
10031 cdf_mem_free(pTdlsPeerStateParams);
10032 sme_release_global_lock(&pMac->sme);
10033 return CDF_STATUS_E_FAILURE;
10034 }
10035 peer_cap = &(pTdlsPeerStateParams->peerCap);
10036 peer_cap->isPeerResponder =
10037 peerStateParams->peerCap.isPeerResponder;
10038 peer_cap->peerUapsdQueue =
10039 peerStateParams->peerCap.peerUapsdQueue;
10040 peer_cap->peerMaxSp =
10041 peerStateParams->peerCap.peerMaxSp;
10042 peer_cap->peerBuffStaSupport =
10043 peerStateParams->peerCap.peerBuffStaSupport;
10044 peer_cap->peerOffChanSupport =
10045 peerStateParams->peerCap.peerOffChanSupport;
10046 peer_cap->peerCurrOperClass =
10047 peerStateParams->peerCap.peerCurrOperClass;
10048 peer_cap->selfCurrOperClass =
10049 peerStateParams->peerCap.selfCurrOperClass;
10050
10051 num = 0;
10052 for (i = 0; i < peerStateParams->peerCap.peerChanLen; i++) {
10053 chanId = peerStateParams->peerCap.peerChan[i];
10054 if (!csr_roam_is_channel_valid(pMac, chanId))
10055 continue;
10056 peer_cap->peerChan[num].chanId = chanId;
10057 peer_cap->peerChan[num].pwr =
10058 csr_get_cfg_max_tx_power(pMac, chanId);
10059
10060 if (cds_get_channel_state(chanId) == CHANNEL_STATE_DFS)
10061 peer_cap->peerChan[num].dfsSet =
10062 true;
10063 else
10064 peer_cap->peerChan[num].dfsSet =
10065 false;
10066 num++;
10067 }
10068 peer_cap->peerChanLen = num;
10069 peer_cap->peerOperClassLen =
10070 peerStateParams->peerCap.peerOperClassLen;
10071 for (i = 0; i < HAL_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10072 peer_cap->peerOperClass[i] =
10073 peerStateParams->peerCap.peerOperClass[i];
10074 }
10075
10076 peer_cap->prefOffChanNum =
10077 peerStateParams->peerCap.prefOffChanNum;
10078 peer_cap->prefOffChanBandwidth =
10079 peerStateParams->peerCap.prefOffChanBandwidth;
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053010080 peer_cap->opClassForPrefOffChan =
10081 peerStateParams->peerCap.opClassForPrefOffChan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010082
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010083 cds_message.type = WMA_UPDATE_TDLS_PEER_STATE;
10084 cds_message.reserved = 0;
10085 cds_message.bodyptr = pTdlsPeerStateParams;
10086
10087 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
10088 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
10089 cdf_mem_free(pTdlsPeerStateParams);
10090 status = CDF_STATUS_E_FAILURE;
10091 }
10092 sme_release_global_lock(&pMac->sme);
10093 return status;
10094}
10095
10096/**
10097 * sme_send_tdls_chan_switch_req() - send tdls channel switch request
10098 * @hal: UMAC handler
10099 * @ch_switch_params: Pointer to the chan switch parameter structure
10100 *
10101 * API to set tdls channel switch parameters.
10102 *
10103 * Return: CDF_STATUS_SUCCESS on success; another CDF_STATUS_* code otherwise
10104 */
10105CDF_STATUS sme_send_tdls_chan_switch_req(tHalHandle hal,
10106 sme_tdls_chan_switch_params *ch_switch_params)
10107{
10108 CDF_STATUS status = CDF_STATUS_SUCCESS;
10109 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
10110 tpAniSirGlobal mac = PMAC_STRUCT(hal);
10111 tdls_chan_switch_params *chan_switch_params = NULL;
10112 cds_msg_t cds_message;
10113
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +053010114 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
10115 TRACE_CODE_SME_RX_HDD_TDLS_CHAN_SWITCH_REQ,
10116 NO_SESSION, ch_switch_params->tdls_off_channel));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010117 status = sme_acquire_global_lock(&mac->sme);
10118 if (CDF_STATUS_SUCCESS != status)
10119 return status;
10120 chan_switch_params = cdf_mem_malloc(sizeof(*chan_switch_params));
10121 if (NULL == chan_switch_params) {
10122 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10123 FL("fail to alloc mem for tdls chan switch param"));
10124 sme_release_global_lock(&mac->sme);
10125 return CDF_STATUS_E_FAILURE;
10126 }
10127 cdf_mem_zero(chan_switch_params, sizeof(*chan_switch_params));
10128
10129 switch (ch_switch_params->tdls_off_ch_mode) {
10130 case ENABLE_CHANSWITCH:
10131 chan_switch_params->tdls_sw_mode = WMA_TDLS_ENABLE_OFFCHANNEL;
10132 break;
10133
10134 case DISABLE_CHANSWITCH:
10135 chan_switch_params->tdls_sw_mode = WMA_TDLS_DISABLE_OFFCHANNEL;
10136 break;
10137
10138 default:
10139 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10140 FL("invalid off channel command (%d)"),
10141 ch_switch_params->tdls_off_ch_mode);
10142 cdf_mem_free(chan_switch_params);
10143 sme_release_global_lock(&mac->sme);
10144 return CDF_STATUS_E_FAILURE;
10145 }
10146
10147 cdf_mem_copy(&chan_switch_params->peer_mac_addr,
10148 &ch_switch_params->peer_mac_addr, sizeof(tSirMacAddr));
10149 chan_switch_params->vdev_id = ch_switch_params->vdev_id;
10150 chan_switch_params->tdls_off_ch = ch_switch_params->tdls_off_channel;
10151 chan_switch_params->tdls_off_ch_bw_offset =
10152 ch_switch_params->tdls_off_ch_bw_offset;
10153 chan_switch_params->is_responder = ch_switch_params->is_responder;
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053010154 chan_switch_params->oper_class = ch_switch_params->opclass;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010155
10156 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
10157 FL("Country Code=%s, Req offset=%d, Selected Operate Class=%d"),
10158 mac->scan.countryCodeCurrent,
10159 chan_switch_params->tdls_off_ch_bw_offset,
10160 chan_switch_params->oper_class);
10161
10162 cds_message.type = WMA_TDLS_SET_OFFCHAN_MODE;
10163 cds_message.reserved = 0;
10164 cds_message.bodyptr = chan_switch_params;
10165
10166 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
10167 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
10168 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10169 FL("Message Post failed status=%d"),
10170 cdf_status);
10171 cdf_mem_free(chan_switch_params);
10172 status = CDF_STATUS_E_FAILURE;
10173 }
10174 sme_release_global_lock(&mac->sme);
10175 return status;
10176}
10177#endif /* FEATURE_WLAN_TDLS */
10178
10179CDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
10180 void *plsContext,
10181 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
10182 void *pContext))
10183{
10184
10185 CDF_STATUS status = CDF_STATUS_SUCCESS;
10186 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
10187 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10188 cds_msg_t cds_message;
10189
10190 status = sme_acquire_global_lock(&pMac->sme);
10191 if (CDF_STATUS_SUCCESS == status) {
10192 if ((NULL == pCallbackfn) &&
10193 (NULL == pMac->sme.pLinkSpeedIndCb)) {
10194 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10195 "%s: Indication Call back did not registered",
10196 __func__);
10197 sme_release_global_lock(&pMac->sme);
10198 return CDF_STATUS_E_FAILURE;
10199 } else if (NULL != pCallbackfn) {
10200 pMac->sme.pLinkSpeedCbContext = plsContext;
10201 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
10202 }
10203 /* serialize the req through MC thread */
10204 cds_message.bodyptr = lsReq;
10205 cds_message.type = WMA_GET_LINK_SPEED;
10206 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
10207 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
10208 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10209 "%s: Post Link Speed msg fail", __func__);
10210 status = CDF_STATUS_E_FAILURE;
10211 }
10212 sme_release_global_lock(&pMac->sme);
10213 }
10214 return status;
10215}
10216
10217
10218/*
10219 * SME API to enable/disable WLAN driver initiated SSR
10220 */
10221void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
10222{
10223 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10224 CDF_STATUS status = CDF_STATUS_SUCCESS;
10225
10226 status = sme_acquire_global_lock(&pMac->sme);
10227 if (CDF_IS_STATUS_SUCCESS(status)) {
10228 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
10229 "SSR level is changed %d", enableSSR);
10230 /* not serializing this messsage, as this is only going
10231 * to set a variable in WMA/WDI
10232 */
10233 WMA_SetEnableSSR(enableSSR);
10234 sme_release_global_lock(&pMac->sme);
10235 }
10236 return;
10237}
10238
10239CDF_STATUS sme_check_ch_in_band(tpAniSirGlobal mac_ctx, uint8_t start_ch,
10240 uint8_t ch_cnt)
10241{
10242 uint8_t i;
10243 for (i = 0; i < ch_cnt; i++) {
10244 if (CDF_STATUS_SUCCESS != csr_is_valid_channel(mac_ctx,
10245 (start_ch + i*4)))
10246 return CDF_STATUS_E_FAILURE;
10247 }
10248 return CDF_STATUS_SUCCESS;
10249}
10250
10251void sme_set_160bw_params(tpAniSirGlobal mac_ctx, uint8_t channel,
10252 chan_params_t *ch_params)
10253{
10254 uint8_t start_ch = 0;
10255 CDF_STATUS status = CDF_STATUS_SUCCESS;
10256
10257 if (channel >= 36 && channel <= 64) {
10258 ch_params->center_freq_seg0 = 50;
10259 start_ch = 36;
10260 } else if (channel >= 100 && channel <= 128) {
10261 ch_params->center_freq_seg0 = 114;
10262 start_ch = 100;
10263 } else {
10264 ch_params->ch_width = CH_WIDTH_80MHZ;
10265 }
10266
10267 if (ch_params->ch_width == CH_WIDTH_160MHZ)
10268 status = sme_check_ch_in_band(mac_ctx, start_ch, 8);
10269
10270 if (CDF_STATUS_SUCCESS != status)
10271 ch_params->ch_width = CH_WIDTH_80MHZ;
10272}
10273
10274void sme_set_80bw_params(tpAniSirGlobal mac_ctx, uint8_t channel,
10275 chan_params_t *ch_params)
10276{
10277 uint8_t start_ch = 0;
10278 CDF_STATUS status = CDF_STATUS_SUCCESS;
10279
10280 if (channel >= 36 && channel <= 48) {
10281 ch_params->center_freq_seg0 = 42;
10282 start_ch = 36;
10283 } else if (channel >= 52 && channel <= 64) {
10284 ch_params->center_freq_seg0 = 58;
10285 start_ch = 52;
10286 } else if (channel >= 100 && channel <= 112) {
10287 ch_params->center_freq_seg0 = 106;
10288 start_ch = 100;
10289 } else if (channel >= 116 && channel <= 128) {
10290 ch_params->center_freq_seg0 = 122;
10291 start_ch = 116;
10292 } else if (channel >= 132 && channel <= 144) {
10293 ch_params->center_freq_seg0 = 138;
10294 start_ch = 132;
10295 } else if (channel >= 149 && channel <= 161) {
10296 ch_params->center_freq_seg0 = 155;
10297 start_ch = 149;
10298 } else {
10299 ch_params->ch_width = CH_WIDTH_40MHZ;
10300 }
10301
10302 if (ch_params->ch_width == CH_WIDTH_80MHZ)
10303 status = sme_check_ch_in_band(mac_ctx, start_ch, 4);
10304
10305 if (CDF_STATUS_SUCCESS != status)
10306 ch_params->ch_width = CH_WIDTH_40MHZ;
10307}
10308
10309void sme_set_40bw_params(tpAniSirGlobal mac_ctx, uint8_t channel,
10310 chan_params_t *ch_params, uint8_t is_11ac_mode)
10311{
10312 uint8_t tmp;
10313 uint8_t center_freq = 0;
10314 bool valid_40Mhz_ch = true;
10315
10316 if (channel == 165) {
10317 ch_params->ch_width = CH_WIDTH_20MHZ;
10318 ch_params->center_freq_seg0 = 0;
10319 ch_params->sec_ch_offset = PHY_SINGLE_CHANNEL_CENTERED;
10320 return;
10321 }
10322 tmp = channel % 2;
10323 if ((channel - tmp) % 8) {
10324 ch_params->sec_ch_offset = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
10325 center_freq = channel + 2;
10326 } else {
10327 ch_params->sec_ch_offset = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10328 center_freq = channel - 2;
10329 }
10330 if ((!is_11ac_mode) || (is_11ac_mode &&
10331 (ch_params->ch_width == CH_WIDTH_40MHZ))) {
10332 ch_params->ch_width = CH_WIDTH_40MHZ;
10333 ch_params->center_freq_seg0 = center_freq;
10334 valid_40Mhz_ch = csr_roam_is_valid40_mhz_channel(mac_ctx,
10335 ch_params->center_freq_seg0);
10336 }
10337 if (!valid_40Mhz_ch) {
10338 ch_params->ch_width = CH_WIDTH_20MHZ;
10339 ch_params->center_freq_seg0 = 0;
10340 ch_params->sec_ch_offset = PHY_SINGLE_CHANNEL_CENTERED;
10341 }
10342}
10343
10344/*
10345 * SME API to determine the channel bonding mode
10346 */
10347CDF_STATUS sme_set_ch_params(tHalHandle hHal, eCsrPhyMode eCsrPhyMode,
10348 uint8_t channel, uint8_t ht_sec_ch, chan_params_t *ch_params)
10349{
10350 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
10351 int is_11ac_mode = CSR_IS_PHY_MODE_11ac(eCsrPhyMode);
10352
10353 if (!CSR_IS_PHY_MODE_11n(eCsrPhyMode) ||
10354 ch_params->ch_width == CH_WIDTH_20MHZ ||
10355 CDF_STATUS_SUCCESS != csr_is_valid_channel(mac_ctx, channel)) {
10356 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10357 "%s: Invalid Channel/phymode config: CB Mode disabled",
10358 __func__);
10359 ch_params->ch_width = CH_WIDTH_20MHZ;
10360 ch_params->sec_ch_offset = PHY_SINGLE_CHANNEL_CENTERED;
10361 if (channel <= 14)
10362 mac_ctx->roam.configParam.channelBondingMode24GHz =
10363 PHY_SINGLE_CHANNEL_CENTERED;
10364 else
10365 mac_ctx->roam.configParam.channelBondingMode5GHz =
10366 PHY_SINGLE_CHANNEL_CENTERED;
10367 return CDF_STATUS_SUCCESS;
10368 }
10369
10370 sms_log(mac_ctx, LOGW, "%s: channel - %d, vht channel width - %d",
10371 __func__, channel, ch_params->ch_width);
10372
10373 if (CDS_IS_CHANNEL_5GHZ(channel)) {
10374 if (ch_params->ch_width == CH_WIDTH_160MHZ)
10375 sme_set_160bw_params(mac_ctx, channel, ch_params);
10376 if ((ch_params->ch_width == CH_WIDTH_80MHZ) ||
10377 (ch_params->ch_width == CH_WIDTH_80P80MHZ))
10378 sme_set_80bw_params(mac_ctx, channel, ch_params);
10379
10380 sme_set_40bw_params(mac_ctx, channel,
10381 ch_params, is_11ac_mode);
10382
10383 mac_ctx->roam.configParam.channelBondingMode5GHz =
10384 ch_params->sec_ch_offset;
10385 } else if (CDS_IS_CHANNEL_24GHZ(channel)) {
10386 if (channel >= 1 && channel < 5) {
10387 ch_params->ch_width = CH_WIDTH_40MHZ;
10388 ch_params->sec_ch_offset =
10389 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
10390 ch_params->center_freq_seg0 = channel + 2;
10391 } else if (channel >= 5 && channel <= 9) {
10392 ch_params->ch_width = CH_WIDTH_40MHZ;
10393 if (0 != ht_sec_ch) {
10394 if (ht_sec_ch > channel) {
10395 ch_params->sec_ch_offset =
10396 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
10397 ch_params->center_freq_seg0 =
10398 channel + 2;
10399 } else {
10400 ch_params->sec_ch_offset =
10401 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10402 ch_params->center_freq_seg0 =
10403 channel - 2;
10404 }
10405 } else {
10406 /* in case ht_sec_ch is not set by ACS or
10407 * calling function, set the secondary channel
10408 * offset value to lower channel
10409 */
10410 ch_params->sec_ch_offset =
10411 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10412 ch_params->center_freq_seg0 = channel - 2;
10413 }
10414 } else if (channel > 9 && channel <= 13) {
10415 ch_params->ch_width = CH_WIDTH_40MHZ;
10416 ch_params->sec_ch_offset =
10417 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10418 ch_params->center_freq_seg0 = channel - 2;
10419 } else if (channel == 14) {
10420 ch_params->ch_width = CH_WIDTH_20MHZ;
10421 ch_params->sec_ch_offset =
10422 PHY_SINGLE_CHANNEL_CENTERED;
10423 ch_params->center_freq_seg0 = 0;
10424 }
10425 mac_ctx->roam.configParam.channelBondingMode24GHz =
10426 ch_params->sec_ch_offset;
10427 }
10428 return CDF_STATUS_SUCCESS;
10429}
10430
10431/*convert the ini value to the ENUM used in csr and MAC for CB state*/
10432ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
10433{
10434 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
10435}
10436
10437/*--------------------------------------------------------------------------
10438
10439 \brief sme_set_curr_device_mode() - Sets the current operating device mode.
10440 \param hHal - The handle returned by mac_open.
10441 \param currDeviceMode - Current operating device mode.
10442 --------------------------------------------------------------------------*/
10443
10444void sme_set_curr_device_mode(tHalHandle hHal, tCDF_CON_MODE currDeviceMode)
10445{
10446 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10447 pMac->sme.currDeviceMode = currDeviceMode;
10448 return;
10449}
10450
10451/*--------------------------------------------------------------------------
10452 \brief sme_handoff_request() - a wrapper function to Request a handoff
10453 from CSR.
10454 This is a synchronous call
10455 \param hHal - The handle returned by mac_open
10456 \param sessionId - Session Identifier
10457 \param pHandoffInfo - info provided by HDD with the handoff request (namely:
10458 BSSID, channel etc.)
10459 \return CDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
10460 Other status means SME is failed to send the request.
10461 \sa
10462 --------------------------------------------------------------------------*/
10463
10464CDF_STATUS sme_handoff_request(tHalHandle hHal,
10465 uint8_t sessionId,
10466 tCsrHandoffRequest *pHandoffInfo)
10467{
10468 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10469 CDF_STATUS status = CDF_STATUS_SUCCESS;
10470
10471 status = sme_acquire_global_lock(&pMac->sme);
10472 if (CDF_IS_STATUS_SUCCESS(status)) {
10473 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
10474 "%s: invoked", __func__);
10475 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
10476 sme_release_global_lock(&pMac->sme);
10477 }
10478
10479 return status;
10480}
10481
10482#ifdef IPA_OFFLOAD
10483/* ---------------------------------------------------------------------------
10484 \fn sme_ipa_offload_enable_disable
10485 \brief API to enable/disable IPA offload
10486 \param hal - The handle returned by macOpen.
10487 \param session_id - Session Identifier
10488 \param request - Pointer to the offload request.
10489 \return CDF_STATUS
10490 ---------------------------------------------------------------------------*/
10491CDF_STATUS sme_ipa_offload_enable_disable(tHalHandle hal, uint8_t session_id,
10492 struct sir_ipa_offload_enable_disable *request)
10493{
10494 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10495 CDF_STATUS status = CDF_STATUS_E_FAILURE;
10496 struct sir_ipa_offload_enable_disable *request_buf;
10497 cds_msg_t msg;
10498
10499 status = sme_acquire_global_lock(&pMac->sme);
10500 if (CDF_STATUS_SUCCESS == status) {
10501 request_buf = cdf_mem_malloc(sizeof(*request_buf));
10502 if (NULL == request_buf) {
10503 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10504 FL("Not able to allocate memory for \
10505 IPA_OFFLOAD_ENABLE_DISABLE"));
10506 sme_release_global_lock(&pMac->sme);
10507 return CDF_STATUS_E_NOMEM;
10508 }
10509
10510 request_buf->offload_type = request->offload_type;
10511 request_buf->vdev_id = request->vdev_id;
10512 request_buf->enable = request->enable;
10513
10514 msg.type = WMA_IPA_OFFLOAD_ENABLE_DISABLE;
10515 msg.reserved = 0;
10516 msg.bodyptr = request_buf;
10517 if (!CDF_IS_STATUS_SUCCESS(
10518 cds_mq_post_message(CDS_MQ_ID_WMA, &msg))) {
10519 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10520 FL("Not able to post WMA_IPA_OFFLOAD_\
10521 ENABLE_DISABLE message to WMA"));
10522 cdf_mem_free(request_buf);
10523 sme_release_global_lock(&pMac->sme);
10524 return CDF_STATUS_E_FAILURE;
10525 }
10526
10527 sme_release_global_lock(&pMac->sme);
10528 }
10529
10530 return CDF_STATUS_SUCCESS;
10531}
10532#endif /* IPA_OFFLOAD */
10533
10534/*
10535 * SME API to check if there is any infra station or
10536 * P2P client is connected
10537 */
10538CDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
10539{
10540 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10541 if (csr_is_infra_connected(pMac)) {
10542 return CDF_STATUS_SUCCESS;
10543 }
10544 return CDF_STATUS_E_FAILURE;
10545}
10546
10547#ifdef FEATURE_WLAN_LPHB
10548/* ---------------------------------------------------------------------------
10549 \fn sme_lphb_config_req
10550 \API to make configuration LPHB within FW.
10551 \param hHal - The handle returned by mac_open
10552 \param lphdReq - LPHB request argument by client
10553 \param pCallbackfn - LPHB timeout notification callback function pointer
10554 \- return Configuration message posting status, SUCCESS or Fail
10555 -------------------------------------------------------------------------*/
10556CDF_STATUS sme_lphb_config_req
10557 (tHalHandle hHal,
10558 tSirLPHBReq *lphdReq,
10559 void (*pCallbackfn)(void *pHddCtx, tSirLPHBInd *indParam)
10560 ) {
10561 CDF_STATUS status = CDF_STATUS_SUCCESS;
10562 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
10563 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10564 cds_msg_t cds_message;
10565
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +053010566 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
10567 TRACE_CODE_SME_RX_HDD_LPHB_CONFIG_REQ,
10568 NO_SESSION, lphdReq->cmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010569 status = sme_acquire_global_lock(&pMac->sme);
10570 if (CDF_STATUS_SUCCESS == status) {
10571 if ((LPHB_SET_EN_PARAMS_INDID == lphdReq->cmd) &&
10572 (NULL == pCallbackfn) && (NULL == pMac->sme.pLphbIndCb)) {
10573 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10574 "%s: Indication Call back did not registered",
10575 __func__);
10576 sme_release_global_lock(&pMac->sme);
10577 return CDF_STATUS_E_FAILURE;
10578 } else if (NULL != pCallbackfn) {
10579 pMac->sme.pLphbIndCb = pCallbackfn;
10580 }
10581
10582 /* serialize the req through MC thread */
10583 cds_message.bodyptr = lphdReq;
10584 cds_message.type = WMA_LPHB_CONF_REQ;
10585 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
10586 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
10587 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10588 "%s: Post Config LPHB MSG fail", __func__);
10589 status = CDF_STATUS_E_FAILURE;
10590 }
10591 sme_release_global_lock(&pMac->sme);
10592 }
10593
10594 return status;
10595}
10596#endif /* FEATURE_WLAN_LPHB */
10597/*--------------------------------------------------------------------------
10598 \brief sme_enable_disable_split_scan() - a wrapper function to set the split
10599 scan parameter.
10600 This is a synchronous call
10601 \param hHal - The handle returned by mac_open
10602 \return NONE.
10603 \sa
10604 --------------------------------------------------------------------------*/
10605void sme_enable_disable_split_scan(tHalHandle hHal, uint8_t nNumStaChan,
10606 uint8_t nNumP2PChan)
10607{
10608 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10609
10610 pMac->roam.configParam.nNumStaChanCombinedConc = nNumStaChan;
10611 pMac->roam.configParam.nNumP2PChanCombinedConc = nNumP2PChan;
10612
10613 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
10614 "%s: SCAN nNumStaChanCombinedConc : %d,"
10615 "nNumP2PChanCombinedConc : %d ",
10616 __func__, nNumStaChan, nNumP2PChan);
10617
10618 return;
10619
10620}
10621
10622/**
10623 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
10624 * @hal: global hal handle
10625 * @addPeriodicTxPtrnParams: request message
10626 *
10627 * Return: CDF_STATUS enumeration
10628 */
10629CDF_STATUS
10630sme_add_periodic_tx_ptrn(tHalHandle hal,
10631 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
10632{
10633 CDF_STATUS status = CDF_STATUS_SUCCESS;
10634 tpAniSirGlobal mac = PMAC_STRUCT(hal);
10635 struct sSirAddPeriodicTxPtrn *req_msg;
10636 cds_msg_t msg;
10637
10638 sms_log(mac, LOG1, FL("enter"));
10639
10640 req_msg = cdf_mem_malloc(sizeof(*req_msg));
10641 if (!req_msg) {
10642 sms_log(mac, LOGE, FL("memory allocation failed"));
10643 return CDF_STATUS_E_NOMEM;
10644 }
10645
10646 *req_msg = *addPeriodicTxPtrnParams;
10647
10648 status = sme_acquire_global_lock(&mac->sme);
10649 if (!CDF_IS_STATUS_SUCCESS(status)) {
10650 sms_log(mac, LOGE,
10651 FL("sme_acquire_global_lock failed!(status=%d)"),
10652 status);
10653 cdf_mem_free(req_msg);
10654 return status;
10655 }
10656
10657 /* Serialize the req through MC thread */
10658 msg.bodyptr = req_msg;
10659 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
10660 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10661 if (!CDF_IS_STATUS_SUCCESS(status)) {
10662 sms_log(mac, LOGE,
10663 FL("cds_mq_post_message failed!(err=%d)"),
10664 status);
10665 cdf_mem_free(req_msg);
10666 }
10667 sme_release_global_lock(&mac->sme);
10668 return status;
10669}
10670
10671/**
10672 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
10673 * @hal: global hal handle
10674 * @delPeriodicTxPtrnParams: request message
10675 *
10676 * Return: CDF_STATUS enumeration
10677 */
10678CDF_STATUS
10679sme_del_periodic_tx_ptrn(tHalHandle hal,
10680 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
10681{
10682 CDF_STATUS status = CDF_STATUS_SUCCESS;
10683 tpAniSirGlobal mac = PMAC_STRUCT(hal);
10684 struct sSirDelPeriodicTxPtrn *req_msg;
10685 cds_msg_t msg;
10686
10687 sms_log(mac, LOG1, FL("enter"));
10688
10689 req_msg = cdf_mem_malloc(sizeof(*req_msg));
10690 if (!req_msg) {
10691 sms_log(mac, LOGE, FL("memory allocation failed"));
10692 return CDF_STATUS_E_NOMEM;
10693 }
10694
10695 *req_msg = *delPeriodicTxPtrnParams;
10696
10697 status = sme_acquire_global_lock(&mac->sme);
10698 if (!CDF_IS_STATUS_SUCCESS(status)) {
10699 sms_log(mac, LOGE,
10700 FL("sme_acquire_global_lock failed!(status=%d)"),
10701 status);
10702 cdf_mem_free(req_msg);
10703 return status;
10704 }
10705
10706 /* Serialize the req through MC thread */
10707 msg.bodyptr = req_msg;
10708 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
10709 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10710 if (!CDF_IS_STATUS_SUCCESS(status)) {
10711 sms_log(mac, LOGE,
10712 FL("cds_mq_post_message failed!(err=%d)"),
10713 status);
10714 cdf_mem_free(req_msg);
10715 }
10716 sme_release_global_lock(&mac->sme);
10717 return status;
10718}
10719
10720void sme_get_command_q_status(tHalHandle hHal)
10721{
10722 tSmeCmd *pTempCmd = NULL;
10723 tListElem *pEntry;
10724 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10725
10726 if (NULL == pMac) {
10727 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10728 "%s: pMac is NULL", __func__);
10729 return;
10730 }
10731
10732 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10733 if (pEntry) {
10734 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10735 }
10736 sms_log(pMac, LOGE, "Currently smeCmdActiveList has command (0x%X)",
10737 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
10738 if (pTempCmd) {
10739 if (eSmeCsrCommandMask & pTempCmd->command) {
10740 /* CSR command is stuck. See what the reason code is for that command */
10741 dump_csr_command_info(pMac, pTempCmd);
10742 }
10743 } /* if(pTempCmd) */
10744
10745 sms_log(pMac, LOGE, "Currently smeCmdPendingList has %d commands",
10746 csr_ll_count(&pMac->sme.smeCmdPendingList));
10747
10748 sms_log(pMac, LOGE, "Currently roamCmdPendingList has %d commands",
10749 csr_ll_count(&pMac->roam.roamCmdPendingList));
10750
10751 return;
10752}
10753
10754/**
10755 * sme_set_dot11p_config() - API to set the 802.11p config
10756 * @hHal: The handle returned by macOpen
10757 * @enable_dot11p: 802.11p config param
10758 */
10759void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
10760{
10761 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10762 pMac->enable_dot11p = enable_dot11p;
10763}
10764
10765/**
10766 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
10767 * @src: the source configuration
10768 *
10769 * Return: pointer to the copied OCB configuration
10770 */
10771static struct sir_ocb_config *sme_copy_sir_ocb_config(
10772 struct sir_ocb_config *src)
10773{
10774 struct sir_ocb_config *dst;
10775 uint32_t length;
10776 void *cursor;
10777
10778 length = sizeof(*src) +
10779 src->channel_count * sizeof(*src->channels) +
10780 src->schedule_size * sizeof(*src->schedule) +
10781 src->dcc_ndl_chan_list_len +
10782 src->dcc_ndl_active_state_list_len;
10783
10784 dst = cdf_mem_malloc(length);
10785 if (!dst)
10786 return NULL;
10787
10788 *dst = *src;
10789
10790 cursor = dst;
10791 cursor += sizeof(*dst);
10792 dst->channels = cursor;
10793 cursor += src->channel_count * sizeof(*src->channels);
10794 cdf_mem_copy(dst->channels, src->channels,
10795 src->channel_count * sizeof(*src->channels));
10796 dst->schedule = cursor;
10797 cursor += src->schedule_size * sizeof(*src->schedule);
10798 cdf_mem_copy(dst->schedule, src->schedule,
10799 src->schedule_size * sizeof(*src->schedule));
10800 dst->dcc_ndl_chan_list = cursor;
10801 cursor += src->dcc_ndl_chan_list_len;
10802 cdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
10803 src->dcc_ndl_chan_list_len);
10804 dst->dcc_ndl_active_state_list = cursor;
10805 cursor += src->dcc_ndl_active_state_list_len;
10806 cdf_mem_copy(dst->dcc_ndl_active_state_list,
10807 src->dcc_ndl_active_state_list,
10808 src->dcc_ndl_active_state_list_len);
10809 return dst;
10810}
10811
10812/**
10813 * sme_ocb_set_config() - Set the OCB configuration
10814 * @hHal: reference to the HAL
10815 * @context: the context of the call
10816 * @callback: the callback to hdd
10817 * @config: the OCB configuration
10818 *
10819 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
10820 */
10821CDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
10822 ocb_callback callback,
10823 struct sir_ocb_config *config)
10824{
10825 CDF_STATUS status = CDF_STATUS_E_FAILURE;
10826 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10827 cds_msg_t msg = {0};
10828 struct sir_ocb_config *msg_body;
10829
10830 /* Lock the SME structure */
10831 status = sme_acquire_global_lock(&pMac->sme);
10832 if (!CDF_IS_STATUS_SUCCESS(status))
10833 return status;
10834
10835 /*
10836 * Check if there is a pending request and return an error if one
10837 * exists
10838 */
10839 if (pMac->sme.ocb_set_config_callback) {
10840 status = CDF_STATUS_E_BUSY;
10841 goto end;
10842 }
10843
10844 msg_body = sme_copy_sir_ocb_config(config);
10845
10846 if (!msg_body) {
10847 status = CDF_STATUS_E_NOMEM;
10848 goto end;
10849 }
10850
10851 msg.type = WMA_OCB_SET_CONFIG_CMD;
10852 msg.bodyptr = msg_body;
10853
10854 /* Set the request callback and context */
10855 pMac->sme.ocb_set_config_callback = callback;
10856 pMac->sme.ocb_set_config_context = context;
10857
10858 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10859 if (!CDF_IS_STATUS_SUCCESS(status)) {
10860 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10861 FL("Error posting message to WDA: %d"), status);
10862 pMac->sme.ocb_set_config_callback = callback;
10863 pMac->sme.ocb_set_config_context = context;
10864 cdf_mem_free(msg_body);
10865 goto end;
10866 }
10867
10868end:
10869 sme_release_global_lock(&pMac->sme);
10870
10871 return status;
10872}
10873
10874/**
10875 * sme_ocb_set_utc_time() - Set the OCB UTC time
10876 * @hHal: reference to the HAL
10877 * @utc: the UTC time struct
10878 *
10879 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
10880 */
10881CDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
10882{
10883 CDF_STATUS status = CDF_STATUS_E_FAILURE;
10884 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10885 cds_msg_t msg = {0};
10886 struct sir_ocb_utc *sme_utc;
10887
10888 /* Lock the SME structure */
10889 status = sme_acquire_global_lock(&pMac->sme);
10890 if (!CDF_IS_STATUS_SUCCESS(status))
10891 return status;
10892
10893 sme_utc = cdf_mem_malloc(sizeof(*sme_utc));
10894 if (!sme_utc) {
10895 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10896 FL("Malloc failed"));
10897 status = CDF_STATUS_E_NOMEM;
10898 goto end;
10899 }
10900 *sme_utc = *utc;
10901
10902 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
10903 msg.reserved = 0;
10904 msg.bodyptr = sme_utc;
10905 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10906 if (!CDF_IS_STATUS_SUCCESS(status)) {
10907 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10908 FL("Not able to post message to WDA"));
10909 cdf_mem_free(utc);
10910 goto end;
10911 }
10912
10913end:
10914 sme_release_global_lock(&pMac->sme);
10915
10916 return status;
10917}
10918
10919/**
10920 * sme_ocb_start_timing_advert() - Start sending timing advert frames
10921 * @hHal: reference to the HAL
10922 * @timing_advert: the timing advertisement struct
10923 *
10924 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
10925 */
10926CDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
10927 struct sir_ocb_timing_advert *timing_advert)
10928{
10929 CDF_STATUS status = CDF_STATUS_E_FAILURE;
10930 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10931 cds_msg_t msg = {0};
10932 void *buf;
10933 struct sir_ocb_timing_advert *sme_timing_advert;
10934
10935 /* Lock the SME structure */
10936 status = sme_acquire_global_lock(&pMac->sme);
10937 if (!CDF_IS_STATUS_SUCCESS(status))
10938 return status;
10939
10940 buf = cdf_mem_malloc(sizeof(*sme_timing_advert) +
10941 timing_advert->template_length);
10942 if (!buf) {
10943 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10944 FL("Not able to allocate memory for start TA"));
10945 status = CDF_STATUS_E_NOMEM;
10946 goto end;
10947 }
10948
10949 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
10950 *sme_timing_advert = *timing_advert;
10951 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
10952 cdf_mem_copy(sme_timing_advert->template_value,
10953 timing_advert->template_value, timing_advert->template_length);
10954
10955 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
10956 msg.reserved = 0;
10957 msg.bodyptr = buf;
10958 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10959 if (!CDF_IS_STATUS_SUCCESS(status)) {
10960 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10961 FL("Not able to post msg to WDA"));
10962 goto end;
10963 }
10964
10965end:
10966 sme_release_global_lock(&pMac->sme);
10967
10968 return status;
10969}
10970
10971/**
10972 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
10973 * @hHal: reference to the HAL
10974 * @timing_advert: the timing advertisement struct
10975 *
10976 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
10977 */
10978CDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
10979 struct sir_ocb_timing_advert *timing_advert)
10980{
10981 CDF_STATUS status = CDF_STATUS_E_FAILURE;
10982 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10983 cds_msg_t msg = {0};
10984 struct sir_ocb_timing_advert *sme_timing_advert;
10985
10986 /* Lock the SME structure */
10987 status = sme_acquire_global_lock(&pMac->sme);
10988 if (!CDF_IS_STATUS_SUCCESS(status))
10989 return status;
10990
10991 sme_timing_advert = cdf_mem_malloc(sizeof(*timing_advert));
10992 if (!sme_timing_advert) {
10993 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10994 FL("Not able to allocate memory for stop TA"));
10995 status = CDF_STATUS_E_NOMEM;
10996 goto end;
10997 }
10998 *sme_timing_advert = *timing_advert;
10999
11000 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
11001 msg.reserved = 0;
11002 msg.bodyptr = sme_timing_advert;
11003 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
11004 if (!CDF_IS_STATUS_SUCCESS(status)) {
11005 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11006 FL("Not able to post msg to WDA"));
11007 goto end;
11008 }
11009
11010end:
11011 sme_release_global_lock(&pMac->sme);
11012
11013 return status;
11014}
11015
11016/**
Naveen Rawatb4d37622015-11-13 16:15:25 -080011017 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
11018 * @hal_handle: reference to the HAL
11019 * @self_addr: the self MAC address
11020 * @buf: the buffer that will contain the frame
11021 * @timestamp_offset: return for the offset of the timestamp field
11022 * @time_value_offset: return for the time_value field in the TA IE
11023 *
11024 * Return: the length of the buffer.
11025 */
11026int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
11027 tSirMacAddr self_addr, uint8_t **buf,
11028 uint32_t *timestamp_offset,
11029 uint32_t *time_value_offset)
11030{
11031 int template_length;
11032 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
11033
11034 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
11035 timestamp_offset,
11036 time_value_offset);
11037 return template_length;
11038}
11039/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011040 * sme_ocb_get_tsf_timer() - Get the TSF timer value
11041 * @hHal: reference to the HAL
11042 * @context: the context of the call
11043 * @callback: the callback to hdd
11044 * @request: the TSF timer request
11045 *
11046 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
11047 */
11048CDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
11049 ocb_callback callback,
11050 struct sir_ocb_get_tsf_timer *request)
11051{
11052 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11053 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11054 cds_msg_t msg = {0};
11055 struct sir_ocb_get_tsf_timer *msg_body;
11056
11057 /* Lock the SME structure */
11058 status = sme_acquire_global_lock(&pMac->sme);
11059 if (!CDF_IS_STATUS_SUCCESS(status))
11060 return status;
11061
11062 /* Allocate memory for the WMI request, and copy the parameter */
11063 msg_body = cdf_mem_malloc(sizeof(*msg_body));
11064 if (!msg_body) {
11065 status = CDF_STATUS_E_NOMEM;
11066 goto end;
11067 }
11068 *msg_body = *request;
11069
11070 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
11071 msg.bodyptr = msg_body;
11072
11073 /* Set the request callback and the context */
11074 pMac->sme.ocb_get_tsf_timer_callback = callback;
11075 pMac->sme.ocb_get_tsf_timer_context = context;
11076
11077 /* Post the message to WDA */
11078 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
11079 if (!CDF_IS_STATUS_SUCCESS(status)) {
11080 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11081 FL("Error posting message to WDA: %d"), status);
11082 pMac->sme.ocb_get_tsf_timer_callback = NULL;
11083 pMac->sme.ocb_get_tsf_timer_context = NULL;
11084 cdf_mem_free(msg_body);
11085 goto end;
11086 }
11087
11088end:
11089 sme_release_global_lock(&pMac->sme);
11090
11091 return status;
11092}
11093
11094/**
11095 * sme_dcc_get_stats() - Get the DCC stats
11096 * @hHal: reference to the HAL
11097 * @context: the context of the call
11098 * @callback: the callback to hdd
11099 * @request: the get DCC stats request
11100 *
11101 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
11102 */
11103CDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
11104 ocb_callback callback,
11105 struct sir_dcc_get_stats *request)
11106{
11107 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11108 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11109 cds_msg_t msg = {0};
11110 struct sir_dcc_get_stats *msg_body;
11111
11112 /* Lock the SME structure */
11113 status = sme_acquire_global_lock(&pMac->sme);
11114 if (!CDF_IS_STATUS_SUCCESS(status))
11115 return status;
11116
11117 /* Allocate memory for the WMI request, and copy the parameter */
11118 msg_body = cdf_mem_malloc(sizeof(*msg_body) +
11119 request->request_array_len);
11120 if (!msg_body) {
11121 status = CDF_STATUS_E_NOMEM;
11122 goto end;
11123 }
11124 *msg_body = *request;
11125 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
11126 cdf_mem_copy(msg_body->request_array, request->request_array,
11127 request->request_array_len);
11128
11129 msg.type = WMA_DCC_GET_STATS_CMD;
11130 msg.bodyptr = msg_body;
11131
11132 /* Set the request callback and context */
11133 pMac->sme.dcc_get_stats_callback = callback;
11134 pMac->sme.dcc_get_stats_context = context;
11135
11136 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
11137 if (!CDF_IS_STATUS_SUCCESS(status)) {
11138 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11139 FL("Error posting message to WDA: %d"), status);
11140 pMac->sme.dcc_get_stats_callback = callback;
11141 pMac->sme.dcc_get_stats_context = context;
11142 cdf_mem_free(msg_body);
11143 goto end;
11144 }
11145
11146end:
11147 sme_release_global_lock(&pMac->sme);
11148
11149 return status;
11150}
11151
11152/**
11153 * sme_dcc_clear_stats() - Clear the DCC stats
11154 * @hHal: reference to the HAL
11155 * @vdev_id: vdev id for OCB interface
11156 * @dcc_stats_bitmap: the entries in the stats to clear
11157 *
11158 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
11159 */
11160CDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
11161 uint32_t dcc_stats_bitmap)
11162{
11163 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11164 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11165 cds_msg_t msg = {0};
11166 struct sir_dcc_clear_stats *request;
11167
11168 /* Lock the SME structure */
11169 status = sme_acquire_global_lock(&pMac->sme);
11170 if (!CDF_IS_STATUS_SUCCESS(status))
11171 return status;
11172
11173 request = cdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
11174 if (!request) {
11175 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11176 FL("Not able to allocate memory"));
11177 status = CDF_STATUS_E_NOMEM;
11178 goto end;
11179 }
11180
11181 cdf_mem_zero(request, sizeof(*request));
11182 request->vdev_id = vdev_id;
11183 request->dcc_stats_bitmap = dcc_stats_bitmap;
11184
11185 msg.type = WMA_DCC_CLEAR_STATS_CMD;
11186 msg.bodyptr = request;
11187
11188 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
11189 if (!CDF_IS_STATUS_SUCCESS(status)) {
11190 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11191 FL("Not able to post msg to WDA"));
11192 cdf_mem_free(request);
11193 goto end;
11194 }
11195
11196end:
11197 sme_release_global_lock(&pMac->sme);
11198
11199 return status;
11200}
11201
11202/**
11203 * sme_dcc_update_ndl() - Update the DCC settings
11204 * @hHal: reference to the HAL
11205 * @context: the context of the call
11206 * @callback: the callback to hdd
11207 * @request: the update DCC request
11208 *
11209 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
11210 */
11211CDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
11212 ocb_callback callback,
11213 struct sir_dcc_update_ndl *request)
11214{
11215 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11216 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11217 cds_msg_t msg = {0};
11218 struct sir_dcc_update_ndl *msg_body;
11219
11220 /* Lock the SME structure */
11221 status = sme_acquire_global_lock(&pMac->sme);
11222 if (!CDF_IS_STATUS_SUCCESS(status))
11223 return status;
11224
11225 /* Allocate memory for the WMI request, and copy the parameter */
11226 msg_body = cdf_mem_malloc(sizeof(*msg_body) +
11227 request->dcc_ndl_chan_list_len +
11228 request->dcc_ndl_active_state_list_len);
11229 if (!msg_body) {
11230 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11231 FL("Failed to allocate memory"));
11232 status = CDF_STATUS_E_NOMEM;
11233 goto end;
11234 }
11235
11236 *msg_body = *request;
11237
11238 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
11239 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
11240 request->dcc_ndl_chan_list_len;
11241 cdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
11242 request->dcc_ndl_active_state_list_len);
11243 cdf_mem_copy(msg_body->dcc_ndl_active_state_list,
11244 request->dcc_ndl_active_state_list,
11245 request->dcc_ndl_active_state_list_len);
11246
11247 msg.type = WMA_DCC_UPDATE_NDL_CMD;
11248 msg.bodyptr = msg_body;
11249
11250 /* Set the request callback and the context */
11251 pMac->sme.dcc_update_ndl_callback = callback;
11252 pMac->sme.dcc_update_ndl_context = context;
11253
11254 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
11255 if (!CDF_IS_STATUS_SUCCESS(status)) {
11256 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11257 FL("Error posting message to WDA: %d"), status);
11258 pMac->sme.dcc_update_ndl_callback = NULL;
11259 pMac->sme.dcc_update_ndl_context = NULL;
11260 cdf_mem_free(msg_body);
11261 goto end;
11262 }
11263
11264end:
11265 sme_release_global_lock(&pMac->sme);
11266
11267 return status;
11268}
11269
11270/**
11271 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
11272 * event
11273 * @hHal: reference to the HAL
11274 * @context: the context of the call
11275 * @callback: the callback to hdd
11276 *
11277 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
11278 */
11279CDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
11280 ocb_callback callback)
11281{
11282 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11283 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11284
11285 status = sme_acquire_global_lock(&pMac->sme);
11286 pMac->sme.dcc_stats_event_callback = callback;
11287 pMac->sme.dcc_stats_event_context = context;
11288 sme_release_global_lock(&pMac->sme);
11289
11290 return 0;
11291}
11292
11293void sme_get_recovery_stats(tHalHandle hHal)
11294{
11295 uint8_t i;
11296
11297 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11298 "Self Recovery Stats");
11299 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
11300 if (eSmeNoCommand !=
11301 g_self_recovery_stats.activeCmdStats[i].command) {
11302 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11303 "timestamp %llu: command 0x%0X: reason %d: session %d",
11304 g_self_recovery_stats.activeCmdStats[i].
11305 timestamp,
11306 g_self_recovery_stats.activeCmdStats[i].command,
11307 g_self_recovery_stats.activeCmdStats[i].reason,
11308 g_self_recovery_stats.activeCmdStats[i].
11309 sessionId);
11310 }
11311 }
11312}
11313
11314/**
11315 * sme_save_active_cmd_stats() - To save active command stats
11316 * @hHal: HAL context
11317 *
11318 * This routine is to save active command stats
11319 *
11320 * Return: None
11321 */
11322void sme_save_active_cmd_stats(tHalHandle hHal)
11323{
11324 tSmeCmd *pTempCmd = NULL;
11325 tListElem *pEntry;
11326 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11327 uint8_t statidx = 0;
11328 tActiveCmdStats *actv_cmd_stat = NULL;
11329
11330 if (NULL == pMac) {
11331 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11332 FL("pMac is NULL"));
11333 return;
11334 }
11335
11336 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11337 if (pEntry)
11338 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11339
11340 if (!pTempCmd)
11341 return;
11342
11343 if (eSmeCsrCommandMask & pTempCmd->command) {
11344 statidx = g_self_recovery_stats.cmdStatsIndx;
11345 actv_cmd_stat = &g_self_recovery_stats.activeCmdStats[statidx];
11346 actv_cmd_stat->command = pTempCmd->command;
11347 actv_cmd_stat->sessionId = pTempCmd->sessionId;
11348 actv_cmd_stat->timestamp = cds_get_monotonic_boottime();
11349 if (eSmeCommandRoam == pTempCmd->command)
11350 actv_cmd_stat->reason = pTempCmd->u.roamCmd.roamReason;
11351 else if (eSmeCommandScan == pTempCmd->command)
11352 actv_cmd_stat->reason = pTempCmd->u.scanCmd.reason;
11353 else
11354 actv_cmd_stat->reason = 0xFF;
11355
11356 g_self_recovery_stats.cmdStatsIndx =
11357 ((g_self_recovery_stats.cmdStatsIndx + 1) &
11358 (MAX_ACTIVE_CMD_STATS - 1));
11359 }
11360 return;
11361}
11362
11363void active_list_cmd_timeout_handle(void *userData)
11364{
11365 if (NULL == userData)
11366 return;
11367 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11368 "%s: Active List command timeout Cmd List Count %d", __func__,
11369 csr_ll_count(&((tpAniSirGlobal) userData)->sme.
11370 smeCmdActiveList));
11371 sme_get_command_q_status((tHalHandle) userData);
11372
11373 if (((tpAniSirGlobal) userData)->sme.enableSelfRecovery) {
11374 sme_save_active_cmd_stats((tHalHandle) userData);
11375 cds_trigger_recovery();
11376 } else {
11377 CDF_BUG(0);
11378 }
11379}
11380
11381CDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
11382{
11383 cds_msg_t msg;
11384 tpSirModemPowerStateInd request_buf;
11385 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11386
11387 if (NULL == pMac) {
11388 return CDF_STATUS_E_FAILURE;
11389 }
11390
11391 request_buf = cdf_mem_malloc(sizeof(tSirModemPowerStateInd));
11392 if (NULL == request_buf) {
11393 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11394 "%s: Not able to allocate memory for MODEM POWER STATE IND",
11395 __func__);
11396 return CDF_STATUS_E_NOMEM;
11397 }
11398
11399 request_buf->param = value;
11400
11401 msg.type = WMA_MODEM_POWER_STATE_IND;
11402 msg.reserved = 0;
11403 msg.bodyptr = request_buf;
11404 if (!CDF_IS_STATUS_SUCCESS
11405 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
11406 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11407 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message"
11408 " to WMA", __func__);
11409 cdf_mem_free(request_buf);
11410 return CDF_STATUS_E_FAILURE;
11411 }
11412
11413 return CDF_STATUS_SUCCESS;
11414}
11415
11416#ifdef QCA_HT_2040_COEX
11417CDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
11418 struct cdf_mac_addr macAddrSTA,
11419 uint8_t sessionId,
11420 uint8_t channel_type)
11421{
11422 cds_msg_t msg;
11423 tUpdateVHTOpMode *pHtOpMode = NULL;
11424 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11425
11426 if (NULL == pMac) {
11427 return CDF_STATUS_E_FAILURE;
11428 }
11429
11430 pHtOpMode = cdf_mem_malloc(sizeof(tUpdateVHTOpMode));
11431 if (NULL == pHtOpMode) {
11432 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11433 "%s: Not able to allocate memory for setting OP mode",
11434 __func__);
11435 return CDF_STATUS_E_NOMEM;
11436 }
11437
11438 switch (channel_type) {
11439 case eHT_CHAN_HT20:
11440 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
11441 break;
11442
11443 case eHT_CHAN_HT40MINUS:
11444 case eHT_CHAN_HT40PLUS:
11445 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
11446 break;
11447
11448 default:
11449 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11450 "%s: Invalid OP mode", __func__);
11451 return CDF_STATUS_E_FAILURE;
11452 }
11453
11454 pHtOpMode->staId = staId,
11455 cdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
11456 sizeof(tSirMacAddr));
11457 pHtOpMode->smesessionId = sessionId;
11458
11459 msg.type = WMA_UPDATE_OP_MODE;
11460 msg.reserved = 0;
11461 msg.bodyptr = pHtOpMode;
11462 if (!CDF_IS_STATUS_SUCCESS
11463 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
11464 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11465 "%s: Not able to post WMA_UPDATE_OP_MODE message"
11466 " to WMA", __func__);
11467 cdf_mem_free(pHtOpMode);
11468 return CDF_STATUS_E_FAILURE;
11469 }
11470
11471 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
11472 "%s: Notifed FW about OP mode: %d for staId=%d",
11473 __func__, pHtOpMode->opMode, staId);
11474
11475 return CDF_STATUS_SUCCESS;
11476}
11477
11478/* ---------------------------------------------------------------------------
11479
11480 \fn sme_set_ht2040_mode
11481
11482 \brief To update HT Operation beacon IE.
11483
11484 \param
11485
11486 \return CDF_STATUS SUCCESS
11487 FAILURE or RESOURCES
11488 The API finished and failed.
11489
11490 -------------------------------------------------------------------------------*/
11491CDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
11492 uint8_t channel_type, bool obssEnabled)
11493{
11494 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11495 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11496 ePhyChanBondState cbMode;
11497
11498 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
11499 "%s: Update HT operation beacon IE, channel_type=%d",
11500 __func__, channel_type);
11501
11502 switch (channel_type) {
11503 case eHT_CHAN_HT20:
11504 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
11505 break;
11506 case eHT_CHAN_HT40MINUS:
11507 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
11508 break;
11509 case eHT_CHAN_HT40PLUS:
11510 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
11511 break;
11512 default:
11513 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11514 "%s:Error!!! Invalid HT20/40 mode !", __func__);
11515 return CDF_STATUS_E_FAILURE;
11516 }
11517 status = sme_acquire_global_lock(&pMac->sme);
11518 if (CDF_IS_STATUS_SUCCESS(status)) {
11519 status = csr_set_ht2040_mode(pMac, sessionId,
11520 cbMode, obssEnabled);
11521 sme_release_global_lock(&pMac->sme);
11522 }
11523 return status;
11524}
11525
11526/* ---------------------------------------------------------------------------
11527
11528 \fn sme_set_phy_cb_mode24_g
11529
11530 \brief Changes PHY channel bonding mode
11531
11532 \param hHal - The handle returned by mac_open.
11533
11534 \param cbMode new channel bonding mode which is to set
11535
11536 \return CDF_STATUS SUCCESS.
11537
11538 -------------------------------------------------------------------------------*/
11539CDF_STATUS sme_set_phy_cb_mode24_g(tHalHandle hHal, ePhyChanBondState phyCBMode)
11540{
11541 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11542
11543 if (NULL == pMac) {
11544 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11545 "%s: invalid context", __func__);
11546 return CDF_STATUS_E_FAILURE;
11547 }
11548
11549 pMac->roam.configParam.channelBondingMode24GHz = phyCBMode;
11550
11551 return CDF_STATUS_SUCCESS;
11552}
11553#endif
11554
11555/*
11556 * SME API to enable/disable idle mode powersave
11557 * This should be called only if powersave offload
11558 * is enabled
11559 */
11560CDF_STATUS sme_set_idle_powersave_config(void *cds_context,
11561 tHalHandle hHal, uint32_t value)
11562{
11563 void *wmaContext = cds_get_context(CDF_MODULE_ID_WMA);
11564 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11565
11566 if (NULL == wmaContext) {
11567 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11568 "%s: wmaContext is NULL", __func__);
11569 return CDF_STATUS_E_FAILURE;
11570 }
11571 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
11572 " Idle Ps Set Value %d", value);
11573
11574 pMac->imps_enabled = false;
11575 if (CDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
11576 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11577 " Failed to Set Idle Ps Value %d", value);
11578 return CDF_STATUS_E_FAILURE;
11579 }
11580 if (value)
11581 pMac->imps_enabled = true;
11582 return CDF_STATUS_SUCCESS;
11583}
11584
11585int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id, uint16_t ht_capab)
11586{
11587 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11588 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, session_id);
11589
11590 if (NULL == pSession) {
11591 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11592 "%s: pSession is NULL", __func__);
11593 return -EIO;
11594 }
11595 switch (ht_capab) {
11596 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
11597 return pSession->htConfig.ht_rx_ldpc;
11598 case WNI_CFG_HT_CAP_INFO_TX_STBC:
11599 return pSession->htConfig.ht_tx_stbc;
11600 case WNI_CFG_HT_CAP_INFO_RX_STBC:
11601 return pSession->htConfig.ht_rx_stbc;
11602 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
11603 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
11604 return pSession->htConfig.ht_sgi;
11605 default:
11606 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11607 "invalid ht capability");
11608 return -EIO;
11609 }
11610}
11611
11612int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
11613 int value)
11614{
11615 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11616 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11617
11618 if (NULL == pSession) {
11619 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11620 "%s: pSession is NULL", __func__);
11621 return -EIO;
11622 }
11623
11624 if (CDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
11625 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11626 "Failed to set ht capability in target");
11627 return -EIO;
11628 }
11629
11630 switch (htCapab) {
11631 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
11632 pSession->htConfig.ht_rx_ldpc = value;
11633 break;
11634 case WNI_CFG_HT_CAP_INFO_TX_STBC:
11635 pSession->htConfig.ht_tx_stbc = value;
11636 break;
11637 case WNI_CFG_HT_CAP_INFO_RX_STBC:
11638 pSession->htConfig.ht_rx_stbc = value;
11639 break;
11640 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
11641 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
11642 pSession->htConfig.ht_sgi = value;
11643 break;
11644 }
11645
11646 return 0;
11647}
11648
11649#define HT20_SHORT_GI_MCS7_RATE 722
11650/* ---------------------------------------------------------------------------
11651 \fn sme_send_rate_update_ind
11652 \brief API to Update rate
11653 \param hHal - The handle returned by mac_open
11654 \param rateUpdateParams - Pointer to rate update params
11655 \return CDF_STATUS
11656 ---------------------------------------------------------------------------*/
11657CDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
11658 tSirRateUpdateInd *rateUpdateParams)
11659{
11660 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11661 CDF_STATUS status;
11662 cds_msg_t msg;
11663 tSirRateUpdateInd *rate_upd = cdf_mem_malloc(sizeof(tSirRateUpdateInd));
11664
11665 if (rate_upd == NULL) {
11666 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11667 "Rate update struct alloc failed");
11668 return CDF_STATUS_E_FAILURE;
11669 }
11670 *rate_upd = *rateUpdateParams;
11671
11672 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
11673 rate_upd->mcastDataRate24GHzTxFlag =
11674 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
11675 else if (rate_upd->reliableMcastDataRate ==
11676 HT20_SHORT_GI_MCS7_RATE)
11677 rate_upd->reliableMcastDataRateTxFlag =
11678 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
11679
11680 status = sme_acquire_global_lock(&pMac->sme);
11681 if (CDF_STATUS_SUCCESS == status) {
11682 msg.type = WMA_RATE_UPDATE_IND;
11683 msg.bodyptr = rate_upd;
11684
11685 if (!CDF_IS_STATUS_SUCCESS
11686 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
11687 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11688 "%s: Not able "
11689 "to post WMA_SET_RMC_RATE_IND to WMA!",
11690 __func__);
11691
11692 sme_release_global_lock(&pMac->sme);
11693 cdf_mem_free(rate_upd);
11694 return CDF_STATUS_E_FAILURE;
11695 }
11696
11697 sme_release_global_lock(&pMac->sme);
11698 return CDF_STATUS_SUCCESS;
11699 }
11700
11701 return status;
11702}
11703
11704/**
11705 * sme_get_reg_info() - To get registration info
11706 * @hHal: HAL context
11707 * @chanId: channel id
11708 * @regInfo1: first reg info to fill
11709 * @regInfo2: second reg info to fill
11710 *
11711 * This routine will give you reg info
11712 *
11713 * Return: CDF_STATUS
11714 */
11715CDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
11716 uint32_t *regInfo1, uint32_t *regInfo2)
11717{
11718 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11719 CDF_STATUS status;
11720 uint8_t i;
11721 bool found = false;
11722
11723 status = sme_acquire_global_lock(&pMac->sme);
11724 *regInfo1 = 0;
11725 *regInfo2 = 0;
11726 if (!CDF_IS_STATUS_SUCCESS(status))
11727 return status;
11728
11729 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
11730 if (pMac->scan.defaultPowerTable[i].chanId == chanId) {
11731 SME_SET_CHANNEL_REG_POWER(*regInfo1,
11732 pMac->scan.defaultPowerTable[i].pwr);
11733
11734 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
11735 pMac->scan.defaultPowerTable[i].pwr);
11736 found = true;
11737 break;
11738 }
11739 }
11740 if (!found)
11741 status = CDF_STATUS_E_FAILURE;
11742
11743 sme_release_global_lock(&pMac->sme);
11744 return status;
11745}
11746
11747#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
11748/* ---------------------------------------------------------------------------
11749 \fn sme_auto_shutdown_cb
11750 \brief Used to plug in callback function for receiving auto shutdown evt
11751 \param hHal
11752 \param pCallbackfn : callback function pointer should be plugged in
11753 \- return CDF_STATUS
11754 -------------------------------------------------------------------------*/
11755CDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
11756 ) {
11757 CDF_STATUS status = CDF_STATUS_SUCCESS;
11758 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11759
11760 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11761 "%s: Plug in Auto shutdown event callback", __func__);
11762
11763 status = sme_acquire_global_lock(&pMac->sme);
11764 if (CDF_STATUS_SUCCESS == status) {
11765 if (NULL != pCallbackfn) {
11766 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
11767 }
11768 sme_release_global_lock(&pMac->sme);
11769 }
11770
11771 return status;
11772}
11773
11774/* ---------------------------------------------------------------------------
11775 \fn sme_set_auto_shutdown_timer
11776 \API to set auto shutdown timer value in FW.
11777 \param hHal - The handle returned by mac_open
11778 \param timer_val - The auto shutdown timer value to be set
11779 \- return Configuration message posting status, SUCCESS or Fail
11780 -------------------------------------------------------------------------*/
11781CDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
11782{
11783 CDF_STATUS status = CDF_STATUS_SUCCESS;
11784 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
11785 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11786 tSirAutoShutdownCmdParams *auto_sh_cmd;
11787 cds_msg_t cds_message;
11788
11789 status = sme_acquire_global_lock(&pMac->sme);
11790 if (CDF_STATUS_SUCCESS == status) {
11791 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
11792 cdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
11793 if (auto_sh_cmd == NULL) {
11794 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
11795 "%s Request Buffer Alloc Fail", __func__);
11796 sme_release_global_lock(&pMac->sme);
11797 return CDF_STATUS_E_NOMEM;
11798 }
11799
11800 auto_sh_cmd->timer_val = timer_val;
11801
11802 /* serialize the req through MC thread */
11803 cds_message.bodyptr = auto_sh_cmd;
11804 cds_message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
11805 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
11806 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
11807 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11808 "%s: Post Auto shutdown MSG fail", __func__);
11809 cdf_mem_free(auto_sh_cmd);
11810 sme_release_global_lock(&pMac->sme);
11811 return CDF_STATUS_E_FAILURE;
11812 }
11813 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
11814 "%s: Posted Auto shutdown MSG", __func__);
11815 sme_release_global_lock(&pMac->sme);
11816 }
11817
11818 return status;
11819}
11820#endif
11821
11822#ifdef FEATURE_WLAN_CH_AVOID
11823/* ---------------------------------------------------------------------------
11824 \fn sme_add_ch_avoid_callback
11825 \brief Used to plug in callback function
11826 Which notify channel may not be used with SAP or P2PGO mode.
11827 Notification come from FW.
11828 \param hHal
11829 \param pCallbackfn : callback function pointer should be plugged in
11830 \- return CDF_STATUS
11831 -------------------------------------------------------------------------*/
11832CDF_STATUS sme_add_ch_avoid_callback
11833 (tHalHandle hHal, void (*pCallbackfn)(void *pAdapter, void *indParam)
11834 ) {
11835 CDF_STATUS status = CDF_STATUS_SUCCESS;
11836 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11837
11838 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11839 "%s: Plug in CH AVOID CB", __func__);
11840
11841 status = sme_acquire_global_lock(&pMac->sme);
11842 if (CDF_STATUS_SUCCESS == status) {
11843 if (NULL != pCallbackfn) {
11844 pMac->sme.pChAvoidNotificationCb = pCallbackfn;
11845 }
11846 sme_release_global_lock(&pMac->sme);
11847 }
11848
11849 return status;
11850}
11851
11852/* ---------------------------------------------------------------------------
11853 \fn sme_ch_avoid_update_req
11854 \API to request channel avoidance update from FW.
11855 \param hHal - The handle returned by mac_open
11856 \param update_type - The udpate_type parameter of this request call
11857 \- return Configuration message posting status, SUCCESS or Fail
11858 -------------------------------------------------------------------------*/
11859CDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
11860{
11861 CDF_STATUS status = CDF_STATUS_SUCCESS;
11862 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
11863 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11864 tSirChAvoidUpdateReq *cauReq;
11865 cds_msg_t cds_message;
11866
11867 status = sme_acquire_global_lock(&pMac->sme);
11868 if (CDF_STATUS_SUCCESS == status) {
11869 cauReq = (tSirChAvoidUpdateReq *)
11870 cdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
11871 if (NULL == cauReq) {
11872 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
11873 "%s Request Buffer Alloc Fail", __func__);
11874 sme_release_global_lock(&pMac->sme);
11875 return CDF_STATUS_E_NOMEM;
11876 }
11877
11878 cauReq->reserved_param = 0;
11879
11880 /* serialize the req through MC thread */
11881 cds_message.bodyptr = cauReq;
11882 cds_message.type = WMA_CH_AVOID_UPDATE_REQ;
11883 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
11884 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
11885 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11886 "%s: Post Ch Avoid Update MSG fail",
11887 __func__);
11888 cdf_mem_free(cauReq);
11889 sme_release_global_lock(&pMac->sme);
11890 return CDF_STATUS_E_FAILURE;
11891 }
11892 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
11893 "%s: Posted Ch Avoid Update MSG", __func__);
11894 sme_release_global_lock(&pMac->sme);
11895 }
11896
11897 return status;
11898}
11899#endif /* FEATURE_WLAN_CH_AVOID */
11900
11901/**
11902 * sme_set_miracast() - Function to set miracast value to UMAC
11903 * @hal: Handle returned by macOpen
11904 * @filter_type: 0-Disabled, 1-Source, 2-sink
11905 *
11906 * This function passes down the value of miracast set by
11907 * framework to UMAC
11908 *
11909 * Return: Configuration message posting status, SUCCESS or Fail
11910 *
11911 */
11912CDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
11913{
11914 cds_msg_t msg;
11915 uint32_t *val;
11916 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
11917
11918 val = cdf_mem_malloc(sizeof(*val));
11919 if (NULL == val || NULL == mac_ptr) {
11920 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11921 "%s: Invalid pointer", __func__);
11922 return CDF_STATUS_E_NOMEM;
11923 }
11924
11925 *val = filter_type;
11926
11927 msg.type = SIR_HAL_SET_MIRACAST;
11928 msg.reserved = 0;
11929 msg.bodyptr = val;
11930
11931 if (!CDF_IS_STATUS_SUCCESS(
11932 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
11933 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11934 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
11935 __func__);
11936 cdf_mem_free(val);
11937 return CDF_STATUS_E_FAILURE;
11938 }
11939
11940 mac_ptr->sme.miracast_value = filter_type;
11941 return CDF_STATUS_SUCCESS;
11942}
11943
11944/**
11945 * sme_set_mas() - Function to set MAS value to UMAC
11946 * @val: 1-Enable, 0-Disable
11947 *
11948 * This function passes down the value of MAS to the UMAC. A
11949 * value of 1 will enable MAS and a value of 0 will disable MAS
11950 *
11951 * Return: Configuration message posting status, SUCCESS or Fail
11952 *
11953 */
11954CDF_STATUS sme_set_mas(uint32_t val)
11955{
11956 cds_msg_t msg;
11957 uint32_t *ptr_val;
11958
11959 ptr_val = cdf_mem_malloc(sizeof(*ptr_val));
11960 if (NULL == ptr_val) {
11961 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11962 "%s: could not allocate ptr_val", __func__);
11963 return CDF_STATUS_E_NOMEM;
11964 }
11965
11966 *ptr_val = val;
11967
11968 msg.type = SIR_HAL_SET_MAS;
11969 msg.reserved = 0;
11970 msg.bodyptr = ptr_val;
11971
11972 if (!CDF_IS_STATUS_SUCCESS(
11973 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
11974 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11975 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
11976 __func__);
11977 cdf_mem_free(ptr_val);
11978 return CDF_STATUS_E_FAILURE;
11979 }
11980 return CDF_STATUS_SUCCESS;
11981}
11982
11983/* -------------------------------------------------------------------------
11984 \fn sme_roam_channel_change_req
11985 \brief API to Indicate Channel change to new target channel
11986 \param hHal - The handle returned by mac_open
11987 \param targetChannel - New Channel to move the SAP to.
11988 \return CDF_STATUS
11989 ---------------------------------------------------------------------------*/
11990CDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
11991 struct cdf_mac_addr bssid, uint32_t cb_mode, tCsrRoamProfile *profile)
11992{
11993 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11994 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11995 uint8_t ch_mode;
11996
11997 ch_mode = (profile->ChannelInfo.ChannelList[0] <=
11998 CSR_MAX_2_4_GHZ_SUPPORTED_CHANNELS) ?
11999 pMac->roam.configParam.channelBondingMode24GHz :
12000 pMac->roam.configParam.channelBondingMode5GHz;
12001
12002 status = sme_acquire_global_lock(&pMac->sme);
12003 if (CDF_IS_STATUS_SUCCESS(status)) {
12004
12005 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_MED,
12006 FL("sapdfs: requested cbmode=[%d] & new negotiated cbmode[%d]"),
12007 cb_mode, ch_mode);
12008 status = csr_roam_channel_change_req(pMac, bssid, ch_mode,
12009 profile);
12010 sme_release_global_lock(&pMac->sme);
12011 }
12012 return status;
12013}
12014
12015/* -------------------------------------------------------------------------
12016 \fn sme_process_channel_change_resp
12017 \brief API to Indicate Channel change response message to SAP.
12018 \return CDF_STATUS
12019 ---------------------------------------------------------------------------*/
12020CDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
12021 uint16_t msg_type, void *pMsgBuf)
12022{
12023 CDF_STATUS status = CDF_STATUS_SUCCESS;
12024 tCsrRoamInfo proam_info = { 0 };
12025 eCsrRoamResult roamResult;
12026 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
12027 uint32_t SessionId = pChnlParams->peSessionId;
12028
12029 proam_info.channelChangeRespEvent =
12030 (tSirChanChangeResponse *)
12031 cdf_mem_malloc(sizeof(tSirChanChangeResponse));
12032 if (NULL == proam_info.channelChangeRespEvent) {
12033 status = CDF_STATUS_E_NOMEM;
12034 sms_log(pMac, LOGE,
12035 "Channel Change Event Allocation Failed: %d\n", status);
12036 return status;
12037 }
12038 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
12039 proam_info.channelChangeRespEvent->sessionId = SessionId;
12040 proam_info.channelChangeRespEvent->newChannelNumber =
12041 pChnlParams->channelNumber;
12042 proam_info.channelChangeRespEvent->secondaryChannelOffset =
12043 pChnlParams->ch_width;
12044
12045 if (pChnlParams->status == CDF_STATUS_SUCCESS) {
12046 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_MED,
12047 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
12048 SessionId);
12049 proam_info.channelChangeRespEvent->channelChangeStatus =
12050 1;
12051 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
12052 } else {
12053 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_MED,
12054 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
12055 SessionId);
12056 proam_info.channelChangeRespEvent->channelChangeStatus =
12057 0;
12058 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
12059 }
12060
12061 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
12062 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
12063
12064 } else {
12065 status = CDF_STATUS_E_FAILURE;
12066 sms_log(pMac, LOGE, "Invalid Channel Change Resp Message: %d\n",
12067 status);
12068 }
12069 cdf_mem_free(proam_info.channelChangeRespEvent);
12070
12071 return status;
12072}
12073
12074/* -------------------------------------------------------------------------
12075 \fn sme_roam_start_beacon_req
12076 \brief API to Indicate LIM to start Beacon Tx
12077 \after SAP CAC Wait is completed.
12078 \param hHal - The handle returned by mac_open
12079 \param sessionId - session ID
12080 \param dfsCacWaitStatus - CAC WAIT status flag
12081 \return CDF_STATUS
12082 ---------------------------------------------------------------------------*/
12083CDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct cdf_mac_addr bssid,
12084 uint8_t dfsCacWaitStatus)
12085{
12086 CDF_STATUS status = CDF_STATUS_E_FAILURE;
12087 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12088 status = sme_acquire_global_lock(&pMac->sme);
12089
12090 if (CDF_IS_STATUS_SUCCESS(status)) {
12091 status = csr_roam_start_beacon_req(pMac, bssid, dfsCacWaitStatus);
12092 sme_release_global_lock(&pMac->sme);
12093 }
12094 return status;
12095}
12096
12097/* -------------------------------------------------------------------------
12098 \fn sme_roam_csa_ie_request
12099 \brief API to request CSA IE transmission from PE
12100 \param hHal - The handle returned by mac_open
12101 \param pDfsCsaReq - CSA IE request
12102 \param bssid - SAP bssid
12103 \param ch_bandwidth - Channel offset
12104 \return CDF_STATUS
12105 ---------------------------------------------------------------------------*/
12106CDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct cdf_mac_addr bssid,
12107 uint8_t targetChannel, uint8_t csaIeReqd,
12108 uint8_t ch_bandwidth)
12109{
12110 CDF_STATUS status = CDF_STATUS_E_FAILURE;
12111 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12112 status = sme_acquire_global_lock(&pMac->sme);
12113 if (CDF_IS_STATUS_SUCCESS(status)) {
12114 status = csr_roam_send_chan_sw_ie_request(pMac, bssid, targetChannel,
12115 csaIeReqd, ch_bandwidth);
12116 sme_release_global_lock(&pMac->sme);
12117 }
12118 return status;
12119}
12120
12121/* ---------------------------------------------------------------------------
12122 \fn sme_init_thermal_info
12123 \brief SME API to initialize the thermal mitigation parameters
12124 \param hHal
12125 \param thermalParam : thermal mitigation parameters
12126 \- return CDF_STATUS
12127 -------------------------------------------------------------------------*/
12128CDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams thermalParam)
12129{
12130 t_thermal_mgmt *pWmaParam;
12131 cds_msg_t msg;
12132 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12133
12134 pWmaParam = (t_thermal_mgmt *) cdf_mem_malloc(sizeof(t_thermal_mgmt));
12135 if (NULL == pWmaParam) {
12136 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12137 "%s: could not allocate tThermalMgmt", __func__);
12138 return CDF_STATUS_E_NOMEM;
12139 }
12140
12141 cdf_mem_zero((void *)pWmaParam, sizeof(t_thermal_mgmt));
12142
12143 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
12144 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
12145 pWmaParam->thermalLevels[0].minTempThreshold =
12146 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
12147 pWmaParam->thermalLevels[0].maxTempThreshold =
12148 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
12149 pWmaParam->thermalLevels[1].minTempThreshold =
12150 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
12151 pWmaParam->thermalLevels[1].maxTempThreshold =
12152 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
12153 pWmaParam->thermalLevels[2].minTempThreshold =
12154 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
12155 pWmaParam->thermalLevels[2].maxTempThreshold =
12156 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
12157 pWmaParam->thermalLevels[3].minTempThreshold =
12158 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
12159 pWmaParam->thermalLevels[3].maxTempThreshold =
12160 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
12161
12162 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
12163 msg.type = WMA_INIT_THERMAL_INFO_CMD;
12164 msg.bodyptr = pWmaParam;
12165
12166 if (!CDF_IS_STATUS_SUCCESS
12167 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
12168 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12169 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
12170 __func__);
12171 cdf_mem_free(pWmaParam);
12172 sme_release_global_lock(&pMac->sme);
12173 return CDF_STATUS_E_FAILURE;
12174 }
12175 sme_release_global_lock(&pMac->sme);
12176 return CDF_STATUS_SUCCESS;
12177 }
12178 cdf_mem_free(pWmaParam);
12179 return CDF_STATUS_E_FAILURE;
12180}
12181
12182/**
12183 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
12184 * @hal: Handle returned by macOpen
12185 * @callback: sme_set_thermal_level_callback
12186 *
12187 * Plug in set thermal level callback
12188 *
12189 * Return: none
12190 */
12191void sme_add_set_thermal_level_callback(tHalHandle hal,
12192 sme_set_thermal_level_callback callback)
12193{
12194 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
12195
12196 pMac->sme.set_thermal_level_cb = callback;
12197}
12198
12199/**
12200 * sme_set_thermal_level() - SME API to set the thermal mitigation level
12201 * @hal: Handler to HAL
12202 * @level: Thermal mitigation level
12203 *
12204 * Return: CDF_STATUS
12205 */
12206CDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
12207{
12208 cds_msg_t msg;
12209 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
12210 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12211
12212 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
12213 cdf_mem_set(&msg, sizeof(msg), 0);
12214 msg.type = WMA_SET_THERMAL_LEVEL;
12215 msg.bodyval = level;
12216
12217 cdf_status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
12218 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
12219 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12220 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
12221 __func__);
12222 sme_release_global_lock(&pMac->sme);
12223 return CDF_STATUS_E_FAILURE;
12224 }
12225 sme_release_global_lock(&pMac->sme);
12226 return CDF_STATUS_SUCCESS;
12227 }
12228 return CDF_STATUS_E_FAILURE;
12229}
12230
12231/* ---------------------------------------------------------------------------
12232 \fn sme_txpower_limit
12233 \brief SME API to set txpower limits
12234 \param hHal
12235 \param psmetx : power limits for 2g/5g
12236 \- return CDF_STATUS
12237 -------------------------------------------------------------------------*/
12238CDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
12239{
12240 CDF_STATUS status = CDF_STATUS_SUCCESS;
12241 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12242 cds_msg_t cds_message;
12243 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12244
12245 status = sme_acquire_global_lock(&pMac->sme);
12246 if (CDF_IS_STATUS_SUCCESS(status)) {
12247 cds_message.type = WMA_TX_POWER_LIMIT;
12248 cds_message.reserved = 0;
12249 cds_message.bodyptr = psmetx;
12250
12251 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12252 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
12253 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12254 "%s: not able to post WMA_TX_POWER_LIMIT",
12255 __func__);
12256 status = CDF_STATUS_E_FAILURE;
12257 cdf_mem_free(psmetx);
12258 }
12259 sme_release_global_lock(&pMac->sme);
12260 }
12261 return status;
12262}
12263
12264CDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
12265{
12266 CDF_STATUS status = CDF_STATUS_SUCCESS;
12267 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12268 pMac->fEnableDebugLog = set_value;
12269 return status;
12270}
12271
12272/* ---------------------------------------------------------------------------
12273 \fn sme_ap_disable_intra_bss_fwd
12274
12275 \brief
12276 SME will send message to WMA to set Intra BSS in txrx
12277
12278 \param
12279
12280 hHal - The handle returned by mac_open
12281
12282 sessionId - session id ( vdev id)
12283
12284 disablefwd - bool value that indicate disable intrabss fwd disable
12285
12286 \return CDF_STATUS
12287 --------------------------------------------------------------------------- */
12288CDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
12289 bool disablefwd)
12290{
12291 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12292 int status = CDF_STATUS_SUCCESS;
12293 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12294 cds_msg_t cds_message;
12295 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
12296
12297 /* Prepare the request to send to SME. */
12298 pSapDisableIntraFwd = cdf_mem_malloc(sizeof(tDisableIntraBssFwd));
12299 if (NULL == pSapDisableIntraFwd) {
12300 sms_log(pMac, LOGP, "Memory Allocation Failure!!! %s", __func__);
12301 return CDF_STATUS_E_NOMEM;
12302 }
12303
12304 cdf_mem_zero(pSapDisableIntraFwd, sizeof(tDisableIntraBssFwd));
12305
12306 pSapDisableIntraFwd->sessionId = sessionId;
12307 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
12308
12309 status = sme_acquire_global_lock(&pMac->sme);
12310 if (CDF_IS_STATUS_SUCCESS(status)) {
12311 /* serialize the req through MC thread */
12312 cds_message.bodyptr = pSapDisableIntraFwd;
12313 cds_message.type = WMA_SET_SAP_INTRABSS_DIS;
12314 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12315 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
12316 status = CDF_STATUS_E_FAILURE;
12317 cdf_mem_free(pSapDisableIntraFwd);
12318 }
12319 sme_release_global_lock(&pMac->sme);
12320 }
12321 return status;
12322}
12323
12324#ifdef WLAN_FEATURE_STATS_EXT
12325
12326/******************************************************************************
12327 \fn sme_stats_ext_register_callback
12328
12329 \brief
12330 a function called to register the callback that send vendor event for stats
12331 ext
12332
12333 \param callback - callback to be registered
12334******************************************************************************/
12335void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
12336{
12337 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12338
12339 pMac->sme.StatsExtCallback = callback;
12340}
12341
12342/******************************************************************************
12343 \fn sme_stats_ext_request
12344
12345 \brief
12346 a function called when HDD receives STATS EXT vendor command from userspace
12347
12348 \param sessionID - vdevID for the stats ext request
12349
12350 \param input - Stats Ext Request structure ptr
12351
12352 \return CDF_STATUS
12353******************************************************************************/
12354CDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
12355{
12356 cds_msg_t msg;
12357 tpStatsExtRequest data;
12358 size_t data_len;
12359
12360 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
12361 data = cdf_mem_malloc(data_len);
12362
12363 if (data == NULL) {
12364 return CDF_STATUS_E_NOMEM;
12365 }
12366
12367 cdf_mem_zero(data, data_len);
12368 data->vdev_id = session_id;
12369 data->request_data_len = input->request_data_len;
12370 if (input->request_data_len) {
12371 cdf_mem_copy(data->request_data,
12372 input->request_data, input->request_data_len);
12373 }
12374
12375 msg.type = WMA_STATS_EXT_REQUEST;
12376 msg.reserved = 0;
12377 msg.bodyptr = data;
12378
12379 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
12380 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12381 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
12382 __func__);
12383 cdf_mem_free(data);
12384 return CDF_STATUS_E_FAILURE;
12385 }
12386
12387 return CDF_STATUS_SUCCESS;
12388}
12389
12390/******************************************************************************
12391 \fn sme_stats_ext_event
12392
12393 \brief
12394 a callback function called when SME received eWNI_SME_STATS_EXT_EVENT
12395 response from WMA
12396
12397 \param hHal - HAL handle for device
12398 \param pMsg - Message body passed from WMA; includes NAN header
12399 \return CDF_STATUS
12400******************************************************************************/
12401CDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
12402{
12403 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12404 CDF_STATUS status = CDF_STATUS_SUCCESS;
12405
12406 if (NULL == pMsg) {
12407 sms_log(pMac, LOGE, "in %s msg ptr is NULL", __func__);
12408 status = CDF_STATUS_E_FAILURE;
12409 } else {
12410 sms_log(pMac, LOG2, "SME: entering %s", __func__);
12411
12412 if (pMac->sme.StatsExtCallback) {
12413 pMac->sme.StatsExtCallback(pMac->hHdd,
12414 (tpStatsExtEvent) pMsg);
12415 }
12416 }
12417
12418 return status;
12419}
12420
12421#endif
12422
12423/* ---------------------------------------------------------------------------
12424 \fn sme_update_dfs_scan_mode
12425 \brief Update DFS roam scan mode
12426 This function is called through dynamic setConfig callback function
12427 to configure allowDFSChannelRoam.
12428 \param hHal - HAL handle for device
12429 \param sessionId - Session Identifier
12430 \param allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
12431 1 (passive), 2 (active)
12432 \return CDF_STATUS_SUCCESS - SME update DFS roaming scan config
12433 successfully.
12434 Other status means SME failed to update DFS roaming scan config.
12435 \sa
12436 -------------------------------------------------------------------------*/
12437CDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
12438 uint8_t allowDFSChannelRoam)
12439{
12440 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12441 CDF_STATUS status = CDF_STATUS_SUCCESS;
12442
12443 status = sme_acquire_global_lock(&pMac->sme);
12444 if (CDF_IS_STATUS_SUCCESS(status)) {
12445 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
12446 "LFR runtime successfully set AllowDFSChannelRoam Mode to "
12447 "%d - old value is %d - roam state is %s",
12448 allowDFSChannelRoam,
12449 pMac->roam.configParam.allowDFSChannelRoam,
12450 mac_trace_get_neighbour_roam_state(pMac->roam.
12451 neighborRoamInfo
12452 [sessionId].
12453 neighborRoamState));
12454 pMac->roam.configParam.allowDFSChannelRoam =
12455 allowDFSChannelRoam;
12456 sme_release_global_lock(&pMac->sme);
12457 }
12458 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
12459 csr_roam_offload_scan(pMac, sessionId,
12460 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
12461 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
12462 }
12463
12464 return status;
12465}
12466
12467/*--------------------------------------------------------------------------
12468 \brief sme_get_dfs_scan_mode() - get DFS roam scan mode
12469 This is a synchronous call
12470 \param hHal - The handle returned by mac_open.
12471 \return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
12472 \sa
12473 --------------------------------------------------------------------------*/
12474uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
12475{
12476 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12477 return pMac->roam.configParam.allowDFSChannelRoam;
12478}
12479
12480/*----------------------------------------------------------------------------
12481 \fn sme_modify_add_ie
12482 \brief This function sends msg to updates the additional IE buffers in PE
12483 \param hHal - global structure
12484 \param pModifyIE - pointer to tModifyIE structure
12485 \param updateType - type of buffer
12486 \- return Success or failure
12487 -----------------------------------------------------------------------------*/
12488CDF_STATUS sme_modify_add_ie(tHalHandle hHal,
12489 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
12490{
12491 CDF_STATUS status = CDF_STATUS_E_FAILURE;
12492 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12493 status = sme_acquire_global_lock(&pMac->sme);
12494
12495 if (CDF_IS_STATUS_SUCCESS(status)) {
12496 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
12497 sme_release_global_lock(&pMac->sme);
12498 }
12499 return status;
12500}
12501
12502/*----------------------------------------------------------------------------
12503 \fn sme_update_add_ie
12504 \brief This function sends msg to updates the additional IE buffers in PE
12505 \param hHal - global structure
12506 \param pUpdateIE - pointer to structure tUpdateIE
12507 \param updateType - type of buffer
12508 \- return Success or failure
12509 -----------------------------------------------------------------------------*/
12510CDF_STATUS sme_update_add_ie(tHalHandle hHal,
12511 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
12512{
12513 CDF_STATUS status = CDF_STATUS_E_FAILURE;
12514 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12515 status = sme_acquire_global_lock(&pMac->sme);
12516
12517 if (CDF_IS_STATUS_SUCCESS(status)) {
12518 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
12519 sme_release_global_lock(&pMac->sme);
12520 }
12521 return status;
12522}
12523
12524/* ---------------------------------------------------------------------------
12525 \fn sme_sta_in_middle_of_roaming
12526 \brief This function returns true if STA is in the middle of roaming state
12527 \param hHal - HAL handle for device
12528 \param sessionId - Session Identifier
12529 \- return true or false
12530 -------------------------------------------------------------------------*/
12531bool sme_sta_in_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12532{
12533 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12534 CDF_STATUS status = CDF_STATUS_SUCCESS;
12535 bool ret = false;
12536
12537 status = sme_acquire_global_lock(&pMac->sme);
12538 if (CDF_IS_STATUS_SUCCESS(status)) {
12539 ret = csr_neighbor_middle_of_roaming(hHal, sessionId);
12540 sme_release_global_lock(&pMac->sme);
12541 }
12542 return ret;
12543}
12544
12545
12546/**
12547 * sme_update_dsc_pto_up_mapping()
12548 * @hHal: HAL context
12549 * @dscpmapping: pointer to DSCP mapping structure
12550 * @sessionId: SME session id
12551 *
12552 * This routine is called to update dscp mapping
12553 *
12554 * Return: CDF_STATUS
12555 */
12556CDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
12557 sme_QosWmmUpType *dscpmapping,
12558 uint8_t sessionId)
12559{
12560 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12561 CDF_STATUS status = CDF_STATUS_SUCCESS;
12562 uint8_t i, j, peSessionId;
12563 tCsrRoamSession *pCsrSession = NULL;
12564 tpPESession pSession = NULL;
12565
12566 status = sme_acquire_global_lock(&pMac->sme);
12567 if (!CDF_IS_STATUS_SUCCESS(status))
12568 return status;
12569 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
12570 if (pCsrSession == NULL) {
12571 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12572 FL("Session lookup fails for CSR session"));
12573 sme_release_global_lock(&pMac->sme);
12574 return CDF_STATUS_E_FAILURE;
12575 }
12576 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
12577 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12578 FL("Invalid session Id %u"), sessionId);
12579 sme_release_global_lock(&pMac->sme);
12580 return CDF_STATUS_E_FAILURE;
12581 }
12582
12583 pSession = pe_find_session_by_bssid(pMac,
12584 pCsrSession->connectedProfile.bssid.bytes,
12585 &peSessionId);
12586
12587 if (pSession == NULL) {
12588 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12589 FL(" Session lookup fails for BSSID"));
12590 sme_release_global_lock(&pMac->sme);
12591 return CDF_STATUS_E_FAILURE;
12592 }
12593
12594 if (!pSession->QosMapSet.present) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -080012595 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012596 FL("QOS Mapping IE not present"));
12597 sme_release_global_lock(&pMac->sme);
12598 return CDF_STATUS_E_FAILURE;
12599 }
12600 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
12601 for (j = pSession->QosMapSet.dscp_range[i][0];
12602 j <= pSession->QosMapSet.dscp_range[i][1];
12603 j++) {
12604 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
12605 && (pSession->QosMapSet.dscp_range[i][1] ==
12606 255)) {
12607 dscpmapping[j] = 0;
12608 CDF_TRACE(CDF_MODULE_ID_SME,
12609 CDF_TRACE_LEVEL_ERROR,
12610 FL("User Priority %d isn't used"), i);
12611 break;
12612 } else {
12613 dscpmapping[j] = i;
12614 }
12615 }
12616 }
12617 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
12618 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
12619 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
12620 pSession->QosMapSet.dscp_exceptions[i][1];
12621
12622 sme_release_global_lock(&pMac->sme);
12623 return status;
12624}
12625
12626/* ---------------------------------------------------------------------------
12627 \fn sme_abort_roam_scan
12628 \brief API to abort current roam scan cycle by roam scan offload module.
12629 \param hHal - The handle returned by mac_open.
12630 \param sessionId - Session Identifier
12631 \return CDF_STATUS
12632 ---------------------------------------------------------------------------*/
12633
12634CDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
12635{
12636 CDF_STATUS status = CDF_STATUS_SUCCESS;
12637 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12638
12639 sms_log(pMac, LOGW, "entering function %s", __func__);
12640 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
12641 /* acquire the lock for the sme object */
12642 status = sme_acquire_global_lock(&pMac->sme);
12643 if (CDF_IS_STATUS_SUCCESS(status)) {
12644 csr_roam_offload_scan(pMac, sessionId,
12645 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
12646 REASON_ROAM_ABORT_ROAM_SCAN);
12647 /* release the lock for the sme object */
12648 sme_release_global_lock(&pMac->sme);
12649 }
12650 }
12651
12652 return status;
12653}
12654
12655#ifdef FEATURE_WLAN_EXTSCAN
12656/**
12657 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
12658 * @hHal: HAL context
12659 * @wifiBand: RF band information
12660 * @aValidChannels: output array to store channel info
12661 * @pNumChannels: output number of channels
12662 *
12663 * SME API to fetch all valid channels filtered by band
12664 *
12665 * Return: CDF_STATUS
12666 */
12667CDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
12668 uint8_t wifiBand,
12669 uint32_t *aValidChannels,
12670 uint8_t *pNumChannels)
12671{
12672 CDF_STATUS status = CDF_STATUS_SUCCESS;
12673 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
12674 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12675 uint8_t numChannels = 0;
12676 uint8_t i = 0;
12677 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12678
12679 if (!aValidChannels || !pNumChannels) {
12680 sms_log(pMac, CDF_TRACE_LEVEL_ERROR,
12681 FL("Output channel list/NumChannels is NULL"));
12682 return CDF_STATUS_E_INVAL;
12683 }
12684
12685 if ((wifiBand < WIFI_BAND_UNSPECIFIED) || (wifiBand >= WIFI_BAND_MAX)) {
12686 sms_log(pMac, CDF_TRACE_LEVEL_ERROR,
12687 FL("Invalid wifiBand (%d)"), wifiBand);
12688 return CDF_STATUS_E_INVAL;
12689 }
12690
12691 status = sme_get_cfg_valid_channels(hHal, &chanList[0],
12692 &totValidChannels);
12693 if (!CDF_IS_STATUS_SUCCESS(status)) {
12694 sms_log(pMac, CDF_TRACE_LEVEL_ERROR,
12695 FL("Fail to get valid channel list (err=%d)"), status);
12696 return status;
12697 }
12698
12699 switch (wifiBand) {
12700 case WIFI_BAND_UNSPECIFIED:
12701 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12702 FL("Unspec Band, return all (%d) valid channels"),
12703 totValidChannels);
12704 numChannels = totValidChannels;
12705 for (i = 0; i < totValidChannels; i++) {
12706 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
12707 }
12708 break;
12709
12710 case WIFI_BAND_BG:
12711 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12712 FL("WIFI_BAND_BG (2.4 GHz)"));
12713 for (i = 0; i < totValidChannels; i++) {
12714 if (CDS_IS_CHANNEL_24GHZ(chanList[i])) {
12715 aValidChannels[numChannels++] =
12716 cds_chan_to_freq(chanList[i]);
12717 }
12718 }
12719 break;
12720
12721 case WIFI_BAND_A:
12722 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12723 FL("WIFI_BAND_A (5 GHz without DFS)"));
12724 for (i = 0; i < totValidChannels; i++) {
12725 if (CDS_IS_CHANNEL_5GHZ(chanList[i]) &&
12726 !CDS_IS_DFS_CH(chanList[i])) {
12727 aValidChannels[numChannels++] =
12728 cds_chan_to_freq(chanList[i]);
12729 }
12730 }
12731 break;
12732
12733 case WIFI_BAND_ABG:
12734 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12735 FL("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)"));
12736 for (i = 0; i < totValidChannels; i++) {
12737 if ((CDS_IS_CHANNEL_24GHZ(chanList[i]) ||
12738 CDS_IS_CHANNEL_5GHZ(chanList[i])) &&
12739 !CDS_IS_DFS_CH(chanList[i])) {
12740 aValidChannels[numChannels++] =
12741 cds_chan_to_freq(chanList[i]);
12742 }
12743 }
12744 break;
12745
12746 case WIFI_BAND_A_DFS_ONLY:
12747 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12748 FL("WIFI_BAND_A_DFS (5 GHz DFS only)"));
12749 for (i = 0; i < totValidChannels; i++) {
12750 if (CDS_IS_CHANNEL_5GHZ(chanList[i]) &&
12751 CDS_IS_DFS_CH(chanList[i])) {
12752 aValidChannels[numChannels++] =
12753 cds_chan_to_freq(chanList[i]);
12754 }
12755 }
12756 break;
12757
12758 case WIFI_BAND_A_WITH_DFS:
12759 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12760 FL("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)"));
12761 for (i = 0; i < totValidChannels; i++) {
12762 if (CDS_IS_CHANNEL_5GHZ(chanList[i])) {
12763 aValidChannels[numChannels++] =
12764 cds_chan_to_freq(chanList[i]);
12765 }
12766 }
12767 break;
12768
12769 case WIFI_BAND_ABG_WITH_DFS:
12770 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12771 FL("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)"));
12772 for (i = 0; i < totValidChannels; i++) {
12773 if (CDS_IS_CHANNEL_24GHZ(chanList[i]) ||
12774 CDS_IS_CHANNEL_5GHZ(chanList[i])) {
12775 aValidChannels[numChannels++] =
12776 cds_chan_to_freq(chanList[i]);
12777 }
12778 }
12779 break;
12780
12781 default:
12782 sms_log(pMac, CDF_TRACE_LEVEL_ERROR,
12783 FL("Unknown wifiBand (%d))"), wifiBand);
12784 return CDF_STATUS_E_INVAL;
12785 break;
12786 }
12787 *pNumChannels = numChannels;
12788
12789 return status;
12790}
12791
12792/* ---------------------------------------------------------------------------
12793 \fn sme_ext_scan_get_capabilities
12794 \brief SME API to fetch extscan capabilities
12795 \param hHal
12796 \param pReq: extscan capabilities structure
12797 \- return CDF_STATUS
12798 -------------------------------------------------------------------------*/
12799CDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
12800 tSirGetExtScanCapabilitiesReqParams *
12801 pReq)
12802{
12803 CDF_STATUS status = CDF_STATUS_SUCCESS;
12804 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12805 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12806 cds_msg_t cds_message;
12807
12808 status = sme_acquire_global_lock(&pMac->sme);
12809 if (CDF_IS_STATUS_SUCCESS(status)) {
12810 /* Serialize the req through MC thread */
12811 cds_message.bodyptr = pReq;
12812 cds_message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
12813 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12814 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12815 status = CDF_STATUS_E_FAILURE;
12816
12817 sme_release_global_lock(&pMac->sme);
12818 }
12819 return status;
12820}
12821
12822/* ---------------------------------------------------------------------------
12823 \fn sme_ext_scan_start
12824 \brief SME API to issue extscan start
12825 \param hHal
12826 \param pStartCmd: extscan start structure
12827 \- return CDF_STATUS
12828 -------------------------------------------------------------------------*/
12829CDF_STATUS sme_ext_scan_start(tHalHandle hHal,
12830 tSirWifiScanCmdReqParams *pStartCmd)
12831{
12832 CDF_STATUS status = CDF_STATUS_SUCCESS;
12833 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12834 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12835 cds_msg_t cds_message;
12836
12837 status = sme_acquire_global_lock(&pMac->sme);
12838 if (CDF_IS_STATUS_SUCCESS(status)) {
12839 /* Serialize the req through MC thread */
12840 cds_message.bodyptr = pStartCmd;
12841 cds_message.type = WMA_EXTSCAN_START_REQ;
12842 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12843 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12844 status = CDF_STATUS_E_FAILURE;
12845
12846 sme_release_global_lock(&pMac->sme);
12847 }
12848 return status;
12849}
12850
12851/* ---------------------------------------------------------------------------
12852 \fn sme_ext_scan_stop
12853 \brief SME API to issue extscan stop
12854 \param hHal
12855 \param pStopReq: extscan stop structure
12856 \- return CDF_STATUS
12857 -------------------------------------------------------------------------*/
12858CDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams *pStopReq)
12859{
12860 CDF_STATUS status = CDF_STATUS_SUCCESS;
12861 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12862 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12863 cds_msg_t cds_message;
12864
12865 status = sme_acquire_global_lock(&pMac->sme);
12866 if (CDF_IS_STATUS_SUCCESS(status)) {
12867 /* Serialize the req through MC thread */
12868 cds_message.bodyptr = pStopReq;
12869 cds_message.type = WMA_EXTSCAN_STOP_REQ;
12870 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12871 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12872 status = CDF_STATUS_E_FAILURE;
12873 sme_release_global_lock(&pMac->sme);
12874 }
12875 return status;
12876}
12877
12878/* ---------------------------------------------------------------------------
12879 \fn sme_set_bss_hotlist
12880 \brief SME API to set BSSID hotlist
12881 \param hHal
12882 \param pSetHotListReq: extscan set hotlist structure
12883 \- return CDF_STATUS
12884 -------------------------------------------------------------------------*/
12885CDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
12886 tSirExtScanSetBssidHotListReqParams *
12887 pSetHotListReq)
12888{
12889 CDF_STATUS status = CDF_STATUS_SUCCESS;
12890 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12891 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12892 cds_msg_t cds_message;
12893
12894 status = sme_acquire_global_lock(&pMac->sme);
12895 if (CDF_IS_STATUS_SUCCESS(status)) {
12896 /* Serialize the req through MC thread */
12897 cds_message.bodyptr = pSetHotListReq;
12898 cds_message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
12899 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12900 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12901 status = CDF_STATUS_E_FAILURE;
12902
12903 sme_release_global_lock(&pMac->sme);
12904 }
12905 return status;
12906}
12907
12908/* ---------------------------------------------------------------------------
12909 \fn sme_reset_bss_hotlist
12910 \brief SME API to reset BSSID hotlist
12911 \param hHal
12912 \param pSetHotListReq: extscan set hotlist structure
12913 \- return CDF_STATUS
12914 -------------------------------------------------------------------------*/
12915CDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
12916 tSirExtScanResetBssidHotlistReqParams *
12917 pResetReq)
12918{
12919 CDF_STATUS status = CDF_STATUS_SUCCESS;
12920 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12921 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12922 cds_msg_t cds_message;
12923
12924 status = sme_acquire_global_lock(&pMac->sme);
12925 if (CDF_IS_STATUS_SUCCESS(status)) {
12926 /* Serialize the req through MC thread */
12927 cds_message.bodyptr = pResetReq;
12928 cds_message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
12929 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12930 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12931 status = CDF_STATUS_E_FAILURE;
12932
12933 sme_release_global_lock(&pMac->sme);
12934 }
12935 return status;
12936}
12937
12938/* ---------------------------------------------------------------------------
12939 \fn sme_set_significant_change
12940 \brief SME API to set significant change
12941 \param hHal
12942 \param pSetSignificantChangeReq: extscan set significant change structure
12943 \- return CDF_STATUS
12944 -------------------------------------------------------------------------*/
12945CDF_STATUS sme_set_significant_change(tHalHandle hHal,
12946 tSirExtScanSetSigChangeReqParams *
12947 pSetSignificantChangeReq)
12948{
12949 CDF_STATUS status = CDF_STATUS_SUCCESS;
12950 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12951 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12952 cds_msg_t cds_message;
12953
12954 status = sme_acquire_global_lock(&pMac->sme);
12955 if (CDF_IS_STATUS_SUCCESS(status)) {
12956 /* Serialize the req through MC thread */
12957 cds_message.bodyptr = pSetSignificantChangeReq;
12958 cds_message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
12959 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12960 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12961 status = CDF_STATUS_E_FAILURE;
12962
12963 sme_release_global_lock(&pMac->sme);
12964 }
12965 return status;
12966}
12967
12968/* ---------------------------------------------------------------------------
12969 \fn sme_reset_significant_change
12970 \brief SME API to reset significant change
12971 \param hHal
12972 \param pResetReq: extscan reset significant change structure
12973 \- return CDF_STATUS
12974 -------------------------------------------------------------------------*/
12975CDF_STATUS sme_reset_significant_change(tHalHandle hHal,
12976 tSirExtScanResetSignificantChangeReqParams
12977 *pResetReq)
12978{
12979 CDF_STATUS status = CDF_STATUS_SUCCESS;
12980 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12981 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12982 cds_msg_t cds_message;
12983
12984 status = sme_acquire_global_lock(&pMac->sme);
12985 if (CDF_IS_STATUS_SUCCESS(status)) {
12986 /* Serialize the req through MC thread */
12987 cds_message.bodyptr = pResetReq;
12988 cds_message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
12989 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12990 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12991 status = CDF_STATUS_E_FAILURE;
12992
12993 sme_release_global_lock(&pMac->sme);
12994 }
12995 return status;
12996}
12997
12998/* ---------------------------------------------------------------------------
12999 \fn sme_get_cached_results
13000 \brief SME API to get cached results
13001 \param hHal
13002 \param pCachedResultsReq: extscan get cached results structure
13003 \- return CDF_STATUS
13004 -------------------------------------------------------------------------*/
13005CDF_STATUS sme_get_cached_results(tHalHandle hHal,
13006 tSirExtScanGetCachedResultsReqParams *
13007 pCachedResultsReq)
13008{
13009 CDF_STATUS status = CDF_STATUS_SUCCESS;
13010 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13011 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13012 cds_msg_t cds_message;
13013
13014 status = sme_acquire_global_lock(&pMac->sme);
13015 if (CDF_IS_STATUS_SUCCESS(status)) {
13016 /* Serialize the req through MC thread */
13017 cds_message.bodyptr = pCachedResultsReq;
13018 cds_message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
13019 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13020 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
13021 status = CDF_STATUS_E_FAILURE;
13022
13023 sme_release_global_lock(&pMac->sme);
13024 }
13025 return status;
13026}
13027
13028/**
13029 * sme_set_epno_list() - set epno network list
13030 * @hHal: global hal handle
13031 * @input: request message
13032 *
13033 * This function constructs the cds message and fill in message type,
13034 * bodyptr with %input and posts it to WDA queue.
13035 *
13036 * Return: eHalStatus enumeration
13037 */
13038CDF_STATUS sme_set_epno_list(tHalHandle hal,
13039 struct wifi_epno_params *input)
13040{
13041 CDF_STATUS status = CDF_STATUS_SUCCESS;
13042 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13043 cds_msg_t cds_message;
13044 struct wifi_epno_params *req_msg;
13045 int len, i;
13046
13047 sms_log(mac, LOG1, FL("enter"));
13048 len = sizeof(*req_msg) +
13049 (input->num_networks * sizeof(struct wifi_epno_network));
13050 req_msg = cdf_mem_malloc(len);
13051 if (!req_msg) {
13052 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
13053 return CDF_STATUS_E_NOMEM;
13054 }
13055
13056 cdf_mem_zero(req_msg, len);
13057 req_msg->num_networks = input->num_networks;
13058 req_msg->request_id = input->request_id;
13059 req_msg->session_id = input->session_id;
13060 for (i = 0; i < req_msg->num_networks; i++) {
13061 req_msg->networks[i].rssi_threshold =
13062 input->networks[i].rssi_threshold;
13063 req_msg->networks[i].flags = input->networks[i].flags;
13064 req_msg->networks[i].auth_bit_field =
13065 input->networks[i].auth_bit_field;
13066 req_msg->networks[i].ssid.length =
13067 input->networks[i].ssid.length;
13068 cdf_mem_copy(req_msg->networks[i].ssid.ssId,
13069 input->networks[i].ssid.ssId,
13070 req_msg->networks[i].ssid.length);
13071 }
13072
13073 status = sme_acquire_global_lock(&mac->sme);
13074 if (CDF_IS_STATUS_SUCCESS(status)) {
13075 sms_log(mac, LOGE,
13076 FL("sme_acquire_global_lock failed!(status=%d)"),
13077 status);
13078 cdf_mem_free(req_msg);
13079 return status;
13080 }
13081
13082 /* Serialize the req through MC thread */
13083 cds_message.bodyptr = req_msg;
13084 cds_message.type = WMA_SET_EPNO_LIST_REQ;
13085 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13086 if (!CDF_IS_STATUS_SUCCESS(status)) {
13087 sms_log(mac, LOGE,
13088 FL("cds_mq_post_message failed!(err=%d)"),
13089 status);
13090 cdf_mem_free(req_msg);
13091 status = CDF_STATUS_E_FAILURE;
13092 }
13093 sme_release_global_lock(&mac->sme);
13094 return status;
13095}
13096
13097/**
13098 * sme_set_passpoint_list() - set passpoint network list
13099 * @hal: global hal handle
13100 * @input: request message
13101 *
13102 * This function constructs the cds message and fill in message type,
13103 * bodyptr with @input and posts it to WDA queue.
13104 *
13105 * Return: eHalStatus enumeration
13106 */
13107CDF_STATUS sme_set_passpoint_list(tHalHandle hal,
13108 struct wifi_passpoint_req *input)
13109{
13110 CDF_STATUS status = CDF_STATUS_SUCCESS;
13111 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13112 cds_msg_t cds_message;
13113 struct wifi_passpoint_req *req_msg;
13114 int len, i;
13115
13116 sms_log(mac, LOG1, FL("enter"));
13117 len = sizeof(*req_msg) +
13118 (input->num_networks * sizeof(struct wifi_passpoint_network));
13119 req_msg = cdf_mem_malloc(len);
13120 if (!req_msg) {
13121 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
13122 return CDF_STATUS_E_NOMEM;
13123 }
13124
13125 cdf_mem_zero(req_msg, len);
13126 req_msg->num_networks = input->num_networks;
13127 req_msg->request_id = input->request_id;
13128 req_msg->session_id = input->session_id;
13129 for (i = 0; i < req_msg->num_networks; i++) {
13130 req_msg->networks[i].id =
13131 input->networks[i].id;
13132 cdf_mem_copy(req_msg->networks[i].realm,
13133 input->networks[i].realm,
13134 strlen(input->networks[i].realm) + 1);
13135 cdf_mem_copy(req_msg->networks[i].plmn,
13136 input->networks[i].plmn,
13137 SIR_PASSPOINT_PLMN_LEN);
13138 cdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
13139 input->networks[i].roaming_consortium_ids,
13140 sizeof(req_msg->networks[i].roaming_consortium_ids));
13141 }
13142
13143 status = sme_acquire_global_lock(&mac->sme);
13144 if (CDF_IS_STATUS_SUCCESS(status)) {
13145 sms_log(mac, LOGE,
13146 FL("sme_acquire_global_lock failed!(status=%d)"),
13147 status);
13148 cdf_mem_free(req_msg);
13149 return status;
13150 }
13151
13152 /* Serialize the req through MC thread */
13153 cds_message.bodyptr = req_msg;
13154 cds_message.type = WMA_SET_PASSPOINT_LIST_REQ;
13155 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13156 if (!CDF_IS_STATUS_SUCCESS(status)) {
13157 sms_log(mac, LOGE,
13158 FL("cds_mq_post_message failed!(err=%d)"),
13159 status);
13160 cdf_mem_free(req_msg);
13161 status = CDF_STATUS_E_FAILURE;
13162 }
13163 sme_release_global_lock(&mac->sme);
13164 return status;
13165}
13166
13167/**
13168 * sme_reset_passpoint_list() - reset passpoint network list
13169 * @hHal: global hal handle
13170 * @input: request message
13171 *
13172 * Return: eHalStatus enumeration
13173 */
13174CDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
13175 struct wifi_passpoint_req *input)
13176{
13177 CDF_STATUS status = CDF_STATUS_SUCCESS;
13178 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13179 cds_msg_t cds_message;
13180 struct wifi_passpoint_req *req_msg;
13181
13182 sms_log(mac, LOG1, FL("enter"));
13183 req_msg = cdf_mem_malloc(sizeof(*req_msg));
13184 if (!req_msg) {
13185 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
13186 return CDF_STATUS_E_NOMEM;
13187 }
13188
13189 cdf_mem_zero(req_msg, sizeof(*req_msg));
13190 req_msg->request_id = input->request_id;
13191 req_msg->session_id = input->session_id;
13192
13193 status = sme_acquire_global_lock(&mac->sme);
13194 if (CDF_IS_STATUS_SUCCESS(status)) {
13195 sms_log(mac, LOGE,
13196 FL("sme_acquire_global_lock failed!(status=%d)"),
13197 status);
13198 cdf_mem_free(req_msg);
13199 return status;
13200 }
13201
13202 /* Serialize the req through MC thread */
13203 cds_message.bodyptr = req_msg;
13204 cds_message.type = WMA_RESET_PASSPOINT_LIST_REQ;
13205 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13206 if (!CDF_IS_STATUS_SUCCESS(status)) {
13207 sms_log(mac, LOGE,
13208 FL("cds_mq_post_message failed!(err=%d)"),
13209 status);
13210 cdf_mem_free(req_msg);
13211 status = CDF_STATUS_E_FAILURE;
13212 }
13213 sme_release_global_lock(&mac->sme);
13214 return status;
13215}
13216
13217/**
13218 * sme_set_ssid_hotlist() - Set the SSID hotlist
13219 * @hal: SME handle
13220 * @request: set ssid hotlist request
13221 *
13222 * Return: eHalStatus
13223 */
13224CDF_STATUS
13225sme_set_ssid_hotlist(tHalHandle hal,
13226 struct sir_set_ssid_hotlist_request *request)
13227{
13228 CDF_STATUS status = CDF_STATUS_SUCCESS;
13229 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13230 cds_msg_t cds_message;
13231 struct sir_set_ssid_hotlist_request *set_req;
13232
13233 set_req = cdf_mem_malloc(sizeof(*set_req));
13234 if (!set_req) {
13235 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
13236 return CDF_STATUS_E_FAILURE;
13237 }
13238
13239 *set_req = *request;
13240 status = sme_acquire_global_lock(&mac->sme);
13241 if (CDF_STATUS_SUCCESS == status) {
13242 /* Serialize the req through MC thread */
13243 cds_message.bodyptr = set_req;
13244 cds_message.type = WMA_EXTSCAN_SET_SSID_HOTLIST_REQ;
13245 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13246 sme_release_global_lock(&mac->sme);
13247 if (!CDF_IS_STATUS_SUCCESS(status)) {
13248 cdf_mem_free(set_req);
13249 status = CDF_STATUS_E_FAILURE;
13250 }
13251 } else {
13252 sms_log(mac, LOGE,
13253 FL("sme_acquire_global_lock failed!(status=%d)"),
13254 status);
13255 cdf_mem_free(set_req);
13256 status = CDF_STATUS_E_FAILURE;
13257 }
13258 return status;
13259}
13260
13261CDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
13262 void (*pExtScanIndCb)(void *,
13263 const uint16_t,
13264 void *))
13265{
13266 CDF_STATUS status = CDF_STATUS_SUCCESS;
13267 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13268
13269 status = sme_acquire_global_lock(&pMac->sme);
13270 if (CDF_IS_STATUS_SUCCESS(status)) {
13271 pMac->sme.pExtScanIndCb = pExtScanIndCb;
13272 sme_release_global_lock(&pMac->sme);
13273 }
13274 return status;
13275}
13276
13277#else
13278CDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
13279 void (*pExtScanIndCb)(void *, const uint16_t, void *))
13280{
13281 return CDF_STATUS_SUCCESS;
13282}
13283
13284#endif /* FEATURE_WLAN_EXTSCAN */
13285
13286#ifdef WLAN_FEATURE_LINK_LAYER_STATS
13287
13288/* ---------------------------------------------------------------------------
13289 \fn sme_ll_stats_clear_req
13290 \brief SME API to clear Link Layer Statistics
13291 \param hHal
13292 \param pclearStatsReq: Link Layer clear stats request params structure
13293 \- return CDF_STATUS
13294 -------------------------------------------------------------------------*/
13295CDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
13296 tSirLLStatsClearReq *pclearStatsReq)
13297{
13298 CDF_STATUS status = CDF_STATUS_SUCCESS;
13299 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13300 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13301 cds_msg_t cds_message;
13302 tSirLLStatsClearReq *clear_stats_req;
13303
13304 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13305 "staId = %u", pclearStatsReq->staId);
13306 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13307 "statsClearReqMask = 0x%X",
13308 pclearStatsReq->statsClearReqMask);
13309 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13310 "stopReq = %u", pclearStatsReq->stopReq);
13311
13312 clear_stats_req = cdf_mem_malloc(sizeof(*clear_stats_req));
13313
13314 if (!clear_stats_req) {
13315 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13316 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
13317 __func__);
13318 return CDF_STATUS_E_NOMEM;
13319 }
13320
13321 *clear_stats_req = *pclearStatsReq;
13322
13323 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
13324 /* Serialize the req through MC thread */
13325 cds_message.bodyptr = clear_stats_req;
13326 cds_message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
13327 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13328 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
13329 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13330 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
13331 __func__);
13332 cdf_mem_free(clear_stats_req);
13333 status = CDF_STATUS_E_FAILURE;
13334 }
13335 sme_release_global_lock(&pMac->sme);
13336 } else {
13337 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR, "%s: "
13338 "sme_acquire_global_lock error", __func__);
13339 cdf_mem_free(clear_stats_req);
13340 status = CDF_STATUS_E_FAILURE;
13341 }
13342
13343 return status;
13344}
13345
13346/* ---------------------------------------------------------------------------
13347 \fn sme_ll_stats_set_req
13348 \brief SME API to set the Link Layer Statistics
13349 \param hHal
13350 \param psetStatsReq: Link Layer set stats request params structure
13351 \- return CDF_STATUS
13352 -------------------------------------------------------------------------*/
13353CDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq *psetStatsReq)
13354{
13355 CDF_STATUS status = CDF_STATUS_SUCCESS;
13356 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13357 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13358 cds_msg_t cds_message;
13359 tSirLLStatsSetReq *set_stats_req;
13360
13361 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13362 "%s: MPDU Size = %u", __func__,
13363 psetStatsReq->mpduSizeThreshold);
13364 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13365 " Aggressive Stats Collections = %u",
13366 psetStatsReq->aggressiveStatisticsGathering);
13367
13368 set_stats_req = cdf_mem_malloc(sizeof(*set_stats_req));
13369
13370 if (!set_stats_req) {
13371 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13372 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
13373 __func__);
13374 return CDF_STATUS_E_NOMEM;
13375 }
13376
13377 *set_stats_req = *psetStatsReq;
13378
13379 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
13380 /* Serialize the req through MC thread */
13381 cds_message.bodyptr = set_stats_req;
13382 cds_message.type = WMA_LINK_LAYER_STATS_SET_REQ;
13383 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13384 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
13385 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13386 "%s: not able to post WMA_LL_STATS_SET_REQ",
13387 __func__);
13388 cdf_mem_free(set_stats_req);
13389 status = CDF_STATUS_E_FAILURE;
13390 }
13391 sme_release_global_lock(&pMac->sme);
13392 } else {
13393 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR, "%s: "
13394 "sme_acquire_global_lock error", __func__);
13395 cdf_mem_free(set_stats_req);
13396 status = CDF_STATUS_E_FAILURE;
13397 }
13398
13399 return status;
13400}
13401
13402/* ---------------------------------------------------------------------------
13403 \fn sme_ll_stats_get_req
13404 \brief SME API to get the Link Layer Statistics
13405 \param hHal
13406 \param pgetStatsReq: Link Layer get stats request params structure
13407 \- return CDF_STATUS
13408 -------------------------------------------------------------------------*/
13409CDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq *pgetStatsReq)
13410{
13411 CDF_STATUS status = CDF_STATUS_SUCCESS;
13412 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13413 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13414 cds_msg_t cds_message;
13415 tSirLLStatsGetReq *get_stats_req;
13416
13417 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13418 "reqId = %u", pgetStatsReq->reqId);
13419 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13420 "staId = %u", pgetStatsReq->staId);
13421 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13422 "Stats Type = %u", pgetStatsReq->paramIdMask);
13423
13424 get_stats_req = cdf_mem_malloc(sizeof(*get_stats_req));
13425
13426 if (!get_stats_req) {
13427 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13428 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
13429 __func__);
13430 return CDF_STATUS_E_NOMEM;
13431 }
13432
13433 *get_stats_req = *pgetStatsReq;
13434
13435 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
13436 /* Serialize the req through MC thread */
13437 cds_message.bodyptr = get_stats_req;
13438 cds_message.type = WMA_LINK_LAYER_STATS_GET_REQ;
13439 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13440 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
13441 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13442 "%s: not able to post WMA_LL_STATS_GET_REQ",
13443 __func__);
13444
13445 cdf_mem_free(get_stats_req);
13446 status = CDF_STATUS_E_FAILURE;
13447
13448 }
13449 sme_release_global_lock(&pMac->sme);
13450 } else {
13451 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR, "%s: "
13452 "sme_acquire_global_lock error", __func__);
13453 cdf_mem_free(get_stats_req);
13454 status = CDF_STATUS_E_FAILURE;
13455 }
13456
13457 return status;
13458}
13459
13460/* ---------------------------------------------------------------------------
13461 \fn sme_set_link_layer_stats_ind_cb
13462 \brief SME API to trigger the stats are available after get request
13463 \param hHal
13464 \param callback_routine - HDD callback which needs to be invoked after
13465 getting status notification from FW
13466 \- return CDF_STATUS
13467 -------------------------------------------------------------------------*/
13468CDF_STATUS sme_set_link_layer_stats_ind_cb
13469 (tHalHandle hHal,
13470 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp)
13471 ) {
13472 CDF_STATUS status = CDF_STATUS_SUCCESS;
13473 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13474
13475 status = sme_acquire_global_lock(&pMac->sme);
13476 if (CDF_IS_STATUS_SUCCESS(status)) {
13477 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
13478 sme_release_global_lock(&pMac->sme);
13479 } else {
13480 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR, "%s: "
13481 "sme_acquire_global_lock error", __func__);
13482 }
13483
13484 return status;
13485}
13486
13487#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
13488
13489/**
13490 * sme_fw_mem_dump_register_cb() - Register fw memory dump callback
13491 *
13492 * @hal - MAC global handle
13493 * @callback_routine - callback routine from HDD
13494 *
13495 * This API is invoked by HDD to register its callback in SME
13496 *
13497 * Return: CDF_STATUS
13498 */
13499#ifdef WLAN_FEATURE_MEMDUMP
13500CDF_STATUS sme_fw_mem_dump_register_cb(tHalHandle hal,
13501 void (*callback_routine)(void *cb_context,
13502 struct fw_dump_rsp *rsp))
13503{
13504 CDF_STATUS status = CDF_STATUS_SUCCESS;
13505 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
13506
13507 status = sme_acquire_global_lock(&pmac->sme);
13508 if (CDF_STATUS_SUCCESS == status) {
13509 pmac->sme.fw_dump_callback = callback_routine;
13510 sme_release_global_lock(&pmac->sme);
13511 } else {
13512 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13513 FL("sme_acquire_global_lock error"));
13514 }
13515
13516 return status;
13517}
13518#else
13519CDF_STATUS sme_fw_mem_dump_register_cb(tHalHandle hal,
13520 void (*callback_routine)(void *cb_context,
13521 struct fw_dump_rsp *rsp))
13522{
13523 return CDF_STATUS_SUCCESS;
13524}
13525#endif /* WLAN_FEATURE_MEMDUMP */
13526
13527/**
13528 * sme_fw_mem_dump_unregister_cb() - Unregister fw memory dump callback
13529 *
13530 * @hHal - MAC global handle
13531 *
13532 * This API is invoked by HDD to unregister its callback in SME
13533 *
13534 * Return: CDF_STATUS
13535 */
13536#ifdef WLAN_FEATURE_MEMDUMP
13537CDF_STATUS sme_fw_mem_dump_unregister_cb(tHalHandle hal)
13538{
13539 CDF_STATUS status;
13540 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
13541
13542 status = sme_acquire_global_lock(&pmac->sme);
13543 if (CDF_STATUS_SUCCESS == status) {
13544 pmac->sme.fw_dump_callback = NULL;
13545 sme_release_global_lock(&pmac->sme);
13546 } else {
13547 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13548 FL("sme_acquire_global_lock error"));
13549 }
13550
13551 return status;
13552}
13553#else
13554CDF_STATUS sme_fw_mem_dump_unregister_cb(tHalHandle hal)
13555{
13556 return CDF_STATUS_SUCCESS;
13557}
13558#endif /* WLAN_FEATURE_MEMDUMP */
13559
13560#ifdef WLAN_FEATURE_ROAM_OFFLOAD
13561/*--------------------------------------------------------------------------
13562 \brief sme_update_roam_offload_enabled() - enable/disable roam offload feaure
13563 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
13564 \param hHal - The handle returned by mac_open.
13565 \param nRoamOffloadEnabled - The bool to update with
13566 \return CDF_STATUS_SUCCESS - SME update config successfully.
13567 Other status means SME is failed to update.
13568 \sa
13569 --------------------------------------------------------------------------*/
13570
13571CDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
13572 bool nRoamOffloadEnabled)
13573{
13574 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13575 CDF_STATUS status = CDF_STATUS_SUCCESS;
13576
13577 status = sme_acquire_global_lock(&pMac->sme);
13578 if (CDF_IS_STATUS_SUCCESS(status)) {
13579 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13580 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
13581 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
13582 nRoamOffloadEnabled);
13583 pMac->roam.configParam.isRoamOffloadEnabled =
13584 nRoamOffloadEnabled;
13585 sme_release_global_lock(&pMac->sme);
13586 }
13587
13588 return status;
13589}
13590
13591/*--------------------------------------------------------------------------
13592 \brief sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt
13593 offload
13594 This is a synchronous call
13595 \param hHal - The handle returned by mac_open.
13596 \param sessionId - Session Identifier
13597 \param nRoamKeyMgmtOffloadEnabled - The bool to update with
13598 \return CDF_STATUS_SUCCESS - SME update config successfully.
13599 Other status means SME is failed to update.
13600 \sa
13601 --------------------------------------------------------------------------*/
13602
13603CDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hHal,
13604 uint8_t sessionId,
13605 bool nRoamKeyMgmtOffloadEnabled)
13606{
13607 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13608 CDF_STATUS status = CDF_STATUS_SUCCESS;
13609
13610 status = sme_acquire_global_lock(&pMac->sme);
13611 if (CDF_IS_STATUS_SUCCESS(status)) {
13612 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
13613 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13614 "%s: LFR3: KeyMgmtOffloadEnabled changed to %d",
13615 __func__, nRoamKeyMgmtOffloadEnabled);
13616 status = csr_roam_set_key_mgmt_offload(pMac,
13617 sessionId,
13618 nRoamKeyMgmtOffloadEnabled);
13619 } else {
13620 status = CDF_STATUS_E_INVAL;
13621 }
13622 sme_release_global_lock(&pMac->sme);
13623 }
13624
13625 return status;
13626}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080013627#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013628
13629/* ---------------------------------------------------------------------------
13630 \fn sme_get_temperature
13631 \brief SME API to get the pdev temperature
13632 \param hHal
13633 \param temperature context
13634 \param pCallbackfn: callback fn with response (temperature)
13635 \- return CDF_STATUS
13636 -------------------------------------------------------------------------*/
13637CDF_STATUS sme_get_temperature(tHalHandle hHal,
13638 void *tempContext,
13639 void (*pCallbackfn)(int temperature,
13640 void *pContext))
13641{
13642 CDF_STATUS status = CDF_STATUS_SUCCESS;
13643 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13644 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13645 cds_msg_t cds_message;
13646
13647 status = sme_acquire_global_lock(&pMac->sme);
13648 if (CDF_STATUS_SUCCESS == status) {
13649 if ((NULL == pCallbackfn) &&
13650 (NULL == pMac->sme.pGetTemperatureCb)) {
13651 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13652 FL
13653 ("Indication Call back did not registered"));
13654 sme_release_global_lock(&pMac->sme);
13655 return CDF_STATUS_E_FAILURE;
13656 } else if (NULL != pCallbackfn) {
13657 pMac->sme.pTemperatureCbContext = tempContext;
13658 pMac->sme.pGetTemperatureCb = pCallbackfn;
13659 }
13660 /* serialize the req through MC thread */
13661 cds_message.bodyptr = NULL;
13662 cds_message.type = WMA_GET_TEMPERATURE_REQ;
13663 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13664 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
13665 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13666 FL("Post Get Temperature msg fail"));
13667 status = CDF_STATUS_E_FAILURE;
13668 }
13669 sme_release_global_lock(&pMac->sme);
13670 }
13671 return status;
13672}
13673
13674/* ---------------------------------------------------------------------------
13675 \fn sme_set_scanning_mac_oui
13676 \brief SME API to set scanning mac oui
13677 \param hHal
13678 \param pScanMacOui: Scanning Mac Oui (input 3 bytes)
13679 \- return CDF_STATUS
13680 -------------------------------------------------------------------------*/
13681CDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui *pScanMacOui)
13682{
13683 CDF_STATUS status = CDF_STATUS_SUCCESS;
13684 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13685 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13686 cds_msg_t cds_message;
13687
13688 status = sme_acquire_global_lock(&pMac->sme);
13689 if (CDF_STATUS_SUCCESS == status) {
13690 /* Serialize the req through MC thread */
13691 cds_message.bodyptr = pScanMacOui;
13692 cds_message.type = WMA_SET_SCAN_MAC_OUI_REQ;
13693 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13694 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
13695 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13696 FL("Msg post Set Scan Mac OUI failed"));
13697 status = CDF_STATUS_E_FAILURE;
13698 }
13699 sme_release_global_lock(&pMac->sme);
13700 }
13701 return status;
13702}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013703
13704#ifdef DHCP_SERVER_OFFLOAD
13705/* ---------------------------------------------------------------------------
13706 \fn sme_set_dhcp_srv_offload
13707 \brief SME API to set DHCP server offload info
13708 \param hHal
13709 \param pDhcpSrvInfo : DHCP server offload info struct
13710 \- return CDF_STATUS
13711 -------------------------------------------------------------------------*/
13712CDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
13713 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
13714{
13715 cds_msg_t cds_message;
13716 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
13717 CDF_STATUS status = CDF_STATUS_SUCCESS;
13718 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13719
13720 pSmeDhcpSrvInfo = cdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
13721
13722 if (!pSmeDhcpSrvInfo) {
13723 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13724 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
13725 __func__);
13726 return CDF_STATUS_E_NOMEM;
13727 }
13728
13729 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
13730
13731 status = sme_acquire_global_lock(&pMac->sme);
13732 if (CDF_STATUS_SUCCESS == status) {
13733 /* serialize the req through MC thread */
13734 cds_message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
13735 cds_message.bodyptr = pSmeDhcpSrvInfo;
13736
13737 if (!CDF_IS_STATUS_SUCCESS
13738 (cds_mq_post_message(CDF_MODULE_ID_WMA, &cds_message))) {
13739 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13740 "%s: Not able to post WMA_SET_DHCP_SERVER_OFFLOAD_CMD to WMA!",
13741 __func__);
13742 cdf_mem_free(pSmeDhcpSrvInfo);
13743 status = CDF_STATUS_E_FAILURE;
13744 }
13745 sme_release_global_lock(&pMac->sme);
13746 } else {
13747 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13748 "%s: sme_acquire_global_lock error!", __func__);
13749 cdf_mem_free(pSmeDhcpSrvInfo);
13750 }
13751
13752 return status;
13753}
13754#endif /* DHCP_SERVER_OFFLOAD */
13755
13756#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
13757/* ---------------------------------------------------------------------------
13758 \fn sme_set_led_flashing
13759 \brief API to set the Led flashing parameters.
13760 \param hHal - The handle returned by mac_open.
13761 \param x0, x1 - led flashing parameters
13762 \return CDF_STATUS
13763 ---------------------------------------------------------------------------*/
13764CDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
13765 uint32_t x0, uint32_t x1)
13766{
13767 CDF_STATUS status = CDF_STATUS_SUCCESS;
13768 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13769 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13770 cds_msg_t cds_message;
13771 tSirLedFlashingReq *ledflashing;
13772
13773 ledflashing = cdf_mem_malloc(sizeof(*ledflashing));
13774 if (!ledflashing) {
13775 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13776 FL
13777 ("Not able to allocate memory for WMA_LED_TIMING_REQ"));
13778 return CDF_STATUS_E_NOMEM;
13779 }
13780
13781 ledflashing->pattern_id = type;
13782 ledflashing->led_x0 = x0;
13783 ledflashing->led_x1 = x1;
13784
13785 status = sme_acquire_global_lock(&pMac->sme);
13786 if (CDF_IS_STATUS_SUCCESS(status)) {
13787 /* Serialize the req through MC thread */
13788 cds_message.bodyptr = ledflashing;
13789 cds_message.type = WMA_LED_FLASHING_REQ;
13790 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13791 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
13792 status = CDF_STATUS_E_FAILURE;
13793 sme_release_global_lock(&pMac->sme);
13794 }
13795 return status;
13796}
13797#endif
13798
13799/**
13800 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
13801 * @h_hal: corestack handler
13802 * @dfs_flag: flag indicating dfs channel enable/disable
13803 * Return: CDF_STATUS
13804 */
13805CDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
13806{
13807 CDF_STATUS status = CDF_STATUS_SUCCESS;
13808 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
13809
13810 status = sme_acquire_global_lock(&mac->sme);
13811
13812 if (CDF_STATUS_SUCCESS == status) {
13813
13814 mac->scan.fEnableDFSChnlScan = dfs_flag;
13815
13816 /* update the channel list to the firmware */
13817 status = csr_update_channel_list(mac);
13818
13819 sme_release_global_lock(&mac->sme);
13820 }
13821
13822 return status;
13823}
13824
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053013825#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
13826/**
13827 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
13828 * concurreny rules set to avoid channel interference.
13829 * @hal - Hal context
13830 * @sap_ch - channel to switch
13831 * @sap_phy_mode - phy mode of SAP
13832 * @cc_switch_mode - concurreny switch mode
13833 * @session_id - sme session id.
13834 *
13835 * Return: true if there is no channel interference else return false
13836 */
13837bool sme_validate_sap_channel_switch(tHalHandle hal,
13838 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
13839 uint8_t session_id)
13840{
13841 CDF_STATUS status = CDF_STATUS_E_FAILURE;
13842 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13843 tCsrRoamSession *session = CSR_GET_SESSION(mac, session_id);
13844 uint16_t intf_channel = 0;
13845
13846 if (!session)
13847 return false;
13848
13849 session->ch_switch_in_progress = true;
13850 status = sme_acquire_global_lock(&mac->sme);
13851 if (CDF_IS_STATUS_SUCCESS(status)) {
13852 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
13853 sap_phy_mode,
13854 cc_switch_mode);
13855 sme_release_global_lock(&mac->sme);
13856 } else {
13857 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13858 FL("sme_acquire_global_lock error!"));
13859 session->ch_switch_in_progress = false;
13860 return false;
13861 }
13862
13863 session->ch_switch_in_progress = false;
13864 return (intf_channel == 0) ? true : false;
13865}
13866#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013867
13868/**
13869 * sme_configure_stats_avg_factor() - function to config avg. stats factor
13870 * @hal: hal
13871 * @session_id: session ID
13872 * @stats_avg_factor: average stats factor
13873 *
13874 * This function configures the stats avg factor in firmware
13875 *
13876 * Return: CDF_STATUS
13877 */
13878CDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
13879 uint16_t stats_avg_factor)
13880{
13881 cds_msg_t msg;
13882 CDF_STATUS status = CDF_STATUS_SUCCESS;
13883 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13884 struct sir_stats_avg_factor *stats_factor;
13885
13886 stats_factor = cdf_mem_malloc(sizeof(*stats_factor));
13887
13888 if (!stats_factor) {
13889 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13890 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
13891 __func__);
13892 return CDF_STATUS_E_NOMEM;
13893 }
13894
13895 status = sme_acquire_global_lock(&mac->sme);
13896
13897 if (CDF_STATUS_SUCCESS == status) {
13898
13899 stats_factor->vdev_id = session_id;
13900 stats_factor->stats_avg_factor = stats_avg_factor;
13901
13902 /* serialize the req through MC thread */
13903 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
13904 msg.bodyptr = stats_factor;
13905
13906 if (!CDF_IS_STATUS_SUCCESS(
13907 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
13908 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13909 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
13910 __func__);
13911 cdf_mem_free(stats_factor);
13912 status = CDF_STATUS_E_FAILURE;
13913 }
13914 sme_release_global_lock(&mac->sme);
13915 } else {
13916 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13917 "%s: sme_acquire_global_lock error!",
13918 __func__);
13919 cdf_mem_free(stats_factor);
13920 }
13921
13922 return status;
13923}
13924
13925/**
13926 * sme_configure_guard_time() - function to configure guard time
13927 * @hal: hal
13928 * @session_id: session id
13929 * @guard_time: guard time
13930 *
13931 * This function configures the guard time in firmware
13932 *
13933 * Return: CDF_STATUS
13934 */
13935CDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
13936 uint32_t guard_time)
13937{
13938 cds_msg_t msg;
13939 CDF_STATUS status = CDF_STATUS_SUCCESS;
13940 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13941 struct sir_guard_time_request *g_time;
13942
13943 g_time = cdf_mem_malloc(sizeof(*g_time));
13944
13945 if (!g_time) {
13946 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13947 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
13948 __func__);
13949 return CDF_STATUS_E_NOMEM;
13950 }
13951
13952 status = sme_acquire_global_lock(&mac->sme);
13953
13954 if (CDF_STATUS_SUCCESS == status) {
13955
13956 g_time->vdev_id = session_id;
13957 g_time->guard_time = guard_time;
13958
13959 /* serialize the req through MC thread */
13960 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
13961 msg.bodyptr = g_time;
13962
13963 if (!CDF_IS_STATUS_SUCCESS(
13964 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
13965 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13966 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
13967 __func__);
13968 cdf_mem_free(g_time);
13969 status = CDF_STATUS_E_FAILURE;
13970 }
13971 sme_release_global_lock(&mac->sme);
13972 } else {
13973 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13974 "%s: sme_acquire_global_lock error!",
13975 __func__);
13976 cdf_mem_free(g_time);
13977 }
13978
13979 return status;
13980}
13981
13982/**
13983 * sme_configure_modulated_dtim() - function to configure modulated dtim
13984 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
13985 * @session_id: session ID
13986 * @modulated_dtim: modulated dtim value
13987 *
13988 * This function configures the modulated dtim in firmware
13989 *
13990 * Return: CDF_STATUS
13991 */
13992CDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
13993 uint32_t modulated_dtim)
13994{
13995 cds_msg_t msg;
13996 CDF_STATUS status = CDF_STATUS_SUCCESS;
13997 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
13998 wma_cli_set_cmd_t *iwcmd;
13999
14000 iwcmd = cdf_mem_malloc(sizeof(*iwcmd));
14001 if (NULL == iwcmd) {
14002 CDF_TRACE(CDF_MODULE_ID_SME,
14003 CDF_TRACE_LEVEL_FATAL,
14004 "%s: cdf_mem_alloc failed", __func__);
14005 return CDF_STATUS_E_NOMEM;
14006 }
14007
14008 status = sme_acquire_global_lock(&mac->sme);
14009
14010 if (CDF_STATUS_SUCCESS == status) {
14011
14012 cdf_mem_zero((void *)iwcmd, sizeof(*iwcmd));
14013 iwcmd->param_value = modulated_dtim;
14014 iwcmd->param_vdev_id = session_id;
14015 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
14016 iwcmd->param_vp_dev = GEN_CMD;
14017 msg.type = WMA_CLI_SET_CMD;
14018 msg.reserved = 0;
14019 msg.bodyptr = (void *)iwcmd;
14020
14021 if (!CDF_IS_STATUS_SUCCESS(
14022 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
14023 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14024 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
14025 __func__);
14026 cdf_mem_free(iwcmd);
14027 status = CDF_STATUS_E_FAILURE;
14028 }
14029 sme_release_global_lock(&mac->sme);
14030 } else {
14031 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14032 "%s: sme_acquire_global_lock error!",
14033 __func__);
14034 cdf_mem_free(iwcmd);
14035 }
14036
14037 return status;
14038}
14039
14040/*
14041 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
14042 * to either start/stop logging
14043 * @hal: HAL context
14044 * @start_log: Structure containing the wifi start logger params
14045 *
14046 * This function sends the start/stop logging command to WMA
14047 *
14048 * Return: CDF_STATUS_SUCCESS on successful posting
14049 */
14050CDF_STATUS sme_wifi_start_logger(tHalHandle hal,
14051 struct sir_wifi_start_log start_log)
14052{
14053 CDF_STATUS status = CDF_STATUS_SUCCESS;
14054 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14055 cds_msg_t cds_message;
14056 struct sir_wifi_start_log *req_msg;
14057 uint32_t len;
14058
14059 len = sizeof(*req_msg);
14060 req_msg = cdf_mem_malloc(len);
14061 if (!req_msg) {
14062 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
14063 return CDF_STATUS_E_NOMEM;
14064 }
14065
14066 cdf_mem_zero(req_msg, len);
14067
14068 req_msg->verbose_level = start_log.verbose_level;
14069 req_msg->flag = start_log.flag;
14070 req_msg->ring_id = start_log.ring_id;
14071
14072 status = sme_acquire_global_lock(&mac->sme);
14073 if (status != CDF_STATUS_SUCCESS) {
14074 sms_log(mac, LOGE,
14075 FL("sme_acquire_global_lock failed(status=%d)"),
14076 status);
14077 cdf_mem_free(req_msg);
14078 return status;
14079 }
14080
14081 /* Serialize the req through MC thread */
14082 cds_message.bodyptr = req_msg;
14083 cds_message.type = SIR_HAL_START_STOP_LOGGING;
14084 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
14085 if (!CDF_IS_STATUS_SUCCESS(status)) {
14086 sms_log(mac, LOGE,
14087 FL("vos_mq_post_message failed!(err=%d)"),
14088 status);
14089 cdf_mem_free(req_msg);
14090 status = CDF_STATUS_E_FAILURE;
14091 }
14092 sme_release_global_lock(&mac->sme);
14093
14094 return status;
14095}
14096
14097/**
14098 * sme_neighbor_middle_of_roaming() - Function to know if
14099 * STA is in the middle of roaming states
14100 * @hal: Handle returned by macOpen
14101 * @sessionId: sessionId of the STA session
14102 *
14103 * This function is a wrapper to call
14104 * csr_neighbor_middle_of_roaming to know STA is in the
14105 * middle of roaming states
14106 *
14107 * Return: True or False
14108 *
14109 */
14110bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
14111{
14112 return csr_neighbor_middle_of_roaming(PMAC_STRUCT(hHal), sessionId);
14113}
14114
14115/*
14116 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
14117 * @mac: MAC handle
14118 *
14119 * This function is used to send the command that will
14120 * be used to flush the logs in the firmware
14121 *
14122 * Return: eHalStatus
14123 */
14124CDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
14125{
14126 CDF_STATUS status;
14127 cds_msg_t message;
14128
14129 status = sme_acquire_global_lock(&mac->sme);
14130 if (status != CDF_STATUS_SUCCESS) {
14131 sms_log(mac, LOGE,
14132 FL("sme_acquire_global_lock failed!(status=%d)"),
14133 status);
14134 return status;
14135 }
14136
14137 /* Serialize the req through MC thread */
14138 message.bodyptr = NULL;
14139 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
14140 status = cds_mq_post_message(CDS_MQ_ID_WMA, &message);
14141 if (!CDF_IS_STATUS_SUCCESS(status)) {
14142 sms_log(mac, LOGE,
14143 FL("cds_mq_post_message failed!(err=%d)"),
14144 status);
14145 status = CDF_STATUS_E_FAILURE;
14146 }
14147 sme_release_global_lock(&mac->sme);
14148 return status;
14149}
14150
14151/**
14152 * sme_enable_uapsd_for_ac() - enable uapsd for access catagory requerst to WMA
14153 * @cds_ctx: cds context
14154 * @sta_id: station id
14155 * @ac: access catagory
14156 * @tid: tid value
14157 * @pri: user priority
14158 * @srvc_int: service interval
14159 * @sus_int: suspend interval
14160 * @dir: tspec direction
14161 * @psb: PSB value
14162 * @sessionId: session id
14163 * @delay_interval: delay interval
14164 *
14165 * Return: CDF status
14166 */
14167CDF_STATUS sme_enable_uapsd_for_ac(void *cds_ctx, uint8_t sta_id,
14168 sme_ac_enum_type ac, uint8_t tid,
14169 uint8_t pri, uint32_t srvc_int,
14170 uint32_t sus_int,
14171 sme_tspec_dir_type dir,
14172 uint8_t psb, uint32_t sessionId,
14173 uint32_t delay_interval)
14174{
14175 void *wma_handle;
14176 t_wma_trigger_uapsd_params uapsd_params;
14177 enum uapsd_ac access_category;
14178
14179 if (!psb) {
14180 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
14181 "No need to configure auto trigger:psb is 0");
14182 return CDF_STATUS_SUCCESS;
14183 }
14184
14185 wma_handle = cds_get_context(CDF_MODULE_ID_WMA);
14186 if (!wma_handle) {
14187 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14188 "wma_handle is NULL");
14189 return CDF_STATUS_E_FAILURE;
14190 }
14191
14192 switch (ac) {
14193 case SME_AC_BK:
14194 access_category = UAPSD_BK;
14195 break;
14196 case SME_AC_BE:
14197 access_category = UAPSD_BE;
14198 break;
14199 case SME_AC_VI:
14200 access_category = UAPSD_VI;
14201 break;
14202 case SME_AC_VO:
14203 access_category = UAPSD_VO;
14204 break;
14205 default:
14206 return CDF_STATUS_E_FAILURE;
14207 }
14208
14209 uapsd_params.wmm_ac = access_category;
14210 uapsd_params.user_priority = pri;
14211 uapsd_params.service_interval = srvc_int;
14212 uapsd_params.delay_interval = delay_interval;
14213 uapsd_params.suspend_interval = sus_int;
14214
14215 if (CDF_STATUS_SUCCESS !=
14216 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
14217 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14218 "Failed to Trigger Uapsd params for sessionId %d",
14219 sessionId);
14220 return CDF_STATUS_E_FAILURE;
14221 }
14222 return CDF_STATUS_SUCCESS;
14223}
14224
14225/**
14226 * sme_disable_uapsd_for_ac() - disable uapsed access catagory request to WMA
14227 * @cds_ctx: cds context
14228 * @sta_id: station id
14229 * @ac: access catagory
14230 * @sessionId: session id
14231 *
14232 * Return: CDF status
14233 */
14234CDF_STATUS sme_disable_uapsd_for_ac(void *cds_ctx, uint8_t sta_id,
14235 sme_ac_enum_type ac,
14236 uint32_t sessionId)
14237{
14238 void *wma_handle;
14239 enum uapsd_ac access_category;
14240
14241 switch (ac) {
14242 case SME_AC_BK:
14243 access_category = UAPSD_BK;
14244 break;
14245 case SME_AC_BE:
14246 access_category = UAPSD_BE;
14247 break;
14248 case SME_AC_VI:
14249 access_category = UAPSD_VI;
14250 break;
14251 case SME_AC_VO:
14252 access_category = UAPSD_VO;
14253 break;
14254 default:
14255 return CDF_STATUS_E_FAILURE;
14256 }
14257
14258 wma_handle = cds_get_context(CDF_MODULE_ID_WMA);
14259 if (!wma_handle) {
14260 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14261 "wma handle is NULL");
14262 return CDF_STATUS_E_FAILURE;
14263 }
14264 if (CDF_STATUS_SUCCESS !=
14265 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
14266 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14267 "Failed to disable uapsd for ac %d for sessionId %d",
14268 ac, sessionId);
14269 return CDF_STATUS_E_FAILURE;
14270 }
14271 return CDF_STATUS_SUCCESS;
14272}
14273
14274/**
14275 * sme_update_nss() - SME API to change the number for spatial streams
14276 * (1 or 2)
14277 * @hal: Handle returned by mac open
14278 * @nss: Number of spatial streams
14279 *
14280 * This function is used to update the number of spatial streams supported.
14281 *
14282 * Return: Success upon successfully changing nss else failure
14283 *
14284 */
14285CDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
14286{
14287 CDF_STATUS status;
14288 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
14289 uint32_t i, value = 0;
14290 union {
14291 uint16_t cfg_value16;
14292 tSirMacHTCapabilityInfo ht_cap_info;
14293 } uHTCapabilityInfo;
14294 tCsrRoamSession *csr_session;
14295
14296 status = sme_acquire_global_lock(&mac_ctx->sme);
14297
14298 if (CDF_STATUS_SUCCESS == status) {
14299 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
14300
14301 /* get the HT capability info*/
14302 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
14303 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
14304
14305 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
14306 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
14307 csr_session = &mac_ctx->roam.roamSession[i];
14308 csr_session->htConfig.ht_tx_stbc =
14309 uHTCapabilityInfo.ht_cap_info.txSTBC;
14310 }
14311 }
14312
14313 sme_release_global_lock(&mac_ctx->sme);
14314 }
14315 return status;
14316}
14317
14318/**
14319 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
14320 * @hal: global hal handle
14321 * @cb: callback function pointer
14322 *
14323 * This function stores the rssi threshold breached callback function.
14324 *
14325 * Return: CDF_STATUS enumeration.
14326 */
14327CDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle hal,
14328 void (*cb)(void *, struct rssi_breach_event *))
14329{
14330 CDF_STATUS status = CDF_STATUS_SUCCESS;
14331 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14332
14333 status = sme_acquire_global_lock(&mac->sme);
14334 if (!CDF_IS_STATUS_SUCCESS(status)) {
14335 sms_log(mac, LOGE,
14336 FL("sme_acquire_global_lock failed!(status=%d)"),
14337 status);
14338 return status;
14339 }
14340
14341 mac->sme.rssi_threshold_breached_cb = cb;
14342 sme_release_global_lock(&mac->sme);
14343 return status;
14344}
14345
14346/**
14347 * sme_is_any_session_in_connected_state() - SME wrapper API to
14348 * check if any session is in connected state or not.
14349 *
14350 * @hal: Handle returned by mac open
14351 *
14352 * This function is used to check if any valid sme session is in
14353 * connected state or not.
14354 *
14355 * Return: true if any session is connected, else false.
14356 *
14357 */
14358bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
14359{
14360 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
14361 CDF_STATUS status;
14362 bool ret = false;
14363
14364 status = sme_acquire_global_lock(&mac_ctx->sme);
14365 if (CDF_STATUS_SUCCESS == status) {
14366 ret = csr_is_any_session_in_connect_state(mac_ctx);
14367 sme_release_global_lock(&mac_ctx->sme);
14368 }
14369 return ret;
14370}
14371
14372/**
14373 * sme_set_rssi_monitoring() - set rssi monitoring
14374 * @hal: global hal handle
14375 * @input: request message
14376 *
14377 * This function constructs the vos message and fill in message type,
14378 * bodyptr with @input and posts it to WDA queue.
14379 *
14380 * Return: CDF_STATUS enumeration
14381 */
14382CDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
14383 struct rssi_monitor_req *input)
14384{
14385 CDF_STATUS status = CDF_STATUS_SUCCESS;
14386 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14387 cds_msg_t cds_message;
14388 struct rssi_monitor_req *req_msg;
14389
14390 sms_log(mac, LOG1, FL("enter"));
14391 req_msg = cdf_mem_malloc(sizeof(*req_msg));
14392 if (!req_msg) {
14393 sms_log(mac, LOGE, FL("memory allocation failed"));
14394 return CDF_STATUS_E_NOMEM;
14395 }
14396
14397 *req_msg = *input;
14398
14399 status = sme_acquire_global_lock(&mac->sme);
14400 if (!CDF_IS_STATUS_SUCCESS(status)) {
14401 sms_log(mac, LOGE,
14402 FL("sme_acquire_global_lock failed!(status=%d)"),
14403 status);
14404 cdf_mem_free(req_msg);
14405 return status;
14406 }
14407
14408 /* Serialize the req through MC thread */
14409 cds_message.bodyptr = req_msg;
14410 cds_message.type = WMA_SET_RSSI_MONITOR_REQ;
14411 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
14412 if (!CDF_IS_STATUS_SUCCESS(status)) {
14413 sms_log(mac, LOGE,
14414 FL("cds_mq_post_message failed!(err=%d)"),
14415 status);
14416 cdf_mem_free(req_msg);
14417 }
14418 sme_release_global_lock(&mac->sme);
14419
14420 return status;
14421}
14422
14423/**
14424 * sme_fw_mem_dump() - Get FW memory dump
14425 * @hHal: hal handle
14426 * @recvd_req: received memory dump request.
14427 *
14428 * This API is invoked by HDD to indicate FW to start
14429 * dumping firmware memory.
14430 *
14431 * Return: CDF_STATUS
14432 */
14433#ifdef WLAN_FEATURE_MEMDUMP
14434CDF_STATUS sme_fw_mem_dump(tHalHandle hHal, void *recvd_req)
14435{
14436 CDF_STATUS status = CDF_STATUS_SUCCESS;
14437 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
14438 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14439 cds_msg_t msg;
14440 struct fw_dump_req *send_req;
14441 struct fw_dump_seg_req seg_req;
14442 int loop;
14443
14444 send_req = cdf_mem_malloc(sizeof(*send_req));
14445 if (!send_req) {
14446 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14447 FL("Memory allocation failed for WDA_FW_MEM_DUMP"));
14448 return CDF_STATUS_E_FAILURE;
14449 }
14450 cdf_mem_copy(send_req, recvd_req, sizeof(*send_req));
14451
14452 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14453 FL("request_id:%d num_seg:%d"),
14454 send_req->request_id, send_req->num_seg);
14455 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14456 FL("Segment Information"));
14457 for (loop = 0; loop < send_req->num_seg; loop++) {
14458 seg_req = send_req->segment[loop];
14459 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14460 FL("seg_number:%d"), loop);
14461 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14462 FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
14463 seg_req.seg_id, seg_req.seg_start_addr_lo,
14464 seg_req.seg_start_addr_hi);
14465 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14466 FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
14467 seg_req.seg_length, seg_req.dst_addr_lo,
14468 seg_req.dst_addr_hi);
14469 }
14470
14471 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
14472 msg.bodyptr = send_req;
14473 msg.type = WMA_FW_MEM_DUMP_REQ;
14474 msg.reserved = 0;
14475
14476 cdf_status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
14477 if (CDF_STATUS_SUCCESS != cdf_status) {
14478 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14479 FL("Not able to post WMA_FW_MEM_DUMP"));
14480 cdf_mem_free(send_req);
14481 status = CDF_STATUS_E_FAILURE;
14482 }
14483 sme_release_global_lock(&pMac->sme);
14484 } else {
14485 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14486 FL("Failed to acquire SME Global Lock"));
14487 cdf_mem_free(send_req);
14488 status = CDF_STATUS_E_FAILURE;
14489 }
14490
14491 return status;
14492}
14493#else
14494CDF_STATUS sme_fw_mem_dump(tHalHandle hHal, void *recvd_req)
14495{
14496 return CDF_STATUS_SUCCESS;
14497}
14498#endif /* WLAN_FEATURE_MEMDUMP */
14499
14500/*
14501 * sme_soc_set_pcl() - Send WMI_SOC_SET_PCL_CMDID to the WMA
14502 * @hal: Handle returned by macOpen
14503 * @msg: PCL channel list and length structure
14504 *
14505 * Sends the command to WMA to send WMI_SOC_SET_PCL_CMDID to FW
14506 * Return: CDF_STATUS_SUCCESS on successful posting
14507 */
14508CDF_STATUS sme_soc_set_pcl(tHalHandle hal,
14509 struct sir_pcl_list msg)
14510{
14511 CDF_STATUS status = CDF_STATUS_SUCCESS;
14512 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14513 cds_msg_t cds_message;
14514 struct sir_pcl_list *req_msg;
14515 uint32_t len, i;
14516
14517 len = sizeof(*req_msg);
14518
14519 req_msg = cdf_mem_malloc(len);
14520 if (!req_msg) {
14521 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
14522 return CDF_STATUS_E_NOMEM;
14523 }
14524
14525 cdf_mem_zero(req_msg, len);
14526
14527 for (i = 0; i < msg.pcl_len; i++)
14528 req_msg->pcl_list[i] = msg.pcl_list[i];
14529
14530 req_msg->pcl_len = msg.pcl_len;
14531
14532 status = sme_acquire_global_lock(&mac->sme);
14533 if (status != CDF_STATUS_SUCCESS) {
14534 sms_log(mac, LOGE,
14535 FL("sme_AcquireGlobalLock failed!(status=%d)"),
14536 status);
14537 cdf_mem_free(req_msg);
14538 return status;
14539 }
14540
14541 /* Serialize the req through MC thread */
14542 cds_message.bodyptr = req_msg;
14543 cds_message.type = SIR_HAL_SOC_SET_PCL_TO_FW;
14544 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
14545 if (!CDF_IS_STATUS_SUCCESS(status)) {
14546 sms_log(mac, LOGE,
14547 FL("vos_mq_post_message failed!(err=%d)"),
14548 status);
14549 cdf_mem_free(req_msg);
14550 status = CDF_STATUS_E_FAILURE;
14551 }
14552 sme_release_global_lock(&mac->sme);
14553
14554 return status;
14555}
14556
14557/*
14558 * sme_soc_set_hw_mode() - Send WMI_SOC_SET_HW_MODE_CMDID to the WMA
14559 * @hal: Handle returned by macOpen
14560 * @msg: HW mode structure containing hw mode and callback details
14561 *
14562 * Sends the command to CSR to send WMI_SOC_SET_HW_MODE_CMDID to FW
14563 * Return: CDF_STATUS_SUCCESS on successful posting
14564 */
14565CDF_STATUS sme_soc_set_hw_mode(tHalHandle hal,
14566 struct sir_hw_mode msg)
14567{
14568 CDF_STATUS status = CDF_STATUS_SUCCESS;
14569 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14570 tSmeCmd *cmd = NULL;
14571
14572 status = sme_acquire_global_lock(&mac->sme);
14573 if (!CDF_IS_STATUS_SUCCESS(status)) {
14574 sms_log(mac, LOGE, FL("Failed to acquire lock"));
14575 return CDF_STATUS_E_RESOURCES;
14576 }
14577
14578 cmd = sme_get_command_buffer(mac);
14579 if (!cmd) {
14580 sms_log(mac, LOGE, FL("Get command buffer failed"));
14581 sme_release_global_lock(&mac->sme);
14582 return CDF_STATUS_E_NULL_VALUE;
14583 }
14584
14585 cmd->command = e_sme_command_set_hw_mode;
14586 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
14587 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053014588 cmd->u.set_hw_mode_cmd.reason = msg.reason;
14589 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014590
14591 sms_log(mac, LOG1, FL("Queuing e_sme_command_set_hw_mode to CSR"));
14592 csr_queue_sme_command(mac, cmd, false);
14593
14594 sme_release_global_lock(&mac->sme);
14595 return CDF_STATUS_SUCCESS;
14596}
14597
14598/**
14599 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
14600 * @hal: Handle returned by macOpen
14601 * @callback: HDD callback to be registered
14602 *
14603 * Registers the HDD callback with SME. This callback will be invoked when
14604 * HW mode transition event is received from the FW
14605 *
14606 * Return: None
14607 */
14608void sme_register_hw_mode_trans_cb(tHalHandle hal,
14609 hw_mode_transition_cb callback)
14610{
14611 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14612
14613 mac->sme.sme_hw_mode_trans_cb = callback;
14614 sms_log(mac, LOG1, FL("HW mode transition callback registered"));
14615}
14616
14617/**
14618 * sme_nss_update_request() - Send beacon templete update to FW with new
14619 * nss value
14620 * @hal: Handle returned by macOpen
14621 * @vdev_id: the session id
14622 * @new_nss: the new nss value
14623 * @cback: hdd callback
14624 * @next_action: next action to happen at policy mgr after beacon update
14625 *
14626 * Sends the command to CSR to send to PE
14627 * Return: CDF_STATUS_SUCCESS on successful posting
14628 */
14629CDF_STATUS sme_nss_update_request(tHalHandle hHal, uint32_t vdev_id,
14630 uint8_t new_nss, void *cback, uint8_t next_action,
14631 void *hdd_context)
14632{
14633 CDF_STATUS status = CDF_STATUS_E_FAILURE;
14634 tpAniSirGlobal mac = PMAC_STRUCT(hHal);
14635 tSmeCmd *cmd = NULL;
14636
14637 status = sme_acquire_global_lock(&mac->sme);
14638 if (CDF_IS_STATUS_SUCCESS(status)) {
14639 cmd = sme_get_command_buffer(mac);
14640 if (!cmd) {
14641 sms_log(mac, LOGE, FL("Get command buffer failed"));
14642 sme_release_global_lock(&mac->sme);
14643 return CDF_STATUS_E_NULL_VALUE;
14644 }
14645 cmd->command = e_sme_command_nss_update;
14646 /* Sessionized modules may require this info */
14647 cmd->sessionId = vdev_id;
14648 cmd->u.nss_update_cmd.new_nss = new_nss;
14649 cmd->u.nss_update_cmd.session_id = vdev_id;
14650 cmd->u.nss_update_cmd.nss_update_cb = cback;
14651 cmd->u.nss_update_cmd.context = hdd_context;
14652 cmd->u.nss_update_cmd.next_action = next_action;
14653
14654 sms_log(mac, LOG1, FL("Queuing e_sme_command_nss_update to CSR"));
14655 csr_queue_sme_command(mac, cmd, false);
14656 sme_release_global_lock(&mac->sme);
14657 }
14658 return status;
14659}
14660
14661/**
14662 * sme_soc_set_dual_mac_config() - Set dual mac configurations
14663 * @hal: Handle returned by macOpen
14664 * @msg: Structure containing the dual mac config parameters
14665 *
14666 * Queues configuration information to CSR to configure
14667 * WLAN firmware for the dual MAC features
14668 *
14669 * Return: CDF_STATUS
14670 */
14671CDF_STATUS sme_soc_set_dual_mac_config(tHalHandle hal,
14672 struct sir_dual_mac_config msg)
14673{
14674 CDF_STATUS status = CDF_STATUS_SUCCESS;
14675 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14676 tSmeCmd *cmd;
14677
14678 status = sme_acquire_global_lock(&mac->sme);
14679 if (!CDF_IS_STATUS_SUCCESS(status)) {
14680 sms_log(mac, LOGE, FL("Failed to acquire lock"));
14681 return CDF_STATUS_E_RESOURCES;
14682 }
14683
14684 cmd = sme_get_command_buffer(mac);
14685 if (!cmd) {
14686 sms_log(mac, LOGE, FL("Get command buffer failed"));
14687 sme_release_global_lock(&mac->sme);
14688 return CDF_STATUS_E_NULL_VALUE;
14689 }
14690
14691 cmd->command = e_sme_command_set_dual_mac_config;
14692 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
14693 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
14694 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
14695
14696 sms_log(mac, LOG1,
14697 FL("Queuing e_sme_command_set_dual_mac_config to CSR: %x %x"),
14698 cmd->u.set_dual_mac_cmd.scan_config,
14699 cmd->u.set_dual_mac_cmd.fw_mode_config);
14700 csr_queue_sme_command(mac, cmd, false);
14701
14702 sme_release_global_lock(&mac->sme);
14703 return CDF_STATUS_SUCCESS;
14704}
14705
Ravi Joshi9e891ba2015-11-09 19:03:46 -080014706#ifdef FEATURE_LFR_SUBNET_DETECTION
14707/**
14708 * sme_gateway_param_update() - to update gateway parameters with WMA
14709 * @Hal: hal handle
14710 * @gw_params: request parameters from HDD
14711 *
14712 * Return: CDF_STATUS
14713 *
14714 * This routine will update gateway parameters to WMA
14715 */
14716CDF_STATUS sme_gateway_param_update(tHalHandle Hal,
14717 struct gateway_param_update_req *gw_params)
14718{
14719 CDF_STATUS cdf_status;
14720 cds_msg_t cds_message;
14721 struct gateway_param_update_req *request_buf;
14722
14723 request_buf = cdf_mem_malloc(sizeof(*request_buf));
14724 if (NULL == request_buf) {
14725 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14726 FL("Not able to allocate memory for gw param update request"));
14727 return CDF_STATUS_E_NOMEM;
14728 }
14729
14730 *request_buf = *gw_params;
14731
14732 cds_message.type = WMA_GW_PARAM_UPDATE_REQ;
14733 cds_message.reserved = 0;
14734 cds_message.bodyptr = request_buf;
14735 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
14736 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
14737 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14738 FL("Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL"));
14739 cdf_mem_free(request_buf);
14740 return CDF_STATUS_E_FAILURE;
14741 }
14742
14743 return CDF_STATUS_SUCCESS;
14744}
14745#endif /* FEATURE_LFR_SUBNET_DETECTION */
14746
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014747/**
14748 * sme_set_peer_authorized() - call peer authorized callback
14749 * @peer_addr: peer mac address
14750 * @auth_cb: auth callback
14751 * @vdev_id: vdev id
14752 *
14753 * Return: CDF Status
14754 */
14755CDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
14756 sme_peer_authorized_fp auth_cb,
14757 uint32_t vdev_id)
14758{
14759 void *wma_handle;
14760
14761 wma_handle = cds_get_context(CDF_MODULE_ID_WMA);
14762 if (!wma_handle) {
14763 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14764 "wma handle is NULL");
14765 return CDF_STATUS_E_FAILURE;
14766 }
14767
14768 wma_set_peer_authorized_cb(wma_handle, auth_cb);
14769 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
14770 1, vdev_id);
14771}
14772
14773/*
14774 * sme_disable_non_fcc_channel() - non-fcc channel disable request
14775 * @hal: HAL pointer
14776 * @fcc_constraint: true: disable, false; enable
14777 *
14778 * Return: CDF_STATUS
14779 */
14780CDF_STATUS sme_disable_non_fcc_channel(tHalHandle hal, bool fcc_constraint)
14781{
14782 CDF_STATUS status;
14783 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
14784
14785 status = sme_acquire_global_lock(&mac_ptr->sme);
14786
14787 if (CDF_STATUS_SUCCESS == status) {
14788
14789 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
14790 mac_ptr->scan.fcc_constraint = fcc_constraint;
14791
14792 /* update the channel list in firmware */
14793 status = csr_update_channel_list(mac_ptr);
14794 }
14795
14796 sme_release_global_lock(&mac_ptr->sme);
14797 }
14798
14799 return status;
14800}
14801/**
14802 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
14803 * @hal: Global MAC pointer
14804 *
14805 * Return: NULL.
14806 */
14807void sme_setdef_dot11mode(tHalHandle hal)
14808{
14809 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14810 csr_set_default_dot11_mode(mac_ctx);
14811}
14812
14813/**
14814 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
14815 * params
14816 * @hal_handle - The handle returned by macOpen.
14817 * @session_id - Session Identifier
14818 * @notify_id - Identifies 1 of the 4 parameters to be modified
14819 * @val New value of the parameter
14820 *
14821 * Return: CDF_STATUS - SME update config successful.
14822 * Other status means SME failed to update
14823 */
14824
14825CDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
14826 uint8_t session_id,
14827 uint32_t notify_id,
14828 int32_t val)
14829{
14830 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14831 CDF_STATUS status = CDF_STATUS_SUCCESS;
14832 tCsrNeighborRoamConfig *nr_config = NULL;
14833 tpCsrNeighborRoamControlInfo nr_info = NULL;
14834 uint32_t reason = 0;
14835
14836 status = sme_acquire_global_lock(&mac_ctx->sme);
14837 if (CDF_IS_STATUS_SUCCESS(status)) {
14838 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
14839 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
14840 switch (notify_id) {
14841 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
14842 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14843 "%s: gRoamScanHirssiMaxCount %d => %d",
14844 __func__, nr_config->nhi_rssi_scan_max_count,
14845 val);
14846 nr_config->nhi_rssi_scan_max_count = val;
14847 nr_info->cfgParams.hi_rssi_scan_max_count = val;
14848 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
14849 break;
14850
14851 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
14852 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14853 FL("gRoamScanHiRssiDelta %d => %d"),
14854 nr_config->nhi_rssi_scan_rssi_delta,
14855 val);
14856 nr_config->nhi_rssi_scan_rssi_delta = val;
14857 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
14858 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
14859 break;
14860
14861 case eCSR_HI_RSSI_SCAN_DELAY_ID:
14862 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14863 FL("gRoamScanHiRssiDelay %d => %d"),
14864 nr_config->nhi_rssi_scan_delay,
14865 val);
14866 nr_config->nhi_rssi_scan_delay = val;
14867 nr_info->cfgParams.hi_rssi_scan_delay = val;
14868 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
14869 break;
14870
14871 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
14872 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14873 FL("gRoamScanHiRssiUpperBound %d => %d"),
14874 nr_config->nhi_rssi_scan_rssi_ub,
14875 val);
14876 nr_config->nhi_rssi_scan_rssi_ub = val;
14877 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
14878 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
14879 break;
14880
14881 default:
14882 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14883 FL("invalid parameter notify_id %d"),
14884 notify_id);
14885 status = CDF_STATUS_E_INVAL;
14886 break;
14887 }
14888 sme_release_global_lock(&mac_ctx->sme);
14889 }
14890#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14891 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
14892 status == CDF_STATUS_SUCCESS) {
14893 csr_roam_offload_scan(mac_ctx, session_id,
14894 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
14895 }
14896#endif
14897
14898 return status;
14899}
14900
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070014901/**
14902 * sme_update_tgt_services() - update the target services config.
14903 * @hal: HAL pointer.
14904 * @cfg: wma_tgt_services parameters.
14905 *
14906 * update the target services config.
14907 *
14908 * Return: None.
14909 */
14910void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
14911{
14912 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14913
14914 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
14915 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053014916 mac_ctx->pmf_offload = cfg->pmf_offload;
14917 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14918 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070014919
14920 return;
14921}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014922
14923#ifdef FEATURE_WLAN_TDLS
14924
14925/**
14926 * sme_get_opclass() - determine operating class
14927 * @hal: Pointer to HAL
14928 * @channel: channel id
14929 * @bw_offset: bandwidth offset
14930 * @opclass: pointer to operating class
14931 *
14932 * Function will determine operating class from regdm_get_opclass_from_channel
14933 *
14934 * Return: none
14935 */
14936void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
14937 uint8_t *opclass)
14938{
14939 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14940
14941 /* redgm opclass table contains opclass for 40MHz low primary,
14942 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
14943 * first we will check if bit for 40MHz is set and if so find
14944 * matching opclass either with low primary or high primary
14945 * (a channel would never be in both) and then search for opclass
14946 * matching 20MHz, else for any BW.
14947 */
14948 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
14949 *opclass = cds_regdm_get_opclass_from_channel(
14950 mac_ctx->scan.countryCodeCurrent,
14951 channel, BW40_LOW_PRIMARY);
14952 if (!(*opclass)) {
14953 *opclass = cds_regdm_get_opclass_from_channel(
14954 mac_ctx->scan.countryCodeCurrent,
14955 channel, BW40_HIGH_PRIMARY);
14956 }
14957 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
14958 *opclass = cds_regdm_get_opclass_from_channel(
14959 mac_ctx->scan.countryCodeCurrent,
14960 channel, BW20);
14961 } else {
14962 *opclass = cds_regdm_get_opclass_from_channel(
14963 mac_ctx->scan.countryCodeCurrent,
14964 channel, BWALL);
14965 }
14966}
14967#endif