blob: e1651637af8434b1bd923360ef861b79ef6b450a [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
66#define READ_MEMORY_DUMP_CMD 9
67#define TL_INIT_STATE 0
68
69static tSelfRecoveryStats g_self_recovery_stats;
70/* TxMB Functions */
71extern CDF_STATUS pmc_prepare_command(tpAniSirGlobal pMac, uint32_t sessionId,
72 eSmeCommandType cmdType, void *pvParam,
73 uint32_t size, tSmeCmd **ppCmd);
74extern void pmc_release_command(tpAniSirGlobal pMac, tSmeCmd *pCommand);
75extern void qos_release_command(tpAniSirGlobal pMac, tSmeCmd *pCommand);
76extern CDF_STATUS p2p_process_remain_on_channel_cmd(tpAniSirGlobal pMac,
77 tSmeCmd *p2pRemainonChn);
78extern CDF_STATUS sme_remain_on_chn_rsp(tpAniSirGlobal pMac, uint8_t *pMsg);
79extern CDF_STATUS sme_mgmt_frm_ind(tHalHandle hHal,
80 tpSirSmeMgmtFrameInd pSmeMgmtFrm);
81extern CDF_STATUS sme_remain_on_chn_ready(tHalHandle hHal, uint8_t *pMsg);
82extern CDF_STATUS sme_send_action_cnf(tHalHandle hHal, uint8_t *pMsg);
83
84static CDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac);
85static void sme_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
86 bool fStopping);
87
88eCsrPhyMode sme_get_phy_mode(tHalHandle hHal);
89
90CDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac, void *pMsgBuf);
91
92void sme_disconnect_connected_sessions(tpAniSirGlobal pMac);
93
94CDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
95 void *pMsgBuf);
96
97CDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg);
98
99#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
100bool csr_is_supported_channel(tpAniSirGlobal pMac, uint8_t channelId);
101#endif
102
103#ifdef WLAN_FEATURE_11W
104CDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
105 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm);
106#endif
107
108/* Message processor for events from DFS */
109CDF_STATUS dfs_msg_processor(tpAniSirGlobal pMac,
110 uint16_t msg_type, void *pMsgBuf);
111
112/* Channel Change Response Indication Handler */
113CDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
114 uint16_t msg_type, void *pMsgBuf);
115
116/* Internal SME APIs */
117CDF_STATUS sme_acquire_global_lock(tSmeStruct *psSme)
118{
119 CDF_STATUS status = CDF_STATUS_E_INVAL;
120
121 if (psSme) {
122 if (CDF_IS_STATUS_SUCCESS
123 (cdf_mutex_acquire(&psSme->lkSmeGlobalLock))) {
124 status = CDF_STATUS_SUCCESS;
125 }
126 }
127
128 return status;
129}
130
131CDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
132{
133 CDF_STATUS status = CDF_STATUS_E_INVAL;
134
135 if (psSme) {
136 if (CDF_IS_STATUS_SUCCESS
137 (cdf_mutex_release(&psSme->lkSmeGlobalLock))) {
138 status = CDF_STATUS_SUCCESS;
139 }
140 }
141
142 return status;
143}
144
145/**
146 * sme_process_set_hw_mode_resp() - Process set HW mode response
147 * @mac: Global MAC pointer
148 * @msg: HW mode response
149 *
150 * Processes the HW mode response and invokes the HDD callback
151 * to process further
152 */
153static CDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
154{
155 tListElem *entry = NULL;
156 tSmeCmd *command = NULL;
157 bool found;
158 hw_mode_cb callback = NULL;
159 struct sir_set_hw_mode_resp *param;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530160 enum cds_conn_update_reason reason;
161 tSmeCmd *saved_cmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530163 sms_log(mac, LOG1, FL("%s"), __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 param = (struct sir_set_hw_mode_resp *)msg;
165 if (!param) {
166 sms_log(mac, LOGE, FL("HW mode resp param is NULL"));
167 /* Not returning. Need to check if active command list
168 * needs to be freed
169 */
170 }
171
172 entry = csr_ll_peek_head(&mac->sme.smeCmdActiveList,
173 LL_ACCESS_LOCK);
174 if (!entry) {
175 sms_log(mac, LOGE, FL("No cmd found in active list"));
176 return CDF_STATUS_E_FAILURE;
177 }
178
179 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
180 if (!command) {
181 sms_log(mac, LOGE, FL("Base address is NULL"));
182 return CDF_STATUS_E_FAILURE;
183 }
184
185 if (e_sme_command_set_hw_mode != command->command) {
186 sms_log(mac, LOGE, FL("Command mismatch!"));
187 return CDF_STATUS_E_FAILURE;
188 }
189
190 callback = command->u.set_hw_mode_cmd.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530191 reason = command->u.set_hw_mode_cmd.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800192 if (callback) {
193 if (!param) {
194 sms_log(mac, LOGE,
195 FL("Callback failed since HW mode params is NULL"));
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530196 } else if (reason == CDS_UPDATE_REASON_HIDDEN_STA) {
197 /* In the case of hidden SSID, connection update
198 * (set hw mode) is done after the scan with reason
199 * code eCsrScanForSsid completes. The connect/failure
200 * needs to be handled after the response of set hw
201 * mode
202 */
203 saved_cmd = (tSmeCmd *)mac->sme.saved_scan_cmd;
204 if (!saved_cmd) {
205 sms_log(mac, LOGP,
206 FL("saved cmd is NULL, Check this"));
207 goto end;
208 }
209 if (param->status == SET_HW_MODE_STATUS_OK) {
210 sms_log(mac, LOG1,
211 FL("search for ssid success"));
212 csr_scan_handle_search_for_ssid(mac,
213 saved_cmd);
214 } else {
215 sms_log(mac, LOG1,
216 FL("search for ssid failure"));
217 csr_scan_handle_search_for_ssid_failure(mac,
218 saved_cmd);
219 }
220 if (saved_cmd->u.roamCmd.pRoamBssEntry)
221 cdf_mem_free(
222 saved_cmd->u.roamCmd.pRoamBssEntry);
223 if (saved_cmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList)
224 cdf_mem_free(saved_cmd->u.scanCmd.u.
225 scanRequest.SSIDs.SSIDList);
226 if (saved_cmd->u.scanCmd.pToRoamProfile)
227 cdf_mem_free(saved_cmd->u.scanCmd.
228 pToRoamProfile);
229 if (saved_cmd) {
230 cdf_mem_free(saved_cmd);
231 saved_cmd = NULL;
Chandrasekaran, Manishekar49d21a42015-11-19 09:57:58 +0530232 mac->sme.saved_scan_cmd = NULL;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530233 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 } else {
235 sms_log(mac, LOGE,
236 FL("Calling HDD callback for HW mode response"));
237 callback(param->status,
238 param->cfgd_hw_mode_index,
239 param->num_vdev_mac_entries,
240 param->vdev_mac_map);
241 }
242 } else {
243 sms_log(mac, LOGE, FL("Callback does not exist"));
244 }
245
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530246end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 found = csr_ll_remove_entry(&mac->sme.smeCmdActiveList, entry,
248 LL_ACCESS_LOCK);
249 if (found) {
250 /* Now put this command back on the avilable command list */
251 sme_release_command(mac, command);
252 }
253 sme_process_pending_queue(mac);
254 return CDF_STATUS_SUCCESS;
255}
256
257/**
258 * sme_process_hw_mode_trans_ind() - Process HW mode transition indication
259 * @mac: Global MAC pointer
260 * @msg: HW mode transition response
261 *
262 * Processes the HW mode transition indication and invoke the HDD callback
263 * to process further
264 */
265static CDF_STATUS sme_process_hw_mode_trans_ind(tpAniSirGlobal mac,
266 uint8_t *msg)
267{
268 hw_mode_transition_cb callback = NULL;
269 struct sir_hw_mode_trans_ind *param;
270
271 param = (struct sir_hw_mode_trans_ind *)msg;
272 if (!param) {
273 sms_log(mac, LOGE, FL("HW mode trans ind param is NULL"));
274 return CDF_STATUS_E_FAILURE;
275 }
276
277 callback = mac->sme.sme_hw_mode_trans_cb;
278 if (callback) {
279 sms_log(mac, LOGE, FL("Calling registered callback..."));
280 callback(param->old_hw_mode_index,
281 param->new_hw_mode_index,
282 param->num_vdev_mac_entries,
283 param->vdev_mac_map);
284 }
285
286 return CDF_STATUS_SUCCESS;
287}
288
289static CDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
290{
291 CDF_STATUS status;
292 tSmeCmd *pCmd;
293 uint32_t cmd_idx;
294 CDF_STATUS cdf_status;
295 cdf_mc_timer_t *cmdTimeoutTimer = NULL;
296
297 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
298
299 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdActiveList);
300 if (!CDF_IS_STATUS_SUCCESS(status))
301 goto end;
302
303 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdPendingList);
304 if (!CDF_IS_STATUS_SUCCESS(status))
305 goto end;
306
307 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeScanCmdActiveList);
308 if (!CDF_IS_STATUS_SUCCESS(status))
309 goto end;
310
311 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeScanCmdPendingList);
312 if (!CDF_IS_STATUS_SUCCESS(status))
313 goto end;
314
315 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdFreeList);
316 if (!CDF_IS_STATUS_SUCCESS(status))
317 goto end;
318
319 pCmd = cdf_mem_malloc(sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
320 if (NULL == pCmd)
321 status = CDF_STATUS_E_NOMEM;
322 else {
323 status = CDF_STATUS_SUCCESS;
324
325 cdf_mem_set(pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd, 0);
326 pMac->sme.pSmeCmdBufAddr = pCmd;
327
328 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++) {
329 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList,
330 &pCmd[cmd_idx].Link, LL_ACCESS_LOCK);
331 }
332 }
333
334 /* This timer is only to debug the active list command timeout */
335
336 cmdTimeoutTimer =
337 (cdf_mc_timer_t *) cdf_mem_malloc(sizeof(cdf_mc_timer_t));
338 if (cmdTimeoutTimer) {
339 pMac->sme.smeCmdActiveList.cmdTimeoutTimer = cmdTimeoutTimer;
340 cdf_status =
341 cdf_mc_timer_init(pMac->sme.smeCmdActiveList.
342 cmdTimeoutTimer, CDF_TIMER_TYPE_SW,
343 active_list_cmd_timeout_handle, (void *)pMac);
344
345 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
346 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
347 "Init Timer fail for active list command process time out");
348 cdf_mem_free(pMac->sme.smeCmdActiveList.
349 cmdTimeoutTimer);
350 pMac->sme.smeCmdActiveList.cmdTimeoutTimer = NULL;
351 } else {
352 pMac->sme.smeCmdActiveList.cmdTimeoutDuration =
353 CSR_ACTIVE_LIST_CMD_TIMEOUT_VALUE;
354 }
355 }
356
357end:
358 if (!CDF_IS_STATUS_SUCCESS(status))
359 sms_log(pMac, LOGE, "failed to initialize sme command list:%d\n",
360 status);
361
362 return status;
363}
364
365void sme_release_command(tpAniSirGlobal pMac, tSmeCmd *pCmd)
366{
367 pCmd->command = eSmeNoCommand;
368 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList, &pCmd->Link, LL_ACCESS_LOCK);
369}
370
371static void sme_release_cmd_list(tpAniSirGlobal pMac, tDblLinkList *pList)
372{
373 tListElem *pEntry;
374 tSmeCmd *pCommand;
375
376 while ((pEntry = csr_ll_remove_head(pList, LL_ACCESS_LOCK)) != NULL) {
377 /* TODO: base on command type to call release functions */
378 /* reinitialize different command types so they can be reused */
379 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
380 sme_abort_command(pMac, pCommand, true);
381 }
382}
383
384static void purge_sme_cmd_list(tpAniSirGlobal pMac)
385{
386 /* release any out standing commands back to free command list */
387 sme_release_cmd_list(pMac, &pMac->sme.smeCmdPendingList);
388 sme_release_cmd_list(pMac, &pMac->sme.smeCmdActiveList);
389 sme_release_cmd_list(pMac, &pMac->sme.smeScanCmdPendingList);
390 sme_release_cmd_list(pMac, &pMac->sme.smeScanCmdActiveList);
391}
392
393void purge_sme_session_cmd_list(tpAniSirGlobal pMac, uint32_t sessionId,
394 tDblLinkList *pList)
395{
396 /* release any out standing commands back to free command list */
397 tListElem *pEntry, *pNext;
398 tSmeCmd *pCommand;
399 tDblLinkList localList;
400
401 cdf_mem_zero(&localList, sizeof(tDblLinkList));
402 if (!CDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) {
403 sms_log(pMac, LOGE, FL(" failed to open list"));
404 return;
405 }
406
407 csr_ll_lock(pList);
408 pEntry = csr_ll_peek_head(pList, LL_ACCESS_NOLOCK);
409 while (pEntry != NULL) {
410 pNext = csr_ll_next(pList, pEntry, LL_ACCESS_NOLOCK);
411 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
412 if (pCommand->sessionId == sessionId) {
413 if (csr_ll_remove_entry(pList, pEntry, LL_ACCESS_NOLOCK)) {
414 csr_ll_insert_tail(&localList, pEntry,
415 LL_ACCESS_NOLOCK);
416 }
417 }
418 pEntry = pNext;
419 }
420 csr_ll_unlock(pList);
421
422 while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) {
423 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
424 sme_abort_command(pMac, pCommand, true);
425 }
426 csr_ll_close(&localList);
427}
428
429static CDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
430{
431 CDF_STATUS status = CDF_STATUS_SUCCESS;
432
433 purge_sme_cmd_list(pMac);
434 csr_ll_close(&pMac->sme.smeCmdPendingList);
435 csr_ll_close(&pMac->sme.smeCmdActiveList);
436 csr_ll_close(&pMac->sme.smeScanCmdPendingList);
437 csr_ll_close(&pMac->sme.smeScanCmdActiveList);
438 csr_ll_close(&pMac->sme.smeCmdFreeList);
439
440 /*destroy active list command time out timer */
441 cdf_mc_timer_destroy(pMac->sme.smeCmdActiveList.cmdTimeoutTimer);
442 cdf_mem_free(pMac->sme.smeCmdActiveList.cmdTimeoutTimer);
443 pMac->sme.smeCmdActiveList.cmdTimeoutTimer = NULL;
444
445 status = cdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
446 if (status != CDF_STATUS_SUCCESS) {
447 sms_log(pMac, LOGE,
448 FL("Failed to acquire the lock status = %d"), status);
449 goto done;
450 }
451
452 if (NULL != pMac->sme.pSmeCmdBufAddr) {
453 cdf_mem_free(pMac->sme.pSmeCmdBufAddr);
454 pMac->sme.pSmeCmdBufAddr = NULL;
455 }
456
457 status = cdf_mutex_release(&pMac->sme.lkSmeGlobalLock);
458 if (status != CDF_STATUS_SUCCESS) {
459 sms_log(pMac, LOGE,
460 FL("Failed to release the lock status = %d"), status);
461 }
462done:
463 return status;
464}
465
466void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
467{
468 switch (pCmd->command) {
469 case eSmeCommandScan:
470 sms_log(pMac, LOGE, " scan command reason is %d",
471 pCmd->u.scanCmd.reason);
472 break;
473
474 case eSmeCommandRoam:
475 sms_log(pMac, LOGE, " roam command reason is %d",
476 pCmd->u.roamCmd.roamReason);
477 break;
478
479 case eSmeCommandWmStatusChange:
480 sms_log(pMac, LOGE, " WMStatusChange command type is %d",
481 pCmd->u.wmStatusChangeCmd.Type);
482 break;
483
484 case eSmeCommandSetKey:
485 sms_log(pMac, LOGE, " setKey command auth(%d) enc(%d)",
486 pCmd->u.setKeyCmd.authType, pCmd->u.setKeyCmd.encType);
487 break;
488
489 default:
490 sms_log(pMac, LOGE, " default: Unhandled command %d",
491 pCmd->command);
492 break;
493 }
494}
495
496tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
497{
498 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
499 tListElem *pEntry;
500 static int sme_command_queue_full;
501
502 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
503
504 /* If we can get another MS Msg buffer, then we are ok. Just link */
505 /* the entry onto the linked list. (We are using the linked list */
506 /* to keep track of tfhe message buffers). */
507 if (pEntry) {
508 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
509 /* reset when free list is available */
510 sme_command_queue_full = 0;
511 } else {
512 int idx = 1;
513
514 /* Cannot change pRetCmd here since it needs to return later. */
515 pEntry =
516 csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
517 if (pEntry) {
518 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
519 }
520 sms_log(pMac, LOGE,
521 "Out of command buffer.... command (0x%X) stuck",
522 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
523 if (pTempCmd) {
524 if (eSmeCsrCommandMask & pTempCmd->command) {
525 /* CSR command is stuck. See what the reason code is for that command */
526 dump_csr_command_info(pMac, pTempCmd);
527 }
528 } /* if(pTempCmd) */
529
530 /* dump what is in the pending queue */
531 csr_ll_lock(&pMac->sme.smeCmdPendingList);
532 pEntry =
533 csr_ll_peek_head(&pMac->sme.smeCmdPendingList,
534 LL_ACCESS_NOLOCK);
535 while (pEntry && !sme_command_queue_full) {
536 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
537 /* Print only 1st five commands from pending queue. */
538 if (idx <= 5)
539 sms_log(pMac, LOGE,
540 "Out of command buffer.... SME pending command #%d (0x%X)",
541 idx, pTempCmd->command);
542 idx++;
543 if (eSmeCsrCommandMask & pTempCmd->command) {
544 /* CSR command is stuck. See what the reason code is for that command */
545 dump_csr_command_info(pMac, pTempCmd);
546 }
547 pEntry =
548 csr_ll_next(&pMac->sme.smeCmdPendingList, pEntry,
549 LL_ACCESS_NOLOCK);
550 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 csr_ll_unlock(&pMac->sme.smeCmdPendingList);
552
DARAM SUDHAf6c3f972015-05-26 19:26:16 +0530553 idx = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800554 /* There may be some more command in CSR's own pending queue */
555 csr_ll_lock(&pMac->roam.roamCmdPendingList);
556 pEntry =
557 csr_ll_peek_head(&pMac->roam.roamCmdPendingList,
558 LL_ACCESS_NOLOCK);
DARAM SUDHAf6c3f972015-05-26 19:26:16 +0530559 while (pEntry && !sme_command_queue_full) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
DARAM SUDHAf6c3f972015-05-26 19:26:16 +0530561 /* Print only 1st five commands from CSR pending queue */
562 if (idx <= 5)
563 sms_log(pMac, LOGE,
564 "Out of command buffer.... "
565 "CSR roamCmdPendingList command #%d (0x%X)",
566 idx, pTempCmd->command);
567 idx++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 dump_csr_command_info(pMac, pTempCmd);
569 pEntry =
570 csr_ll_next(&pMac->roam.roamCmdPendingList, pEntry,
571 LL_ACCESS_NOLOCK);
572 }
DARAM SUDHAf6c3f972015-05-26 19:26:16 +0530573
574 /* Increment static variable so that it prints
575 * pending command only once
576 */
577 sme_command_queue_full++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 csr_ll_unlock(&pMac->roam.roamCmdPendingList);
DARAM SUDHAf6c3f972015-05-26 19:26:16 +0530579
580 /* panic with out-of-command */
581 CDF_BUG(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 }
583
584 /* memset to zero */
585 if (pRetCmd) {
586 cdf_mem_set((uint8_t *)&pRetCmd->command,
587 sizeof(pRetCmd->command), 0);
588 cdf_mem_set((uint8_t *)&pRetCmd->sessionId,
589 sizeof(pRetCmd->sessionId), 0);
590 cdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
591 }
592
593 return pRetCmd;
594}
595
596void sme_push_command(tpAniSirGlobal pMac, tSmeCmd *pCmd, bool fHighPriority)
597{
598 if (!SME_IS_START(pMac)) {
599 sms_log(pMac, LOGE, FL("Sme in stop state"));
600 CDF_ASSERT(0);
601 return;
602 }
603
604 if (fHighPriority) {
605 csr_ll_insert_head(&pMac->sme.smeCmdPendingList, &pCmd->Link,
606 LL_ACCESS_LOCK);
607 } else {
608 csr_ll_insert_tail(&pMac->sme.smeCmdPendingList, &pCmd->Link,
609 LL_ACCESS_LOCK);
610 }
611
612 /* process the command queue... */
613 sme_process_pending_queue(pMac);
614
615 return;
616}
617
618/* For commands that need to do extra cleanup. */
619static void sme_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
620 bool fStopping)
621{
622 if (eSmePmcCommandMask & pCommand->command) {
623 sms_log(pMac, LOG1,
624 "No need to process PMC commands");
625 return;
626 }
627 if (eSmeCsrCommandMask & pCommand->command) {
628 csr_abort_command(pMac, pCommand, fStopping);
629 return;
630 }
631 switch (pCommand->command) {
632 case eSmeCommandRemainOnChannel:
633 if (NULL != pCommand->u.remainChlCmd.callback) {
634 remainOnChanCallback callback =
635 pCommand->u.remainChlCmd.callback;
636 /* process the msg */
637 if (callback) {
638 callback(pMac, pCommand->u.remainChlCmd.
639 callbackCtx, eCSR_SCAN_ABORT,
640 pCommand->u.remainChlCmd.scan_id);
641 }
642 }
643 sme_release_command(pMac, pCommand);
644 break;
645 default:
646 sme_release_command(pMac, pCommand);
647 break;
648 }
649
650}
651
652tListElem *csr_get_cmd_to_process(tpAniSirGlobal pMac, tDblLinkList *pList,
653 uint8_t sessionId, bool fInterlocked)
654{
655 tListElem *pCurEntry = NULL;
656 tSmeCmd *pCommand;
657
658 /* Go through the list and return the command whose session id is not
659 * matching with the current ongoing scan cmd sessionId */
660 pCurEntry = csr_ll_peek_head(pList, LL_ACCESS_LOCK);
661 while (pCurEntry) {
662 pCommand = GET_BASE_ADDR(pCurEntry, tSmeCmd, Link);
663 if (pCommand->sessionId != sessionId) {
664 sms_log(pMac, LOG1,
665 "selected the command with different sessionId");
666 return pCurEntry;
667 }
668
669 pCurEntry = csr_ll_next(pList, pCurEntry, fInterlocked);
670 }
671
672 sms_log(pMac, LOG1, "No command pending with different sessionId");
673 return NULL;
674}
675
676bool sme_process_scan_queue(tpAniSirGlobal pMac)
677{
678 tListElem *pEntry;
679 tSmeCmd *pCommand;
680 tListElem *pSmeEntry = NULL;
681 tSmeCmd *pSmeCommand = NULL;
682 bool status = true;
683
684 if ((!csr_ll_is_list_empty(&pMac->sme.smeCmdActiveList,
685 LL_ACCESS_LOCK))) {
686 pSmeEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList,
687 LL_ACCESS_LOCK);
688 if (pSmeEntry)
689 pSmeCommand = GET_BASE_ADDR(pSmeEntry, tSmeCmd, Link);
690 }
691 csr_ll_lock(&pMac->sme.smeScanCmdActiveList);
692 if (csr_ll_is_list_empty(&pMac->sme.smeScanCmdPendingList,
693 LL_ACCESS_LOCK))
694 goto end;
695 pEntry = csr_ll_peek_head(&pMac->sme.smeScanCmdPendingList,
696 LL_ACCESS_LOCK);
697 if (!pEntry)
698 goto end;
699
700 sms_log(pMac, LOGE,
701 FL("scan_count in active scanlist %d "),
702 pMac->sme.smeScanCmdActiveList.Count);
703
704 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
705 if (pSmeCommand != NULL) {
706 /*
707 * if scan is running on one interface and SME receives
708 * the next command on the same interface then
709 * dont the allow the command to be queued to
710 * smeCmdPendingList. If next scan is allowed on
711 * the same interface the CSR state machine will
712 * get screwed up.
713 */
714 if (pSmeCommand->sessionId == pCommand->sessionId) {
715 status = false;
716 goto end;
717 }
718 }
719 /*
720 * We cannot execute any command in wait-for-key state until setKey is
721 * through.
722 */
723 if (CSR_IS_WAIT_FOR_KEY(pMac, pCommand->sessionId)) {
724 if (!CSR_IS_SET_KEY_COMMAND(pCommand)) {
725 sms_log(pMac, LOGE,
726 FL("Can't process cmd(%d), waiting for key"),
727 pCommand->command);
728 status = false;
729 goto end;
730 }
731 }
732 if (csr_ll_remove_entry(&pMac->sme.smeScanCmdPendingList, pEntry,
733 LL_ACCESS_LOCK)) {
734 csr_ll_insert_head(&pMac->sme.smeScanCmdActiveList,
735 &pCommand->Link, LL_ACCESS_NOLOCK);
736 switch (pCommand->command) {
737 case eSmeCommandScan:
738 sms_log(pMac, LOG1, FL("Processing scan offload cmd."));
739 cdf_mc_timer_start(&pCommand->u.scanCmd.csr_scan_timer,
740 CSR_ACTIVE_SCAN_LIST_CMD_TIMEOUT);
741 csr_process_scan_command(pMac, pCommand);
742 break;
743 case eSmeCommandRemainOnChannel:
744 sms_log(pMac, LOG1,
745 FL("Processing remain on channel offload cmd"));
746 p2p_process_remain_on_channel_cmd(pMac, pCommand);
747 break;
748 default:
749 sms_log(pMac, LOGE,
750 FL("Wrong cmd enqueued to ScanCmdPendingList"));
751 pEntry = csr_ll_remove_head(
752 &pMac->sme.smeScanCmdActiveList,
753 LL_ACCESS_NOLOCK);
754 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
755 sme_release_command(pMac, pCommand);
756 break;
757 }
758 }
759end:
760 csr_ll_unlock(&pMac->sme.smeScanCmdActiveList);
761 return status;
762}
763
764/**
765 * sme_process_command() - processes SME commnd
766 * @mac_ctx: mac global context
767 *
768 * This function is called by sme_process_pending_queue() in a while loop
769 *
770 * Return: true indicates that caller function can proceed to next cmd
771 * false otherwise.
772 */
773bool sme_process_command(tpAniSirGlobal pMac)
774{
775 bool fContinue = false;
776 CDF_STATUS status = CDF_STATUS_SUCCESS;
777 tListElem *pEntry;
778 tSmeCmd *pCommand;
779 tListElem *pSmeEntry;
780 tSmeCmd *pSmeCommand;
781
782 /*
783 * if the ActiveList is empty, then nothing is active so we can process
784 * a pending command...
785 * alwasy lock active list before locking pending list
786 */
787 csr_ll_lock(&pMac->sme.smeCmdActiveList);
788 if (!csr_ll_is_list_empty(&pMac->sme.smeCmdActiveList,
789 LL_ACCESS_NOLOCK)) {
790 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
791 goto process_scan_q;
792 }
793
794 if (csr_ll_is_list_empty(&pMac->sme.smeCmdPendingList,
795 LL_ACCESS_LOCK)) {
796 /* No command waiting */
797 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
798 goto process_scan_q;
799 }
800
801 /*
802 * If scan command is pending in the smeScanCmdActive list then pick the
803 * command from smeCmdPendingList which is not matching with the scan
804 * command session id. At any point of time only one command will be
805 * allowed on a single session.
806 */
807 if (!csr_ll_is_list_empty(
808 &pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK)) {
809 pSmeEntry = csr_ll_peek_head(&pMac->sme.smeScanCmdActiveList,
810 LL_ACCESS_LOCK);
811 if (pSmeEntry) {
812 pSmeCommand = GET_BASE_ADDR(pSmeEntry, tSmeCmd, Link);
813 pEntry = csr_get_cmd_to_process(pMac,
814 &pMac->sme.smeCmdPendingList,
815 pSmeCommand->sessionId,
816 LL_ACCESS_LOCK);
817 goto sme_process_cmd;
818 }
819 }
820
821 /* Peek the command */
822 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
823sme_process_cmd:
824 if (!pEntry) {
825 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
826 goto process_scan_q;
827 }
828 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
829 /*
830 * Allow only disconnect command in wait-for-key state until setKey is
831 * through.
832 */
833 if (CSR_IS_WAIT_FOR_KEY(pMac, pCommand->sessionId)
834 && !CSR_IS_DISCONNECT_COMMAND(pCommand)
835 && !CSR_IS_SET_KEY_COMMAND(pCommand)) {
836 if (CSR_IS_CLOSE_SESSION_COMMAND(pCommand)) {
837 tSmeCmd *sme_cmd = NULL;
838
839 sms_log(pMac, LOGE,
840 FL("SessionId %d: close session command issued while waiting for key, issue disconnect first"),
841 pCommand->sessionId);
842 status = csr_prepare_disconnect_command(pMac,
843 pCommand->sessionId, &sme_cmd);
844 if (status == CDF_STATUS_SUCCESS && sme_cmd) {
845 csr_ll_lock(&pMac->sme.smeCmdPendingList);
846 csr_ll_insert_head(&pMac->sme.smeCmdPendingList,
847 &sme_cmd->Link, LL_ACCESS_NOLOCK);
848 pEntry = csr_ll_peek_head(
849 &pMac->sme.smeCmdPendingList,
850 LL_ACCESS_NOLOCK);
851 csr_ll_unlock(&pMac->sme.smeCmdPendingList);
852 goto sme_process_cmd;
853 }
854 }
855
856 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
857 sms_log(pMac, LOGE,
858 FL("SessionId %d: Can't process cmd(%d), waiting for key"),
859 pCommand->sessionId, pCommand->command);
860 fContinue = false;
861 goto process_scan_q;
862 }
863
864 if (!csr_ll_remove_entry(&pMac->sme.smeCmdPendingList, pEntry,
865 LL_ACCESS_LOCK)) {
866 /* This is odd. Some one else pull off the command. */
867 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
868 goto process_scan_q;
869 }
870 /* we can reuse the pCommand. Insert the command onto the ActiveList */
871 csr_ll_insert_head(&pMac->sme.smeCmdActiveList, &pCommand->Link,
872 LL_ACCESS_NOLOCK);
873 /* .... and process the command. */
874 MTRACE(cdf_trace(CDF_MODULE_ID_SME, TRACE_CODE_SME_COMMAND,
875 pCommand->sessionId, pCommand->command));
876
877 switch (pCommand->command) {
878 case eSmeCommandScan:
879 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
880 status = csr_process_scan_command(pMac, pCommand);
881 break;
882 case eSmeCommandRoam:
883 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
884 status = csr_roam_process_command(pMac, pCommand);
885 if (!CDF_IS_STATUS_SUCCESS(status)
886 && csr_ll_remove_entry(&pMac->sme.smeCmdActiveList,
887 &pCommand->Link, LL_ACCESS_LOCK))
888 csr_release_command_roam(pMac, pCommand);
889 break;
890 case eSmeCommandWmStatusChange:
891 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
892 csr_roam_process_wm_status_change_command(pMac, pCommand);
893 break;
894 case eSmeCommandSetKey:
895 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
896 status = csr_roam_process_set_key_command(pMac, pCommand);
897 if (!CDF_IS_STATUS_SUCCESS(status)
898 && csr_ll_remove_entry(&pMac->sme.smeCmdActiveList,
899 &pCommand->Link, LL_ACCESS_LOCK)) {
900 csr_release_command_set_key(pMac, pCommand);
901 }
902 break;
903 case eSmeCommandAddStaSession:
904 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
905 csr_process_add_sta_session_command(pMac, pCommand);
906 break;
907 case eSmeCommandDelStaSession:
908 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
909 csr_process_del_sta_session_command(pMac, pCommand);
910 break;
911#ifdef FEATURE_OEM_DATA_SUPPORT
912 case eSmeCommandOemDataReq:
913 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
914 oem_data_process_oem_data_req_command(pMac, pCommand);
915 break;
916#endif
917 case eSmeCommandRemainOnChannel:
918 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
919 p2p_process_remain_on_channel_cmd(pMac, pCommand);
920 break;
921 /*
922 * Treat standby differently here because caller may not be able
923 * to handle the failure so we do our best here
924 */
925 case eSmeCommandEnterStandby:
926 break;
927 case eSmeCommandAddTs:
928 case eSmeCommandDelTs:
929 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
930#ifndef WLAN_MDM_CODE_REDUCTION_OPT
931 fContinue = qos_process_command(pMac, pCommand);
932 if (fContinue && csr_ll_remove_entry(
933 &pMac->sme.smeCmdActiveList,
934 &pCommand->Link, LL_ACCESS_NOLOCK)) {
935 /* The command failed, remove it */
936 qos_release_command(pMac, pCommand);
937 }
938#endif
939 break;
940#ifdef FEATURE_WLAN_TDLS
941 case eSmeCommandTdlsSendMgmt:
942 case eSmeCommandTdlsAddPeer:
943 case eSmeCommandTdlsDelPeer:
944 case eSmeCommandTdlsLinkEstablish:
945 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
946 FL("sending TDLS Command 0x%x to PE"),
947 pCommand->command);
948 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
949 status = csr_tdls_process_cmd(pMac, pCommand);
950 break;
951#endif
952 case e_sme_command_set_hw_mode:
953 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
954 csr_process_set_hw_mode(pMac, pCommand);
955 break;
956 case e_sme_command_nss_update:
957 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
958 csr_process_nss_update_req(pMac, pCommand);
959 break;
960 case e_sme_command_set_dual_mac_config:
961 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
962 csr_process_set_dual_mac_config(pMac, pCommand);
963 break;
964 default:
965 /* something is wrong */
966 /* remove it from the active list */
967 sms_log(pMac, LOGE, FL("unknown command %d"),
968 pCommand->command);
969 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdActiveList,
970 LL_ACCESS_NOLOCK);
971 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
972 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
973 sme_release_command(pMac, pCommand);
974 status = CDF_STATUS_E_FAILURE;
975 break;
976 }
977 if (!CDF_IS_STATUS_SUCCESS(status))
978 fContinue = true;
979process_scan_q:
980 if (!(sme_process_scan_queue(pMac)))
981 fContinue = false;
982 return fContinue;
983}
984
985void sme_process_pending_queue(tpAniSirGlobal pMac)
986{
987 while (sme_process_command(pMac))
988 ;
989}
990
991bool sme_command_pending(tpAniSirGlobal pMac)
992{
993 return !csr_ll_is_list_empty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK)
994 || !csr_ll_is_list_empty(&pMac->sme.smeCmdPendingList,
995 LL_ACCESS_NOLOCK);
996}
997
998/* Global APIs */
999
1000/**
1001 * sme_open() - Initialze all SME modules and put them at idle state
1002 * @hHal: The handle returned by mac_open
1003 *
1004 * The function initializes each module inside SME, PMC, CSR, etc. Upon
1005 * successfully return, all modules are at idle state ready to start.
1006 * smeOpen must be called before any other SME APIs can be involved.
1007 * smeOpen must be called after mac_open.
1008 *
1009 * Return: CDF_STATUS_SUCCESS - SME is successfully initialized.
1010 * Other status means SME is failed to be initialized
1011 */
1012CDF_STATUS sme_open(tHalHandle hHal)
1013{
1014 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1015 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1016#ifndef WLAN_FEATURE_MBSSID
1017 void *p_cds_gctx = cds_get_global_context();
1018#endif
1019
1020 pMac->sme.state = SME_STATE_STOP;
1021 pMac->sme.currDeviceMode = CDF_STA_MODE;
1022 if (!CDF_IS_STATUS_SUCCESS(cdf_mutex_init(
1023 &pMac->sme.lkSmeGlobalLock))) {
1024 sms_log(pMac, LOGE, FL("sme_open failed init lock"));
1025 return CDF_STATUS_E_FAILURE;
1026 }
1027 status = csr_open(pMac);
1028 if (!CDF_IS_STATUS_SUCCESS(status)) {
1029 sms_log(pMac, LOGE, FL("csr_open failed, status=%d"), status);
1030 return status;
1031 }
1032
1033 status = sme_ps_open(hHal);
1034 if (!CDF_IS_STATUS_SUCCESS(status)) {
1035 sms_log(pMac, LOGE,
1036 FL("sme_ps_open failed during initialization with status=%d"),
1037 status);
1038 return status;
1039 }
1040#ifdef FEATURE_WLAN_TDLS
1041 pMac->is_tdls_power_save_prohibited = 0;
1042#endif
1043
1044#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1045 status = sme_qos_open(pMac);
1046 if (!CDF_IS_STATUS_SUCCESS(status)) {
1047 sms_log(pMac, LOGE, FL("Qos open, status=%d"), status);
1048 return status;
1049 }
1050#endif
1051#ifdef FEATURE_OEM_DATA_SUPPORT
1052 status = oem_data_oem_data_req_open(pMac);
1053 if (!CDF_IS_STATUS_SUCCESS(status)) {
1054 sms_log(pMac, LOGE,
1055 FL("oem_data_oem_data_req_open, status=%d"),
1056 status);
1057 return status;
1058 }
1059#endif
1060 status = init_sme_cmd_list(pMac);
1061 if (!CDF_IS_STATUS_SUCCESS(status))
1062 return status;
1063#ifndef WLAN_FEATURE_MBSSID
1064 if (NULL == p_cds_gctx) {
1065 sms_log(pMac, LOGE, FL("p_cds_gctx is NULL"));
1066 return CDF_STATUS_E_FAILURE;
1067 }
1068 status = wlansap_open(p_cds_gctx);
1069 if (!CDF_IS_STATUS_SUCCESS(status)) {
1070 sms_log(pMac, LOGE, FL("wlansap_open failed, status=%d"),
1071 status);
1072 return status;
1073 }
1074#endif
1075
1076#if defined WLAN_FEATURE_VOWIFI
1077 status = rrm_open(pMac);
1078 if (!CDF_IS_STATUS_SUCCESS(status)) {
1079 sms_log(pMac, LOGE, FL("rrm_open failed, status=%d"), status);
1080 return status;
1081 }
1082#endif
1083 sme_p2p_open(pMac);
1084 sme_trace_init(pMac);
1085 return status;
1086}
1087
1088/*
1089 * sme_init_chan_list, triggers channel setup based on country code.
1090 */
1091CDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
1092 COUNTRY_CODE_SOURCE cc_src)
1093{
1094 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
1095
1096 if ((cc_src == COUNTRY_CODE_SET_BY_USER) &&
1097 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
1098 pmac->roam.configParam.Is11dSupportEnabled = false;
1099 }
1100
1101 return csr_init_chan_list(pmac, alpha2);
1102}
1103
1104/*--------------------------------------------------------------------------
1105
1106 \brief sme_set11dinfo() - Set the 11d information about valid channels
1107 and there power using information from nvRAM
1108 This function is called only for AP.
1109
1110 This is a synchronous call
1111
1112 \param hHal - The handle returned by mac_open.
1113 \Param pSmeConfigParams - a pointer to a caller allocated object of
1114 typedef struct _smeConfigParams.
1115
1116 \return CDF_STATUS_SUCCESS - SME update the config parameters successfully.
1117
1118 Other status means SME is failed to update the config parameters.
1119 \sa
1120 --------------------------------------------------------------------------*/
1121
1122CDF_STATUS sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1123{
1124 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1125 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1126
1127 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
1128 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
1129 if (NULL == pSmeConfigParams) {
1130 sms_log(pMac, LOGE,
1131 "Empty config param structure for SME, nothing to update");
1132 return status;
1133 }
1134
1135 status = csr_set_channels(hHal, &pSmeConfigParams->csrConfig);
1136 if (!CDF_IS_STATUS_SUCCESS(status)) {
1137 sms_log(pMac, LOGE,
1138 "csr_change_default_config_param failed with status=%d",
1139 status);
1140 }
1141 return status;
1142}
1143
1144/**
1145 * sme_set_scan_disable() - Dynamically enable/disable scan
1146 * @h_hal: Handle to HAL
1147 *
1148 * This command gives the user an option to dynamically
1149 * enable or disable scans.
1150 *
1151 * Return: None
1152 */
1153void sme_set_scan_disable(tHalHandle h_hal, int value)
1154{
1155 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
1156 mac_ctx->lim.scan_disabled = value;
1157 sms_log(mac_ctx, LOG1, FL("value=%d"), value);
1158}
1159/*--------------------------------------------------------------------------
1160
1161 \brief sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
1162
1163 This is a synchronous call
1164
1165 \param hHal - The handle returned by HostapdAdapter.
1166 \Param v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
1167
1168 \return CDF_STATUS_SUCCESS - SME successfully completed the request.
1169
1170 Other status means, failed to get the current regulatory domain.
1171 \sa
1172 --------------------------------------------------------------------------*/
1173
1174CDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t *domainIdSoftAp)
1175{
1176 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1177 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1178
1179 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
1180 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
1181 NO_SESSION, 0));
1182 if (NULL == domainIdSoftAp) {
1183 sms_log(pMac, LOGE, "Uninitialized domain Id");
1184 return status;
1185 }
1186
1187 *domainIdSoftAp = pMac->scan.domainIdCurrent;
1188 status = CDF_STATUS_SUCCESS;
1189
1190 return status;
1191}
1192
1193CDF_STATUS sme_set_reg_info(tHalHandle hHal, uint8_t *apCntryCode)
1194{
1195 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1196 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1197
1198 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
1199 TRACE_CODE_SME_RX_HDD_MSG_SET_REGINFO, NO_SESSION, 0));
1200 if (NULL == apCntryCode) {
1201 sms_log(pMac, LOGE, "Empty Country Code, nothing to update");
1202 return status;
1203 }
1204
1205 status = csr_set_reg_info(hHal, apCntryCode);
1206 if (!CDF_IS_STATUS_SUCCESS(status)) {
1207 sms_log(pMac, LOGE, "csr_set_reg_info failed with status=%d",
1208 status);
1209 }
1210 return status;
1211}
1212
1213#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1214CDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1215{
1216 CDF_STATUS status;
1217 bool ret = false;
1218 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1219 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST] = { 0 };
1220 uint8_t count, valid_count = 0;
1221 cds_msg_t msg;
1222 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, pPlmReq->sessionId);
1223
1224 status = sme_acquire_global_lock(&pMac->sme);
1225 if (!CDF_IS_STATUS_SUCCESS(status))
1226 return status;
1227
1228 if (!pSession) {
1229 sms_log(pMac, LOGE, FL("session %d not found"),
1230 pPlmReq->sessionId);
1231 sme_release_global_lock(&pMac->sme);
1232 return CDF_STATUS_E_FAILURE;
1233 }
1234
1235 if (!pSession->sessionActive) {
1236 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
1237 FL("Invalid Sessionid"));
1238 sme_release_global_lock(&pMac->sme);
1239 return CDF_STATUS_E_FAILURE;
1240 }
1241
1242 if (!pPlmReq->enable)
1243 goto send_plm_start;
1244 /* validating channel numbers */
1245 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1246 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1247 if (ret && pPlmReq->plmChList[count] > 14) {
1248 if (CHANNEL_STATE_DFS == cds_get_channel_state(
1249 pPlmReq->plmChList[count])) {
1250 /* DFS channel is provided, no PLM bursts can be
1251 * transmitted. Ignoring these channels.
1252 */
1253 CDF_TRACE(CDF_MODULE_ID_SME,
1254 CDF_TRACE_LEVEL_INFO,
1255 FL("DFS channel %d ignored for PLM"),
1256 pPlmReq->plmChList[count]);
1257 continue;
1258 }
1259 } else if (!ret) {
1260 /* Not supported, ignore the channel */
1261 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
1262 FL("Unsupported channel %d ignored for PLM"),
1263 pPlmReq->plmChList[count]);
1264 continue;
1265 }
1266 ch_list[valid_count] = pPlmReq->plmChList[count];
1267 valid_count++;
1268 } /* End of for () */
1269
1270 /* Copying back the valid channel list to plm struct */
1271 cdf_mem_set((void *)pPlmReq->plmChList,
1272 pPlmReq->plmNumCh, 0);
1273 if (valid_count)
1274 cdf_mem_copy(pPlmReq->plmChList, ch_list,
1275 valid_count);
1276 /* All are invalid channels, FW need to send the PLM
1277 * report with "incapable" bit set.
1278 */
1279 pPlmReq->plmNumCh = valid_count;
1280
1281send_plm_start:
1282 /* PLM START */
1283 msg.type = WMA_SET_PLM_REQ;
1284 msg.reserved = 0;
1285 msg.bodyptr = pPlmReq;
1286
1287 if (!CDF_IS_STATUS_SUCCESS(cds_mq_post_message(CDF_MODULE_ID_WMA,
1288 &msg))) {
1289 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
1290 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1291 sme_release_global_lock(&pMac->sme);
1292 return CDF_STATUS_E_FAILURE;
1293 }
1294
1295 sme_release_global_lock(&pMac->sme);
1296 return status;
1297}
1298#endif
1299
1300/*--------------------------------------------------------------------------
1301
1302 \brief sme_update_config() - Change configurations for all SME moduels
1303
1304 The function updates some configuration for modules in SME, CSR, etc
1305 during SMEs close open sequence.
1306
1307 Modules inside SME apply the new configuration at the next transaction.
1308
1309 This is a synchronous call
1310
1311 \param hHal - The handle returned by mac_open.
1312 \Param pSmeConfigParams - a pointer to a caller allocated object of
1313 typedef struct _smeConfigParams.
1314
1315 \return CDF_STATUS_SUCCESS - SME update the config parameters successfully.
1316
1317 Other status means SME is failed to update the config parameters.
1318 \sa
1319
1320 --------------------------------------------------------------------------*/
1321CDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1322{
1323 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1324 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1325
1326 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
1327 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
1328 0));
1329 if (NULL == pSmeConfigParams) {
1330 sms_log(pMac, LOGE,
1331 "Empty config param structure for SME, nothing to update");
1332 return status;
1333 }
1334
1335 status =
1336 csr_change_default_config_param(pMac, &pSmeConfigParams->csrConfig);
1337
1338 if (!CDF_IS_STATUS_SUCCESS(status)) {
1339 sms_log(pMac, LOGE,
1340 "csr_change_default_config_param failed with status=%d",
1341 status);
1342 }
1343#if defined WLAN_FEATURE_VOWIFI
1344 status =
1345 rrm_change_default_config_param(hHal, &pSmeConfigParams->rrmConfig);
1346
1347 if (!CDF_IS_STATUS_SUCCESS(status)) {
1348 sms_log(pMac, LOGE,
1349 "rrm_change_default_config_param failed with status=%d",
1350 status);
1351 }
1352#endif
1353 /* For SOC, CFG is set before start */
1354 /* We don't want to apply global CFG in connect state because that may cause some side affect */
1355 if (csr_is_all_session_disconnected(pMac)) {
1356 csr_set_global_cfgs(pMac);
1357 }
1358
1359 /*
1360 * If scan offload is enabled then lim has allow the sending of
1361 * scan request to firmware even in powersave mode. The firmware has
1362 * to take care of exiting from power save mode
1363 */
1364 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
1365
1366 if (CDF_STATUS_SUCCESS != status) {
1367 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
1368 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
1369 }
1370 pMac->isCoalesingInIBSSAllowed =
1371 pSmeConfigParams->csrConfig.isCoalesingInIBSSAllowed;
1372
1373 /* update p2p offload status */
1374 pMac->pnoOffload = pSmeConfigParams->pnoOffload;
1375
1376 pMac->fEnableDebugLog = pSmeConfigParams->fEnableDebugLog;
1377
1378 /* update interface configuration */
1379 pMac->sme.max_intf_count = pSmeConfigParams->max_intf_count;
1380
1381 pMac->enable5gEBT = pSmeConfigParams->enable5gEBT;
1382 pMac->sme.enableSelfRecovery = pSmeConfigParams->enableSelfRecovery;
1383
1384 pMac->f_sta_miracast_mcc_rest_time_val =
1385 pSmeConfigParams->f_sta_miracast_mcc_rest_time_val;
1386
1387#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
1388 pMac->sap.sap_channel_avoidance =
1389 pSmeConfigParams->sap_channel_avoidance;
1390#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
1391
1392 pMac->f_prefer_non_dfs_on_radar =
1393 pSmeConfigParams->f_prefer_non_dfs_on_radar;
1394
1395 pMac->sme.ps_global_info.ps_enabled =
1396 pSmeConfigParams->is_ps_enabled;
1397
1398 pMac->policy_manager_enabled = pSmeConfigParams->policy_manager_enabled;
1399 pMac->fine_time_meas_cap = pSmeConfigParams->fine_time_meas_cap;
1400 pMac->dual_mac_feature_disable =
1401 pSmeConfigParams->dual_mac_feature_disable;
Varun Reddy Yeturub43fda12015-09-10 18:16:21 -07001402 sme_update_roam_pno_channel_prediction_config(pMac, pSmeConfigParams,
1403 SME_CONFIG_TO_ROAM_CONFIG);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07001404 pMac->roam.configParam.early_stop_scan_enable =
1405 pSmeConfigParams->early_stop_scan_enable;
1406 pMac->roam.configParam.early_stop_scan_min_threshold =
1407 pSmeConfigParams->early_stop_scan_min_threshold;
1408 pMac->roam.configParam.early_stop_scan_max_threshold =
1409 pSmeConfigParams->early_stop_scan_max_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410
1411 return status;
1412}
1413
1414/**
1415 * sme_update_roam_params() - Store/Update the roaming params
1416 * @hal: Handle for Hal layer
1417 * @session_id: SME Session ID
1418 * @roam_params_src: The source buffer to copy
1419 * @update_param: Type of parameter to be updated
1420 *
1421 * Return: Return the status of the updation.
1422 */
1423CDF_STATUS sme_update_roam_params(tHalHandle hal,
1424 uint8_t session_id, struct roam_ext_params roam_params_src,
1425 int update_param)
1426{
1427 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
1428 struct roam_ext_params *roam_params_dst;
1429 uint8_t i;
1430
1431 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
1432 switch (update_param) {
1433 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
1434 roam_params_dst->raise_rssi_thresh_5g =
1435 roam_params_src.raise_rssi_thresh_5g;
1436 roam_params_dst->drop_rssi_thresh_5g =
1437 roam_params_src.drop_rssi_thresh_5g;
1438 roam_params_dst->raise_factor_5g =
1439 roam_params_src.raise_factor_5g;
1440 roam_params_dst->drop_factor_5g =
1441 roam_params_src.drop_factor_5g;
1442 roam_params_dst->max_raise_rssi_5g =
1443 roam_params_src.max_raise_rssi_5g;
1444 roam_params_dst->max_drop_rssi_5g =
1445 roam_params_src.max_drop_rssi_5g;
1446 roam_params_dst->alert_rssi_threshold =
1447 roam_params_src.alert_rssi_threshold;
1448 roam_params_dst->is_5g_pref_enabled = true;
1449 break;
1450 case REASON_ROAM_SET_SSID_ALLOWED:
1451 cdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
1452 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1453 roam_params_dst->num_ssid_allowed_list =
1454 roam_params_src.num_ssid_allowed_list;
1455 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1456 roam_params_dst->ssid_allowed_list[i].length =
1457 roam_params_src.ssid_allowed_list[i].length;
1458 cdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
1459 roam_params_src.ssid_allowed_list[i].ssId,
1460 roam_params_dst->ssid_allowed_list[i].length);
1461 }
1462 break;
1463 case REASON_ROAM_SET_FAVORED_BSSID:
1464 cdf_mem_set(&roam_params_dst->bssid_favored, 0,
1465 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1466 roam_params_dst->num_bssid_favored =
1467 roam_params_src.num_bssid_favored;
1468 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
1469 cdf_mem_copy(&roam_params_dst->bssid_favored[i],
1470 &roam_params_src.bssid_favored[i],
1471 sizeof(tSirMacAddr));
1472 roam_params_dst->bssid_favored_factor[i] =
1473 roam_params_src.bssid_favored_factor[i];
1474 }
1475 break;
1476 case REASON_ROAM_SET_BLACKLIST_BSSID:
1477 cdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
1478 sizeof(tSirMacAddr) * MAX_BSSID_AVOID_LIST);
1479 roam_params_dst->num_bssid_avoid_list =
1480 roam_params_src.num_bssid_avoid_list;
1481 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
1482 cdf_mem_copy(&roam_params_dst->bssid_avoid_list[i],
1483 &roam_params_src.bssid_avoid_list[i],
1484 sizeof(tSirMacAddr));
1485 }
1486 break;
1487 case REASON_ROAM_GOOD_RSSI_CHANGED:
1488 roam_params_dst->good_rssi_roam =
1489 roam_params_src.good_rssi_roam;
1490 break;
1491 default:
1492 break;
1493 }
1494 csr_roam_offload_scan(mac_ctx, session_id, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1495 update_param);
1496 return 0;
1497}
1498
1499#ifdef WLAN_FEATURE_GTK_OFFLOAD
1500void sme_process_get_gtk_info_rsp(tHalHandle hHal,
1501 tpSirGtkOffloadGetInfoRspParams
1502 pGtkOffloadGetInfoRsp)
1503{
1504 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1505
1506 if (NULL == pMac) {
1507 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_FATAL,
1508 "%s: pMac is null", __func__);
1509 return;
1510 }
1511 if (pMac->sme.gtk_offload_get_info_cb == NULL) {
1512 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
1513 "%s: HDD callback is null", __func__);
1514 return;
1515 }
1516 pMac->sme.gtk_offload_get_info_cb(
1517 pMac->sme.gtk_offload_get_info_cb_context,
1518 pGtkOffloadGetInfoRsp);
1519}
1520#endif
1521
1522/*--------------------------------------------------------------------------
1523
1524 \fn - sme_process_ready_to_suspend
1525 \brief - On getting ready to suspend indication, this function calls
1526 callback registered (HDD callbacks) with SME to inform
1527 ready to suspend indication.
1528
1529 \param hHal - Handle returned by mac_open.
1530 pReadyToSuspend - Parameter received along with ready to suspend
1531 indication from WMA.
1532
1533 \return None
1534
1535 \sa
1536
1537 --------------------------------------------------------------------------*/
1538void sme_process_ready_to_suspend(tHalHandle hHal,
1539 tpSirReadyToSuspendInd pReadyToSuspend)
1540{
1541 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1542
1543 if (NULL == pMac) {
1544 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_FATAL,
1545 "%s: pMac is null", __func__);
1546 return;
1547 }
1548
1549 if (NULL != pMac->readyToSuspendCallback) {
1550 pMac->readyToSuspendCallback(pMac->readyToSuspendContext,
1551 pReadyToSuspend->suspended);
1552 pMac->readyToSuspendCallback = NULL;
1553 }
1554}
1555
1556#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
1557/*--------------------------------------------------------------------------
1558
1559 \fn - sme_process_ready_to_ext_wo_w
1560 \brief - On getting ready to Ext WoW indication, this function calls
1561 callback registered (HDD callbacks) with SME to inform
1562 ready to ExtWoW indication.
1563
1564 \param hHal - Handle returned by mac_open.
1565 pReadyToExtWoW - Parameter received along with ready to Ext WoW
1566 indication from WMA.
1567
1568 \return None
1569
1570 \sa
1571
1572 --------------------------------------------------------------------------*/
1573void sme_process_ready_to_ext_wo_w(tHalHandle hHal,
1574 tpSirReadyToExtWoWInd pReadyToExtWoW)
1575{
1576 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1577
1578 if (NULL == pMac) {
1579 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_FATAL,
1580 "%s: pMac is null", __func__);
1581 return;
1582 }
1583
1584 if (NULL != pMac->readyToExtWoWCallback) {
1585 pMac->readyToExtWoWCallback(pMac->readyToExtWoWContext,
1586 pReadyToExtWoW->status);
1587 pMac->readyToExtWoWCallback = NULL;
1588 pMac->readyToExtWoWContext = NULL;
1589 }
1590
1591}
1592#endif
1593
1594/* ---------------------------------------------------------------------------
1595 \fn sme_change_config_params
1596 \brief The SME API exposed for HDD to provide config params to SME during
1597 SMEs stop -> start sequence.
1598
1599 If HDD changed the domain that will cause a reset. This function will
1600 provide the new set of 11d information for the new domain. Currrently this
1601 API provides info regarding 11d only at reset but we can extend this for
1602 other params (PMC, QoS) which needs to be initialized again at reset.
1603
1604 This is a synchronous call
1605
1606 \param hHal - The handle returned by mac_open.
1607
1608 \Param
1609 pUpdateConfigParam - a pointer to a structure (tCsrUpdateConfigParam) that
1610 currently provides 11d related information like Country code,
1611 Regulatory domain, valid channel list, Tx power per channel, a
1612 list with active/passive scan allowed per valid channel.
1613
1614 \return CDF_STATUS
1615 ---------------------------------------------------------------------------*/
1616CDF_STATUS sme_change_config_params(tHalHandle hHal,
1617 tCsrUpdateConfigParam *pUpdateConfigParam)
1618{
1619 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1620 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1621
1622 if (NULL == pUpdateConfigParam) {
1623 sms_log(pMac, LOGE,
1624 "Empty config param structure for SME, nothing to reset");
1625 return status;
1626 }
1627
1628 status = csr_change_config_params(pMac, pUpdateConfigParam);
1629
1630 if (!CDF_IS_STATUS_SUCCESS(status)) {
1631 sms_log(pMac, LOGE, "csrUpdateConfigParam failed with status=%d",
1632 status);
1633 }
1634
1635 return status;
1636
1637}
1638
1639/*--------------------------------------------------------------------------
1640
1641 \brief sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1642 that the NIC is ready tio run.
1643
1644 The function is called by HDD at the end of initialization stage so PE/HAL can
1645 enable the NIC to running state.
1646
1647 This is a synchronous call
1648 \param hHal - The handle returned by mac_open.
1649
1650 \return CDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1651 successfully.
1652
1653 Other status means SME failed to send the message to PE.
1654 \sa
1655
1656 --------------------------------------------------------------------------*/
1657CDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
1658{
1659 tSirSmeReadyReq Msg;
1660 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1661 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1662
1663 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
1664 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1665 do {
1666
1667 Msg.messageType = eWNI_SME_SYS_READY_IND;
1668 Msg.length = sizeof(tSirSmeReadyReq);
1669 Msg.add_bssdescr_cb = csr_scan_process_single_bssdescr;
1670
1671
1672 if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *) &Msg)) {
1673 status = CDF_STATUS_SUCCESS;
1674 } else {
1675 sms_log(pMac, LOGE,
1676 "u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
1677 break;
1678 }
1679
1680 status = csr_ready(pMac);
1681 if (!CDF_IS_STATUS_SUCCESS(status)) {
1682 sms_log(pMac, LOGE,
1683 "csr_ready failed with status=%d",
1684 status);
1685 break;
1686 }
1687
1688#if defined WLAN_FEATURE_VOWIFI
1689 if (CDF_STATUS_SUCCESS != rrm_ready(hHal)) {
1690 status = CDF_STATUS_E_FAILURE;
1691 sms_log(pMac, LOGE, "rrm_ready failed");
1692 break;
1693 }
1694#endif
1695 pMac->sme.state = SME_STATE_READY;
1696 } while (0);
1697
1698 return status;
1699}
1700
1701/*--------------------------------------------------------------------------
1702
1703 \brief sme_start() - Put all SME modules at ready state.
1704
1705 The function starts each module in SME, PMC, CSR, etc. . Upon
1706 successfully return, all modules are ready to run.
1707 This is a synchronous call
1708 \param hHal - The handle returned by mac_open.
1709
1710 \return CDF_STATUS_SUCCESS - SME is ready.
1711
1712 Other status means SME is failed to start
1713 \sa
1714
1715 --------------------------------------------------------------------------*/
1716CDF_STATUS sme_start(tHalHandle hHal)
1717{
1718 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1719 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1720
1721 do {
1722 status = csr_start(pMac);
1723 if (!CDF_IS_STATUS_SUCCESS(status)) {
1724 sms_log(pMac, LOGE,
1725 "csr_start failed during smeStart with status=%d",
1726 status);
1727 break;
1728 }
1729
1730#ifndef WLAN_FEATURE_MBSSID
1731 status = wlansap_start(cds_get_global_context());
1732 if (!CDF_IS_STATUS_SUCCESS(status)) {
1733 sms_log(pMac, LOGE,
1734 "wlansap_start failed during smeStart with status=%d",
1735 status);
1736 break;
1737 }
1738#endif
1739
1740 pMac->sme.state = SME_STATE_START;
1741 } while (0);
1742
1743 return status;
1744}
1745
1746/**
1747 * sme_handle_scan_req() - Scan request handler
1748 * @mac_ctx: MAC global context
1749 * @msg: message buffer
1750 *
1751 * Scan request message from upper layer is handled as
1752 * part of this API
1753 *
1754 * Return: CDF_STATUS
1755 */
1756static CDF_STATUS sme_handle_scan_req(tpAniSirGlobal mac_ctx,
1757 void *msg)
1758{
1759 struct ani_scan_req *scan_msg;
1760 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1761 uint16_t session_id;
1762 csr_scan_completeCallback callback;
1763
1764 scan_msg = msg;
1765 session_id = scan_msg->session_id;
1766 callback = scan_msg->callback;
1767 status = csr_scan_request(mac_ctx, session_id,
1768 scan_msg->scan_param,
1769 callback, scan_msg->ctx);
1770 if (!CDF_IS_STATUS_SUCCESS(status)) {
1771 sms_log(mac_ctx, LOGE,
1772 FL("scan request failed. session_id %d"), session_id);
1773 }
1774 csr_scan_free_request(mac_ctx, scan_msg->scan_param);
1775 return status;
1776}
1777
1778/**
1779 * sme_handle_roc_req() - Roc request handler
1780 * @mac_ctx: MAC global context
1781 * @msg: message buffer
1782 *
1783 * Roc request message from upper layer is handled as
1784 * part of this API
1785 *
1786 * Return: CDF_STATUS
1787 */
1788static CDF_STATUS sme_handle_roc_req(tHalHandle hal,
1789 void *msg)
1790{
1791 struct ani_roc_req *roc_msg;
1792 CDF_STATUS status = CDF_STATUS_E_FAILURE;
1793 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
1794 remainOnChanCallback callback;
1795
1796 if (msg == NULL) {
1797 sms_log(mac_ctx, LOGE, FL("ROC request is NULL"));
1798 return status;
1799 }
1800
1801 roc_msg = msg;
1802 callback = roc_msg->callback;
1803 status = p2p_remain_on_channel(hal, roc_msg->session_id,
1804 roc_msg->channel, roc_msg->duration, callback,
1805 roc_msg->ctx, roc_msg->is_p2pprobe_allowed,
1806 roc_msg->scan_id);
1807 if (!CDF_IS_STATUS_SUCCESS(status)) {
1808 sms_log(mac_ctx, LOGE,
1809 FL("scan request failed. session_id %d scan_id %d"),
1810 roc_msg->session_id, roc_msg->scan_id);
1811 }
1812 return status;
1813}
1814
1815#ifdef WLAN_FEATURE_11W
1816/*------------------------------------------------------------------
1817 *
1818 * Handle the unprotected management frame indication from LIM and
1819 * forward it to HDD.
1820 *
1821 *------------------------------------------------------------------*/
1822
1823CDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
1824 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1825{
1826 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1827 CDF_STATUS status = CDF_STATUS_SUCCESS;
1828 tCsrRoamInfo pRoamInfo = { 0 };
1829 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1830
1831 pRoamInfo.nFrameLength = pSmeMgmtFrm->frameLen;
1832 pRoamInfo.pbFrames = pSmeMgmtFrm->frameBuf;
1833 pRoamInfo.frameType = pSmeMgmtFrm->frameType;
1834
1835 /* forward the mgmt frame to HDD */
1836 csr_roam_call_callback(pMac, SessionId, &pRoamInfo, 0,
1837 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1838
1839 return status;
1840}
1841#endif
1842
1843/*------------------------------------------------------------------
1844 *
1845 * Handle the DFS Radar Event and indicate it to the SAP
1846 *
1847 *------------------------------------------------------------------*/
1848CDF_STATUS dfs_msg_processor(tpAniSirGlobal pMac, uint16_t msgType, void *pMsgBuf)
1849{
1850 CDF_STATUS status = CDF_STATUS_SUCCESS;
1851 tCsrRoamInfo roamInfo = { 0 };
1852 tSirSmeDfsEventInd *dfs_event;
1853 tSirSmeCSAIeTxCompleteRsp *csaIeTxCompleteRsp;
1854 uint32_t sessionId = 0;
1855 eRoamCmdStatus roamStatus;
1856 eCsrRoamResult roamResult;
1857 int i;
1858
1859 switch (msgType) {
1860 case eWNI_SME_DFS_RADAR_FOUND:
1861 {
1862 /* Radar found !! */
1863 dfs_event = (tSirSmeDfsEventInd *) pMsgBuf;
1864 if (NULL == dfs_event) {
1865 sms_log(pMac, LOGE,
1866 "%s: pMsg is NULL for eWNI_SME_DFS_RADAR_FOUND message",
1867 __func__);
1868 return CDF_STATUS_E_FAILURE;
1869 }
1870 sessionId = dfs_event->sessionId;
1871 roamInfo.dfs_event.sessionId = sessionId;
1872 roamInfo.dfs_event.chan_list.nchannels =
1873 dfs_event->chan_list.nchannels;
1874 for (i = 0; i < dfs_event->chan_list.nchannels; i++) {
1875 roamInfo.dfs_event.chan_list.channels[i] =
1876 dfs_event->chan_list.channels[i];
1877 }
1878
1879 roamInfo.dfs_event.dfs_radar_status =
1880 dfs_event->dfs_radar_status;
1881 roamInfo.dfs_event.use_nol = dfs_event->use_nol;
1882
1883 roamStatus = eCSR_ROAM_DFS_RADAR_IND;
1884 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
1885 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_MED,
1886 "sapdfs: Radar indication event occurred");
1887 break;
1888 }
1889 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1890 {
1891 csaIeTxCompleteRsp =
1892 (tSirSmeCSAIeTxCompleteRsp *) pMsgBuf;
1893 if (NULL == csaIeTxCompleteRsp) {
1894 sms_log(pMac, LOGE,
1895 "%s: pMsg is NULL for eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND",
1896 __func__);
1897 return CDF_STATUS_E_FAILURE;
1898 }
1899 sessionId = csaIeTxCompleteRsp->sessionId;
1900 roamStatus = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1901 roamResult = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
1902 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_MED,
1903 "sapdfs: Received eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND for session id [%d]",
1904 sessionId);
1905 break;
1906 }
1907 default:
1908 {
1909 sms_log(pMac, LOG1, "%s: Invalid DFS message = 0x%x",
1910 __func__, msgType);
1911 status = CDF_STATUS_E_FAILURE;
1912 return status;
1913 }
1914 }
1915
1916 /* Indicate Radar Event to SAP */
1917 csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
1918 roamStatus, roamResult);
1919 return status;
1920}
1921
Abhishek Singh518323d2015-10-19 17:42:01 +05301922/**
1923 * sme_extended_change_channel_ind()- function to indicate ECSA
1924 * action frame is received in lim to SAP
1925 * @mac_ctx: pointer to global mac structure
1926 * @msg_buf: contain new channel and session id.
1927 *
1928 * This function is called to post ECSA action frame
1929 * receive event to SAP.
1930 *
1931 * Return: success if msg indicated to SAP else return failure
1932 */
1933static CDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
1934 void *msg_buf)
1935{
1936 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
1937 CDF_STATUS status = CDF_STATUS_SUCCESS;
1938 uint32_t session_id = 0;
1939 tCsrRoamInfo roamInfo = {0};
1940 eRoamCmdStatus roam_status;
1941 eCsrRoamResult roam_result;
1942
1943
1944 ext_chan_ind = msg_buf;
1945 if (NULL == ext_chan_ind) {
1946 sms_log(mac_ctx, LOGE,
1947 FL("pMsg is NULL for eWNI_SME_EXT_CHANGE_CHANNEL_IND"));
1948 return CDF_STATUS_E_FAILURE;
1949 }
1950 session_id = ext_chan_ind->session_id;
1951 roamInfo.target_channel = ext_chan_ind->new_channel;
1952 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1953 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
1954 sms_log(mac_ctx, LOG1,
1955 FL("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]"),
1956 session_id);
1957
1958 /* Indicate Ext Channel Change event to SAP */
1959 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1960 roam_status, roam_result);
1961 return status;
1962}
1963
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1965/*------------------------------------------------------------------
1966 *
1967 * Handle the tsm ie indication from LIM and forward it to HDD.
1968 *
1969 *------------------------------------------------------------------*/
1970CDF_STATUS sme_tsm_ie_ind(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
1971{
1972 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1973 CDF_STATUS status = CDF_STATUS_SUCCESS;
1974 tCsrRoamInfo pRoamInfo = { 0 };
1975 uint32_t SessionId = pSmeTsmIeInd->sessionId;
1976 pRoamInfo.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1977 pRoamInfo.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1978 pRoamInfo.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
1979 /* forward the tsm ie information to HDD */
1980 csr_roam_call_callback(pMac,
1981 SessionId, &pRoamInfo, 0, eCSR_ROAM_TSM_IE_IND, 0);
1982 return status;
1983}
1984
1985/* ---------------------------------------------------------------------------
1986 \fn sme_set_cckm_ie
1987 \brief function to store the CCKM IE passed from supplicant and use
1988 it while packing reassociation request
1989 \param hHal - HAL handle for device
1990 \param sessionId - Session Identifier
1991 \param pCckmIe - pointer to CCKM IE data
1992 \param pCckmIeLen - length of the CCKM IE
1993 \- return Success or failure
1994 -------------------------------------------------------------------------*/
1995CDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
1996 uint8_t *pCckmIe, uint8_t cckmIeLen)
1997{
1998 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1999 CDF_STATUS status = CDF_STATUS_SUCCESS;
2000 status = sme_acquire_global_lock(&pMac->sme);
2001 if (CDF_IS_STATUS_SUCCESS(status)) {
2002 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
2003 sme_release_global_lock(&pMac->sme);
2004 }
2005 return status;
2006}
2007
2008/* ---------------------------------------------------------------------------
2009 \fn sme_set_ese_beacon_request
2010 \brief function to set ESE beacon request parameters
2011 \param hHal - HAL handle for device
2012 \param sessionId - Session id
2013 \param pEseBcnReq - pointer to ESE beacon request
2014 \- return Success or failure
2015 -------------------------------------------------------------------------*/
2016CDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
2017 const tCsrEseBeaconReq *pEseBcnReq)
2018{
2019 CDF_STATUS status = eSIR_SUCCESS;
2020 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2021 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
2022 tCsrEseBeaconReqParams *pBeaconReq = NULL;
2023 uint8_t counter = 0;
2024 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
2025 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
2026
2027 if (pSmeRrmContext->eseBcnReqInProgress == true) {
2028 sms_log(pMac, LOGE,
2029 "A Beacon Report Req is already in progress");
2030 return CDF_STATUS_E_RESOURCES;
2031 }
2032
2033 /* Store the info in RRM context */
2034 cdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
2035 sizeof(tCsrEseBeaconReq));
2036
2037 /* Prepare the request to send to SME. */
2038 pSmeBcnReportReq = cdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
2039 if (NULL == pSmeBcnReportReq) {
2040 sms_log(pMac, LOGP,
2041 "Memory Allocation Failure!!! ESE BcnReq Ind to SME");
2042 return CDF_STATUS_E_NOMEM;
2043 }
2044
2045 pSmeRrmContext->eseBcnReqInProgress = true;
2046
2047 sms_log(pMac, LOGE, "Sending Beacon Report Req to SME");
2048 cdf_mem_zero(pSmeBcnReportReq, sizeof(tSirBeaconReportReqInd));
2049
2050 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
2051 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
2052 cdf_mem_copy(pSmeBcnReportReq->bssId,
2053 pSession->connectedProfile.bssid.bytes,
2054 sizeof(tSirMacAddr));
2055 pSmeBcnReportReq->channelInfo.channelNum = 255;
2056 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
2057 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
2058
2059 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
2060 pBeaconReq =
2061 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
2062 pSmeBcnReportReq->fMeasurementtype[counter] =
2063 pBeaconReq->scanMode;
2064 pSmeBcnReportReq->measurementDuration[counter] =
2065 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
2066 pSmeBcnReportReq->channelList.channelNumber[counter] =
2067 pBeaconReq->channel;
2068 }
2069
2070 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
2071
2072 if (status != CDF_STATUS_SUCCESS)
2073 pSmeRrmContext->eseBcnReqInProgress = false;
2074
2075 return status;
2076}
2077
2078#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
2079
2080/**
2081 * sme_process_fw_mem_dump_rsp - process fw memory dump response from WMA
2082 *
2083 * @mac_ctx: pointer to MAC handle.
2084 * @msg: pointer to received SME msg.
2085 *
2086 * This function process the received SME message and calls the corresponding
2087 * callback which was already registered with SME.
2088 *
2089 * Return: None
2090 */
2091#ifdef WLAN_FEATURE_MEMDUMP
2092static void sme_process_fw_mem_dump_rsp(tpAniSirGlobal mac_ctx, cds_msg_t *msg)
2093{
2094 if (msg->bodyptr) {
2095 if (mac_ctx->sme.fw_dump_callback)
2096 mac_ctx->sme.fw_dump_callback(mac_ctx->hHdd,
2097 (struct fw_dump_rsp *) msg->bodyptr);
2098 cdf_mem_free(msg->bodyptr);
2099 }
2100}
2101#else
2102static void sme_process_fw_mem_dump_rsp(tpAniSirGlobal mac_ctx, cds_msg_t *msg)
2103{
2104}
2105#endif
2106
2107/**
2108 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
2109 * @mac: Global MAC pointer
2110 * @msg: Dual mac config response
2111 *
2112 * Processes the dual mac configuration response and invokes the HDD callback
2113 * to process further
2114 */
2115static CDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
2116 uint8_t *msg)
2117{
2118 tListElem *entry = NULL;
2119 tSmeCmd *command = NULL;
2120 bool found;
2121 dual_mac_cb callback = NULL;
2122 struct sir_dual_mac_config_resp *param;
2123
2124 param = (struct sir_dual_mac_config_resp *)msg;
2125 if (!param) {
2126 sms_log(mac, LOGE, FL("Dual mac config resp param is NULL"));
2127 /* Not returning. Need to check if active command list
2128 * needs to be freed
2129 */
2130 }
2131
2132 entry = csr_ll_peek_head(&mac->sme.smeCmdActiveList,
2133 LL_ACCESS_LOCK);
2134 if (!entry) {
2135 sms_log(mac, LOGE, FL("No cmd found in active list"));
2136 return CDF_STATUS_E_FAILURE;
2137 }
2138
2139 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2140 if (!command) {
2141 sms_log(mac, LOGE, FL("Base address is NULL"));
2142 return CDF_STATUS_E_FAILURE;
2143 }
2144
2145 if (e_sme_command_set_dual_mac_config != command->command) {
2146 sms_log(mac, LOGE, FL("Command mismatch!"));
2147 return CDF_STATUS_E_FAILURE;
2148 }
2149
2150 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
2151 if (callback) {
2152 if (!param) {
2153 sms_log(mac, LOGE,
2154 FL("Callback failed-Dual mac config is NULL"));
2155 } else {
2156 sms_log(mac, LOG1,
2157 FL("Calling HDD callback for Dual mac config"));
2158 callback(param->status,
2159 command->u.set_dual_mac_cmd.scan_config,
2160 command->u.set_dual_mac_cmd.fw_mode_config);
2161 }
2162 } else {
2163 sms_log(mac, LOGE, FL("Callback does not exist"));
2164 }
2165
2166 found = csr_ll_remove_entry(&mac->sme.smeCmdActiveList, entry,
2167 LL_ACCESS_LOCK);
2168 if (found)
2169 /* Now put this command back on the available command list */
2170 sme_release_command(mac, command);
2171
2172 sme_process_pending_queue(mac);
2173 return CDF_STATUS_SUCCESS;
2174}
2175
2176/*--------------------------------------------------------------------------
2177
2178 \brief sme_process_msg() - The main message processor for SME.
2179
2180 The function is called by a message dispatcher when to process a message
2181 targeted for SME.
2182
2183 This is a synchronous call
2184 \param hHal - The handle returned by mac_open.
2185 \param pMsg - A pointer to a caller allocated object of tSirMsgQ.
2186
2187 \return CDF_STATUS_SUCCESS - SME successfully process the message.
2188
2189 Other status means SME failed to process the message to HAL.
2190 \sa
2191
2192 --------------------------------------------------------------------------*/
2193CDF_STATUS sme_process_msg(tHalHandle hHal, cds_msg_t *pMsg)
2194{
2195 CDF_STATUS status = CDF_STATUS_E_FAILURE;
2196 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2197
2198 if (pMsg == NULL) {
2199 sms_log(pMac, LOGE, "Empty message for SME");
2200 return status;
2201 }
2202 status = sme_acquire_global_lock(&pMac->sme);
2203 if (!CDF_IS_STATUS_SUCCESS(status)) {
2204 sms_log(pMac, LOGW, FL("Locking failed, bailing out"));
2205 if (pMsg->bodyptr)
2206 cdf_mem_free(pMsg->bodyptr);
2207 return status;
2208 }
2209 if (!SME_IS_START(pMac)) {
2210 sms_log(pMac, LOGW, FL("message type %d in stop state ignored"),
2211 pMsg->type);
2212 if (pMsg->bodyptr)
2213 cdf_mem_free(pMsg->bodyptr);
2214 goto release_lock;
2215 }
2216 switch (pMsg->type) {
2217#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2218 case eWNI_SME_ROAM_OFFLOAD_SYNCH_IND:
2219 csr_process_roam_offload_synch_ind(pMac,
2220 (roam_offload_synch_ind *) pMsg->bodyptr);
2221 cdf_mem_free(pMsg->bodyptr);
2222 break;
2223 case eWNI_SME_HO_FAIL_IND:
2224 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
2225 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
2226 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
2227 cdf_mem_free(pMsg->bodyptr);
2228 break;
2229#endif
2230 case eWNI_PMC_SMPS_STATE_IND:
2231 break;
2232 case WNI_CFG_SET_CNF:
2233 case WNI_CFG_DNLD_CNF:
2234 case WNI_CFG_GET_RSP:
2235 case WNI_CFG_ADD_GRP_ADDR_CNF:
2236 case WNI_CFG_DEL_GRP_ADDR_CNF:
2237 break;
2238 case eWNI_SME_ADDTS_RSP:
2239 case eWNI_SME_DELTS_RSP:
2240 case eWNI_SME_DELTS_IND:
2241#ifdef WLAN_FEATURE_VOWIFI_11R
2242 case eWNI_SME_FT_AGGR_QOS_RSP:
2243#endif
2244 /* QoS */
2245 if (pMsg->bodyptr) {
2246#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2247 status = sme_qos_msg_processor(pMac, pMsg->type,
2248 pMsg->bodyptr);
2249 cdf_mem_free(pMsg->bodyptr);
2250#endif
2251 } else {
2252 sms_log(pMac, LOGE, FL("Empty message for %d"),
2253 pMsg->type);
2254 }
2255 break;
2256#if defined WLAN_FEATURE_VOWIFI
2257 case eWNI_SME_NEIGHBOR_REPORT_IND:
2258 case eWNI_SME_BEACON_REPORT_REQ_IND:
2259#if defined WLAN_VOWIFI_DEBUG
2260 sms_log(pMac, LOGE, FL("Received RRM message. Message Id = %d"),
2261 pMsg->type);
2262#endif
2263 if (pMsg->bodyptr) {
2264 status = sme_rrm_msg_processor(pMac, pMsg->type,
2265 pMsg->bodyptr);
2266 cdf_mem_free(pMsg->bodyptr);
2267 } else {
2268 sms_log(pMac, LOGE, FL("Empty message for %d"),
2269 pMsg->type);
2270 }
2271 break;
2272#endif
2273#ifdef FEATURE_OEM_DATA_SUPPORT
2274 /* Handle the eWNI_SME_OEM_DATA_RSP: */
2275 case eWNI_SME_OEM_DATA_RSP:
2276 if (pMsg->bodyptr) {
2277 status = sme_handle_oem_data_rsp(pMac, pMsg->bodyptr);
2278 cdf_mem_free(pMsg->bodyptr);
2279 } else {
2280 sms_log(pMac, LOGE, FL("Empty message for %d"),
2281 pMsg->type);
2282 }
2283 sme_process_pending_queue(pMac);
2284 break;
2285#endif
2286 case eWNI_SME_ADD_STA_SELF_RSP:
2287 if (pMsg->bodyptr) {
2288 status = csr_process_add_sta_session_rsp(pMac,
2289 pMsg->bodyptr);
2290 cdf_mem_free(pMsg->bodyptr);
2291 } else {
2292 sms_log(pMac, LOGE, FL("Empty message for %d"),
2293 pMsg->type);
2294 }
2295 break;
2296 case eWNI_SME_DEL_STA_SELF_RSP:
2297 if (pMsg->bodyptr) {
2298 status = csr_process_del_sta_session_rsp(pMac,
2299 pMsg->bodyptr);
2300 cdf_mem_free(pMsg->bodyptr);
2301 } else {
2302 sms_log(pMac, LOGE, FL("Empty message for %d"),
2303 pMsg->type);
2304 }
2305 break;
2306 case eWNI_SME_REMAIN_ON_CHN_RSP:
2307 if (pMsg->bodyptr) {
2308 status = sme_remain_on_chn_rsp(pMac, pMsg->bodyptr);
2309 cdf_mem_free(pMsg->bodyptr);
2310 } else {
2311 sms_log(pMac, LOGE, FL("Empty message for %d"),
2312 pMsg->type);
2313 }
2314 break;
2315 case eWNI_SME_REMAIN_ON_CHN_RDY_IND:
2316 if (pMsg->bodyptr) {
2317 status = sme_remain_on_chn_ready(pMac, pMsg->bodyptr);
2318 cdf_mem_free(pMsg->bodyptr);
2319 } else {
2320 sms_log(pMac, LOGE, FL("Empty message for %d"),
2321 pMsg->type);
2322 }
2323 break;
2324 case eWNI_SME_MGMT_FRM_IND:
2325 if (pMsg->bodyptr) {
2326 sme_mgmt_frm_ind(pMac, pMsg->bodyptr);
2327 cdf_mem_free(pMsg->bodyptr);
2328 } else {
2329 sms_log(pMac, LOGE, FL("Empty message for %d"),
2330 pMsg->type);
2331 }
2332 break;
2333 case eWNI_SME_ACTION_FRAME_SEND_CNF:
2334 if (pMsg->bodyptr) {
2335 status = sme_send_action_cnf(pMac, pMsg->bodyptr);
2336 cdf_mem_free(pMsg->bodyptr);
2337 } else {
2338 sms_log(pMac, LOGE, FL("Empty message for %d"),
2339 pMsg->type);
2340 }
2341 break;
2342#ifdef FEATURE_WLAN_SCAN_PNO
2343 case eWNI_SME_PREF_NETWORK_FOUND_IND:
2344 if (pMsg->bodyptr) {
2345 status = sme_preferred_network_found_ind((void *)pMac,
2346 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#endif /* FEATURE_WLAN_SCAN_PNO */
2354 case eWNI_SME_CHANGE_COUNTRY_CODE:
2355 if (pMsg->bodyptr) {
2356 status = sme_handle_change_country_code((void *)pMac,
2357 pMsg->bodyptr);
2358 cdf_mem_free(pMsg->bodyptr);
2359 } else {
2360 sms_log(pMac, LOGE, FL("Empty message for %d"),
2361 pMsg->type);
2362 }
2363 break;
2364 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2365 if (pMsg->bodyptr) {
2366 status = sme_handle_generic_change_country_code(
2367 (void *)pMac, pMsg->bodyptr);
2368 cdf_mem_free(pMsg->bodyptr);
2369 } else {
2370 sms_log(pMac, LOGE, FL("Empty message for %d"),
2371 pMsg->type);
2372 }
2373 break;
2374 case eWNI_SME_SCAN_CMD:
2375 if (pMsg->bodyptr) {
2376 status = sme_handle_scan_req(pMac, pMsg->bodyptr);
2377 cdf_mem_free(pMsg->bodyptr);
2378 } else {
2379 sms_log(pMac, LOGE, FL("Empty message for %d"),
2380 pMsg->type);
2381 }
2382 break;
2383 case eWNI_SME_ROC_CMD:
2384 if (pMsg->bodyptr) {
2385 status = sme_handle_roc_req(hHal, pMsg->bodyptr);
2386 cdf_mem_free(pMsg->bodyptr);
2387 } else {
2388 sms_log(pMac, LOGE, FL("Empty message for %d"),
2389 pMsg->type);
2390 }
2391 break;
2392#ifdef FEATURE_WLAN_TDLS
2393 /*
2394 * command rescived from PE, SME tdls msg processor shall be called
2395 * to process commands recieved from PE
2396 */
2397 case eWNI_SME_TDLS_SEND_MGMT_RSP:
2398 case eWNI_SME_TDLS_ADD_STA_RSP:
2399 case eWNI_SME_TDLS_DEL_STA_RSP:
2400 case eWNI_SME_TDLS_DEL_STA_IND:
2401 case eWNI_SME_TDLS_DEL_ALL_PEER_IND:
2402 case eWNI_SME_MGMT_FRM_TX_COMPLETION_IND:
2403 case eWNI_SME_TDLS_LINK_ESTABLISH_RSP:
2404 case eWNI_SME_TDLS_SHOULD_DISCOVER:
2405 case eWNI_SME_TDLS_SHOULD_TEARDOWN:
2406 case eWNI_SME_TDLS_PEER_DISCONNECTED:
2407 if (pMsg->bodyptr) {
2408 status = tdls_msg_processor(pMac, pMsg->type,
2409 pMsg->bodyptr);
2410 cdf_mem_free(pMsg->bodyptr);
2411 } else {
2412 sms_log(pMac, LOGE, FL("Empty message for %d"),
2413 pMsg->type);
2414 }
2415 break;
2416#endif
2417#ifdef WLAN_FEATURE_11W
2418 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2419 if (pMsg->bodyptr) {
2420 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
2421 cdf_mem_free(pMsg->bodyptr);
2422 } else {
2423 sms_log(pMac, LOGE, FL("Empty message for %d"),
2424 pMsg->type);
2425 }
2426 break;
2427#endif
2428#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
2429 case eWNI_SME_TSM_IE_IND:
2430 if (pMsg->bodyptr) {
2431 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
2432 cdf_mem_free(pMsg->bodyptr);
2433 } else {
2434 sms_log(pMac, LOGE, FL("Empty message for %d"),
2435 pMsg->type);
2436 }
2437 break;
2438#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
2439 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2440 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2441 pMsg->bodyptr);
2442 cdf_mem_free(pMsg->bodyptr);
2443 break;
2444#ifdef WLAN_FEATURE_GTK_OFFLOAD
2445 case eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP:
2446 if (pMsg->bodyptr) {
2447 sme_process_get_gtk_info_rsp(pMac, pMsg->bodyptr);
2448 cdf_mem_free(pMsg->bodyptr);
2449 } else {
2450 sms_log(pMac, LOGE, FL("Empty message for %d"),
2451 pMsg->type);
2452 }
2453 break;
2454#endif
2455#ifdef FEATURE_WLAN_LPHB
2456 /* LPHB timeout indication arrived, send IND to client */
2457 case eWNI_SME_LPHB_IND:
2458 if (pMac->sme.pLphbIndCb)
2459 pMac->sme.pLphbIndCb(pMac->hHdd, pMsg->bodyptr);
2460 cdf_mem_free(pMsg->bodyptr);
2461 break;
2462#endif /* FEATURE_WLAN_LPHB */
2463
2464 case eWNI_SME_READY_TO_SUSPEND_IND:
2465 if (pMsg->bodyptr) {
2466 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
2467 cdf_mem_free(pMsg->bodyptr);
2468 } else {
2469 sms_log(pMac, LOGE, FL("Empty message for %d"),
2470 pMsg->type);
2471 }
2472 break;
2473#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2474 case eWNI_SME_READY_TO_EXTWOW_IND:
2475 if (pMsg->bodyptr) {
2476 sme_process_ready_to_ext_wo_w(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_CH_AVOID
2485 /* channel avoid message arrived, send IND to client */
2486 case eWNI_SME_CH_AVOID_IND:
2487 if (pMac->sme.pChAvoidNotificationCb) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08002488 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 FL("CH avoid notification"));
2490 pMac->sme.pChAvoidNotificationCb(pMac->hHdd,
2491 pMsg->bodyptr);
2492 }
2493 cdf_mem_free(pMsg->bodyptr);
2494 break;
2495#endif /* FEATURE_WLAN_CH_AVOID */
2496#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2497 case eWNI_SME_AUTO_SHUTDOWN_IND:
2498 if (pMac->sme.pAutoShutdownNotificationCb) {
2499 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
2500 FL("Auto shutdown notification"));
2501 pMac->sme.pAutoShutdownNotificationCb();
2502 }
2503 cdf_mem_free(pMsg->bodyptr);
2504 break;
2505#endif
2506 case eWNI_SME_DFS_RADAR_FOUND:
2507 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
2508 status = dfs_msg_processor(pMac, pMsg->type, pMsg->bodyptr);
2509 cdf_mem_free(pMsg->bodyptr);
2510 break;
2511 case eWNI_SME_CHANNEL_CHANGE_RSP:
2512 if (pMsg->bodyptr) {
2513 status = sme_process_channel_change_resp(pMac,
2514 pMsg->type,
2515 pMsg->bodyptr);
2516 cdf_mem_free(pMsg->bodyptr);
2517 } else {
2518 sms_log(pMac, LOGE, FL("Empty message for %d"),
2519 pMsg->type);
2520 }
2521 break;
2522#ifdef WLAN_FEATURE_STATS_EXT
2523 case eWNI_SME_STATS_EXT_EVENT:
2524 if (pMsg->bodyptr) {
2525 status = sme_stats_ext_event(hHal, pMsg->bodyptr);
2526 cdf_mem_free(pMsg->bodyptr);
2527 } else {
2528 sms_log(pMac, LOGE, FL("Empty message for %d"),
2529 pMsg->type);
2530 }
2531 break;
2532#endif
2533 case eWNI_SME_LINK_SPEED_IND:
2534 if (pMac->sme.pLinkSpeedIndCb)
2535 pMac->sme.pLinkSpeedIndCb(pMsg->bodyptr,
2536 pMac->sme.pLinkSpeedCbContext);
2537 if (pMsg->bodyptr)
2538 cdf_mem_free(pMsg->bodyptr);
2539 break;
2540 case eWNI_SME_CSA_OFFLOAD_EVENT:
2541 if (pMsg->bodyptr) {
2542 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
2543 cdf_mem_free(pMsg->bodyptr);
2544 }
2545 break;
2546#ifdef WLAN_FEATURE_NAN
2547 case eWNI_SME_NAN_EVENT:
2548 if (pMsg->bodyptr) {
2549 sme_nan_event(hHal, pMsg->bodyptr);
2550 cdf_mem_free(pMsg->bodyptr);
2551 }
2552 break;
2553#endif /* WLAN_FEATURE_NAN */
2554 case eWNI_SME_LINK_STATUS_IND:
2555 {
2556 tAniGetLinkStatus *pLinkStatus =
2557 (tAniGetLinkStatus *) pMsg->bodyptr;
2558 if (pLinkStatus) {
2559 if (pMac->sme.linkStatusCallback) {
2560 pMac->sme.linkStatusCallback(
2561 pLinkStatus->linkStatus,
2562 pMac->sme.linkStatusContext);
2563 }
2564 pMac->sme.linkStatusCallback = NULL;
2565 pMac->sme.linkStatusContext = NULL;
2566 cdf_mem_free(pLinkStatus);
2567 }
2568 break;
2569 }
2570 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
2571 if (pMac->sme.pGetTemperatureCb) {
2572 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2573 pMac->sme.pTemperatureCbContext);
2574 }
2575 break;
2576 case eWNI_SME_SNR_IND:
2577 {
2578 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
2579 if (pSnrReq) {
2580 if (pSnrReq->snrCallback) {
2581 ((tCsrSnrCallback)
2582 (pSnrReq->snrCallback))
2583 (pSnrReq->snr, pSnrReq->staId,
2584 pSnrReq->pDevContext);
2585 }
2586 cdf_mem_free(pSnrReq);
2587 }
2588 break;
2589 }
2590#ifdef FEATURE_WLAN_EXTSCAN
2591 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2592 if (pMac->sme.pExtScanIndCb)
2593 pMac->sme.pExtScanIndCb(pMac->hHdd,
2594 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2595 pMsg->bodyptr);
2596 else
2597 sms_log(pMac, LOGE,
2598 FL("callback not registered to process %d"),
2599 pMsg->type);
2600
2601 cdf_mem_free(pMsg->bodyptr);
2602 break;
2603 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2604 if (pMac->sme.pExtScanIndCb)
2605 pMac->sme.pExtScanIndCb(pMac->hHdd,
2606 eSIR_EPNO_NETWORK_FOUND_IND,
2607 pMsg->bodyptr);
2608 else
2609 sms_log(pMac, LOGE,
2610 FL("callback not registered to process %d"),
2611 pMsg->type);
2612
2613 cdf_mem_free(pMsg->bodyptr);
2614 break;
2615#endif
2616 case eWNI_SME_FW_DUMP_IND:
2617 sme_process_fw_mem_dump_rsp(pMac, pMsg);
2618 break;
2619 case eWNI_SME_SET_HW_MODE_RESP:
2620 if (pMsg->bodyptr) {
2621 status = sme_process_set_hw_mode_resp(pMac,
2622 pMsg->bodyptr);
2623 cdf_mem_free(pMsg->bodyptr);
2624 } else {
2625 sms_log(pMac, LOGE, FL("Empty message for %d"),
2626 pMsg->type);
2627 }
2628 break;
2629 case eWNI_SME_HW_MODE_TRANS_IND:
2630 if (pMsg->bodyptr) {
2631 status = sme_process_hw_mode_trans_ind(pMac,
2632 pMsg->bodyptr);
2633 cdf_mem_free(pMsg->bodyptr);
2634 } else {
2635 sms_log(pMac, LOGE, FL("Empty message for %d"),
2636 pMsg->type);
2637 }
2638 break;
2639 case eWNI_SME_NSS_UPDATE_RSP:
2640 if (pMsg->bodyptr) {
2641 status = sme_process_nss_update_resp(pMac,
2642 pMsg->bodyptr);
2643 cdf_mem_free(pMsg->bodyptr);
2644 } else {
2645 sms_log(pMac, LOGE, FL("Empty message for %d"),
2646 pMsg->type);
2647 }
2648 break;
2649 case eWNI_SME_OCB_SET_CONFIG_RSP:
2650 if (pMac->sme.ocb_set_config_callback) {
2651 pMac->sme.ocb_set_config_callback(
2652 pMac->sme.ocb_set_config_context,
2653 pMsg->bodyptr);
2654 } else {
2655 sms_log(pMac, LOGE, FL(
2656 "Message error. The callback is NULL."));
2657 }
2658 pMac->sme.ocb_set_config_callback = NULL;
2659 pMac->sme.ocb_set_config_context = NULL;
2660 cdf_mem_free(pMsg->bodyptr);
2661 break;
2662 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
2663 if (pMac->sme.ocb_get_tsf_timer_callback) {
2664 pMac->sme.ocb_get_tsf_timer_callback(
2665 pMac->sme.ocb_get_tsf_timer_context,
2666 pMsg->bodyptr);
2667 } else {
2668 sms_log(pMac, LOGE, FL(
2669 "Message error. The callback is NULL."));
2670 }
2671 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2672 pMac->sme.ocb_get_tsf_timer_context = NULL;
2673 cdf_mem_free(pMsg->bodyptr);
2674 break;
2675 case eWNI_SME_DCC_GET_STATS_RSP:
2676 if (pMac->sme.dcc_get_stats_callback) {
2677 pMac->sme.dcc_get_stats_callback(
2678 pMac->sme.dcc_get_stats_context,
2679 pMsg->bodyptr);
2680 } else {
2681 sms_log(pMac, LOGE, FL(
2682 "Message error. The callback is NULL."));
2683 }
2684 pMac->sme.dcc_get_stats_callback = NULL;
2685 pMac->sme.dcc_get_stats_context = NULL;
2686 cdf_mem_free(pMsg->bodyptr);
2687 break;
2688 case eWNI_SME_DCC_UPDATE_NDL_RSP:
2689 if (pMac->sme.dcc_update_ndl_callback) {
2690 pMac->sme.dcc_update_ndl_callback(
2691 pMac->sme.dcc_update_ndl_context,
2692 pMsg->bodyptr);
2693 } else {
2694 sms_log(pMac, LOGE, FL(
2695 "Message error. The callback is NULL."));
2696 }
2697 pMac->sme.dcc_update_ndl_callback = NULL;
2698 pMac->sme.dcc_update_ndl_context = NULL;
2699 cdf_mem_free(pMsg->bodyptr);
2700 break;
2701 case eWNI_SME_DCC_STATS_EVENT:
2702 if (pMac->sme.dcc_stats_event_callback) {
2703 pMac->sme.dcc_stats_event_callback(
2704 pMac->sme.dcc_stats_event_context,
2705 pMsg->bodyptr);
2706 } else {
2707 sms_log(pMac, LOGE, FL(
2708 "Message error. The callback is NULL."));
2709 }
2710 cdf_mem_free(pMsg->bodyptr);
2711 break;
2712 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2713 if (pMsg->bodyptr) {
2714 status = sme_process_dual_mac_config_resp(pMac,
2715 pMsg->bodyptr);
2716 cdf_mem_free(pMsg->bodyptr);
2717 } else {
2718 sms_log(pMac, LOGE, FL("Empty message for %d"),
2719 pMsg->type);
2720 }
2721 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2722 if (pMac->sme.set_thermal_level_cb)
2723 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2724 pMsg->bodyval);
2725 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302726 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2727 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
2728 cdf_mem_free(pMsg->bodyptr);
2729 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 default:
2731
2732 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2733 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2734 /* CSR */
2735 if (pMsg->bodyptr) {
2736 status = csr_msg_processor(hHal, pMsg->bodyptr);
2737 cdf_mem_free(pMsg->bodyptr);
2738 } else {
2739 sms_log(pMac, LOGE, FL("Empty message for %d"),
2740 pMsg->type);
2741 }
2742 } else {
2743 sms_log(pMac, LOGW, FL("Unknown message type %d"),
2744 pMsg->type);
2745 if (pMsg->bodyptr)
2746 cdf_mem_free(pMsg->bodyptr);
2747 }
2748 } /* switch */
2749release_lock:
2750 sme_release_global_lock(&pMac->sme);
2751 return status;
2752}
2753
2754/**
2755 * sme_process_nss_update_resp() - Process nss update response
2756 * @mac: Global MAC pointer
2757 * @msg: nss update response
2758 *
2759 * Processes the nss update response and invokes the HDD
2760 * callback to process further
2761 */
2762CDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
2763{
2764 tListElem *entry = NULL;
2765 tSmeCmd *command = NULL;
2766 bool found;
2767 nss_update_cb callback = NULL;
2768 struct sir_beacon_tx_complete_rsp *param;
2769
2770 param = (struct sir_beacon_tx_complete_rsp *)msg;
2771 if (!param) {
2772 sms_log(mac, LOGE, FL("nss update resp param is NULL"));
2773 /* Not returning. Need to check if active command list
2774 * needs to be freed
2775 */
2776 }
2777
2778 entry = csr_ll_peek_head(&mac->sme.smeCmdActiveList,
2779 LL_ACCESS_LOCK);
2780 if (!entry) {
2781 sms_log(mac, LOGE, FL("No cmd found in active list"));
2782 return CDF_STATUS_E_FAILURE;
2783 }
2784
2785 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2786 if (!command) {
2787 sms_log(mac, LOGE, FL("Base address is NULL"));
2788 return CDF_STATUS_E_FAILURE;
2789 }
2790
2791 if (e_sme_command_nss_update != command->command) {
2792 sms_log(mac, LOGE, FL("Command mismatch!"));
2793 return CDF_STATUS_E_FAILURE;
2794 }
2795
2796 callback = command->u.nss_update_cmd.nss_update_cb;
2797 if (callback) {
2798 if (!param) {
2799 sms_log(mac, LOGE,
2800 FL("Callback failed since nss update params is NULL"));
2801 } else {
2802 sms_log(mac, LOGE,
2803 FL("Calling HDD callback for nss update response"));
2804 callback(command->u.nss_update_cmd.context,
2805 param->tx_status,
2806 param->session_id,
2807 command->u.nss_update_cmd.next_action);
2808 }
2809 } else {
2810 sms_log(mac, LOGE, FL("Callback does not exisit"));
2811 }
2812
2813 found = csr_ll_remove_entry(&mac->sme.smeCmdActiveList, entry,
2814 LL_ACCESS_LOCK);
2815 if (found) {
2816 /* Now put this command back on the avilable command list */
2817 sme_release_command(mac, command);
2818 }
2819 sme_process_pending_queue(mac);
2820 return CDF_STATUS_SUCCESS;
2821}
2822
2823/* No need to hold the global lock here because this function can only be called */
2824/* after sme_stop. */
2825void sme_free_msg(tHalHandle hHal, cds_msg_t *pMsg)
2826{
2827 if (pMsg) {
2828 if (pMsg->bodyptr) {
2829 cdf_mem_free(pMsg->bodyptr);
2830 }
2831 }
2832
2833}
2834
2835/*--------------------------------------------------------------------------
2836
2837 \brief sme_stop() - Stop all SME modules and put them at idle state
2838
2839 The function stops each module in SME, PMC, CSR, etc. . Upon
2840 return, all modules are at idle state ready to start.
2841
2842 This is a synchronous call
2843 \param hHal - The handle returned by mac_open
2844 \param tHalStopType - reason for stopping
2845
2846 \return CDF_STATUS_SUCCESS - SME is stopped.
2847
2848 Other status means SME is failed to stop but caller should still
2849 consider SME is stopped.
2850 \sa
2851
2852 --------------------------------------------------------------------------*/
2853CDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
2854{
2855 CDF_STATUS status = CDF_STATUS_E_FAILURE;
2856 CDF_STATUS fail_status = CDF_STATUS_SUCCESS;
2857 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2858
2859#ifndef WLAN_FEATURE_MBSSID
2860 status = wlansap_stop(cds_get_global_context());
2861 if (!CDF_IS_STATUS_SUCCESS(status)) {
2862 sms_log(pMac, LOGE,
2863 "wlansap_stop failed during smeStop with status=%d",
2864 status);
2865 fail_status = status;
2866 }
2867#endif
2868
2869 p2p_stop(hHal);
2870
2871 status = csr_stop(pMac, stopType);
2872 if (!CDF_IS_STATUS_SUCCESS(status)) {
2873 sms_log(pMac, LOGE,
2874 "csr_stop failed during smeStop with status=%d", status);
2875 fail_status = status;
2876 }
2877
2878 purge_sme_cmd_list(pMac);
2879
2880 if (!CDF_IS_STATUS_SUCCESS(fail_status)) {
2881 status = fail_status;
2882 }
2883
2884 pMac->sme.state = SME_STATE_STOP;
2885
2886 return status;
2887}
2888
2889/*--------------------------------------------------------------------------
2890
2891 \brief sme_close() - Release all SME modules and their resources.
2892
2893 The function release each module in SME, PMC, CSR, etc. . Upon
2894 return, all modules are at closed state.
2895
2896 No SME APIs can be involved after smeClose except smeOpen.
2897 smeClose must be called before mac_close.
2898 This is a synchronous call
2899 \param hHal - The handle returned by mac_open
2900
2901 \return CDF_STATUS_SUCCESS - SME is successfully close.
2902
2903 Other status means SME is failed to be closed but caller still cannot
2904 call any other SME functions except smeOpen.
2905 \sa
2906
2907 --------------------------------------------------------------------------*/
2908CDF_STATUS sme_close(tHalHandle hHal)
2909{
2910 CDF_STATUS status = CDF_STATUS_E_FAILURE;
2911 CDF_STATUS fail_status = CDF_STATUS_SUCCESS;
2912 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2913
2914 if (!pMac)
2915 return CDF_STATUS_E_FAILURE;
2916
2917 /* Note: pSession will be invalid from here on, do not access */
2918 status = csr_close(pMac);
2919 if (!CDF_IS_STATUS_SUCCESS(status)) {
2920 sms_log(pMac, LOGE,
2921 "csr_close failed during sme close with status=%d",
2922 status);
2923 fail_status = status;
2924 }
2925#ifndef WLAN_FEATURE_MBSSID
2926 status = wlansap_close(cds_get_global_context());
2927 if (!CDF_IS_STATUS_SUCCESS(status)) {
2928 sms_log(pMac, LOGE,
2929 "WLANSAP_close failed during sme close with status=%d",
2930 status);
2931 fail_status = status;
2932 }
2933#endif
2934
2935#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2936 status = sme_qos_close(pMac);
2937 if (!CDF_IS_STATUS_SUCCESS(status)) {
2938 sms_log(pMac, LOGE,
2939 "Qos close failed during sme close with status=%d",
2940 status);
2941 fail_status = status;
2942 }
2943#endif
2944#ifdef FEATURE_OEM_DATA_SUPPORT
2945 status = oem_data_oem_data_req_close(hHal);
2946 if (!CDF_IS_STATUS_SUCCESS(status)) {
2947 sms_log(pMac, LOGE,
2948 "OEM DATA REQ close failed during sme close with status=%d",
2949 status);
2950 fail_status = status;
2951 }
2952#endif
2953 status = sme_ps_close(hHal);
2954 if (!CDF_IS_STATUS_SUCCESS(status)) {
2955 sms_log(pMac, LOGE,
2956 "sme_ps_close failed during smeClose status=%d",
2957 status);
2958 fail_status = status;
2959 }
2960
2961#if defined WLAN_FEATURE_VOWIFI
2962 status = rrm_close(hHal);
2963 if (!CDF_IS_STATUS_SUCCESS(status)) {
2964 sms_log(pMac, LOGE,
2965 "RRM close failed during sme close with status=%d",
2966 status);
2967 fail_status = status;
2968 }
2969#endif
2970
2971 sme_p2p_close(hHal);
2972
2973 free_sme_cmd_list(pMac);
2974
2975 if (!CDF_IS_STATUS_SUCCESS
2976 (cdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock))) {
2977 fail_status = CDF_STATUS_E_FAILURE;
2978 }
2979
2980 if (!CDF_IS_STATUS_SUCCESS(fail_status)) {
2981 status = fail_status;
2982 }
2983
2984 pMac->sme.state = SME_STATE_STOP;
2985
2986 return status;
2987}
2988
2989/**
2990 * sme_scan_request() - wrapper function to Request a 11d or full scan from CSR.
2991 * @hal: hal global context
2992 * @session_id: session id
2993 * @scan_req: scan req
2994 * @callback: a callback function that scan calls upon finish, will not
2995 * be called if csr_scan_request returns error
2996 * @ctx: a pointer passed in for the callback
2997 *
2998 * This is a wrapper function to Request a 11d or full scan from CSR. This is
2999 * an asynchronous call
3000 *
3001 * Return: Status of operation
3002 */
3003CDF_STATUS sme_scan_request(tHalHandle hal, uint8_t session_id,
3004 tCsrScanRequest *scan_req,
3005 csr_scan_completeCallback callback, void *ctx)
3006{
3007 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3008 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
3009 struct ani_scan_req *scan_msg;
3010 cds_msg_t msg;
3011 uint32_t scan_req_id, scan_count;
3012
3013 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3014 TRACE_CODE_SME_RX_HDD_MSG_SCAN_REQ, session_id,
3015 scan_req->scanType));
3016 if (!mac_ctx->scan.fScanEnable) {
3017 sms_log(mac_ctx, LOGE, FL("fScanEnable false"));
3018 return status;
3019 }
3020
3021 scan_count = csr_ll_count(&mac_ctx->sme.smeScanCmdActiveList);
3022 if (scan_count >= mac_ctx->scan.max_scan_count) {
3023 sms_log(mac_ctx, LOGE, FL("Max scan reached"));
3024 return CDF_STATUS_E_FAILURE;
3025 }
3026 wma_get_scan_id(&scan_req_id);
3027 scan_req->scan_id = scan_req_id;
3028
3029 status = sme_acquire_global_lock(&mac_ctx->sme);
3030 if (!CDF_IS_STATUS_SUCCESS(status)) {
3031 sms_log(mac_ctx, LOGE, FL("Unable to acquire lock"));
3032 return status;
3033 }
3034 sms_log(mac_ctx, LOG1, FL(" called"));
3035 scan_msg = cdf_mem_malloc(sizeof(struct ani_scan_req));
3036 if (NULL == scan_msg) {
3037 sms_log(mac_ctx, LOGE,
3038 " scan_req: failed to allocate mem for msg");
3039 sme_release_global_lock(&mac_ctx->sme);
3040 return CDF_STATUS_E_NOMEM;
3041 }
3042 scan_msg->msg_type = eWNI_SME_SCAN_CMD;
3043 scan_msg->msg_len = (uint16_t) sizeof(struct ani_scan_req);
3044 scan_msg->session_id = session_id;
3045 scan_msg->callback = callback;
3046 scan_msg->ctx = ctx;
3047 scan_msg->scan_param = cdf_mem_malloc(sizeof(tCsrScanRequest));
3048 if (NULL == scan_msg->scan_param) {
3049 sms_log(mac_ctx, LOGE,
3050 "scan_req:failed to allocate mem for scanreq");
3051 sme_release_global_lock(&mac_ctx->sme);
3052 cdf_mem_free(scan_msg);
3053 return CDF_STATUS_E_NOMEM;
3054 }
3055 csr_scan_copy_request(mac_ctx, scan_msg->scan_param, scan_req);
3056 msg.type = eWNI_SME_SCAN_CMD;
3057 msg.bodyptr = scan_msg;
3058 msg.reserved = 0;
3059 msg.bodyval = 0;
3060 if (CDF_STATUS_SUCCESS !=
3061 cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
3062 sms_log(mac_ctx, LOGE,
3063 " sme_scan_req failed to post msg");
3064 csr_scan_free_request(mac_ctx, scan_msg->scan_param);
3065 cdf_mem_free(scan_msg);
3066 status = CDF_STATUS_E_FAILURE;
3067 }
3068 sme_release_global_lock(&mac_ctx->sme);
3069 return status;
3070}
3071
3072/* ---------------------------------------------------------------------------
3073 \fn sme_scan_get_result
3074 \brief a wrapper function to request scan results from CSR.
3075 This is a synchronous call
3076 \param pFilter - If pFilter is NULL, all cached results are returned
3077 \param phResult - an object for the result.
3078 \return CDF_STATUS
3079 ---------------------------------------------------------------------------*/
3080CDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
3081 tCsrScanResultFilter *pFilter,
3082 tScanResultHandle *phResult)
3083{
3084 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3085 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3086
3087 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3088 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
3089 0));
3090 sms_log(pMac, LOG2, FL("enter"));
3091 status = sme_acquire_global_lock(&pMac->sme);
3092 if (CDF_IS_STATUS_SUCCESS(status)) {
3093 status = csr_scan_get_result(hHal, pFilter, phResult);
3094 sme_release_global_lock(&pMac->sme);
3095 }
3096 sms_log(pMac, LOG2, FL("exit status %d"), status);
3097
3098 return status;
3099}
3100
3101/**
3102 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
3103 * channel id from CSR by filtering the
3104 * result which matches our roam profile.
3105 * @profile: SAP adapter
3106 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
3107 * best ap from scan cache.
3108 *
3109 * This function is written to get AP's channel id from CSR by filtering
3110 * the result which matches our roam profile. This is a synchronous call.
3111 *
3112 * Return: CDF_STATUS.
3113 */
3114CDF_STATUS sme_get_ap_channel_from_scan_cache(tHalHandle hal_handle,
3115 tCsrRoamProfile *profile,
3116 tScanResultHandle *scan_cache,
3117 uint8_t *ap_chnl_id)
3118{
3119 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3120 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
3121 tCsrScanResultFilter *scan_filter = NULL;
3122 tScanResultHandle filtered_scan_result = NULL;
3123 tSirBssDescription first_ap_profile;
3124
3125 if (NULL == mac_ctx) {
3126 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3127 FL("mac_ctx is NULL"));
3128 return CDF_STATUS_E_FAILURE;
3129 }
3130 scan_filter = cdf_mem_malloc(sizeof(tCsrScanResultFilter));
3131 if (NULL == scan_filter) {
3132 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3133 FL("scan_filter mem alloc failed"));
3134 return CDF_STATUS_E_FAILURE;
3135 } else {
3136 cdf_mem_set(scan_filter, sizeof(tCsrScanResultFilter), 0);
3137 cdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
3138
3139 if (NULL == profile) {
3140 scan_filter->EncryptionType.numEntries = 1;
3141 scan_filter->EncryptionType.encryptionType[0]
3142 = eCSR_ENCRYPT_TYPE_NONE;
3143 } else {
3144 /* Here is the profile we need to connect to */
3145 status = csr_roam_prepare_filter_from_profile(mac_ctx,
3146 profile,
3147 scan_filter);
3148 }
3149
3150 if (CDF_STATUS_SUCCESS == status) {
3151 /* Save the WPS info */
3152 if (NULL != profile) {
3153 scan_filter->bWPSAssociation =
3154 profile->bWPSAssociation;
3155 scan_filter->bOSENAssociation =
3156 profile->bOSENAssociation;
3157 } else {
3158 scan_filter->bWPSAssociation = 0;
3159 scan_filter->bOSENAssociation = 0;
3160 }
3161 } else {
3162 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3163 FL("Preparing the profile filter failed"));
3164 cdf_mem_free(scan_filter);
3165 return CDF_STATUS_E_FAILURE;
3166 }
3167 }
3168 status = sme_acquire_global_lock(&mac_ctx->sme);
3169 if (CDF_STATUS_SUCCESS == status) {
3170 status = csr_scan_get_result(hal_handle, scan_filter,
3171 &filtered_scan_result);
3172 if (CDF_STATUS_SUCCESS == status) {
3173 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
3174 &first_ap_profile);
3175 *scan_cache = filtered_scan_result;
3176 if (0 != first_ap_profile.channelId) {
3177 *ap_chnl_id = first_ap_profile.channelId;
3178 CDF_TRACE(CDF_MODULE_ID_SME,
3179 CDF_TRACE_LEVEL_ERROR,
3180 FL("Found best AP & its on chnl[%d]"),
3181 first_ap_profile.channelId);
3182 } else {
3183 /*
3184 * This means scan result is empty
3185 * so set the channel to zero, caller should
3186 * take of zero channel id case.
3187 */
3188 *ap_chnl_id = 0;
3189 CDF_TRACE(CDF_MODULE_ID_SME,
3190 CDF_TRACE_LEVEL_ERROR,
3191 FL("Scan is empty, set chnl to 0"));
3192 status = CDF_STATUS_E_FAILURE;
3193 }
3194 } else {
3195 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3196 FL("Failed to get scan get result"));
3197 status = CDF_STATUS_E_FAILURE;
3198 }
3199 csr_free_scan_filter(mac_ctx, scan_filter);
3200 sme_release_global_lock(&mac_ctx->sme);
3201 } else {
3202 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3203 FL("Aquiring lock failed"));
3204 status = CDF_STATUS_E_FAILURE;
3205 }
3206
3207 cdf_mem_free(scan_filter);
3208
3209 return status;
3210}
3211
3212/**
3213 * sme_store_joinreq_param() - This function will pass station's join
3214 * request to store to csr.
3215 * @hal_handle: pointer to hal context.
3216 * @profile: pointer to station's roam profile.
3217 * @scan_cache: pointer to station's scan cache.
3218 * @roam_id: reference to roam_id variable being passed.
3219 * @session_id: station's session id.
3220 *
3221 * This function will pass station's join request further down to csr
3222 * to store it. this stored parameter will be used later.
3223 *
3224 * Return: true or false based on function's overall success.
3225 **/
3226bool sme_store_joinreq_param(tHalHandle hal_handle,
3227 tCsrRoamProfile *profile,
3228 tScanResultHandle scan_cache,
3229 uint32_t *roam_id,
3230 uint32_t session_id)
3231{
3232 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
3233 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3234 bool ret_status = true;
3235
3236 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3237 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
3238 session_id, 0));
3239 status = sme_acquire_global_lock(&mac_ctx->sme);
3240 if (CDF_STATUS_SUCCESS == status) {
3241 if (false == csr_store_joinreq_param(mac_ctx, profile,
3242 scan_cache, roam_id, session_id)) {
3243 ret_status = false;
3244 }
3245 sme_release_global_lock(&mac_ctx->sme);
3246 } else {
3247 ret_status = false;
3248 }
3249
3250 return ret_status;
3251}
3252
3253/**
3254 * sme_clear_joinreq_param() - This function will pass station's clear
3255 * the join request to csr.
3256 * @hal_handle: pointer to hal context.
3257 * @session_id: station's session id.
3258 *
3259 * This function will pass station's clear join request further down to csr
3260 * to cleanup.
3261 *
3262 * Return: true or false based on function's overall success.
3263 **/
3264bool sme_clear_joinreq_param(tHalHandle hal_handle,
3265 uint32_t session_id)
3266{
3267 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
3268 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3269 bool ret_status = true;
3270
3271 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3272 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
3273 session_id, 0));
3274 status = sme_acquire_global_lock(&mac_ctx->sme);
3275 if (CDF_STATUS_SUCCESS == status) {
3276 if (false == csr_clear_joinreq_param(mac_ctx,
3277 session_id)) {
3278 ret_status = false;
3279 }
3280 sme_release_global_lock(&mac_ctx->sme);
3281 } else {
3282 ret_status = false;
3283 }
3284
3285 return ret_status;
3286}
3287
3288/**
3289 * sme_issue_stored_joinreq() - This function will issues station's stored
3290 * the join request to csr.
3291 * @hal_handle: pointer to hal context.
3292 * @roam_id: reference to roam_id variable being passed.
3293 * @session_id: station's session id.
3294 *
3295 * This function will issue station's stored join request further down to csr
3296 * to proceed forward.
3297 *
3298 * Return: CDF_STATUS_SUCCESS or CDF_STATUS_E_FAILURE.
3299 **/
3300CDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
3301 uint32_t *roam_id,
3302 uint32_t session_id)
3303{
3304 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
3305 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3306 CDF_STATUS ret_status = CDF_STATUS_SUCCESS;
3307
3308 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3309 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
3310 session_id, 0));
3311 status = sme_acquire_global_lock(&mac_ctx->sme);
3312 if (CDF_STATUS_SUCCESS == status) {
3313 if (CDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
3314 roam_id,
3315 session_id)) {
3316 ret_status = CDF_STATUS_E_FAILURE;
3317 }
3318 sme_release_global_lock(&mac_ctx->sme);
3319 } else {
3320 csr_clear_joinreq_param(mac_ctx, session_id);
3321 ret_status = CDF_STATUS_E_FAILURE;
3322 }
3323 return ret_status;
3324}
3325
3326/* ---------------------------------------------------------------------------
3327 \fn sme_scan_flush_result
3328 \brief a wrapper function to request CSR to clear scan results.
3329 This is a synchronous call
3330 \return CDF_STATUS
3331 ---------------------------------------------------------------------------*/
3332CDF_STATUS sme_scan_flush_result(tHalHandle hHal)
3333{
3334 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3335 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3336
3337 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3338 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
3339 0, 0));
3340 status = sme_acquire_global_lock(&pMac->sme);
3341 if (CDF_IS_STATUS_SUCCESS(status)) {
3342 status = csr_scan_flush_result(hHal);
3343 sme_release_global_lock(&pMac->sme);
3344 }
3345
3346 return status;
3347}
3348
3349/* ---------------------------------------------------------------------------
3350 \fn sme_filter_scan_results
3351 \brief a wrapper function to request CSR to clear scan results.
3352 This is a synchronous call
3353 \param tHalHandle - HAL context handle
3354 \param sessionId - session id
3355 \return CDF_STATUS
3356 ---------------------------------------------------------------------------*/
3357CDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
3358{
3359 CDF_STATUS status = CDF_STATUS_SUCCESS;
3360 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3361
3362 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3363 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
3364 sessionId, 0));
3365 status = sme_acquire_global_lock(&pMac->sme);
3366 if (CDF_IS_STATUS_SUCCESS(status)) {
3367 csr_scan_filter_results(pMac);
3368 sme_release_global_lock(&pMac->sme);
3369 }
3370
3371 return status;
3372}
3373
3374CDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
3375{
3376 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3377 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3378
3379 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3380 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
3381 sessionId, 0));
3382 status = sme_acquire_global_lock(&pMac->sme);
3383 if (CDF_IS_STATUS_SUCCESS(status)) {
3384 status = csr_scan_flush_selective_result(hHal, true);
3385 sme_release_global_lock(&pMac->sme);
3386 }
3387
3388 return status;
3389}
3390
3391/* ---------------------------------------------------------------------------
3392 \fn sme_scan_result_get_first
3393 \brief a wrapper function to request CSR to returns the first element of
3394 scan result.
3395 This is a synchronous call
3396 \param hScanResult - returned from csr_scan_get_result
3397 \return tCsrScanResultInfo * - NULL if no result
3398 ---------------------------------------------------------------------------*/
3399tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
3400 tScanResultHandle hScanResult)
3401{
3402 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3403 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3404 tCsrScanResultInfo *pRet = NULL;
3405
3406 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3407 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
3408 NO_SESSION, 0));
3409 status = sme_acquire_global_lock(&pMac->sme);
3410 if (CDF_IS_STATUS_SUCCESS(status)) {
3411 pRet = csr_scan_result_get_first(pMac, hScanResult);
3412 sme_release_global_lock(&pMac->sme);
3413 }
3414
3415 return pRet;
3416}
3417
3418/* ---------------------------------------------------------------------------
3419 \fn sme_scan_result_get_next
3420 \brief a wrapper function to request CSR to returns the next element of
3421 scan result. It can be called without calling csr_scan_result_get_first
3422 first
3423 This is a synchronous call
3424 \param hScanResult - returned from csr_scan_get_result
3425 \return Null if no result or reach the end
3426 ---------------------------------------------------------------------------*/
3427tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
3428 tScanResultHandle hScanResult)
3429{
3430 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3431 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3432 tCsrScanResultInfo *pRet = NULL;
3433
3434 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3435 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETNEXT,
3436 NO_SESSION, 0));
3437 status = sme_acquire_global_lock(&pMac->sme);
3438 if (CDF_IS_STATUS_SUCCESS(status)) {
3439 pRet = csr_scan_result_get_next(pMac, hScanResult);
3440 sme_release_global_lock(&pMac->sme);
3441 }
3442
3443 return pRet;
3444}
3445
3446/* ---------------------------------------------------------------------------
3447 \fn sme_scan_result_purge
3448 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
3449 in the list and free memory for each item
3450 This is a synchronous call
3451 \param hScanResult - returned from csr_scan_get_result. hScanResult is
3452 considered gone by
3453 calling this function and even before this function reutrns.
3454 \return CDF_STATUS
3455 ---------------------------------------------------------------------------*/
3456CDF_STATUS sme_scan_result_purge(tHalHandle hHal, tScanResultHandle hScanResult)
3457{
3458 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3459 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3460
3461 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3462 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3463 NO_SESSION, 0));
3464 status = sme_acquire_global_lock(&pMac->sme);
3465 if (CDF_IS_STATUS_SUCCESS(status)) {
3466 status = csr_scan_result_purge(hHal, hScanResult);
3467 sme_release_global_lock(&pMac->sme);
3468 }
3469
3470 return status;
3471}
3472
3473/* ---------------------------------------------------------------------------
3474 \fn sme_scan_get_pmkid_candidate_list
3475 \brief a wrapper function to return the PMKID candidate list
3476 This is a synchronous call
3477 \param pPmkidList - caller allocated buffer point to an array of
3478 tPmkidCandidateInfo
3479 \param pNumItems - pointer to a variable that has the number of
3480 tPmkidCandidateInfo allocated when retruning, this is
3481 either the number needed or number of items put into
3482 pPmkidList
3483 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
3484 big enough and pNumItems
3485 has the number of tPmkidCandidateInfo.
3486 \Note: pNumItems is a number of tPmkidCandidateInfo,
3487 not sizeof(tPmkidCandidateInfo) * something
3488 ---------------------------------------------------------------------------*/
3489CDF_STATUS sme_scan_get_pmkid_candidate_list(tHalHandle hHal, uint8_t sessionId,
3490 tPmkidCandidateInfo *pPmkidList,
3491 uint32_t *pNumItems)
3492{
3493 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3494 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3495
3496 status = sme_acquire_global_lock(&pMac->sme);
3497 if (CDF_IS_STATUS_SUCCESS(status)) {
3498 status =
3499 csr_scan_get_pmkid_candidate_list(pMac, sessionId,
3500 pPmkidList,
3501 pNumItems);
3502 sme_release_global_lock(&pMac->sme);
3503 }
3504
3505 return status;
3506}
3507
3508eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3509{
3510 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3511 return pMac->roam.configParam.phyMode;
3512}
3513
3514/* ---------------------------------------------------------------------------
3515 \fn sme_get_channel_bonding_mode5_g
3516 \brief get the channel bonding mode for 5G band
3517 \param hHal - HAL handle
3518 \return channel bonding mode for 5G
3519 ---------------------------------------------------------------------------*/
3520uint32_t sme_get_channel_bonding_mode5_g(tHalHandle hHal)
3521{
3522 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3523 tSmeConfigParams smeConfig;
3524
3525 sme_get_config_param(pMac, &smeConfig);
3526
3527 return smeConfig.csrConfig.channelBondingMode5GHz;
3528}
3529
3530/* ---------------------------------------------------------------------------
3531 \fn sme_get_channel_bonding_mode24_g
3532 \brief get the channel bonding mode for 2.4G band
3533 \param hHal - HAL handle
3534 \return channel bonding mode for 2.4G
3535 ---------------------------------------------------------------------------*/
3536uint32_t sme_get_channel_bonding_mode24_g(tHalHandle hHal)
3537{
3538 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3539 tSmeConfigParams smeConfig;
3540
3541 sme_get_config_param(pMac, &smeConfig);
3542
3543 return smeConfig.csrConfig.channelBondingMode24GHz;
3544}
3545
3546/* ---------------------------------------------------------------------------
3547 \fn sme_roam_connect
3548 \brief a wrapper function to request CSR to inititiate an association
3549 This is an asynchronous call.
3550 \param sessionId - the sessionId returned by sme_open_session.
3551 \param pProfile - description of the network to which to connect
3552 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
3553 from csr_scan_get_result
3554 \param pRoamId - to get back the request ID
3555 \return CDF_STATUS
3556 ---------------------------------------------------------------------------*/
3557CDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
3558 tCsrRoamProfile *pProfile, uint32_t *pRoamId)
3559{
3560 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3561 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3562
3563 if (!pMac) {
3564 return CDF_STATUS_E_FAILURE;
3565 }
3566
3567 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3568 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
3569 sms_log(pMac, LOG2, FL("enter"));
3570 status = sme_acquire_global_lock(&pMac->sme);
3571 if (CDF_IS_STATUS_SUCCESS(status)) {
3572 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3573 status =
3574 csr_roam_connect(pMac, sessionId, pProfile,
3575 pRoamId);
3576 } else {
3577 sms_log(pMac, LOGE, FL("invalid sessionID %d"),
3578 sessionId);
3579 status = CDF_STATUS_E_INVAL;
3580 }
3581 sme_release_global_lock(&pMac->sme);
3582 } else {
3583 sms_log(pMac, LOGE, FL("sme_acquire_global_lock failed"));
3584 }
3585
3586 return status;
3587}
3588
3589/* ---------------------------------------------------------------------------
3590
3591 \fn sme_set_phy_mode
3592
3593 \brief Changes the PhyMode.
3594
3595 \param hHal - The handle returned by mac_open.
3596
3597 \param phyMode new phyMode which is to set
3598
3599 \return CDF_STATUS SUCCESS.
3600
3601 -------------------------------------------------------------------------------*/
3602CDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
3603{
3604 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3605
3606 if (NULL == pMac) {
3607 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
3608 "%s: invalid context", __func__);
3609 return CDF_STATUS_E_FAILURE;
3610 }
3611
3612 pMac->roam.configParam.phyMode = phyMode;
3613 pMac->roam.configParam.uCfgDot11Mode =
3614 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
3615 pMac->roam.configParam.phyMode,
3616 pMac->roam.configParam.
3617 ProprietaryRatesEnabled);
3618
3619 return CDF_STATUS_SUCCESS;
3620}
3621
3622/* ---------------------------------------------------------------------------
3623 \fn sme_roam_reassoc
3624 \brief a wrapper function to request CSR to inititiate a re-association
3625 \param pProfile - can be NULL to join the currently connected AP. In that
3626 case modProfileFields should carry the modified field(s) which could trigger
3627 reassoc
3628 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
3629 that might need modification dynamically once STA is up & running and this
3630 could trigger a reassoc
3631 \param pRoamId - to get back the request ID
3632 \return CDF_STATUS
3633 -------------------------------------------------------------------------------*/
3634CDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
3635 tCsrRoamProfile *pProfile,
3636 tCsrRoamModifyProfileFields modProfileFields,
3637 uint32_t *pRoamId, bool fForce)
3638{
3639 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3640 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3641
3642 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3643 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
3644 sms_log(pMac, LOG2, FL("enter"));
3645 status = sme_acquire_global_lock(&pMac->sme);
3646 if (CDF_IS_STATUS_SUCCESS(status)) {
3647 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3648 if ((NULL == pProfile) && (fForce == 1)) {
3649 status =
3650 csr_reassoc(pMac, sessionId,
3651 &modProfileFields, pRoamId,
3652 fForce);
3653 } else {
3654 status =
3655 csr_roam_reassoc(pMac, sessionId, pProfile,
3656 modProfileFields, pRoamId);
3657 }
3658 } else {
3659 status = CDF_STATUS_E_INVAL;
3660 }
3661 sme_release_global_lock(&pMac->sme);
3662 }
3663
3664 return status;
3665}
3666
3667/* ---------------------------------------------------------------------------
3668 \fn sme_roam_connect_to_last_profile
3669 \brief a wrapper function to request CSR to disconnect and reconnect with
3670 the same profile
3671 This is an asynchronous call.
3672 \return CDF_STATUS. It returns fail if currently connected
3673 ---------------------------------------------------------------------------*/
3674CDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
3675{
3676 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3677 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3678
3679 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3680 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3681 sessionId, 0));
3682 status = sme_acquire_global_lock(&pMac->sme);
3683 if (CDF_IS_STATUS_SUCCESS(status)) {
3684 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3685 status = csr_roam_connect_to_last_profile(pMac, sessionId);
3686 } else {
3687 status = CDF_STATUS_E_INVAL;
3688 }
3689 sme_release_global_lock(&pMac->sme);
3690 }
3691
3692 return status;
3693}
3694
3695/* ---------------------------------------------------------------------------
3696 \fn sme_roam_disconnect
3697 \brief a wrapper function to request CSR to disconnect from a network
3698 This is an asynchronous call.
3699 \param reason -- To indicate the reason for disconnecting. Currently, only
3700 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
3701 \return CDF_STATUS
3702 ---------------------------------------------------------------------------*/
3703CDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
3704 eCsrRoamDisconnectReason reason)
3705{
3706 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3707 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3708
3709 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3710 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId,
3711 reason));
3712 sms_log(pMac, LOG2, FL("enter"));
3713 status = sme_acquire_global_lock(&pMac->sme);
3714 if (CDF_IS_STATUS_SUCCESS(status)) {
3715 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3716 status = csr_roam_disconnect(pMac, sessionId, reason);
3717 } else {
3718 status = CDF_STATUS_E_INVAL;
3719 }
3720 sme_release_global_lock(&pMac->sme);
3721 }
3722
3723 return status;
3724}
3725
3726/* ---------------------------------------------------------------------------
3727 \fn sme_roam_stop_bss
3728 \brief To stop BSS for Soft AP. This is an asynchronous API.
3729 \param hHal - Global structure
3730 \param sessionId - sessionId of SoftAP
3731 \return CDF_STATUS SUCCESS Roam callback will be called to indicate actual results
3732 -------------------------------------------------------------------------------*/
3733CDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
3734{
3735 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3736 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3737
3738 sms_log(pMac, LOG2, FL("enter"));
3739 status = sme_acquire_global_lock(&pMac->sme);
3740 if (CDF_IS_STATUS_SUCCESS(status)) {
3741 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3742 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId, true);
3743 } else {
3744 status = CDF_STATUS_E_INVAL;
3745 }
3746 sme_release_global_lock(&pMac->sme);
3747 }
3748
3749 return status;
3750}
3751
3752/* ---------------------------------------------------------------------------
3753 \fn sme_roam_disconnect_sta
3754 \brief To disassociate a station. This is an asynchronous API.
3755 \param hHal - Global structure
3756 \param sessionId - sessionId of SoftAP
3757 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
3758 \return CDF_STATUS SUCCESS Roam callback will be called to indicate actual results
3759 -------------------------------------------------------------------------------*/
3760CDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
3761 const uint8_t *pPeerMacAddr)
3762{
3763 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3764 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3765
3766 if (NULL == pMac) {
3767 CDF_ASSERT(0);
3768 return status;
3769 }
3770
3771 status = sme_acquire_global_lock(&pMac->sme);
3772 if (CDF_IS_STATUS_SUCCESS(status)) {
3773 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3774 status = csr_roam_issue_disassociate_sta_cmd(pMac,
3775 sessionId, pPeerMacAddr,
3776 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
3777 } else {
3778 status = CDF_STATUS_E_INVAL;
3779 }
3780 sme_release_global_lock(&pMac->sme);
3781 }
3782
3783 return status;
3784}
3785
3786/**
3787 * sme_roam_deauth_sta() - deauthenticate a station
3788 * @hHal: Global structure
3789 * @sessionId: SessionId of SoftAP
3790 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3791 *
3792 * To disassociate a station. This is an asynchronous API.
3793 *
3794 * Return: CDF_STATUS_SUCCESS on success or another CDF_STATUS error
3795 * code on error. Roam callback will be called to indicate actual
3796 * result
3797 */
3798CDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
3799 struct tagCsrDelStaParams *pDelStaParams)
3800{
3801 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3802 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3803
3804 if (NULL == pMac) {
3805 CDF_ASSERT(0);
3806 return status;
3807 }
3808
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303809 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3810 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3811 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 status = sme_acquire_global_lock(&pMac->sme);
3813 if (CDF_IS_STATUS_SUCCESS(status)) {
3814 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3815 status =
3816 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3817 pDelStaParams);
3818 } else {
3819 status = CDF_STATUS_E_INVAL;
3820 }
3821 sme_release_global_lock(&pMac->sme);
3822 }
3823
3824 return status;
3825}
3826
3827/* ---------------------------------------------------------------------------
3828 \fn sme_roam_tkip_counter_measures
3829 \brief To start or stop TKIP counter measures. This is an asynchronous API.
3830 \param sessionId - sessionId of SoftAP
3831 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
3832 \return CDF_STATUS
3833 -------------------------------------------------------------------------------*/
3834CDF_STATUS sme_roam_tkip_counter_measures(tHalHandle hHal, uint8_t sessionId,
3835 bool bEnable)
3836{
3837 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3838 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3839
3840 if (NULL == pMac) {
3841 CDF_ASSERT(0);
3842 return status;
3843 }
3844
3845 status = sme_acquire_global_lock(&pMac->sme);
3846 if (CDF_IS_STATUS_SUCCESS(status)) {
3847 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3848 status =
3849 csr_roam_issue_tkip_counter_measures(pMac, sessionId,
3850 bEnable);
3851 } else {
3852 status = CDF_STATUS_E_INVAL;
3853 }
3854 sme_release_global_lock(&pMac->sme);
3855 }
3856
3857 return status;
3858}
3859
3860/* ---------------------------------------------------------------------------
3861 \fn sme_roam_get_associated_stas
3862 \brief To probe the list of associated stations from various modules
3863 of CORE stack.
3864 \This is an asynchronous API.
3865 \param sessionId - sessionId of SoftAP
3866 \param modId - Module from whom list of associtated stations is
3867 to be probed. If an invalid module is passed then
3868 by default CDF_MODULE_ID_PE will be probed.
3869 \param pUsrContext - Opaque HDD context
3870 \param pfnSapEventCallback - Sap event callback in HDD
3871 \param pAssocBuf - Caller allocated memory to be filled with associatd
3872 stations info
3873 \return CDF_STATUS
3874 -------------------------------------------------------------------------------*/
3875CDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
3876 CDF_MODULE_ID modId, void *pUsrContext,
3877 void *pfnSapEventCallback,
3878 uint8_t *pAssocStasBuf)
3879{
3880 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3881 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3882
3883 if (NULL == pMac) {
3884 CDF_ASSERT(0);
3885 return status;
3886 }
3887
3888 status = sme_acquire_global_lock(&pMac->sme);
3889 if (CDF_IS_STATUS_SUCCESS(status)) {
3890 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3891 status =
3892 csr_roam_get_associated_stas(pMac, sessionId, modId,
3893 pUsrContext,
3894 pfnSapEventCallback,
3895 pAssocStasBuf);
3896 } else {
3897 status = CDF_STATUS_E_INVAL;
3898 }
3899 sme_release_global_lock(&pMac->sme);
3900 }
3901
3902 return status;
3903}
3904
3905/* ---------------------------------------------------------------------------
3906 \fn sme_roam_get_wps_session_overlap
3907 \brief To get the WPS PBC session overlap information.
3908 \This is an asynchronous API.
3909 \param sessionId - sessionId of SoftAP
3910 \param pUsrContext - Opaque HDD context
3911 \param pfnSapEventCallback - Sap event callback in HDD
3912 \pRemoveMac - pointer to Mac address which needs to be removed from session
3913 \return CDF_STATUS
3914 -------------------------------------------------------------------------------*/
3915CDF_STATUS sme_roam_get_wps_session_overlap(tHalHandle hHal, uint8_t sessionId,
3916 void *pUsrContext, void
3917 *pfnSapEventCallback,
3918 struct cdf_mac_addr pRemoveMac)
3919{
3920 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3921 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3922
3923 if (NULL == pMac) {
3924 CDF_ASSERT(0);
3925 return status;
3926 }
3927
3928 status = sme_acquire_global_lock(&pMac->sme);
3929 if (CDF_IS_STATUS_SUCCESS(status)) {
3930 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3931 status =
3932 csr_roam_get_wps_session_overlap(pMac, sessionId,
3933 pUsrContext,
3934 pfnSapEventCallback,
3935 pRemoveMac);
3936 } else {
3937 status = CDF_STATUS_E_INVAL;
3938 }
3939 sme_release_global_lock(&pMac->sme);
3940 }
3941
3942 return status;
3943}
3944
3945/* ---------------------------------------------------------------------------
3946 \fn sme_roam_get_connect_state
3947 \brief a wrapper function to request CSR to return the current connect state
3948 of Roaming
3949 This is a synchronous call.
3950 \return CDF_STATUS
3951 ---------------------------------------------------------------------------*/
3952CDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
3953 eCsrConnectState *pState)
3954{
3955 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3956 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3957
3958 status = sme_acquire_global_lock(&pMac->sme);
3959 if (CDF_IS_STATUS_SUCCESS(status)) {
3960 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3961 status =
3962 csr_roam_get_connect_state(pMac, sessionId, pState);
3963 } else {
3964 status = CDF_STATUS_E_INVAL;
3965 }
3966 sme_release_global_lock(&pMac->sme);
3967 }
3968
3969 return status;
3970}
3971
3972/* ---------------------------------------------------------------------------
3973 \fn sme_roam_get_connect_profile
3974 \brief a wrapper function to request CSR to return the current connect
3975 profile. Caller must call csr_roam_free_connect_profile after it is done
3976 and before reuse for another csr_roam_get_connect_profile call.
3977 This is a synchronous call.
3978 \param pProfile - pointer to a caller allocated structure
3979 tCsrRoamConnectedProfile
3980 \return CDF_STATUS. Failure if not connected
3981 ---------------------------------------------------------------------------*/
3982CDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
3983 tCsrRoamConnectedProfile *pProfile)
3984{
3985 CDF_STATUS status = CDF_STATUS_E_FAILURE;
3986 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3987
3988 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
3989 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3990 sessionId, 0));
3991 status = sme_acquire_global_lock(&pMac->sme);
3992 if (CDF_IS_STATUS_SUCCESS(status)) {
3993 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3994 status =
3995 csr_roam_get_connect_profile(pMac, sessionId, pProfile);
3996 } else {
3997 status = CDF_STATUS_E_INVAL;
3998 }
3999 sme_release_global_lock(&pMac->sme);
4000 }
4001
4002 return status;
4003}
4004
4005/* ---------------------------------------------------------------------------
4006 \fn sme_roam_free_connect_profile
4007 \brief a wrapper function to request CSR to free and reinitialize the
4008 profile returned previously by csr_roam_get_connect_profile.
4009 This is a synchronous call.
4010 \param pProfile - pointer to a caller allocated structure
4011 tCsrRoamConnectedProfile
4012 \return CDF_STATUS.
4013 ---------------------------------------------------------------------------*/
4014CDF_STATUS sme_roam_free_connect_profile(tHalHandle hHal,
4015 tCsrRoamConnectedProfile *pProfile)
4016{
4017 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4018 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4019
4020 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4021 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
4022 NO_SESSION, 0));
4023 status = sme_acquire_global_lock(&pMac->sme);
4024 if (CDF_IS_STATUS_SUCCESS(status)) {
4025 status = csr_roam_free_connect_profile(pMac, pProfile);
4026 sme_release_global_lock(&pMac->sme);
4027 }
4028
4029 return status;
4030}
4031
4032/* ---------------------------------------------------------------------------
4033 \fn sme_roam_set_pmkid_cache
4034 \brief a wrapper function to request CSR to return the PMKID candidate list
4035 This is a synchronous call.
4036 \param pPMKIDCache - caller allocated buffer point to an array of
4037 tPmkidCacheInfo
4038 \param numItems - a variable that has the number of tPmkidCacheInfo
4039 allocated when retruning, this is either the number needed
4040 or number of items put into pPMKIDCache
4041 \param update_entire_cache - this bool value specifies if the entire pmkid
4042 cache should be overwritten or should it be
4043 updated entry by entry.
4044 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
4045 big enough and pNumItems has the number of
4046 tPmkidCacheInfo.
4047 \Note: pNumItems is a number of tPmkidCacheInfo,
4048 not sizeof(tPmkidCacheInfo) * something
4049 ---------------------------------------------------------------------------*/
4050CDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
4051 tPmkidCacheInfo *pPMKIDCache,
4052 uint32_t numItems, bool update_entire_cache)
4053{
4054 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4055 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4056
4057 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4058 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
4059 numItems));
4060 status = sme_acquire_global_lock(&pMac->sme);
4061 if (CDF_IS_STATUS_SUCCESS(status)) {
4062 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4063 status =
4064 csr_roam_set_pmkid_cache(pMac, sessionId, pPMKIDCache,
4065 numItems, update_entire_cache);
4066 } else {
4067 status = CDF_STATUS_E_INVAL;
4068 }
4069 sme_release_global_lock(&pMac->sme);
4070 }
4071
4072 return status;
4073}
4074
4075CDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
4076 const uint8_t *pBSSId, bool flush_cache)
4077{
4078 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4079 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05304080
4081 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4082 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
4083 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 status = sme_acquire_global_lock(&pMac->sme);
4085 if (CDF_IS_STATUS_SUCCESS(status)) {
4086 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4087 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
4088 pBSSId, flush_cache);
4089 } else {
4090 status = CDF_STATUS_E_INVAL;
4091 }
4092 sme_release_global_lock(&pMac->sme);
4093 }
4094 return status;
4095}
4096
4097#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4098/* ---------------------------------------------------------------------------
4099 * \fn sme_roam_set_psk_pmk
4100 * \brief a wrapper function to request CSR to save PSK/PMK
4101 * This is a synchronous call.
4102 * \param hHal - Global structure
4103 * \param sessionId - SME sessionId
4104 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
4105 * \param pmk_len - Length could be only 16 bytes in case if LEAP
4106 * connections. Need to pass this information to
4107 * firmware.
4108 * \return CDF_STATUS -status whether PSK/PMK is set or not
4109 *---------------------------------------------------------------------------
4110 */
4111CDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
4112 uint8_t *pPSK_PMK, size_t pmk_len)
4113{
4114 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4115 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4116 status = sme_acquire_global_lock(&pMac->sme);
4117 if (CDF_IS_STATUS_SUCCESS(status)) {
4118 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4119 status =
4120 csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
4121 pmk_len);
4122 } else {
4123 status = CDF_STATUS_E_INVAL;
4124 }
4125 sme_release_global_lock(&pMac->sme);
4126 }
4127 return status;
4128}
4129#endif
4130/* ---------------------------------------------------------------------------
4131 \fn sme_roam_get_security_req_ie
4132 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
4133 passes to PE to JOIN request or START_BSS request
4134 This is a synchronous call.
4135 \param pLen - caller allocated memory that has the length of pBuf as input.
4136 Upon returned, *pLen has the needed or IE length in pBuf.
4137 \param pBuf - Caller allocated memory that contain the IE field, if any,
4138 upon return
4139 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
4140 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
4141 big enough
4142 ---------------------------------------------------------------------------*/
4143CDF_STATUS sme_roam_get_security_req_ie(tHalHandle hHal, uint8_t sessionId,
4144 uint32_t *pLen, uint8_t *pBuf,
4145 eCsrSecurityType secType)
4146{
4147 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4148 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4149
4150 status = sme_acquire_global_lock(&pMac->sme);
4151 if (CDF_IS_STATUS_SUCCESS(status)) {
4152 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4153 status =
4154 csr_roam_get_wpa_rsn_req_ie(hHal, sessionId, pLen, pBuf);
4155 } else {
4156 status = CDF_STATUS_E_INVAL;
4157 }
4158 sme_release_global_lock(&pMac->sme);
4159 }
4160
4161 return status;
4162}
4163
4164/* ---------------------------------------------------------------------------
4165 \fn sme_roam_get_security_rsp_ie
4166 \brief a wrapper function to request CSR to return the WPA or RSN or
4167 WAPI IE from the beacon or probe rsp if connected
4168 This is a synchronous call.
4169 \param pLen - caller allocated memory that has the length of pBuf as input.
4170 Upon returned, *pLen has the needed or IE length in pBuf.
4171 \param pBuf - Caller allocated memory that contain the IE field, if any,
4172 upon return
4173 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
4174 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
4175 big enough
4176 ---------------------------------------------------------------------------*/
4177CDF_STATUS sme_roam_get_security_rsp_ie(tHalHandle hHal, uint8_t sessionId,
4178 uint32_t *pLen, uint8_t *pBuf,
4179 eCsrSecurityType secType)
4180{
4181 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4182 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4183
4184 status = sme_acquire_global_lock(&pMac->sme);
4185 if (CDF_IS_STATUS_SUCCESS(status)) {
4186 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4187 status =
4188 csr_roam_get_wpa_rsn_rsp_ie(pMac, sessionId, pLen, pBuf);
4189 } else {
4190 status = CDF_STATUS_E_INVAL;
4191 }
4192 sme_release_global_lock(&pMac->sme);
4193 }
4194
4195 return status;
4196
4197}
4198
4199/* ---------------------------------------------------------------------------
4200 \fn sme_roam_get_num_pmkid_cache
4201 \brief a wrapper function to request CSR to return number of PMKID cache
4202 entries
4203 This is a synchronous call.
4204 \return uint32_t - the number of PMKID cache entries
4205 ---------------------------------------------------------------------------*/
4206uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
4207{
4208 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4209 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4210 uint32_t numPmkidCache = 0;
4211
4212 status = sme_acquire_global_lock(&pMac->sme);
4213 if (CDF_IS_STATUS_SUCCESS(status)) {
4214 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4215 numPmkidCache =
4216 csr_roam_get_num_pmkid_cache(pMac, sessionId);
4217 status = CDF_STATUS_SUCCESS;
4218 } else {
4219 status = CDF_STATUS_E_INVAL;
4220 }
4221 sme_release_global_lock(&pMac->sme);
4222 }
4223
4224 return numPmkidCache;
4225}
4226
4227/* ---------------------------------------------------------------------------
4228 \fn sme_roam_get_pmkid_cache
4229 \brief a wrapper function to request CSR to return PMKID cache from CSR
4230 This is a synchronous call.
4231 \param pNum - caller allocated memory that has the space of the number of
4232 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
4233 needed or actually number in tPmkidCacheInfo.
4234 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
4235 any, upon return
4236 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
4237 big enough
4238 ---------------------------------------------------------------------------*/
4239CDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
4240 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
4241{
4242 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4243 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4244
4245 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4246 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
4247 0));
4248 status = sme_acquire_global_lock(&pMac->sme);
4249 if (CDF_IS_STATUS_SUCCESS(status)) {
4250 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4251 status =
4252 csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
4253 pPmkidCache);
4254 } else {
4255 status = CDF_STATUS_E_INVAL;
4256 }
4257 sme_release_global_lock(&pMac->sme);
4258 }
4259
4260 return status;
4261}
4262
4263/* ---------------------------------------------------------------------------
4264 \fn sme_get_config_param
4265 \brief a wrapper function that HDD calls to get the global settings
4266 currently maintained by CSR.
4267 This is a synchronous call.
4268 \param pParam - caller allocated memory
4269 \return CDF_STATUS
4270 ---------------------------------------------------------------------------*/
4271CDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
4272{
4273 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4274 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4275
4276 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4277 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
4278 status = sme_acquire_global_lock(&pMac->sme);
4279 if (CDF_IS_STATUS_SUCCESS(status)) {
4280 status = csr_get_config_param(pMac, &pParam->csrConfig);
4281 if (status != CDF_STATUS_SUCCESS) {
4282 sms_log(pMac, LOGE, "%s csr_get_config_param failed",
4283 __func__);
4284 sme_release_global_lock(&pMac->sme);
4285 return status;
4286 }
4287#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
4288 pParam->sap_channel_avoidance = pMac->sap.sap_channel_avoidance;
4289#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
4290 pParam->max_intf_count = pMac->sme.max_intf_count;
4291 pParam->enableSelfRecovery = pMac->sme.enableSelfRecovery;
4292 pParam->f_prefer_non_dfs_on_radar =
4293 pMac->f_prefer_non_dfs_on_radar;
4294 pParam->policy_manager_enabled = pMac->policy_manager_enabled;
4295 pParam->fine_time_meas_cap = pMac->fine_time_meas_cap;
4296 pParam->dual_mac_feature_disable =
4297 pMac->dual_mac_feature_disable;
4298 pParam->is_ps_enabled = pMac->sme.ps_global_info.ps_enabled;
4299 pParam->pnoOffload = pMac->pnoOffload;
4300 pParam->fEnableDebugLog = pMac->fEnableDebugLog;
4301 pParam->enable5gEBT = pMac->enable5gEBT;
4302 pParam->f_sta_miracast_mcc_rest_time_val =
4303 pMac->f_sta_miracast_mcc_rest_time_val;
Varun Reddy Yeturub43fda12015-09-10 18:16:21 -07004304 sme_update_roam_pno_channel_prediction_config(pMac, pParam,
4305 ROAM_CONFIG_TO_SME_CONFIG);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07004306 pParam->early_stop_scan_enable =
4307 pMac->roam.configParam.early_stop_scan_enable;
4308 pParam->early_stop_scan_min_threshold =
4309 pMac->roam.configParam.early_stop_scan_min_threshold;
4310 pParam->early_stop_scan_max_threshold =
4311 pMac->roam.configParam.early_stop_scan_max_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 sme_release_global_lock(&pMac->sme);
4313 }
4314
4315 return status;
4316}
4317
4318/**
4319 * sme_cfg_set_int() - Sets the cfg parameter value.
4320 * @hal: Handle to hal.
4321 * @cfg_id: Configuration parameter ID.
4322 * @value: value to be saved in the cfg parameter.
4323 *
4324 * This function sets the string value in cfg parameter.
4325 *
4326 * Return: CDF_STATUS
4327 */
4328CDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
4329{
4330 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4331 CDF_STATUS status = CDF_STATUS_SUCCESS;
4332
4333 if (eSIR_SUCCESS != cfg_set_int(pmac, cfg_id, value))
4334 status = CDF_STATUS_E_FAILURE;
4335
4336 return status;
4337}
4338
4339/**
4340 * sme_cfg_set_str() - Sets the cfg parameter string.
4341 * @hal: Handle to hal.
4342 * @cfg_id: Configuration parameter ID.
4343 * @str: Pointer to the string buffer.
4344 * @length: Length of the string.
4345 *
4346 * This function sets the string value in cfg parameter.
4347 *
4348 * Return: CDF_STATUS
4349 */
4350CDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
4351 uint32_t length)
4352{
4353 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4354 CDF_STATUS status = CDF_STATUS_SUCCESS;
4355
4356 if (eSIR_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
4357 status = CDF_STATUS_E_FAILURE;
4358
4359 return status;
4360}
4361
4362/**
4363 * sme_cfg_get_int() - Gets the cfg parameter value.
4364 * @hal: Handle to hal.
4365 * @cfg_id: Configuration parameter ID.
4366 * @cfg_value: Pointer to variable in which cfg value
4367 * will be saved.
4368 *
4369 * This function gets the value of the cfg parameter.
4370 *
4371 * Return: CDF_STATUS
4372 */
4373CDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
4374{
4375 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4376 CDF_STATUS status = CDF_STATUS_SUCCESS;
4377
4378 if (eSIR_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
4379 status = CDF_STATUS_E_FAILURE;
4380
4381 return status;
4382}
4383
4384/**
4385 * sme_cfg_get_str() - Gets the cfg parameter string.
4386 * @hal: Handle to hal.
4387 * @cfg_id: Configuration parameter ID.
4388 * @str: Pointer to the string buffer.
4389 * @length: Pointer to length of the string.
4390 *
4391 * This function gets the string value of the cfg parameter.
4392 *
4393 * Return: CDF_STATUS
4394 */
4395CDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
4396 uint32_t *length)
4397{
4398 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4399 CDF_STATUS status = CDF_STATUS_SUCCESS;
4400
4401 if (eSIR_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
4402 status = CDF_STATUS_E_INVAL;
4403
4404 return status;
4405}
4406
4407/* ---------------------------------------------------------------------------
4408 \fn sme_get_modify_profile_fields
4409 \brief HDD or SME - QOS calls this function to get the current values of
4410 connected profile fields, changing which can cause reassoc.
4411 This function must be called after CFG is downloaded and STA is in connected
4412 state. Also, make sure to call this function to get the current profile
4413 fields before calling the reassoc. So that pModifyProfileFields will have
4414 all the latest values plus the one(s) has been updated as part of reassoc
4415 request.
4416 \param pModifyProfileFields - pointer to the connected profile fields
4417 changing which can cause reassoc
4418
4419 \return CDF_STATUS
4420 -------------------------------------------------------------------------------*/
4421CDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
4422 tCsrRoamModifyProfileFields *
4423 pModifyProfileFields)
4424{
4425 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4426 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4427
4428 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4429 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
4430 0));
4431 status = sme_acquire_global_lock(&pMac->sme);
4432 if (CDF_IS_STATUS_SUCCESS(status)) {
4433 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4434 status =
4435 csr_get_modify_profile_fields(pMac, sessionId,
4436 pModifyProfileFields);
4437 } else {
4438 status = CDF_STATUS_E_INVAL;
4439 }
4440 sme_release_global_lock(&pMac->sme);
4441 }
4442
4443 return status;
4444}
4445
4446/* ---------------------------------------------------------------------------
4447 \fn sme_set_dhcp_till_power_active_flag
4448 \brief Sets/Clears DHCP related flag to disable/enable auto PS
4449 \param hal - The handle returned by mac_open.
4450 ---------------------------------------------------------------------------*/
4451void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
4452{
4453 tpAniSirGlobal mac = PMAC_STRUCT(hal);
4454 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
4455
4456 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4457 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
4458 flag));
4459 /* Set/Clear the DHCP flag which will disable/enable auto PS */
4460 ps_global_info->remain_in_power_active_till_dhcp = flag;
4461}
4462
4463/* ---------------------------------------------------------------------------
4464 \fn sme_register11d_scan_done_callback
4465 \brief Register a routine of type csr_scan_completeCallback which is
4466 called whenever an 11d scan is done
4467 \param hHal - The handle returned by mac_open.
4468 \param callback - 11d scan complete routine to be registered
4469 \return CDF_STATUS
4470 ---------------------------------------------------------------------------*/
4471CDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
4472 csr_scan_completeCallback callback)
4473{
4474 CDF_STATUS status = CDF_STATUS_SUCCESS;
4475 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4476
4477 pMac->scan.callback11dScanDone = callback;
4478
4479 return status;
4480}
4481
4482#ifdef FEATURE_OEM_DATA_SUPPORT
4483/**
4484 * sme_register_oem_data_rsp_callback() - Register a routine of
4485 * type send_oem_data_rsp_msg
4486 * @h_hal: Handle returned by mac_open.
4487 * @callback: Callback to send response
4488 * to oem application.
4489 *
4490 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
4491 * callback function.
4492 *
4493 * Return: CDF_STATUS.
4494 */
4495CDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
4496 sme_send_oem_data_rsp_msg callback)
4497{
4498 CDF_STATUS status = CDF_STATUS_SUCCESS;
4499 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
4500
4501 pmac->oemData.oem_data_rsp_callback = callback;
4502
4503 return status;
4504
4505}
4506#endif
4507
4508/**
4509 * sme_register_ftm_msg_processor() - registers hdd ftm message processor
4510 * function to MAC/SYS
4511 *
4512 * @hal: hal handle
4513 * @callback: hdd function that has to be registered
4514 *
4515 * Return: void
4516 */
4517void sme_register_ftm_msg_processor(tHalHandle hal,
4518 hdd_ftm_msg_processor callback)
4519{
4520 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4521
4522 if (mac_ctx == NULL) {
4523 sms_log(mac_ctx, LOGE, FL("mac_ctx is NULL"));
4524 return;
4525 }
4526 mac_ctx->ftm_msg_processor_callback = callback;
4527 return;
4528}
4529
4530/**
4531 * sme_wow_add_pattern() - add a wow pattern in fw
4532 * @hHal: handle returned by mac_open
4533 * @pattern: pointer to input pattern
4534 *
4535 * Add a pattern for Pattern Byte Matching in WoW mode. Firmware will
4536 * do a pattern match on these patterns when WoW is enabled during system
4537 * suspend.
4538 *
4539 * Return: CDF_STATUS
4540 */
4541CDF_STATUS sme_wow_add_pattern(tHalHandle hal,
4542 struct wow_add_pattern *pattern,
4543 uint8_t session_id)
4544{
4545 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
4546 struct wow_add_pattern *ptrn;
4547 tSirRetStatus ret_code = eSIR_SUCCESS;
4548 tSirMsgQ msg_q;
4549 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4550 TRACE_CODE_SME_RX_HDD_WOWL_ADDBCAST_PATTERN, session_id,
4551 0));
4552 ptrn = cdf_mem_malloc(sizeof(*ptrn));
4553 if (NULL == ptrn) {
4554 sms_log(pMac, LOGP,
4555 FL("Fail to allocate memory for WoWLAN Add Bcast Pattern "));
4556 return CDF_STATUS_E_NOMEM;
4557 }
4558 (void)cdf_mem_copy(ptrn, pattern, sizeof(*ptrn));
4559
4560 msg_q.type = WMA_WOW_ADD_PTRN;
4561 msg_q.reserved = 0;
4562 msg_q.bodyptr = ptrn;
4563 msg_q.bodyval = 0;
4564
4565 sms_log(pMac, LOG1, FL("Sending WMA_WOWL_ADD_BCAST_PTRN to HAL"));
4566 ret_code = wma_post_ctrl_msg(pMac, &msg_q);
4567 if (eSIR_SUCCESS != ret_code) {
4568 sms_log(pMac, LOGE,
4569 FL("Posting WMA_WOWL_ADD_BCAST_PTRN failed, reason=%X"),
4570 ret_code);
4571 }
4572 return ret_code;
4573}
4574
4575/**
4576 * sme_wow_delete_pattern() - delete user configured wow pattern in target
4577 * @hHal: handle returned by mac_open.
4578 * @pattern: pointer to delete pattern parameter
4579 * @sessionId: session id
4580 *
4581 * Return: CDF_STATUS
4582 */
4583CDF_STATUS sme_wow_delete_pattern(tHalHandle hal,
4584 struct wow_delete_pattern *pattern, uint8_t sessionId)
4585{
4586 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
4587 struct wow_delete_pattern *delete_ptrn;
4588 tSirRetStatus ret_code = eSIR_SUCCESS;
4589 tSirMsgQ msg_q;
4590 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4591 TRACE_CODE_SME_RX_HDD_WOWL_DELBCAST_PATTERN, sessionId,
4592 0));
4593 delete_ptrn = cdf_mem_malloc(sizeof(*delete_ptrn));
4594 if (NULL == delete_ptrn) {
4595 sms_log(pMac, LOGP,
4596 FL("Fail to allocate memory for WoWLAN Delete Bcast Pattern "));
4597 return CDF_STATUS_E_NOMEM;
4598 }
4599 (void)cdf_mem_copy(delete_ptrn, pattern, sizeof(*delete_ptrn));
4600 msg_q.type = WMA_WOW_DEL_PTRN;
4601 msg_q.reserved = 0;
4602 msg_q.bodyptr = delete_ptrn;
4603 msg_q.bodyval = 0;
4604
4605 sms_log(pMac, LOG1, FL("Sending WMA_WOWL_DEL_BCAST_PTRN"));
4606
4607 ret_code = wma_post_ctrl_msg(pMac, &msg_q);
4608 if (eSIR_SUCCESS != ret_code) {
4609 sms_log(pMac, LOGE,
4610 FL("Posting WMA_WOWL_DEL_BCAST_PTRN failed, reason=%X"),
4611 ret_code);
4612 }
4613 return ret_code;
4614}
4615
4616/**
4617 * sme_enter_wowl(): SME API exposed to HDD to request enabling of WOWL mode.
4618 * @hal_ctx - The handle returned by mac_open.
4619 * @enter_wowl_callback_routine - Callback routine provided by HDD.
4620 * Used for success/failure notification by SME
4621 * @enter_wowl_callback_context - A cookie passed by HDD, that is passed
4622 * back to HDD at the time of callback.
4623 * @wake_reason_ind_cb - Callback routine provided by HDD.
4624 * Used for Wake Reason Indication by SME
4625 * @wake_reason_ind_cb_ctx - A cookie passed by HDD, that is passed
4626 * back to HDD at the time of callback.
4627 *
4628 * WoWLAN works on top of BMPS mode.
4629 * If the device is not in BMPS mode,
4630 * SME will will cache the information that
4631 * WOWL has been enabled and attempt to put the device
4632 * in BMPS. On entry into BMPS, SME will enable the
4633 * WOWL mode.
4634 * Note 1: If we exit BMPS mode (someone requests full power),
4635 * we will NOT resume WOWL when we go back to BMPS again.
4636 * Request for full power (while in WOWL mode) means disable
4637 * WOWL and go to full power.
4638 * Note 2: Both UAPSD and WOWL work on top of BMPS.
4639 * On entry into BMPS, SME will give priority to UAPSD and
4640 * enable only UAPSD if both UAPSD and WOWL are required.
4641 * Currently there is no requirement or use case to support
4642 * UAPSD and WOWL at the same time.
4643 *
4644 * Return: CDF_STATUS
4645 * CDF_STATUS_SUCCESS Device is already in WoWLAN mode
4646 * CDF_STATUS_E_FAILURE Device cannot enter WoWLAN mode.
4647 * CDF_STATUS_PMC_PENDING Request accepted. SME will enable
4648 * WOWL after BMPS mode is entered.
4649 */
4650CDF_STATUS sme_enter_wowl(tHalHandle hal_ctx,
4651 void (*enter_wowl_callback_routine)(void
4652 *callback_context,
4653 CDF_STATUS status),
4654 void *enter_wowl_callback_context,
4655#ifdef WLAN_WAKEUP_EVENTS
4656 void (*wakeIndicationCB)(void *callback_context,
4657 tpSirWakeReasonInd
4658 wake_reason_ind),
4659 void *wakeIndicationCBContext,
4660#endif /* WLAN_WAKEUP_EVENTS */
4661 tpSirSmeWowlEnterParams wowl_enter_params,
4662 uint8_t session_id)
4663{
4664 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4665 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4666 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4667 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4668 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, session_id, 0));
4669
4670 /* cache the WOWL information */
4671 ps_global_info->ps_params[session_id].wowl_enter_params =
4672 *wowl_enter_params;
4673 ps_global_info->ps_params[session_id].enter_wowl_callback_routine =
4674 enter_wowl_callback_routine;
4675 ps_global_info->ps_params[session_id].enter_wowl_callback_context =
4676 enter_wowl_callback_context;
4677#ifdef WLAN_WAKEUP_EVENTS
4678 /* Cache the Wake Reason Indication callback information */
4679 ps_global_info->ps_params[session_id].wake_reason_ind_cb =
4680 wakeIndicationCB;
4681 ps_global_info->ps_params[session_id].wake_reason_ind_cb_ctx =
4682 wakeIndicationCBContext;
4683#endif /* WLAN_WAKEUP_EVENTS */
4684
4685 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_ENTER);
4686 return status;
4687}
4688/**
4689 *sme_exit_wowl(): SME API exposed to HDD to request exit from WoWLAN mode.
4690 * @hal_ctx - The handle returned by mac_open.
4691 * @wowl_exit_params - Carries info on which smesession
4692 * wowl exit is requested.
4693 *
4694 * SME will initiate exit from WoWLAN mode and device will be
4695 * put in BMPS mode.
4696 * Return CDF_STATUS
4697 * CDF_STATUS_E_FAILURE Device cannot exit WoWLAN mode.
4698 * CDF_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
4699 */
4700CDF_STATUS sme_exit_wowl(tHalHandle hal_ctx,
4701 tpSirSmeWowlExitParams wowl_exit_params)
4702{
4703 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4704 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4705 uint8_t session_id;
4706 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4707 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
4708 session_id = wowl_exit_params->sessionId;
4709 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_EXIT);
4710 return status;
4711}
4712
4713/**
4714 * sme_roam_set_key() - To set encryption key.
4715 * @hal: hal global context
4716 * @session_id: session id
4717 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4718 * @ptr_roam_id: Upon success return, this is the id caller can use to
4719 * identify the request in roamcallback
4720 *
4721 * This function should be called only when connected. This is an asynchronous
4722 * API.
4723 *
4724 * Return: Status of operation
4725 */
4726CDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
4727 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4728{
4729 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4730 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4731 uint32_t roam_id;
4732 uint32_t i;
4733 tCsrRoamSession *session = NULL;
4734 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4735
4736 MTRACE(cdf_trace(CDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
4737 session_id, 0));
4738 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
4739 sms_log(mac_ctx, LOGE, FL("Invalid key length %d"),
4740 set_key->keyLength);
4741 return CDF_STATUS_E_FAILURE;
4742 }
4743 /*Once Setkey is done, we can go in BMPS */
4744 if (set_key->keyLength)
4745 ps_global_info->remain_in_power_active_till_dhcp = false;
4746
4747 status = sme_acquire_global_lock(&mac_ctx->sme);
4748 if (!CDF_IS_STATUS_SUCCESS(status))
4749 return status;
4750
4751 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4752 if (ptr_roam_id)
4753 *ptr_roam_id = roam_id;
4754
4755 sms_log(mac_ctx, LOG2, FL("keyLength %d"), set_key->keyLength);
4756 for (i = 0; i < set_key->keyLength; i++)
4757 sms_log(mac_ctx, LOG2, FL("%02x"), set_key->Key[i]);
4758
4759 sms_log(mac_ctx, LOG2, "\n session_id=%d roam_id=%d", session_id,
4760 roam_id);
4761 session = CSR_GET_SESSION(mac_ctx, session_id);
4762 if (!session) {
4763 sms_log(mac_ctx, LOGE, FL("session %d not found"), session_id);
4764 sme_release_global_lock(&mac_ctx->sme);
4765 return CDF_STATUS_E_FAILURE;
4766 }
4767 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4768 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4769 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4770 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4771 set_key->encType)) {
4772 session->pCurRoamProfile->negotiatedUCEncryptionType =
4773 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4774 }
4775 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4776 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4777 set_key->encType)) {
4778 session->pCurRoamProfile->negotiatedUCEncryptionType =
4779 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4780 }
4781 }
4782 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4783 sme_release_global_lock(&mac_ctx->sme);
4784 return status;
4785}
4786
4787/* ---------------------------------------------------------------------------
4788 \fn sme_get_rssi
4789 \brief a wrapper function that client calls to register a callback to get
4790 RSSI
4791
4792 \param hHal - HAL handle for device
4793 \param callback - SME sends back the requested stats using the callback
4794 \param staId - The station ID for which the stats is requested for
4795 \param bssid - The bssid of the connected session
4796 \param lastRSSI - RSSI value at time of request. In case fw cannot provide
4797 RSSI, do not hold up but return this value.
4798 \param pContext - user context to be passed back along with the callback
4799 \param p_cds_context - cds context
4800 \return CDF_STATUS
4801 ---------------------------------------------------------------------------*/
4802CDF_STATUS sme_get_rssi(tHalHandle hHal,
4803 tCsrRssiCallback callback,
4804 uint8_t staId, struct cdf_mac_addr bssId, int8_t lastRSSI,
4805 void *pContext, void *p_cds_context)
4806{
4807 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4808 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4809
4810 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4811 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4812 status = sme_acquire_global_lock(&pMac->sme);
4813 if (CDF_IS_STATUS_SUCCESS(status)) {
4814 status = csr_get_rssi(pMac, callback,
4815 staId, bssId, lastRSSI,
4816 pContext, p_cds_context);
4817 sme_release_global_lock(&pMac->sme);
4818 }
4819 return status;
4820}
4821
4822/* ---------------------------------------------------------------------------
4823 \fn sme_get_snr
4824 \brief a wrapper function that client calls to register a callback to
4825 get SNR
4826
4827 \param callback - SME sends back the requested stats using the callback
4828 \param staId - The station ID for which the stats is requested for
4829 \param pContext - user context to be passed back along with the callback
4830 \param p_cds_context - cds context
4831 \return CDF_STATUS
4832 ---------------------------------------------------------------------------*/
4833CDF_STATUS sme_get_snr(tHalHandle hHal,
4834 tCsrSnrCallback callback,
4835 uint8_t staId, struct cdf_mac_addr bssId, void *pContext)
4836{
4837 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4838 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4839
4840 status = sme_acquire_global_lock(&pMac->sme);
4841 if (CDF_IS_STATUS_SUCCESS(status)) {
4842 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4843 sme_release_global_lock(&pMac->sme);
4844 }
4845 return status;
4846}
4847
4848#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4849/* ---------------------------------------------------------------------------
4850 \fn sme_get_tsm_stats
4851 \brief a wrapper function that client calls to register a callback to
4852 get TSM Stats
4853 \param callback - SME sends back the requested stats using the callback
4854 \param staId - The station ID for which the stats is requested for
4855 \param pContext - user context to be passed back along with the callback
4856 \param p_cds_context - cds context
4857 \return CDF_STATUS
4858 ---------------------------------------------------------------------------*/
4859CDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
4860 tCsrTsmStatsCallback callback,
4861 uint8_t staId, struct cdf_mac_addr bssId,
4862 void *pContext, void *p_cds_context, uint8_t tid)
4863{
4864 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4865 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4866 status = sme_acquire_global_lock(&pMac->sme);
4867 if (CDF_IS_STATUS_SUCCESS(status)) {
4868 status = csr_get_tsm_stats(pMac, callback,
4869 staId, bssId, pContext, p_cds_context,
4870 tid);
4871 sme_release_global_lock(&pMac->sme);
4872 }
4873 return status;
4874}
4875#endif
4876
4877/* ---------------------------------------------------------------------------
4878 \fn sme_get_statistics
4879 \brief a wrapper function that client calls to register a callback to get
4880 different PHY level statistics from CSR.
4881
4882 \param requesterId - different client requesting for statistics,
4883 HDD, UMA/GAN etc
4884 \param statsMask - The different category/categories of stats requester
4885 is looking for
4886 \param callback - SME sends back the requested stats using the callback
4887 \param periodicity - If requester needs periodic update in millisec, 0 means
4888 it's an one time request
4889 \param cache - If requester is happy with cached stats
4890 \param staId - The station ID for which the stats is requested for
4891 \param pContext - user context to be passed back along with the callback
4892 \param sessionId - sme session interface
4893 \return CDF_STATUS
4894 ---------------------------------------------------------------------------*/
4895CDF_STATUS sme_get_statistics(tHalHandle hHal,
4896 eCsrStatsRequesterType requesterId,
4897 uint32_t statsMask, tCsrStatsCallback callback,
4898 uint32_t periodicity, bool cache, uint8_t staId,
4899 void *pContext, uint8_t sessionId)
4900{
4901 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4902 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4903
4904 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4905 TRACE_CODE_SME_RX_HDD_GET_STATS, NO_SESSION,
4906 periodicity));
4907 status = sme_acquire_global_lock(&pMac->sme);
4908 if (CDF_IS_STATUS_SUCCESS(status)) {
4909 status =
4910 csr_get_statistics(pMac, requesterId, statsMask, callback,
4911 periodicity, cache, staId, pContext,
4912 sessionId);
4913 sme_release_global_lock(&pMac->sme);
4914 }
4915
4916 return status;
4917
4918}
4919
4920CDF_STATUS sme_get_link_status(tHalHandle hHal,
4921 tCsrLinkStatusCallback callback,
4922 void *pContext, uint8_t sessionId)
4923{
4924 CDF_STATUS status = CDF_STATUS_E_FAILURE;
4925 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4926 tAniGetLinkStatus *pMsg;
4927 cds_msg_t cds_message;
4928
4929 status = sme_acquire_global_lock(&pMac->sme);
4930 if (CDF_IS_STATUS_SUCCESS(status)) {
4931 pMsg = cdf_mem_malloc(sizeof(tAniGetLinkStatus));
4932 if (NULL == pMsg) {
4933 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
4934 "%s: Not able to allocate memory for link status",
4935 __func__);
4936 sme_release_global_lock(&pMac->sme);
4937 return CDF_STATUS_E_NOMEM;
4938 }
4939
4940 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4941 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4942 pMsg->sessionId = sessionId;
4943 pMac->sme.linkStatusContext = pContext;
4944 pMac->sme.linkStatusCallback = callback;
4945
4946 cds_message.type = WMA_LINK_STATUS_GET_REQ;
4947 cds_message.bodyptr = pMsg;
4948 cds_message.reserved = 0;
4949
4950 if (!CDF_IS_STATUS_SUCCESS
4951 (cds_mq_post_message(CDF_MODULE_ID_WMA, &cds_message))) {
4952 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
4953 "%s: Post LINK STATUS MSG fail", __func__);
4954 cdf_mem_free(pMsg);
4955 pMac->sme.linkStatusContext = NULL;
4956 pMac->sme.linkStatusCallback = NULL;
4957 status = CDF_STATUS_E_FAILURE;
4958 }
4959
4960 sme_release_global_lock(&pMac->sme);
4961 }
4962
4963 return status;
4964}
4965
4966/* ---------------------------------------------------------------------------
4967
4968 \fn sme_get_country_code
4969
4970 \brief To return the current country code. If no country code is applied,
4971 default country code is used to fill the buffer.
4972 If 11d supported is turned off, an error is return and the last
4973 applied/default country code is used.
4974 This is a synchronous API.
4975
4976 \param pBuf - pointer to a caller allocated buffer for returned country code.
4977
4978 \param pbLen For input, this parameter indicates how big is the buffer.
4979 Upon return, this parameter has the number of bytes for
4980 country. If pBuf doesn't have enough space, this function
4981 returns fail status and this parameter contains the number
4982 that is needed.
4983
4984 \return CDF_STATUS SUCCESS.
4985
4986 FAILURE or RESOURCES The API finished and failed.
4987
4988 -------------------------------------------------------------------------------*/
4989CDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
4990{
4991 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4992
4993 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
4994 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4995
4996 return csr_get_country_code(pMac, pBuf, pbLen);
4997}
4998
4999/**
5000 * sme_apply_channel_power_info_to_fw() - sends channel info to fw
5001 * @hHal: hal handle
5002 *
5003 * This function sends the channel power info to firmware
5004 *
5005 * Return: none
5006 */
5007void sme_apply_channel_power_info_to_fw(tHalHandle hHal)
5008{
5009 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5010
5011 csr_apply_channel_power_info_wrapper(pMac);
5012}
5013
5014/* some support functions */
5015bool sme_is11d_supported(tHalHandle hHal)
5016{
5017 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5018
5019 return csr_is11d_supported(pMac);
5020}
5021
5022bool sme_is11h_supported(tHalHandle hHal)
5023{
5024 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5025
5026 return csr_is11h_supported(pMac);
5027}
5028
5029bool sme_is_wmm_supported(tHalHandle hHal)
5030{
5031 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5032
5033 return csr_is_wmm_supported(pMac);
5034}
5035
5036/* ---------------------------------------------------------------------------
5037
5038 \fn sme_change_country_code
5039
5040 \brief Change Country code from upperlayer during WLAN driver operation.
5041 This is a synchronous API.
5042
5043 \param hHal - The handle returned by mac_open.
5044
5045 \param pCountry New Country Code String
5046
5047 \param sendRegHint If we want to send reg hint to nl80211
5048
5049 \return CDF_STATUS SUCCESS.
5050
5051 FAILURE or RESOURCES The API finished and failed.
5052
5053 -------------------------------------------------------------------------------*/
5054CDF_STATUS sme_change_country_code(tHalHandle hHal,
5055 tSmeChangeCountryCallback callback,
5056 uint8_t *pCountry,
5057 void *pContext,
5058 void *p_cds_context,
5059 tAniBool countryFromUserSpace,
5060 tAniBool sendRegHint)
5061{
5062 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5063 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5064 cds_msg_t msg;
5065 tAniChangeCountryCodeReq *pMsg;
5066
5067 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5068 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION,
5069 0));
5070 status = sme_acquire_global_lock(&pMac->sme);
5071 if (CDF_IS_STATUS_SUCCESS(status)) {
5072 sms_log(pMac, LOG1, FL(" called"));
5073
5074 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
5075 && (!pMac->roam.configParam.
5076 fSupplicantCountryCodeHasPriority)) {
5077
5078 sms_log(pMac, LOGW,
5079 "Set Country Code Fail since the STA is associated and userspace does not have priority ");
5080
5081 sme_release_global_lock(&pMac->sme);
5082 status = CDF_STATUS_E_FAILURE;
5083 return status;
5084 }
5085
5086 pMsg = cdf_mem_malloc(sizeof(tAniChangeCountryCodeReq));
5087 if (NULL == pMsg) {
5088 sms_log(pMac, LOGE,
5089 " csrChangeCountryCode: failed to allocate mem for req");
5090 sme_release_global_lock(&pMac->sme);
5091 return CDF_STATUS_E_NOMEM;
5092 }
5093
5094 pMsg->msgType = eWNI_SME_CHANGE_COUNTRY_CODE;
5095 pMsg->msgLen = (uint16_t) sizeof(tAniChangeCountryCodeReq);
5096 cdf_mem_copy(pMsg->countryCode, pCountry, 3);
5097 pMsg->countryFromUserSpace = countryFromUserSpace;
5098 pMsg->sendRegHint = sendRegHint;
5099 pMsg->changeCCCallback = callback;
5100 pMsg->pDevContext = pContext;
5101 pMsg->p_cds_context = p_cds_context;
5102
5103 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
5104 msg.bodyptr = pMsg;
5105 msg.reserved = 0;
5106
5107 if (CDF_STATUS_SUCCESS !=
5108 cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
5109 sms_log(pMac, LOGE,
5110 " sme_change_country_code failed to post msg to self ");
5111 cdf_mem_free((void *)pMsg);
5112 status = CDF_STATUS_E_FAILURE;
5113 }
5114 sms_log(pMac, LOG1, FL(" returned"));
5115 sme_release_global_lock(&pMac->sme);
5116 }
5117
5118 return status;
5119}
5120
5121/*--------------------------------------------------------------------------
5122
5123 \fn sme_generic_change_country_code
5124
5125 \brief Change Country code from upperlayer during WLAN driver operation.
5126 This is a synchronous API.
5127
5128 \param hHal - The handle returned by mac_open.
5129
5130 \param pCountry New Country Code String
5131
5132 \param reg_domain regulatory domain
5133
5134 \return CDF_STATUS SUCCESS.
5135
5136 FAILURE or RESOURCES The API finished and failed.
5137
5138 -----------------------------------------------------------------------------*/
5139CDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
5140 uint8_t *pCountry,
5141 v_REGDOMAIN_t reg_domain)
5142{
5143 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5144 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5145 cds_msg_t msg;
5146 tAniGenericChangeCountryCodeReq *pMsg;
5147
5148 if (NULL == pMac) {
5149 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_FATAL,
5150 "%s: pMac is null", __func__);
5151 return status;
5152 }
5153
5154 status = sme_acquire_global_lock(&pMac->sme);
5155 if (CDF_IS_STATUS_SUCCESS(status)) {
5156 sms_log(pMac, LOG1, FL(" called"));
5157 pMsg = cdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
5158
5159 if (NULL == pMsg) {
5160 sms_log(pMac, LOGE,
5161 " sme_generic_change_country_code: failed to allocate mem for req");
5162 sme_release_global_lock(&pMac->sme);
5163 return CDF_STATUS_E_NOMEM;
5164 }
5165
5166 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
5167 pMsg->msgLen =
5168 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
5169 cdf_mem_copy(pMsg->countryCode, pCountry, 2);
5170 pMsg->domain_index = reg_domain;
5171 pMsg->countryCode[2] = ' '; /* For ASCII space */
5172
5173 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
5174 msg.bodyptr = pMsg;
5175 msg.reserved = 0;
5176
5177 if (CDF_STATUS_SUCCESS !=
5178 cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
5179 sms_log(pMac, LOGE,
5180 "sme_generic_change_country_code failed to post msg to self");
5181 cdf_mem_free(pMsg);
5182 status = CDF_STATUS_E_FAILURE;
5183 }
5184 sms_log(pMac, LOG1, FL(" returned"));
5185 sme_release_global_lock(&pMac->sme);
5186 }
5187
5188 return status;
5189}
5190
5191/* ---------------------------------------------------------------------------
5192
5193 \fn sme_dhcp_start_ind
5194
5195 \brief API to signal the FW about the DHCP Start event.
5196
5197 \param hHal - HAL handle for device.
5198
5199 \param device_mode - mode(AP,SAP etc) of the device.
5200
5201 \param macAddr - MAC address of the adapter.
5202
5203 \param sessionId - session ID.
5204
5205 \return CDF_STATUS SUCCESS.
5206
5207 FAILURE or RESOURCES The API finished and failed.
5208 --------------------------------------------------------------------------*/
5209CDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
5210 uint8_t device_mode,
5211 uint8_t *macAddr, uint8_t sessionId)
5212{
5213 CDF_STATUS status;
5214 CDF_STATUS cdf_status;
5215 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5216 cds_msg_t cds_message;
5217 tAniDHCPInd *pMsg;
5218 tCsrRoamSession *pSession;
5219
5220 status = sme_acquire_global_lock(&pMac->sme);
5221 if (CDF_STATUS_SUCCESS == status) {
5222 pSession = CSR_GET_SESSION(pMac, sessionId);
5223
5224 if (!pSession) {
5225 sms_log(pMac, LOGE, FL("session %d not found "),
5226 sessionId);
5227 sme_release_global_lock(&pMac->sme);
5228 return CDF_STATUS_E_FAILURE;
5229 }
5230
5231 pMsg = (tAniDHCPInd *) cdf_mem_malloc(sizeof(tAniDHCPInd));
5232 if (NULL == pMsg) {
5233 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5234 "%s: Not able to allocate memory for dhcp start",
5235 __func__);
5236 sme_release_global_lock(&pMac->sme);
5237 return CDF_STATUS_E_NOMEM;
5238 }
5239 pMsg->msgType = WMA_DHCP_START_IND;
5240 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
5241 pMsg->device_mode = device_mode;
Srinivas Girigowda296105a2015-09-24 16:31:16 -07005242 cdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
5243 CDF_MAC_ADDR_SIZE);
5244 cdf_copy_macaddr(&pMsg->peerMacAddr,
5245 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246
5247 cds_message.type = WMA_DHCP_START_IND;
5248 cds_message.bodyptr = pMsg;
5249 cds_message.reserved = 0;
5250
5251 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
5252 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
5253 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5254 "%s: Post DHCP Start MSG fail", __func__);
5255 cdf_mem_free(pMsg);
5256 status = CDF_STATUS_E_FAILURE;
5257 }
5258 sme_release_global_lock(&pMac->sme);
5259 }
5260 return status;
5261}
5262
5263/* ---------------------------------------------------------------------------
5264 \fn sme_dhcp_stop_ind
5265
5266 \brief API to signal the FW about the DHCP complete event.
5267
5268 \param hHal - HAL handle for device.
5269
5270 \param device_mode - mode(AP, SAP etc) of the device.
5271
5272 \param macAddr - MAC address of the adapter.
5273
5274 \param sessionId - session ID.
5275
5276 \return CDF_STATUS SUCCESS.
5277 FAILURE or RESOURCES The API finished and failed.
5278 --------------------------------------------------------------------------*/
5279CDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
5280 uint8_t device_mode,
5281 uint8_t *macAddr, uint8_t sessionId)
5282{
5283 CDF_STATUS status;
5284 CDF_STATUS cdf_status;
5285 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5286 cds_msg_t cds_message;
5287 tAniDHCPInd *pMsg;
5288 tCsrRoamSession *pSession;
5289
5290 status = sme_acquire_global_lock(&pMac->sme);
5291 if (CDF_STATUS_SUCCESS == status) {
5292 pSession = CSR_GET_SESSION(pMac, sessionId);
5293
5294 if (!pSession) {
5295 sms_log(pMac, LOGE, FL("session %d not found "),
5296 sessionId);
5297 sme_release_global_lock(&pMac->sme);
5298 return CDF_STATUS_E_FAILURE;
5299 }
5300
5301 pMsg = (tAniDHCPInd *) cdf_mem_malloc(sizeof(tAniDHCPInd));
5302 if (NULL == pMsg) {
5303 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5304 "%s: Not able to allocate memory for dhcp stop",
5305 __func__);
5306 sme_release_global_lock(&pMac->sme);
5307 return CDF_STATUS_E_NOMEM;
5308 }
5309
5310 pMsg->msgType = WMA_DHCP_STOP_IND;
5311 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
5312 pMsg->device_mode = device_mode;
Srinivas Girigowda296105a2015-09-24 16:31:16 -07005313 cdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
5314 CDF_MAC_ADDR_SIZE);
5315 cdf_copy_macaddr(&pMsg->peerMacAddr,
5316 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317
5318 cds_message.type = WMA_DHCP_STOP_IND;
5319 cds_message.bodyptr = pMsg;
5320 cds_message.reserved = 0;
5321
5322 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
5323 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
5324 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5325 "%s: Post DHCP Stop MSG fail", __func__);
5326 cdf_mem_free(pMsg);
5327 status = CDF_STATUS_E_FAILURE;
5328 }
5329
5330 sme_release_global_lock(&pMac->sme);
5331 }
5332 return status;
5333}
5334
5335/* ---------------------------------------------------------------------------
5336 \fn sme_set_cfg_privacy
5337 \brief API to set configure privacy parameters
5338 \param hHal - The handle returned by mac_open.
5339 \param pProfile - Pointer CSR Roam profile.
5340 \param fPrivacy - This parameter indicates status of privacy
5341
5342 \return void
5343 ---------------------------------------------------------------------------*/
5344void sme_set_cfg_privacy(tHalHandle hHal,
5345 tCsrRoamProfile *pProfile, bool fPrivacy)
5346{
5347 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5348 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5349 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
5350 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5351 csr_set_cfg_privacy(pMac, pProfile, fPrivacy);
5352 sme_release_global_lock(&pMac->sme);
5353 }
5354}
5355
5356#if defined WLAN_FEATURE_VOWIFI
5357/* ---------------------------------------------------------------------------
5358 \fn sme_neighbor_report_request
5359 \brief API to request neighbor report.
5360 \param hHal - The handle returned by mac_open.
5361 \param pRrmNeighborReq - Pointer to a caller allocated object of type
5362 tRrmNeighborReq. Caller owns the memory and is
5363 responsible for freeing it.
5364 \return CDF_STATUS
5365 CDF_STATUS_E_FAILURE - failure
5366 CDF_STATUS_SUCCESS success
5367 ---------------------------------------------------------------------------*/
5368CDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
5369 tpRrmNeighborReq pRrmNeighborReq,
5370 tpRrmNeighborRspCallbackInfo callbackInfo)
5371{
5372 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5373 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5374 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5375 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
5376 0));
5377
5378 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5379 status =
5380 sme_rrm_neighbor_report_request(hHal, sessionId,
5381 pRrmNeighborReq, callbackInfo);
5382 sme_release_global_lock(&pMac->sme);
5383 }
5384
5385 return status;
5386}
5387#endif
5388
5389void sms_log(tpAniSirGlobal pMac, uint32_t loglevel, const char *pString, ...)
5390{
5391#ifdef WLAN_DEBUG
5392 /* Verify against current log level */
5393 if (loglevel >
5394 pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE(SIR_SMS_MODULE_ID)])
5395 return;
5396 else {
5397 va_list marker;
5398
5399 va_start(marker, pString); /* Initialize variable arguments. */
5400
5401 log_debug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
5402
5403 va_end(marker); /* Reset variable arguments. */
5404 }
5405#endif
5406}
5407
5408/* ---------------------------------------------------------------------------
5409 \fn sme_get_wcnss_wlan_compiled_version
5410 \brief This API returns the version of the WCNSS WLAN API with
5411 which the HOST driver was built
5412 \param hHal - The handle returned by mac_open.
5413 \param pVersion - Points to the Version structure to be filled
5414 \return CDF_STATUS
5415 CDF_STATUS_E_INVAL - failure
5416 CDF_STATUS_SUCCESS success
5417 ---------------------------------------------------------------------------*/
5418CDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
5419 tSirVersionType *pVersion)
5420{
5421 CDF_STATUS status = CDF_STATUS_SUCCESS;
5422 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5423
5424 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5425 if (pVersion != NULL)
5426 status = CDF_STATUS_SUCCESS;
5427 else
5428 status = CDF_STATUS_E_INVAL;
5429
5430 sme_release_global_lock(&pMac->sme);
5431 }
5432
5433 return status;
5434}
5435
5436/* ---------------------------------------------------------------------------
5437 \fn sme_get_wcnss_wlan_reported_version
5438 \brief This API returns the version of the WCNSS WLAN API with
5439 which the WCNSS driver reports it was built
5440 \param hHal - The handle returned by mac_open.
5441 \param pVersion - Points to the Version structure to be filled
5442 \return CDF_STATUS
5443 CDF_STATUS_E_INVAL - failure
5444 CDF_STATUS_SUCCESS success
5445 ---------------------------------------------------------------------------*/
5446CDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
5447 tSirVersionType *pVersion)
5448{
5449 CDF_STATUS status = CDF_STATUS_SUCCESS;
5450 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5451
5452 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5453 if (pVersion != NULL)
5454 status = CDF_STATUS_SUCCESS;
5455 else
5456 status = CDF_STATUS_E_INVAL;
5457
5458 sme_release_global_lock(&pMac->sme);
5459 }
5460
5461 return status;
5462}
5463
5464/* ---------------------------------------------------------------------------
5465 \fn sme_get_wcnss_software_version
5466 \brief This API returns the version string of the WCNSS driver
5467 \param hHal - The handle returned by mac_open.
5468 \param pVersion - Points to the Version string buffer to be filled
5469 \param versionBufferSize - THe size of the Version string buffer
5470 \return CDF_STATUS
5471 CDF_STATUS_E_INVAL - failure
5472 CDF_STATUS_SUCCESS success
5473 ---------------------------------------------------------------------------*/
5474CDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
5475 uint8_t *pVersion,
5476 uint32_t versionBufferSize)
5477{
5478 CDF_STATUS status = CDF_STATUS_SUCCESS;
5479 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5480 v_CONTEXT_t cds_context = cds_get_global_context();
5481
5482 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5483 if (pVersion != NULL) {
5484 status =
5485 wma_get_wcnss_software_version(cds_context,
5486 pVersion,
5487 versionBufferSize);
5488 } else {
5489 status = CDF_STATUS_E_INVAL;
5490 }
5491 sme_release_global_lock(&pMac->sme);
5492 }
5493
5494 return status;
5495}
5496
5497/* ---------------------------------------------------------------------------
5498 \fn sme_get_wcnss_hardware_version
5499 \brief This API returns the version string of the WCNSS hardware
5500 \param hHal - The handle returned by mac_open.
5501 \param pVersion - Points to the Version string buffer to be filled
5502 \param versionBufferSize - THe size of the Version string buffer
5503 \return CDF_STATUS
5504 CDF_STATUS_E_INVAL - failure
5505 CDF_STATUS_SUCCESS success
5506 ---------------------------------------------------------------------------*/
5507CDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
5508 uint8_t *pVersion,
5509 uint32_t versionBufferSize)
5510{
5511 CDF_STATUS status = CDF_STATUS_SUCCESS;
5512 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5513
5514 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
5515 if (pVersion != NULL)
5516 status = CDF_STATUS_SUCCESS;
5517 else
5518 status = CDF_STATUS_E_INVAL;
5519
5520 sme_release_global_lock(&pMac->sme);
5521 }
5522
5523 return status;
5524}
5525
5526#ifdef FEATURE_WLAN_WAPI
5527
5528/* ---------------------------------------------------------------------------
5529 \fn sme_scan_get_bkid_candidate_list
5530 \brief a wrapper function to return the BKID candidate list
5531 \param pBkidList - caller allocated buffer point to an array of
5532 tBkidCandidateInfo
5533 \param pNumItems - pointer to a variable that has the number of
5534 tBkidCandidateInfo allocated when retruning, this is
5535 either the number needed or number of items put into
5536 pPmkidList
5537 \return CDF_STATUS - when fail, it usually means the buffer allocated is not
5538 big enough and pNumItems
5539 has the number of tBkidCandidateInfo.
5540 \Note: pNumItems is a number of tBkidCandidateInfo,
5541 not sizeof(tBkidCandidateInfo) * something
5542 ---------------------------------------------------------------------------*/
5543CDF_STATUS sme_scan_get_bkid_candidate_list(tHalHandle hHal, uint32_t sessionId,
5544 tBkidCandidateInfo *pBkidList,
5545 uint32_t *pNumItems)
5546{
5547 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5548 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5549
5550 status = sme_acquire_global_lock(&pMac->sme);
5551 if (CDF_IS_STATUS_SUCCESS(status)) {
5552 status =
5553 csr_scan_get_bkid_candidate_list(pMac, sessionId, pBkidList,
5554 pNumItems);
5555 sme_release_global_lock(&pMac->sme);
5556 }
5557
5558 return status;
5559}
5560#endif /* FEATURE_WLAN_WAPI */
5561
5562#ifdef FEATURE_OEM_DATA_SUPPORT
5563
5564/*****************************************************************************
5565 OEM DATA related modifications and function additions
5566*****************************************************************************/
5567
5568/* ---------------------------------------------------------------------------
5569 \fn sme_oem_data_req
5570 \brief a wrapper function for OEM DATA REQ
5571 \param sessionId - session id to be used.
5572 \param pOemDataReqId - pointer to an object to get back the request ID
5573 \param callback - a callback function that is called upon finish
5574 \param pContext - a pointer passed in for the callback
5575 \return CDF_STATUS
5576 ---------------------------------------------------------------------------*/
5577CDF_STATUS sme_oem_data_req(tHalHandle hHal,
5578 uint8_t sessionId,
5579 tOemDataReqConfig *pOemDataReqConfig,
5580 uint32_t *pOemDataReqID,
5581 oem_data_oem_data_reqCompleteCallback callback,
5582 void *pContext)
5583{
5584 CDF_STATUS status = CDF_STATUS_SUCCESS;
5585 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5586
5587 do {
5588 /* acquire the lock for the sme object */
5589 status = sme_acquire_global_lock(&pMac->sme);
5590 if (CDF_IS_STATUS_SUCCESS(status)) {
5591 uint32_t lOemDataReqId = pMac->oemData.oemDataReqID++; /* let it wrap around */
5592
5593 if (pOemDataReqID) {
5594 *pOemDataReqID = lOemDataReqId;
5595 } else {
5596 sme_release_global_lock(&pMac->sme);
5597 return CDF_STATUS_E_FAILURE;
5598 }
5599
5600 status =
5601 oem_data_oem_data_req(hHal, sessionId,
5602 pOemDataReqConfig, pOemDataReqID,
5603 callback, pContext);
5604
5605 /* release the lock for the sme object */
5606 sme_release_global_lock(&pMac->sme);
5607 }
5608 } while (0);
5609
5610 sms_log(pMac, LOGW, "exiting function %s", __func__);
5611
5612 return status;
5613}
5614
5615#endif /*FEATURE_OEM_DATA_SUPPORT */
5616
5617/*--------------------------------------------------------------------------
5618
5619 \brief sme_open_session() - Open a session for scan/roam operation.
5620
5621 This is a synchronous API.
5622
5623 \param hHal - The handle returned by mac_open.
5624 \param callback - A pointer to the function caller specifies for
5625 roam/connect status indication
5626 \param pContext - The context passed with callback
5627 \param pSelfMacAddr - Caller allocated memory filled with self MAC address
5628 (6 bytes)
5629 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
5630
5631 \return CDF_STATUS_SUCCESS - session is opened. sessionId returned.
5632
5633 Other status means SME is failed to open the session.
5634 CDF_STATUS_E_RESOURCES - no more session available.
5635 \sa
5636
5637 --------------------------------------------------------------------------*/
5638CDF_STATUS sme_open_session(tHalHandle hHal, csr_roam_completeCallback callback,
5639 void *pContext,
5640 uint8_t *pSelfMacAddr, uint8_t *pbSessionId,
5641 uint32_t type, uint32_t subType)
5642{
5643 CDF_STATUS status;
5644 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5645
5646 CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH,
5647 "%s: type=%d, subType=%d", __func__, type, subType);
5648
5649 if (NULL == pbSessionId) {
5650 status = CDF_STATUS_E_INVAL;
5651 } else {
5652 status = sme_acquire_global_lock(&pMac->sme);
5653 if (CDF_IS_STATUS_SUCCESS(status)) {
5654 status =
5655 csr_roam_open_session(pMac, callback, pContext,
5656 pSelfMacAddr, pbSessionId, type,
5657 subType);
5658
5659 sme_release_global_lock(&pMac->sme);
5660 }
5661 }
5662 if (NULL != pbSessionId)
5663 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5664 TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
5665 *pbSessionId, 0));
5666
5667 return status;
5668}
5669
5670/*--------------------------------------------------------------------------
5671
5672 \brief sme_close_session() - Open a session for scan/roam operation.
5673
5674 This is a synchronous API.
5675
5676 \param hHal - The handle returned by mac_open.
5677
5678 \param sessionId - A previous opened session's ID.
5679
5680 \return CDF_STATUS_SUCCESS - session is closed.
5681
5682 Other status means SME is failed to open the session.
5683 CDF_STATUS_E_INVAL - session is not opened.
5684 \sa
5685
5686 --------------------------------------------------------------------------*/
5687CDF_STATUS sme_close_session(tHalHandle hHal, uint8_t sessionId,
5688 csr_roamSessionCloseCallback callback,
5689 void *pContext)
5690{
5691 CDF_STATUS status;
5692 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5693
5694 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5695 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, sessionId, 0));
5696 status = sme_acquire_global_lock(&pMac->sme);
5697 if (CDF_IS_STATUS_SUCCESS(status)) {
5698 status = csr_roam_close_session(pMac, sessionId, false,
5699 callback, pContext);
5700
5701 sme_release_global_lock(&pMac->sme);
5702 }
5703
5704 return status;
5705}
5706
5707/* ---------------------------------------------------------------------------
5708
5709 \fn sme_roam_update_apwpsie
5710
5711 \brief To update AP's WPS IE. This function should be called after SME AP session is created
5712 This is an asynchronous API.
5713
5714 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
5715
5716 \return CDF_STATUS – SUCCESS –
5717
5718 FAILURE or RESOURCES – The API finished and failed.
5719
5720 -------------------------------------------------------------------------------*/
5721CDF_STATUS sme_roam_update_apwpsie(tHalHandle hHal, uint8_t sessionId,
5722 tSirAPWPSIEs *pAPWPSIES)
5723{
5724
5725 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5726 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5727
5728 status = sme_acquire_global_lock(&pMac->sme);
5729 if (CDF_IS_STATUS_SUCCESS(status)) {
5730
5731 status = csr_roam_update_apwpsie(pMac, sessionId, pAPWPSIES);
5732
5733 sme_release_global_lock(&pMac->sme);
5734 }
5735
5736 return status;
5737}
5738
5739/* ---------------------------------------------------------------------------
5740
5741 \fn sme_roam_update_apwparsni_es
5742
5743 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
5744 This is an asynchronous API.
5745
5746 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
5747
5748 \return CDF_STATUS – SUCCESS –
5749
5750 FAILURE or RESOURCES – The API finished and failed.
5751
5752 -------------------------------------------------------------------------------*/
5753CDF_STATUS sme_roam_update_apwparsni_es(tHalHandle hHal, uint8_t sessionId,
5754 tSirRSNie *pAPSirRSNie)
5755{
5756
5757 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5758 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5759
5760 status = sme_acquire_global_lock(&pMac->sme);
5761 if (CDF_IS_STATUS_SUCCESS(status)) {
5762
5763 status = csr_roam_update_wparsni_es(pMac, sessionId, pAPSirRSNie);
5764
5765 sme_release_global_lock(&pMac->sme);
5766 }
5767
5768 return status;
5769}
5770
5771/* ---------------------------------------------------------------------------
5772
5773 \fn sme_change_mcc_beacon_interval
5774
5775 \brief To update P2P-GO beaconInterval. This function should be called after
5776 disassociating all the station is done
5777 This is an asynchronous API.
5778
5779 \param
5780
5781 \return CDF_STATUS SUCCESS
5782 FAILURE or RESOURCES
5783 The API finished and failed.
5784
5785 -------------------------------------------------------------------------------*/
5786CDF_STATUS sme_change_mcc_beacon_interval(tHalHandle hHal, uint8_t sessionId)
5787{
5788 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5789 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5790
5791 sms_log(pMac, LOG1, FL("Update Beacon PARAMS "));
5792 status = sme_acquire_global_lock(&pMac->sme);
5793 if (CDF_IS_STATUS_SUCCESS(status)) {
5794 status = csr_send_chng_mcc_beacon_interval(pMac, sessionId);
5795 sme_release_global_lock(&pMac->sme);
5796 }
5797 return status;
5798}
5799
5800/**
5801 * sme_set_host_offload(): API to set the host offload feature.
5802 * @hHal: The handle returned by mac_open.
5803 * @sessionId: Session Identifier
5804 * @request: Pointer to the offload request.
5805 *
5806 * Return CDF_STATUS
5807 */
5808CDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
5809 tpSirHostOffloadReq request)
5810{
5811 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5812 CDF_STATUS status = CDF_STATUS_E_FAILURE;
5813
5814 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
5815 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
5816 status = sme_acquire_global_lock(&pMac->sme);
5817 if (CDF_IS_STATUS_SUCCESS(status)) {
5818#ifdef WLAN_NS_OFFLOAD
5819 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
5820 status = sme_set_ps_ns_offload(hHal, request,
5821 sessionId);
5822 } else
5823#endif /* WLAN_NS_OFFLOAD */
5824 {
5825 status = sme_set_ps_host_offload(hHal, request,
5826 sessionId);
5827 }
5828 sme_release_global_lock(&pMac->sme);
5829 }
5830
5831 return status;
5832}
5833
5834#ifdef WLAN_FEATURE_GTK_OFFLOAD
5835/**
5836 * sme_set_gtk_offload(): API to set GTK offload information.
5837 * @hHal: The handle returned by mac_open.
5838 * @sessionId: Session Identifier
5839 * @pGtkOffload: Pointer to the GTK offload request..
5840 *
5841 * Return CDF_STATUS
5842 */
5843CDF_STATUS sme_set_gtk_offload(tHalHandle hHal,
5844 tpSirGtkOffloadParams pGtkOffload,
5845 uint8_t sessionId)
5846{
5847 tpSirGtkOffloadParams request_buf;
5848 cds_msg_t msg;
5849 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5850 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5851
5852 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_INFO,
5853 "%s: KeyReplayCounter: %lld", __func__,
5854 pGtkOffload->ullKeyReplayCounter);
5855
5856 if (NULL == pSession) {
5857 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5858 "%s: Session not found ", __func__);
5859 return CDF_STATUS_E_FAILURE;
5860 }
5861
5862 request_buf = cdf_mem_malloc(sizeof(*request_buf));
5863 if (NULL == request_buf) {
5864 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5865 FL("Not able to allocate memory for GTK offload request"));
5866 return CDF_STATUS_E_NOMEM;
5867 }
5868
5869 cdf_mem_copy(pGtkOffload->bssId, pSession->connectedProfile.bssid.bytes,
5870 sizeof(tSirMacAddr));
5871
5872 *request_buf = *pGtkOffload;
5873
5874 msg.type = WMA_GTK_OFFLOAD_REQ;
5875 msg.reserved = 0;
5876 msg.bodyptr = request_buf;
5877 if (!CDF_IS_STATUS_SUCCESS
5878 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
5879 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5880 FL("Not able to post SIR_HAL_SET_GTK_OFFLOAD message to HAL"));
5881 cdf_mem_free(request_buf);
5882 return CDF_STATUS_E_FAILURE;
5883 }
5884
5885 return CDF_STATUS_SUCCESS;
5886}
5887
5888/**
5889 * sme_get_gtk_offload(): API to get GTK offload information
5890 * @hHal: The handle returned by mac_open.
5891 * @callback_routine: callback_routine.
5892 * @sessionId: Session Identifier.
5893 * callback_context: callback_context.
5894 *
5895 * Return CDF_STATUS
5896 */
5897CDF_STATUS sme_get_gtk_offload(tHalHandle hHal,
5898 gtk_offload_get_info_callback callback_routine,
5899 void *callback_context, uint8_t session_id)
5900{
5901 tpSirGtkOffloadGetInfoRspParams request_buf;
5902 cds_msg_t msg;
5903 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5904 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, session_id);
5905
5906 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "%s: Entered",
5907 __func__);
5908
5909 if (NULL == pSession) {
5910 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5911 "%s: Session not found ", __func__);
5912 return CDF_STATUS_E_FAILURE;
5913 }
5914
5915 request_buf = cdf_mem_malloc(sizeof(*request_buf));
5916 if (NULL == request_buf) {
5917 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5918 FL("Not able to allocate memory for Get GTK offload request"));
5919 return CDF_STATUS_E_NOMEM;
5920 }
5921
5922 cdf_mem_copy(request_buf->bssId, pSession->connectedProfile.bssid.bytes,
5923 sizeof(tSirMacAddr));
5924
5925 msg.type = WMA_GTK_OFFLOAD_GETINFO_REQ;
5926 msg.reserved = 0;
5927 msg.bodyptr = request_buf;
5928
5929 /* Cache the Get GTK Offload callback information */
5930 if (NULL != pMac->sme.gtk_offload_get_info_cb) {
5931
5932 /* Do we need to check if the callback is in use? */
5933 /* Because we are not sending the same message again
5934 * when it is pending,
5935 * the only case when the callback is not NULL is that
5936 * the previous message was timed out or failed.
5937 * So, it will be safe to set the callback in this case.
5938 */
5939 }
5940
5941 pMac->sme.gtk_offload_get_info_cb = callback_routine;
5942 pMac->sme.gtk_offload_get_info_cb_context = callback_context;
5943
5944 if (!CDF_IS_STATUS_SUCCESS
5945 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
5946 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5947 FL("Not able to post WMA_GTK_OFFLOAD_GETINFO_REQ message to WMA"));
5948 cdf_mem_free(request_buf);
5949 return CDF_STATUS_E_FAILURE;
5950 }
5951
5952 return CDF_STATUS_SUCCESS;
5953}
5954#endif /* WLAN_FEATURE_GTK_OFFLOAD */
5955
5956/* ---------------------------------------------------------------------------
5957 \fn sme_set_keep_alive
5958 \brief API to set the Keep Alive feature.
5959 \param hHal - The handle returned by mac_open.
5960 \param request - Pointer to the Keep Alive request.
5961 \return CDF_STATUS
5962 ---------------------------------------------------------------------------*/
5963CDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
5964 tpSirKeepAliveReq request)
5965{
5966 tpSirKeepAliveReq request_buf;
5967 cds_msg_t msg;
5968 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5969 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, session_id);
5970
5971 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_LOW,
5972 FL("WMA_SET_KEEP_ALIVE message"));
5973
5974 if (pSession == NULL) {
5975 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5976 FL("Session not Found"));
5977 return CDF_STATUS_E_FAILURE;
5978 }
5979 request_buf = cdf_mem_malloc(sizeof(tSirKeepAliveReq));
5980 if (NULL == request_buf) {
5981 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
5982 FL("Not able to allocate memory for keep alive request"));
5983 return CDF_STATUS_E_NOMEM;
5984 }
5985
5986 cdf_mem_copy(request->bssId, pSession->connectedProfile.bssid.bytes,
5987 sizeof(tSirMacAddr));
5988 cdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
5989
5990 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_LOW,
5991 "buff TP %d input TP %d ", request_buf->timePeriod,
5992 request->timePeriod);
5993 request_buf->sessionId = session_id;
5994
5995 msg.type = WMA_SET_KEEP_ALIVE;
5996 msg.reserved = 0;
5997 msg.bodyptr = request_buf;
5998 if (CDF_STATUS_SUCCESS !=
5999 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
6000 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
6001 FL("Not able to post WMA_SET_KEEP_ALIVE message to WMA"));
6002 cdf_mem_free(request_buf);
6003 return CDF_STATUS_E_FAILURE;
6004 }
6005
6006 return CDF_STATUS_SUCCESS;
6007}
6008
6009#ifdef FEATURE_WLAN_SCAN_PNO
6010/* ---------------------------------------------------------------------------
6011 \fn sme_set_preferred_network_list
6012 \brief API to set the Preferred Network List Offload feature.
6013 \param hHal - The handle returned by mac_open.
6014 \param request - Pointer to the offload request.
6015 \return CDF_STATUS
6016 ---------------------------------------------------------------------------*/
6017CDF_STATUS sme_set_preferred_network_list(tHalHandle hHal,
6018 tpSirPNOScanReq request,
6019 uint8_t sessionId,
6020 void (*callback_routine)(void *callback_context,
6021 tSirPrefNetworkFoundInd
6022 *pPrefNetworkFoundInd),
6023 void *callback_context)
6024{
6025 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6026 CDF_STATUS status;
6027
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05306028 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6029 TRACE_CODE_SME_RX_HDD_PREF_NET_LIST,
6030 sessionId, request->ucNetworksCount));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006031 status = sme_acquire_global_lock(&pMac->sme);
6032 if (CDF_IS_STATUS_SUCCESS(status)) {
6033 sme_set_ps_preferred_network_list(hHal, request, sessionId,
6034 callback_routine, callback_context);
6035 sme_release_global_lock(&pMac->sme);
6036 }
6037
6038 return status;
6039}
6040
6041#endif /* FEATURE_WLAN_SCAN_PNO */
6042
6043/* ---------------------------------------------------------------------------
6044 \fn sme_abort_mac_scan
6045 \brief API to cancel MAC scan.
6046 \param hHal - The handle returned by mac_open.
6047 \param sessionId - sessionId on which we need to abort scan.
6048 \param reason - Reason to abort the scan.
6049 \return CDF_STATUS
6050 CDF_STATUS_E_FAILURE - failure
6051 CDF_STATUS_SUCCESS success
6052 ---------------------------------------------------------------------------*/
6053CDF_STATUS sme_abort_mac_scan(tHalHandle hHal, uint8_t sessionId,
6054 eCsrAbortReason reason)
6055{
6056 CDF_STATUS status;
6057 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6058
6059 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6060 TRACE_CODE_SME_RX_HDD_ABORT_MACSCAN, NO_SESSION, 0));
6061 status = sme_acquire_global_lock(&pMac->sme);
6062 if (CDF_IS_STATUS_SUCCESS(status)) {
6063 status = csr_scan_abort_mac_scan(pMac, sessionId, reason);
6064
6065 sme_release_global_lock(&pMac->sme);
6066 }
6067
6068 return status;
6069}
6070
6071/* ----------------------------------------------------------------------------
6072 \fn sme_get_operation_channel
6073 \brief API to get current channel on which STA is parked
6074 this function gives channel information only of infra station or IBSS station
6075 \param hHal, pointer to memory location and sessionId
6076 \returns CDF_STATUS_SUCCESS
6077 CDF_STATUS_E_FAILURE
6078 -------------------------------------------------------------------------------*/
6079CDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
6080 uint8_t sessionId)
6081{
6082 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6083 tCsrRoamSession *pSession;
6084
6085 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
6086 pSession = CSR_GET_SESSION(pMac, sessionId);
6087
6088 if ((pSession->connectedProfile.BSSType ==
6089 eCSR_BSS_TYPE_INFRASTRUCTURE)
6090 || (pSession->connectedProfile.BSSType ==
6091 eCSR_BSS_TYPE_IBSS)
6092 || (pSession->connectedProfile.BSSType ==
6093 eCSR_BSS_TYPE_INFRA_AP)
6094 || (pSession->connectedProfile.BSSType ==
6095 eCSR_BSS_TYPE_START_IBSS)) {
6096 *pChannel = pSession->connectedProfile.operationChannel;
6097 return CDF_STATUS_SUCCESS;
6098 }
6099 }
6100 return CDF_STATUS_E_FAILURE;
6101} /* sme_get_operation_channel ends here */
6102
6103/* ---------------------------------------------------------------------------
6104
6105 \fn sme_RegisterMgtFrame
6106
6107 \brief To register managment frame of specified type and subtype.
6108 \param frameType - type of the frame that needs to be passed to HDD.
6109 \param matchData - data which needs to be matched before passing frame
6110 to HDD.
6111 \param matchDataLen - Length of matched data.
6112 \return CDF_STATUS
6113 -------------------------------------------------------------------------------*/
6114CDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
6115 uint16_t frameType, uint8_t *matchData,
6116 uint16_t matchLen)
6117{
6118 CDF_STATUS status = CDF_STATUS_SUCCESS;
6119 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6120
6121 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6122 TRACE_CODE_SME_RX_HDD_REGISTER_MGMTFR, sessionId, 0));
6123 status = sme_acquire_global_lock(&pMac->sme);
6124 if (CDF_IS_STATUS_SUCCESS(status)) {
6125 tSirRegisterMgmtFrame *pMsg;
6126 uint16_t len;
6127 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
6128
6129 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
6130 sms_log(pMac, LOGE, FL(" session %d not found "),
6131 sessionId);
6132 sme_release_global_lock(&pMac->sme);
6133 return CDF_STATUS_E_FAILURE;
6134 }
6135
6136 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession->sessionActive) {
6137 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
6138 "%s Invalid Sessionid", __func__);
6139 sme_release_global_lock(&pMac->sme);
6140 return CDF_STATUS_E_FAILURE;
6141 }
6142
6143 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
6144
6145 pMsg = cdf_mem_malloc(len);
6146 if (NULL == pMsg)
6147 status = CDF_STATUS_E_NOMEM;
6148 else {
6149 cdf_mem_set(pMsg, len, 0);
6150 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
6151 pMsg->length = len;
6152 pMsg->sessionId = sessionId;
6153 pMsg->registerFrame = true;
6154 pMsg->frameType = frameType;
6155 pMsg->matchLen = matchLen;
6156 cdf_mem_copy(pMsg->matchData, matchData, matchLen);
6157 status = cds_send_mb_message_to_mac(pMsg);
6158 }
6159 sme_release_global_lock(&pMac->sme);
6160 }
6161 return status;
6162}
6163
6164/* ---------------------------------------------------------------------------
6165
6166 \fn sme_DeregisterMgtFrame
6167
6168 \brief To De-register managment frame of specified type and subtype.
6169 \param frameType - type of the frame that needs to be passed to HDD.
6170 \param matchData - data which needs to be matched before passing frame
6171 to HDD.
6172 \param matchDataLen - Length of matched data.
6173 \return CDF_STATUS
6174 -------------------------------------------------------------------------------*/
6175CDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
6176 uint16_t frameType, uint8_t *matchData,
6177 uint16_t matchLen)
6178{
6179 CDF_STATUS status = CDF_STATUS_SUCCESS;
6180 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6181
6182 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6183 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
6184 0));
6185 status = sme_acquire_global_lock(&pMac->sme);
6186 if (CDF_IS_STATUS_SUCCESS(status)) {
6187 tSirRegisterMgmtFrame *pMsg;
6188 uint16_t len;
6189 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
6190
6191 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
6192 sms_log(pMac, LOGE, FL(" session %d not found "),
6193 sessionId);
6194 sme_release_global_lock(&pMac->sme);
6195 return CDF_STATUS_E_FAILURE;
6196 }
6197
6198 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession->sessionActive) {
6199 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
6200 "%s Invalid Sessionid", __func__);
6201 sme_release_global_lock(&pMac->sme);
6202 return CDF_STATUS_E_FAILURE;
6203 }
6204
6205 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
6206
6207 pMsg = cdf_mem_malloc(len);
6208 if (NULL == pMsg)
6209 status = CDF_STATUS_E_NOMEM;
6210 else {
6211 cdf_mem_set(pMsg, len, 0);
6212 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
6213 pMsg->length = len;
6214 pMsg->registerFrame = false;
6215 pMsg->frameType = frameType;
6216 pMsg->matchLen = matchLen;
6217 cdf_mem_copy(pMsg->matchData, matchData, matchLen);
6218 status = cds_send_mb_message_to_mac(pMsg);
6219 }
6220 sme_release_global_lock(&pMac->sme);
6221 }
6222 return status;
6223}
6224
6225/**
6226 * sme_remain_on_channel - API to request remain on channel for 'x' duration
6227 *
6228 * @hHal: pointer to MAC handle
6229 * @session_id: Session identifier
6230 * @channel: channel information
6231 * @duration: duration in ms
6232 * @callback: HDD registered callback to process reaminOnChannelRsp
6233 * @context: HDD Callback param
6234 * @scan_id: scan identifier
6235 *
6236 * This function process the roc request and generates scan identifier.s
6237 *
6238 * Return: CDF_STATUS
6239 */
6240CDF_STATUS sme_remain_on_channel(tHalHandle hHal, uint8_t session_id,
6241 uint8_t channel, uint32_t duration,
6242 remainOnChanCallback callback,
6243 void *pContext, uint8_t isP2PProbeReqAllowed,
6244 uint32_t *scan_id)
6245{
6246 CDF_STATUS status = CDF_STATUS_SUCCESS;
6247 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
6248 uint32_t san_req_id, scan_count;
6249 struct ani_roc_req *roc_msg;
6250 cds_msg_t msg;
6251
6252
6253 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6254 TRACE_CODE_SME_RX_HDD_REMAIN_ONCHAN, session_id, 0));
6255
6256 scan_count = csr_ll_count(&mac_ctx->sme.smeScanCmdActiveList);
6257 if (scan_count >= mac_ctx->scan.max_scan_count) {
6258 sms_log(mac_ctx, LOGE, FL("Max scan reached"));
6259 return CDF_STATUS_E_FAILURE;
6260 }
6261
6262 wma_get_scan_id(&san_req_id);
6263 *scan_id = san_req_id;
6264 status = sme_acquire_global_lock(&mac_ctx->sme);
6265
6266 sms_log(mac_ctx, LOG1, FL(" called"));
6267 roc_msg = cdf_mem_malloc(sizeof(struct ani_roc_req));
6268 if (NULL == roc_msg) {
6269 sms_log(mac_ctx, LOGE,
6270 " scan_req: failed to allocate mem for msg");
6271 sme_release_global_lock(&mac_ctx->sme);
6272 return CDF_STATUS_E_NOMEM;
6273 }
6274 roc_msg->msg_type = eWNI_SME_ROC_CMD;
6275 roc_msg->msg_len = (uint16_t) sizeof(struct ani_roc_req);
6276 roc_msg->session_id = session_id;
6277 roc_msg->callback = callback;
6278 roc_msg->duration = duration;
6279 roc_msg->channel = channel;
6280 roc_msg->is_p2pprobe_allowed = isP2PProbeReqAllowed;
6281 roc_msg->ctx = pContext;
6282 roc_msg->scan_id = *scan_id;
6283 msg.type = eWNI_SME_ROC_CMD;
6284 msg.bodyptr = roc_msg;
6285 msg.reserved = 0;
6286 msg.bodyval = 0;
6287 if (CDF_STATUS_SUCCESS !=
6288 cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
6289 sms_log(mac_ctx, LOGE,
6290 " sme_scan_req failed to post msg");
6291 cdf_mem_free(roc_msg);
6292 status = CDF_STATUS_E_FAILURE;
6293 }
6294 sme_release_global_lock(&mac_ctx->sme);
6295 return status;
6296}
6297
6298/* ---------------------------------------------------------------------------
6299 \fn sme_report_probe_req
6300 \brief API to enable/disable forwarding of probeReq to apps in p2p.
6301 \param hHal - The handle returned by mac_open.
6302 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
6303 \return CDF_STATUS
6304 ---------------------------------------------------------------------------*/
6305
6306#ifndef WLAN_FEATURE_CONCURRENT_P2P
6307CDF_STATUS sme_report_probe_req(tHalHandle hHal, uint8_t flag)
6308{
6309 CDF_STATUS status = CDF_STATUS_SUCCESS;
6310 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6311
6312 do {
6313 /* acquire the lock for the sme object */
6314 status = sme_acquire_global_lock(&pMac->sme);
6315 if (CDF_IS_STATUS_SUCCESS(status)) {
6316 /* call set in context */
6317 pMac->p2pContext.probeReqForwarding = flag;
6318 /* release the lock for the sme object */
6319 sme_release_global_lock(&pMac->sme);
6320 }
6321 } while (0);
6322
6323 sms_log(pMac, LOGW, "exiting function %s", __func__);
6324
6325 return status;
6326}
6327
6328/* ---------------------------------------------------------------------------
6329 \fn sme_update_p2p_ie
6330 \brief API to set the P2p Ie in p2p context
6331 \param hHal - The handle returned by mac_open.
6332 \param p2pIe - Ptr to p2pIe from HDD.
6333 \param p2pIeLength: length of p2pIe
6334 \return CDF_STATUS
6335 ---------------------------------------------------------------------------*/
6336
6337CDF_STATUS sme_update_p2p_ie(tHalHandle hHal, void *p2pIe, uint32_t p2pIeLength)
6338{
6339 CDF_STATUS status = CDF_STATUS_SUCCESS;
6340 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6341
6342 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6343 TRACE_CODE_SME_RX_HDD_UPDATE_P2P_IE, NO_SESSION, 0));
6344 /* acquire the lock for the sme object */
6345 status = sme_acquire_global_lock(&pMac->sme);
6346 if (CDF_IS_STATUS_SUCCESS(status)) {
6347 if (NULL != pMac->p2pContext.probeRspIe) {
6348 cdf_mem_free(pMac->p2pContext.probeRspIe);
6349 pMac->p2pContext.probeRspIeLength = 0;
6350 }
6351
6352 pMac->p2pContext.probeRspIe = cdf_mem_malloc(p2pIeLength);
6353 if (NULL == pMac->p2pContext.probeRspIe) {
6354 sms_log(pMac, LOGE, "%s: Unable to allocate P2P IE",
6355 __func__);
6356 pMac->p2pContext.probeRspIeLength = 0;
6357 status = CDF_STATUS_E_NOMEM;
6358 } else {
6359 pMac->p2pContext.probeRspIeLength = p2pIeLength;
6360
6361 sir_dump_buf(pMac, SIR_LIM_MODULE_ID, LOG2,
6362 pMac->p2pContext.probeRspIe,
6363 pMac->p2pContext.probeRspIeLength);
6364 cdf_mem_copy((uint8_t *) pMac->p2pContext.probeRspIe,
6365 p2pIe, p2pIeLength);
6366 }
6367
6368 /* release the lock for the sme object */
6369 sme_release_global_lock(&pMac->sme);
6370 }
6371
6372 sms_log(pMac, LOG2, "exiting function %s", __func__);
6373
6374 return status;
6375}
6376#endif
6377
6378/* ---------------------------------------------------------------------------
6379 \fn sme_send_action
6380 \brief API to send action frame from supplicant.
6381 \param hHal - The handle returned by mac_open.
6382 \return CDF_STATUS
6383 ---------------------------------------------------------------------------*/
6384
6385CDF_STATUS sme_send_action(tHalHandle hHal, uint8_t sessionId,
6386 const uint8_t *pBuf, uint32_t len,
6387 uint16_t wait, bool noack,
6388 uint16_t channel_freq)
6389{
6390 CDF_STATUS status = CDF_STATUS_SUCCESS;
6391 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6392
6393 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6394 TRACE_CODE_SME_RX_HDD_SEND_ACTION, sessionId, 0));
6395 /* acquire the lock for the sme object */
6396 status = sme_acquire_global_lock(&pMac->sme);
6397 if (CDF_IS_STATUS_SUCCESS(status)) {
6398 p2p_send_action(hHal, sessionId, pBuf, len, wait, noack,
6399 channel_freq);
6400 /* release the lock for the sme object */
6401 sme_release_global_lock(&pMac->sme);
6402 }
6403
6404 sms_log(pMac, LOGW, "exiting function %s", __func__);
6405
6406 return status;
6407}
6408
6409CDF_STATUS sme_cancel_remain_on_channel(tHalHandle hHal,
6410 uint8_t sessionId, uint32_t scan_id)
6411{
6412 CDF_STATUS status = CDF_STATUS_SUCCESS;
6413 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6414
6415 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6416 TRACE_CODE_SME_RX_HDD_CANCEL_REMAIN_ONCHAN, sessionId,
6417 0));
6418 status = sme_acquire_global_lock(&pMac->sme);
6419 if (CDF_IS_STATUS_SUCCESS(status)) {
6420 status = p2p_cancel_remain_on_channel(hHal, sessionId, scan_id);
6421 sme_release_global_lock(&pMac->sme);
6422 }
6423 return status;
6424}
6425
6426/* Power Save Related */
6427CDF_STATUS sme_p2p_set_ps(tHalHandle hHal, tP2pPsConfig *data)
6428{
6429 CDF_STATUS status = CDF_STATUS_SUCCESS;
6430 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6431
6432 status = sme_acquire_global_lock(&pMac->sme);
6433 if (CDF_IS_STATUS_SUCCESS(status)) {
6434 status = p2p_set_ps(hHal, data);
6435 sme_release_global_lock(&pMac->sme);
6436 }
6437 return status;
6438}
6439
6440/* ---------------------------------------------------------------------------
6441
6442 \fn sme_configure_rxp_filter
6443
6444 \brief
6445 SME will pass this request to lower mac to set/reset the filter on RXP for
6446 multicast & broadcast traffic.
6447
6448 \param
6449
6450 hHal - The handle returned by mac_open.
6451
6452 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
6453 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
6454 on this param. In future we can use this as a mask to set various types of
6455 filters as suggested below:
6456 FILTER_ALL_MULTICAST:
6457 FILTER_ALL_BROADCAST:
6458 FILTER_ALL_MULTICAST_BROADCAST:
6459
6460 \return CDF_STATUS
6461
6462 --------------------------------------------------------------------------- */
6463CDF_STATUS sme_configure_rxp_filter(tHalHandle hHal,
6464 tpSirWlanSetRxpFilters wlanRxpFilterParam)
6465{
6466 CDF_STATUS status = CDF_STATUS_SUCCESS;
6467 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6468 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6469 cds_msg_t cds_message;
6470
6471 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6472 TRACE_CODE_SME_RX_HDD_CONFIG_RXPFIL, NO_SESSION, 0));
6473 status = sme_acquire_global_lock(&pMac->sme);
6474 if (CDF_IS_STATUS_SUCCESS(status)) {
6475 /* serialize the req through MC thread */
6476 cds_message.bodyptr = wlanRxpFilterParam;
6477 cds_message.type = WMA_CFG_RXP_FILTER_REQ;
6478 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6479 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6480 status = CDF_STATUS_E_FAILURE;
6481 }
6482 sme_release_global_lock(&pMac->sme);
6483 }
6484 return status;
6485}
6486
6487/* ---------------------------------------------------------------------------
6488
6489 \fn sme_configure_suspend_ind
6490
6491 \brief
6492 SME will pass this request to lower mac to Indicate that the wlan needs to
6493 be suspended
6494
6495 \param
6496
6497 hHal - The handle returned by mac_open.
6498
6499 wlanSuspendParam- Depicts the wlan suspend params
6500
6501 csr_readyToSuspendCallback - Callback to be called when ready to suspend
6502 event is received.
6503 callback_context - Context associated with csr_readyToSuspendCallback.
6504
6505 \return CDF_STATUS
6506
6507 --------------------------------------------------------------------------- */
6508CDF_STATUS sme_configure_suspend_ind(tHalHandle hHal,
6509 tpSirWlanSuspendParam wlanSuspendParam,
6510 csr_readyToSuspendCallback callback,
6511 void *callback_context)
6512{
6513 CDF_STATUS status = CDF_STATUS_SUCCESS;
6514 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6515 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6516 cds_msg_t cds_message;
6517
6518 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6519 TRACE_CODE_SME_RX_HDD_CONFIG_SUSPENDIND, NO_SESSION,
6520 0));
6521
6522 pMac->readyToSuspendCallback = callback;
6523 pMac->readyToSuspendContext = callback_context;
6524
6525 status = sme_acquire_global_lock(&pMac->sme);
6526 if (CDF_IS_STATUS_SUCCESS(status)) {
6527 /* serialize the req through MC thread */
6528 cds_message.bodyptr = wlanSuspendParam;
6529 cds_message.type = WMA_WLAN_SUSPEND_IND;
6530 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6531 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6532 pMac->readyToSuspendCallback = NULL;
6533 pMac->readyToSuspendContext = NULL;
6534 status = CDF_STATUS_E_FAILURE;
6535 }
6536 sme_release_global_lock(&pMac->sme);
6537 }
6538
6539 return status;
6540}
6541
6542/* ---------------------------------------------------------------------------
6543
6544 \fn sme_configure_resume_req
6545
6546 \brief
6547 SME will pass this request to lower mac to Indicate that the wlan needs to
6548 be Resumed
6549
6550 \param
6551
6552 hHal - The handle returned by mac_open.
6553
6554 wlanResumeParam- Depicts the wlan resume params
6555
6556 \return CDF_STATUS
6557
6558 --------------------------------------------------------------------------- */
6559CDF_STATUS sme_configure_resume_req(tHalHandle hHal,
6560 tpSirWlanResumeParam wlanResumeParam)
6561{
6562 CDF_STATUS status = CDF_STATUS_SUCCESS;
6563 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6564 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6565 cds_msg_t cds_message;
6566
6567 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6568 TRACE_CODE_SME_RX_HDD_CONFIG_RESUMEREQ, NO_SESSION,
6569 0));
6570 status = sme_acquire_global_lock(&pMac->sme);
6571 if (CDF_IS_STATUS_SUCCESS(status)) {
6572 /* serialize the req through MC thread */
6573 cds_message.bodyptr = wlanResumeParam;
6574 cds_message.type = WMA_WLAN_RESUME_REQ;
6575 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6576 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6577 status = CDF_STATUS_E_FAILURE;
6578 }
6579 sme_release_global_lock(&pMac->sme);
6580 }
6581 return status;
6582}
6583
6584#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
6585/* ---------------------------------------------------------------------------
6586
6587 \fn sme_configure_ext_wo_w
6588
6589 \brief
6590 SME will pass this request to lower mac to configure Extr WoW
6591
6592 \param
6593
6594 hHal - The handle returned by mac_open.
6595
6596 wlanExtParams- Depicts the wlan Ext params
6597
6598 \return CDF_STATUS
6599
6600 --------------------------------------------------------------------------- */
6601CDF_STATUS sme_configure_ext_wo_w(tHalHandle hHal,
6602 tpSirExtWoWParams wlanExtParams,
6603 csr_readyToExtWoWCallback callback,
6604 void *callback_context)
6605{
6606 CDF_STATUS status = CDF_STATUS_SUCCESS;
6607 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6608 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6609 cds_msg_t cds_message;
6610 tpSirExtWoWParams MsgPtr = cdf_mem_malloc(sizeof(*MsgPtr));
6611
6612 if (!MsgPtr)
6613 return CDF_STATUS_E_NOMEM;
6614
6615 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6616 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
6617
6618 pMac->readyToExtWoWCallback = callback;
6619 pMac->readyToExtWoWContext = callback_context;
6620
6621 status = sme_acquire_global_lock(&pMac->sme);
6622 if (CDF_IS_STATUS_SUCCESS(status)) {
6623
6624 /* serialize the req through MC thread */
6625 cdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
6626 cds_message.bodyptr = MsgPtr;
6627 cds_message.type = WMA_WLAN_EXT_WOW;
6628 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6629 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6630 pMac->readyToExtWoWCallback = NULL;
6631 pMac->readyToExtWoWContext = NULL;
6632 cdf_mem_free(MsgPtr);
6633 status = CDF_STATUS_E_FAILURE;
6634 }
6635 sme_release_global_lock(&pMac->sme);
6636 } else {
6637 pMac->readyToExtWoWCallback = NULL;
6638 pMac->readyToExtWoWContext = NULL;
6639 cdf_mem_free(MsgPtr);
6640 }
6641
6642 return status;
6643}
6644
6645/* ---------------------------------------------------------------------------
6646
6647 \fn sme_configure_app_type1_params
6648
6649 \brief
6650 SME will pass this request to lower mac to configure Indoor WoW parameters.
6651
6652 \param
6653
6654 hHal - The handle returned by mac_open.
6655
6656 wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
6657
6658 \return CDF_STATUS
6659
6660 --------------------------------------------------------------------------- */
6661CDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
6662 tpSirAppType1Params wlanAppType1Params)
6663{
6664 CDF_STATUS status = CDF_STATUS_SUCCESS;
6665 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6666 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6667 cds_msg_t cds_message;
6668 tpSirAppType1Params MsgPtr = cdf_mem_malloc(sizeof(*MsgPtr));
6669
6670 if (!MsgPtr)
6671 return CDF_STATUS_E_NOMEM;
6672
6673 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6674 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
6675 0));
6676
6677 status = sme_acquire_global_lock(&pMac->sme);
6678 if (CDF_IS_STATUS_SUCCESS(status)) {
6679 /* serialize the req through MC thread */
6680 cdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
6681 cds_message.bodyptr = MsgPtr;
6682 cds_message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
6683 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6684 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6685 cdf_mem_free(MsgPtr);
6686 status = CDF_STATUS_E_FAILURE;
6687 }
6688 sme_release_global_lock(&pMac->sme);
6689 } else {
6690 cdf_mem_free(MsgPtr);
6691 }
6692
6693 return status;
6694}
6695
6696/* ---------------------------------------------------------------------------
6697
6698 \fn sme_configure_app_type2_params
6699
6700 \brief
6701 SME will pass this request to lower mac to configure Indoor WoW parameters.
6702
6703 \param
6704
6705 hHal - The handle returned by mac_open.
6706
6707 wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
6708
6709 \return CDF_STATUS
6710
6711 --------------------------------------------------------------------------- */
6712CDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
6713 tpSirAppType2Params wlanAppType2Params)
6714{
6715 CDF_STATUS status = CDF_STATUS_SUCCESS;
6716 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
6717 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6718 cds_msg_t cds_message;
6719 tpSirAppType2Params MsgPtr = cdf_mem_malloc(sizeof(*MsgPtr));
6720
6721 if (!MsgPtr)
6722 return CDF_STATUS_E_NOMEM;
6723
6724 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
6725 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
6726 0));
6727
6728 status = sme_acquire_global_lock(&pMac->sme);
6729 if (CDF_IS_STATUS_SUCCESS(status)) {
6730 /* serialize the req through MC thread */
6731 cdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
6732 cds_message.bodyptr = MsgPtr;
6733 cds_message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
6734 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
6735 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
6736 cdf_mem_free(MsgPtr);
6737 status = CDF_STATUS_E_FAILURE;
6738 }
6739 sme_release_global_lock(&pMac->sme);
6740 } else {
6741 cdf_mem_free(MsgPtr);
6742 }
6743
6744 return status;
6745}
6746#endif
6747
6748/* ---------------------------------------------------------------------------
6749
6750 \fn sme_get_infra_session_id
6751
6752 \brief To get the session ID for infra session, if connected
6753 This is a synchronous API.
6754
6755 \param hHal - The handle returned by mac_open.
6756
6757 \return sessionid, -1 if infra session is not connected
6758
6759 -------------------------------------------------------------------------------*/
6760int8_t sme_get_infra_session_id(tHalHandle hHal)
6761{
6762 CDF_STATUS status = CDF_STATUS_E_FAILURE;
6763 int8_t sessionid = -1;
6764 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6765
6766 status = sme_acquire_global_lock(&pMac->sme);
6767 if (CDF_IS_STATUS_SUCCESS(status)) {
6768
6769 sessionid = csr_get_infra_session_id(pMac);
6770
6771 sme_release_global_lock(&pMac->sme);
6772 }
6773
6774 return sessionid;
6775}
6776
6777/* ---------------------------------------------------------------------------
6778
6779 \fn sme_get_infra_operation_channel
6780
6781 \brief To get the operating channel for infra session, if connected
6782 This is a synchronous API.
6783
6784 \param hHal - The handle returned by mac_open.
6785 \param sessionId - the sessionId returned by sme_open_session.
6786
6787 \return operating channel, 0 if infra session is not connected
6788
6789 -------------------------------------------------------------------------------*/
6790uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
6791{
6792 CDF_STATUS status = CDF_STATUS_E_FAILURE;
6793 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6794 uint8_t channel = 0;
6795 status = sme_acquire_global_lock(&pMac->sme);
6796 if (CDF_IS_STATUS_SUCCESS(status)) {
6797
6798 channel = csr_get_infra_operation_channel(pMac, sessionId);
6799
6800 sme_release_global_lock(&pMac->sme);
6801 }
6802
6803 return channel;
6804}
6805
6806/* This routine will return poerating channel on which other BSS is operating to be used for concurrency mode. */
6807/* If other BSS is not up or not connected it will return 0 */
6808uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
6809{
6810 CDF_STATUS status = CDF_STATUS_E_FAILURE;
6811 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6812 uint8_t channel = 0;
6813 status = sme_acquire_global_lock(&pMac->sme);
6814 if (CDF_IS_STATUS_SUCCESS(status)) {
6815
6816 channel = csr_get_concurrent_operation_channel(pMac);
6817 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_HIGH, "%s: "
6818 " Other Concurrent Channel = %d", __func__, channel);
6819 sme_release_global_lock(&pMac->sme);
6820 }
6821
6822 return channel;
6823}
6824
6825#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6826uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
6827 eCsrPhyMode sapPhyMode,
6828 uint8_t cc_switch_mode)
6829{
6830 CDF_STATUS status = CDF_STATUS_E_FAILURE;
6831 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6832 uint16_t channel = 0;
6833
6834 status = sme_acquire_global_lock(&pMac->sme);
6835 if (CDF_IS_STATUS_SUCCESS(status)) {
6836 channel =
6837 csr_check_concurrent_channel_overlap(pMac, sap_ch, sapPhyMode,
6838 cc_switch_mode);
6839 sme_release_global_lock(&pMac->sme);
6840 }
6841
6842 return channel;
6843}
6844#endif
6845
6846#ifdef FEATURE_WLAN_SCAN_PNO
Varun Reddy Yeturub43fda12015-09-10 18:16:21 -07006847/**
6848 * sme_update_roam_pno_channel_prediction_config() - Update PNO config
6849 * @sme_config: config from SME context
6850 * @hal: Global Hal handle
6851 * @copy_from_to: Used to specify the source and destination
6852 *
6853 * Copy the PNO channel prediction configuration parameters from
6854 * SME context to MAC context or vice-versa
6855 *
6856 * Return: None
6857 */
6858void sme_update_roam_pno_channel_prediction_config(
6859 tHalHandle hal, tpSmeConfigParams sme_config,
6860 uint8_t copy_from_to)
6861{
6862 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
6863 if (copy_from_to == SME_CONFIG_TO_ROAM_CONFIG) {
6864 mac_ctx->roam.configParam.pno_channel_prediction =
6865 sme_config->pno_channel_prediction;
6866 mac_ctx->roam.configParam.top_k_num_of_channels =
6867 sme_config->top_k_num_of_channels;
6868 mac_ctx->roam.configParam.stationary_thresh =
6869 sme_config->stationary_thresh;
6870 mac_ctx->roam.configParam.channel_prediction_full_scan =
6871 sme_config->channel_prediction_full_scan;
6872 } else if (copy_from_to == ROAM_CONFIG_TO_SME_CONFIG) {
6873 sme_config->pno_channel_prediction =
6874 mac_ctx->roam.configParam.pno_channel_prediction;
6875 sme_config->top_k_num_of_channels =
6876 mac_ctx->roam.configParam.top_k_num_of_channels;
6877 sme_config->stationary_thresh =
6878 mac_ctx->roam.configParam.stationary_thresh;
6879 sme_config->channel_prediction_full_scan =
6880 mac_ctx->roam.configParam.channel_prediction_full_scan;
6881 }
6882
6883}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006884/******************************************************************************
6885*
6886* Name: sme_preferred_network_found_ind
6887*
6888* Description:
6889* Invoke Preferred Network Found Indication
6890*
6891* Parameters:
6892* hHal - HAL handle for device
6893* pMsg - found network description
6894*
6895* Returns: CDF_STATUS
6896*
6897******************************************************************************/
6898CDF_STATUS sme_preferred_network_found_ind(tHalHandle hHal, void *pMsg)
6899{
6900 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6901 CDF_STATUS status = CDF_STATUS_SUCCESS;
6902 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd =
6903 (tSirPrefNetworkFoundInd *) pMsg;
6904 uint8_t dumpSsId[SIR_MAC_MAX_SSID_LENGTH + 1];
6905 uint8_t ssIdLength = 0;
6906
6907 if (NULL == pMsg) {
6908 sms_log(pMac, LOGE, "in %s msg ptr is NULL", __func__);
6909 return CDF_STATUS_E_FAILURE;
6910 }
6911
6912 if (pMac->pnoOffload) {
6913 /* Call Preferred Network Found Indication callback routine. */
6914 if (pMac->sme.pref_netw_found_cb != NULL) {
6915 pMac->sme.pref_netw_found_cb(pMac->sme.
6916 preferred_network_found_ind_cb_ctx,
6917 pPrefNetworkFoundInd);
6918 }
6919 return status;
6920 }
6921
6922 if (pPrefNetworkFoundInd->ssId.length > 0) {
6923 ssIdLength = CSR_MIN(SIR_MAC_MAX_SSID_LENGTH,
6924 pPrefNetworkFoundInd->ssId.length);
6925 cdf_mem_copy(dumpSsId, pPrefNetworkFoundInd->ssId.ssId,
6926 ssIdLength);
6927 dumpSsId[ssIdLength] = 0;
6928 sms_log(pMac, LOG2, "%s:SSID=%s frame length %d",
6929 __func__, dumpSsId, pPrefNetworkFoundInd->frameLength);
6930
6931 /* Flush scan results, So as to avoid indication/updation of
6932 * stale entries, which may not have aged out during APPS collapse
6933 */
6934 sme_scan_flush_result(hHal);
6935
6936 /* Save the frame to scan result */
6937 if (pPrefNetworkFoundInd->mesgLen >
6938 sizeof(tSirPrefNetworkFoundInd)) {
6939 /* we may have a frame */
6940 status = csr_scan_save_preferred_network_found(pMac,
6941 pPrefNetworkFoundInd);
6942 if (!CDF_IS_STATUS_SUCCESS(status)) {
6943 sms_log(pMac, LOGE,
6944 FL(" fail to save preferred network"));
6945 }
6946 } else {
6947 sms_log(pMac, LOGE,
6948 FL(" not enough data length %d needed %zu"),
6949 pPrefNetworkFoundInd->mesgLen,
6950 sizeof(tSirPrefNetworkFoundInd));
6951 }
6952
6953 /* Call Preferred Netowrk Found Indication callback routine. */
6954 if (CDF_IS_STATUS_SUCCESS(status)
6955 && (pMac->sme.pref_netw_found_cb != NULL)) {
6956 pMac->sme.pref_netw_found_cb(pMac->sme.
6957 preferred_network_found_ind_cb_ctx,
6958 pPrefNetworkFoundInd);
6959 }
6960 } else {
6961 sms_log(pMac, LOGE, "%s: callback failed - SSID is NULL",
6962 __func__);
6963 status = CDF_STATUS_E_FAILURE;
6964 }
6965
6966 return status;
6967}
6968
6969#endif /* FEATURE_WLAN_SCAN_PNO */
6970
6971CDF_STATUS sme_get_cfg_valid_channels(tHalHandle hHal, uint8_t *aValidChannels,
6972 uint32_t *len)
6973{
6974 CDF_STATUS status = CDF_STATUS_E_FAILURE;
6975 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6976
6977 status = sme_acquire_global_lock(&pMac->sme);
6978 if (CDF_IS_STATUS_SUCCESS(status)) {
6979 status = csr_get_cfg_valid_channels(pMac, aValidChannels, len);
6980 sme_release_global_lock(&pMac->sme);
6981 }
6982
6983 return status;
6984}
6985
6986/* ---------------------------------------------------------------------------
6987
6988 \fn sme_handle_change_country_code
6989
6990 \brief Change Country code, Reg Domain and channel list
6991
6992 \details Country Code Priority
6993 If Supplicant country code is priority than 11d is disabled.
6994 If 11D is enabled, we update the country code after every scan.
6995 Hence when Supplicant country code is priority, we don't need 11D info.
6996 Country code from Supplicant is set as current courtry code.
6997 User can send reset command XX (instead of country code) to reset the
6998 country code to default values.
6999 If 11D is priority,
7000 Than Supplicant country code code is set to default code. But 11D code is set as current country code
7001
7002 \param pMac - The handle returned by mac_open.
7003 \param pMsgBuf - MSG Buffer
7004
7005 \return CDF_STATUS
7006
7007 -------------------------------------------------------------------------------*/
7008CDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac, void *pMsgBuf)
7009{
7010 CDF_STATUS status = CDF_STATUS_SUCCESS;
7011 tAniChangeCountryCodeReq *pMsg;
7012 v_REGDOMAIN_t domainIdIoctl;
7013 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
7014 static country_code_t default_country;
7015 pMsg = (tAniChangeCountryCodeReq *) pMsgBuf;
7016
7017 /*
7018 * if the reset Supplicant country code command is triggered,
7019 * enable 11D, reset the country code and return
7020 */
7021 if (true ==
7022 cdf_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) {
7023 pMac->roam.configParam.Is11dSupportEnabled =
7024 pMac->roam.configParam.Is11dSupportEnabledOriginal;
7025
7026 cdf_status = cds_read_default_country(default_country);
7027
7028 /* read the country code and use it */
7029 if (CDF_IS_STATUS_SUCCESS(cdf_status)) {
7030 cdf_mem_copy(pMsg->countryCode,
7031 default_country,
7032 WNI_CFG_COUNTRY_CODE_LEN);
7033 } else {
7034 status = CDF_STATUS_E_FAILURE;
7035 return status;
7036 }
7037 /*
7038 * Update the 11d country to default country so that when
7039 * callback is received for this default country, driver will
7040 * not disable the 11d taking it as valid country by user.
7041 */
7042 sms_log(pMac, LOG1,
7043 FL("Set default country code (%c%c) as invalid country received"),
7044 pMsg->countryCode[0], pMsg->countryCode[1]);
7045 cdf_mem_copy(pMac->scan.countryCode11d,
7046 pMsg->countryCode,
7047 WNI_CFG_COUNTRY_CODE_LEN);
7048 } else {
7049 /* if Supplicant country code has priority, disable 11d */
7050 if (pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
7051 pMsg->countryFromUserSpace) {
7052 pMac->roam.configParam.Is11dSupportEnabled = false;
7053 }
7054 }
7055
7056 if (pMac->roam.configParam.Is11dSupportEnabled)
7057 return CDF_STATUS_SUCCESS;
7058
7059 /* Set Current Country code and Current Regulatory domain */
7060 status = csr_set_country_code(pMac, pMsg->countryCode);
7061 if (CDF_STATUS_SUCCESS != status) {
7062 /* Supplicant country code failed. So give 11D priority */
7063 pMac->roam.configParam.Is11dSupportEnabled =
7064 pMac->roam.configParam.Is11dSupportEnabledOriginal;
7065 sms_log(pMac, LOGE, "Set Country Code Fail %d", status);
7066 return status;
7067 }
7068
7069 /* overwrite the defualt country code */
7070 cdf_mem_copy(pMac->scan.countryCodeDefault,
7071 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
7072
7073 /* Get Domain ID from country code */
7074 status = csr_get_regulatory_domain_for_country(pMac,
7075 pMac->scan.countryCodeCurrent,
7076 (v_REGDOMAIN_t *) &
7077 domainIdIoctl, COUNTRY_QUERY);
7078 if (status != CDF_STATUS_SUCCESS) {
7079 sms_log(pMac, LOGE, FL(" fail to get regId %d"), domainIdIoctl);
7080 return status;
7081 } else if (REGDOMAIN_WORLD == domainIdIoctl) {
7082 /* Supplicant country code is invalid, so we are on world mode now. So
7083 give 11D chance to update */
7084 pMac->roam.configParam.Is11dSupportEnabled =
7085 pMac->roam.configParam.Is11dSupportEnabledOriginal;
7086 sms_log(pMac, LOG1, FL("Country Code unrecognized by driver"));
7087 }
7088
7089 status = wma_set_reg_domain(pMac, domainIdIoctl);
7090
7091 if (status != CDF_STATUS_SUCCESS) {
7092 sms_log(pMac, LOGE, FL(" fail to set regId %d"), domainIdIoctl);
7093 return status;
7094 } else {
7095 /* if 11d has priority, clear currentCountryBssid & countryCode11d to get */
7096 /* set again if we find AP with 11d info during scan */
7097 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) {
7098 sms_log(pMac, LOGW,
7099 FL
7100 ("Clearing currentCountryBssid, countryCode11d"));
7101 cdf_mem_zero(&pMac->scan.currentCountryBssid,
7102 sizeof(struct cdf_mac_addr));
7103 cdf_mem_zero(pMac->scan.countryCode11d,
7104 sizeof(pMac->scan.countryCode11d));
7105 }
7106 }
7107
7108 if (pMsg->changeCCCallback) {
7109 ((tSmeChangeCountryCallback) (pMsg->changeCCCallback))((void *)
7110 pMsg->
7111 pDevContext);
7112 }
7113
7114 return CDF_STATUS_SUCCESS;
7115}
7116
7117/**
7118 * sme_handle_change_country_code_by_user() - handles country ch req
7119 * @mac_ctx: mac global context
7120 * @msg: request msg packet
7121 *
7122 * If Supplicant country code is priority than 11d is disabled.
7123 * If 11D is enabled, we update the country code after every scan.
7124 * Hence when Supplicant country code is priority, we don't need 11D info.
7125 * Country code from Supplicant is set as current country code.
7126 *
7127 * Return: status of operation
7128 */
7129CDF_STATUS
7130sme_handle_change_country_code_by_user(tpAniSirGlobal mac_ctx,
7131 tAniGenericChangeCountryCodeReq *msg)
7132{
7133 CDF_STATUS status = CDF_STATUS_SUCCESS;
7134 v_REGDOMAIN_t reg_domain_id;
7135 bool is_11d_country = false;
7136 bool supplicant_priority =
7137 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
7138
7139 sms_log(mac_ctx, LOG1, FL(" called"));
7140 reg_domain_id = (v_REGDOMAIN_t) msg->domain_index;
7141 if (memcmp(msg->countryCode, mac_ctx->scan.countryCode11d,
7142 CDS_COUNTRY_CODE_LEN) == 0) {
7143 is_11d_country = true;
7144 }
7145 /* Set the country code given by userspace when 11dOriginal is false
7146 * when 11doriginal is True,is_11d_country =0 and
7147 * fSupplicantCountryCodeHasPriority = 0, then revert the country code,
7148 * and return failure
7149 */
7150 if (mac_ctx->roam.configParam.Is11dSupportEnabledOriginal == true
7151 && !is_11d_country && !supplicant_priority) {
7152 sms_log(mac_ctx, LOGW,
7153 FL("Incorrect country req, nullify this"));
7154
7155 /* we have got a request for a country that should not have been
7156 * added since the STA is associated; nullify this request. If
7157 * both countryCode11d[0] and countryCode11d[1] are zero, revert
7158 * it to World domain to avoid from causing cfg80211 call trace.
7159 */
7160 if ((mac_ctx->scan.countryCode11d[0] == 0)
7161 && (mac_ctx->scan.countryCode11d[1] == 0))
7162 status = csr_get_regulatory_domain_for_country(mac_ctx,
7163 "00", (v_REGDOMAIN_t *) &reg_domain_id,
7164 COUNTRY_IE);
7165 else
7166 status = csr_get_regulatory_domain_for_country(mac_ctx,
7167 mac_ctx->scan.countryCode11d,
7168 (v_REGDOMAIN_t *) &reg_domain_id,
7169 COUNTRY_IE);
7170
7171 return CDF_STATUS_E_FAILURE;
7172 }
7173 /* if Supplicant country code has priority, disable 11d */
7174 if (!is_11d_country && supplicant_priority)
7175 mac_ctx->roam.configParam.Is11dSupportEnabled = false;
7176 cdf_mem_copy(mac_ctx->scan.countryCodeCurrent, msg->countryCode,
7177 WNI_CFG_COUNTRY_CODE_LEN);
7178 status = wma_set_reg_domain(mac_ctx, reg_domain_id);
7179 if (false == is_11d_country) {
7180 /* overwrite the defualt country code */
7181 cdf_mem_copy(mac_ctx->scan.countryCodeDefault,
7182 mac_ctx->scan.countryCodeCurrent,
7183 WNI_CFG_COUNTRY_CODE_LEN);
7184 /* set to default domain ID */
7185 mac_ctx->scan.domainIdDefault = mac_ctx->scan.domainIdCurrent;
7186 }
7187 if (status != CDF_STATUS_SUCCESS) {
7188 sms_log(mac_ctx, LOGE, FL("fail to set regId %d"),
7189 reg_domain_id);
7190 return status;
7191 } else {
7192 /* if 11d has priority, clear currentCountryBssid &
7193 * countryCode11d to get set again if we find AP with 11d info
7194 * during scan
7195 */
7196 if (!supplicant_priority && (false == is_11d_country)) {
7197 sms_log(mac_ctx, LOGW,
7198 FL("Clearing currentCountryBssid, countryCode11d"));
7199 cdf_mem_zero(&mac_ctx->scan.currentCountryBssid,
7200 sizeof(struct cdf_mac_addr));
7201 cdf_mem_zero(mac_ctx->scan.countryCode11d,
7202 sizeof(mac_ctx->scan.countryCode11d));
7203 }
7204 }
7205 /* get the channels based on new cc */
7206 status = csr_get_channel_and_power_list(mac_ctx);
7207
7208 if (status != CDF_STATUS_SUCCESS) {
7209 sms_log(mac_ctx, LOGE, FL("fail to get Channels"));
7210 return status;
7211 }
7212 /* reset info based on new cc, and we are done */
7213 csr_apply_channel_power_info_wrapper(mac_ctx);
7214
7215 /* Country code Changed, Purge Only scan result
7216 * which does not have channel number belong to 11d
7217 * channel list
7218 */
7219 csr_scan_filter_results(mac_ctx);
7220 /* Do active scans after the country is set by User hints or
7221 * Country IE
7222 */
7223 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
7224 sme_disconnect_connected_sessions(mac_ctx);
7225 sms_log(mac_ctx, LOG1, FL(" returned"));
7226 return CDF_STATUS_SUCCESS;
7227}
7228
7229/* ---------------------------------------------------------------------------
7230
7231 \fn sme_handle_change_country_code_by_core
7232
7233 \brief Update Country code in the driver if set by kernel as world
7234
7235 If 11D is enabled, we update the country code after every scan & notify kernel.
7236 This is to make sure kernel & driver are in sync in case of CC found in
7237 driver but not in kernel database
7238
7239 \param pMac - The handle returned by mac_open.
7240 \param pMsg - Carrying new CC set in kernel
7241
7242 \return CDF_STATUS
7243
7244 -------------------------------------------------------------------------------*/
7245CDF_STATUS sme_handle_change_country_code_by_core(tpAniSirGlobal pMac,
7246 tAniGenericChangeCountryCodeReq *
7247 pMsg)
7248{
7249 CDF_STATUS status;
7250
7251 sms_log(pMac, LOG1, FL(" called"));
7252
7253 /* this is to make sure kernel & driver are in sync in case of CC found in */
7254 /* driver but not in kernel database */
7255 if (('0' == pMsg->countryCode[0]) && ('0' == pMsg->countryCode[1])) {
7256 sms_log(pMac, LOGW,
7257 FL
7258 ("Setting countryCode11d & countryCodeCurrent to world CC"));
7259 cdf_mem_copy(pMac->scan.countryCode11d, pMsg->countryCode,
7260 WNI_CFG_COUNTRY_CODE_LEN);
7261 cdf_mem_copy(pMac->scan.countryCodeCurrent, pMsg->countryCode,
7262 WNI_CFG_COUNTRY_CODE_LEN);
7263 }
7264
7265 status = wma_set_reg_domain(pMac, REGDOMAIN_WORLD);
7266
7267 if (status != CDF_STATUS_SUCCESS) {
7268 sms_log(pMac, LOGE, FL(" fail to set regId"));
7269 return status;
7270 } else {
7271 status = csr_get_channel_and_power_list(pMac);
7272 if (status != CDF_STATUS_SUCCESS) {
7273 sms_log(pMac, LOGE, FL(" fail to get Channels "));
7274 } else {
7275 csr_apply_channel_and_power_list(pMac);
7276 }
7277 }
7278 /* Country code Changed, Purge Only scan result
7279 * which does not have channel number belong to 11d
7280 * channel list
7281 */
7282 csr_scan_filter_results(pMac);
7283 sms_log(pMac, LOG1, FL(" returned"));
7284 return CDF_STATUS_SUCCESS;
7285}
7286
7287static bool
7288sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
7289{
7290 uint8_t i;
7291 tCsrChannel *ch_lst_info;
7292 ch_lst_info = &mac_ctx->scan.base_channels;
7293 for (i = 0; i < ch_lst_info->numChannels; i++) {
7294 if (ch_lst_info->channelList[i] == curr_ch)
7295 return true;
7296 }
7297
7298 ch_lst_info = &mac_ctx->scan.base40MHzChannels;
7299 for (i = 0; i < ch_lst_info->numChannels; i++) {
7300 if (ch_lst_info->channelList[i] == curr_ch)
7301 return true;
7302 }
7303 return false;
7304}
7305/**
7306 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
7307 * if channel is not supported
7308 * @mac_ctx: mac global context
7309 *
7310 * If new country code does not support the channel on which STA/P2P client
7311 * is connetced, it sends the disconnect to the AP/P2P GO
7312 *
7313 * Return: void
7314 */
7315void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
7316{
7317 uint8_t session_id, found = false;
7318 uint8_t curr_ch;
7319
7320 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
7321 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
7322 continue;
7323 found = false;
7324 /* Session is connected.Check the channel */
7325 curr_ch = csr_get_infra_operation_channel(mac_ctx,
7326 session_id);
7327 sms_log(mac_ctx, LOGW,
7328 FL("Current Operating channel : %d, session :%d"),
7329 curr_ch, session_id);
7330 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
7331 if (!found) {
7332 sms_log(mac_ctx, LOGW, FL("Disconnect Session :%d"),
7333 session_id);
7334 csr_roam_disconnect(mac_ctx, session_id,
7335 eCSR_DISCONNECT_REASON_UNSPECIFIED);
7336 }
7337 }
7338}
7339
7340/* ---------------------------------------------------------------------------
7341
7342 \fn sme_handle_generic_change_country_code
7343
7344 \brief Change Country code, Reg Domain and channel list
7345
7346 If Supplicant country code is priority than 11d is disabled.
7347 If 11D is enabled, we update the country code after every scan.
7348 Hence when Supplicant country code is priority, we don't need 11D info.
7349 Country code from kernel is set as current country code.
7350
7351 \param pMac - The handle returned by mac_open.
7352 \param pMsgBuf - message buffer
7353
7354 \return CDF_STATUS
7355
7356 -------------------------------------------------------------------------------*/
7357CDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
7358 void *pMsgBuf)
7359{
7360 tAniGenericChangeCountryCodeReq *pMsg;
7361 v_REGDOMAIN_t reg_domain_id;
7362
7363 sms_log(pMac, LOG1, FL(" called"));
7364 pMsg = (tAniGenericChangeCountryCodeReq *) pMsgBuf;
7365 reg_domain_id = (v_REGDOMAIN_t) pMsg->domain_index;
7366
7367 if (REGDOMAIN_COUNT == reg_domain_id) {
7368 sme_handle_change_country_code_by_core(pMac, pMsg);
7369 } else {
7370 sme_handle_change_country_code_by_user(pMac, pMsg);
7371 }
7372 sms_log(pMac, LOG1, FL(" returned"));
7373 return CDF_STATUS_SUCCESS;
7374}
7375
7376#ifdef WLAN_FEATURE_PACKET_FILTERING
7377CDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
7378 tpSirRcvFltMcAddrList pMulticastAddrs)
7379{
7380 tpSirRcvFltMcAddrList request_buf;
7381 cds_msg_t msg;
7382 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7383 tCsrRoamSession *pSession = NULL;
7384
7385 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "%s: "
7386 "ulMulticastAddrCnt=%d, multicastAddr[0]=%p", __func__,
7387 pMulticastAddrs->ulMulticastAddrCnt,
7388 pMulticastAddrs->multicastAddr[0]);
7389
7390 /*
7391 *Find the connected Infra / P2P_client connected session
7392 */
7393 if (CSR_IS_SESSION_VALID(pMac, sessionId) &&
7394 csr_is_conn_state_infra(pMac, sessionId)) {
7395 pSession = CSR_GET_SESSION(pMac, sessionId);
7396 }
7397
7398 if (pSession == NULL) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08007399 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_WARN,
7400 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007401 sessionId);
7402 return CDF_STATUS_E_FAILURE;
7403 }
7404
7405 request_buf = cdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7406 if (NULL == request_buf) {
7407 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7408 "%s: Not able to "
7409 "allocate memory for 8023 Multicast List request",
7410 __func__);
7411 return CDF_STATUS_E_NOMEM;
7412 }
7413
7414 if (!csr_is_conn_state_connected_infra(pMac, sessionId)) {
7415 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7416 "%s: Ignoring the "
7417 "indication as we are not connected", __func__);
7418 cdf_mem_free(request_buf);
7419 return CDF_STATUS_E_FAILURE;
7420 }
7421
7422 cdf_mem_copy(request_buf, pMulticastAddrs,
7423 sizeof(tSirRcvFltMcAddrList));
7424
7425 cdf_mem_copy(request_buf->selfMacAddr, pSession->selfMacAddr.bytes,
7426 sizeof(tSirMacAddr));
7427 cdf_mem_copy(request_buf->bssId, pSession->connectedProfile.bssid.bytes,
7428 sizeof(tSirMacAddr));
7429
7430 msg.type = WMA_8023_MULTICAST_LIST_REQ;
7431 msg.reserved = 0;
7432 msg.bodyptr = request_buf;
7433 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7434 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7435 "%s: Not able to "
7436 "post WMA_8023_MULTICAST_LIST message to WMA",
7437 __func__);
7438 cdf_mem_free(request_buf);
7439 return CDF_STATUS_E_FAILURE;
7440 }
7441
7442 return CDF_STATUS_SUCCESS;
7443}
7444
7445CDF_STATUS sme_receive_filter_set_filter(tHalHandle hHal,
7446 tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
7447 uint8_t sessionId)
7448{
7449 tpSirRcvPktFilterCfgType request_buf;
7450 int32_t allocSize;
7451 cds_msg_t msg;
7452 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7453 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7454 uint8_t idx = 0;
7455
7456 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "%s: filterType=%d, "
7457 "filterId = %d", __func__,
7458 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
7459
7460 allocSize = sizeof(tSirRcvPktFilterCfgType);
7461
7462 request_buf = cdf_mem_malloc(allocSize);
7463
7464 if (NULL == request_buf) {
7465 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7466 "%s: Not able to "
7467 "allocate memory for Receive Filter Set Filter request",
7468 __func__);
7469 return CDF_STATUS_E_NOMEM;
7470 }
7471
7472 if (NULL == pSession) {
7473 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7474 "%s: Session Not found ", __func__);
7475 cdf_mem_free(request_buf);
7476 return CDF_STATUS_E_FAILURE;
7477 }
7478
7479 cdf_mem_copy(pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr.bytes,
7480 sizeof(tSirMacAddr));
7481 cdf_mem_copy(pRcvPktFilterCfg->bssId,
7482 pSession->connectedProfile.bssid.bytes,
7483 sizeof(tSirMacAddr));
7484 cdf_mem_copy(request_buf, pRcvPktFilterCfg, allocSize);
7485
7486 msg.type = WMA_RECEIVE_FILTER_SET_FILTER_REQ;
7487 msg.reserved = 0;
7488 msg.bodyptr = request_buf;
7489
7490 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "Pkt Flt Req : "
7491 "FT %d FID %d ",
7492 request_buf->filterType, request_buf->filterId);
7493
7494 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "Pkt Flt Req : "
7495 "params %d CT %d",
7496 request_buf->numFieldParams, request_buf->coalesceTime);
7497
7498 for (idx = 0; idx < request_buf->numFieldParams; idx++) {
7499
7500 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
7501 "Proto %d Comp Flag %d ",
7502 request_buf->paramsData[idx].protocolLayer,
7503 request_buf->paramsData[idx].cmpFlag);
7504
7505 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
7506 "Data Offset %d Data Len %d",
7507 request_buf->paramsData[idx].dataOffset,
7508 request_buf->paramsData[idx].dataLength);
7509
7510 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
7511 "CData: %d:%d:%d:%d:%d:%d",
7512 request_buf->paramsData[idx].compareData[0],
7513 request_buf->paramsData[idx].compareData[1],
7514 request_buf->paramsData[idx].compareData[2],
7515 request_buf->paramsData[idx].compareData[3],
7516 request_buf->paramsData[idx].compareData[4],
7517 request_buf->paramsData[idx].compareData[5]);
7518
7519 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
7520 "MData: %d:%d:%d:%d:%d:%d",
7521 request_buf->paramsData[idx].dataMask[0],
7522 request_buf->paramsData[idx].dataMask[1],
7523 request_buf->paramsData[idx].dataMask[2],
7524 request_buf->paramsData[idx].dataMask[3],
7525 request_buf->paramsData[idx].dataMask[4],
7526 request_buf->paramsData[idx].dataMask[5]);
7527
7528 }
7529
7530 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7531 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7532 "%s: Not able to post "
7533 "WMA_RECEIVE_FILTER_SET_FILTER message to WMA",
7534 __func__);
7535 cdf_mem_free(request_buf);
7536 return CDF_STATUS_E_FAILURE;
7537 }
7538
7539 return CDF_STATUS_SUCCESS;
7540}
7541
7542CDF_STATUS sme_receive_filter_clear_filter(tHalHandle hHal,
7543 tpSirRcvFltPktClearParam
7544 pRcvFltPktClearParam, uint8_t sessionId)
7545{
7546 tpSirRcvFltPktClearParam request_buf;
7547 cds_msg_t msg;
7548 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7549 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7550
7551 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "%s: filterId = %d",
7552 __func__, pRcvFltPktClearParam->filterId);
7553
7554 request_buf = cdf_mem_malloc(sizeof(tSirRcvFltPktClearParam));
7555 if (NULL == request_buf) {
7556 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7557 "%s: Not able to allocate memory for Receive Filter "
7558 "Clear Filter request", __func__);
7559 return CDF_STATUS_E_NOMEM;
7560 }
7561 if (NULL == pSession) {
7562 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7563 "%s: Session Not find ", __func__);
7564 cdf_mem_free(request_buf);
7565 return CDF_STATUS_E_FAILURE;
7566 }
7567
7568 cdf_mem_copy(pRcvFltPktClearParam->selfMacAddr,
7569 pSession->selfMacAddr.bytes,
7570 sizeof(tSirMacAddr));
7571 cdf_mem_copy(pRcvFltPktClearParam->bssId,
7572 pSession->connectedProfile.bssid.bytes, sizeof(tSirMacAddr));
7573
7574 cdf_mem_copy(request_buf, pRcvFltPktClearParam,
7575 sizeof(tSirRcvFltPktClearParam));
7576
7577 msg.type = WMA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
7578 msg.reserved = 0;
7579 msg.bodyptr = request_buf;
7580 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7581 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7582 "%s: Not able to post "
7583 "WMA_RECEIVE_FILTER_CLEAR_FILTER message to WMA",
7584 __func__);
7585 cdf_mem_free(request_buf);
7586 return CDF_STATUS_E_FAILURE;
7587 }
7588
7589 return CDF_STATUS_SUCCESS;
7590}
7591#endif /* WLAN_FEATURE_PACKET_FILTERING */
7592
7593/* ---------------------------------------------------------------------------
7594
7595 \fn sme_is_channel_valid
7596
7597 \brief To check if the channel is valid for currently established domain
7598 This is a synchronous API.
7599
7600 \param hHal - The handle returned by mac_open.
7601 \param channel - channel to verify
7602
7603 \return true/false, true if channel is valid
7604
7605 -------------------------------------------------------------------------------*/
7606bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
7607{
7608 CDF_STATUS status = CDF_STATUS_E_FAILURE;
7609 bool valid = false;
7610 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7611
7612 status = sme_acquire_global_lock(&pMac->sme);
7613 if (CDF_IS_STATUS_SUCCESS(status)) {
7614
7615 valid = csr_roam_is_channel_valid(pMac, channel);
7616
7617 sme_release_global_lock(&pMac->sme);
7618 }
7619
7620 return valid;
7621}
7622
7623/* ---------------------------------------------------------------------------
7624 \fn sme_set_freq_band
7625 \brief Used to set frequency band.
7626 \param hHal
7627 \param sessionId - Session Identifier
7628 \eBand band value to be configured
7629 \- return CDF_STATUS
7630 -------------------------------------------------------------------------*/
7631CDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId, eCsrBand eBand)
7632{
7633 CDF_STATUS status = CDF_STATUS_E_FAILURE;
7634 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7635
7636 status = sme_acquire_global_lock(&pMac->sme);
7637 if (CDF_IS_STATUS_SUCCESS(status)) {
7638 status = csr_set_band(hHal, sessionId, eBand);
7639 sme_release_global_lock(&pMac->sme);
7640 }
7641 return status;
7642}
7643
7644/* ---------------------------------------------------------------------------
7645 \fn sme_get_freq_band
7646 \brief Used to get the current band settings.
7647 \param hHal
7648 \pBand pointer to hold band value
7649 \- return CDF_STATUS
7650 -------------------------------------------------------------------------*/
7651CDF_STATUS sme_get_freq_band(tHalHandle hHal, eCsrBand *pBand)
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 *pBand = csr_get_current_band(hHal);
7659 sme_release_global_lock(&pMac->sme);
7660 }
7661 return status;
7662}
7663
7664/* ---------------------------------------------------------------------------
7665 \fn sme_set_max_tx_power_per_band
7666
7667 \brief Set the Maximum Transmit Power specific to band dynamically.
7668 Note: this setting will not persist over reboots.
7669
7670 \param band
7671 \param power to set in dB
7672 \- return CDF_STATUS
7673
7674 ----------------------------------------------------------------------------*/
7675CDF_STATUS sme_set_max_tx_power_per_band(eCsrBand band, int8_t dB)
7676{
7677 cds_msg_t msg;
7678 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
7679
7680 pMaxTxPowerPerBandParams =
7681 cdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
7682 if (NULL == pMaxTxPowerPerBandParams) {
7683 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7684 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
7685 __func__);
7686 return CDF_STATUS_E_NOMEM;
7687 }
7688
7689 pMaxTxPowerPerBandParams->power = dB;
7690 pMaxTxPowerPerBandParams->bandInfo = band;
7691
7692 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
7693 msg.reserved = 0;
7694 msg.bodyptr = pMaxTxPowerPerBandParams;
7695
7696 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7697 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7698 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
7699 __func__);
7700 cdf_mem_free(pMaxTxPowerPerBandParams);
7701 return CDF_STATUS_E_FAILURE;
7702 }
7703
7704 return CDF_STATUS_SUCCESS;
7705}
7706
7707/* ---------------------------------------------------------------------------
7708
7709 \fn sme_set_max_tx_power
7710
7711 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
7712 not persist over reboots.
7713
7714 \param hHal
7715 \param pBssid BSSID to set the power cap for
7716 \param pBssid pSelfMacAddress self MAC Address
7717 \param pBssid power to set in dB
7718 \- return CDF_STATUS
7719
7720 -------------------------------------------------------------------------------*/
Srinivas Girigowda97215232015-09-24 12:26:28 -07007721CDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct cdf_mac_addr pBssid,
7722 struct cdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007723{
7724 cds_msg_t msg;
7725 tpMaxTxPowerParams pMaxTxParams = NULL;
7726
7727 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
7728 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
7729 pMaxTxParams = cdf_mem_malloc(sizeof(tMaxTxPowerParams));
7730 if (NULL == pMaxTxParams) {
7731 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7732 "%s: Not able to allocate memory for pMaxTxParams",
7733 __func__);
7734 return CDF_STATUS_E_NOMEM;
7735 }
7736
Srinivas Girigowda97215232015-09-24 12:26:28 -07007737 cdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
7738 cdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007739 pMaxTxParams->power = dB;
7740
7741 msg.type = WMA_SET_MAX_TX_POWER_REQ;
7742 msg.reserved = 0;
7743 msg.bodyptr = pMaxTxParams;
7744
7745 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7746 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7747 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
7748 __func__);
7749 cdf_mem_free(pMaxTxParams);
7750 return CDF_STATUS_E_FAILURE;
7751 }
7752
7753 return CDF_STATUS_SUCCESS;
7754}
7755
7756/* ---------------------------------------------------------------------------
7757
7758 \fn sme_set_custom_mac_addr
7759
7760 \brief Set the customer Mac Address.
7761
7762 \param customMacAddr customer MAC Address
7763 \- return CDF_STATUS
7764
7765 ---------------------------------------------------------------------------*/
7766CDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
7767{
7768 cds_msg_t msg;
7769 tSirMacAddr *pBaseMacAddr;
7770
7771 pBaseMacAddr = cdf_mem_malloc(sizeof(tSirMacAddr));
7772 if (NULL == pBaseMacAddr) {
7773 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7774 FL("Not able to allocate memory for pBaseMacAddr"));
7775 return CDF_STATUS_E_NOMEM;
7776 }
7777
7778 cdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
7779
7780 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
7781 msg.reserved = 0;
7782 msg.bodyptr = pBaseMacAddr;
7783
7784 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7785 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7786 FL
7787 ("Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA"));
7788 cdf_mem_free(pBaseMacAddr);
7789 return CDF_STATUS_E_FAILURE;
7790 }
7791
7792 return CDF_STATUS_SUCCESS;
7793}
7794
7795/* ----------------------------------------------------------------------------
7796 \fn sme_set_tx_power
7797 \brief Set Transmit Power dynamically.
7798 \param hHal
7799 \param sessionId Target Session ID
7800 \pBSSId BSSID
7801 \dev_mode dev_mode such as station, P2PGO, SAP
7802 \param dBm power to set
7803 \- return CDF_STATUS
7804 ---------------------------------------------------------------------------*/
7805CDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Srinivas Girigowda97215232015-09-24 12:26:28 -07007806 struct cdf_mac_addr pBSSId,
7807 tCDF_CON_MODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007808{
7809 cds_msg_t msg;
7810 tpMaxTxPowerParams pTxParams = NULL;
7811 int8_t power = (int8_t) dBm;
7812
7813 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
7814 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
7815
7816 /* make sure there is no overflow */
7817 if ((int)power != dBm) {
7818 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7819 "%s: error, invalid power = %d", __func__, dBm);
7820 return CDF_STATUS_E_FAILURE;
7821 }
7822
7823 pTxParams = cdf_mem_malloc(sizeof(tMaxTxPowerParams));
7824 if (NULL == pTxParams) {
7825 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7826 "%s: Not able to allocate memory for pTxParams",
7827 __func__);
7828 return CDF_STATUS_E_NOMEM;
7829 }
7830
Srinivas Girigowda97215232015-09-24 12:26:28 -07007831 cdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007832 pTxParams->power = power; /* unit is dBm */
7833 pTxParams->dev_mode = dev_mode;
7834 msg.type = WMA_SET_TX_POWER_REQ;
7835 msg.reserved = 0;
7836 msg.bodyptr = pTxParams;
7837
7838 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
7839 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7840 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
7841 __func__);
7842 cdf_mem_free(pTxParams);
7843 return CDF_STATUS_E_FAILURE;
7844 }
7845
7846 return CDF_STATUS_SUCCESS;
7847}
7848
7849/* ---------------------------------------------------------------------------
7850
7851 \fn sme_hide_ssid
7852
7853 \brief hide/show SSID dynamically. Note: this setting will
7854 not persist over reboots.
7855
7856 \param hHal
7857 \param sessionId
7858 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
7859 \- return CDF_STATUS
7860
7861 -------------------------------------------------------------------------------*/
7862CDF_STATUS sme_hide_ssid(tHalHandle hHal, uint8_t sessionId, uint8_t ssidHidden)
7863{
7864 CDF_STATUS status = CDF_STATUS_SUCCESS;
7865 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7866 uint16_t len;
7867
7868 status = sme_acquire_global_lock(&pMac->sme);
7869 if (CDF_IS_STATUS_SUCCESS(status)) {
7870 tpSirUpdateParams pMsg;
7871 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7872
7873 if (!pSession) {
7874 sms_log(pMac, LOGE, FL(" session %d not found "),
7875 sessionId);
7876 sme_release_global_lock(&pMac->sme);
7877 return CDF_STATUS_E_FAILURE;
7878 }
7879
7880 if (!pSession->sessionActive)
7881 CDF_ASSERT(0);
7882
7883 /* Create the message and send to lim */
7884 len = sizeof(tSirUpdateParams);
7885 pMsg = cdf_mem_malloc(len);
7886 if (NULL == pMsg)
7887 status = CDF_STATUS_E_NOMEM;
7888 else {
7889 cdf_mem_set(pMsg, sizeof(tSirUpdateParams), 0);
7890 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
7891 pMsg->length = len;
7892 /* Data starts from here */
7893 pMsg->sessionId = sessionId;
7894 pMsg->ssidHidden = ssidHidden;
7895 status = cds_send_mb_message_to_mac(pMsg);
7896 }
7897 sme_release_global_lock(&pMac->sme);
7898 }
7899 return status;
7900}
7901
7902/* ---------------------------------------------------------------------------
7903
7904 \fn sme_set_tm_level
7905 \brief Set Thermal Mitigation Level to RIVA
7906 \param hHal - The handle returned by mac_open.
7907 \param newTMLevel - new Thermal Mitigation Level
7908 \param tmMode - Thermal Mitigation handle mode, default 0
7909 \return CDF_STATUS
7910 ---------------------------------------------------------------------------*/
7911CDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t tmMode)
7912{
7913 CDF_STATUS status = CDF_STATUS_SUCCESS;
7914 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
7915 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7916 cds_msg_t cds_message;
7917 tAniSetTmLevelReq *setTmLevelReq = NULL;
7918
7919 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
7920 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
7921 status = sme_acquire_global_lock(&pMac->sme);
7922 if (CDF_IS_STATUS_SUCCESS(status)) {
7923 setTmLevelReq =
7924 (tAniSetTmLevelReq *)
7925 cdf_mem_malloc(sizeof(tAniSetTmLevelReq));
7926 if (NULL == setTmLevelReq) {
7927 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7928 "%s: Not able to allocate memory for sme_set_tm_level",
7929 __func__);
7930 sme_release_global_lock(&pMac->sme);
7931 return CDF_STATUS_E_NOMEM;
7932 }
7933
7934 setTmLevelReq->tmMode = tmMode;
7935 setTmLevelReq->newTmLevel = newTMLevel;
7936
7937 /* serialize the req through MC thread */
7938 cds_message.bodyptr = setTmLevelReq;
7939 cds_message.type = WMA_SET_TM_LEVEL_REQ;
7940 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
7941 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
7942 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
7943 "%s: Post Set TM Level MSG fail", __func__);
7944 cdf_mem_free(setTmLevelReq);
7945 status = CDF_STATUS_E_FAILURE;
7946 }
7947 sme_release_global_lock(&pMac->sme);
7948 }
7949 return status;
7950}
7951
7952/*---------------------------------------------------------------------------
7953
7954 \brief sme_feature_caps_exchange() - SME interface to exchange capabilities between
7955 Host and FW.
7956
7957 \param hHal - HAL handle for device
7958
7959 \return NONE
7960
7961 ---------------------------------------------------------------------------*/
7962void sme_feature_caps_exchange(tHalHandle hHal)
7963{
7964 MTRACE(cdf_trace
7965 (CDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH, NO_SESSION,
7966 0));
7967}
7968
7969/*---------------------------------------------------------------------------
7970
7971 \brief sme_disable_feature_capablity() - SME interface to disable Active mode offload capablity
7972 in Host.
7973
7974 \param hHal - HAL handle for device
7975
7976 \return NONE
7977
7978 ---------------------------------------------------------------------------*/
7979void sme_disable_feature_capablity(uint8_t feature_index)
7980{
7981}
7982
7983/* ---------------------------------------------------------------------------
7984 \fn sme_reset_power_values_for5_g
7985 \brief Reset the power values for 5G band with default power values.
7986 \param hHal - HAL handle for device
7987 \- return NONE
7988 -------------------------------------------------------------------------*/
7989void sme_reset_power_values_for5_g(tHalHandle hHal)
7990{
7991 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7992 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
7993 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
7994 csr_save_channel_power_for_band(pMac, true);
7995 csr_apply_power2_current(pMac); /* Store the channel+power info in the global place: Cfg */
7996}
7997
7998#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
7999/* ---------------------------------------------------------------------------
8000 \fn sme_update_roam_prefer5_g_hz
8001 \brief enable/disable Roam prefer 5G runtime option
8002 This function is called through dynamic setConfig callback function
8003 to configure the Roam prefer 5G runtime option
8004 \param hHal - HAL handle for device
8005 \param nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
8006 \- return Success or failure
8007 -------------------------------------------------------------------------*/
8008
8009CDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal, bool nRoamPrefer5GHz)
8010{
8011 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8012 CDF_STATUS status = CDF_STATUS_SUCCESS;
8013
8014 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8015 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
8016 status = sme_acquire_global_lock(&pMac->sme);
8017 if (CDF_IS_STATUS_SUCCESS(status)) {
8018 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8019 "%s: gRoamPrefer5GHz is changed from %d to %d",
8020 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
8021 nRoamPrefer5GHz);
8022 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
8023 sme_release_global_lock(&pMac->sme);
8024 }
8025
8026 return status;
8027}
8028
8029/* ---------------------------------------------------------------------------
8030 \fn sme_set_roam_intra_band
8031 \brief enable/disable Intra band roaming
8032 This function is called through dynamic setConfig callback function
8033 to configure the intra band roaming
8034 \param hHal - HAL handle for device
8035 \param nRoamIntraBand Enable/Disable Intra band roaming
8036 \- return Success or failure
8037 -------------------------------------------------------------------------*/
8038CDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
8039{
8040 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8041 CDF_STATUS status = CDF_STATUS_SUCCESS;
8042
8043 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8044 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
8045 status = sme_acquire_global_lock(&pMac->sme);
8046 if (CDF_IS_STATUS_SUCCESS(status)) {
8047 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8048 "%s: gRoamIntraBand is changed from %d to %d",
8049 __func__, pMac->roam.configParam.nRoamIntraBand,
8050 nRoamIntraBand);
8051 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
8052 sme_release_global_lock(&pMac->sme);
8053 }
8054
8055 return status;
8056}
8057
8058/* ---------------------------------------------------------------------------
8059 \fn sme_update_roam_scan_n_probes
8060 \brief function to update roam scan N probes
8061 This function is called through dynamic setConfig callback function
8062 to update roam scan N probes
8063 \param hHal - HAL handle for device
8064 \param sessionId - Session Identifier
8065 \param nProbes number of probe requests to be sent out
8066 \- return Success or failure
8067 -------------------------------------------------------------------------*/
8068CDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
8069 const uint8_t nProbes)
8070{
8071 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8072 CDF_STATUS status = CDF_STATUS_SUCCESS;
8073
8074 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8075 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
8076 NO_SESSION, 0));
8077 status = sme_acquire_global_lock(&pMac->sme);
8078 if (CDF_IS_STATUS_SUCCESS(status)) {
8079 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8080 "%s: gRoamScanNProbes is changed from %d to %d",
8081 __func__, pMac->roam.configParam.nProbes, nProbes);
8082 pMac->roam.configParam.nProbes = nProbes;
8083 sme_release_global_lock(&pMac->sme);
8084 }
8085 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8086 csr_roam_offload_scan(pMac, sessionId,
8087 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8088 REASON_NPROBES_CHANGED);
8089 }
8090 return status;
8091}
8092
8093/* ---------------------------------------------------------------------------
8094 \fn sme_update_roam_scan_home_away_time
8095 \brief function to update roam scan Home away time
8096 This function is called through dynamic setConfig callback function
8097 to update roam scan home away time
8098 \param hHal - HAL handle for device
8099 \param sessionId - Session Identifier
8100 \param nRoamScanAwayTime Scan home away time
8101 \param bSendOffloadCmd If true then send offload command to firmware
8102 If false then command is not sent to firmware
8103 \- return Success or failure
8104 -------------------------------------------------------------------------*/
8105CDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
8106 uint8_t sessionId,
8107 const uint16_t nRoamScanHomeAwayTime,
8108 const bool bSendOffloadCmd)
8109{
8110 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8111 CDF_STATUS status = CDF_STATUS_SUCCESS;
8112
8113 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8114 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
8115 NO_SESSION, 0));
8116 status = sme_acquire_global_lock(&pMac->sme);
8117 if (CDF_IS_STATUS_SUCCESS(status)) {
8118 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8119 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
8120 __func__,
8121 pMac->roam.configParam.nRoamScanHomeAwayTime,
8122 nRoamScanHomeAwayTime);
8123 pMac->roam.configParam.nRoamScanHomeAwayTime =
8124 nRoamScanHomeAwayTime;
8125 sme_release_global_lock(&pMac->sme);
8126 }
8127 if (pMac->roam.configParam.isRoamOffloadScanEnabled && bSendOffloadCmd) {
8128 csr_roam_offload_scan(pMac, sessionId,
8129 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8130 REASON_HOME_AWAY_TIME_CHANGED);
8131 }
8132 return status;
8133}
8134
Abhishek Singh518323d2015-10-19 17:42:01 +05308135/**
8136 * sme_ext_change_channel()- function to post send ECSA
8137 * action frame to csr.
8138 * @hHal: Hal context
8139 * @channel: new channel to switch
8140 * @session_id: senssion it should be sent on.
8141 *
8142 * This function is called to post ECSA frame to csr.
8143 *
8144 * Return: success if msg is sent else return failure
8145 */
8146CDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
8147 uint8_t session_id)
8148{
8149 CDF_STATUS status = CDF_STATUS_SUCCESS;
8150 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
8151 uint8_t channel_state;
8152
8153 sms_log(mac_ctx, LOGE, FL(" Set Channel %d "), channel);
8154 channel_state =
8155 cds_get_channel_state(channel);
8156
8157 if (CHANNEL_STATE_DISABLE == channel_state) {
8158 sms_log(mac_ctx, LOGE, FL(" Invalid channel %d "), channel);
8159 return CDF_STATUS_E_INVAL;
8160 }
8161
8162 status = sme_acquire_global_lock(&mac_ctx->sme);
8163
8164 if (CDF_STATUS_SUCCESS == status) {
8165 /* update the channel list to the firmware */
8166 status = csr_send_ext_change_channel(mac_ctx,
8167 channel, session_id);
8168 sme_release_global_lock(&mac_ctx->sme);
8169 }
8170
8171 return status;
8172}
8173
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008174/* ---------------------------------------------------------------------------
8175 \fn sme_get_roam_intra_band
8176 \brief get Intra band roaming
8177 \param hHal - HAL handle for device
8178 \- return Success or failure
8179 -------------------------------------------------------------------------*/
8180bool sme_get_roam_intra_band(tHalHandle hHal)
8181{
8182 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8183 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8184 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
8185 return pMac->roam.configParam.nRoamIntraBand;
8186}
8187
8188/* ---------------------------------------------------------------------------
8189 \fn sme_get_roam_scan_n_probes
8190 \brief get N Probes
8191 \param hHal - HAL handle for device
8192 \- return Success or failure
8193 -------------------------------------------------------------------------*/
8194uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
8195{
8196 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8197 return pMac->roam.configParam.nProbes;
8198}
8199
8200/* ---------------------------------------------------------------------------
8201 \fn sme_get_roam_scan_home_away_time
8202 \brief get Roam scan home away time
8203 \param hHal - HAL handle for device
8204 \- return Success or failure
8205 -------------------------------------------------------------------------*/
8206uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
8207{
8208 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8209 return pMac->roam.configParam.nRoamScanHomeAwayTime;
8210}
8211
8212/* ---------------------------------------------------------------------------
8213 \fn sme_update_roam_rssi_diff
8214 \brief Update RoamRssiDiff
8215 This function is called through dynamic setConfig callback function
8216 to configure RoamRssiDiff
8217 Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
8218 \param hHal - HAL handle for device
8219 \param sessionId - Session Identifier
8220 \param RoamRssiDiff - minimum rssi difference between potential
8221 candidate and current AP.
8222 \- return Success or failure
8223 -------------------------------------------------------------------------*/
8224
8225CDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
8226 uint8_t RoamRssiDiff)
8227{
8228 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8229 CDF_STATUS status = CDF_STATUS_SUCCESS;
8230
8231 status = sme_acquire_global_lock(&pMac->sme);
8232 if (CDF_IS_STATUS_SUCCESS(status)) {
8233 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8234 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
8235 RoamRssiDiff,
8236 pMac->roam.configParam.RoamRssiDiff,
8237 mac_trace_get_neighbour_roam_state(pMac->roam.
8238 neighborRoamInfo
8239 [sessionId].
8240 neighborRoamState));
8241 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
8242 sme_release_global_lock(&pMac->sme);
8243 }
8244 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8245 csr_roam_offload_scan(pMac, sessionId,
8246 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8247 REASON_RSSI_DIFF_CHANGED);
8248 }
8249 return status;
8250}
8251
8252/*--------------------------------------------------------------------------
8253 \brief sme_update_fast_transition_enabled() - enable/disable Fast Transition
8254 support at runtime
8255 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8256 isFastTransitionEnabled.
8257 This is a synchronous call
8258 \param hHal - The handle returned by mac_open.
8259 \return CDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
8260 successfully.
8261 Other status means SME is failed to update isFastTransitionEnabled.
8262 \sa
8263 --------------------------------------------------------------------------*/
8264CDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
8265 bool isFastTransitionEnabled)
8266{
8267 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8268 CDF_STATUS status = CDF_STATUS_SUCCESS;
8269
8270 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8271 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
8272 0));
8273 status = sme_acquire_global_lock(&pMac->sme);
8274 if (CDF_IS_STATUS_SUCCESS(status)) {
8275 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8276 "%s: FastTransitionEnabled is changed from %d to %d",
8277 __func__,
8278 pMac->roam.configParam.isFastTransitionEnabled,
8279 isFastTransitionEnabled);
8280 pMac->roam.configParam.isFastTransitionEnabled =
8281 isFastTransitionEnabled;
8282 sme_release_global_lock(&pMac->sme);
8283 }
8284
8285 return status;
8286}
8287
8288/* ---------------------------------------------------------------------------
8289 \fn sme_update_wes_mode
8290 \brief Update WES Mode
8291 This function is called through dynamic setConfig callback function
8292 to configure isWESModeEnabled
8293 \param hHal - HAL handle for device
8294 \param isWESModeEnabled - WES mode
8295 \param sessionId - Session Identifier
8296 \return CDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
8297 Other status means SME is failed to update isWESModeEnabled.
8298 -------------------------------------------------------------------------*/
8299
8300CDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
8301 uint8_t sessionId)
8302{
8303 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8304 CDF_STATUS status = CDF_STATUS_SUCCESS;
8305
8306 status = sme_acquire_global_lock(&pMac->sme);
8307 if (CDF_IS_STATUS_SUCCESS(status)) {
8308 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8309 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
8310 isWESModeEnabled,
8311 pMac->roam.configParam.isWESModeEnabled,
8312 mac_trace_get_neighbour_roam_state(pMac->roam.
8313 neighborRoamInfo
8314 [sessionId].
8315 neighborRoamState));
8316 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
8317 sme_release_global_lock(&pMac->sme);
8318 }
8319
8320 return status;
8321}
8322
8323/* ---------------------------------------------------------------------------
8324 \fn sme_set_roam_scan_control
8325 \brief Set roam scan control
8326 This function is called to set roam scan control
8327 if roam scan control is set to 0, roaming scan cache is cleared
8328 any value other than 0 is treated as invalid value
8329 \param hHal - HAL handle for device
8330 \param sessionId - Session Identifier
8331 \return CDF_STATUS_SUCCESS - SME update config successfully.
8332 Other status means SME failure to update
8333 -------------------------------------------------------------------------*/
8334CDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
8335 bool roamScanControl)
8336{
8337 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8338 CDF_STATUS status = CDF_STATUS_SUCCESS;
8339
8340 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
8341 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
8342 status = sme_acquire_global_lock(&pMac->sme);
8343 if (CDF_IS_STATUS_SUCCESS(status)) {
8344 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8345 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
8346 roamScanControl,
8347 pMac->roam.configParam.nRoamScanControl,
8348 mac_trace_get_neighbour_roam_state(pMac->roam.
8349 neighborRoamInfo
8350 [sessionId].
8351 neighborRoamState));
8352 pMac->roam.configParam.nRoamScanControl = roamScanControl;
8353 if (0 == roamScanControl) {
8354 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8355 "LFR runtime successfully cleared roam scan cache");
8356 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8357 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8358 csr_roam_offload_scan(pMac, sessionId,
8359 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8360 REASON_FLUSH_CHANNEL_LIST);
8361 }
8362 }
8363 sme_release_global_lock(&pMac->sme);
8364 }
8365 return status;
8366}
8367#endif /* (WLAN_FEATURE_VOWIFI_11R) || (FEATURE_WLAN_ESE) || (FEATURE_WLAN_LFR) */
8368
8369#ifdef FEATURE_WLAN_LFR
8370/*--------------------------------------------------------------------------
8371 \brief sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
8372 support at runtime
8373 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8374 isFastRoamIniFeatureEnabled.
8375 This is a synchronous call
8376 \param hHal - The handle returned by mac_open.
8377 \param sessionId - Session Identifier
8378 \return CDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
8379 successfully.
8380 Other status means SME is failed to update isFastRoamIniFeatureEnabled.
8381 \sa
8382 --------------------------------------------------------------------------*/
8383CDF_STATUS sme_update_is_fast_roam_ini_feature_enabled
8384 (tHalHandle hHal,
8385 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled) {
8386 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8387
8388 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
8389 isFastRoamIniFeatureEnabled) {
8390 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8391 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
8392 __func__,
8393 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
8394 isFastRoamIniFeatureEnabled);
8395 return CDF_STATUS_SUCCESS;
8396 }
8397
8398 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8399 "%s: FastRoamEnabled is changed from %d to %d", __func__,
8400 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
8401 isFastRoamIniFeatureEnabled);
8402 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
8403 isFastRoamIniFeatureEnabled;
8404 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
8405 isFastRoamIniFeatureEnabled);
8406
8407 return CDF_STATUS_SUCCESS;
8408}
8409
8410/*--------------------------------------------------------------------------
8411 \brief sme_update_is_mawc_ini_feature_enabled() -
8412 Enable/disable LFR MAWC support at runtime
8413 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8414 isMAWCIniFeatureEnabled.
8415 This is a synchronous call
8416 \param hHal - The handle returned by mac_open.
8417 \return CDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
8418 Other status means SME is failed to update MAWCEnabled.
8419 \sa
8420 --------------------------------------------------------------------------*/
8421CDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
8422 const bool MAWCEnabled)
8423{
8424 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8425 CDF_STATUS status = CDF_STATUS_SUCCESS;
8426
8427 status = sme_acquire_global_lock(&pMac->sme);
8428 if (CDF_IS_STATUS_SUCCESS(status)) {
8429 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8430 "%s: MAWCEnabled is changed from %d to %d", __func__,
8431 pMac->roam.configParam.MAWCEnabled, MAWCEnabled);
8432 pMac->roam.configParam.MAWCEnabled = MAWCEnabled;
8433 sme_release_global_lock(&pMac->sme);
8434 }
8435
8436 return status;
8437
8438}
8439
8440/*--------------------------------------------------------------------------
8441 \brief sme_stop_roaming() - Stop roaming for a given sessionId
8442 This is a synchronous call
8443 \param hHal - The handle returned by mac_open
8444 \param sessionId - Session Identifier
8445 \return CDF_STATUS_SUCCESS on success
8446 Other status on failure
8447 \sa
8448 --------------------------------------------------------------------------*/
8449CDF_STATUS sme_stop_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
8450{
8451 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8452 CDF_STATUS status = CDF_STATUS_SUCCESS;
8453
8454 status = sme_acquire_global_lock(&pMac->sme);
8455 if (CDF_IS_STATUS_SUCCESS(status)) {
8456 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_STOP,
8457 reason);
8458 sme_release_global_lock(&pMac->sme);
8459 }
8460
8461 return status;
8462}
8463
8464/*--------------------------------------------------------------------------
8465 \brief sme_start_roaming() - Start roaming for a given sessionId
8466 This is a synchronous call
8467 \param hHal - The handle returned by mac_open
8468 \param sessionId - Session Identifier
8469 \return CDF_STATUS_SUCCESS on success
8470 Other status on failure
8471 \sa
8472 --------------------------------------------------------------------------*/
8473CDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
8474{
8475 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8476 CDF_STATUS status = CDF_STATUS_SUCCESS;
8477
8478 status = sme_acquire_global_lock(&pMac->sme);
8479 if (CDF_IS_STATUS_SUCCESS(status)) {
8480 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
8481 reason);
8482 sme_release_global_lock(&pMac->sme);
8483 }
8484
8485 return status;
8486}
8487
8488/*--------------------------------------------------------------------------
8489 \brief sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
8490 Concurrent session exists
8491 This is a synchronuous call
8492 \param hHal - The handle returned by mac_open.
8493 \return CDF_STATUS_SUCCESS
8494 Other status means SME is failed
8495 \sa
8496 --------------------------------------------------------------------------*/
8497
8498CDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
8499 bool
8500 bFastRoamInConIniFeatureEnabled)
8501{
8502
8503 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8504 CDF_STATUS status = CDF_STATUS_SUCCESS;
8505
8506 status = sme_acquire_global_lock(&pMac->sme);
8507 if (CDF_IS_STATUS_SUCCESS(status)) {
8508 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
8509 bFastRoamInConIniFeatureEnabled;
8510 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
8511 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
8512 0;
8513 }
8514 sme_release_global_lock(&pMac->sme);
8515 }
8516
8517 return status;
8518}
8519#endif /* FEATURE_WLAN_LFR */
8520
8521#ifdef FEATURE_WLAN_ESE
8522/*--------------------------------------------------------------------------
8523 \brief sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
8524 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8525 isEseIniFeatureEnabled.
8526 This is a synchronous call
8527 \param hHal - The handle returned by mac_open.
8528 \param sessionId - Session Identifier
8529 \param isEseIniFeatureEnabled - flag to enable/disable
8530 \return CDF_STATUS_SUCCESS - SME update isEseIniFeatureEnabled config
8531 successfully.
8532 Other status means SME is failed to update isEseIniFeatureEnabled.
8533 \sa
8534 --------------------------------------------------------------------------*/
8535CDF_STATUS sme_update_is_ese_feature_enabled
8536 (tHalHandle hHal, uint8_t sessionId, const bool isEseIniFeatureEnabled) {
8537 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8538
8539 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
8540 isEseIniFeatureEnabled) {
8541 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8542 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
8543 __func__,
8544 pMac->roam.configParam.isEseIniFeatureEnabled,
8545 isEseIniFeatureEnabled);
8546 return CDF_STATUS_SUCCESS;
8547 }
8548
8549 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
8550 "%s: EseEnabled is changed from %d to %d", __func__,
8551 pMac->roam.configParam.isEseIniFeatureEnabled,
8552 isEseIniFeatureEnabled);
8553 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
8554 csr_neighbor_roam_update_ese_mode_enabled(pMac, sessionId,
8555 isEseIniFeatureEnabled);
8556
8557 if (true == isEseIniFeatureEnabled) {
8558 sme_update_fast_transition_enabled(hHal, true);
8559 }
8560 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8561 csr_roam_offload_scan(pMac, sessionId,
8562 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8563 REASON_ESE_INI_CFG_CHANGED);
8564 }
8565 return CDF_STATUS_SUCCESS;
8566}
8567#endif /* FEATURE_WLAN_ESE */
8568
8569/*--------------------------------------------------------------------------
8570 \brief sme_update_config_fw_rssi_monitoring() - enable/disable firmware RSSI
8571 Monitoring at runtime
8572 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8573 fEnableFwRssiMonitoring.
8574 This is a synchronous call
8575 \param hHal - The handle returned by mac_open.
8576 \return CDF_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring.
8577 config successfully.
8578 Other status means SME is failed to update fEnableFwRssiMonitoring.
8579 \sa
8580 --------------------------------------------------------------------------*/
8581
8582CDF_STATUS sme_update_config_fw_rssi_monitoring(tHalHandle hHal,
8583 bool fEnableFwRssiMonitoring)
8584{
8585 CDF_STATUS cdf_ret_status = CDF_STATUS_SUCCESS;
8586
8587 if (sme_cfg_set_int (hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR,
8588 fEnableFwRssiMonitoring) == CDF_STATUS_E_FAILURE) {
8589 cdf_ret_status = CDF_STATUS_E_FAILURE;
8590 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
8591 "Could not pass on WNI_CFG_PS_RSSI_MONITOR to CFG");
8592 }
8593
8594 return cdf_ret_status;
8595}
8596
8597#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8598/* ---------------------------------------------------------------------------
8599 \fn sme_set_roam_opportunistic_scan_threshold_diff
8600 \brief Update Opportunistic Scan threshold diff
8601 This function is called through dynamic setConfig callback function
8602 to configure nOpportunisticThresholdDiff
8603 \param hHal - HAL handle for device
8604 \param sessionId - Session Identifier
8605 \param nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
8606 \return CDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
8607 successfully.
8608 else SME is failed to update nOpportunisticThresholdDiff.
8609 -------------------------------------------------------------------------*/
8610CDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
8611 uint8_t sessionId,
8612 const uint8_t
8613 nOpportunisticThresholdDiff)
8614{
8615 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8616 CDF_STATUS status = CDF_STATUS_SUCCESS;
8617
8618 status = sme_acquire_global_lock(&pMac->sme);
8619 if (CDF_IS_STATUS_SUCCESS(status)) {
8620 status = csr_neighbor_roam_set_opportunistic_scan_threshold_diff(pMac,
8621 sessionId,
8622 nOpportunisticThresholdDiff);
8623 if (CDF_IS_STATUS_SUCCESS(status)) {
8624 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8625 "LFR runtime successfully set "
8626 "opportunistic threshold diff to %d"
8627 " - old value is %d - roam state is %d",
8628 nOpportunisticThresholdDiff,
8629 pMac->roam.configParam.neighborRoamConfig.
8630 nOpportunisticThresholdDiff,
8631 pMac->roam.neighborRoamInfo[sessionId].
8632 neighborRoamState);
8633 pMac->roam.configParam.neighborRoamConfig.
8634 nOpportunisticThresholdDiff =
8635 nOpportunisticThresholdDiff;
8636 }
8637 sme_release_global_lock(&pMac->sme);
8638 }
8639 return status;
8640}
8641
8642/*--------------------------------------------------------------------------
8643 \fn sme_get_roam_opportunistic_scan_threshold_diff()
8644 \brief gets Opportunistic Scan threshold diff
8645 This is a synchronous call
8646 \param hHal - The handle returned by mac_open
8647 \return uint8_t - nOpportunisticThresholdDiff
8648 \sa
8649 --------------------------------------------------------------------------*/
8650uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
8651{
8652 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8653 return pMac->roam.configParam.neighborRoamConfig.
8654 nOpportunisticThresholdDiff;
8655}
8656
8657/* ---------------------------------------------------------------------------
8658 \fn sme_set_roam_rescan_rssi_diff
8659 \brief Update roam rescan rssi diff
8660 This function is called through dynamic setConfig callback function
8661 to configure nRoamRescanRssiDiff
8662 \param hHal - HAL handle for device
8663 \param sessionId - Session Identifier
8664 \param nRoamRescanRssiDiff - roam rescan rssi diff
8665 \return CDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
8666 successfully.
8667 else SME is failed to update nRoamRescanRssiDiff.
8668 -------------------------------------------------------------------------*/
8669CDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
8670 uint8_t sessionId,
8671 const uint8_t nRoamRescanRssiDiff)
8672{
8673 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8674 CDF_STATUS status = CDF_STATUS_SUCCESS;
8675
8676 status = sme_acquire_global_lock(&pMac->sme);
8677 if (CDF_IS_STATUS_SUCCESS(status)) {
8678 status = csr_neighbor_roam_set_roam_rescan_rssi_diff(pMac, sessionId,
8679 nRoamRescanRssiDiff);
8680 if (CDF_IS_STATUS_SUCCESS(status)) {
8681 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8682 "LFR runtime successfully set "
8683 "opportunistic threshold diff to %d"
8684 " - old value is %d - roam state is %d",
8685 nRoamRescanRssiDiff,
8686 pMac->roam.configParam.neighborRoamConfig.
8687 nRoamRescanRssiDiff,
8688 pMac->roam.neighborRoamInfo[sessionId].
8689 neighborRoamState);
8690 pMac->roam.configParam.neighborRoamConfig.
8691 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
8692 }
8693 sme_release_global_lock(&pMac->sme);
8694 }
8695 return status;
8696}
8697
8698/*--------------------------------------------------------------------------
8699 \fn sme_get_roam_rescan_rssi_diff
8700 \brief gets roam rescan rssi diff
8701 This is a synchronous call
8702 \param hHal - The handle returned by mac_open
8703 \return int8_t - nRoamRescanRssiDiff
8704 \sa
8705 --------------------------------------------------------------------------*/
8706uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
8707{
8708 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8709 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
8710}
8711
8712/* ---------------------------------------------------------------------------
8713 \fn sme_set_roam_bmiss_first_bcnt
8714 \brief Update Roam count for first beacon miss
8715 This function is called through dynamic setConfig callback function
8716 to configure nRoamBmissFirstBcnt
8717 \param hHal - HAL handle for device
8718 \param sessionId - Session Identifier
8719 \param nRoamBmissFirstBcnt - Roam first bmiss count
8720 \return CDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
8721 successfully.
8722 else SME is failed to update nRoamBmissFirstBcnt
8723 -------------------------------------------------------------------------*/
8724CDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
8725 uint8_t sessionId,
8726 const uint8_t nRoamBmissFirstBcnt)
8727{
8728 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8729 CDF_STATUS status = CDF_STATUS_SUCCESS;
8730
8731 status = sme_acquire_global_lock(&pMac->sme);
8732 if (CDF_IS_STATUS_SUCCESS(status)) {
8733 status = csr_neighbor_roam_set_roam_bmiss_first_bcnt(pMac, sessionId,
8734 nRoamBmissFirstBcnt);
8735 if (CDF_IS_STATUS_SUCCESS(status)) {
8736 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8737 "LFR runtime successfully set "
8738 "beacon miss first beacon count to %d"
8739 " - old value is %d - roam state is %d",
8740 nRoamBmissFirstBcnt,
8741 pMac->roam.configParam.neighborRoamConfig.
8742 nRoamBmissFirstBcnt,
8743 pMac->roam.neighborRoamInfo[sessionId].
8744 neighborRoamState);
8745 pMac->roam.configParam.neighborRoamConfig.
8746 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
8747 }
8748 sme_release_global_lock(&pMac->sme);
8749 }
8750 return status;
8751}
8752
8753/* ---------------------------------------------------------------------------
8754 \fn sme_get_roam_bmiss_first_bcnt
8755 \brief get neighbor roam beacon miss first count
8756 \param hHal - The handle returned by mac_open.
8757 \return uint8_t - neighbor roam beacon miss first count
8758 -------------------------------------------------------------------------*/
8759uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
8760{
8761 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8762 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
8763}
8764
8765/* ---------------------------------------------------------------------------
8766 \fn sme_set_roam_bmiss_final_bcnt
8767 \brief Update Roam count for final beacon miss
8768 This function is called through dynamic setConfig callback function
8769 to configure nRoamBmissFinalBcnt
8770 \param hHal - HAL handle for device
8771 \param sessionId - Session Identifier
8772 \param nRoamBmissFinalBcnt - Roam final bmiss count
8773 \return CDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
8774 successfully.
8775 else SME is failed to update nRoamBmissFinalBcnt
8776 -------------------------------------------------------------------------*/
8777CDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
8778 uint8_t sessionId,
8779 const uint8_t nRoamBmissFinalBcnt)
8780{
8781 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8782 CDF_STATUS status = CDF_STATUS_SUCCESS;
8783
8784 status = sme_acquire_global_lock(&pMac->sme);
8785 if (CDF_IS_STATUS_SUCCESS(status)) {
8786 status = csr_neighbor_roam_set_roam_bmiss_final_bcnt(pMac, sessionId,
8787 nRoamBmissFinalBcnt);
8788 if (CDF_IS_STATUS_SUCCESS(status)) {
8789 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8790 "LFR runtime successfully set "
8791 "beacon miss final beacon count to %d"
8792 " - old value is %d - roam state is %d",
8793 nRoamBmissFinalBcnt,
8794 pMac->roam.configParam.neighborRoamConfig.
8795 nRoamBmissFinalBcnt,
8796 pMac->roam.neighborRoamInfo[sessionId].
8797 neighborRoamState);
8798 pMac->roam.configParam.neighborRoamConfig.
8799 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
8800 }
8801 sme_release_global_lock(&pMac->sme);
8802 }
8803 return status;
8804}
8805
8806/*--------------------------------------------------------------------------
8807 \fn sme_get_roam_bmiss_final_bcnt
8808 \brief gets Roam count for final beacon miss
8809 This is a synchronous call
8810 \param hHal - The handle returned by mac_open
8811 \return uint8_t - nRoamBmissFinalBcnt
8812 \sa
8813 --------------------------------------------------------------------------*/
8814uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
8815{
8816 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8817 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
8818}
8819
8820/* ---------------------------------------------------------------------------
8821 \fn sme_set_roam_beacon_rssi_weight
8822 \brief Update Roam beacon rssi weight
8823 This function is called through dynamic setConfig callback function
8824 to configure nRoamBeaconRssiWeight
8825 \param hHal - HAL handle for device
8826 \param sessionId - Session Identifier
8827 \param nRoamBeaconRssiWeight - Roam beacon rssi weight
8828 \return CDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
8829 successfully.
8830 else SME is failed to update nRoamBeaconRssiWeight
8831 -------------------------------------------------------------------------*/
8832CDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
8833 uint8_t sessionId,
8834 const uint8_t nRoamBeaconRssiWeight)
8835{
8836 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8837 CDF_STATUS status = CDF_STATUS_SUCCESS;
8838
8839 status = sme_acquire_global_lock(&pMac->sme);
8840 if (CDF_IS_STATUS_SUCCESS(status)) {
8841 status = csr_neighbor_roam_set_roam_beacon_rssi_weight(pMac, sessionId,
8842 nRoamBeaconRssiWeight);
8843 if (CDF_IS_STATUS_SUCCESS(status)) {
8844 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8845 "LFR runtime successfully set "
8846 "beacon miss final beacon count to %d"
8847 " - old value is %d - roam state is %d",
8848 nRoamBeaconRssiWeight,
8849 pMac->roam.configParam.neighborRoamConfig.
8850 nRoamBeaconRssiWeight,
8851 pMac->roam.neighborRoamInfo[sessionId].
8852 neighborRoamState);
8853 pMac->roam.configParam.neighborRoamConfig.
8854 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
8855 }
8856 sme_release_global_lock(&pMac->sme);
8857 }
8858 return status;
8859}
8860
8861/*--------------------------------------------------------------------------
8862 \fn sme_get_roam_beacon_rssi_weight
8863 \brief gets Roam beacon rssi weight
8864 This is a synchronous call
8865 \param hHal - The handle returned by mac_open
8866 \return uint8_t - nRoamBeaconRssiWeight
8867 \sa
8868 --------------------------------------------------------------------------*/
8869uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
8870{
8871 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8872 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
8873}
8874
8875/*--------------------------------------------------------------------------
8876 \brief sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
8877 rssi threshold
8878 This is a synchronous call
8879 \param hHal - The handle returned by mac_open.
8880 \param sessionId - Session Identifier
8881 \return CDF_STATUS_SUCCESS - SME update config successful.
8882 Other status means SME is failed to update
8883 \sa
8884 --------------------------------------------------------------------------*/
8885CDF_STATUS sme_set_neighbor_lookup_rssi_threshold
8886 (tHalHandle hHal, uint8_t sessionId, uint8_t neighborLookupRssiThreshold) {
8887 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8888 CDF_STATUS status = CDF_STATUS_SUCCESS;
8889
8890 status = sme_acquire_global_lock(&pMac->sme);
8891 if (CDF_IS_STATUS_SUCCESS(status)) {
8892 status = csr_neighbor_roam_set_lookup_rssi_threshold(pMac, sessionId,
8893 neighborLookupRssiThreshold);
8894 if (CDF_IS_STATUS_SUCCESS(status)) {
8895 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8896 "LFR runtime successfully set Lookup threshold to %d - old value is %d - roam state is %s",
8897 neighborLookupRssiThreshold,
8898 pMac->roam.configParam.neighborRoamConfig.
8899 nNeighborLookupRssiThreshold,
8900 mac_trace_get_neighbour_roam_state(pMac->roam.
8901 neighborRoamInfo
8902 [sessionId].
8903 neighborRoamState));
8904 pMac->roam.configParam.neighborRoamConfig.
8905 nNeighborLookupRssiThreshold =
8906 neighborLookupRssiThreshold;
8907 }
8908 sme_release_global_lock(&pMac->sme);
8909 }
8910 return status;
8911}
8912
8913/*--------------------------------------------------------------------------
8914 \brief sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
8915 This is a synchronous call
8916 \param hal - The handle returned by macOpen.
8917 \param session_id - Session Identifier
8918 \param delay_before_vdev_stop - value to be set
8919 \return CDF_STATUS_SUCCESS - SME update config successful.
8920 Other status means SME is failed to update
8921 \sa
8922 --------------------------------------------------------------------------*/
8923CDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
8924 uint8_t session_id,
8925 uint8_t delay_before_vdev_stop)
8926{
8927 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
8928 CDF_STATUS status = CDF_STATUS_SUCCESS;
8929 status = sme_acquire_global_lock(&pMac->sme);
8930 if (CDF_IS_STATUS_SUCCESS(status)) {
8931 CDF_TRACE(CDF_MODULE_ID_SME,
8932 CDF_TRACE_LEVEL_DEBUG,
8933 FL("LFR param delay_before_vdev_stop changed from %d to %d"),
8934 pMac->roam.configParam.neighborRoamConfig.
8935 delay_before_vdev_stop,
8936 delay_before_vdev_stop);
8937 pMac->roam.neighborRoamInfo[session_id].cfgParams.
8938 delay_before_vdev_stop = delay_before_vdev_stop;
8939 pMac->roam.configParam.neighborRoamConfig.
8940 delay_before_vdev_stop = delay_before_vdev_stop;
8941 sme_release_global_lock(&pMac->sme);
8942 }
8943 return status;
8944}
8945
8946/*--------------------------------------------------------------------------
8947 \brief sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
8948 rssi threshold
8949 This is a synchronous call
8950 \param hHal - The handle returned by mac_open.
8951 \return CDF_STATUS_SUCCESS - SME update config successful.
8952 Other status means SME is failed to update
8953 \sa
8954 --------------------------------------------------------------------------*/
8955uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
8956{
8957 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8958 return pMac->roam.configParam.neighborRoamConfig.
8959 nNeighborLookupRssiThreshold;
8960}
8961
8962/*--------------------------------------------------------------------------
8963 \brief sme_set_neighbor_scan_refresh_period() - set neighbor scan results
8964 refresh period
8965 This is a synchronous call
8966 \param hHal - The handle returned by mac_open.
8967 \param sessionId - Session Identifier
8968 \return CDF_STATUS_SUCCESS - SME update config successful.
8969 Other status means SME is failed to update
8970 \sa
8971 --------------------------------------------------------------------------*/
8972CDF_STATUS sme_set_neighbor_scan_refresh_period
8973 (tHalHandle hHal,
8974 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod) {
8975 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8976 CDF_STATUS status = CDF_STATUS_SUCCESS;
8977 tCsrNeighborRoamConfig *pNeighborRoamConfig = NULL;
8978 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8979
8980 status = sme_acquire_global_lock(&pMac->sme);
8981 if (CDF_IS_STATUS_SUCCESS(status)) {
8982 pNeighborRoamConfig =
8983 &pMac->roam.configParam.neighborRoamConfig;
8984 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
8985 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
8986 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
8987 neighborScanResultsRefreshPeriod,
8988 pMac->roam.configParam.neighborRoamConfig.
8989 nNeighborResultsRefreshPeriod,
8990 mac_trace_get_neighbour_roam_state(pMac->roam.
8991 neighborRoamInfo
8992 [sessionId].
8993 neighborRoamState));
8994 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
8995 neighborScanResultsRefreshPeriod;
8996 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
8997 neighborScanResultsRefreshPeriod;
8998
8999 sme_release_global_lock(&pMac->sme);
9000 }
9001 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
9002 csr_roam_offload_scan(pMac, sessionId,
9003 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9004 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
9005 }
9006 return status;
9007}
9008
9009/*--------------------------------------------------------------------------
9010 \brief sme_update_roam_scan_offload_enabled() - enable/disable roam scan
9011 offload feaure
9012 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
9013 gRoamScanOffloadEnabled.
9014 This is a synchronous call
9015 \param hHal - The handle returned by mac_open.
9016 \return CDF_STATUS_SUCCESS - SME update config successfully.
9017 Other status means SME is failed to update.
9018 \sa
9019 --------------------------------------------------------------------------*/
9020
9021CDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
9022 bool nRoamScanOffloadEnabled)
9023{
9024 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9025 CDF_STATUS status = CDF_STATUS_SUCCESS;
9026
9027 status = sme_acquire_global_lock(&pMac->sme);
9028 if (CDF_IS_STATUS_SUCCESS(status)) {
9029 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9030 FL
9031 ("gRoamScanOffloadEnabled is changed from %d to %d"),
9032 pMac->roam.configParam.isRoamOffloadScanEnabled,
9033 nRoamScanOffloadEnabled);
9034 pMac->roam.configParam.isRoamOffloadScanEnabled =
9035 nRoamScanOffloadEnabled;
9036 sme_release_global_lock(&pMac->sme);
9037 }
9038
9039 return status;
9040}
9041
9042/*--------------------------------------------------------------------------
9043 \brief sme_get_neighbor_scan_refresh_period() - get neighbor scan results
9044 refresh period
9045 This is a synchronous call
9046 \param hHal - The handle returned by mac_open.
9047 \return uint16_t - Neighbor scan results refresh period value
9048 \sa
9049 --------------------------------------------------------------------------*/
9050uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
9051{
9052 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9053 return pMac->roam.configParam.neighborRoamConfig.
9054 nNeighborResultsRefreshPeriod;
9055}
9056
9057/*--------------------------------------------------------------------------
9058 \brief sme_get_empty_scan_refresh_period() - get empty scan refresh period
9059 This is a synchronuous call
9060 \param hHal - The handle returned by mac_open.
9061 \return CDF_STATUS_SUCCESS - SME update config successful.
9062 Other status means SME is failed to update
9063 \sa
9064 --------------------------------------------------------------------------*/
9065uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
9066{
9067 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9068 return pMac->roam.configParam.neighborRoamConfig.
9069 nEmptyScanRefreshPeriod;
9070}
9071
9072/* ---------------------------------------------------------------------------
9073 \fn sme_update_empty_scan_refresh_period
9074 \brief Update nEmptyScanRefreshPeriod
9075 This function is called through dynamic setConfig callback function
9076 to configure nEmptyScanRefreshPeriod
9077 Usage: adb shell iwpriv wlan0 setConfig
9078 nEmptyScanRefreshPeriod=[0 .. 60]
9079 \param hHal - HAL handle for device
9080 \param sessionId - Session Identifier
9081 \param nEmptyScanRefreshPeriod - scan period following empty scan results.
9082 \- return Success or failure
9083 -------------------------------------------------------------------------*/
9084
9085CDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t sessionId,
9086 uint16_t nEmptyScanRefreshPeriod)
9087{
9088 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9089 CDF_STATUS status = CDF_STATUS_SUCCESS;
9090 tCsrNeighborRoamConfig *pNeighborRoamConfig = NULL;
9091 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
9092
9093 status = sme_acquire_global_lock(&pMac->sme);
9094 if (CDF_IS_STATUS_SUCCESS(status)) {
9095 pNeighborRoamConfig =
9096 &pMac->roam.configParam.neighborRoamConfig;
9097 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
9098 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9099 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
9100 nEmptyScanRefreshPeriod,
9101 pMac->roam.configParam.neighborRoamConfig.
9102 nEmptyScanRefreshPeriod,
9103 mac_trace_get_neighbour_roam_state(pMac->roam.
9104 neighborRoamInfo
9105 [sessionId].
9106 neighborRoamState));
9107 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
9108 nEmptyScanRefreshPeriod;
9109 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
9110 nEmptyScanRefreshPeriod;
9111 sme_release_global_lock(&pMac->sme);
9112 }
9113 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
9114 csr_roam_offload_scan(pMac, sessionId,
9115 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9116 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
9117 }
9118 return status;
9119}
9120
9121/* ---------------------------------------------------------------------------
9122 \fn sme_set_neighbor_scan_min_chan_time
9123 \brief Update nNeighborScanMinChanTime
9124 This function is called through dynamic setConfig callback function
9125 to configure gNeighborScanChannelMinTime
9126 Usage: adb shell iwpriv wlan0 setConfig
9127 gNeighborScanChannelMinTime=[0 .. 60]
9128 \param hHal - HAL handle for device
9129 \param nNeighborScanMinChanTime - Channel minimum dwell time
9130 \param sessionId - Session Identifier
9131 \- return Success or failure
9132 -------------------------------------------------------------------------*/
9133CDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
9134 const uint16_t
9135 nNeighborScanMinChanTime,
9136 uint8_t sessionId)
9137{
9138 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9139 CDF_STATUS status = CDF_STATUS_SUCCESS;
9140
9141 status = sme_acquire_global_lock(&pMac->sme);
9142 if (CDF_IS_STATUS_SUCCESS(status)) {
9143 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9144 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
9145 nNeighborScanMinChanTime,
9146 pMac->roam.configParam.neighborRoamConfig.
9147 nNeighborScanMinChanTime,
9148 mac_trace_get_neighbour_roam_state(pMac->roam.
9149 neighborRoamInfo
9150 [sessionId].
9151 neighborRoamState));
9152
9153 pMac->roam.configParam.neighborRoamConfig.
9154 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
9155 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
9156 minChannelScanTime = nNeighborScanMinChanTime;
9157 sme_release_global_lock(&pMac->sme);
9158 }
9159
9160 return status;
9161}
9162
9163/* ---------------------------------------------------------------------------
9164 \fn sme_set_neighbor_scan_max_chan_time
9165 \brief Update nNeighborScanMaxChanTime
9166 This function is called through dynamic setConfig callback function
9167 to configure gNeighborScanChannelMaxTime
9168 Usage: adb shell iwpriv wlan0 setConfig
9169 gNeighborScanChannelMaxTime=[0 .. 60]
9170 \param hHal - HAL handle for device
9171 \param sessionId - Session Identifier
9172 \param nNeighborScanMinChanTime - Channel maximum dwell time
9173 \- return Success or failure
9174 -------------------------------------------------------------------------*/
9175CDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId,
9176 const uint16_t
9177 nNeighborScanMaxChanTime)
9178{
9179 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9180 CDF_STATUS status = CDF_STATUS_SUCCESS;
9181 tCsrNeighborRoamConfig *pNeighborRoamConfig = NULL;
9182 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
9183
9184 status = sme_acquire_global_lock(&pMac->sme);
9185 if (CDF_IS_STATUS_SUCCESS(status)) {
9186 pNeighborRoamConfig =
9187 &pMac->roam.configParam.neighborRoamConfig;
9188 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
9189 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9190 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
9191 nNeighborScanMaxChanTime,
9192 pMac->roam.configParam.neighborRoamConfig.
9193 nNeighborScanMaxChanTime,
9194 mac_trace_get_neighbour_roam_state(pMac->roam.
9195 neighborRoamInfo
9196 [sessionId].
9197 neighborRoamState));
9198 pNeighborRoamConfig->nNeighborScanMaxChanTime =
9199 nNeighborScanMaxChanTime;
9200 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
9201 nNeighborScanMaxChanTime;
9202 sme_release_global_lock(&pMac->sme);
9203 }
9204 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
9205 csr_roam_offload_scan(pMac, sessionId,
9206 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9207 REASON_SCAN_CH_TIME_CHANGED);
9208 }
9209
9210 return status;
9211}
9212
9213/* ---------------------------------------------------------------------------
9214 \fn sme_get_neighbor_scan_min_chan_time
9215 \brief get neighbor scan min channel time
9216 \param hHal - The handle returned by mac_open.
9217 \param sessionId - Session Identifier
9218 \return uint16_t - channel min time value
9219 -------------------------------------------------------------------------*/
9220uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
9221{
9222 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9223 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
9224 minChannelScanTime;
9225}
9226
9227/* ---------------------------------------------------------------------------
9228 \fn sme_get_neighbor_roam_state
9229 \brief get neighbor roam state
9230 \param hHal - The handle returned by mac_open.
9231 \param sessionId - Session Identifier
9232 \return uint32_t - neighbor roam state
9233 -------------------------------------------------------------------------*/
9234uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
9235{
9236 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9237 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
9238}
9239
9240/* ---------------------------------------------------------------------------
9241 \fn sme_get_current_roam_state
9242 \brief get current roam state
9243 \param hHal - The handle returned by mac_open.
9244 \param sessionId - Session Identifier
9245 \return uint32_t - current roam state
9246 -------------------------------------------------------------------------*/
9247uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
9248{
9249 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9250 return pMac->roam.curState[sessionId];
9251}
9252
9253/* ---------------------------------------------------------------------------
9254 \fn sme_get_current_roam_sub_state
9255 \brief get neighbor roam sub state
9256 \param hHal - The handle returned by mac_open.
9257 \param sessionId - Session Identifier
9258 \return uint32_t - current roam sub state
9259 -------------------------------------------------------------------------*/
9260uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
9261{
9262 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9263 return pMac->roam.curSubState[sessionId];
9264}
9265
9266/* ---------------------------------------------------------------------------
9267 \fn sme_get_lim_sme_state
9268 \brief get Lim Sme state
9269 \param hHal - The handle returned by mac_open.
9270 \return uint32_t - Lim Sme state
9271 -------------------------------------------------------------------------*/
9272uint32_t sme_get_lim_sme_state(tHalHandle hHal)
9273{
9274 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9275 return pMac->lim.gLimSmeState;
9276}
9277
9278/* ---------------------------------------------------------------------------
9279 \fn sme_get_lim_mlm_state
9280 \brief get Lim Mlm state
9281 \param hHal - The handle returned by mac_open.
9282 \return uint32_t - Lim Mlm state
9283 -------------------------------------------------------------------------*/
9284uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
9285{
9286 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9287 return pMac->lim.gLimMlmState;
9288}
9289
9290/* ---------------------------------------------------------------------------
9291 \fn sme_is_lim_session_valid
9292 \brief is Lim session valid
9293 \param hHal - The handle returned by mac_open.
9294 \param sessionId - Session Identifier
9295 \return bool - true or false
9296 -------------------------------------------------------------------------*/
9297bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
9298{
9299 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9300 return pMac->lim.gpSession[sessionId].valid;
9301}
9302
9303/* ---------------------------------------------------------------------------
9304 \fn sme_get_lim_sme_session_state
9305 \brief get Lim Sme session state
9306 \param hHal - The handle returned by mac_open.
9307 \param sessionId - Session Identifier
9308 \return uint32_t - Lim Sme session state
9309 -------------------------------------------------------------------------*/
9310uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
9311{
9312 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9313 return pMac->lim.gpSession[sessionId].limSmeState;
9314}
9315
9316/* ---------------------------------------------------------------------------
9317 \fn sme_get_lim_mlm_session_state
9318 \brief get Lim Mlm session state
9319 \param hHal - The handle returned by mac_open.
9320 \param sessionId - Session Identifier
9321 \return uint32_t - Lim Mlm session state
9322 -------------------------------------------------------------------------*/
9323uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
9324{
9325 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9326 return pMac->lim.gpSession[sessionId].limMlmState;
9327}
9328
9329/* ---------------------------------------------------------------------------
9330 \fn sme_get_neighbor_scan_max_chan_time
9331 \brief get neighbor scan max channel time
9332 \param hHal - The handle returned by mac_open.
9333 \param sessionId - Session Identifier
9334 \return uint16_t - channel max time value
9335 -------------------------------------------------------------------------*/
9336uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
9337{
9338 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9339 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
9340 maxChannelScanTime;
9341}
9342
9343/* ---------------------------------------------------------------------------
9344 \fn sme_set_neighbor_scan_period
9345 \brief Update nNeighborScanPeriod
9346 This function is called through dynamic setConfig callback function
9347 to configure nNeighborScanPeriod
9348 Usage: adb shell iwpriv wlan0 setConfig
9349 nNeighborScanPeriod=[0 .. 1000]
9350 \param hHal - HAL handle for device
9351 \param sessionId - Session Identifier
9352 \param nNeighborScanPeriod - neighbor scan period
9353 \- return Success or failure
9354 -------------------------------------------------------------------------*/
9355CDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
9356 const uint16_t nNeighborScanPeriod)
9357{
9358 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9359 CDF_STATUS status = CDF_STATUS_SUCCESS;
9360 tCsrNeighborRoamConfig *pNeighborRoamConfig = NULL;
9361 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
9362
9363 status = sme_acquire_global_lock(&pMac->sme);
9364 if (CDF_IS_STATUS_SUCCESS(status)) {
9365 pNeighborRoamConfig =
9366 &pMac->roam.configParam.neighborRoamConfig;
9367 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
9368 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9369 "LFR runtime successfully set neighbor scan period to %d"
9370 " - old value is %d - roam state is %s",
9371 nNeighborScanPeriod,
9372 pMac->roam.configParam.neighborRoamConfig.
9373 nNeighborScanTimerPeriod,
9374 mac_trace_get_neighbour_roam_state(pMac->roam.
9375 neighborRoamInfo
9376 [sessionId].
9377 neighborRoamState));
9378 pNeighborRoamConfig->nNeighborScanTimerPeriod =
9379 nNeighborScanPeriod;
9380 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
9381 nNeighborScanPeriod;
9382 sme_release_global_lock(&pMac->sme);
9383 }
9384 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
9385 csr_roam_offload_scan(pMac, sessionId,
9386 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9387 REASON_SCAN_HOME_TIME_CHANGED);
9388 }
9389
9390 return status;
9391}
9392
9393/* ---------------------------------------------------------------------------
9394 \fn sme_get_neighbor_scan_period
9395 \brief get neighbor scan period
9396 \param hHal - The handle returned by mac_open.
9397 \param sessionId - Session Identifier
9398 \return uint16_t - neighbor scan period
9399 -------------------------------------------------------------------------*/
9400uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
9401{
9402 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9403 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
9404 neighborScanPeriod;
9405}
9406
9407#endif
9408
9409#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
9410
9411/*--------------------------------------------------------------------------
9412 \brief sme_get_roam_rssi_diff() - get Roam rssi diff
9413 This is a synchronous call
9414 \param hHal - The handle returned by mac_open.
9415 \return uint16_t - Rssi diff value
9416 \sa
9417 --------------------------------------------------------------------------*/
9418uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
9419{
9420 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9421 return pMac->roam.configParam.RoamRssiDiff;
9422}
9423
9424/**
9425 * sme_change_roam_scan_channel_list() - to change scan channel list
9426 * @hHal: pointer HAL handle returned by mac_open
9427 * @sessionId: sme session id
9428 * @pChannelList: Output channel list
9429 * @numChannels: Output number of channels
9430 *
9431 * This routine is called to Change roam scan channel list.
9432 * This is a synchronous call
9433 *
9434 * Return: CDF_STATUS
9435 */
9436CDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
9437 uint8_t *pChannelList,
9438 uint8_t numChannels)
9439{
9440 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9441 CDF_STATUS status = CDF_STATUS_SUCCESS;
9442 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
9443 &pMac->roam.neighborRoamInfo[sessionId];
9444 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
9445 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
9446 uint8_t i = 0, j = 0;
9447 tCsrChannelInfo *chan_info;
9448
9449
9450 status = sme_acquire_global_lock(&pMac->sme);
9451 if (!CDF_IS_STATUS_SUCCESS(status)) {
9452 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9453 csr_roam_offload_scan(pMac, sessionId,
9454 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9455 REASON_CHANNEL_LIST_CHANGED);
9456 return status;
9457 }
9458 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
9459
9460 if (NULL != chan_info->ChannelList) {
9461 for (i = 0; i < chan_info->numOfChannels; i++) {
9462 if (j < sizeof(oldChannelList))
9463 j += snprintf(oldChannelList + j,
9464 sizeof(oldChannelList) -
9465 j, "%d",
9466 chan_info->ChannelList[i]);
9467 else
9468 break;
9469 }
9470 }
9471 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
9472 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
9473 numChannels);
9474 sme_set_roam_scan_control(hHal, sessionId, 1);
9475 if (NULL != chan_info->ChannelList) {
9476 j = 0;
9477 for (i = 0; i < chan_info->numOfChannels; i++) {
9478 if (j < sizeof(newChannelList))
9479 j += snprintf(newChannelList + j,
9480 sizeof(newChannelList) -
9481 j, " %d",
9482 chan_info->ChannelList[i]);
9483 else
9484 break;
9485 }
9486 }
9487 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9488 FL("LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d"),
9489 newChannelList, oldChannelList,
9490 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
9491 sme_release_global_lock(&pMac->sme);
9492
9493 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9494 csr_roam_offload_scan(pMac, sessionId,
9495 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9496 REASON_CHANNEL_LIST_CHANGED);
9497 return status;
9498}
9499
9500#ifdef FEATURE_WLAN_ESE_UPLOAD
9501/**
9502 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
9503 * @hHal: pointer HAL handle returned by mac_open
9504 * @sessionId: sme session id
9505 * @pChannelList: Output channel list
9506 * @numChannels: Output number of channels
9507 *
9508 * This routine is called to set ese roam scan channel list.
9509 * This is a synchronous call
9510 *
9511 * Return: CDF_STATUS
9512 */
9513CDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
9514 uint8_t sessionId,
9515 uint8_t *pChannelList,
9516 uint8_t numChannels)
9517{
9518 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9519 CDF_STATUS status = CDF_STATUS_SUCCESS;
9520 tpCsrNeighborRoamControlInfo pNeighborRoamInfo
9521 = &pMac->roam.neighborRoamInfo[sessionId];
9522 tpCsrChannelInfo curchnl_list_info
9523 = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
9524 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
9525 uint8_t newChannelList[128] = { 0 };
9526 uint8_t i = 0, j = 0;
9527
9528 status = sme_acquire_global_lock(&pMac->sme);
9529 if (!CDF_IS_STATUS_SUCCESS(status)) {
9530 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9531 csr_roam_offload_scan(pMac, sessionId,
9532 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9533 REASON_CHANNEL_LIST_CHANGED);
9534 return status;
9535 }
9536 if (NULL != curchnl_list_info->ChannelList) {
9537 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
9538 j += snprintf(oldChannelList + j,
9539 sizeof(oldChannelList) - j, "%d",
9540 curchnl_list_info->ChannelList[i]);
9541 }
9542 }
9543 status = csr_create_roam_scan_channel_list(pMac, sessionId,
9544 pChannelList, numChannels,
9545 csr_get_current_band(hHal));
9546 if (CDF_IS_STATUS_SUCCESS(status)) {
9547 if (NULL != curchnl_list_info->ChannelList) {
9548 j = 0;
9549 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
9550 j += snprintf(newChannelList + j,
9551 sizeof(newChannelList) - j, "%d",
9552 curchnl_list_info->ChannelList[i]);
9553 }
9554 }
9555 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
9556 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
9557 newChannelList, oldChannelList,
9558 pNeighborRoamInfo->neighborRoamState);
9559 }
9560 sme_release_global_lock(&pMac->sme);
9561 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
9562 csr_roam_offload_scan(pMac, sessionId,
9563 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
9564 REASON_CHANNEL_LIST_CHANGED);
9565 return status;
9566}
9567#endif
9568
9569/**
9570 * sme_get_roam_scan_channel_list() - To get roam scan channel list
9571 * @hHal: HAL pointer
9572 * @pChannelList: Output channel list
9573 * @pNumChannels: Output number of channels
9574 * @sessionId: Session Identifier
9575 *
9576 * To get roam scan channel list This is a synchronous call
9577 *
9578 * Return: CDF_STATUS
9579 */
9580CDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
9581 uint8_t *pChannelList, uint8_t *pNumChannels,
9582 uint8_t sessionId)
9583{
9584 int i = 0;
9585 uint8_t *pOutPtr = pChannelList;
9586 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9587 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
9588 &pMac->roam.neighborRoamInfo[sessionId];
9589 CDF_STATUS status = CDF_STATUS_SUCCESS;
9590
9591 status = sme_acquire_global_lock(&pMac->sme);
9592 if (!CDF_IS_STATUS_SUCCESS(status))
9593 return status;
9594 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
9595 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_WARN,
9596 FL("Roam Scan channel list is NOT yet initialized"));
9597 *pNumChannels = 0;
9598 sme_release_global_lock(&pMac->sme);
9599 return status;
9600 }
9601
9602 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
9603 for (i = 0; i < (*pNumChannels); i++) {
9604 pOutPtr[i] =
9605 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
9606 }
9607 pOutPtr[i] = '\0';
9608 sme_release_global_lock(&pMac->sme);
9609 return status;
9610}
9611
9612/*--------------------------------------------------------------------------
9613 \brief sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
9614 This is a synchronuous call
9615 \param hHal - The handle returned by mac_open.
9616 \return true (1) - if the ESE feature is enabled
9617 false (0) - if feature is disabled (compile or runtime)
9618 \sa
9619 --------------------------------------------------------------------------*/
9620bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
9621{
9622#ifdef FEATURE_WLAN_ESE
9623 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9624 return csr_roam_is_ese_ini_feature_enabled(pMac);
9625#else
9626 return false;
9627#endif
9628}
9629
9630/*--------------------------------------------------------------------------
9631 \brief sme_get_wes_mode() - get WES Mode
9632 This is a synchronous call
9633 \param hHal - The handle returned by mac_open
9634 \return uint8_t - WES Mode Enabled(1)/Disabled(0)
9635 \sa
9636 --------------------------------------------------------------------------*/
9637bool sme_get_wes_mode(tHalHandle hHal)
9638{
9639 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9640 return pMac->roam.configParam.isWESModeEnabled;
9641}
9642
9643/*--------------------------------------------------------------------------
9644 \brief sme_get_roam_scan_control() - get scan control
9645 This is a synchronous call
9646 \param hHal - The handle returned by mac_open.
9647 \return bool - Enabled(1)/Disabled(0)
9648 \sa
9649 --------------------------------------------------------------------------*/
9650bool sme_get_roam_scan_control(tHalHandle hHal)
9651{
9652 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9653 return pMac->roam.configParam.nRoamScanControl;
9654}
9655#endif
9656
9657/*--------------------------------------------------------------------------
9658 \brief sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
9659 This is a synchronuous call
9660 \param hHal - The handle returned by mac_open.
9661 \return true (1) - if the feature is enabled
9662 false (0) - if feature is disabled (compile or runtime)
9663 \sa
9664 --------------------------------------------------------------------------*/
9665bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
9666{
9667#ifdef FEATURE_WLAN_LFR
9668 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9669 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
9670#else
9671 return false;
9672#endif
9673}
9674
9675/*--------------------------------------------------------------------------
9676 \brief sme_get_is_ft_feature_enabled() - get FT feature enabled or not
9677 This is a synchronuous call
9678 \param hHal - The handle returned by mac_open.
9679 \return true (1) - if the feature is enabled
9680 false (0) - if feature is disabled (compile or runtime)
9681 \sa
9682 --------------------------------------------------------------------------*/
9683bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
9684{
9685#ifdef WLAN_FEATURE_VOWIFI_11R
9686 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9687 return pMac->roam.configParam.isFastTransitionEnabled;
9688#else
9689 return false;
9690#endif
9691}
9692
9693/* ---------------------------------------------------------------------------
9694 \fn sme_is_feature_supported_by_fw
9695 \brief Check if an feature is enabled by FW
9696
9697 \param feattEnumValue - Enumeration value from placeHolderInCapBitmap
9698 \- return 1/0 (true/false)
9699 -------------------------------------------------------------------------*/
9700uint8_t sme_is_feature_supported_by_fw(uint8_t featEnumValue)
9701{
9702 return IS_FEATURE_SUPPORTED_BY_FW(featEnumValue);
9703}
9704
9705#ifdef FEATURE_WLAN_TDLS
9706
9707/* ---------------------------------------------------------------------------
9708 \fn sme_send_tdls_link_establish_params
9709 \brief API to send TDLS Peer Link Establishment Parameters.
9710
9711 \param peerMac - peer's Mac Adress.
9712 \param tdlsLinkEstablishParams - TDLS Peer Link Establishment Parameters
9713 \- return CDF_STATUS_SUCCES
9714 -------------------------------------------------------------------------*/
9715CDF_STATUS sme_send_tdls_link_establish_params(tHalHandle hHal,
9716 uint8_t sessionId,
9717 const tSirMacAddr peerMac,
9718 tCsrTdlsLinkEstablishParams *
9719 tdlsLinkEstablishParams)
9720{
9721 CDF_STATUS status = CDF_STATUS_SUCCESS;
9722 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9723
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05309724 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
9725 TRACE_CODE_SME_RX_HDD_TDLS_LINK_ESTABLISH_PARAM,
9726 sessionId,
9727 tdlsLinkEstablishParams->isOffChannelSupported));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009728 status = sme_acquire_global_lock(&pMac->sme);
9729
9730 if (CDF_IS_STATUS_SUCCESS(status)) {
9731 status = csr_tdls_send_link_establish_params(hHal, sessionId,
9732 peerMac, tdlsLinkEstablishParams);
9733 sme_release_global_lock(&pMac->sme);
9734 }
9735 return status;
9736}
9737
9738/* ---------------------------------------------------------------------------
9739 \fn sme_send_tdls_mgmt_frame
9740 \brief API to send TDLS management frames.
9741
9742 \param peerMac - peer's Mac Adress.
9743 \param frame_type - Type of TDLS mgmt frame to be sent.
9744 \param dialog - dialog token used in the frame.
9745 \param status - status to be incuded in the frame.
9746 \param peerCapability - peer cpabilities
9747 \param buf - additional IEs to be included
9748 \param len - lenght of additional Ies
9749 \param responder - Tdls request type
9750 \- return CDF_STATUS_SUCCES
9751 -------------------------------------------------------------------------*/
9752CDF_STATUS sme_send_tdls_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
9753 const tSirMacAddr peerMac,
9754 uint8_t frame_type,
9755 uint8_t dialog, uint16_t statusCode,
9756 uint32_t peerCapability, uint8_t *buf,
9757 uint8_t len, uint8_t responder)
9758{
9759 CDF_STATUS status = CDF_STATUS_SUCCESS;
9760 tCsrTdlsSendMgmt sendTdlsReq = { {0} };
9761 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9762
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05309763 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
9764 TRACE_CODE_SME_RX_HDD_TDLS_SEND_MGMT_FRAME,
9765 sessionId, statusCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009766 status = sme_acquire_global_lock(&pMac->sme);
9767 if (CDF_IS_STATUS_SUCCESS(status)) {
9768 cdf_mem_copy(sendTdlsReq.peerMac, peerMac, sizeof(tSirMacAddr));
9769 sendTdlsReq.frameType = frame_type;
9770 sendTdlsReq.buf = buf;
9771 sendTdlsReq.len = len;
9772 sendTdlsReq.dialog = dialog;
9773 sendTdlsReq.statusCode = statusCode;
9774 sendTdlsReq.responder = responder;
9775 sendTdlsReq.peerCapability = peerCapability;
9776
9777 status = csr_tdls_send_mgmt_req(hHal, sessionId, &sendTdlsReq);
9778
9779 sme_release_global_lock(&pMac->sme);
9780 }
9781
9782 return status;
9783
9784}
9785
9786/* ---------------------------------------------------------------------------
9787 \fn sme_change_tdls_peer_sta
9788 \brief API to Update TDLS peer sta parameters.
9789
9790 \param peerMac - peer's Mac Adress.
9791 \param staParams - Peer Station Parameters
9792 \- return CDF_STATUS_SUCCES
9793 -------------------------------------------------------------------------*/
9794CDF_STATUS sme_change_tdls_peer_sta(tHalHandle hHal, uint8_t sessionId,
9795 const tSirMacAddr peerMac,
9796 tCsrStaParams *pstaParams)
9797{
9798 CDF_STATUS status = CDF_STATUS_SUCCESS;
9799 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9800
9801 if (NULL == pstaParams) {
9802 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
9803 "%s :pstaParams is NULL", __func__);
9804 return CDF_STATUS_E_FAILURE;
9805 }
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05309806 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
9807 TRACE_CODE_SME_RX_HDD_TDLS_CHANGE_PEER_STA,
9808 sessionId, pstaParams->capability));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009809 status = sme_acquire_global_lock(&pMac->sme);
9810 if (CDF_IS_STATUS_SUCCESS(status)) {
9811 status = csr_tdls_change_peer_sta(hHal, sessionId, peerMac,
9812 pstaParams);
9813
9814 sme_release_global_lock(&pMac->sme);
9815 }
9816
9817 return status;
9818
9819}
9820
9821/* ---------------------------------------------------------------------------
9822 \fn sme_add_tdls_peer_sta
9823 \brief API to Add TDLS peer sta entry.
9824
9825 \param peerMac - peer's Mac Adress.
9826 \- return CDF_STATUS_SUCCES
9827 -------------------------------------------------------------------------*/
9828CDF_STATUS sme_add_tdls_peer_sta(tHalHandle hHal, uint8_t sessionId,
9829 const tSirMacAddr peerMac)
9830{
9831 CDF_STATUS status = CDF_STATUS_SUCCESS;
9832 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9833
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05309834 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
9835 TRACE_CODE_SME_RX_HDD_TDLS_ADD_PEER_STA,
9836 sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009837 status = sme_acquire_global_lock(&pMac->sme);
9838 if (CDF_IS_STATUS_SUCCESS(status)) {
9839 status = csr_tdls_add_peer_sta(hHal, sessionId, peerMac);
9840
9841 sme_release_global_lock(&pMac->sme);
9842 }
9843
9844 return status;
9845
9846}
9847
9848/* ---------------------------------------------------------------------------
9849 \fn sme_delete_tdls_peer_sta
9850 \brief API to Delete TDLS peer sta entry.
9851
9852 \param peerMac - peer's Mac Adress.
9853 \- return CDF_STATUS_SUCCES
9854 -------------------------------------------------------------------------*/
9855CDF_STATUS sme_delete_tdls_peer_sta(tHalHandle hHal, uint8_t sessionId,
9856 const tSirMacAddr peerMac)
9857{
9858 CDF_STATUS status = CDF_STATUS_SUCCESS;
9859 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9860
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05309861 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
9862 TRACE_CODE_SME_RX_HDD_TDLS_DEL_PEER_STA,
9863 sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009864 status = sme_acquire_global_lock(&pMac->sme);
9865 if (CDF_IS_STATUS_SUCCESS(status)) {
9866 status = csr_tdls_del_peer_sta(hHal, sessionId, peerMac);
9867
9868 sme_release_global_lock(&pMac->sme);
9869 }
9870
9871 return status;
9872
9873}
9874
9875/* ---------------------------------------------------------------------------
9876 \fn sme_set_tdls_power_save_prohibited
9877 \API to set/reset the is_tdls_power_save_prohibited.
9878
9879 \- return void
9880 -------------------------------------------------------------------------*/
9881void sme_set_tdls_power_save_prohibited(tHalHandle hHal, uint32_t sessionId,
9882 bool val)
9883{
9884 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9885 struct ps_global_info *ps_global_info = &pMac->sme.ps_global_info;
9886 struct ps_params *ps_param = &ps_global_info->ps_params[sessionId];
9887 ps_param->is_tdls_power_save_prohibited = val;
9888 return;
9889}
9890
9891/* ---------------------------------------------------------------------------
9892 \fn sme_update_fw_tdls_state
9893
9894 \brief
9895 SME will send message to WMA to set TDLS state in f/w
9896
9897 \param
9898
9899 hHal - The handle returned by mac_open
9900
9901 psmeTdlsParams - TDLS state info to update in f/w
9902
9903 useSmeLock - Need to acquire SME Global Lock before state update or not
9904
9905 \return CDF_STATUS
9906 --------------------------------------------------------------------------- */
9907CDF_STATUS sme_update_fw_tdls_state(tHalHandle hHal, void *psmeTdlsParams,
9908 bool useSmeLock)
9909{
9910 CDF_STATUS status = CDF_STATUS_SUCCESS;
9911 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
9912 tpAniSirGlobal pMac = NULL;
9913 cds_msg_t cds_message;
9914
9915 /* only acquire sme global lock before state update if asked to */
9916 if (useSmeLock) {
9917 pMac = PMAC_STRUCT(hHal);
9918 if (NULL == pMac)
9919 return CDF_STATUS_E_FAILURE;
9920
9921 status = sme_acquire_global_lock(&pMac->sme);
9922 if (CDF_STATUS_SUCCESS != status)
9923 return status;
9924 }
9925
9926 /* serialize the req through MC thread */
9927 cds_message.bodyptr = psmeTdlsParams;
9928 cds_message.type = WMA_UPDATE_FW_TDLS_STATE;
9929 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
9930 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
9931 status = CDF_STATUS_E_FAILURE;
9932
9933 /* release the lock if it was acquired */
9934 if (useSmeLock)
9935 sme_release_global_lock(&pMac->sme);
9936
9937 return status;
9938}
9939
9940/**
9941 * sme_update_tdls_peer_state() - to update the state of TDLS peer
9942 * @hHal: The handle returned by mac_open
9943 * @peerStateParams: TDLS Peer state info to update in f/w
9944 *
9945 * SME will send message to WMA to set TDLS Peer state in f/w
9946 *
9947 * Return: CDF_STATUS
9948 */
9949CDF_STATUS sme_update_tdls_peer_state(tHalHandle hHal,
9950 tSmeTdlsPeerStateParams *peerStateParams)
9951{
9952 CDF_STATUS status = CDF_STATUS_SUCCESS;
9953 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
9954 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9955 tTdlsPeerStateParams *pTdlsPeerStateParams = NULL;
9956 tTdlsPeerCapParams *peer_cap = NULL;
9957 cds_msg_t cds_message;
9958 uint8_t num;
9959 uint8_t chanId;
9960 uint8_t i;
9961
9962 status = sme_acquire_global_lock(&pMac->sme);
9963 if (!CDF_IS_STATUS_SUCCESS(status))
9964 return status;
9965 pTdlsPeerStateParams = cdf_mem_malloc(sizeof(*pTdlsPeerStateParams));
9966 if (NULL == pTdlsPeerStateParams) {
9967 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
9968 FL("failed to allocate mem for tdls peer state param"));
9969 sme_release_global_lock(&pMac->sme);
9970 return CDF_STATUS_E_NOMEM;
9971 }
9972
9973 cdf_mem_zero(pTdlsPeerStateParams, sizeof(*pTdlsPeerStateParams));
9974 cdf_mem_copy(&pTdlsPeerStateParams->peerMacAddr,
9975 &peerStateParams->peerMacAddr, sizeof(tSirMacAddr));
9976 pTdlsPeerStateParams->vdevId = peerStateParams->vdevId;
9977 pTdlsPeerStateParams->peerState = peerStateParams->peerState;
9978
9979 switch (peerStateParams->peerState) {
9980 case eSME_TDLS_PEER_STATE_PEERING:
9981 pTdlsPeerStateParams->peerState =
9982 WMA_TDLS_PEER_STATE_PEERING;
9983 break;
9984
9985 case eSME_TDLS_PEER_STATE_CONNECTED:
9986 pTdlsPeerStateParams->peerState =
9987 WMA_TDLS_PEER_STATE_CONNECTED;
9988 break;
9989
9990 case eSME_TDLS_PEER_STATE_TEARDOWN:
9991 pTdlsPeerStateParams->peerState =
9992 WMA_TDLS_PEER_STATE_TEARDOWN;
9993 break;
9994
9995 default:
9996 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
9997 FL("invalid peer state param (%d)"),
9998 peerStateParams->peerState);
9999 cdf_mem_free(pTdlsPeerStateParams);
10000 sme_release_global_lock(&pMac->sme);
10001 return CDF_STATUS_E_FAILURE;
10002 }
10003 peer_cap = &(pTdlsPeerStateParams->peerCap);
10004 peer_cap->isPeerResponder =
10005 peerStateParams->peerCap.isPeerResponder;
10006 peer_cap->peerUapsdQueue =
10007 peerStateParams->peerCap.peerUapsdQueue;
10008 peer_cap->peerMaxSp =
10009 peerStateParams->peerCap.peerMaxSp;
10010 peer_cap->peerBuffStaSupport =
10011 peerStateParams->peerCap.peerBuffStaSupport;
10012 peer_cap->peerOffChanSupport =
10013 peerStateParams->peerCap.peerOffChanSupport;
10014 peer_cap->peerCurrOperClass =
10015 peerStateParams->peerCap.peerCurrOperClass;
10016 peer_cap->selfCurrOperClass =
10017 peerStateParams->peerCap.selfCurrOperClass;
10018
10019 num = 0;
10020 for (i = 0; i < peerStateParams->peerCap.peerChanLen; i++) {
10021 chanId = peerStateParams->peerCap.peerChan[i];
10022 if (!csr_roam_is_channel_valid(pMac, chanId))
10023 continue;
10024 peer_cap->peerChan[num].chanId = chanId;
10025 peer_cap->peerChan[num].pwr =
10026 csr_get_cfg_max_tx_power(pMac, chanId);
10027
10028 if (cds_get_channel_state(chanId) == CHANNEL_STATE_DFS)
10029 peer_cap->peerChan[num].dfsSet =
10030 true;
10031 else
10032 peer_cap->peerChan[num].dfsSet =
10033 false;
10034 num++;
10035 }
10036 peer_cap->peerChanLen = num;
10037 peer_cap->peerOperClassLen =
10038 peerStateParams->peerCap.peerOperClassLen;
10039 for (i = 0; i < HAL_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10040 peer_cap->peerOperClass[i] =
10041 peerStateParams->peerCap.peerOperClass[i];
10042 }
10043
10044 peer_cap->prefOffChanNum =
10045 peerStateParams->peerCap.prefOffChanNum;
10046 peer_cap->prefOffChanBandwidth =
10047 peerStateParams->peerCap.prefOffChanBandwidth;
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053010048 peer_cap->opClassForPrefOffChan =
10049 peerStateParams->peerCap.opClassForPrefOffChan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010050
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010051 cds_message.type = WMA_UPDATE_TDLS_PEER_STATE;
10052 cds_message.reserved = 0;
10053 cds_message.bodyptr = pTdlsPeerStateParams;
10054
10055 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
10056 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
10057 cdf_mem_free(pTdlsPeerStateParams);
10058 status = CDF_STATUS_E_FAILURE;
10059 }
10060 sme_release_global_lock(&pMac->sme);
10061 return status;
10062}
10063
10064/**
10065 * sme_send_tdls_chan_switch_req() - send tdls channel switch request
10066 * @hal: UMAC handler
10067 * @ch_switch_params: Pointer to the chan switch parameter structure
10068 *
10069 * API to set tdls channel switch parameters.
10070 *
10071 * Return: CDF_STATUS_SUCCESS on success; another CDF_STATUS_* code otherwise
10072 */
10073CDF_STATUS sme_send_tdls_chan_switch_req(tHalHandle hal,
10074 sme_tdls_chan_switch_params *ch_switch_params)
10075{
10076 CDF_STATUS status = CDF_STATUS_SUCCESS;
10077 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
10078 tpAniSirGlobal mac = PMAC_STRUCT(hal);
10079 tdls_chan_switch_params *chan_switch_params = NULL;
10080 cds_msg_t cds_message;
10081
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +053010082 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
10083 TRACE_CODE_SME_RX_HDD_TDLS_CHAN_SWITCH_REQ,
10084 NO_SESSION, ch_switch_params->tdls_off_channel));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010085 status = sme_acquire_global_lock(&mac->sme);
10086 if (CDF_STATUS_SUCCESS != status)
10087 return status;
10088 chan_switch_params = cdf_mem_malloc(sizeof(*chan_switch_params));
10089 if (NULL == chan_switch_params) {
10090 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10091 FL("fail to alloc mem for tdls chan switch param"));
10092 sme_release_global_lock(&mac->sme);
10093 return CDF_STATUS_E_FAILURE;
10094 }
10095 cdf_mem_zero(chan_switch_params, sizeof(*chan_switch_params));
10096
10097 switch (ch_switch_params->tdls_off_ch_mode) {
10098 case ENABLE_CHANSWITCH:
10099 chan_switch_params->tdls_sw_mode = WMA_TDLS_ENABLE_OFFCHANNEL;
10100 break;
10101
10102 case DISABLE_CHANSWITCH:
10103 chan_switch_params->tdls_sw_mode = WMA_TDLS_DISABLE_OFFCHANNEL;
10104 break;
10105
10106 default:
10107 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10108 FL("invalid off channel command (%d)"),
10109 ch_switch_params->tdls_off_ch_mode);
10110 cdf_mem_free(chan_switch_params);
10111 sme_release_global_lock(&mac->sme);
10112 return CDF_STATUS_E_FAILURE;
10113 }
10114
10115 cdf_mem_copy(&chan_switch_params->peer_mac_addr,
10116 &ch_switch_params->peer_mac_addr, sizeof(tSirMacAddr));
10117 chan_switch_params->vdev_id = ch_switch_params->vdev_id;
10118 chan_switch_params->tdls_off_ch = ch_switch_params->tdls_off_channel;
10119 chan_switch_params->tdls_off_ch_bw_offset =
10120 ch_switch_params->tdls_off_ch_bw_offset;
10121 chan_switch_params->is_responder = ch_switch_params->is_responder;
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053010122 chan_switch_params->oper_class = ch_switch_params->opclass;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010123
10124 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
10125 FL("Country Code=%s, Req offset=%d, Selected Operate Class=%d"),
10126 mac->scan.countryCodeCurrent,
10127 chan_switch_params->tdls_off_ch_bw_offset,
10128 chan_switch_params->oper_class);
10129
10130 cds_message.type = WMA_TDLS_SET_OFFCHAN_MODE;
10131 cds_message.reserved = 0;
10132 cds_message.bodyptr = chan_switch_params;
10133
10134 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
10135 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
10136 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10137 FL("Message Post failed status=%d"),
10138 cdf_status);
10139 cdf_mem_free(chan_switch_params);
10140 status = CDF_STATUS_E_FAILURE;
10141 }
10142 sme_release_global_lock(&mac->sme);
10143 return status;
10144}
10145#endif /* FEATURE_WLAN_TDLS */
10146
10147CDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
10148 void *plsContext,
10149 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
10150 void *pContext))
10151{
10152
10153 CDF_STATUS status = CDF_STATUS_SUCCESS;
10154 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
10155 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10156 cds_msg_t cds_message;
10157
10158 status = sme_acquire_global_lock(&pMac->sme);
10159 if (CDF_STATUS_SUCCESS == status) {
10160 if ((NULL == pCallbackfn) &&
10161 (NULL == pMac->sme.pLinkSpeedIndCb)) {
10162 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10163 "%s: Indication Call back did not registered",
10164 __func__);
10165 sme_release_global_lock(&pMac->sme);
10166 return CDF_STATUS_E_FAILURE;
10167 } else if (NULL != pCallbackfn) {
10168 pMac->sme.pLinkSpeedCbContext = plsContext;
10169 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
10170 }
10171 /* serialize the req through MC thread */
10172 cds_message.bodyptr = lsReq;
10173 cds_message.type = WMA_GET_LINK_SPEED;
10174 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
10175 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
10176 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10177 "%s: Post Link Speed msg fail", __func__);
10178 status = CDF_STATUS_E_FAILURE;
10179 }
10180 sme_release_global_lock(&pMac->sme);
10181 }
10182 return status;
10183}
10184
10185
10186/*
10187 * SME API to enable/disable WLAN driver initiated SSR
10188 */
10189void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
10190{
10191 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10192 CDF_STATUS status = CDF_STATUS_SUCCESS;
10193
10194 status = sme_acquire_global_lock(&pMac->sme);
10195 if (CDF_IS_STATUS_SUCCESS(status)) {
10196 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
10197 "SSR level is changed %d", enableSSR);
10198 /* not serializing this messsage, as this is only going
10199 * to set a variable in WMA/WDI
10200 */
10201 WMA_SetEnableSSR(enableSSR);
10202 sme_release_global_lock(&pMac->sme);
10203 }
10204 return;
10205}
10206
10207CDF_STATUS sme_check_ch_in_band(tpAniSirGlobal mac_ctx, uint8_t start_ch,
10208 uint8_t ch_cnt)
10209{
10210 uint8_t i;
10211 for (i = 0; i < ch_cnt; i++) {
10212 if (CDF_STATUS_SUCCESS != csr_is_valid_channel(mac_ctx,
10213 (start_ch + i*4)))
10214 return CDF_STATUS_E_FAILURE;
10215 }
10216 return CDF_STATUS_SUCCESS;
10217}
10218
10219void sme_set_160bw_params(tpAniSirGlobal mac_ctx, uint8_t channel,
10220 chan_params_t *ch_params)
10221{
10222 uint8_t start_ch = 0;
10223 CDF_STATUS status = CDF_STATUS_SUCCESS;
10224
10225 if (channel >= 36 && channel <= 64) {
10226 ch_params->center_freq_seg0 = 50;
10227 start_ch = 36;
10228 } else if (channel >= 100 && channel <= 128) {
10229 ch_params->center_freq_seg0 = 114;
10230 start_ch = 100;
10231 } else {
10232 ch_params->ch_width = CH_WIDTH_80MHZ;
10233 }
10234
10235 if (ch_params->ch_width == CH_WIDTH_160MHZ)
10236 status = sme_check_ch_in_band(mac_ctx, start_ch, 8);
10237
10238 if (CDF_STATUS_SUCCESS != status)
10239 ch_params->ch_width = CH_WIDTH_80MHZ;
10240}
10241
10242void sme_set_80bw_params(tpAniSirGlobal mac_ctx, uint8_t channel,
10243 chan_params_t *ch_params)
10244{
10245 uint8_t start_ch = 0;
10246 CDF_STATUS status = CDF_STATUS_SUCCESS;
10247
10248 if (channel >= 36 && channel <= 48) {
10249 ch_params->center_freq_seg0 = 42;
10250 start_ch = 36;
10251 } else if (channel >= 52 && channel <= 64) {
10252 ch_params->center_freq_seg0 = 58;
10253 start_ch = 52;
10254 } else if (channel >= 100 && channel <= 112) {
10255 ch_params->center_freq_seg0 = 106;
10256 start_ch = 100;
10257 } else if (channel >= 116 && channel <= 128) {
10258 ch_params->center_freq_seg0 = 122;
10259 start_ch = 116;
10260 } else if (channel >= 132 && channel <= 144) {
10261 ch_params->center_freq_seg0 = 138;
10262 start_ch = 132;
10263 } else if (channel >= 149 && channel <= 161) {
10264 ch_params->center_freq_seg0 = 155;
10265 start_ch = 149;
10266 } else {
10267 ch_params->ch_width = CH_WIDTH_40MHZ;
10268 }
10269
10270 if (ch_params->ch_width == CH_WIDTH_80MHZ)
10271 status = sme_check_ch_in_band(mac_ctx, start_ch, 4);
10272
10273 if (CDF_STATUS_SUCCESS != status)
10274 ch_params->ch_width = CH_WIDTH_40MHZ;
10275}
10276
10277void sme_set_40bw_params(tpAniSirGlobal mac_ctx, uint8_t channel,
10278 chan_params_t *ch_params, uint8_t is_11ac_mode)
10279{
10280 uint8_t tmp;
10281 uint8_t center_freq = 0;
10282 bool valid_40Mhz_ch = true;
10283
10284 if (channel == 165) {
10285 ch_params->ch_width = CH_WIDTH_20MHZ;
10286 ch_params->center_freq_seg0 = 0;
10287 ch_params->sec_ch_offset = PHY_SINGLE_CHANNEL_CENTERED;
10288 return;
10289 }
10290 tmp = channel % 2;
10291 if ((channel - tmp) % 8) {
10292 ch_params->sec_ch_offset = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
10293 center_freq = channel + 2;
10294 } else {
10295 ch_params->sec_ch_offset = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10296 center_freq = channel - 2;
10297 }
10298 if ((!is_11ac_mode) || (is_11ac_mode &&
10299 (ch_params->ch_width == CH_WIDTH_40MHZ))) {
10300 ch_params->ch_width = CH_WIDTH_40MHZ;
10301 ch_params->center_freq_seg0 = center_freq;
10302 valid_40Mhz_ch = csr_roam_is_valid40_mhz_channel(mac_ctx,
10303 ch_params->center_freq_seg0);
10304 }
10305 if (!valid_40Mhz_ch) {
10306 ch_params->ch_width = CH_WIDTH_20MHZ;
10307 ch_params->center_freq_seg0 = 0;
10308 ch_params->sec_ch_offset = PHY_SINGLE_CHANNEL_CENTERED;
10309 }
10310}
10311
10312/*
10313 * SME API to determine the channel bonding mode
10314 */
10315CDF_STATUS sme_set_ch_params(tHalHandle hHal, eCsrPhyMode eCsrPhyMode,
10316 uint8_t channel, uint8_t ht_sec_ch, chan_params_t *ch_params)
10317{
10318 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
10319 int is_11ac_mode = CSR_IS_PHY_MODE_11ac(eCsrPhyMode);
10320
10321 if (!CSR_IS_PHY_MODE_11n(eCsrPhyMode) ||
10322 ch_params->ch_width == CH_WIDTH_20MHZ ||
10323 CDF_STATUS_SUCCESS != csr_is_valid_channel(mac_ctx, channel)) {
10324 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10325 "%s: Invalid Channel/phymode config: CB Mode disabled",
10326 __func__);
10327 ch_params->ch_width = CH_WIDTH_20MHZ;
10328 ch_params->sec_ch_offset = PHY_SINGLE_CHANNEL_CENTERED;
10329 if (channel <= 14)
10330 mac_ctx->roam.configParam.channelBondingMode24GHz =
10331 PHY_SINGLE_CHANNEL_CENTERED;
10332 else
10333 mac_ctx->roam.configParam.channelBondingMode5GHz =
10334 PHY_SINGLE_CHANNEL_CENTERED;
10335 return CDF_STATUS_SUCCESS;
10336 }
10337
10338 sms_log(mac_ctx, LOGW, "%s: channel - %d, vht channel width - %d",
10339 __func__, channel, ch_params->ch_width);
10340
10341 if (CDS_IS_CHANNEL_5GHZ(channel)) {
10342 if (ch_params->ch_width == CH_WIDTH_160MHZ)
10343 sme_set_160bw_params(mac_ctx, channel, ch_params);
10344 if ((ch_params->ch_width == CH_WIDTH_80MHZ) ||
10345 (ch_params->ch_width == CH_WIDTH_80P80MHZ))
10346 sme_set_80bw_params(mac_ctx, channel, ch_params);
10347
10348 sme_set_40bw_params(mac_ctx, channel,
10349 ch_params, is_11ac_mode);
10350
10351 mac_ctx->roam.configParam.channelBondingMode5GHz =
10352 ch_params->sec_ch_offset;
10353 } else if (CDS_IS_CHANNEL_24GHZ(channel)) {
10354 if (channel >= 1 && channel < 5) {
10355 ch_params->ch_width = CH_WIDTH_40MHZ;
10356 ch_params->sec_ch_offset =
10357 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
10358 ch_params->center_freq_seg0 = channel + 2;
10359 } else if (channel >= 5 && channel <= 9) {
10360 ch_params->ch_width = CH_WIDTH_40MHZ;
10361 if (0 != ht_sec_ch) {
10362 if (ht_sec_ch > channel) {
10363 ch_params->sec_ch_offset =
10364 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
10365 ch_params->center_freq_seg0 =
10366 channel + 2;
10367 } else {
10368 ch_params->sec_ch_offset =
10369 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10370 ch_params->center_freq_seg0 =
10371 channel - 2;
10372 }
10373 } else {
10374 /* in case ht_sec_ch is not set by ACS or
10375 * calling function, set the secondary channel
10376 * offset value to lower channel
10377 */
10378 ch_params->sec_ch_offset =
10379 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10380 ch_params->center_freq_seg0 = channel - 2;
10381 }
10382 } else if (channel > 9 && channel <= 13) {
10383 ch_params->ch_width = CH_WIDTH_40MHZ;
10384 ch_params->sec_ch_offset =
10385 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10386 ch_params->center_freq_seg0 = channel - 2;
10387 } else if (channel == 14) {
10388 ch_params->ch_width = CH_WIDTH_20MHZ;
10389 ch_params->sec_ch_offset =
10390 PHY_SINGLE_CHANNEL_CENTERED;
10391 ch_params->center_freq_seg0 = 0;
10392 }
10393 mac_ctx->roam.configParam.channelBondingMode24GHz =
10394 ch_params->sec_ch_offset;
10395 }
10396 return CDF_STATUS_SUCCESS;
10397}
10398
10399/*convert the ini value to the ENUM used in csr and MAC for CB state*/
10400ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
10401{
10402 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
10403}
10404
10405/*--------------------------------------------------------------------------
10406
10407 \brief sme_set_curr_device_mode() - Sets the current operating device mode.
10408 \param hHal - The handle returned by mac_open.
10409 \param currDeviceMode - Current operating device mode.
10410 --------------------------------------------------------------------------*/
10411
10412void sme_set_curr_device_mode(tHalHandle hHal, tCDF_CON_MODE currDeviceMode)
10413{
10414 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10415 pMac->sme.currDeviceMode = currDeviceMode;
10416 return;
10417}
10418
10419/*--------------------------------------------------------------------------
10420 \brief sme_handoff_request() - a wrapper function to Request a handoff
10421 from CSR.
10422 This is a synchronous call
10423 \param hHal - The handle returned by mac_open
10424 \param sessionId - Session Identifier
10425 \param pHandoffInfo - info provided by HDD with the handoff request (namely:
10426 BSSID, channel etc.)
10427 \return CDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
10428 Other status means SME is failed to send the request.
10429 \sa
10430 --------------------------------------------------------------------------*/
10431
10432CDF_STATUS sme_handoff_request(tHalHandle hHal,
10433 uint8_t sessionId,
10434 tCsrHandoffRequest *pHandoffInfo)
10435{
10436 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10437 CDF_STATUS status = CDF_STATUS_SUCCESS;
10438
10439 status = sme_acquire_global_lock(&pMac->sme);
10440 if (CDF_IS_STATUS_SUCCESS(status)) {
10441 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
10442 "%s: invoked", __func__);
10443 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
10444 sme_release_global_lock(&pMac->sme);
10445 }
10446
10447 return status;
10448}
10449
10450#ifdef IPA_OFFLOAD
10451/* ---------------------------------------------------------------------------
10452 \fn sme_ipa_offload_enable_disable
10453 \brief API to enable/disable IPA offload
10454 \param hal - The handle returned by macOpen.
10455 \param session_id - Session Identifier
10456 \param request - Pointer to the offload request.
10457 \return CDF_STATUS
10458 ---------------------------------------------------------------------------*/
10459CDF_STATUS sme_ipa_offload_enable_disable(tHalHandle hal, uint8_t session_id,
10460 struct sir_ipa_offload_enable_disable *request)
10461{
10462 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10463 CDF_STATUS status = CDF_STATUS_E_FAILURE;
10464 struct sir_ipa_offload_enable_disable *request_buf;
10465 cds_msg_t msg;
10466
10467 status = sme_acquire_global_lock(&pMac->sme);
10468 if (CDF_STATUS_SUCCESS == status) {
10469 request_buf = cdf_mem_malloc(sizeof(*request_buf));
10470 if (NULL == request_buf) {
10471 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10472 FL("Not able to allocate memory for \
10473 IPA_OFFLOAD_ENABLE_DISABLE"));
10474 sme_release_global_lock(&pMac->sme);
10475 return CDF_STATUS_E_NOMEM;
10476 }
10477
10478 request_buf->offload_type = request->offload_type;
10479 request_buf->vdev_id = request->vdev_id;
10480 request_buf->enable = request->enable;
10481
10482 msg.type = WMA_IPA_OFFLOAD_ENABLE_DISABLE;
10483 msg.reserved = 0;
10484 msg.bodyptr = request_buf;
10485 if (!CDF_IS_STATUS_SUCCESS(
10486 cds_mq_post_message(CDS_MQ_ID_WMA, &msg))) {
10487 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10488 FL("Not able to post WMA_IPA_OFFLOAD_\
10489 ENABLE_DISABLE message to WMA"));
10490 cdf_mem_free(request_buf);
10491 sme_release_global_lock(&pMac->sme);
10492 return CDF_STATUS_E_FAILURE;
10493 }
10494
10495 sme_release_global_lock(&pMac->sme);
10496 }
10497
10498 return CDF_STATUS_SUCCESS;
10499}
10500#endif /* IPA_OFFLOAD */
10501
10502/*
10503 * SME API to check if there is any infra station or
10504 * P2P client is connected
10505 */
10506CDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
10507{
10508 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10509 if (csr_is_infra_connected(pMac)) {
10510 return CDF_STATUS_SUCCESS;
10511 }
10512 return CDF_STATUS_E_FAILURE;
10513}
10514
10515#ifdef FEATURE_WLAN_LPHB
10516/* ---------------------------------------------------------------------------
10517 \fn sme_lphb_config_req
10518 \API to make configuration LPHB within FW.
10519 \param hHal - The handle returned by mac_open
10520 \param lphdReq - LPHB request argument by client
10521 \param pCallbackfn - LPHB timeout notification callback function pointer
10522 \- return Configuration message posting status, SUCCESS or Fail
10523 -------------------------------------------------------------------------*/
10524CDF_STATUS sme_lphb_config_req
10525 (tHalHandle hHal,
10526 tSirLPHBReq *lphdReq,
10527 void (*pCallbackfn)(void *pHddCtx, tSirLPHBInd *indParam)
10528 ) {
10529 CDF_STATUS status = CDF_STATUS_SUCCESS;
10530 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
10531 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10532 cds_msg_t cds_message;
10533
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +053010534 MTRACE(cdf_trace(CDF_MODULE_ID_SME,
10535 TRACE_CODE_SME_RX_HDD_LPHB_CONFIG_REQ,
10536 NO_SESSION, lphdReq->cmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010537 status = sme_acquire_global_lock(&pMac->sme);
10538 if (CDF_STATUS_SUCCESS == status) {
10539 if ((LPHB_SET_EN_PARAMS_INDID == lphdReq->cmd) &&
10540 (NULL == pCallbackfn) && (NULL == pMac->sme.pLphbIndCb)) {
10541 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10542 "%s: Indication Call back did not registered",
10543 __func__);
10544 sme_release_global_lock(&pMac->sme);
10545 return CDF_STATUS_E_FAILURE;
10546 } else if (NULL != pCallbackfn) {
10547 pMac->sme.pLphbIndCb = pCallbackfn;
10548 }
10549
10550 /* serialize the req through MC thread */
10551 cds_message.bodyptr = lphdReq;
10552 cds_message.type = WMA_LPHB_CONF_REQ;
10553 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
10554 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
10555 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10556 "%s: Post Config LPHB MSG fail", __func__);
10557 status = CDF_STATUS_E_FAILURE;
10558 }
10559 sme_release_global_lock(&pMac->sme);
10560 }
10561
10562 return status;
10563}
10564#endif /* FEATURE_WLAN_LPHB */
10565/*--------------------------------------------------------------------------
10566 \brief sme_enable_disable_split_scan() - a wrapper function to set the split
10567 scan parameter.
10568 This is a synchronous call
10569 \param hHal - The handle returned by mac_open
10570 \return NONE.
10571 \sa
10572 --------------------------------------------------------------------------*/
10573void sme_enable_disable_split_scan(tHalHandle hHal, uint8_t nNumStaChan,
10574 uint8_t nNumP2PChan)
10575{
10576 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10577
10578 pMac->roam.configParam.nNumStaChanCombinedConc = nNumStaChan;
10579 pMac->roam.configParam.nNumP2PChanCombinedConc = nNumP2PChan;
10580
10581 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
10582 "%s: SCAN nNumStaChanCombinedConc : %d,"
10583 "nNumP2PChanCombinedConc : %d ",
10584 __func__, nNumStaChan, nNumP2PChan);
10585
10586 return;
10587
10588}
10589
10590/**
10591 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
10592 * @hal: global hal handle
10593 * @addPeriodicTxPtrnParams: request message
10594 *
10595 * Return: CDF_STATUS enumeration
10596 */
10597CDF_STATUS
10598sme_add_periodic_tx_ptrn(tHalHandle hal,
10599 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
10600{
10601 CDF_STATUS status = CDF_STATUS_SUCCESS;
10602 tpAniSirGlobal mac = PMAC_STRUCT(hal);
10603 struct sSirAddPeriodicTxPtrn *req_msg;
10604 cds_msg_t msg;
10605
10606 sms_log(mac, LOG1, FL("enter"));
10607
10608 req_msg = cdf_mem_malloc(sizeof(*req_msg));
10609 if (!req_msg) {
10610 sms_log(mac, LOGE, FL("memory allocation failed"));
10611 return CDF_STATUS_E_NOMEM;
10612 }
10613
10614 *req_msg = *addPeriodicTxPtrnParams;
10615
10616 status = sme_acquire_global_lock(&mac->sme);
10617 if (!CDF_IS_STATUS_SUCCESS(status)) {
10618 sms_log(mac, LOGE,
10619 FL("sme_acquire_global_lock failed!(status=%d)"),
10620 status);
10621 cdf_mem_free(req_msg);
10622 return status;
10623 }
10624
10625 /* Serialize the req through MC thread */
10626 msg.bodyptr = req_msg;
10627 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
10628 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10629 if (!CDF_IS_STATUS_SUCCESS(status)) {
10630 sms_log(mac, LOGE,
10631 FL("cds_mq_post_message failed!(err=%d)"),
10632 status);
10633 cdf_mem_free(req_msg);
10634 }
10635 sme_release_global_lock(&mac->sme);
10636 return status;
10637}
10638
10639/**
10640 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
10641 * @hal: global hal handle
10642 * @delPeriodicTxPtrnParams: request message
10643 *
10644 * Return: CDF_STATUS enumeration
10645 */
10646CDF_STATUS
10647sme_del_periodic_tx_ptrn(tHalHandle hal,
10648 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
10649{
10650 CDF_STATUS status = CDF_STATUS_SUCCESS;
10651 tpAniSirGlobal mac = PMAC_STRUCT(hal);
10652 struct sSirDelPeriodicTxPtrn *req_msg;
10653 cds_msg_t msg;
10654
10655 sms_log(mac, LOG1, FL("enter"));
10656
10657 req_msg = cdf_mem_malloc(sizeof(*req_msg));
10658 if (!req_msg) {
10659 sms_log(mac, LOGE, FL("memory allocation failed"));
10660 return CDF_STATUS_E_NOMEM;
10661 }
10662
10663 *req_msg = *delPeriodicTxPtrnParams;
10664
10665 status = sme_acquire_global_lock(&mac->sme);
10666 if (!CDF_IS_STATUS_SUCCESS(status)) {
10667 sms_log(mac, LOGE,
10668 FL("sme_acquire_global_lock failed!(status=%d)"),
10669 status);
10670 cdf_mem_free(req_msg);
10671 return status;
10672 }
10673
10674 /* Serialize the req through MC thread */
10675 msg.bodyptr = req_msg;
10676 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
10677 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10678 if (!CDF_IS_STATUS_SUCCESS(status)) {
10679 sms_log(mac, LOGE,
10680 FL("cds_mq_post_message failed!(err=%d)"),
10681 status);
10682 cdf_mem_free(req_msg);
10683 }
10684 sme_release_global_lock(&mac->sme);
10685 return status;
10686}
10687
10688void sme_get_command_q_status(tHalHandle hHal)
10689{
10690 tSmeCmd *pTempCmd = NULL;
10691 tListElem *pEntry;
10692 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10693
10694 if (NULL == pMac) {
10695 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10696 "%s: pMac is NULL", __func__);
10697 return;
10698 }
10699
10700 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10701 if (pEntry) {
10702 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10703 }
10704 sms_log(pMac, LOGE, "Currently smeCmdActiveList has command (0x%X)",
10705 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
10706 if (pTempCmd) {
10707 if (eSmeCsrCommandMask & pTempCmd->command) {
10708 /* CSR command is stuck. See what the reason code is for that command */
10709 dump_csr_command_info(pMac, pTempCmd);
10710 }
10711 } /* if(pTempCmd) */
10712
10713 sms_log(pMac, LOGE, "Currently smeCmdPendingList has %d commands",
10714 csr_ll_count(&pMac->sme.smeCmdPendingList));
10715
10716 sms_log(pMac, LOGE, "Currently roamCmdPendingList has %d commands",
10717 csr_ll_count(&pMac->roam.roamCmdPendingList));
10718
10719 return;
10720}
10721
10722/**
10723 * sme_set_dot11p_config() - API to set the 802.11p config
10724 * @hHal: The handle returned by macOpen
10725 * @enable_dot11p: 802.11p config param
10726 */
10727void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
10728{
10729 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10730 pMac->enable_dot11p = enable_dot11p;
10731}
10732
10733/**
10734 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
10735 * @src: the source configuration
10736 *
10737 * Return: pointer to the copied OCB configuration
10738 */
10739static struct sir_ocb_config *sme_copy_sir_ocb_config(
10740 struct sir_ocb_config *src)
10741{
10742 struct sir_ocb_config *dst;
10743 uint32_t length;
10744 void *cursor;
10745
10746 length = sizeof(*src) +
10747 src->channel_count * sizeof(*src->channels) +
10748 src->schedule_size * sizeof(*src->schedule) +
10749 src->dcc_ndl_chan_list_len +
10750 src->dcc_ndl_active_state_list_len;
10751
10752 dst = cdf_mem_malloc(length);
10753 if (!dst)
10754 return NULL;
10755
10756 *dst = *src;
10757
10758 cursor = dst;
10759 cursor += sizeof(*dst);
10760 dst->channels = cursor;
10761 cursor += src->channel_count * sizeof(*src->channels);
10762 cdf_mem_copy(dst->channels, src->channels,
10763 src->channel_count * sizeof(*src->channels));
10764 dst->schedule = cursor;
10765 cursor += src->schedule_size * sizeof(*src->schedule);
10766 cdf_mem_copy(dst->schedule, src->schedule,
10767 src->schedule_size * sizeof(*src->schedule));
10768 dst->dcc_ndl_chan_list = cursor;
10769 cursor += src->dcc_ndl_chan_list_len;
10770 cdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
10771 src->dcc_ndl_chan_list_len);
10772 dst->dcc_ndl_active_state_list = cursor;
10773 cursor += src->dcc_ndl_active_state_list_len;
10774 cdf_mem_copy(dst->dcc_ndl_active_state_list,
10775 src->dcc_ndl_active_state_list,
10776 src->dcc_ndl_active_state_list_len);
10777 return dst;
10778}
10779
10780/**
10781 * sme_ocb_set_config() - Set the OCB configuration
10782 * @hHal: reference to the HAL
10783 * @context: the context of the call
10784 * @callback: the callback to hdd
10785 * @config: the OCB configuration
10786 *
10787 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
10788 */
10789CDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
10790 ocb_callback callback,
10791 struct sir_ocb_config *config)
10792{
10793 CDF_STATUS status = CDF_STATUS_E_FAILURE;
10794 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10795 cds_msg_t msg = {0};
10796 struct sir_ocb_config *msg_body;
10797
10798 /* Lock the SME structure */
10799 status = sme_acquire_global_lock(&pMac->sme);
10800 if (!CDF_IS_STATUS_SUCCESS(status))
10801 return status;
10802
10803 /*
10804 * Check if there is a pending request and return an error if one
10805 * exists
10806 */
10807 if (pMac->sme.ocb_set_config_callback) {
10808 status = CDF_STATUS_E_BUSY;
10809 goto end;
10810 }
10811
10812 msg_body = sme_copy_sir_ocb_config(config);
10813
10814 if (!msg_body) {
10815 status = CDF_STATUS_E_NOMEM;
10816 goto end;
10817 }
10818
10819 msg.type = WMA_OCB_SET_CONFIG_CMD;
10820 msg.bodyptr = msg_body;
10821
10822 /* Set the request callback and context */
10823 pMac->sme.ocb_set_config_callback = callback;
10824 pMac->sme.ocb_set_config_context = context;
10825
10826 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10827 if (!CDF_IS_STATUS_SUCCESS(status)) {
10828 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10829 FL("Error posting message to WDA: %d"), status);
10830 pMac->sme.ocb_set_config_callback = callback;
10831 pMac->sme.ocb_set_config_context = context;
10832 cdf_mem_free(msg_body);
10833 goto end;
10834 }
10835
10836end:
10837 sme_release_global_lock(&pMac->sme);
10838
10839 return status;
10840}
10841
10842/**
10843 * sme_ocb_set_utc_time() - Set the OCB UTC time
10844 * @hHal: reference to the HAL
10845 * @utc: the UTC time struct
10846 *
10847 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
10848 */
10849CDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
10850{
10851 CDF_STATUS status = CDF_STATUS_E_FAILURE;
10852 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10853 cds_msg_t msg = {0};
10854 struct sir_ocb_utc *sme_utc;
10855
10856 /* Lock the SME structure */
10857 status = sme_acquire_global_lock(&pMac->sme);
10858 if (!CDF_IS_STATUS_SUCCESS(status))
10859 return status;
10860
10861 sme_utc = cdf_mem_malloc(sizeof(*sme_utc));
10862 if (!sme_utc) {
10863 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10864 FL("Malloc failed"));
10865 status = CDF_STATUS_E_NOMEM;
10866 goto end;
10867 }
10868 *sme_utc = *utc;
10869
10870 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
10871 msg.reserved = 0;
10872 msg.bodyptr = sme_utc;
10873 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10874 if (!CDF_IS_STATUS_SUCCESS(status)) {
10875 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10876 FL("Not able to post message to WDA"));
10877 cdf_mem_free(utc);
10878 goto end;
10879 }
10880
10881end:
10882 sme_release_global_lock(&pMac->sme);
10883
10884 return status;
10885}
10886
10887/**
10888 * sme_ocb_start_timing_advert() - Start sending timing advert frames
10889 * @hHal: reference to the HAL
10890 * @timing_advert: the timing advertisement struct
10891 *
10892 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
10893 */
10894CDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
10895 struct sir_ocb_timing_advert *timing_advert)
10896{
10897 CDF_STATUS status = CDF_STATUS_E_FAILURE;
10898 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10899 cds_msg_t msg = {0};
10900 void *buf;
10901 struct sir_ocb_timing_advert *sme_timing_advert;
10902
10903 /* Lock the SME structure */
10904 status = sme_acquire_global_lock(&pMac->sme);
10905 if (!CDF_IS_STATUS_SUCCESS(status))
10906 return status;
10907
10908 buf = cdf_mem_malloc(sizeof(*sme_timing_advert) +
10909 timing_advert->template_length);
10910 if (!buf) {
10911 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10912 FL("Not able to allocate memory for start TA"));
10913 status = CDF_STATUS_E_NOMEM;
10914 goto end;
10915 }
10916
10917 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
10918 *sme_timing_advert = *timing_advert;
10919 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
10920 cdf_mem_copy(sme_timing_advert->template_value,
10921 timing_advert->template_value, timing_advert->template_length);
10922
10923 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
10924 msg.reserved = 0;
10925 msg.bodyptr = buf;
10926 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10927 if (!CDF_IS_STATUS_SUCCESS(status)) {
10928 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10929 FL("Not able to post msg to WDA"));
10930 goto end;
10931 }
10932
10933end:
10934 sme_release_global_lock(&pMac->sme);
10935
10936 return status;
10937}
10938
10939/**
10940 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
10941 * @hHal: reference to the HAL
10942 * @timing_advert: the timing advertisement struct
10943 *
10944 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
10945 */
10946CDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
10947 struct sir_ocb_timing_advert *timing_advert)
10948{
10949 CDF_STATUS status = CDF_STATUS_E_FAILURE;
10950 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10951 cds_msg_t msg = {0};
10952 struct sir_ocb_timing_advert *sme_timing_advert;
10953
10954 /* Lock the SME structure */
10955 status = sme_acquire_global_lock(&pMac->sme);
10956 if (!CDF_IS_STATUS_SUCCESS(status))
10957 return status;
10958
10959 sme_timing_advert = cdf_mem_malloc(sizeof(*timing_advert));
10960 if (!sme_timing_advert) {
10961 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10962 FL("Not able to allocate memory for stop TA"));
10963 status = CDF_STATUS_E_NOMEM;
10964 goto end;
10965 }
10966 *sme_timing_advert = *timing_advert;
10967
10968 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
10969 msg.reserved = 0;
10970 msg.bodyptr = sme_timing_advert;
10971 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
10972 if (!CDF_IS_STATUS_SUCCESS(status)) {
10973 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
10974 FL("Not able to post msg to WDA"));
10975 goto end;
10976 }
10977
10978end:
10979 sme_release_global_lock(&pMac->sme);
10980
10981 return status;
10982}
10983
10984/**
Naveen Rawatb4d37622015-11-13 16:15:25 -080010985 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
10986 * @hal_handle: reference to the HAL
10987 * @self_addr: the self MAC address
10988 * @buf: the buffer that will contain the frame
10989 * @timestamp_offset: return for the offset of the timestamp field
10990 * @time_value_offset: return for the time_value field in the TA IE
10991 *
10992 * Return: the length of the buffer.
10993 */
10994int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
10995 tSirMacAddr self_addr, uint8_t **buf,
10996 uint32_t *timestamp_offset,
10997 uint32_t *time_value_offset)
10998{
10999 int template_length;
11000 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
11001
11002 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
11003 timestamp_offset,
11004 time_value_offset);
11005 return template_length;
11006}
11007/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011008 * sme_ocb_get_tsf_timer() - Get the TSF timer value
11009 * @hHal: reference to the HAL
11010 * @context: the context of the call
11011 * @callback: the callback to hdd
11012 * @request: the TSF timer request
11013 *
11014 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
11015 */
11016CDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
11017 ocb_callback callback,
11018 struct sir_ocb_get_tsf_timer *request)
11019{
11020 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11021 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11022 cds_msg_t msg = {0};
11023 struct sir_ocb_get_tsf_timer *msg_body;
11024
11025 /* Lock the SME structure */
11026 status = sme_acquire_global_lock(&pMac->sme);
11027 if (!CDF_IS_STATUS_SUCCESS(status))
11028 return status;
11029
11030 /* Allocate memory for the WMI request, and copy the parameter */
11031 msg_body = cdf_mem_malloc(sizeof(*msg_body));
11032 if (!msg_body) {
11033 status = CDF_STATUS_E_NOMEM;
11034 goto end;
11035 }
11036 *msg_body = *request;
11037
11038 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
11039 msg.bodyptr = msg_body;
11040
11041 /* Set the request callback and the context */
11042 pMac->sme.ocb_get_tsf_timer_callback = callback;
11043 pMac->sme.ocb_get_tsf_timer_context = context;
11044
11045 /* Post the message to WDA */
11046 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
11047 if (!CDF_IS_STATUS_SUCCESS(status)) {
11048 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11049 FL("Error posting message to WDA: %d"), status);
11050 pMac->sme.ocb_get_tsf_timer_callback = NULL;
11051 pMac->sme.ocb_get_tsf_timer_context = NULL;
11052 cdf_mem_free(msg_body);
11053 goto end;
11054 }
11055
11056end:
11057 sme_release_global_lock(&pMac->sme);
11058
11059 return status;
11060}
11061
11062/**
11063 * sme_dcc_get_stats() - Get the DCC stats
11064 * @hHal: reference to the HAL
11065 * @context: the context of the call
11066 * @callback: the callback to hdd
11067 * @request: the get DCC stats request
11068 *
11069 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
11070 */
11071CDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
11072 ocb_callback callback,
11073 struct sir_dcc_get_stats *request)
11074{
11075 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11076 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11077 cds_msg_t msg = {0};
11078 struct sir_dcc_get_stats *msg_body;
11079
11080 /* Lock the SME structure */
11081 status = sme_acquire_global_lock(&pMac->sme);
11082 if (!CDF_IS_STATUS_SUCCESS(status))
11083 return status;
11084
11085 /* Allocate memory for the WMI request, and copy the parameter */
11086 msg_body = cdf_mem_malloc(sizeof(*msg_body) +
11087 request->request_array_len);
11088 if (!msg_body) {
11089 status = CDF_STATUS_E_NOMEM;
11090 goto end;
11091 }
11092 *msg_body = *request;
11093 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
11094 cdf_mem_copy(msg_body->request_array, request->request_array,
11095 request->request_array_len);
11096
11097 msg.type = WMA_DCC_GET_STATS_CMD;
11098 msg.bodyptr = msg_body;
11099
11100 /* Set the request callback and context */
11101 pMac->sme.dcc_get_stats_callback = callback;
11102 pMac->sme.dcc_get_stats_context = context;
11103
11104 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
11105 if (!CDF_IS_STATUS_SUCCESS(status)) {
11106 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11107 FL("Error posting message to WDA: %d"), status);
11108 pMac->sme.dcc_get_stats_callback = callback;
11109 pMac->sme.dcc_get_stats_context = context;
11110 cdf_mem_free(msg_body);
11111 goto end;
11112 }
11113
11114end:
11115 sme_release_global_lock(&pMac->sme);
11116
11117 return status;
11118}
11119
11120/**
11121 * sme_dcc_clear_stats() - Clear the DCC stats
11122 * @hHal: reference to the HAL
11123 * @vdev_id: vdev id for OCB interface
11124 * @dcc_stats_bitmap: the entries in the stats to clear
11125 *
11126 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
11127 */
11128CDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
11129 uint32_t dcc_stats_bitmap)
11130{
11131 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11132 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11133 cds_msg_t msg = {0};
11134 struct sir_dcc_clear_stats *request;
11135
11136 /* Lock the SME structure */
11137 status = sme_acquire_global_lock(&pMac->sme);
11138 if (!CDF_IS_STATUS_SUCCESS(status))
11139 return status;
11140
11141 request = cdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
11142 if (!request) {
11143 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11144 FL("Not able to allocate memory"));
11145 status = CDF_STATUS_E_NOMEM;
11146 goto end;
11147 }
11148
11149 cdf_mem_zero(request, sizeof(*request));
11150 request->vdev_id = vdev_id;
11151 request->dcc_stats_bitmap = dcc_stats_bitmap;
11152
11153 msg.type = WMA_DCC_CLEAR_STATS_CMD;
11154 msg.bodyptr = request;
11155
11156 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
11157 if (!CDF_IS_STATUS_SUCCESS(status)) {
11158 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11159 FL("Not able to post msg to WDA"));
11160 cdf_mem_free(request);
11161 goto end;
11162 }
11163
11164end:
11165 sme_release_global_lock(&pMac->sme);
11166
11167 return status;
11168}
11169
11170/**
11171 * sme_dcc_update_ndl() - Update the DCC settings
11172 * @hHal: reference to the HAL
11173 * @context: the context of the call
11174 * @callback: the callback to hdd
11175 * @request: the update DCC request
11176 *
11177 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
11178 */
11179CDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
11180 ocb_callback callback,
11181 struct sir_dcc_update_ndl *request)
11182{
11183 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11184 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11185 cds_msg_t msg = {0};
11186 struct sir_dcc_update_ndl *msg_body;
11187
11188 /* Lock the SME structure */
11189 status = sme_acquire_global_lock(&pMac->sme);
11190 if (!CDF_IS_STATUS_SUCCESS(status))
11191 return status;
11192
11193 /* Allocate memory for the WMI request, and copy the parameter */
11194 msg_body = cdf_mem_malloc(sizeof(*msg_body) +
11195 request->dcc_ndl_chan_list_len +
11196 request->dcc_ndl_active_state_list_len);
11197 if (!msg_body) {
11198 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11199 FL("Failed to allocate memory"));
11200 status = CDF_STATUS_E_NOMEM;
11201 goto end;
11202 }
11203
11204 *msg_body = *request;
11205
11206 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
11207 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
11208 request->dcc_ndl_chan_list_len;
11209 cdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
11210 request->dcc_ndl_active_state_list_len);
11211 cdf_mem_copy(msg_body->dcc_ndl_active_state_list,
11212 request->dcc_ndl_active_state_list,
11213 request->dcc_ndl_active_state_list_len);
11214
11215 msg.type = WMA_DCC_UPDATE_NDL_CMD;
11216 msg.bodyptr = msg_body;
11217
11218 /* Set the request callback and the context */
11219 pMac->sme.dcc_update_ndl_callback = callback;
11220 pMac->sme.dcc_update_ndl_context = context;
11221
11222 status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
11223 if (!CDF_IS_STATUS_SUCCESS(status)) {
11224 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11225 FL("Error posting message to WDA: %d"), status);
11226 pMac->sme.dcc_update_ndl_callback = NULL;
11227 pMac->sme.dcc_update_ndl_context = NULL;
11228 cdf_mem_free(msg_body);
11229 goto end;
11230 }
11231
11232end:
11233 sme_release_global_lock(&pMac->sme);
11234
11235 return status;
11236}
11237
11238/**
11239 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
11240 * event
11241 * @hHal: reference to the HAL
11242 * @context: the context of the call
11243 * @callback: the callback to hdd
11244 *
11245 * Return: CDF_STATUS_SUCCESS on success, CDF_STATUS_E_FAILURE on failure
11246 */
11247CDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
11248 ocb_callback callback)
11249{
11250 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11251 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11252
11253 status = sme_acquire_global_lock(&pMac->sme);
11254 pMac->sme.dcc_stats_event_callback = callback;
11255 pMac->sme.dcc_stats_event_context = context;
11256 sme_release_global_lock(&pMac->sme);
11257
11258 return 0;
11259}
11260
11261void sme_get_recovery_stats(tHalHandle hHal)
11262{
11263 uint8_t i;
11264
11265 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11266 "Self Recovery Stats");
11267 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
11268 if (eSmeNoCommand !=
11269 g_self_recovery_stats.activeCmdStats[i].command) {
11270 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11271 "timestamp %llu: command 0x%0X: reason %d: session %d",
11272 g_self_recovery_stats.activeCmdStats[i].
11273 timestamp,
11274 g_self_recovery_stats.activeCmdStats[i].command,
11275 g_self_recovery_stats.activeCmdStats[i].reason,
11276 g_self_recovery_stats.activeCmdStats[i].
11277 sessionId);
11278 }
11279 }
11280}
11281
11282/**
11283 * sme_save_active_cmd_stats() - To save active command stats
11284 * @hHal: HAL context
11285 *
11286 * This routine is to save active command stats
11287 *
11288 * Return: None
11289 */
11290void sme_save_active_cmd_stats(tHalHandle hHal)
11291{
11292 tSmeCmd *pTempCmd = NULL;
11293 tListElem *pEntry;
11294 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11295 uint8_t statidx = 0;
11296 tActiveCmdStats *actv_cmd_stat = NULL;
11297
11298 if (NULL == pMac) {
11299 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11300 FL("pMac is NULL"));
11301 return;
11302 }
11303
11304 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11305 if (pEntry)
11306 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11307
11308 if (!pTempCmd)
11309 return;
11310
11311 if (eSmeCsrCommandMask & pTempCmd->command) {
11312 statidx = g_self_recovery_stats.cmdStatsIndx;
11313 actv_cmd_stat = &g_self_recovery_stats.activeCmdStats[statidx];
11314 actv_cmd_stat->command = pTempCmd->command;
11315 actv_cmd_stat->sessionId = pTempCmd->sessionId;
11316 actv_cmd_stat->timestamp = cds_get_monotonic_boottime();
11317 if (eSmeCommandRoam == pTempCmd->command)
11318 actv_cmd_stat->reason = pTempCmd->u.roamCmd.roamReason;
11319 else if (eSmeCommandScan == pTempCmd->command)
11320 actv_cmd_stat->reason = pTempCmd->u.scanCmd.reason;
11321 else
11322 actv_cmd_stat->reason = 0xFF;
11323
11324 g_self_recovery_stats.cmdStatsIndx =
11325 ((g_self_recovery_stats.cmdStatsIndx + 1) &
11326 (MAX_ACTIVE_CMD_STATS - 1));
11327 }
11328 return;
11329}
11330
11331void active_list_cmd_timeout_handle(void *userData)
11332{
11333 if (NULL == userData)
11334 return;
11335 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11336 "%s: Active List command timeout Cmd List Count %d", __func__,
11337 csr_ll_count(&((tpAniSirGlobal) userData)->sme.
11338 smeCmdActiveList));
11339 sme_get_command_q_status((tHalHandle) userData);
11340
11341 if (((tpAniSirGlobal) userData)->sme.enableSelfRecovery) {
11342 sme_save_active_cmd_stats((tHalHandle) userData);
11343 cds_trigger_recovery();
11344 } else {
11345 CDF_BUG(0);
11346 }
11347}
11348
11349CDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
11350{
11351 cds_msg_t msg;
11352 tpSirModemPowerStateInd request_buf;
11353 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11354
11355 if (NULL == pMac) {
11356 return CDF_STATUS_E_FAILURE;
11357 }
11358
11359 request_buf = cdf_mem_malloc(sizeof(tSirModemPowerStateInd));
11360 if (NULL == request_buf) {
11361 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11362 "%s: Not able to allocate memory for MODEM POWER STATE IND",
11363 __func__);
11364 return CDF_STATUS_E_NOMEM;
11365 }
11366
11367 request_buf->param = value;
11368
11369 msg.type = WMA_MODEM_POWER_STATE_IND;
11370 msg.reserved = 0;
11371 msg.bodyptr = request_buf;
11372 if (!CDF_IS_STATUS_SUCCESS
11373 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
11374 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11375 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message"
11376 " to WMA", __func__);
11377 cdf_mem_free(request_buf);
11378 return CDF_STATUS_E_FAILURE;
11379 }
11380
11381 return CDF_STATUS_SUCCESS;
11382}
11383
11384#ifdef QCA_HT_2040_COEX
11385CDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
11386 struct cdf_mac_addr macAddrSTA,
11387 uint8_t sessionId,
11388 uint8_t channel_type)
11389{
11390 cds_msg_t msg;
11391 tUpdateVHTOpMode *pHtOpMode = NULL;
11392 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11393
11394 if (NULL == pMac) {
11395 return CDF_STATUS_E_FAILURE;
11396 }
11397
11398 pHtOpMode = cdf_mem_malloc(sizeof(tUpdateVHTOpMode));
11399 if (NULL == pHtOpMode) {
11400 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11401 "%s: Not able to allocate memory for setting OP mode",
11402 __func__);
11403 return CDF_STATUS_E_NOMEM;
11404 }
11405
11406 switch (channel_type) {
11407 case eHT_CHAN_HT20:
11408 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
11409 break;
11410
11411 case eHT_CHAN_HT40MINUS:
11412 case eHT_CHAN_HT40PLUS:
11413 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
11414 break;
11415
11416 default:
11417 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11418 "%s: Invalid OP mode", __func__);
11419 return CDF_STATUS_E_FAILURE;
11420 }
11421
11422 pHtOpMode->staId = staId,
11423 cdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
11424 sizeof(tSirMacAddr));
11425 pHtOpMode->smesessionId = sessionId;
11426
11427 msg.type = WMA_UPDATE_OP_MODE;
11428 msg.reserved = 0;
11429 msg.bodyptr = pHtOpMode;
11430 if (!CDF_IS_STATUS_SUCCESS
11431 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
11432 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11433 "%s: Not able to post WMA_UPDATE_OP_MODE message"
11434 " to WMA", __func__);
11435 cdf_mem_free(pHtOpMode);
11436 return CDF_STATUS_E_FAILURE;
11437 }
11438
11439 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
11440 "%s: Notifed FW about OP mode: %d for staId=%d",
11441 __func__, pHtOpMode->opMode, staId);
11442
11443 return CDF_STATUS_SUCCESS;
11444}
11445
11446/* ---------------------------------------------------------------------------
11447
11448 \fn sme_set_ht2040_mode
11449
11450 \brief To update HT Operation beacon IE.
11451
11452 \param
11453
11454 \return CDF_STATUS SUCCESS
11455 FAILURE or RESOURCES
11456 The API finished and failed.
11457
11458 -------------------------------------------------------------------------------*/
11459CDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
11460 uint8_t channel_type, bool obssEnabled)
11461{
11462 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11463 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11464 ePhyChanBondState cbMode;
11465
11466 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
11467 "%s: Update HT operation beacon IE, channel_type=%d",
11468 __func__, channel_type);
11469
11470 switch (channel_type) {
11471 case eHT_CHAN_HT20:
11472 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
11473 break;
11474 case eHT_CHAN_HT40MINUS:
11475 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
11476 break;
11477 case eHT_CHAN_HT40PLUS:
11478 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
11479 break;
11480 default:
11481 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11482 "%s:Error!!! Invalid HT20/40 mode !", __func__);
11483 return CDF_STATUS_E_FAILURE;
11484 }
11485 status = sme_acquire_global_lock(&pMac->sme);
11486 if (CDF_IS_STATUS_SUCCESS(status)) {
11487 status = csr_set_ht2040_mode(pMac, sessionId,
11488 cbMode, obssEnabled);
11489 sme_release_global_lock(&pMac->sme);
11490 }
11491 return status;
11492}
11493
11494/* ---------------------------------------------------------------------------
11495
11496 \fn sme_set_phy_cb_mode24_g
11497
11498 \brief Changes PHY channel bonding mode
11499
11500 \param hHal - The handle returned by mac_open.
11501
11502 \param cbMode new channel bonding mode which is to set
11503
11504 \return CDF_STATUS SUCCESS.
11505
11506 -------------------------------------------------------------------------------*/
11507CDF_STATUS sme_set_phy_cb_mode24_g(tHalHandle hHal, ePhyChanBondState phyCBMode)
11508{
11509 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11510
11511 if (NULL == pMac) {
11512 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11513 "%s: invalid context", __func__);
11514 return CDF_STATUS_E_FAILURE;
11515 }
11516
11517 pMac->roam.configParam.channelBondingMode24GHz = phyCBMode;
11518
11519 return CDF_STATUS_SUCCESS;
11520}
11521#endif
11522
11523/*
11524 * SME API to enable/disable idle mode powersave
11525 * This should be called only if powersave offload
11526 * is enabled
11527 */
11528CDF_STATUS sme_set_idle_powersave_config(void *cds_context,
11529 tHalHandle hHal, uint32_t value)
11530{
11531 void *wmaContext = cds_get_context(CDF_MODULE_ID_WMA);
11532 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11533
11534 if (NULL == wmaContext) {
11535 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11536 "%s: wmaContext is NULL", __func__);
11537 return CDF_STATUS_E_FAILURE;
11538 }
11539 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
11540 " Idle Ps Set Value %d", value);
11541
11542 pMac->imps_enabled = false;
11543 if (CDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
11544 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11545 " Failed to Set Idle Ps Value %d", value);
11546 return CDF_STATUS_E_FAILURE;
11547 }
11548 if (value)
11549 pMac->imps_enabled = true;
11550 return CDF_STATUS_SUCCESS;
11551}
11552
11553int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id, uint16_t ht_capab)
11554{
11555 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11556 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, session_id);
11557
11558 if (NULL == pSession) {
11559 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11560 "%s: pSession is NULL", __func__);
11561 return -EIO;
11562 }
11563 switch (ht_capab) {
11564 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
11565 return pSession->htConfig.ht_rx_ldpc;
11566 case WNI_CFG_HT_CAP_INFO_TX_STBC:
11567 return pSession->htConfig.ht_tx_stbc;
11568 case WNI_CFG_HT_CAP_INFO_RX_STBC:
11569 return pSession->htConfig.ht_rx_stbc;
11570 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
11571 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
11572 return pSession->htConfig.ht_sgi;
11573 default:
11574 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11575 "invalid ht capability");
11576 return -EIO;
11577 }
11578}
11579
11580int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
11581 int value)
11582{
11583 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11584 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11585
11586 if (NULL == pSession) {
11587 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11588 "%s: pSession is NULL", __func__);
11589 return -EIO;
11590 }
11591
11592 if (CDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
11593 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11594 "Failed to set ht capability in target");
11595 return -EIO;
11596 }
11597
11598 switch (htCapab) {
11599 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
11600 pSession->htConfig.ht_rx_ldpc = value;
11601 break;
11602 case WNI_CFG_HT_CAP_INFO_TX_STBC:
11603 pSession->htConfig.ht_tx_stbc = value;
11604 break;
11605 case WNI_CFG_HT_CAP_INFO_RX_STBC:
11606 pSession->htConfig.ht_rx_stbc = value;
11607 break;
11608 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
11609 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
11610 pSession->htConfig.ht_sgi = value;
11611 break;
11612 }
11613
11614 return 0;
11615}
11616
11617#define HT20_SHORT_GI_MCS7_RATE 722
11618/* ---------------------------------------------------------------------------
11619 \fn sme_send_rate_update_ind
11620 \brief API to Update rate
11621 \param hHal - The handle returned by mac_open
11622 \param rateUpdateParams - Pointer to rate update params
11623 \return CDF_STATUS
11624 ---------------------------------------------------------------------------*/
11625CDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
11626 tSirRateUpdateInd *rateUpdateParams)
11627{
11628 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11629 CDF_STATUS status;
11630 cds_msg_t msg;
11631 tSirRateUpdateInd *rate_upd = cdf_mem_malloc(sizeof(tSirRateUpdateInd));
11632
11633 if (rate_upd == NULL) {
11634 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11635 "Rate update struct alloc failed");
11636 return CDF_STATUS_E_FAILURE;
11637 }
11638 *rate_upd = *rateUpdateParams;
11639
11640 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
11641 rate_upd->mcastDataRate24GHzTxFlag =
11642 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
11643 else if (rate_upd->reliableMcastDataRate ==
11644 HT20_SHORT_GI_MCS7_RATE)
11645 rate_upd->reliableMcastDataRateTxFlag =
11646 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
11647
11648 status = sme_acquire_global_lock(&pMac->sme);
11649 if (CDF_STATUS_SUCCESS == status) {
11650 msg.type = WMA_RATE_UPDATE_IND;
11651 msg.bodyptr = rate_upd;
11652
11653 if (!CDF_IS_STATUS_SUCCESS
11654 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
11655 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11656 "%s: Not able "
11657 "to post WMA_SET_RMC_RATE_IND to WMA!",
11658 __func__);
11659
11660 sme_release_global_lock(&pMac->sme);
11661 cdf_mem_free(rate_upd);
11662 return CDF_STATUS_E_FAILURE;
11663 }
11664
11665 sme_release_global_lock(&pMac->sme);
11666 return CDF_STATUS_SUCCESS;
11667 }
11668
11669 return status;
11670}
11671
11672/**
11673 * sme_get_reg_info() - To get registration info
11674 * @hHal: HAL context
11675 * @chanId: channel id
11676 * @regInfo1: first reg info to fill
11677 * @regInfo2: second reg info to fill
11678 *
11679 * This routine will give you reg info
11680 *
11681 * Return: CDF_STATUS
11682 */
11683CDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
11684 uint32_t *regInfo1, uint32_t *regInfo2)
11685{
11686 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11687 CDF_STATUS status;
11688 uint8_t i;
11689 bool found = false;
11690
11691 status = sme_acquire_global_lock(&pMac->sme);
11692 *regInfo1 = 0;
11693 *regInfo2 = 0;
11694 if (!CDF_IS_STATUS_SUCCESS(status))
11695 return status;
11696
11697 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
11698 if (pMac->scan.defaultPowerTable[i].chanId == chanId) {
11699 SME_SET_CHANNEL_REG_POWER(*regInfo1,
11700 pMac->scan.defaultPowerTable[i].pwr);
11701
11702 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
11703 pMac->scan.defaultPowerTable[i].pwr);
11704 found = true;
11705 break;
11706 }
11707 }
11708 if (!found)
11709 status = CDF_STATUS_E_FAILURE;
11710
11711 sme_release_global_lock(&pMac->sme);
11712 return status;
11713}
11714
11715#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
11716/* ---------------------------------------------------------------------------
11717 \fn sme_auto_shutdown_cb
11718 \brief Used to plug in callback function for receiving auto shutdown evt
11719 \param hHal
11720 \param pCallbackfn : callback function pointer should be plugged in
11721 \- return CDF_STATUS
11722 -------------------------------------------------------------------------*/
11723CDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
11724 ) {
11725 CDF_STATUS status = CDF_STATUS_SUCCESS;
11726 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11727
11728 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11729 "%s: Plug in Auto shutdown event callback", __func__);
11730
11731 status = sme_acquire_global_lock(&pMac->sme);
11732 if (CDF_STATUS_SUCCESS == status) {
11733 if (NULL != pCallbackfn) {
11734 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
11735 }
11736 sme_release_global_lock(&pMac->sme);
11737 }
11738
11739 return status;
11740}
11741
11742/* ---------------------------------------------------------------------------
11743 \fn sme_set_auto_shutdown_timer
11744 \API to set auto shutdown timer value in FW.
11745 \param hHal - The handle returned by mac_open
11746 \param timer_val - The auto shutdown timer value to be set
11747 \- return Configuration message posting status, SUCCESS or Fail
11748 -------------------------------------------------------------------------*/
11749CDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
11750{
11751 CDF_STATUS status = CDF_STATUS_SUCCESS;
11752 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
11753 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11754 tSirAutoShutdownCmdParams *auto_sh_cmd;
11755 cds_msg_t cds_message;
11756
11757 status = sme_acquire_global_lock(&pMac->sme);
11758 if (CDF_STATUS_SUCCESS == status) {
11759 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
11760 cdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
11761 if (auto_sh_cmd == NULL) {
11762 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
11763 "%s Request Buffer Alloc Fail", __func__);
11764 sme_release_global_lock(&pMac->sme);
11765 return CDF_STATUS_E_NOMEM;
11766 }
11767
11768 auto_sh_cmd->timer_val = timer_val;
11769
11770 /* serialize the req through MC thread */
11771 cds_message.bodyptr = auto_sh_cmd;
11772 cds_message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
11773 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
11774 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
11775 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11776 "%s: Post Auto shutdown MSG fail", __func__);
11777 cdf_mem_free(auto_sh_cmd);
11778 sme_release_global_lock(&pMac->sme);
11779 return CDF_STATUS_E_FAILURE;
11780 }
11781 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
11782 "%s: Posted Auto shutdown MSG", __func__);
11783 sme_release_global_lock(&pMac->sme);
11784 }
11785
11786 return status;
11787}
11788#endif
11789
11790#ifdef FEATURE_WLAN_CH_AVOID
11791/* ---------------------------------------------------------------------------
11792 \fn sme_add_ch_avoid_callback
11793 \brief Used to plug in callback function
11794 Which notify channel may not be used with SAP or P2PGO mode.
11795 Notification come from FW.
11796 \param hHal
11797 \param pCallbackfn : callback function pointer should be plugged in
11798 \- return CDF_STATUS
11799 -------------------------------------------------------------------------*/
11800CDF_STATUS sme_add_ch_avoid_callback
11801 (tHalHandle hHal, void (*pCallbackfn)(void *pAdapter, void *indParam)
11802 ) {
11803 CDF_STATUS status = CDF_STATUS_SUCCESS;
11804 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11805
11806 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11807 "%s: Plug in CH AVOID CB", __func__);
11808
11809 status = sme_acquire_global_lock(&pMac->sme);
11810 if (CDF_STATUS_SUCCESS == status) {
11811 if (NULL != pCallbackfn) {
11812 pMac->sme.pChAvoidNotificationCb = pCallbackfn;
11813 }
11814 sme_release_global_lock(&pMac->sme);
11815 }
11816
11817 return status;
11818}
11819
11820/* ---------------------------------------------------------------------------
11821 \fn sme_ch_avoid_update_req
11822 \API to request channel avoidance update from FW.
11823 \param hHal - The handle returned by mac_open
11824 \param update_type - The udpate_type parameter of this request call
11825 \- return Configuration message posting status, SUCCESS or Fail
11826 -------------------------------------------------------------------------*/
11827CDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
11828{
11829 CDF_STATUS status = CDF_STATUS_SUCCESS;
11830 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
11831 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11832 tSirChAvoidUpdateReq *cauReq;
11833 cds_msg_t cds_message;
11834
11835 status = sme_acquire_global_lock(&pMac->sme);
11836 if (CDF_STATUS_SUCCESS == status) {
11837 cauReq = (tSirChAvoidUpdateReq *)
11838 cdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
11839 if (NULL == cauReq) {
11840 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
11841 "%s Request Buffer Alloc Fail", __func__);
11842 sme_release_global_lock(&pMac->sme);
11843 return CDF_STATUS_E_NOMEM;
11844 }
11845
11846 cauReq->reserved_param = 0;
11847
11848 /* serialize the req through MC thread */
11849 cds_message.bodyptr = cauReq;
11850 cds_message.type = WMA_CH_AVOID_UPDATE_REQ;
11851 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
11852 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
11853 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11854 "%s: Post Ch Avoid Update MSG fail",
11855 __func__);
11856 cdf_mem_free(cauReq);
11857 sme_release_global_lock(&pMac->sme);
11858 return CDF_STATUS_E_FAILURE;
11859 }
11860 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
11861 "%s: Posted Ch Avoid Update MSG", __func__);
11862 sme_release_global_lock(&pMac->sme);
11863 }
11864
11865 return status;
11866}
11867#endif /* FEATURE_WLAN_CH_AVOID */
11868
11869/**
11870 * sme_set_miracast() - Function to set miracast value to UMAC
11871 * @hal: Handle returned by macOpen
11872 * @filter_type: 0-Disabled, 1-Source, 2-sink
11873 *
11874 * This function passes down the value of miracast set by
11875 * framework to UMAC
11876 *
11877 * Return: Configuration message posting status, SUCCESS or Fail
11878 *
11879 */
11880CDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
11881{
11882 cds_msg_t msg;
11883 uint32_t *val;
11884 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
11885
11886 val = cdf_mem_malloc(sizeof(*val));
11887 if (NULL == val || NULL == mac_ptr) {
11888 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11889 "%s: Invalid pointer", __func__);
11890 return CDF_STATUS_E_NOMEM;
11891 }
11892
11893 *val = filter_type;
11894
11895 msg.type = SIR_HAL_SET_MIRACAST;
11896 msg.reserved = 0;
11897 msg.bodyptr = val;
11898
11899 if (!CDF_IS_STATUS_SUCCESS(
11900 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
11901 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11902 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
11903 __func__);
11904 cdf_mem_free(val);
11905 return CDF_STATUS_E_FAILURE;
11906 }
11907
11908 mac_ptr->sme.miracast_value = filter_type;
11909 return CDF_STATUS_SUCCESS;
11910}
11911
11912/**
11913 * sme_set_mas() - Function to set MAS value to UMAC
11914 * @val: 1-Enable, 0-Disable
11915 *
11916 * This function passes down the value of MAS to the UMAC. A
11917 * value of 1 will enable MAS and a value of 0 will disable MAS
11918 *
11919 * Return: Configuration message posting status, SUCCESS or Fail
11920 *
11921 */
11922CDF_STATUS sme_set_mas(uint32_t val)
11923{
11924 cds_msg_t msg;
11925 uint32_t *ptr_val;
11926
11927 ptr_val = cdf_mem_malloc(sizeof(*ptr_val));
11928 if (NULL == ptr_val) {
11929 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11930 "%s: could not allocate ptr_val", __func__);
11931 return CDF_STATUS_E_NOMEM;
11932 }
11933
11934 *ptr_val = val;
11935
11936 msg.type = SIR_HAL_SET_MAS;
11937 msg.reserved = 0;
11938 msg.bodyptr = ptr_val;
11939
11940 if (!CDF_IS_STATUS_SUCCESS(
11941 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
11942 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
11943 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
11944 __func__);
11945 cdf_mem_free(ptr_val);
11946 return CDF_STATUS_E_FAILURE;
11947 }
11948 return CDF_STATUS_SUCCESS;
11949}
11950
11951/* -------------------------------------------------------------------------
11952 \fn sme_roam_channel_change_req
11953 \brief API to Indicate Channel change to new target channel
11954 \param hHal - The handle returned by mac_open
11955 \param targetChannel - New Channel to move the SAP to.
11956 \return CDF_STATUS
11957 ---------------------------------------------------------------------------*/
11958CDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
11959 struct cdf_mac_addr bssid, uint32_t cb_mode, tCsrRoamProfile *profile)
11960{
11961 CDF_STATUS status = CDF_STATUS_E_FAILURE;
11962 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11963 uint8_t ch_mode;
11964
11965 ch_mode = (profile->ChannelInfo.ChannelList[0] <=
11966 CSR_MAX_2_4_GHZ_SUPPORTED_CHANNELS) ?
11967 pMac->roam.configParam.channelBondingMode24GHz :
11968 pMac->roam.configParam.channelBondingMode5GHz;
11969
11970 status = sme_acquire_global_lock(&pMac->sme);
11971 if (CDF_IS_STATUS_SUCCESS(status)) {
11972
11973 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_MED,
11974 FL("sapdfs: requested cbmode=[%d] & new negotiated cbmode[%d]"),
11975 cb_mode, ch_mode);
11976 status = csr_roam_channel_change_req(pMac, bssid, ch_mode,
11977 profile);
11978 sme_release_global_lock(&pMac->sme);
11979 }
11980 return status;
11981}
11982
11983/* -------------------------------------------------------------------------
11984 \fn sme_process_channel_change_resp
11985 \brief API to Indicate Channel change response message to SAP.
11986 \return CDF_STATUS
11987 ---------------------------------------------------------------------------*/
11988CDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
11989 uint16_t msg_type, void *pMsgBuf)
11990{
11991 CDF_STATUS status = CDF_STATUS_SUCCESS;
11992 tCsrRoamInfo proam_info = { 0 };
11993 eCsrRoamResult roamResult;
11994 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
11995 uint32_t SessionId = pChnlParams->peSessionId;
11996
11997 proam_info.channelChangeRespEvent =
11998 (tSirChanChangeResponse *)
11999 cdf_mem_malloc(sizeof(tSirChanChangeResponse));
12000 if (NULL == proam_info.channelChangeRespEvent) {
12001 status = CDF_STATUS_E_NOMEM;
12002 sms_log(pMac, LOGE,
12003 "Channel Change Event Allocation Failed: %d\n", status);
12004 return status;
12005 }
12006 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
12007 proam_info.channelChangeRespEvent->sessionId = SessionId;
12008 proam_info.channelChangeRespEvent->newChannelNumber =
12009 pChnlParams->channelNumber;
12010 proam_info.channelChangeRespEvent->secondaryChannelOffset =
12011 pChnlParams->ch_width;
12012
12013 if (pChnlParams->status == CDF_STATUS_SUCCESS) {
12014 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_MED,
12015 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
12016 SessionId);
12017 proam_info.channelChangeRespEvent->channelChangeStatus =
12018 1;
12019 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
12020 } else {
12021 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO_MED,
12022 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
12023 SessionId);
12024 proam_info.channelChangeRespEvent->channelChangeStatus =
12025 0;
12026 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
12027 }
12028
12029 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
12030 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
12031
12032 } else {
12033 status = CDF_STATUS_E_FAILURE;
12034 sms_log(pMac, LOGE, "Invalid Channel Change Resp Message: %d\n",
12035 status);
12036 }
12037 cdf_mem_free(proam_info.channelChangeRespEvent);
12038
12039 return status;
12040}
12041
12042/* -------------------------------------------------------------------------
12043 \fn sme_roam_start_beacon_req
12044 \brief API to Indicate LIM to start Beacon Tx
12045 \after SAP CAC Wait is completed.
12046 \param hHal - The handle returned by mac_open
12047 \param sessionId - session ID
12048 \param dfsCacWaitStatus - CAC WAIT status flag
12049 \return CDF_STATUS
12050 ---------------------------------------------------------------------------*/
12051CDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct cdf_mac_addr bssid,
12052 uint8_t dfsCacWaitStatus)
12053{
12054 CDF_STATUS status = CDF_STATUS_E_FAILURE;
12055 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12056 status = sme_acquire_global_lock(&pMac->sme);
12057
12058 if (CDF_IS_STATUS_SUCCESS(status)) {
12059 status = csr_roam_start_beacon_req(pMac, bssid, dfsCacWaitStatus);
12060 sme_release_global_lock(&pMac->sme);
12061 }
12062 return status;
12063}
12064
12065/* -------------------------------------------------------------------------
12066 \fn sme_roam_csa_ie_request
12067 \brief API to request CSA IE transmission from PE
12068 \param hHal - The handle returned by mac_open
12069 \param pDfsCsaReq - CSA IE request
12070 \param bssid - SAP bssid
12071 \param ch_bandwidth - Channel offset
12072 \return CDF_STATUS
12073 ---------------------------------------------------------------------------*/
12074CDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct cdf_mac_addr bssid,
12075 uint8_t targetChannel, uint8_t csaIeReqd,
12076 uint8_t ch_bandwidth)
12077{
12078 CDF_STATUS status = CDF_STATUS_E_FAILURE;
12079 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12080 status = sme_acquire_global_lock(&pMac->sme);
12081 if (CDF_IS_STATUS_SUCCESS(status)) {
12082 status = csr_roam_send_chan_sw_ie_request(pMac, bssid, targetChannel,
12083 csaIeReqd, ch_bandwidth);
12084 sme_release_global_lock(&pMac->sme);
12085 }
12086 return status;
12087}
12088
12089/* ---------------------------------------------------------------------------
12090 \fn sme_init_thermal_info
12091 \brief SME API to initialize the thermal mitigation parameters
12092 \param hHal
12093 \param thermalParam : thermal mitigation parameters
12094 \- return CDF_STATUS
12095 -------------------------------------------------------------------------*/
12096CDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams thermalParam)
12097{
12098 t_thermal_mgmt *pWmaParam;
12099 cds_msg_t msg;
12100 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12101
12102 pWmaParam = (t_thermal_mgmt *) cdf_mem_malloc(sizeof(t_thermal_mgmt));
12103 if (NULL == pWmaParam) {
12104 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12105 "%s: could not allocate tThermalMgmt", __func__);
12106 return CDF_STATUS_E_NOMEM;
12107 }
12108
12109 cdf_mem_zero((void *)pWmaParam, sizeof(t_thermal_mgmt));
12110
12111 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
12112 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
12113 pWmaParam->thermalLevels[0].minTempThreshold =
12114 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
12115 pWmaParam->thermalLevels[0].maxTempThreshold =
12116 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
12117 pWmaParam->thermalLevels[1].minTempThreshold =
12118 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
12119 pWmaParam->thermalLevels[1].maxTempThreshold =
12120 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
12121 pWmaParam->thermalLevels[2].minTempThreshold =
12122 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
12123 pWmaParam->thermalLevels[2].maxTempThreshold =
12124 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
12125 pWmaParam->thermalLevels[3].minTempThreshold =
12126 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
12127 pWmaParam->thermalLevels[3].maxTempThreshold =
12128 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
12129
12130 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
12131 msg.type = WMA_INIT_THERMAL_INFO_CMD;
12132 msg.bodyptr = pWmaParam;
12133
12134 if (!CDF_IS_STATUS_SUCCESS
12135 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
12136 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12137 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
12138 __func__);
12139 cdf_mem_free(pWmaParam);
12140 sme_release_global_lock(&pMac->sme);
12141 return CDF_STATUS_E_FAILURE;
12142 }
12143 sme_release_global_lock(&pMac->sme);
12144 return CDF_STATUS_SUCCESS;
12145 }
12146 cdf_mem_free(pWmaParam);
12147 return CDF_STATUS_E_FAILURE;
12148}
12149
12150/**
12151 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
12152 * @hal: Handle returned by macOpen
12153 * @callback: sme_set_thermal_level_callback
12154 *
12155 * Plug in set thermal level callback
12156 *
12157 * Return: none
12158 */
12159void sme_add_set_thermal_level_callback(tHalHandle hal,
12160 sme_set_thermal_level_callback callback)
12161{
12162 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
12163
12164 pMac->sme.set_thermal_level_cb = callback;
12165}
12166
12167/**
12168 * sme_set_thermal_level() - SME API to set the thermal mitigation level
12169 * @hal: Handler to HAL
12170 * @level: Thermal mitigation level
12171 *
12172 * Return: CDF_STATUS
12173 */
12174CDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
12175{
12176 cds_msg_t msg;
12177 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
12178 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12179
12180 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
12181 cdf_mem_set(&msg, sizeof(msg), 0);
12182 msg.type = WMA_SET_THERMAL_LEVEL;
12183 msg.bodyval = level;
12184
12185 cdf_status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
12186 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
12187 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12188 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
12189 __func__);
12190 sme_release_global_lock(&pMac->sme);
12191 return CDF_STATUS_E_FAILURE;
12192 }
12193 sme_release_global_lock(&pMac->sme);
12194 return CDF_STATUS_SUCCESS;
12195 }
12196 return CDF_STATUS_E_FAILURE;
12197}
12198
12199/* ---------------------------------------------------------------------------
12200 \fn sme_txpower_limit
12201 \brief SME API to set txpower limits
12202 \param hHal
12203 \param psmetx : power limits for 2g/5g
12204 \- return CDF_STATUS
12205 -------------------------------------------------------------------------*/
12206CDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
12207{
12208 CDF_STATUS status = CDF_STATUS_SUCCESS;
12209 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12210 cds_msg_t cds_message;
12211 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12212
12213 status = sme_acquire_global_lock(&pMac->sme);
12214 if (CDF_IS_STATUS_SUCCESS(status)) {
12215 cds_message.type = WMA_TX_POWER_LIMIT;
12216 cds_message.reserved = 0;
12217 cds_message.bodyptr = psmetx;
12218
12219 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12220 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
12221 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12222 "%s: not able to post WMA_TX_POWER_LIMIT",
12223 __func__);
12224 status = CDF_STATUS_E_FAILURE;
12225 cdf_mem_free(psmetx);
12226 }
12227 sme_release_global_lock(&pMac->sme);
12228 }
12229 return status;
12230}
12231
12232CDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
12233{
12234 CDF_STATUS status = CDF_STATUS_SUCCESS;
12235 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12236 pMac->fEnableDebugLog = set_value;
12237 return status;
12238}
12239
12240/* ---------------------------------------------------------------------------
12241 \fn sme_ap_disable_intra_bss_fwd
12242
12243 \brief
12244 SME will send message to WMA to set Intra BSS in txrx
12245
12246 \param
12247
12248 hHal - The handle returned by mac_open
12249
12250 sessionId - session id ( vdev id)
12251
12252 disablefwd - bool value that indicate disable intrabss fwd disable
12253
12254 \return CDF_STATUS
12255 --------------------------------------------------------------------------- */
12256CDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
12257 bool disablefwd)
12258{
12259 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12260 int status = CDF_STATUS_SUCCESS;
12261 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12262 cds_msg_t cds_message;
12263 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
12264
12265 /* Prepare the request to send to SME. */
12266 pSapDisableIntraFwd = cdf_mem_malloc(sizeof(tDisableIntraBssFwd));
12267 if (NULL == pSapDisableIntraFwd) {
12268 sms_log(pMac, LOGP, "Memory Allocation Failure!!! %s", __func__);
12269 return CDF_STATUS_E_NOMEM;
12270 }
12271
12272 cdf_mem_zero(pSapDisableIntraFwd, sizeof(tDisableIntraBssFwd));
12273
12274 pSapDisableIntraFwd->sessionId = sessionId;
12275 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
12276
12277 status = sme_acquire_global_lock(&pMac->sme);
12278 if (CDF_IS_STATUS_SUCCESS(status)) {
12279 /* serialize the req through MC thread */
12280 cds_message.bodyptr = pSapDisableIntraFwd;
12281 cds_message.type = WMA_SET_SAP_INTRABSS_DIS;
12282 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12283 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
12284 status = CDF_STATUS_E_FAILURE;
12285 cdf_mem_free(pSapDisableIntraFwd);
12286 }
12287 sme_release_global_lock(&pMac->sme);
12288 }
12289 return status;
12290}
12291
12292#ifdef WLAN_FEATURE_STATS_EXT
12293
12294/******************************************************************************
12295 \fn sme_stats_ext_register_callback
12296
12297 \brief
12298 a function called to register the callback that send vendor event for stats
12299 ext
12300
12301 \param callback - callback to be registered
12302******************************************************************************/
12303void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
12304{
12305 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12306
12307 pMac->sme.StatsExtCallback = callback;
12308}
12309
12310/******************************************************************************
12311 \fn sme_stats_ext_request
12312
12313 \brief
12314 a function called when HDD receives STATS EXT vendor command from userspace
12315
12316 \param sessionID - vdevID for the stats ext request
12317
12318 \param input - Stats Ext Request structure ptr
12319
12320 \return CDF_STATUS
12321******************************************************************************/
12322CDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
12323{
12324 cds_msg_t msg;
12325 tpStatsExtRequest data;
12326 size_t data_len;
12327
12328 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
12329 data = cdf_mem_malloc(data_len);
12330
12331 if (data == NULL) {
12332 return CDF_STATUS_E_NOMEM;
12333 }
12334
12335 cdf_mem_zero(data, data_len);
12336 data->vdev_id = session_id;
12337 data->request_data_len = input->request_data_len;
12338 if (input->request_data_len) {
12339 cdf_mem_copy(data->request_data,
12340 input->request_data, input->request_data_len);
12341 }
12342
12343 msg.type = WMA_STATS_EXT_REQUEST;
12344 msg.reserved = 0;
12345 msg.bodyptr = data;
12346
12347 if (CDF_STATUS_SUCCESS != cds_mq_post_message(CDF_MODULE_ID_WMA, &msg)) {
12348 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12349 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
12350 __func__);
12351 cdf_mem_free(data);
12352 return CDF_STATUS_E_FAILURE;
12353 }
12354
12355 return CDF_STATUS_SUCCESS;
12356}
12357
12358/******************************************************************************
12359 \fn sme_stats_ext_event
12360
12361 \brief
12362 a callback function called when SME received eWNI_SME_STATS_EXT_EVENT
12363 response from WMA
12364
12365 \param hHal - HAL handle for device
12366 \param pMsg - Message body passed from WMA; includes NAN header
12367 \return CDF_STATUS
12368******************************************************************************/
12369CDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
12370{
12371 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12372 CDF_STATUS status = CDF_STATUS_SUCCESS;
12373
12374 if (NULL == pMsg) {
12375 sms_log(pMac, LOGE, "in %s msg ptr is NULL", __func__);
12376 status = CDF_STATUS_E_FAILURE;
12377 } else {
12378 sms_log(pMac, LOG2, "SME: entering %s", __func__);
12379
12380 if (pMac->sme.StatsExtCallback) {
12381 pMac->sme.StatsExtCallback(pMac->hHdd,
12382 (tpStatsExtEvent) pMsg);
12383 }
12384 }
12385
12386 return status;
12387}
12388
12389#endif
12390
12391/* ---------------------------------------------------------------------------
12392 \fn sme_update_dfs_scan_mode
12393 \brief Update DFS roam scan mode
12394 This function is called through dynamic setConfig callback function
12395 to configure allowDFSChannelRoam.
12396 \param hHal - HAL handle for device
12397 \param sessionId - Session Identifier
12398 \param allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
12399 1 (passive), 2 (active)
12400 \return CDF_STATUS_SUCCESS - SME update DFS roaming scan config
12401 successfully.
12402 Other status means SME failed to update DFS roaming scan config.
12403 \sa
12404 -------------------------------------------------------------------------*/
12405CDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
12406 uint8_t allowDFSChannelRoam)
12407{
12408 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12409 CDF_STATUS status = CDF_STATUS_SUCCESS;
12410
12411 status = sme_acquire_global_lock(&pMac->sme);
12412 if (CDF_IS_STATUS_SUCCESS(status)) {
12413 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
12414 "LFR runtime successfully set AllowDFSChannelRoam Mode to "
12415 "%d - old value is %d - roam state is %s",
12416 allowDFSChannelRoam,
12417 pMac->roam.configParam.allowDFSChannelRoam,
12418 mac_trace_get_neighbour_roam_state(pMac->roam.
12419 neighborRoamInfo
12420 [sessionId].
12421 neighborRoamState));
12422 pMac->roam.configParam.allowDFSChannelRoam =
12423 allowDFSChannelRoam;
12424 sme_release_global_lock(&pMac->sme);
12425 }
12426 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
12427 csr_roam_offload_scan(pMac, sessionId,
12428 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
12429 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
12430 }
12431
12432 return status;
12433}
12434
12435/*--------------------------------------------------------------------------
12436 \brief sme_get_dfs_scan_mode() - get DFS roam scan mode
12437 This is a synchronous call
12438 \param hHal - The handle returned by mac_open.
12439 \return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
12440 \sa
12441 --------------------------------------------------------------------------*/
12442uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
12443{
12444 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12445 return pMac->roam.configParam.allowDFSChannelRoam;
12446}
12447
12448/*----------------------------------------------------------------------------
12449 \fn sme_modify_add_ie
12450 \brief This function sends msg to updates the additional IE buffers in PE
12451 \param hHal - global structure
12452 \param pModifyIE - pointer to tModifyIE structure
12453 \param updateType - type of buffer
12454 \- return Success or failure
12455 -----------------------------------------------------------------------------*/
12456CDF_STATUS sme_modify_add_ie(tHalHandle hHal,
12457 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
12458{
12459 CDF_STATUS status = CDF_STATUS_E_FAILURE;
12460 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12461 status = sme_acquire_global_lock(&pMac->sme);
12462
12463 if (CDF_IS_STATUS_SUCCESS(status)) {
12464 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
12465 sme_release_global_lock(&pMac->sme);
12466 }
12467 return status;
12468}
12469
12470/*----------------------------------------------------------------------------
12471 \fn sme_update_add_ie
12472 \brief This function sends msg to updates the additional IE buffers in PE
12473 \param hHal - global structure
12474 \param pUpdateIE - pointer to structure tUpdateIE
12475 \param updateType - type of buffer
12476 \- return Success or failure
12477 -----------------------------------------------------------------------------*/
12478CDF_STATUS sme_update_add_ie(tHalHandle hHal,
12479 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
12480{
12481 CDF_STATUS status = CDF_STATUS_E_FAILURE;
12482 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12483 status = sme_acquire_global_lock(&pMac->sme);
12484
12485 if (CDF_IS_STATUS_SUCCESS(status)) {
12486 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
12487 sme_release_global_lock(&pMac->sme);
12488 }
12489 return status;
12490}
12491
12492/* ---------------------------------------------------------------------------
12493 \fn sme_sta_in_middle_of_roaming
12494 \brief This function returns true if STA is in the middle of roaming state
12495 \param hHal - HAL handle for device
12496 \param sessionId - Session Identifier
12497 \- return true or false
12498 -------------------------------------------------------------------------*/
12499bool sme_sta_in_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12500{
12501 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12502 CDF_STATUS status = CDF_STATUS_SUCCESS;
12503 bool ret = false;
12504
12505 status = sme_acquire_global_lock(&pMac->sme);
12506 if (CDF_IS_STATUS_SUCCESS(status)) {
12507 ret = csr_neighbor_middle_of_roaming(hHal, sessionId);
12508 sme_release_global_lock(&pMac->sme);
12509 }
12510 return ret;
12511}
12512
12513
12514/**
12515 * sme_update_dsc_pto_up_mapping()
12516 * @hHal: HAL context
12517 * @dscpmapping: pointer to DSCP mapping structure
12518 * @sessionId: SME session id
12519 *
12520 * This routine is called to update dscp mapping
12521 *
12522 * Return: CDF_STATUS
12523 */
12524CDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
12525 sme_QosWmmUpType *dscpmapping,
12526 uint8_t sessionId)
12527{
12528 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12529 CDF_STATUS status = CDF_STATUS_SUCCESS;
12530 uint8_t i, j, peSessionId;
12531 tCsrRoamSession *pCsrSession = NULL;
12532 tpPESession pSession = NULL;
12533
12534 status = sme_acquire_global_lock(&pMac->sme);
12535 if (!CDF_IS_STATUS_SUCCESS(status))
12536 return status;
12537 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
12538 if (pCsrSession == NULL) {
12539 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12540 FL("Session lookup fails for CSR session"));
12541 sme_release_global_lock(&pMac->sme);
12542 return CDF_STATUS_E_FAILURE;
12543 }
12544 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
12545 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12546 FL("Invalid session Id %u"), sessionId);
12547 sme_release_global_lock(&pMac->sme);
12548 return CDF_STATUS_E_FAILURE;
12549 }
12550
12551 pSession = pe_find_session_by_bssid(pMac,
12552 pCsrSession->connectedProfile.bssid.bytes,
12553 &peSessionId);
12554
12555 if (pSession == NULL) {
12556 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
12557 FL(" Session lookup fails for BSSID"));
12558 sme_release_global_lock(&pMac->sme);
12559 return CDF_STATUS_E_FAILURE;
12560 }
12561
12562 if (!pSession->QosMapSet.present) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -080012563 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012564 FL("QOS Mapping IE not present"));
12565 sme_release_global_lock(&pMac->sme);
12566 return CDF_STATUS_E_FAILURE;
12567 }
12568 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
12569 for (j = pSession->QosMapSet.dscp_range[i][0];
12570 j <= pSession->QosMapSet.dscp_range[i][1];
12571 j++) {
12572 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
12573 && (pSession->QosMapSet.dscp_range[i][1] ==
12574 255)) {
12575 dscpmapping[j] = 0;
12576 CDF_TRACE(CDF_MODULE_ID_SME,
12577 CDF_TRACE_LEVEL_ERROR,
12578 FL("User Priority %d isn't used"), i);
12579 break;
12580 } else {
12581 dscpmapping[j] = i;
12582 }
12583 }
12584 }
12585 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
12586 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
12587 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
12588 pSession->QosMapSet.dscp_exceptions[i][1];
12589
12590 sme_release_global_lock(&pMac->sme);
12591 return status;
12592}
12593
12594/* ---------------------------------------------------------------------------
12595 \fn sme_abort_roam_scan
12596 \brief API to abort current roam scan cycle by roam scan offload module.
12597 \param hHal - The handle returned by mac_open.
12598 \param sessionId - Session Identifier
12599 \return CDF_STATUS
12600 ---------------------------------------------------------------------------*/
12601
12602CDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
12603{
12604 CDF_STATUS status = CDF_STATUS_SUCCESS;
12605 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12606
12607 sms_log(pMac, LOGW, "entering function %s", __func__);
12608 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
12609 /* acquire the lock for the sme object */
12610 status = sme_acquire_global_lock(&pMac->sme);
12611 if (CDF_IS_STATUS_SUCCESS(status)) {
12612 csr_roam_offload_scan(pMac, sessionId,
12613 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
12614 REASON_ROAM_ABORT_ROAM_SCAN);
12615 /* release the lock for the sme object */
12616 sme_release_global_lock(&pMac->sme);
12617 }
12618 }
12619
12620 return status;
12621}
12622
12623#ifdef FEATURE_WLAN_EXTSCAN
12624/**
12625 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
12626 * @hHal: HAL context
12627 * @wifiBand: RF band information
12628 * @aValidChannels: output array to store channel info
12629 * @pNumChannels: output number of channels
12630 *
12631 * SME API to fetch all valid channels filtered by band
12632 *
12633 * Return: CDF_STATUS
12634 */
12635CDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
12636 uint8_t wifiBand,
12637 uint32_t *aValidChannels,
12638 uint8_t *pNumChannels)
12639{
12640 CDF_STATUS status = CDF_STATUS_SUCCESS;
12641 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
12642 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12643 uint8_t numChannels = 0;
12644 uint8_t i = 0;
12645 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12646
12647 if (!aValidChannels || !pNumChannels) {
12648 sms_log(pMac, CDF_TRACE_LEVEL_ERROR,
12649 FL("Output channel list/NumChannels is NULL"));
12650 return CDF_STATUS_E_INVAL;
12651 }
12652
12653 if ((wifiBand < WIFI_BAND_UNSPECIFIED) || (wifiBand >= WIFI_BAND_MAX)) {
12654 sms_log(pMac, CDF_TRACE_LEVEL_ERROR,
12655 FL("Invalid wifiBand (%d)"), wifiBand);
12656 return CDF_STATUS_E_INVAL;
12657 }
12658
12659 status = sme_get_cfg_valid_channels(hHal, &chanList[0],
12660 &totValidChannels);
12661 if (!CDF_IS_STATUS_SUCCESS(status)) {
12662 sms_log(pMac, CDF_TRACE_LEVEL_ERROR,
12663 FL("Fail to get valid channel list (err=%d)"), status);
12664 return status;
12665 }
12666
12667 switch (wifiBand) {
12668 case WIFI_BAND_UNSPECIFIED:
12669 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12670 FL("Unspec Band, return all (%d) valid channels"),
12671 totValidChannels);
12672 numChannels = totValidChannels;
12673 for (i = 0; i < totValidChannels; i++) {
12674 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
12675 }
12676 break;
12677
12678 case WIFI_BAND_BG:
12679 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12680 FL("WIFI_BAND_BG (2.4 GHz)"));
12681 for (i = 0; i < totValidChannels; i++) {
12682 if (CDS_IS_CHANNEL_24GHZ(chanList[i])) {
12683 aValidChannels[numChannels++] =
12684 cds_chan_to_freq(chanList[i]);
12685 }
12686 }
12687 break;
12688
12689 case WIFI_BAND_A:
12690 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12691 FL("WIFI_BAND_A (5 GHz without DFS)"));
12692 for (i = 0; i < totValidChannels; i++) {
12693 if (CDS_IS_CHANNEL_5GHZ(chanList[i]) &&
12694 !CDS_IS_DFS_CH(chanList[i])) {
12695 aValidChannels[numChannels++] =
12696 cds_chan_to_freq(chanList[i]);
12697 }
12698 }
12699 break;
12700
12701 case WIFI_BAND_ABG:
12702 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12703 FL("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)"));
12704 for (i = 0; i < totValidChannels; i++) {
12705 if ((CDS_IS_CHANNEL_24GHZ(chanList[i]) ||
12706 CDS_IS_CHANNEL_5GHZ(chanList[i])) &&
12707 !CDS_IS_DFS_CH(chanList[i])) {
12708 aValidChannels[numChannels++] =
12709 cds_chan_to_freq(chanList[i]);
12710 }
12711 }
12712 break;
12713
12714 case WIFI_BAND_A_DFS_ONLY:
12715 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12716 FL("WIFI_BAND_A_DFS (5 GHz DFS only)"));
12717 for (i = 0; i < totValidChannels; i++) {
12718 if (CDS_IS_CHANNEL_5GHZ(chanList[i]) &&
12719 CDS_IS_DFS_CH(chanList[i])) {
12720 aValidChannels[numChannels++] =
12721 cds_chan_to_freq(chanList[i]);
12722 }
12723 }
12724 break;
12725
12726 case WIFI_BAND_A_WITH_DFS:
12727 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12728 FL("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)"));
12729 for (i = 0; i < totValidChannels; i++) {
12730 if (CDS_IS_CHANNEL_5GHZ(chanList[i])) {
12731 aValidChannels[numChannels++] =
12732 cds_chan_to_freq(chanList[i]);
12733 }
12734 }
12735 break;
12736
12737 case WIFI_BAND_ABG_WITH_DFS:
12738 sms_log(pMac, CDF_TRACE_LEVEL_INFO,
12739 FL("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)"));
12740 for (i = 0; i < totValidChannels; i++) {
12741 if (CDS_IS_CHANNEL_24GHZ(chanList[i]) ||
12742 CDS_IS_CHANNEL_5GHZ(chanList[i])) {
12743 aValidChannels[numChannels++] =
12744 cds_chan_to_freq(chanList[i]);
12745 }
12746 }
12747 break;
12748
12749 default:
12750 sms_log(pMac, CDF_TRACE_LEVEL_ERROR,
12751 FL("Unknown wifiBand (%d))"), wifiBand);
12752 return CDF_STATUS_E_INVAL;
12753 break;
12754 }
12755 *pNumChannels = numChannels;
12756
12757 return status;
12758}
12759
12760/* ---------------------------------------------------------------------------
12761 \fn sme_ext_scan_get_capabilities
12762 \brief SME API to fetch extscan capabilities
12763 \param hHal
12764 \param pReq: extscan capabilities structure
12765 \- return CDF_STATUS
12766 -------------------------------------------------------------------------*/
12767CDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
12768 tSirGetExtScanCapabilitiesReqParams *
12769 pReq)
12770{
12771 CDF_STATUS status = CDF_STATUS_SUCCESS;
12772 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12773 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12774 cds_msg_t cds_message;
12775
12776 status = sme_acquire_global_lock(&pMac->sme);
12777 if (CDF_IS_STATUS_SUCCESS(status)) {
12778 /* Serialize the req through MC thread */
12779 cds_message.bodyptr = pReq;
12780 cds_message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
12781 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12782 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12783 status = CDF_STATUS_E_FAILURE;
12784
12785 sme_release_global_lock(&pMac->sme);
12786 }
12787 return status;
12788}
12789
12790/* ---------------------------------------------------------------------------
12791 \fn sme_ext_scan_start
12792 \brief SME API to issue extscan start
12793 \param hHal
12794 \param pStartCmd: extscan start structure
12795 \- return CDF_STATUS
12796 -------------------------------------------------------------------------*/
12797CDF_STATUS sme_ext_scan_start(tHalHandle hHal,
12798 tSirWifiScanCmdReqParams *pStartCmd)
12799{
12800 CDF_STATUS status = CDF_STATUS_SUCCESS;
12801 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12802 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12803 cds_msg_t cds_message;
12804
12805 status = sme_acquire_global_lock(&pMac->sme);
12806 if (CDF_IS_STATUS_SUCCESS(status)) {
12807 /* Serialize the req through MC thread */
12808 cds_message.bodyptr = pStartCmd;
12809 cds_message.type = WMA_EXTSCAN_START_REQ;
12810 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12811 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12812 status = CDF_STATUS_E_FAILURE;
12813
12814 sme_release_global_lock(&pMac->sme);
12815 }
12816 return status;
12817}
12818
12819/* ---------------------------------------------------------------------------
12820 \fn sme_ext_scan_stop
12821 \brief SME API to issue extscan stop
12822 \param hHal
12823 \param pStopReq: extscan stop structure
12824 \- return CDF_STATUS
12825 -------------------------------------------------------------------------*/
12826CDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams *pStopReq)
12827{
12828 CDF_STATUS status = CDF_STATUS_SUCCESS;
12829 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12830 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12831 cds_msg_t cds_message;
12832
12833 status = sme_acquire_global_lock(&pMac->sme);
12834 if (CDF_IS_STATUS_SUCCESS(status)) {
12835 /* Serialize the req through MC thread */
12836 cds_message.bodyptr = pStopReq;
12837 cds_message.type = WMA_EXTSCAN_STOP_REQ;
12838 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12839 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12840 status = CDF_STATUS_E_FAILURE;
12841 sme_release_global_lock(&pMac->sme);
12842 }
12843 return status;
12844}
12845
12846/* ---------------------------------------------------------------------------
12847 \fn sme_set_bss_hotlist
12848 \brief SME API to set BSSID hotlist
12849 \param hHal
12850 \param pSetHotListReq: extscan set hotlist structure
12851 \- return CDF_STATUS
12852 -------------------------------------------------------------------------*/
12853CDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
12854 tSirExtScanSetBssidHotListReqParams *
12855 pSetHotListReq)
12856{
12857 CDF_STATUS status = CDF_STATUS_SUCCESS;
12858 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12859 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12860 cds_msg_t cds_message;
12861
12862 status = sme_acquire_global_lock(&pMac->sme);
12863 if (CDF_IS_STATUS_SUCCESS(status)) {
12864 /* Serialize the req through MC thread */
12865 cds_message.bodyptr = pSetHotListReq;
12866 cds_message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
12867 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12868 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12869 status = CDF_STATUS_E_FAILURE;
12870
12871 sme_release_global_lock(&pMac->sme);
12872 }
12873 return status;
12874}
12875
12876/* ---------------------------------------------------------------------------
12877 \fn sme_reset_bss_hotlist
12878 \brief SME API to reset BSSID hotlist
12879 \param hHal
12880 \param pSetHotListReq: extscan set hotlist structure
12881 \- return CDF_STATUS
12882 -------------------------------------------------------------------------*/
12883CDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
12884 tSirExtScanResetBssidHotlistReqParams *
12885 pResetReq)
12886{
12887 CDF_STATUS status = CDF_STATUS_SUCCESS;
12888 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12889 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12890 cds_msg_t cds_message;
12891
12892 status = sme_acquire_global_lock(&pMac->sme);
12893 if (CDF_IS_STATUS_SUCCESS(status)) {
12894 /* Serialize the req through MC thread */
12895 cds_message.bodyptr = pResetReq;
12896 cds_message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
12897 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12898 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12899 status = CDF_STATUS_E_FAILURE;
12900
12901 sme_release_global_lock(&pMac->sme);
12902 }
12903 return status;
12904}
12905
12906/* ---------------------------------------------------------------------------
12907 \fn sme_set_significant_change
12908 \brief SME API to set significant change
12909 \param hHal
12910 \param pSetSignificantChangeReq: extscan set significant change structure
12911 \- return CDF_STATUS
12912 -------------------------------------------------------------------------*/
12913CDF_STATUS sme_set_significant_change(tHalHandle hHal,
12914 tSirExtScanSetSigChangeReqParams *
12915 pSetSignificantChangeReq)
12916{
12917 CDF_STATUS status = CDF_STATUS_SUCCESS;
12918 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12919 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12920 cds_msg_t cds_message;
12921
12922 status = sme_acquire_global_lock(&pMac->sme);
12923 if (CDF_IS_STATUS_SUCCESS(status)) {
12924 /* Serialize the req through MC thread */
12925 cds_message.bodyptr = pSetSignificantChangeReq;
12926 cds_message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
12927 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12928 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12929 status = CDF_STATUS_E_FAILURE;
12930
12931 sme_release_global_lock(&pMac->sme);
12932 }
12933 return status;
12934}
12935
12936/* ---------------------------------------------------------------------------
12937 \fn sme_reset_significant_change
12938 \brief SME API to reset significant change
12939 \param hHal
12940 \param pResetReq: extscan reset significant change structure
12941 \- return CDF_STATUS
12942 -------------------------------------------------------------------------*/
12943CDF_STATUS sme_reset_significant_change(tHalHandle hHal,
12944 tSirExtScanResetSignificantChangeReqParams
12945 *pResetReq)
12946{
12947 CDF_STATUS status = CDF_STATUS_SUCCESS;
12948 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12949 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12950 cds_msg_t cds_message;
12951
12952 status = sme_acquire_global_lock(&pMac->sme);
12953 if (CDF_IS_STATUS_SUCCESS(status)) {
12954 /* Serialize the req through MC thread */
12955 cds_message.bodyptr = pResetReq;
12956 cds_message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
12957 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12958 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12959 status = CDF_STATUS_E_FAILURE;
12960
12961 sme_release_global_lock(&pMac->sme);
12962 }
12963 return status;
12964}
12965
12966/* ---------------------------------------------------------------------------
12967 \fn sme_get_cached_results
12968 \brief SME API to get cached results
12969 \param hHal
12970 \param pCachedResultsReq: extscan get cached results structure
12971 \- return CDF_STATUS
12972 -------------------------------------------------------------------------*/
12973CDF_STATUS sme_get_cached_results(tHalHandle hHal,
12974 tSirExtScanGetCachedResultsReqParams *
12975 pCachedResultsReq)
12976{
12977 CDF_STATUS status = CDF_STATUS_SUCCESS;
12978 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
12979 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12980 cds_msg_t cds_message;
12981
12982 status = sme_acquire_global_lock(&pMac->sme);
12983 if (CDF_IS_STATUS_SUCCESS(status)) {
12984 /* Serialize the req through MC thread */
12985 cds_message.bodyptr = pCachedResultsReq;
12986 cds_message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
12987 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
12988 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
12989 status = CDF_STATUS_E_FAILURE;
12990
12991 sme_release_global_lock(&pMac->sme);
12992 }
12993 return status;
12994}
12995
12996/**
12997 * sme_set_epno_list() - set epno network list
12998 * @hHal: global hal handle
12999 * @input: request message
13000 *
13001 * This function constructs the cds message and fill in message type,
13002 * bodyptr with %input and posts it to WDA queue.
13003 *
13004 * Return: eHalStatus enumeration
13005 */
13006CDF_STATUS sme_set_epno_list(tHalHandle hal,
13007 struct wifi_epno_params *input)
13008{
13009 CDF_STATUS status = CDF_STATUS_SUCCESS;
13010 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13011 cds_msg_t cds_message;
13012 struct wifi_epno_params *req_msg;
13013 int len, i;
13014
13015 sms_log(mac, LOG1, FL("enter"));
13016 len = sizeof(*req_msg) +
13017 (input->num_networks * sizeof(struct wifi_epno_network));
13018 req_msg = cdf_mem_malloc(len);
13019 if (!req_msg) {
13020 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
13021 return CDF_STATUS_E_NOMEM;
13022 }
13023
13024 cdf_mem_zero(req_msg, len);
13025 req_msg->num_networks = input->num_networks;
13026 req_msg->request_id = input->request_id;
13027 req_msg->session_id = input->session_id;
13028 for (i = 0; i < req_msg->num_networks; i++) {
13029 req_msg->networks[i].rssi_threshold =
13030 input->networks[i].rssi_threshold;
13031 req_msg->networks[i].flags = input->networks[i].flags;
13032 req_msg->networks[i].auth_bit_field =
13033 input->networks[i].auth_bit_field;
13034 req_msg->networks[i].ssid.length =
13035 input->networks[i].ssid.length;
13036 cdf_mem_copy(req_msg->networks[i].ssid.ssId,
13037 input->networks[i].ssid.ssId,
13038 req_msg->networks[i].ssid.length);
13039 }
13040
13041 status = sme_acquire_global_lock(&mac->sme);
13042 if (CDF_IS_STATUS_SUCCESS(status)) {
13043 sms_log(mac, LOGE,
13044 FL("sme_acquire_global_lock failed!(status=%d)"),
13045 status);
13046 cdf_mem_free(req_msg);
13047 return status;
13048 }
13049
13050 /* Serialize the req through MC thread */
13051 cds_message.bodyptr = req_msg;
13052 cds_message.type = WMA_SET_EPNO_LIST_REQ;
13053 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13054 if (!CDF_IS_STATUS_SUCCESS(status)) {
13055 sms_log(mac, LOGE,
13056 FL("cds_mq_post_message failed!(err=%d)"),
13057 status);
13058 cdf_mem_free(req_msg);
13059 status = CDF_STATUS_E_FAILURE;
13060 }
13061 sme_release_global_lock(&mac->sme);
13062 return status;
13063}
13064
13065/**
13066 * sme_set_passpoint_list() - set passpoint network list
13067 * @hal: global hal handle
13068 * @input: request message
13069 *
13070 * This function constructs the cds message and fill in message type,
13071 * bodyptr with @input and posts it to WDA queue.
13072 *
13073 * Return: eHalStatus enumeration
13074 */
13075CDF_STATUS sme_set_passpoint_list(tHalHandle hal,
13076 struct wifi_passpoint_req *input)
13077{
13078 CDF_STATUS status = CDF_STATUS_SUCCESS;
13079 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13080 cds_msg_t cds_message;
13081 struct wifi_passpoint_req *req_msg;
13082 int len, i;
13083
13084 sms_log(mac, LOG1, FL("enter"));
13085 len = sizeof(*req_msg) +
13086 (input->num_networks * sizeof(struct wifi_passpoint_network));
13087 req_msg = cdf_mem_malloc(len);
13088 if (!req_msg) {
13089 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
13090 return CDF_STATUS_E_NOMEM;
13091 }
13092
13093 cdf_mem_zero(req_msg, len);
13094 req_msg->num_networks = input->num_networks;
13095 req_msg->request_id = input->request_id;
13096 req_msg->session_id = input->session_id;
13097 for (i = 0; i < req_msg->num_networks; i++) {
13098 req_msg->networks[i].id =
13099 input->networks[i].id;
13100 cdf_mem_copy(req_msg->networks[i].realm,
13101 input->networks[i].realm,
13102 strlen(input->networks[i].realm) + 1);
13103 cdf_mem_copy(req_msg->networks[i].plmn,
13104 input->networks[i].plmn,
13105 SIR_PASSPOINT_PLMN_LEN);
13106 cdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
13107 input->networks[i].roaming_consortium_ids,
13108 sizeof(req_msg->networks[i].roaming_consortium_ids));
13109 }
13110
13111 status = sme_acquire_global_lock(&mac->sme);
13112 if (CDF_IS_STATUS_SUCCESS(status)) {
13113 sms_log(mac, LOGE,
13114 FL("sme_acquire_global_lock failed!(status=%d)"),
13115 status);
13116 cdf_mem_free(req_msg);
13117 return status;
13118 }
13119
13120 /* Serialize the req through MC thread */
13121 cds_message.bodyptr = req_msg;
13122 cds_message.type = WMA_SET_PASSPOINT_LIST_REQ;
13123 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13124 if (!CDF_IS_STATUS_SUCCESS(status)) {
13125 sms_log(mac, LOGE,
13126 FL("cds_mq_post_message failed!(err=%d)"),
13127 status);
13128 cdf_mem_free(req_msg);
13129 status = CDF_STATUS_E_FAILURE;
13130 }
13131 sme_release_global_lock(&mac->sme);
13132 return status;
13133}
13134
13135/**
13136 * sme_reset_passpoint_list() - reset passpoint network list
13137 * @hHal: global hal handle
13138 * @input: request message
13139 *
13140 * Return: eHalStatus enumeration
13141 */
13142CDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
13143 struct wifi_passpoint_req *input)
13144{
13145 CDF_STATUS status = CDF_STATUS_SUCCESS;
13146 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13147 cds_msg_t cds_message;
13148 struct wifi_passpoint_req *req_msg;
13149
13150 sms_log(mac, LOG1, FL("enter"));
13151 req_msg = cdf_mem_malloc(sizeof(*req_msg));
13152 if (!req_msg) {
13153 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
13154 return CDF_STATUS_E_NOMEM;
13155 }
13156
13157 cdf_mem_zero(req_msg, sizeof(*req_msg));
13158 req_msg->request_id = input->request_id;
13159 req_msg->session_id = input->session_id;
13160
13161 status = sme_acquire_global_lock(&mac->sme);
13162 if (CDF_IS_STATUS_SUCCESS(status)) {
13163 sms_log(mac, LOGE,
13164 FL("sme_acquire_global_lock failed!(status=%d)"),
13165 status);
13166 cdf_mem_free(req_msg);
13167 return status;
13168 }
13169
13170 /* Serialize the req through MC thread */
13171 cds_message.bodyptr = req_msg;
13172 cds_message.type = WMA_RESET_PASSPOINT_LIST_REQ;
13173 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13174 if (!CDF_IS_STATUS_SUCCESS(status)) {
13175 sms_log(mac, LOGE,
13176 FL("cds_mq_post_message failed!(err=%d)"),
13177 status);
13178 cdf_mem_free(req_msg);
13179 status = CDF_STATUS_E_FAILURE;
13180 }
13181 sme_release_global_lock(&mac->sme);
13182 return status;
13183}
13184
13185/**
13186 * sme_set_ssid_hotlist() - Set the SSID hotlist
13187 * @hal: SME handle
13188 * @request: set ssid hotlist request
13189 *
13190 * Return: eHalStatus
13191 */
13192CDF_STATUS
13193sme_set_ssid_hotlist(tHalHandle hal,
13194 struct sir_set_ssid_hotlist_request *request)
13195{
13196 CDF_STATUS status = CDF_STATUS_SUCCESS;
13197 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13198 cds_msg_t cds_message;
13199 struct sir_set_ssid_hotlist_request *set_req;
13200
13201 set_req = cdf_mem_malloc(sizeof(*set_req));
13202 if (!set_req) {
13203 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
13204 return CDF_STATUS_E_FAILURE;
13205 }
13206
13207 *set_req = *request;
13208 status = sme_acquire_global_lock(&mac->sme);
13209 if (CDF_STATUS_SUCCESS == status) {
13210 /* Serialize the req through MC thread */
13211 cds_message.bodyptr = set_req;
13212 cds_message.type = WMA_EXTSCAN_SET_SSID_HOTLIST_REQ;
13213 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13214 sme_release_global_lock(&mac->sme);
13215 if (!CDF_IS_STATUS_SUCCESS(status)) {
13216 cdf_mem_free(set_req);
13217 status = CDF_STATUS_E_FAILURE;
13218 }
13219 } else {
13220 sms_log(mac, LOGE,
13221 FL("sme_acquire_global_lock failed!(status=%d)"),
13222 status);
13223 cdf_mem_free(set_req);
13224 status = CDF_STATUS_E_FAILURE;
13225 }
13226 return status;
13227}
13228
13229CDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
13230 void (*pExtScanIndCb)(void *,
13231 const uint16_t,
13232 void *))
13233{
13234 CDF_STATUS status = CDF_STATUS_SUCCESS;
13235 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13236
13237 status = sme_acquire_global_lock(&pMac->sme);
13238 if (CDF_IS_STATUS_SUCCESS(status)) {
13239 pMac->sme.pExtScanIndCb = pExtScanIndCb;
13240 sme_release_global_lock(&pMac->sme);
13241 }
13242 return status;
13243}
13244
13245#else
13246CDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
13247 void (*pExtScanIndCb)(void *, const uint16_t, void *))
13248{
13249 return CDF_STATUS_SUCCESS;
13250}
13251
13252#endif /* FEATURE_WLAN_EXTSCAN */
13253
13254#ifdef WLAN_FEATURE_LINK_LAYER_STATS
13255
13256/* ---------------------------------------------------------------------------
13257 \fn sme_ll_stats_clear_req
13258 \brief SME API to clear Link Layer Statistics
13259 \param hHal
13260 \param pclearStatsReq: Link Layer clear stats request params structure
13261 \- return CDF_STATUS
13262 -------------------------------------------------------------------------*/
13263CDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
13264 tSirLLStatsClearReq *pclearStatsReq)
13265{
13266 CDF_STATUS status = CDF_STATUS_SUCCESS;
13267 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13268 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13269 cds_msg_t cds_message;
13270 tSirLLStatsClearReq *clear_stats_req;
13271
13272 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13273 "staId = %u", pclearStatsReq->staId);
13274 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13275 "statsClearReqMask = 0x%X",
13276 pclearStatsReq->statsClearReqMask);
13277 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13278 "stopReq = %u", pclearStatsReq->stopReq);
13279
13280 clear_stats_req = cdf_mem_malloc(sizeof(*clear_stats_req));
13281
13282 if (!clear_stats_req) {
13283 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13284 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
13285 __func__);
13286 return CDF_STATUS_E_NOMEM;
13287 }
13288
13289 *clear_stats_req = *pclearStatsReq;
13290
13291 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
13292 /* Serialize the req through MC thread */
13293 cds_message.bodyptr = clear_stats_req;
13294 cds_message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
13295 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13296 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
13297 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13298 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
13299 __func__);
13300 cdf_mem_free(clear_stats_req);
13301 status = CDF_STATUS_E_FAILURE;
13302 }
13303 sme_release_global_lock(&pMac->sme);
13304 } else {
13305 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR, "%s: "
13306 "sme_acquire_global_lock error", __func__);
13307 cdf_mem_free(clear_stats_req);
13308 status = CDF_STATUS_E_FAILURE;
13309 }
13310
13311 return status;
13312}
13313
13314/* ---------------------------------------------------------------------------
13315 \fn sme_ll_stats_set_req
13316 \brief SME API to set the Link Layer Statistics
13317 \param hHal
13318 \param psetStatsReq: Link Layer set stats request params structure
13319 \- return CDF_STATUS
13320 -------------------------------------------------------------------------*/
13321CDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq *psetStatsReq)
13322{
13323 CDF_STATUS status = CDF_STATUS_SUCCESS;
13324 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13325 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13326 cds_msg_t cds_message;
13327 tSirLLStatsSetReq *set_stats_req;
13328
13329 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13330 "%s: MPDU Size = %u", __func__,
13331 psetStatsReq->mpduSizeThreshold);
13332 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13333 " Aggressive Stats Collections = %u",
13334 psetStatsReq->aggressiveStatisticsGathering);
13335
13336 set_stats_req = cdf_mem_malloc(sizeof(*set_stats_req));
13337
13338 if (!set_stats_req) {
13339 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13340 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
13341 __func__);
13342 return CDF_STATUS_E_NOMEM;
13343 }
13344
13345 *set_stats_req = *psetStatsReq;
13346
13347 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
13348 /* Serialize the req through MC thread */
13349 cds_message.bodyptr = set_stats_req;
13350 cds_message.type = WMA_LINK_LAYER_STATS_SET_REQ;
13351 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13352 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
13353 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13354 "%s: not able to post WMA_LL_STATS_SET_REQ",
13355 __func__);
13356 cdf_mem_free(set_stats_req);
13357 status = CDF_STATUS_E_FAILURE;
13358 }
13359 sme_release_global_lock(&pMac->sme);
13360 } else {
13361 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR, "%s: "
13362 "sme_acquire_global_lock error", __func__);
13363 cdf_mem_free(set_stats_req);
13364 status = CDF_STATUS_E_FAILURE;
13365 }
13366
13367 return status;
13368}
13369
13370/* ---------------------------------------------------------------------------
13371 \fn sme_ll_stats_get_req
13372 \brief SME API to get the Link Layer Statistics
13373 \param hHal
13374 \param pgetStatsReq: Link Layer get stats request params structure
13375 \- return CDF_STATUS
13376 -------------------------------------------------------------------------*/
13377CDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq *pgetStatsReq)
13378{
13379 CDF_STATUS status = CDF_STATUS_SUCCESS;
13380 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13381 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13382 cds_msg_t cds_message;
13383 tSirLLStatsGetReq *get_stats_req;
13384
13385 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13386 "reqId = %u", pgetStatsReq->reqId);
13387 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13388 "staId = %u", pgetStatsReq->staId);
13389 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13390 "Stats Type = %u", pgetStatsReq->paramIdMask);
13391
13392 get_stats_req = cdf_mem_malloc(sizeof(*get_stats_req));
13393
13394 if (!get_stats_req) {
13395 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13396 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
13397 __func__);
13398 return CDF_STATUS_E_NOMEM;
13399 }
13400
13401 *get_stats_req = *pgetStatsReq;
13402
13403 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
13404 /* Serialize the req through MC thread */
13405 cds_message.bodyptr = get_stats_req;
13406 cds_message.type = WMA_LINK_LAYER_STATS_GET_REQ;
13407 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13408 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
13409 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13410 "%s: not able to post WMA_LL_STATS_GET_REQ",
13411 __func__);
13412
13413 cdf_mem_free(get_stats_req);
13414 status = CDF_STATUS_E_FAILURE;
13415
13416 }
13417 sme_release_global_lock(&pMac->sme);
13418 } else {
13419 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR, "%s: "
13420 "sme_acquire_global_lock error", __func__);
13421 cdf_mem_free(get_stats_req);
13422 status = CDF_STATUS_E_FAILURE;
13423 }
13424
13425 return status;
13426}
13427
13428/* ---------------------------------------------------------------------------
13429 \fn sme_set_link_layer_stats_ind_cb
13430 \brief SME API to trigger the stats are available after get request
13431 \param hHal
13432 \param callback_routine - HDD callback which needs to be invoked after
13433 getting status notification from FW
13434 \- return CDF_STATUS
13435 -------------------------------------------------------------------------*/
13436CDF_STATUS sme_set_link_layer_stats_ind_cb
13437 (tHalHandle hHal,
13438 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp)
13439 ) {
13440 CDF_STATUS status = CDF_STATUS_SUCCESS;
13441 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13442
13443 status = sme_acquire_global_lock(&pMac->sme);
13444 if (CDF_IS_STATUS_SUCCESS(status)) {
13445 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
13446 sme_release_global_lock(&pMac->sme);
13447 } else {
13448 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR, "%s: "
13449 "sme_acquire_global_lock error", __func__);
13450 }
13451
13452 return status;
13453}
13454
13455#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
13456
13457/**
13458 * sme_fw_mem_dump_register_cb() - Register fw memory dump callback
13459 *
13460 * @hal - MAC global handle
13461 * @callback_routine - callback routine from HDD
13462 *
13463 * This API is invoked by HDD to register its callback in SME
13464 *
13465 * Return: CDF_STATUS
13466 */
13467#ifdef WLAN_FEATURE_MEMDUMP
13468CDF_STATUS sme_fw_mem_dump_register_cb(tHalHandle hal,
13469 void (*callback_routine)(void *cb_context,
13470 struct fw_dump_rsp *rsp))
13471{
13472 CDF_STATUS status = CDF_STATUS_SUCCESS;
13473 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
13474
13475 status = sme_acquire_global_lock(&pmac->sme);
13476 if (CDF_STATUS_SUCCESS == status) {
13477 pmac->sme.fw_dump_callback = callback_routine;
13478 sme_release_global_lock(&pmac->sme);
13479 } else {
13480 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13481 FL("sme_acquire_global_lock error"));
13482 }
13483
13484 return status;
13485}
13486#else
13487CDF_STATUS sme_fw_mem_dump_register_cb(tHalHandle hal,
13488 void (*callback_routine)(void *cb_context,
13489 struct fw_dump_rsp *rsp))
13490{
13491 return CDF_STATUS_SUCCESS;
13492}
13493#endif /* WLAN_FEATURE_MEMDUMP */
13494
13495/**
13496 * sme_fw_mem_dump_unregister_cb() - Unregister fw memory dump callback
13497 *
13498 * @hHal - MAC global handle
13499 *
13500 * This API is invoked by HDD to unregister its callback in SME
13501 *
13502 * Return: CDF_STATUS
13503 */
13504#ifdef WLAN_FEATURE_MEMDUMP
13505CDF_STATUS sme_fw_mem_dump_unregister_cb(tHalHandle hal)
13506{
13507 CDF_STATUS status;
13508 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
13509
13510 status = sme_acquire_global_lock(&pmac->sme);
13511 if (CDF_STATUS_SUCCESS == status) {
13512 pmac->sme.fw_dump_callback = NULL;
13513 sme_release_global_lock(&pmac->sme);
13514 } else {
13515 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13516 FL("sme_acquire_global_lock error"));
13517 }
13518
13519 return status;
13520}
13521#else
13522CDF_STATUS sme_fw_mem_dump_unregister_cb(tHalHandle hal)
13523{
13524 return CDF_STATUS_SUCCESS;
13525}
13526#endif /* WLAN_FEATURE_MEMDUMP */
13527
13528#ifdef WLAN_FEATURE_ROAM_OFFLOAD
13529/*--------------------------------------------------------------------------
13530 \brief sme_update_roam_offload_enabled() - enable/disable roam offload feaure
13531 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
13532 \param hHal - The handle returned by mac_open.
13533 \param nRoamOffloadEnabled - The bool to update with
13534 \return CDF_STATUS_SUCCESS - SME update config successfully.
13535 Other status means SME is failed to update.
13536 \sa
13537 --------------------------------------------------------------------------*/
13538
13539CDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
13540 bool nRoamOffloadEnabled)
13541{
13542 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13543 CDF_STATUS status = CDF_STATUS_SUCCESS;
13544
13545 status = sme_acquire_global_lock(&pMac->sme);
13546 if (CDF_IS_STATUS_SUCCESS(status)) {
13547 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13548 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
13549 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
13550 nRoamOffloadEnabled);
13551 pMac->roam.configParam.isRoamOffloadEnabled =
13552 nRoamOffloadEnabled;
13553 sme_release_global_lock(&pMac->sme);
13554 }
13555
13556 return status;
13557}
13558
13559/*--------------------------------------------------------------------------
13560 \brief sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt
13561 offload
13562 This is a synchronous call
13563 \param hHal - The handle returned by mac_open.
13564 \param sessionId - Session Identifier
13565 \param nRoamKeyMgmtOffloadEnabled - 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_key_mgmt_offload_enabled(tHalHandle hHal,
13572 uint8_t sessionId,
13573 bool nRoamKeyMgmtOffloadEnabled)
13574{
13575 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13576 CDF_STATUS status = CDF_STATUS_SUCCESS;
13577
13578 status = sme_acquire_global_lock(&pMac->sme);
13579 if (CDF_IS_STATUS_SUCCESS(status)) {
13580 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
13581 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
13582 "%s: LFR3: KeyMgmtOffloadEnabled changed to %d",
13583 __func__, nRoamKeyMgmtOffloadEnabled);
13584 status = csr_roam_set_key_mgmt_offload(pMac,
13585 sessionId,
13586 nRoamKeyMgmtOffloadEnabled);
13587 } else {
13588 status = CDF_STATUS_E_INVAL;
13589 }
13590 sme_release_global_lock(&pMac->sme);
13591 }
13592
13593 return status;
13594}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080013595#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013596
13597/* ---------------------------------------------------------------------------
13598 \fn sme_get_temperature
13599 \brief SME API to get the pdev temperature
13600 \param hHal
13601 \param temperature context
13602 \param pCallbackfn: callback fn with response (temperature)
13603 \- return CDF_STATUS
13604 -------------------------------------------------------------------------*/
13605CDF_STATUS sme_get_temperature(tHalHandle hHal,
13606 void *tempContext,
13607 void (*pCallbackfn)(int temperature,
13608 void *pContext))
13609{
13610 CDF_STATUS status = CDF_STATUS_SUCCESS;
13611 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13612 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13613 cds_msg_t cds_message;
13614
13615 status = sme_acquire_global_lock(&pMac->sme);
13616 if (CDF_STATUS_SUCCESS == status) {
13617 if ((NULL == pCallbackfn) &&
13618 (NULL == pMac->sme.pGetTemperatureCb)) {
13619 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13620 FL
13621 ("Indication Call back did not registered"));
13622 sme_release_global_lock(&pMac->sme);
13623 return CDF_STATUS_E_FAILURE;
13624 } else if (NULL != pCallbackfn) {
13625 pMac->sme.pTemperatureCbContext = tempContext;
13626 pMac->sme.pGetTemperatureCb = pCallbackfn;
13627 }
13628 /* serialize the req through MC thread */
13629 cds_message.bodyptr = NULL;
13630 cds_message.type = WMA_GET_TEMPERATURE_REQ;
13631 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13632 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
13633 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13634 FL("Post Get Temperature msg fail"));
13635 status = CDF_STATUS_E_FAILURE;
13636 }
13637 sme_release_global_lock(&pMac->sme);
13638 }
13639 return status;
13640}
13641
13642/* ---------------------------------------------------------------------------
13643 \fn sme_set_scanning_mac_oui
13644 \brief SME API to set scanning mac oui
13645 \param hHal
13646 \param pScanMacOui: Scanning Mac Oui (input 3 bytes)
13647 \- return CDF_STATUS
13648 -------------------------------------------------------------------------*/
13649CDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui *pScanMacOui)
13650{
13651 CDF_STATUS status = CDF_STATUS_SUCCESS;
13652 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13653 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13654 cds_msg_t cds_message;
13655
13656 status = sme_acquire_global_lock(&pMac->sme);
13657 if (CDF_STATUS_SUCCESS == status) {
13658 /* Serialize the req through MC thread */
13659 cds_message.bodyptr = pScanMacOui;
13660 cds_message.type = WMA_SET_SCAN_MAC_OUI_REQ;
13661 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13662 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
13663 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13664 FL("Msg post Set Scan Mac OUI failed"));
13665 status = CDF_STATUS_E_FAILURE;
13666 }
13667 sme_release_global_lock(&pMac->sme);
13668 }
13669 return status;
13670}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013671
13672#ifdef DHCP_SERVER_OFFLOAD
13673/* ---------------------------------------------------------------------------
13674 \fn sme_set_dhcp_srv_offload
13675 \brief SME API to set DHCP server offload info
13676 \param hHal
13677 \param pDhcpSrvInfo : DHCP server offload info struct
13678 \- return CDF_STATUS
13679 -------------------------------------------------------------------------*/
13680CDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
13681 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
13682{
13683 cds_msg_t cds_message;
13684 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
13685 CDF_STATUS status = CDF_STATUS_SUCCESS;
13686 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13687
13688 pSmeDhcpSrvInfo = cdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
13689
13690 if (!pSmeDhcpSrvInfo) {
13691 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13692 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
13693 __func__);
13694 return CDF_STATUS_E_NOMEM;
13695 }
13696
13697 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
13698
13699 status = sme_acquire_global_lock(&pMac->sme);
13700 if (CDF_STATUS_SUCCESS == status) {
13701 /* serialize the req through MC thread */
13702 cds_message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
13703 cds_message.bodyptr = pSmeDhcpSrvInfo;
13704
13705 if (!CDF_IS_STATUS_SUCCESS
13706 (cds_mq_post_message(CDF_MODULE_ID_WMA, &cds_message))) {
13707 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13708 "%s: Not able to post WMA_SET_DHCP_SERVER_OFFLOAD_CMD to WMA!",
13709 __func__);
13710 cdf_mem_free(pSmeDhcpSrvInfo);
13711 status = CDF_STATUS_E_FAILURE;
13712 }
13713 sme_release_global_lock(&pMac->sme);
13714 } else {
13715 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13716 "%s: sme_acquire_global_lock error!", __func__);
13717 cdf_mem_free(pSmeDhcpSrvInfo);
13718 }
13719
13720 return status;
13721}
13722#endif /* DHCP_SERVER_OFFLOAD */
13723
13724#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
13725/* ---------------------------------------------------------------------------
13726 \fn sme_set_led_flashing
13727 \brief API to set the Led flashing parameters.
13728 \param hHal - The handle returned by mac_open.
13729 \param x0, x1 - led flashing parameters
13730 \return CDF_STATUS
13731 ---------------------------------------------------------------------------*/
13732CDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
13733 uint32_t x0, uint32_t x1)
13734{
13735 CDF_STATUS status = CDF_STATUS_SUCCESS;
13736 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
13737 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
13738 cds_msg_t cds_message;
13739 tSirLedFlashingReq *ledflashing;
13740
13741 ledflashing = cdf_mem_malloc(sizeof(*ledflashing));
13742 if (!ledflashing) {
13743 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13744 FL
13745 ("Not able to allocate memory for WMA_LED_TIMING_REQ"));
13746 return CDF_STATUS_E_NOMEM;
13747 }
13748
13749 ledflashing->pattern_id = type;
13750 ledflashing->led_x0 = x0;
13751 ledflashing->led_x1 = x1;
13752
13753 status = sme_acquire_global_lock(&pMac->sme);
13754 if (CDF_IS_STATUS_SUCCESS(status)) {
13755 /* Serialize the req through MC thread */
13756 cds_message.bodyptr = ledflashing;
13757 cds_message.type = WMA_LED_FLASHING_REQ;
13758 cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
13759 if (!CDF_IS_STATUS_SUCCESS(cdf_status))
13760 status = CDF_STATUS_E_FAILURE;
13761 sme_release_global_lock(&pMac->sme);
13762 }
13763 return status;
13764}
13765#endif
13766
13767/**
13768 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
13769 * @h_hal: corestack handler
13770 * @dfs_flag: flag indicating dfs channel enable/disable
13771 * Return: CDF_STATUS
13772 */
13773CDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
13774{
13775 CDF_STATUS status = CDF_STATUS_SUCCESS;
13776 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
13777
13778 status = sme_acquire_global_lock(&mac->sme);
13779
13780 if (CDF_STATUS_SUCCESS == status) {
13781
13782 mac->scan.fEnableDFSChnlScan = dfs_flag;
13783
13784 /* update the channel list to the firmware */
13785 status = csr_update_channel_list(mac);
13786
13787 sme_release_global_lock(&mac->sme);
13788 }
13789
13790 return status;
13791}
13792
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053013793#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
13794/**
13795 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
13796 * concurreny rules set to avoid channel interference.
13797 * @hal - Hal context
13798 * @sap_ch - channel to switch
13799 * @sap_phy_mode - phy mode of SAP
13800 * @cc_switch_mode - concurreny switch mode
13801 * @session_id - sme session id.
13802 *
13803 * Return: true if there is no channel interference else return false
13804 */
13805bool sme_validate_sap_channel_switch(tHalHandle hal,
13806 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
13807 uint8_t session_id)
13808{
13809 CDF_STATUS status = CDF_STATUS_E_FAILURE;
13810 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13811 tCsrRoamSession *session = CSR_GET_SESSION(mac, session_id);
13812 uint16_t intf_channel = 0;
13813
13814 if (!session)
13815 return false;
13816
13817 session->ch_switch_in_progress = true;
13818 status = sme_acquire_global_lock(&mac->sme);
13819 if (CDF_IS_STATUS_SUCCESS(status)) {
13820 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
13821 sap_phy_mode,
13822 cc_switch_mode);
13823 sme_release_global_lock(&mac->sme);
13824 } else {
13825 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13826 FL("sme_acquire_global_lock error!"));
13827 session->ch_switch_in_progress = false;
13828 return false;
13829 }
13830
13831 session->ch_switch_in_progress = false;
13832 return (intf_channel == 0) ? true : false;
13833}
13834#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013835
13836/**
13837 * sme_configure_stats_avg_factor() - function to config avg. stats factor
13838 * @hal: hal
13839 * @session_id: session ID
13840 * @stats_avg_factor: average stats factor
13841 *
13842 * This function configures the stats avg factor in firmware
13843 *
13844 * Return: CDF_STATUS
13845 */
13846CDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
13847 uint16_t stats_avg_factor)
13848{
13849 cds_msg_t msg;
13850 CDF_STATUS status = CDF_STATUS_SUCCESS;
13851 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13852 struct sir_stats_avg_factor *stats_factor;
13853
13854 stats_factor = cdf_mem_malloc(sizeof(*stats_factor));
13855
13856 if (!stats_factor) {
13857 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13858 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
13859 __func__);
13860 return CDF_STATUS_E_NOMEM;
13861 }
13862
13863 status = sme_acquire_global_lock(&mac->sme);
13864
13865 if (CDF_STATUS_SUCCESS == status) {
13866
13867 stats_factor->vdev_id = session_id;
13868 stats_factor->stats_avg_factor = stats_avg_factor;
13869
13870 /* serialize the req through MC thread */
13871 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
13872 msg.bodyptr = stats_factor;
13873
13874 if (!CDF_IS_STATUS_SUCCESS(
13875 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
13876 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13877 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
13878 __func__);
13879 cdf_mem_free(stats_factor);
13880 status = CDF_STATUS_E_FAILURE;
13881 }
13882 sme_release_global_lock(&mac->sme);
13883 } else {
13884 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13885 "%s: sme_acquire_global_lock error!",
13886 __func__);
13887 cdf_mem_free(stats_factor);
13888 }
13889
13890 return status;
13891}
13892
13893/**
13894 * sme_configure_guard_time() - function to configure guard time
13895 * @hal: hal
13896 * @session_id: session id
13897 * @guard_time: guard time
13898 *
13899 * This function configures the guard time in firmware
13900 *
13901 * Return: CDF_STATUS
13902 */
13903CDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
13904 uint32_t guard_time)
13905{
13906 cds_msg_t msg;
13907 CDF_STATUS status = CDF_STATUS_SUCCESS;
13908 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13909 struct sir_guard_time_request *g_time;
13910
13911 g_time = cdf_mem_malloc(sizeof(*g_time));
13912
13913 if (!g_time) {
13914 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13915 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
13916 __func__);
13917 return CDF_STATUS_E_NOMEM;
13918 }
13919
13920 status = sme_acquire_global_lock(&mac->sme);
13921
13922 if (CDF_STATUS_SUCCESS == status) {
13923
13924 g_time->vdev_id = session_id;
13925 g_time->guard_time = guard_time;
13926
13927 /* serialize the req through MC thread */
13928 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
13929 msg.bodyptr = g_time;
13930
13931 if (!CDF_IS_STATUS_SUCCESS(
13932 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
13933 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13934 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
13935 __func__);
13936 cdf_mem_free(g_time);
13937 status = CDF_STATUS_E_FAILURE;
13938 }
13939 sme_release_global_lock(&mac->sme);
13940 } else {
13941 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13942 "%s: sme_acquire_global_lock error!",
13943 __func__);
13944 cdf_mem_free(g_time);
13945 }
13946
13947 return status;
13948}
13949
13950/**
13951 * sme_configure_modulated_dtim() - function to configure modulated dtim
13952 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
13953 * @session_id: session ID
13954 * @modulated_dtim: modulated dtim value
13955 *
13956 * This function configures the modulated dtim in firmware
13957 *
13958 * Return: CDF_STATUS
13959 */
13960CDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
13961 uint32_t modulated_dtim)
13962{
13963 cds_msg_t msg;
13964 CDF_STATUS status = CDF_STATUS_SUCCESS;
13965 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
13966 wma_cli_set_cmd_t *iwcmd;
13967
13968 iwcmd = cdf_mem_malloc(sizeof(*iwcmd));
13969 if (NULL == iwcmd) {
13970 CDF_TRACE(CDF_MODULE_ID_SME,
13971 CDF_TRACE_LEVEL_FATAL,
13972 "%s: cdf_mem_alloc failed", __func__);
13973 return CDF_STATUS_E_NOMEM;
13974 }
13975
13976 status = sme_acquire_global_lock(&mac->sme);
13977
13978 if (CDF_STATUS_SUCCESS == status) {
13979
13980 cdf_mem_zero((void *)iwcmd, sizeof(*iwcmd));
13981 iwcmd->param_value = modulated_dtim;
13982 iwcmd->param_vdev_id = session_id;
13983 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
13984 iwcmd->param_vp_dev = GEN_CMD;
13985 msg.type = WMA_CLI_SET_CMD;
13986 msg.reserved = 0;
13987 msg.bodyptr = (void *)iwcmd;
13988
13989 if (!CDF_IS_STATUS_SUCCESS(
13990 cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
13991 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
13992 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
13993 __func__);
13994 cdf_mem_free(iwcmd);
13995 status = CDF_STATUS_E_FAILURE;
13996 }
13997 sme_release_global_lock(&mac->sme);
13998 } else {
13999 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14000 "%s: sme_acquire_global_lock error!",
14001 __func__);
14002 cdf_mem_free(iwcmd);
14003 }
14004
14005 return status;
14006}
14007
14008/*
14009 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
14010 * to either start/stop logging
14011 * @hal: HAL context
14012 * @start_log: Structure containing the wifi start logger params
14013 *
14014 * This function sends the start/stop logging command to WMA
14015 *
14016 * Return: CDF_STATUS_SUCCESS on successful posting
14017 */
14018CDF_STATUS sme_wifi_start_logger(tHalHandle hal,
14019 struct sir_wifi_start_log start_log)
14020{
14021 CDF_STATUS status = CDF_STATUS_SUCCESS;
14022 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14023 cds_msg_t cds_message;
14024 struct sir_wifi_start_log *req_msg;
14025 uint32_t len;
14026
14027 len = sizeof(*req_msg);
14028 req_msg = cdf_mem_malloc(len);
14029 if (!req_msg) {
14030 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
14031 return CDF_STATUS_E_NOMEM;
14032 }
14033
14034 cdf_mem_zero(req_msg, len);
14035
14036 req_msg->verbose_level = start_log.verbose_level;
14037 req_msg->flag = start_log.flag;
14038 req_msg->ring_id = start_log.ring_id;
14039
14040 status = sme_acquire_global_lock(&mac->sme);
14041 if (status != CDF_STATUS_SUCCESS) {
14042 sms_log(mac, LOGE,
14043 FL("sme_acquire_global_lock failed(status=%d)"),
14044 status);
14045 cdf_mem_free(req_msg);
14046 return status;
14047 }
14048
14049 /* Serialize the req through MC thread */
14050 cds_message.bodyptr = req_msg;
14051 cds_message.type = SIR_HAL_START_STOP_LOGGING;
14052 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
14053 if (!CDF_IS_STATUS_SUCCESS(status)) {
14054 sms_log(mac, LOGE,
14055 FL("vos_mq_post_message failed!(err=%d)"),
14056 status);
14057 cdf_mem_free(req_msg);
14058 status = CDF_STATUS_E_FAILURE;
14059 }
14060 sme_release_global_lock(&mac->sme);
14061
14062 return status;
14063}
14064
14065/**
14066 * sme_neighbor_middle_of_roaming() - Function to know if
14067 * STA is in the middle of roaming states
14068 * @hal: Handle returned by macOpen
14069 * @sessionId: sessionId of the STA session
14070 *
14071 * This function is a wrapper to call
14072 * csr_neighbor_middle_of_roaming to know STA is in the
14073 * middle of roaming states
14074 *
14075 * Return: True or False
14076 *
14077 */
14078bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
14079{
14080 return csr_neighbor_middle_of_roaming(PMAC_STRUCT(hHal), sessionId);
14081}
14082
14083/*
14084 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
14085 * @mac: MAC handle
14086 *
14087 * This function is used to send the command that will
14088 * be used to flush the logs in the firmware
14089 *
14090 * Return: eHalStatus
14091 */
14092CDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
14093{
14094 CDF_STATUS status;
14095 cds_msg_t message;
14096
14097 status = sme_acquire_global_lock(&mac->sme);
14098 if (status != CDF_STATUS_SUCCESS) {
14099 sms_log(mac, LOGE,
14100 FL("sme_acquire_global_lock failed!(status=%d)"),
14101 status);
14102 return status;
14103 }
14104
14105 /* Serialize the req through MC thread */
14106 message.bodyptr = NULL;
14107 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
14108 status = cds_mq_post_message(CDS_MQ_ID_WMA, &message);
14109 if (!CDF_IS_STATUS_SUCCESS(status)) {
14110 sms_log(mac, LOGE,
14111 FL("cds_mq_post_message failed!(err=%d)"),
14112 status);
14113 status = CDF_STATUS_E_FAILURE;
14114 }
14115 sme_release_global_lock(&mac->sme);
14116 return status;
14117}
14118
14119/**
14120 * sme_enable_uapsd_for_ac() - enable uapsd for access catagory requerst to WMA
14121 * @cds_ctx: cds context
14122 * @sta_id: station id
14123 * @ac: access catagory
14124 * @tid: tid value
14125 * @pri: user priority
14126 * @srvc_int: service interval
14127 * @sus_int: suspend interval
14128 * @dir: tspec direction
14129 * @psb: PSB value
14130 * @sessionId: session id
14131 * @delay_interval: delay interval
14132 *
14133 * Return: CDF status
14134 */
14135CDF_STATUS sme_enable_uapsd_for_ac(void *cds_ctx, uint8_t sta_id,
14136 sme_ac_enum_type ac, uint8_t tid,
14137 uint8_t pri, uint32_t srvc_int,
14138 uint32_t sus_int,
14139 sme_tspec_dir_type dir,
14140 uint8_t psb, uint32_t sessionId,
14141 uint32_t delay_interval)
14142{
14143 void *wma_handle;
14144 t_wma_trigger_uapsd_params uapsd_params;
14145 enum uapsd_ac access_category;
14146
14147 if (!psb) {
14148 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_DEBUG,
14149 "No need to configure auto trigger:psb is 0");
14150 return CDF_STATUS_SUCCESS;
14151 }
14152
14153 wma_handle = cds_get_context(CDF_MODULE_ID_WMA);
14154 if (!wma_handle) {
14155 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14156 "wma_handle is NULL");
14157 return CDF_STATUS_E_FAILURE;
14158 }
14159
14160 switch (ac) {
14161 case SME_AC_BK:
14162 access_category = UAPSD_BK;
14163 break;
14164 case SME_AC_BE:
14165 access_category = UAPSD_BE;
14166 break;
14167 case SME_AC_VI:
14168 access_category = UAPSD_VI;
14169 break;
14170 case SME_AC_VO:
14171 access_category = UAPSD_VO;
14172 break;
14173 default:
14174 return CDF_STATUS_E_FAILURE;
14175 }
14176
14177 uapsd_params.wmm_ac = access_category;
14178 uapsd_params.user_priority = pri;
14179 uapsd_params.service_interval = srvc_int;
14180 uapsd_params.delay_interval = delay_interval;
14181 uapsd_params.suspend_interval = sus_int;
14182
14183 if (CDF_STATUS_SUCCESS !=
14184 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
14185 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14186 "Failed to Trigger Uapsd params for sessionId %d",
14187 sessionId);
14188 return CDF_STATUS_E_FAILURE;
14189 }
14190 return CDF_STATUS_SUCCESS;
14191}
14192
14193/**
14194 * sme_disable_uapsd_for_ac() - disable uapsed access catagory request to WMA
14195 * @cds_ctx: cds context
14196 * @sta_id: station id
14197 * @ac: access catagory
14198 * @sessionId: session id
14199 *
14200 * Return: CDF status
14201 */
14202CDF_STATUS sme_disable_uapsd_for_ac(void *cds_ctx, uint8_t sta_id,
14203 sme_ac_enum_type ac,
14204 uint32_t sessionId)
14205{
14206 void *wma_handle;
14207 enum uapsd_ac access_category;
14208
14209 switch (ac) {
14210 case SME_AC_BK:
14211 access_category = UAPSD_BK;
14212 break;
14213 case SME_AC_BE:
14214 access_category = UAPSD_BE;
14215 break;
14216 case SME_AC_VI:
14217 access_category = UAPSD_VI;
14218 break;
14219 case SME_AC_VO:
14220 access_category = UAPSD_VO;
14221 break;
14222 default:
14223 return CDF_STATUS_E_FAILURE;
14224 }
14225
14226 wma_handle = cds_get_context(CDF_MODULE_ID_WMA);
14227 if (!wma_handle) {
14228 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14229 "wma handle is NULL");
14230 return CDF_STATUS_E_FAILURE;
14231 }
14232 if (CDF_STATUS_SUCCESS !=
14233 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
14234 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14235 "Failed to disable uapsd for ac %d for sessionId %d",
14236 ac, sessionId);
14237 return CDF_STATUS_E_FAILURE;
14238 }
14239 return CDF_STATUS_SUCCESS;
14240}
14241
14242/**
14243 * sme_update_nss() - SME API to change the number for spatial streams
14244 * (1 or 2)
14245 * @hal: Handle returned by mac open
14246 * @nss: Number of spatial streams
14247 *
14248 * This function is used to update the number of spatial streams supported.
14249 *
14250 * Return: Success upon successfully changing nss else failure
14251 *
14252 */
14253CDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
14254{
14255 CDF_STATUS status;
14256 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
14257 uint32_t i, value = 0;
14258 union {
14259 uint16_t cfg_value16;
14260 tSirMacHTCapabilityInfo ht_cap_info;
14261 } uHTCapabilityInfo;
14262 tCsrRoamSession *csr_session;
14263
14264 status = sme_acquire_global_lock(&mac_ctx->sme);
14265
14266 if (CDF_STATUS_SUCCESS == status) {
14267 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
14268
14269 /* get the HT capability info*/
14270 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
14271 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
14272
14273 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
14274 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
14275 csr_session = &mac_ctx->roam.roamSession[i];
14276 csr_session->htConfig.ht_tx_stbc =
14277 uHTCapabilityInfo.ht_cap_info.txSTBC;
14278 }
14279 }
14280
14281 sme_release_global_lock(&mac_ctx->sme);
14282 }
14283 return status;
14284}
14285
14286/**
14287 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
14288 * @hal: global hal handle
14289 * @cb: callback function pointer
14290 *
14291 * This function stores the rssi threshold breached callback function.
14292 *
14293 * Return: CDF_STATUS enumeration.
14294 */
14295CDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle hal,
14296 void (*cb)(void *, struct rssi_breach_event *))
14297{
14298 CDF_STATUS status = CDF_STATUS_SUCCESS;
14299 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14300
14301 status = sme_acquire_global_lock(&mac->sme);
14302 if (!CDF_IS_STATUS_SUCCESS(status)) {
14303 sms_log(mac, LOGE,
14304 FL("sme_acquire_global_lock failed!(status=%d)"),
14305 status);
14306 return status;
14307 }
14308
14309 mac->sme.rssi_threshold_breached_cb = cb;
14310 sme_release_global_lock(&mac->sme);
14311 return status;
14312}
14313
14314/**
14315 * sme_is_any_session_in_connected_state() - SME wrapper API to
14316 * check if any session is in connected state or not.
14317 *
14318 * @hal: Handle returned by mac open
14319 *
14320 * This function is used to check if any valid sme session is in
14321 * connected state or not.
14322 *
14323 * Return: true if any session is connected, else false.
14324 *
14325 */
14326bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
14327{
14328 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
14329 CDF_STATUS status;
14330 bool ret = false;
14331
14332 status = sme_acquire_global_lock(&mac_ctx->sme);
14333 if (CDF_STATUS_SUCCESS == status) {
14334 ret = csr_is_any_session_in_connect_state(mac_ctx);
14335 sme_release_global_lock(&mac_ctx->sme);
14336 }
14337 return ret;
14338}
14339
14340/**
14341 * sme_set_rssi_monitoring() - set rssi monitoring
14342 * @hal: global hal handle
14343 * @input: request message
14344 *
14345 * This function constructs the vos message and fill in message type,
14346 * bodyptr with @input and posts it to WDA queue.
14347 *
14348 * Return: CDF_STATUS enumeration
14349 */
14350CDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
14351 struct rssi_monitor_req *input)
14352{
14353 CDF_STATUS status = CDF_STATUS_SUCCESS;
14354 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14355 cds_msg_t cds_message;
14356 struct rssi_monitor_req *req_msg;
14357
14358 sms_log(mac, LOG1, FL("enter"));
14359 req_msg = cdf_mem_malloc(sizeof(*req_msg));
14360 if (!req_msg) {
14361 sms_log(mac, LOGE, FL("memory allocation failed"));
14362 return CDF_STATUS_E_NOMEM;
14363 }
14364
14365 *req_msg = *input;
14366
14367 status = sme_acquire_global_lock(&mac->sme);
14368 if (!CDF_IS_STATUS_SUCCESS(status)) {
14369 sms_log(mac, LOGE,
14370 FL("sme_acquire_global_lock failed!(status=%d)"),
14371 status);
14372 cdf_mem_free(req_msg);
14373 return status;
14374 }
14375
14376 /* Serialize the req through MC thread */
14377 cds_message.bodyptr = req_msg;
14378 cds_message.type = WMA_SET_RSSI_MONITOR_REQ;
14379 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
14380 if (!CDF_IS_STATUS_SUCCESS(status)) {
14381 sms_log(mac, LOGE,
14382 FL("cds_mq_post_message failed!(err=%d)"),
14383 status);
14384 cdf_mem_free(req_msg);
14385 }
14386 sme_release_global_lock(&mac->sme);
14387
14388 return status;
14389}
14390
14391/**
14392 * sme_fw_mem_dump() - Get FW memory dump
14393 * @hHal: hal handle
14394 * @recvd_req: received memory dump request.
14395 *
14396 * This API is invoked by HDD to indicate FW to start
14397 * dumping firmware memory.
14398 *
14399 * Return: CDF_STATUS
14400 */
14401#ifdef WLAN_FEATURE_MEMDUMP
14402CDF_STATUS sme_fw_mem_dump(tHalHandle hHal, void *recvd_req)
14403{
14404 CDF_STATUS status = CDF_STATUS_SUCCESS;
14405 CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
14406 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14407 cds_msg_t msg;
14408 struct fw_dump_req *send_req;
14409 struct fw_dump_seg_req seg_req;
14410 int loop;
14411
14412 send_req = cdf_mem_malloc(sizeof(*send_req));
14413 if (!send_req) {
14414 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14415 FL("Memory allocation failed for WDA_FW_MEM_DUMP"));
14416 return CDF_STATUS_E_FAILURE;
14417 }
14418 cdf_mem_copy(send_req, recvd_req, sizeof(*send_req));
14419
14420 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14421 FL("request_id:%d num_seg:%d"),
14422 send_req->request_id, send_req->num_seg);
14423 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14424 FL("Segment Information"));
14425 for (loop = 0; loop < send_req->num_seg; loop++) {
14426 seg_req = send_req->segment[loop];
14427 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14428 FL("seg_number:%d"), loop);
14429 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14430 FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
14431 seg_req.seg_id, seg_req.seg_start_addr_lo,
14432 seg_req.seg_start_addr_hi);
14433 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14434 FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
14435 seg_req.seg_length, seg_req.dst_addr_lo,
14436 seg_req.dst_addr_hi);
14437 }
14438
14439 if (CDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
14440 msg.bodyptr = send_req;
14441 msg.type = WMA_FW_MEM_DUMP_REQ;
14442 msg.reserved = 0;
14443
14444 cdf_status = cds_mq_post_message(CDF_MODULE_ID_WMA, &msg);
14445 if (CDF_STATUS_SUCCESS != cdf_status) {
14446 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14447 FL("Not able to post WMA_FW_MEM_DUMP"));
14448 cdf_mem_free(send_req);
14449 status = CDF_STATUS_E_FAILURE;
14450 }
14451 sme_release_global_lock(&pMac->sme);
14452 } else {
14453 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14454 FL("Failed to acquire SME Global Lock"));
14455 cdf_mem_free(send_req);
14456 status = CDF_STATUS_E_FAILURE;
14457 }
14458
14459 return status;
14460}
14461#else
14462CDF_STATUS sme_fw_mem_dump(tHalHandle hHal, void *recvd_req)
14463{
14464 return CDF_STATUS_SUCCESS;
14465}
14466#endif /* WLAN_FEATURE_MEMDUMP */
14467
14468/*
14469 * sme_soc_set_pcl() - Send WMI_SOC_SET_PCL_CMDID to the WMA
14470 * @hal: Handle returned by macOpen
14471 * @msg: PCL channel list and length structure
14472 *
14473 * Sends the command to WMA to send WMI_SOC_SET_PCL_CMDID to FW
14474 * Return: CDF_STATUS_SUCCESS on successful posting
14475 */
14476CDF_STATUS sme_soc_set_pcl(tHalHandle hal,
14477 struct sir_pcl_list msg)
14478{
14479 CDF_STATUS status = CDF_STATUS_SUCCESS;
14480 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14481 cds_msg_t cds_message;
14482 struct sir_pcl_list *req_msg;
14483 uint32_t len, i;
14484
14485 len = sizeof(*req_msg);
14486
14487 req_msg = cdf_mem_malloc(len);
14488 if (!req_msg) {
14489 sms_log(mac, LOGE, FL("cdf_mem_malloc failed"));
14490 return CDF_STATUS_E_NOMEM;
14491 }
14492
14493 cdf_mem_zero(req_msg, len);
14494
14495 for (i = 0; i < msg.pcl_len; i++)
14496 req_msg->pcl_list[i] = msg.pcl_list[i];
14497
14498 req_msg->pcl_len = msg.pcl_len;
14499
14500 status = sme_acquire_global_lock(&mac->sme);
14501 if (status != CDF_STATUS_SUCCESS) {
14502 sms_log(mac, LOGE,
14503 FL("sme_AcquireGlobalLock failed!(status=%d)"),
14504 status);
14505 cdf_mem_free(req_msg);
14506 return status;
14507 }
14508
14509 /* Serialize the req through MC thread */
14510 cds_message.bodyptr = req_msg;
14511 cds_message.type = SIR_HAL_SOC_SET_PCL_TO_FW;
14512 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
14513 if (!CDF_IS_STATUS_SUCCESS(status)) {
14514 sms_log(mac, LOGE,
14515 FL("vos_mq_post_message failed!(err=%d)"),
14516 status);
14517 cdf_mem_free(req_msg);
14518 status = CDF_STATUS_E_FAILURE;
14519 }
14520 sme_release_global_lock(&mac->sme);
14521
14522 return status;
14523}
14524
14525/*
14526 * sme_soc_set_hw_mode() - Send WMI_SOC_SET_HW_MODE_CMDID to the WMA
14527 * @hal: Handle returned by macOpen
14528 * @msg: HW mode structure containing hw mode and callback details
14529 *
14530 * Sends the command to CSR to send WMI_SOC_SET_HW_MODE_CMDID to FW
14531 * Return: CDF_STATUS_SUCCESS on successful posting
14532 */
14533CDF_STATUS sme_soc_set_hw_mode(tHalHandle hal,
14534 struct sir_hw_mode msg)
14535{
14536 CDF_STATUS status = CDF_STATUS_SUCCESS;
14537 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14538 tSmeCmd *cmd = NULL;
14539
14540 status = sme_acquire_global_lock(&mac->sme);
14541 if (!CDF_IS_STATUS_SUCCESS(status)) {
14542 sms_log(mac, LOGE, FL("Failed to acquire lock"));
14543 return CDF_STATUS_E_RESOURCES;
14544 }
14545
14546 cmd = sme_get_command_buffer(mac);
14547 if (!cmd) {
14548 sms_log(mac, LOGE, FL("Get command buffer failed"));
14549 sme_release_global_lock(&mac->sme);
14550 return CDF_STATUS_E_NULL_VALUE;
14551 }
14552
14553 cmd->command = e_sme_command_set_hw_mode;
14554 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
14555 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053014556 cmd->u.set_hw_mode_cmd.reason = msg.reason;
14557 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014558
14559 sms_log(mac, LOG1, FL("Queuing e_sme_command_set_hw_mode to CSR"));
14560 csr_queue_sme_command(mac, cmd, false);
14561
14562 sme_release_global_lock(&mac->sme);
14563 return CDF_STATUS_SUCCESS;
14564}
14565
14566/**
14567 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
14568 * @hal: Handle returned by macOpen
14569 * @callback: HDD callback to be registered
14570 *
14571 * Registers the HDD callback with SME. This callback will be invoked when
14572 * HW mode transition event is received from the FW
14573 *
14574 * Return: None
14575 */
14576void sme_register_hw_mode_trans_cb(tHalHandle hal,
14577 hw_mode_transition_cb callback)
14578{
14579 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14580
14581 mac->sme.sme_hw_mode_trans_cb = callback;
14582 sms_log(mac, LOG1, FL("HW mode transition callback registered"));
14583}
14584
14585/**
14586 * sme_nss_update_request() - Send beacon templete update to FW with new
14587 * nss value
14588 * @hal: Handle returned by macOpen
14589 * @vdev_id: the session id
14590 * @new_nss: the new nss value
14591 * @cback: hdd callback
14592 * @next_action: next action to happen at policy mgr after beacon update
14593 *
14594 * Sends the command to CSR to send to PE
14595 * Return: CDF_STATUS_SUCCESS on successful posting
14596 */
14597CDF_STATUS sme_nss_update_request(tHalHandle hHal, uint32_t vdev_id,
14598 uint8_t new_nss, void *cback, uint8_t next_action,
14599 void *hdd_context)
14600{
14601 CDF_STATUS status = CDF_STATUS_E_FAILURE;
14602 tpAniSirGlobal mac = PMAC_STRUCT(hHal);
14603 tSmeCmd *cmd = NULL;
14604
14605 status = sme_acquire_global_lock(&mac->sme);
14606 if (CDF_IS_STATUS_SUCCESS(status)) {
14607 cmd = sme_get_command_buffer(mac);
14608 if (!cmd) {
14609 sms_log(mac, LOGE, FL("Get command buffer failed"));
14610 sme_release_global_lock(&mac->sme);
14611 return CDF_STATUS_E_NULL_VALUE;
14612 }
14613 cmd->command = e_sme_command_nss_update;
14614 /* Sessionized modules may require this info */
14615 cmd->sessionId = vdev_id;
14616 cmd->u.nss_update_cmd.new_nss = new_nss;
14617 cmd->u.nss_update_cmd.session_id = vdev_id;
14618 cmd->u.nss_update_cmd.nss_update_cb = cback;
14619 cmd->u.nss_update_cmd.context = hdd_context;
14620 cmd->u.nss_update_cmd.next_action = next_action;
14621
14622 sms_log(mac, LOG1, FL("Queuing e_sme_command_nss_update to CSR"));
14623 csr_queue_sme_command(mac, cmd, false);
14624 sme_release_global_lock(&mac->sme);
14625 }
14626 return status;
14627}
14628
14629/**
14630 * sme_soc_set_dual_mac_config() - Set dual mac configurations
14631 * @hal: Handle returned by macOpen
14632 * @msg: Structure containing the dual mac config parameters
14633 *
14634 * Queues configuration information to CSR to configure
14635 * WLAN firmware for the dual MAC features
14636 *
14637 * Return: CDF_STATUS
14638 */
14639CDF_STATUS sme_soc_set_dual_mac_config(tHalHandle hal,
14640 struct sir_dual_mac_config msg)
14641{
14642 CDF_STATUS status = CDF_STATUS_SUCCESS;
14643 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14644 tSmeCmd *cmd;
14645
14646 status = sme_acquire_global_lock(&mac->sme);
14647 if (!CDF_IS_STATUS_SUCCESS(status)) {
14648 sms_log(mac, LOGE, FL("Failed to acquire lock"));
14649 return CDF_STATUS_E_RESOURCES;
14650 }
14651
14652 cmd = sme_get_command_buffer(mac);
14653 if (!cmd) {
14654 sms_log(mac, LOGE, FL("Get command buffer failed"));
14655 sme_release_global_lock(&mac->sme);
14656 return CDF_STATUS_E_NULL_VALUE;
14657 }
14658
14659 cmd->command = e_sme_command_set_dual_mac_config;
14660 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
14661 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
14662 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
14663
14664 sms_log(mac, LOG1,
14665 FL("Queuing e_sme_command_set_dual_mac_config to CSR: %x %x"),
14666 cmd->u.set_dual_mac_cmd.scan_config,
14667 cmd->u.set_dual_mac_cmd.fw_mode_config);
14668 csr_queue_sme_command(mac, cmd, false);
14669
14670 sme_release_global_lock(&mac->sme);
14671 return CDF_STATUS_SUCCESS;
14672}
14673
14674/**
14675 * sme_set_peer_authorized() - call peer authorized callback
14676 * @peer_addr: peer mac address
14677 * @auth_cb: auth callback
14678 * @vdev_id: vdev id
14679 *
14680 * Return: CDF Status
14681 */
14682CDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
14683 sme_peer_authorized_fp auth_cb,
14684 uint32_t vdev_id)
14685{
14686 void *wma_handle;
14687
14688 wma_handle = cds_get_context(CDF_MODULE_ID_WMA);
14689 if (!wma_handle) {
14690 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
14691 "wma handle is NULL");
14692 return CDF_STATUS_E_FAILURE;
14693 }
14694
14695 wma_set_peer_authorized_cb(wma_handle, auth_cb);
14696 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
14697 1, vdev_id);
14698}
14699
14700/*
14701 * sme_disable_non_fcc_channel() - non-fcc channel disable request
14702 * @hal: HAL pointer
14703 * @fcc_constraint: true: disable, false; enable
14704 *
14705 * Return: CDF_STATUS
14706 */
14707CDF_STATUS sme_disable_non_fcc_channel(tHalHandle hal, bool fcc_constraint)
14708{
14709 CDF_STATUS status;
14710 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
14711
14712 status = sme_acquire_global_lock(&mac_ptr->sme);
14713
14714 if (CDF_STATUS_SUCCESS == status) {
14715
14716 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
14717 mac_ptr->scan.fcc_constraint = fcc_constraint;
14718
14719 /* update the channel list in firmware */
14720 status = csr_update_channel_list(mac_ptr);
14721 }
14722
14723 sme_release_global_lock(&mac_ptr->sme);
14724 }
14725
14726 return status;
14727}
14728/**
14729 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
14730 * @hal: Global MAC pointer
14731 *
14732 * Return: NULL.
14733 */
14734void sme_setdef_dot11mode(tHalHandle hal)
14735{
14736 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14737 csr_set_default_dot11_mode(mac_ctx);
14738}
14739
14740/**
14741 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
14742 * params
14743 * @hal_handle - The handle returned by macOpen.
14744 * @session_id - Session Identifier
14745 * @notify_id - Identifies 1 of the 4 parameters to be modified
14746 * @val New value of the parameter
14747 *
14748 * Return: CDF_STATUS - SME update config successful.
14749 * Other status means SME failed to update
14750 */
14751
14752CDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
14753 uint8_t session_id,
14754 uint32_t notify_id,
14755 int32_t val)
14756{
14757 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14758 CDF_STATUS status = CDF_STATUS_SUCCESS;
14759 tCsrNeighborRoamConfig *nr_config = NULL;
14760 tpCsrNeighborRoamControlInfo nr_info = NULL;
14761 uint32_t reason = 0;
14762
14763 status = sme_acquire_global_lock(&mac_ctx->sme);
14764 if (CDF_IS_STATUS_SUCCESS(status)) {
14765 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
14766 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
14767 switch (notify_id) {
14768 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
14769 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14770 "%s: gRoamScanHirssiMaxCount %d => %d",
14771 __func__, nr_config->nhi_rssi_scan_max_count,
14772 val);
14773 nr_config->nhi_rssi_scan_max_count = val;
14774 nr_info->cfgParams.hi_rssi_scan_max_count = val;
14775 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
14776 break;
14777
14778 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
14779 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14780 FL("gRoamScanHiRssiDelta %d => %d"),
14781 nr_config->nhi_rssi_scan_rssi_delta,
14782 val);
14783 nr_config->nhi_rssi_scan_rssi_delta = val;
14784 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
14785 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
14786 break;
14787
14788 case eCSR_HI_RSSI_SCAN_DELAY_ID:
14789 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14790 FL("gRoamScanHiRssiDelay %d => %d"),
14791 nr_config->nhi_rssi_scan_delay,
14792 val);
14793 nr_config->nhi_rssi_scan_delay = val;
14794 nr_info->cfgParams.hi_rssi_scan_delay = val;
14795 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
14796 break;
14797
14798 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
14799 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14800 FL("gRoamScanHiRssiUpperBound %d => %d"),
14801 nr_config->nhi_rssi_scan_rssi_ub,
14802 val);
14803 nr_config->nhi_rssi_scan_rssi_ub = val;
14804 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
14805 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
14806 break;
14807
14808 default:
14809 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14810 FL("invalid parameter notify_id %d"),
14811 notify_id);
14812 status = CDF_STATUS_E_INVAL;
14813 break;
14814 }
14815 sme_release_global_lock(&mac_ctx->sme);
14816 }
14817#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14818 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
14819 status == CDF_STATUS_SUCCESS) {
14820 csr_roam_offload_scan(mac_ctx, session_id,
14821 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
14822 }
14823#endif
14824
14825 return status;
14826}
14827
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070014828/**
14829 * sme_update_tgt_services() - update the target services config.
14830 * @hal: HAL pointer.
14831 * @cfg: wma_tgt_services parameters.
14832 *
14833 * update the target services config.
14834 *
14835 * Return: None.
14836 */
14837void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
14838{
14839 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14840
14841 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
14842 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053014843 mac_ctx->pmf_offload = cfg->pmf_offload;
14844 CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO,
14845 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070014846
14847 return;
14848}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014849
14850#ifdef FEATURE_WLAN_TDLS
14851
14852/**
14853 * sme_get_opclass() - determine operating class
14854 * @hal: Pointer to HAL
14855 * @channel: channel id
14856 * @bw_offset: bandwidth offset
14857 * @opclass: pointer to operating class
14858 *
14859 * Function will determine operating class from regdm_get_opclass_from_channel
14860 *
14861 * Return: none
14862 */
14863void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
14864 uint8_t *opclass)
14865{
14866 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14867
14868 /* redgm opclass table contains opclass for 40MHz low primary,
14869 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
14870 * first we will check if bit for 40MHz is set and if so find
14871 * matching opclass either with low primary or high primary
14872 * (a channel would never be in both) and then search for opclass
14873 * matching 20MHz, else for any BW.
14874 */
14875 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
14876 *opclass = cds_regdm_get_opclass_from_channel(
14877 mac_ctx->scan.countryCodeCurrent,
14878 channel, BW40_LOW_PRIMARY);
14879 if (!(*opclass)) {
14880 *opclass = cds_regdm_get_opclass_from_channel(
14881 mac_ctx->scan.countryCodeCurrent,
14882 channel, BW40_HIGH_PRIMARY);
14883 }
14884 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
14885 *opclass = cds_regdm_get_opclass_from_channel(
14886 mac_ctx->scan.countryCodeCurrent,
14887 channel, BW20);
14888 } else {
14889 *opclass = cds_regdm_get_opclass_from_channel(
14890 mac_ctx->scan.countryCodeCurrent,
14891 channel, BWALL);
14892 }
14893}
14894#endif