Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 22 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 23 | * |
| 24 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 25 | * |
| 26 | * |
| 27 | * Permission to use, copy, modify, and/or distribute this software for |
| 28 | * any purpose with or without fee is hereby granted, provided that the |
| 29 | * above copyright notice and this permission notice appear in all |
| 30 | * copies. |
| 31 | * |
| 32 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 33 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 35 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 36 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 37 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 38 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 39 | * PERFORMANCE OF THIS SOFTWARE. |
| 40 | */ |
| 41 | |
| 42 | /*======================================================================== |
| 43 | |
| 44 | \file wlan_hdd_main.c |
| 45 | |
| 46 | \brief WLAN Host Device Driver implementation |
| 47 | |
| 48 | Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved. |
| 49 | |
| 50 | Qualcomm Confidential and Proprietary. |
| 51 | |
| 52 | ========================================================================*/ |
| 53 | |
| 54 | /**========================================================================= |
| 55 | |
| 56 | EDIT HISTORY FOR FILE |
| 57 | |
| 58 | |
| 59 | This section contains comments describing changes made to the module. |
| 60 | Notice that changes are listed in reverse chronological order. |
| 61 | |
| 62 | |
| 63 | $Header:$ $DateTime: $ $Author: $ |
| 64 | |
| 65 | |
| 66 | when who what, where, why |
| 67 | -------- --- -------------------------------------------------------- |
| 68 | 04/5/09 Shailender Created module. |
| 69 | 02/24/10 Sudhir.S.Kohalli Added to support param for SoftAP module |
| 70 | 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure |
| 71 | ==========================================================================*/ |
| 72 | |
| 73 | /*-------------------------------------------------------------------------- |
| 74 | Include Files |
| 75 | ------------------------------------------------------------------------*/ |
| 76 | //#include <wlan_qct_driver.h> |
| 77 | #include <wlan_hdd_includes.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 78 | #include <vos_api.h> |
| 79 | #include <vos_sched.h> |
| 80 | #include <vos_power.h> |
| 81 | #include <linux/etherdevice.h> |
| 82 | #include <linux/firmware.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 83 | #ifdef ANI_BUS_TYPE_PLATFORM |
| 84 | #include <linux/wcnss_wlan.h> |
| 85 | #endif //ANI_BUS_TYPE_PLATFORM |
| 86 | #ifdef ANI_BUS_TYPE_PCI |
| 87 | #include "wcnss_wlan.h" |
| 88 | #endif /* ANI_BUS_TYPE_PCI */ |
| 89 | #include <wlan_hdd_tx_rx.h> |
| 90 | #include <palTimer.h> |
| 91 | #include <wniApi.h> |
| 92 | #include <wlan_nlink_srv.h> |
| 93 | #include <wlan_btc_svc.h> |
| 94 | #include <wlan_hdd_cfg.h> |
| 95 | #include <wlan_ptt_sock_svc.h> |
| 96 | #include <wlan_hdd_wowl.h> |
| 97 | #include <wlan_hdd_misc.h> |
| 98 | #include <wlan_hdd_wext.h> |
| 99 | #ifdef WLAN_BTAMP_FEATURE |
| 100 | #include <bap_hdd_main.h> |
| 101 | #include <bapInternal.h> |
| 102 | #endif // WLAN_BTAMP_FEATURE |
| 103 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 104 | #include <linux/wireless.h> |
| 105 | #include <net/cfg80211.h> |
| 106 | #include "wlan_hdd_cfg80211.h" |
| 107 | #include "wlan_hdd_p2p.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 108 | #include <linux/rtnetlink.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 109 | int wlan_hdd_ftm_start(hdd_context_t *pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 110 | #include "sapApi.h" |
| 111 | #include <linux/semaphore.h> |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 112 | #include <linux/ctype.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 113 | #include <mach/subsystem_restart.h> |
| 114 | #include <wlan_hdd_hostapd.h> |
| 115 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 116 | #include "cfgApi.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 117 | #include "wlan_hdd_dev_pwr.h" |
| 118 | #ifdef WLAN_BTAMP_FEATURE |
| 119 | #include "bap_hdd_misc.h" |
| 120 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 121 | #include "wlan_qct_pal_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 122 | #include "qwlan_version.h" |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 123 | #include "wlan_qct_wda.h" |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 124 | #ifdef FEATURE_WLAN_TDLS |
| 125 | #include "wlan_hdd_tdls.h" |
| 126 | #endif |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 127 | #include "wlan_hdd_debugfs.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 128 | |
| 129 | #ifdef MODULE |
| 130 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 131 | #else |
| 132 | #define WLAN_MODULE_NAME "wlan" |
| 133 | #endif |
| 134 | |
| 135 | #ifdef TIMER_MANAGER |
| 136 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 137 | #else |
| 138 | #define TIMER_MANAGER_STR "" |
| 139 | #endif |
| 140 | |
| 141 | #ifdef MEMORY_DEBUG |
| 142 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 143 | #else |
| 144 | #define MEMORY_DEBUG_STR "" |
| 145 | #endif |
| 146 | |
| 147 | /* the Android framework expects this param even though we don't use it */ |
| 148 | #define BUF_LEN 20 |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 149 | static char fwpath_buffer[BUF_LEN]; |
| 150 | static struct kparam_string fwpath = { |
| 151 | .string = fwpath_buffer, |
| 152 | .maxlen = BUF_LEN, |
| 153 | }; |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 154 | |
| 155 | static char *country_code; |
| 156 | static int enable_11d = -1; |
| 157 | static int enable_dfs_chan_scan = -1; |
| 158 | |
Madan Mohan Koyyalamudi | 05f313c | 2012-09-18 19:19:15 -0700 | [diff] [blame] | 159 | #ifndef MODULE |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 160 | static int wlan_hdd_inited; |
Madan Mohan Koyyalamudi | 05f313c | 2012-09-18 19:19:15 -0700 | [diff] [blame] | 161 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 162 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 163 | /* |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 164 | * spinlock for synchronizing asynchronous request/response |
| 165 | * (full description of use in wlan_hdd_main.h) |
| 166 | */ |
| 167 | DEFINE_SPINLOCK(hdd_context_lock); |
| 168 | |
| 169 | /* |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 170 | * The rate at which the driver sends RESTART event to supplicant |
| 171 | * once the function 'vos_wlanRestart()' is called |
| 172 | * |
| 173 | */ |
| 174 | #define WLAN_HDD_RESTART_RETRY_DELAY_MS 5000 /* 5 second */ |
| 175 | #define WLAN_HDD_RESTART_RETRY_MAX_CNT 5 /* 5 retries */ |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 176 | |
| 177 | /* |
| 178 | * Size of Driver command strings from upper layer |
| 179 | */ |
| 180 | #define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */ |
| 181 | #define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */ |
| 182 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 183 | #if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD) |
| 184 | #define TID_MIN_VALUE 0 |
| 185 | #define TID_MAX_VALUE 15 |
| 186 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 187 | tAniTrafStrmMetrics* pTsmMetrics); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 188 | static VOS_STATUS hdd_parse_ccx_beacon_req(tANI_U8 *pValue, |
| 189 | tCsrCcxBeaconReq *pCcxBcnReq); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 190 | #endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */ |
| 191 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 192 | #define WLAN_PRIV_DATA_MAX_LEN 4096 |
| 193 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 194 | /* |
| 195 | * Driver miracast parameters 0-Disabled |
| 196 | * 1-Source, 2-Sink |
| 197 | */ |
| 198 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL 0 |
| 199 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL 2 |
| 200 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 201 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 202 | static struct wake_lock wlan_wake_lock; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 203 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 204 | /* set when SSR is needed after unload */ |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 205 | static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 206 | |
| 207 | //internal function declaration |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 208 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx); |
| 209 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx); |
| 210 | static void wlan_hdd_restart_deinit(hdd_context_t *pHddCtx); |
| 211 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 212 | void hdd_set_wlan_suspend_mode(bool suspend); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 213 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 214 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 215 | struct sk_buff *skb); |
| 216 | |
| 217 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 218 | static void hdd_set_multicast_list(struct net_device *dev); |
| 219 | #endif |
| 220 | |
| 221 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter); |
Amar Singhal | 4c723bd | 2013-03-25 18:14:15 -0700 | [diff] [blame] | 222 | int isWDresetInProgress(void); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 223 | |
| 224 | extern int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr); |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 225 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 226 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 227 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand); |
| 228 | static VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 229 | static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, |
| 230 | tANI_U8 *pChannel, tANI_U8 *pDwellTime, |
| 231 | tANI_U8 **pBuf, tANI_U8 *pBufLen); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 232 | static VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 233 | tANI_U8 *pTargetApBssid, |
| 234 | tANI_U8 *pChannel); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 235 | #endif |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 236 | #if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD) |
| 237 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, tANI_U8 *pCckmIeLen); |
| 238 | #endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */ |
| 239 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 240 | static int hdd_netdev_notifier_call(struct notifier_block * nb, |
| 241 | unsigned long state, |
| 242 | void *ndev) |
| 243 | { |
| 244 | struct net_device *dev = ndev; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 245 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 246 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 247 | #ifdef WLAN_BTAMP_FEATURE |
| 248 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 249 | #endif |
| 250 | |
| 251 | //Make sure that this callback corresponds to our device. |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 252 | if ((strncmp(dev->name, "wlan", 4)) && |
Amar Singhal | 4c723bd | 2013-03-25 18:14:15 -0700 | [diff] [blame] | 253 | (strncmp(dev->name, "p2p", 3))) |
| 254 | return NOTIFY_DONE; |
| 255 | |
| 256 | if (isWDresetInProgress()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 257 | return NOTIFY_DONE; |
| 258 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 259 | if (!dev->ieee80211_ptr) |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 260 | return NOTIFY_DONE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 261 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 262 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 263 | { |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 264 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 265 | VOS_ASSERT(0); |
| 266 | return NOTIFY_DONE; |
| 267 | } |
| 268 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 269 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 270 | if (NULL == pHddCtx) |
| 271 | { |
| 272 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__); |
| 273 | VOS_ASSERT(0); |
| 274 | return NOTIFY_DONE; |
| 275 | } |
| 276 | |
| 277 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu", |
| 278 | __func__, dev->name, state); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 279 | |
| 280 | switch (state) { |
| 281 | case NETDEV_REGISTER: |
| 282 | break; |
| 283 | |
| 284 | case NETDEV_UNREGISTER: |
| 285 | break; |
| 286 | |
| 287 | case NETDEV_UP: |
| 288 | break; |
| 289 | |
| 290 | case NETDEV_DOWN: |
| 291 | break; |
| 292 | |
| 293 | case NETDEV_CHANGE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 294 | if(TRUE == pAdapter->isLinkUpSvcNeeded) |
| 295 | complete(&pAdapter->linkup_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 296 | break; |
| 297 | |
| 298 | case NETDEV_GOING_DOWN: |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 299 | if( pHddCtx->scan_info.mScanPending != FALSE ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 300 | { |
| 301 | int result; |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 302 | INIT_COMPLETION(pHddCtx->scan_info.abortscan_event_var); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 303 | hdd_abort_mac_scan(pAdapter->pHddCtx, pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 304 | result = wait_for_completion_interruptible_timeout( |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 305 | &pHddCtx->scan_info.abortscan_event_var, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 306 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 307 | if(!result) |
| 308 | { |
| 309 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 310 | "%s: Timeout occurred while waiting for abortscan" , |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 311 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 312 | } |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 317 | "%s: Scan is not Pending from user" , __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 318 | } |
| 319 | #ifdef WLAN_BTAMP_FEATURE |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 320 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 321 | status = WLANBAP_StopAmp(); |
| 322 | if(VOS_STATUS_SUCCESS != status ) |
| 323 | { |
| 324 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 325 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 326 | "%s: Failed to stop AMP", __func__); |
| 327 | } |
| 328 | else |
| 329 | { |
| 330 | //a state m/c implementation in PAL is TBD to avoid this delay |
| 331 | msleep(500); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 332 | if ( pHddCtx->isAmpAllowed ) |
| 333 | { |
| 334 | WLANBAP_DeregisterFromHCI(); |
| 335 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 336 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 337 | } |
| 338 | #endif //WLAN_BTAMP_FEATURE |
| 339 | break; |
| 340 | |
| 341 | default: |
| 342 | break; |
| 343 | } |
| 344 | |
| 345 | return NOTIFY_DONE; |
| 346 | } |
| 347 | |
| 348 | struct notifier_block hdd_netdev_notifier = { |
| 349 | .notifier_call = hdd_netdev_notifier_call, |
| 350 | }; |
| 351 | |
| 352 | /*--------------------------------------------------------------------------- |
| 353 | * Function definitions |
| 354 | *-------------------------------------------------------------------------*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 355 | void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx); |
| 356 | void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 357 | //variable to hold the insmod parameters |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 358 | static int con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 359 | #ifndef MODULE |
| 360 | /* current con_mode - used only for statically linked driver |
| 361 | * con_mode is changed by userspace to indicate a mode change which will |
| 362 | * result in calling the module exit and init functions. The module |
| 363 | * exit function will clean up based on the value of con_mode prior to it |
| 364 | * being changed by userspace. So curr_con_mode records the current con_mode |
| 365 | * for exit when con_mode becomes the next mode for init |
| 366 | */ |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 367 | static int curr_con_mode; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 368 | #endif |
| 369 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 370 | /**--------------------------------------------------------------------------- |
| 371 | |
| 372 | \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable |
| 373 | |
| 374 | Called immediately after the cfg.ini is read in order to configure |
| 375 | the desired trace levels. |
| 376 | |
| 377 | \param - moduleId - module whose trace level is being configured |
| 378 | \param - bitmask - bitmask of log levels to be enabled |
| 379 | |
| 380 | \return - void |
| 381 | |
| 382 | --------------------------------------------------------------------------*/ |
| 383 | static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask) |
| 384 | { |
| 385 | wpt_tracelevel level; |
| 386 | |
| 387 | /* if the bitmask is the default value, then a bitmask was not |
| 388 | specified in cfg.ini, so leave the logging level alone (it |
| 389 | will remain at the "compiled in" default value) */ |
| 390 | if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask) |
| 391 | { |
| 392 | return; |
| 393 | } |
| 394 | |
| 395 | /* a mask was specified. start by disabling all logging */ |
| 396 | vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0); |
| 397 | |
| 398 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 399 | level = VOS_TRACE_LEVEL_FATAL; |
| 400 | while (0 != bitmask) |
| 401 | { |
| 402 | if (bitmask & 1) |
| 403 | { |
| 404 | vos_trace_setValue(moduleId, level, 1); |
| 405 | } |
| 406 | level++; |
| 407 | bitmask >>= 1; |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 412 | /**--------------------------------------------------------------------------- |
| 413 | |
| 414 | \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable |
| 415 | |
| 416 | Called immediately after the cfg.ini is read in order to configure |
| 417 | the desired trace levels in the WDI. |
| 418 | |
| 419 | \param - moduleId - module whose trace level is being configured |
| 420 | \param - bitmask - bitmask of log levels to be enabled |
| 421 | |
| 422 | \return - void |
| 423 | |
| 424 | --------------------------------------------------------------------------*/ |
| 425 | static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask) |
| 426 | { |
| 427 | wpt_tracelevel level; |
| 428 | |
| 429 | /* if the bitmask is the default value, then a bitmask was not |
| 430 | specified in cfg.ini, so leave the logging level alone (it |
| 431 | will remain at the "compiled in" default value) */ |
| 432 | if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask) |
| 433 | { |
| 434 | return; |
| 435 | } |
| 436 | |
| 437 | /* a mask was specified. start by disabling all logging */ |
| 438 | wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0); |
| 439 | |
| 440 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 441 | level = eWLAN_PAL_TRACE_LEVEL_FATAL; |
| 442 | while (0 != bitmask) |
| 443 | { |
| 444 | if (bitmask & 1) |
| 445 | { |
| 446 | wpalTraceSetLevel(moduleId, level, 1); |
| 447 | } |
| 448 | level++; |
| 449 | bitmask >>= 1; |
| 450 | } |
| 451 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 452 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 453 | /* |
| 454 | * FUNCTION: wlan_hdd_validate_context |
| 455 | * This function is used to check the HDD context |
| 456 | */ |
| 457 | int wlan_hdd_validate_context(hdd_context_t *pHddCtx) |
| 458 | { |
| 459 | ENTER(); |
| 460 | |
| 461 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
| 462 | { |
| 463 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 464 | "%s: HDD context is Null", __func__); |
| 465 | return -ENODEV; |
| 466 | } |
| 467 | |
| 468 | if (pHddCtx->isLogpInProgress) |
| 469 | { |
| 470 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 471 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 472 | return -EAGAIN; |
| 473 | } |
| 474 | |
| 475 | if (pHddCtx->isLoadUnloadInProgress) |
| 476 | { |
| 477 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 478 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 479 | return -EAGAIN; |
| 480 | } |
| 481 | return 0; |
| 482 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 483 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 484 | void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx) |
| 485 | { |
| 486 | hdd_adapter_t *pAdapter = NULL; |
| 487 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 488 | eCsrPhyMode phyMode; |
| 489 | hdd_config_t *cfg_param = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 490 | |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 491 | if (NULL == pHddCtx) |
| 492 | { |
| 493 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 494 | "HDD Context is null !!"); |
| 495 | return ; |
| 496 | } |
| 497 | |
| 498 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 499 | if (NULL == pAdapter) |
| 500 | { |
| 501 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 502 | "pAdapter is null !!"); |
| 503 | return ; |
| 504 | } |
| 505 | |
| 506 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 507 | if (NULL == pHddStaCtx) |
| 508 | { |
| 509 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 510 | "pHddStaCtx is null !!"); |
| 511 | return ; |
| 512 | } |
| 513 | |
| 514 | cfg_param = pHddCtx->cfg_ini; |
| 515 | if (NULL == cfg_param) |
| 516 | { |
| 517 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 518 | "cfg_params not available !!"); |
| 519 | return ; |
| 520 | } |
| 521 | |
| 522 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 523 | |
| 524 | if (!pHddCtx->isVHT80Allowed) |
| 525 | { |
| 526 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 527 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 528 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 529 | { |
| 530 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 531 | "Setting phymode to 11n!!"); |
| 532 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 533 | } |
| 534 | } |
| 535 | else |
| 536 | { |
| 537 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 538 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 539 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 540 | return ; |
| 541 | } |
| 542 | |
| 543 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 544 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 545 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 546 | { |
| 547 | VOS_STATUS vosStatus; |
| 548 | |
| 549 | // need to issue a disconnect to CSR. |
| 550 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 551 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 552 | pAdapter->sessionId, |
| 553 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 554 | |
| 555 | if (VOS_STATUS_SUCCESS == vosStatus) |
| 556 | wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
| 557 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 558 | |
| 559 | } |
| 560 | } |
| 561 | #else |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 562 | void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code) |
| 563 | { |
| 564 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 565 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 566 | hdd_config_t *cfg_param; |
| 567 | eCsrPhyMode phyMode; |
| 568 | |
| 569 | if (NULL == pHddCtx) |
| 570 | { |
| 571 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 572 | "HDD Context is null !!"); |
| 573 | return ; |
| 574 | } |
| 575 | |
| 576 | cfg_param = pHddCtx->cfg_ini; |
| 577 | |
| 578 | if (NULL == cfg_param) |
| 579 | { |
| 580 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 581 | "cfg_params not available !!"); |
| 582 | return ; |
| 583 | } |
| 584 | |
| 585 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 586 | |
| 587 | if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code)) |
| 588 | { |
| 589 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 590 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 591 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 592 | { |
| 593 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 594 | "Setting phymode to 11n!!"); |
| 595 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 596 | } |
| 597 | } |
| 598 | else |
| 599 | { |
| 600 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 601 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 602 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 603 | return ; |
| 604 | } |
| 605 | |
| 606 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 607 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 608 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 609 | { |
| 610 | VOS_STATUS vosStatus; |
| 611 | |
| 612 | // need to issue a disconnect to CSR. |
| 613 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 614 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 615 | pAdapter->sessionId, |
| 616 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 617 | |
| 618 | if (VOS_STATUS_SUCCESS == vosStatus) |
| 619 | wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
| 620 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 621 | |
| 622 | } |
| 623 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 624 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 625 | |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 626 | void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code) |
| 627 | { |
| 628 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 629 | hdd_config_t *cfg_param; |
| 630 | |
| 631 | if (NULL == pHddCtx) |
| 632 | { |
| 633 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 634 | "HDD Context is null !!"); |
| 635 | return ; |
| 636 | } |
| 637 | |
| 638 | cfg_param = pHddCtx->cfg_ini; |
| 639 | |
| 640 | if (NULL == cfg_param) |
| 641 | { |
| 642 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 643 | "cfg_params not available !!"); |
| 644 | return ; |
| 645 | } |
| 646 | |
| 647 | if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code)) |
| 648 | { |
| 649 | /*New country doesn't support DFS */ |
| 650 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
| 651 | } |
| 652 | else |
| 653 | { |
| 654 | /*New country Supports DFS as well resetting value back from .ini*/ |
| 655 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan); |
| 656 | } |
| 657 | |
| 658 | } |
| 659 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 660 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 661 | |
| 662 | /**--------------------------------------------------------------------------- |
| 663 | |
| 664 | \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from |
| 665 | input string |
| 666 | |
| 667 | This function extracts assigned integer from string in below format: |
| 668 | "STRING=10" : extracts integer 10 from this string |
| 669 | |
| 670 | \param - pInPtr Pointer to input string |
| 671 | \param - base Base for string to int conversion(10 for decimal 16 for hex) |
| 672 | \param - pOutPtr Pointer to variable in which extracted integer needs to be |
| 673 | assigned |
| 674 | \param - pLastArg to tell whether it is last arguement in input string or |
| 675 | not |
| 676 | |
| 677 | \return - NULL for failure cases |
| 678 | pointer to next arguement in input string for success cases |
| 679 | --------------------------------------------------------------------------*/ |
| 680 | static tANI_U8 * |
| 681 | hdd_extract_assigned_int_from_str |
| 682 | ( |
| 683 | tANI_U8 *pInPtr, |
| 684 | tANI_U8 base, |
| 685 | tANI_U32 *pOutPtr, |
| 686 | tANI_U8 *pLastArg |
| 687 | ) |
| 688 | { |
| 689 | int tempInt; |
| 690 | int v = 0; |
| 691 | char buf[32]; |
| 692 | int val = 0; |
| 693 | *pLastArg = FALSE; |
| 694 | |
| 695 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 696 | if (NULL == pInPtr) |
| 697 | { |
| 698 | return NULL; |
| 699 | } |
| 700 | |
| 701 | pInPtr++; |
| 702 | |
| 703 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 704 | |
| 705 | val = sscanf(pInPtr, "%32s ", buf); |
| 706 | if (val < 0 && val > strlen(pInPtr)) |
| 707 | { |
| 708 | return NULL; |
| 709 | } |
| 710 | pInPtr += val; |
| 711 | v = kstrtos32(buf, base, &tempInt); |
| 712 | if (v < 0) |
| 713 | { |
| 714 | return NULL; |
| 715 | } |
Rajeev Kumar | 4d93d84 | 2014-01-02 18:31:21 -0800 | [diff] [blame] | 716 | if (tempInt < 0) |
| 717 | { |
| 718 | tempInt = 0; |
| 719 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 720 | *pOutPtr = tempInt; |
| 721 | |
| 722 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 723 | if (NULL == pInPtr) |
| 724 | { |
| 725 | *pLastArg = TRUE; |
| 726 | return NULL; |
| 727 | } |
| 728 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 729 | |
| 730 | return pInPtr; |
| 731 | } |
| 732 | |
| 733 | /**--------------------------------------------------------------------------- |
| 734 | |
| 735 | \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from |
| 736 | input string |
| 737 | |
| 738 | This function extracts assigned character from string in below format: |
| 739 | "STRING=A" : extracts char 'A' from this string |
| 740 | |
| 741 | \param - pInPtr Pointer to input string |
| 742 | \param - pOutPtr Pointer to variable in which extracted char needs to be |
| 743 | assigned |
| 744 | \param - pLastArg to tell whether it is last arguement in input string or |
| 745 | not |
| 746 | |
| 747 | \return - NULL for failure cases |
| 748 | pointer to next arguement in input string for success cases |
| 749 | --------------------------------------------------------------------------*/ |
| 750 | static tANI_U8 * |
| 751 | hdd_extract_assigned_char_from_str |
| 752 | ( |
| 753 | tANI_U8 *pInPtr, |
| 754 | tANI_U8 *pOutPtr, |
| 755 | tANI_U8 *pLastArg |
| 756 | ) |
| 757 | { |
| 758 | *pLastArg = FALSE; |
| 759 | |
| 760 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 761 | if (NULL == pInPtr) |
| 762 | { |
| 763 | return NULL; |
| 764 | } |
| 765 | |
| 766 | pInPtr++; |
| 767 | |
| 768 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 769 | |
| 770 | *pOutPtr = *pInPtr; |
| 771 | |
| 772 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 773 | if (NULL == pInPtr) |
| 774 | { |
| 775 | *pLastArg = TRUE; |
| 776 | return NULL; |
| 777 | } |
| 778 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 779 | |
| 780 | return pInPtr; |
| 781 | } |
| 782 | |
| 783 | |
| 784 | /**--------------------------------------------------------------------------- |
| 785 | |
| 786 | \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command |
| 787 | |
| 788 | This function parses set batch scan command in below format: |
| 789 | WLS_BATCHING_SET <space> followed by below arguements |
| 790 | "SCANFREQ=XX" : Optional defaults to 30 sec |
| 791 | "MSCAN=XX" : Required number of scans to attempt to batch |
| 792 | "BESTN=XX" : Best Network (RSSI) defaults to 16 |
| 793 | "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B. |
| 794 | A. implies only 5 GHz , B. implies only 2.4GHz |
| 795 | "RTT=X" : optional defaults to 0 |
| 796 | returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on |
| 797 | error |
| 798 | |
| 799 | For example input commands: |
| 800 | 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is |
| 801 | translated into set batch scan with following parameters: |
| 802 | a) Frequence 60 seconds |
| 803 | b) Batch 10 scans together |
| 804 | c) Best RSSI to be 20 |
| 805 | d) 5GHz band only |
| 806 | e) RTT is equal to 0 |
| 807 | |
| 808 | \param - pValue Pointer to input channel list |
| 809 | \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure |
| 810 | |
| 811 | \return - 0 for success non-zero for failure |
| 812 | |
| 813 | --------------------------------------------------------------------------*/ |
| 814 | static int |
| 815 | hdd_parse_set_batchscan_command |
| 816 | ( |
| 817 | tANI_U8 *pValue, |
| 818 | tSirSetBatchScanReq *pHddSetBatchScanReq |
| 819 | ) |
| 820 | { |
| 821 | tANI_U8 *inPtr = pValue; |
| 822 | tANI_U8 val = 0; |
| 823 | tANI_U8 lastArg = 0; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 824 | tANI_U32 nScanFreq; |
| 825 | tANI_U32 nMscan; |
| 826 | tANI_U32 nBestN; |
| 827 | tANI_U8 ucRfBand; |
| 828 | tANI_U32 nRtt; |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 829 | tANI_U32 temp; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 830 | |
| 831 | /*initialize default values*/ |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 832 | nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ; |
| 833 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 834 | nRtt = 0; |
| 835 | nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 836 | |
| 837 | /*go to space after WLS_BATCHING_SET command*/ |
| 838 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 839 | /*no argument after the command*/ |
| 840 | if (NULL == inPtr) |
| 841 | { |
| 842 | return -EINVAL; |
| 843 | } |
| 844 | |
| 845 | /*no space after the command*/ |
| 846 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 847 | { |
| 848 | return -EINVAL; |
| 849 | } |
| 850 | |
| 851 | /*removing empty spaces*/ |
| 852 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 853 | |
| 854 | /*no argument followed by spaces*/ |
| 855 | if ('\0' == *inPtr) |
| 856 | { |
| 857 | return -EINVAL; |
| 858 | } |
| 859 | |
| 860 | /*check and parse SCANFREQ*/ |
| 861 | if ((strncmp(inPtr, "SCANFREQ", 8) == 0)) |
| 862 | { |
| 863 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 864 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 865 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 866 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 867 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 868 | nScanFreq = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 869 | } |
| 870 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 871 | if ( (NULL == inPtr) || (TRUE == lastArg)) |
| 872 | { |
| 873 | return -EINVAL; |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | /*check and parse MSCAN*/ |
| 878 | if ((strncmp(inPtr, "MSCAN", 5) == 0)) |
| 879 | { |
| 880 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 881 | &nMscan, &lastArg); |
| 882 | |
| 883 | if (0 == nMscan) |
| 884 | { |
| 885 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 886 | "invalid MSCAN=%d", nMscan); |
| 887 | return -EINVAL; |
| 888 | } |
| 889 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 890 | if (TRUE == lastArg) |
| 891 | { |
| 892 | goto done; |
| 893 | } |
| 894 | else if (NULL == inPtr) |
| 895 | { |
| 896 | return -EINVAL; |
| 897 | } |
| 898 | } |
| 899 | else |
| 900 | { |
| 901 | return -EINVAL; |
| 902 | } |
| 903 | |
| 904 | /*check and parse BESTN*/ |
| 905 | if ((strncmp(inPtr, "BESTN", 5) == 0)) |
| 906 | { |
| 907 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 908 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 909 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 910 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 911 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 912 | nBestN = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 913 | } |
| 914 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 915 | if (TRUE == lastArg) |
| 916 | { |
| 917 | goto done; |
| 918 | } |
| 919 | else if (NULL == inPtr) |
| 920 | { |
| 921 | return -EINVAL; |
| 922 | } |
| 923 | } |
| 924 | |
| 925 | /*check and parse CHANNEL*/ |
| 926 | if ((strncmp(inPtr, "CHANNEL", 7) == 0)) |
| 927 | { |
| 928 | inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg); |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 929 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 930 | if (('A' == val) || ('a' == val)) |
| 931 | { |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 932 | ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 933 | } |
| 934 | else if (('B' == val) || ('b' == val)) |
| 935 | { |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 936 | ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 937 | } |
| 938 | else |
| 939 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 940 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 941 | } |
| 942 | |
| 943 | if (TRUE == lastArg) |
| 944 | { |
| 945 | goto done; |
| 946 | } |
| 947 | else if (NULL == inPtr) |
| 948 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 949 | return -EINVAL; |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | /*check and parse RTT*/ |
| 954 | if ((strncmp(inPtr, "RTT", 3) == 0)) |
| 955 | { |
| 956 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 957 | &nRtt, &lastArg); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 958 | if (TRUE == lastArg) |
| 959 | { |
| 960 | goto done; |
| 961 | } |
| 962 | if (NULL == inPtr) |
| 963 | { |
| 964 | return -EINVAL; |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | |
| 969 | done: |
| 970 | |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 971 | pHddSetBatchScanReq->scanFrequency = nScanFreq; |
| 972 | pHddSetBatchScanReq->numberOfScansToBatch = nMscan; |
| 973 | pHddSetBatchScanReq->bestNetwork = nBestN; |
| 974 | pHddSetBatchScanReq->rfBand = ucRfBand; |
| 975 | pHddSetBatchScanReq->rtt = nRtt; |
| 976 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 977 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 978 | "Received WLS_BATCHING_SET with SCANFREQ=%d " |
| 979 | "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d", |
| 980 | pHddSetBatchScanReq->scanFrequency, |
| 981 | pHddSetBatchScanReq->numberOfScansToBatch, |
| 982 | pHddSetBatchScanReq->bestNetwork, |
| 983 | pHddSetBatchScanReq->rfBand, |
| 984 | pHddSetBatchScanReq->rtt); |
| 985 | |
| 986 | return 0; |
| 987 | }/*End of hdd_parse_set_batchscan_command*/ |
| 988 | |
| 989 | /**--------------------------------------------------------------------------- |
| 990 | |
| 991 | \brief hdd_set_batch_scan_req_callback () - This function is called after |
| 992 | receiving set batch scan response from FW and it saves set batch scan |
| 993 | response data FW to HDD context and sets the completion event on |
| 994 | which hdd_ioctl is waiting |
| 995 | |
| 996 | \param - callbackContext Pointer to HDD adapter |
| 997 | \param - pRsp Pointer to set batch scan response data received from FW |
| 998 | |
| 999 | \return - nothing |
| 1000 | |
| 1001 | --------------------------------------------------------------------------*/ |
| 1002 | static void hdd_set_batch_scan_req_callback |
| 1003 | ( |
| 1004 | void *callbackContext, |
| 1005 | tSirSetBatchScanRsp *pRsp |
| 1006 | ) |
| 1007 | { |
| 1008 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 1009 | tSirSetBatchScanRsp *pHddSetBatchScanRsp; |
| 1010 | |
| 1011 | /*sanity check*/ |
| 1012 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 1013 | { |
| 1014 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1015 | "%s: Invalid pAdapter magic", __func__); |
| 1016 | VOS_ASSERT(0); |
| 1017 | return; |
| 1018 | } |
| 1019 | pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp; |
| 1020 | |
| 1021 | /*save set batch scan response*/ |
| 1022 | pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch; |
| 1023 | |
| 1024 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1025 | "Received set batch scan rsp from FW with nScansToBatch=%d", |
| 1026 | pHddSetBatchScanRsp->nScansToBatch); |
| 1027 | |
| 1028 | pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE; |
| 1029 | complete(&pAdapter->hdd_set_batch_scan_req_var); |
| 1030 | |
| 1031 | return; |
| 1032 | }/*End of hdd_set_batch_scan_req_callback*/ |
| 1033 | |
| 1034 | |
| 1035 | /**--------------------------------------------------------------------------- |
| 1036 | |
| 1037 | \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta |
| 1038 | info in hdd batch scan response queue |
| 1039 | |
| 1040 | \param - pAdapter Pointer to hdd adapter |
| 1041 | \param - pAPMetaInfo Pointer to access point meta info |
| 1042 | \param - scanId scan ID of batch scan response |
| 1043 | \param - isLastAp tells whether AP is last AP in batch scan response or not |
| 1044 | |
| 1045 | \return - nothing |
| 1046 | |
| 1047 | --------------------------------------------------------------------------*/ |
| 1048 | static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter, |
| 1049 | tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp) |
| 1050 | { |
| 1051 | tHddBatchScanRsp *pHead; |
| 1052 | tHddBatchScanRsp *pNode; |
| 1053 | tHddBatchScanRsp *pPrev; |
| 1054 | tHddBatchScanRsp *pTemp; |
| 1055 | tANI_U8 ssidLen; |
| 1056 | |
| 1057 | /*head of hdd batch scan response queue*/ |
| 1058 | pHead = pAdapter->pBatchScanRsp; |
| 1059 | |
| 1060 | pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp)); |
| 1061 | if (NULL == pNode) |
| 1062 | { |
| 1063 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1064 | "%s: Could not allocate memory", __func__); |
| 1065 | VOS_ASSERT(0); |
| 1066 | return; |
| 1067 | } |
| 1068 | |
| 1069 | vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid, |
| 1070 | sizeof(pNode->ApInfo.bssid)); |
| 1071 | ssidLen = strlen(pApMetaInfo->ssid); |
| 1072 | if (SIR_MAX_SSID_SIZE < ssidLen) |
| 1073 | { |
| 1074 | /*invalid scan result*/ |
| 1075 | vos_mem_free(pNode); |
| 1076 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1077 | "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen); |
| 1078 | return; |
| 1079 | } |
| 1080 | vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen); |
| 1081 | /*null terminate ssid*/ |
| 1082 | pNode->ApInfo.ssid[ssidLen] = '\0'; |
| 1083 | pNode->ApInfo.ch = pApMetaInfo->ch; |
| 1084 | pNode->ApInfo.rssi = pApMetaInfo->rssi; |
| 1085 | pNode->ApInfo.age = pApMetaInfo->timestamp; |
| 1086 | pNode->ApInfo.batchId = scanId; |
| 1087 | pNode->ApInfo.isLastAp = isLastAp; |
| 1088 | |
| 1089 | pNode->pNext = NULL; |
| 1090 | if (NULL == pHead) |
| 1091 | { |
| 1092 | pAdapter->pBatchScanRsp = pNode; |
| 1093 | } |
| 1094 | else |
| 1095 | { |
| 1096 | pTemp = pHead; |
| 1097 | while (NULL != pTemp) |
| 1098 | { |
| 1099 | pPrev = pTemp; |
| 1100 | pTemp = pTemp->pNext; |
| 1101 | } |
| 1102 | pPrev->pNext = pNode; |
| 1103 | } |
| 1104 | |
| 1105 | return; |
| 1106 | }/*End of hdd_populate_batch_scan_rsp_queue*/ |
| 1107 | |
| 1108 | /**--------------------------------------------------------------------------- |
| 1109 | |
| 1110 | \brief hdd_batch_scan_result_ind_callback () - This function is called after |
| 1111 | receiving batch scan response indication from FW. It saves get batch scan |
| 1112 | response data in HDD batch scan response queue. This callback sets the |
| 1113 | completion event on which hdd_ioctl is waiting only after getting complete |
| 1114 | batch scan response data from FW |
| 1115 | |
| 1116 | \param - callbackContext Pointer to HDD adapter |
| 1117 | \param - pRsp Pointer to get batch scan response data received from FW |
| 1118 | |
| 1119 | \return - nothing |
| 1120 | |
| 1121 | --------------------------------------------------------------------------*/ |
| 1122 | static void hdd_batch_scan_result_ind_callback |
| 1123 | ( |
| 1124 | void *callbackContext, |
| 1125 | void *pRsp |
| 1126 | ) |
| 1127 | { |
| 1128 | v_BOOL_t isLastAp; |
| 1129 | tANI_U32 numApMetaInfo; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1130 | tANI_U32 numNetworkInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1131 | tANI_U32 numberScanList; |
| 1132 | tANI_U32 nextScanListOffset; |
| 1133 | tANI_U32 nextApMetaInfoOffset; |
| 1134 | hdd_adapter_t* pAdapter; |
| 1135 | tpSirBatchScanList pScanList; |
| 1136 | tpSirBatchScanNetworkInfo pApMetaInfo; |
| 1137 | tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/ |
| 1138 | tSirSetBatchScanReq *pReq; |
| 1139 | |
| 1140 | pAdapter = (hdd_adapter_t *)callbackContext; |
| 1141 | /*sanity check*/ |
Rajeev Kumar | 5286bb9 | 2013-12-05 11:52:10 -0800 | [diff] [blame] | 1142 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1143 | { |
| 1144 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1145 | "%s: Invalid pAdapter magic", __func__); |
| 1146 | VOS_ASSERT(0); |
| 1147 | return; |
| 1148 | } |
| 1149 | |
| 1150 | /*initialize locals*/ |
| 1151 | pReq = &pAdapter->hddSetBatchScanReq; |
| 1152 | pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp; |
| 1153 | isLastAp = FALSE; |
| 1154 | numApMetaInfo = 0; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1155 | numNetworkInScanList = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1156 | numberScanList = 0; |
| 1157 | nextScanListOffset = 0; |
| 1158 | nextApMetaInfoOffset = 0; |
| 1159 | pScanList = NULL; |
| 1160 | pApMetaInfo = NULL; |
| 1161 | |
| 1162 | if ((NULL == pBatchScanRsp) || (NULL == pReq)) |
| 1163 | { |
| 1164 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1165 | "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq); |
| 1166 | isLastAp = TRUE; |
| 1167 | goto done; |
| 1168 | } |
| 1169 | |
| 1170 | pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists; |
| 1171 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1172 | "Batch scan rsp: numberScalList %d", numberScanList); |
| 1173 | |
| 1174 | if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch)) |
| 1175 | { |
| 1176 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1177 | "%s: numberScanList %d", __func__, numberScanList); |
| 1178 | isLastAp = TRUE; |
| 1179 | goto done; |
| 1180 | } |
| 1181 | |
| 1182 | while (numberScanList) |
| 1183 | { |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1184 | pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults + |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1185 | nextScanListOffset); |
| 1186 | if (NULL == pScanList) |
| 1187 | { |
| 1188 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1189 | "%s: pScanList is %p", __func__, pScanList); |
| 1190 | isLastAp = TRUE; |
| 1191 | goto done; |
| 1192 | } |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1193 | numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1194 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1195 | "Batch scan rsp: numApMetaInfo %d scanId %d", |
| 1196 | numApMetaInfo, pScanList->scanId); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1197 | |
| 1198 | if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork)) |
| 1199 | { |
| 1200 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1201 | "%s: numApMetaInfo %d", __func__, numApMetaInfo); |
| 1202 | isLastAp = TRUE; |
| 1203 | goto done; |
| 1204 | } |
| 1205 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1206 | /*Initialize next AP meta info offset for next scan list*/ |
| 1207 | nextApMetaInfoOffset = 0; |
| 1208 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1209 | while (numApMetaInfo) |
| 1210 | { |
| 1211 | pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList + |
| 1212 | nextApMetaInfoOffset); |
| 1213 | if (NULL == pApMetaInfo) |
| 1214 | { |
| 1215 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1216 | "%s: pApMetaInfo is %p", __func__, pApMetaInfo); |
| 1217 | isLastAp = TRUE; |
| 1218 | goto done; |
| 1219 | } |
| 1220 | /*calculate AP age*/ |
| 1221 | pApMetaInfo->timestamp = |
| 1222 | pBatchScanRsp->timestamp - pApMetaInfo->timestamp; |
| 1223 | |
| 1224 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1225 | "%s: bssId "MAC_ADDRESS_STR |
| 1226 | " ch %d rssi %d timestamp %d", __func__, |
| 1227 | MAC_ADDR_ARRAY(pApMetaInfo->bssid), |
| 1228 | pApMetaInfo->ch, pApMetaInfo->rssi, |
| 1229 | pApMetaInfo->timestamp); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1230 | |
| 1231 | /*mark last AP in batch scan response*/ |
| 1232 | if ((TRUE == pBatchScanRsp->isLastResult) && |
| 1233 | (1 == numberScanList) && (1 == numApMetaInfo)) |
| 1234 | { |
| 1235 | isLastAp = TRUE; |
| 1236 | } |
| 1237 | |
| 1238 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1239 | /*store batch scan repsonse in hdd queue*/ |
| 1240 | hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo, |
| 1241 | pScanList->scanId, isLastAp); |
| 1242 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1243 | |
| 1244 | nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo); |
| 1245 | numApMetaInfo--; |
| 1246 | } |
| 1247 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1248 | nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8)) |
| 1249 | + (sizeof(tSirBatchScanNetworkInfo) |
| 1250 | * numNetworkInScanList)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1251 | numberScanList--; |
| 1252 | } |
| 1253 | |
| 1254 | done: |
| 1255 | |
| 1256 | /*notify hdd_ioctl only if complete batch scan rsp is received and it was |
| 1257 | requested from hdd_ioctl*/ |
| 1258 | if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) && |
| 1259 | (TRUE == isLastAp)) |
| 1260 | { |
| 1261 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1262 | complete(&pAdapter->hdd_get_batch_scan_req_var); |
| 1263 | } |
| 1264 | |
| 1265 | return; |
| 1266 | }/*End of hdd_batch_scan_result_ind_callback*/ |
| 1267 | |
| 1268 | /**--------------------------------------------------------------------------- |
| 1269 | |
| 1270 | \brief hdd_format_batch_scan_rsp () - This function formats batch scan |
| 1271 | response as per batch scan FR request format by putting proper markers |
| 1272 | |
| 1273 | \param - pDest pointer to destination buffer |
| 1274 | \param - cur_len current length |
| 1275 | \param - tot_len total remaining size which can be written to user space |
| 1276 | \param - pApMetaInfo Pointer to get batch scan response AP meta info |
| 1277 | \param - pAdapter Pointer to HDD adapter |
| 1278 | |
| 1279 | \return - ret no of characters written |
| 1280 | |
| 1281 | --------------------------------------------------------------------------*/ |
| 1282 | static tANI_U32 |
| 1283 | hdd_format_batch_scan_rsp |
| 1284 | ( |
| 1285 | tANI_U8 *pDest, |
| 1286 | tANI_U32 cur_len, |
| 1287 | tANI_U32 tot_len, |
| 1288 | tHddBatchScanRsp *pApMetaInfo, |
| 1289 | hdd_adapter_t* pAdapter |
| 1290 | ) |
| 1291 | { |
| 1292 | tANI_U32 ret = 0; |
| 1293 | tANI_U32 rem_len = 0; |
| 1294 | tANI_U8 temp_len = 0; |
| 1295 | tANI_U8 temp_total_len = 0; |
| 1296 | tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE]; |
| 1297 | tANI_U8 *pTemp = temp; |
| 1298 | |
| 1299 | /*Batch scan reponse needs to be returned to user space in |
| 1300 | following format: |
| 1301 | "scancount=X\n" where X is the number of scans in current batch |
| 1302 | batch |
| 1303 | "trunc\n" optional present if current scan truncated |
| 1304 | "bssid=XX:XX:XX:XX:XX:XX\n" |
| 1305 | "ssid=XXXX\n" |
| 1306 | "freq=X\n" frequency in Mhz |
| 1307 | "level=XX\n" |
| 1308 | "age=X\n" ms |
| 1309 | "dist=X\n" cm (-1 if not available) |
| 1310 | "errror=X\n" (-1if not available) |
| 1311 | "====\n" (end of ap marker) |
| 1312 | "####\n" (end of scan marker) |
| 1313 | "----\n" (end of results)*/ |
| 1314 | /*send scan result in above format to user space based on |
| 1315 | available length*/ |
| 1316 | /*The GET response may have more data than the driver can return in its |
| 1317 | buffer. In that case the buffer should be filled to the nearest complete |
| 1318 | scan, ending with "%%%%".Subsequent callsshould return the remaining data |
| 1319 | starting with the next scan (optional .trunc\n., .apcount=X\n., etc). |
| 1320 | The final buffer should end with "----\n"*/ |
| 1321 | |
| 1322 | /*sanity*/ |
| 1323 | if (cur_len > tot_len) |
| 1324 | { |
| 1325 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1326 | "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len); |
| 1327 | return 0; |
| 1328 | } |
| 1329 | else |
| 1330 | { |
| 1331 | rem_len = (tot_len - cur_len); |
| 1332 | } |
| 1333 | |
| 1334 | /*end scan marker*/ |
| 1335 | if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id) |
| 1336 | { |
| 1337 | temp_len = snprintf(pTemp, sizeof(temp), "####\n"); |
| 1338 | pTemp += temp_len; |
| 1339 | temp_total_len += temp_len; |
| 1340 | } |
| 1341 | |
| 1342 | /*bssid*/ |
| 1343 | temp_len = snprintf(pTemp, sizeof(temp), |
| 1344 | "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", |
| 1345 | pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1], |
| 1346 | pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3], |
| 1347 | pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]); |
| 1348 | pTemp += temp_len; |
| 1349 | temp_total_len += temp_len; |
| 1350 | |
| 1351 | /*ssid*/ |
| 1352 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n", |
| 1353 | pApMetaInfo->ApInfo.ssid); |
| 1354 | pTemp += temp_len; |
| 1355 | temp_total_len += temp_len; |
| 1356 | |
| 1357 | /*freq*/ |
| 1358 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n", |
Rajeev Kumar | c40f751 | 2013-11-04 14:13:23 -0800 | [diff] [blame] | 1359 | sme_ChnToFreq(pApMetaInfo->ApInfo.ch)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1360 | pTemp += temp_len; |
| 1361 | temp_total_len += temp_len; |
| 1362 | |
| 1363 | /*level*/ |
| 1364 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n", |
| 1365 | pApMetaInfo->ApInfo.rssi); |
| 1366 | pTemp += temp_len; |
| 1367 | temp_total_len += temp_len; |
| 1368 | |
| 1369 | /*age*/ |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1370 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n", |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1371 | pApMetaInfo->ApInfo.age); |
| 1372 | pTemp += temp_len; |
| 1373 | temp_total_len += temp_len; |
| 1374 | |
| 1375 | /*dist*/ |
| 1376 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n"); |
| 1377 | pTemp += temp_len; |
| 1378 | temp_total_len += temp_len; |
| 1379 | |
| 1380 | /*error*/ |
| 1381 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n"); |
| 1382 | pTemp += temp_len; |
| 1383 | temp_total_len += temp_len; |
| 1384 | |
| 1385 | /*end AP marker*/ |
| 1386 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n"); |
| 1387 | pTemp += temp_len; |
| 1388 | temp_total_len += temp_len; |
| 1389 | |
| 1390 | /*last AP in batch scan response*/ |
| 1391 | if(TRUE == pApMetaInfo->ApInfo.isLastAp) |
| 1392 | { |
| 1393 | /*end scan marker*/ |
| 1394 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n"); |
| 1395 | pTemp += temp_len; |
| 1396 | temp_total_len += temp_len; |
| 1397 | |
| 1398 | /*end batch scan result marker*/ |
| 1399 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n"); |
| 1400 | pTemp += temp_len; |
| 1401 | temp_total_len += temp_len; |
Rajeev Kumar | b20d8c8 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1402 | |
| 1403 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1404 | } |
| 1405 | |
| 1406 | if (temp_total_len < rem_len) |
| 1407 | { |
| 1408 | ret = temp_total_len + 1; |
| 1409 | strlcpy(pDest, temp, ret); |
| 1410 | pAdapter->isTruncated = FALSE; |
| 1411 | } |
| 1412 | else |
| 1413 | { |
| 1414 | pAdapter->isTruncated = TRUE; |
| 1415 | if (rem_len >= strlen("%%%%")) |
| 1416 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1417 | ret = snprintf(pDest, sizeof(temp), "%%%%"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1418 | } |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1419 | else |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1420 | { |
| 1421 | ret = 0; |
| 1422 | } |
| 1423 | } |
| 1424 | |
| 1425 | return ret; |
| 1426 | |
| 1427 | }/*End of hdd_format_batch_scan_rsp*/ |
| 1428 | |
| 1429 | /**--------------------------------------------------------------------------- |
| 1430 | |
| 1431 | \brief hdd_populate_user_batch_scan_rsp() - This function populates user data |
| 1432 | buffer starting with head of hdd batch scan response queue |
| 1433 | |
| 1434 | \param - pAdapter Pointer to HDD adapter |
| 1435 | \param - pDest Pointer to user data buffer |
| 1436 | \param - cur_len current offset in user buffer |
| 1437 | \param - rem_len remaining no of bytes in user buffer |
| 1438 | |
| 1439 | \return - number of bytes written in user buffer |
| 1440 | |
| 1441 | --------------------------------------------------------------------------*/ |
| 1442 | |
| 1443 | tANI_U32 hdd_populate_user_batch_scan_rsp |
| 1444 | ( |
| 1445 | hdd_adapter_t* pAdapter, |
| 1446 | tANI_U8 *pDest, |
| 1447 | tANI_U32 cur_len, |
| 1448 | tANI_U32 rem_len |
| 1449 | ) |
| 1450 | { |
| 1451 | tHddBatchScanRsp *pHead; |
| 1452 | tHddBatchScanRsp *pPrev; |
| 1453 | tANI_U32 len; |
| 1454 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1455 | pAdapter->isTruncated = FALSE; |
| 1456 | |
| 1457 | /*head of hdd batch scan response queue*/ |
| 1458 | pHead = pAdapter->pBatchScanRsp; |
| 1459 | while (pHead) |
| 1460 | { |
| 1461 | len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead, |
| 1462 | pAdapter); |
| 1463 | pDest += len; |
Rajeev Kumar | 292d2bb | 2013-10-23 15:01:44 -0700 | [diff] [blame] | 1464 | pDest--; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1465 | cur_len += len; |
| 1466 | if(TRUE == pAdapter->isTruncated) |
| 1467 | { |
| 1468 | /*result is truncated return rest of scan rsp in next req*/ |
| 1469 | cur_len = rem_len; |
| 1470 | break; |
| 1471 | } |
| 1472 | pPrev = pHead; |
| 1473 | pHead = pHead->pNext; |
| 1474 | pAdapter->pBatchScanRsp = pHead; |
| 1475 | pAdapter->prev_batch_id = pPrev->ApInfo.batchId; |
| 1476 | vos_mem_free(pPrev); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 1477 | pPrev = NULL; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1478 | } |
| 1479 | |
| 1480 | return cur_len; |
| 1481 | }/*End of hdd_populate_user_batch_scan_rsp*/ |
| 1482 | |
| 1483 | /**--------------------------------------------------------------------------- |
| 1484 | |
| 1485 | \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch |
| 1486 | scan response data from HDD queue to user space |
| 1487 | It does following in detail: |
| 1488 | a) if HDD has enough data in its queue then it 1st copies data to user |
| 1489 | space and then send get batch scan indication message to FW. In this |
| 1490 | case it does not wait on any event and batch scan response data will |
| 1491 | be populated in HDD response queue in MC thread context after receiving |
| 1492 | indication from FW |
| 1493 | b) else send get batch scan indication message to FW and wait on an event |
| 1494 | which will be set once HDD receives complete batch scan response from |
| 1495 | FW and then this function returns batch scan response to user space |
| 1496 | |
| 1497 | \param - pAdapter Pointer to HDD adapter |
| 1498 | \param - pPrivData Pointer to priv_data |
| 1499 | |
| 1500 | \return - 0 for success -EFAULT for failure |
| 1501 | |
| 1502 | --------------------------------------------------------------------------*/ |
| 1503 | |
| 1504 | int hdd_return_batch_scan_rsp_to_user |
| 1505 | ( |
| 1506 | hdd_adapter_t* pAdapter, |
| 1507 | hdd_priv_data_t *pPrivData, |
| 1508 | tANI_U8 *command |
| 1509 | ) |
| 1510 | { |
| 1511 | tANI_U8 *pDest; |
| 1512 | tANI_U32 count = 0; |
| 1513 | tANI_U32 len = 0; |
| 1514 | tANI_U32 cur_len = 0; |
| 1515 | tANI_U32 rem_len = 0; |
| 1516 | eHalStatus halStatus; |
| 1517 | unsigned long rc; |
| 1518 | tSirTriggerBatchScanResultInd *pReq; |
| 1519 | |
| 1520 | pReq = &pAdapter->hddTriggerBatchScanResultInd; |
| 1521 | pReq->param = 0;/*batch scan client*/ |
| 1522 | pDest = (tANI_U8 *)(command + pPrivData->used_len); |
| 1523 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1524 | |
| 1525 | cur_len = pPrivData->used_len; |
| 1526 | if (pPrivData->total_len > pPrivData->used_len) |
| 1527 | { |
| 1528 | rem_len = pPrivData->total_len - pPrivData->used_len; |
| 1529 | } |
| 1530 | else |
| 1531 | { |
| 1532 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1533 | "%s: Invalid user data buffer total_len %d used_len %d", |
| 1534 | __func__, pPrivData->total_len, pPrivData->used_len); |
| 1535 | return -EFAULT; |
| 1536 | } |
| 1537 | |
| 1538 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1539 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1540 | cur_len, rem_len); |
| 1541 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1542 | |
| 1543 | /*enough scan result available in cache to return to user space or |
| 1544 | scan result needs to be fetched 1st from fw and then return*/ |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1545 | if (len == cur_len) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1546 | { |
| 1547 | pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE; |
| 1548 | halStatus = sme_TriggerBatchScanResultInd( |
| 1549 | WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1550 | pAdapter->sessionId, hdd_batch_scan_result_ind_callback, |
| 1551 | pAdapter); |
| 1552 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1553 | { |
| 1554 | if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) |
| 1555 | { |
| 1556 | INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var); |
| 1557 | rc = wait_for_completion_timeout( |
| 1558 | &pAdapter->hdd_get_batch_scan_req_var, |
| 1559 | msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT)); |
| 1560 | if (0 == rc) |
| 1561 | { |
| 1562 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1563 | "%s: Timeout waiting to fetch batch scan rsp from fw", |
| 1564 | __func__); |
| 1565 | return -EFAULT; |
| 1566 | } |
| 1567 | } |
| 1568 | |
| 1569 | len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE, |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1570 | "scancount=%u\n", pAdapter->numScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1571 | pDest += len; |
| 1572 | cur_len += len; |
| 1573 | |
| 1574 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1575 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1576 | cur_len, rem_len); |
| 1577 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1578 | |
| 1579 | count = 0; |
| 1580 | len = (len - pPrivData->used_len); |
| 1581 | pDest = (command + pPrivData->used_len); |
| 1582 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1583 | "NEW BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1584 | while(count < len) |
| 1585 | { |
| 1586 | printk("%c", *(pDest + count)); |
| 1587 | count++; |
| 1588 | } |
| 1589 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1590 | "%s: copy %d data to user buffer", __func__, len); |
| 1591 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1592 | { |
| 1593 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1594 | "%s: failed to copy data to user buffer", __func__); |
| 1595 | return -EFAULT; |
| 1596 | } |
| 1597 | } |
| 1598 | else |
| 1599 | { |
| 1600 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1601 | "sme_GetBatchScanScan returned failure halStatus %d", |
| 1602 | halStatus); |
| 1603 | return -EINVAL; |
| 1604 | } |
| 1605 | } |
| 1606 | else |
| 1607 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1608 | count = 0; |
| 1609 | len = (len - pPrivData->used_len); |
| 1610 | pDest = (command + pPrivData->used_len); |
| 1611 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1612 | "REMAINING TRUNCATED BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1613 | while(count < len) |
| 1614 | { |
| 1615 | printk("%c", *(pDest + count)); |
| 1616 | count++; |
| 1617 | } |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1618 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1619 | "%s: copy %d data to user buffer", __func__, len); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1620 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1621 | { |
| 1622 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1623 | "%s: failed to copy data to user buffer", __func__); |
| 1624 | return -EFAULT; |
| 1625 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1626 | } |
| 1627 | |
| 1628 | return 0; |
| 1629 | } /*End of hdd_return_batch_scan_rsp_to_user*/ |
| 1630 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1631 | |
| 1632 | /**--------------------------------------------------------------------------- |
| 1633 | |
| 1634 | \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING |
| 1635 | IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled: |
| 1636 | WLS_BATCHING VERSION |
| 1637 | WLS_BATCHING SET |
| 1638 | WLS_BATCHING GET |
| 1639 | WLS_BATCHING STOP |
| 1640 | |
| 1641 | \param - pAdapter Pointer to HDD adapter |
| 1642 | \param - pPrivdata Pointer to priv_data |
| 1643 | \param - command Pointer to command |
| 1644 | |
| 1645 | \return - 0 for success -EFAULT for failure |
| 1646 | |
| 1647 | --------------------------------------------------------------------------*/ |
| 1648 | |
| 1649 | int hdd_handle_batch_scan_ioctl |
| 1650 | ( |
| 1651 | hdd_adapter_t *pAdapter, |
| 1652 | hdd_priv_data_t *pPrivdata, |
| 1653 | tANI_U8 *command |
| 1654 | ) |
| 1655 | { |
| 1656 | int ret = 0; |
| 1657 | |
| 1658 | if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0) |
| 1659 | { |
| 1660 | char extra[32]; |
| 1661 | tANI_U8 len = 0; |
| 1662 | tANI_U8 version = HDD_BATCH_SCAN_VERSION; |
| 1663 | |
| 1664 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1665 | { |
| 1666 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1667 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1668 | ret = -EINVAL; |
| 1669 | goto exit; |
| 1670 | } |
| 1671 | |
| 1672 | len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d", |
| 1673 | version); |
| 1674 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1675 | { |
| 1676 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1677 | "%s: failed to copy data to user buffer", __func__); |
| 1678 | ret = -EFAULT; |
| 1679 | goto exit; |
| 1680 | } |
| 1681 | ret = HDD_BATCH_SCAN_VERSION; |
| 1682 | } |
| 1683 | else if (strncmp(command, "WLS_BATCHING SET", 16) == 0) |
| 1684 | { |
| 1685 | int status; |
| 1686 | tANI_U8 *value = (command + 16); |
| 1687 | eHalStatus halStatus; |
| 1688 | unsigned long rc; |
| 1689 | tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq; |
| 1690 | tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp; |
| 1691 | |
| 1692 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1693 | { |
| 1694 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1695 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1696 | ret = -EINVAL; |
| 1697 | goto exit; |
| 1698 | } |
| 1699 | |
| 1700 | if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) && |
| 1701 | (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) && |
| 1702 | (WLAN_HDD_P2P_GO != pAdapter->device_mode) && |
| 1703 | (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode)) |
| 1704 | { |
| 1705 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1706 | "Received WLS_BATCHING SET command in invalid mode %d " |
| 1707 | "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode", |
| 1708 | pAdapter->device_mode); |
| 1709 | ret = -EINVAL; |
| 1710 | goto exit; |
| 1711 | } |
| 1712 | |
| 1713 | status = hdd_parse_set_batchscan_command(value, pReq); |
| 1714 | if (status) |
| 1715 | { |
| 1716 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1717 | "Invalid WLS_BATCHING SET command"); |
| 1718 | ret = -EINVAL; |
| 1719 | goto exit; |
| 1720 | } |
| 1721 | |
| 1722 | |
| 1723 | pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE; |
| 1724 | halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1725 | pAdapter->sessionId, hdd_set_batch_scan_req_callback, |
| 1726 | pAdapter); |
| 1727 | |
| 1728 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1729 | { |
| 1730 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1731 | "sme_SetBatchScanReq returned success halStatus %d", |
| 1732 | halStatus); |
| 1733 | if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp) |
| 1734 | { |
| 1735 | INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var); |
| 1736 | rc = wait_for_completion_timeout( |
| 1737 | &pAdapter->hdd_set_batch_scan_req_var, |
| 1738 | msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT)); |
| 1739 | if (0 == rc) |
| 1740 | { |
| 1741 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1742 | "%s: Timeout waiting for set batch scan to complete", |
| 1743 | __func__); |
| 1744 | ret = -EINVAL; |
| 1745 | goto exit; |
| 1746 | } |
| 1747 | } |
| 1748 | if ( !pRsp->nScansToBatch ) |
| 1749 | { |
| 1750 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1751 | "%s: Received set batch scan failure response from FW", |
| 1752 | __func__); |
| 1753 | ret = -EINVAL; |
| 1754 | goto exit; |
| 1755 | } |
| 1756 | /*As per the Batch Scan Framework API we should return the MIN of |
| 1757 | either MSCAN or the max # of scans firmware can cache*/ |
| 1758 | ret = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch); |
| 1759 | |
| 1760 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED; |
| 1761 | |
| 1762 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1763 | "%s: request MSCAN %d response MSCAN %d ret %d", |
| 1764 | __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, ret); |
| 1765 | } |
| 1766 | else |
| 1767 | { |
| 1768 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1769 | "sme_SetBatchScanReq returned failure halStatus %d", |
| 1770 | halStatus); |
| 1771 | ret = -EINVAL; |
| 1772 | goto exit; |
| 1773 | } |
| 1774 | } |
| 1775 | else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0) |
| 1776 | { |
| 1777 | eHalStatus halStatus; |
| 1778 | tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd; |
| 1779 | pInd->param = 0; |
| 1780 | |
| 1781 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1782 | { |
| 1783 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1784 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1785 | ret = -EINVAL; |
| 1786 | goto exit; |
| 1787 | } |
| 1788 | |
| 1789 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1790 | { |
| 1791 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1792 | "Batch scan is not yet enabled batch scan state %d", |
| 1793 | pAdapter->batchScanState); |
| 1794 | ret = -EINVAL; |
| 1795 | goto exit; |
| 1796 | } |
| 1797 | |
| 1798 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 1799 | |
| 1800 | halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd, |
| 1801 | pAdapter->sessionId); |
| 1802 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1803 | { |
| 1804 | ret = 0; |
| 1805 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1806 | "sme_StopBatchScanInd returned success halStatus %d", |
| 1807 | halStatus); |
| 1808 | } |
| 1809 | else |
| 1810 | { |
| 1811 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1812 | "sme_StopBatchScanInd returned failure halStatus %d", |
| 1813 | halStatus); |
| 1814 | ret = -EINVAL; |
| 1815 | goto exit; |
| 1816 | } |
| 1817 | } |
| 1818 | else if (strncmp(command, "WLS_BATCHING GET", 16) == 0) |
| 1819 | { |
| 1820 | tANI_U32 remain_len; |
| 1821 | |
| 1822 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1823 | { |
| 1824 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1825 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1826 | ret = -EINVAL; |
| 1827 | goto exit; |
| 1828 | } |
| 1829 | |
| 1830 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1831 | { |
| 1832 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1833 | "Batch scan is not yet enabled could not return results" |
| 1834 | "Batch Scan state %d", |
| 1835 | pAdapter->batchScanState); |
| 1836 | ret = -EINVAL; |
| 1837 | goto exit; |
| 1838 | } |
| 1839 | |
| 1840 | pPrivdata->used_len = 16; |
| 1841 | remain_len = pPrivdata->total_len - pPrivdata->used_len; |
| 1842 | if (remain_len < pPrivdata->total_len) |
| 1843 | { |
| 1844 | /*Clear previous batch scan response data if any*/ |
| 1845 | vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len); |
| 1846 | } |
| 1847 | else |
| 1848 | { |
| 1849 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1850 | "Invalid total length from user space can't fetch batch" |
| 1851 | " scan response total_len %d used_len %d remain len %d", |
| 1852 | pPrivdata->total_len, pPrivdata->used_len, remain_len); |
| 1853 | ret = -EINVAL; |
| 1854 | goto exit; |
| 1855 | } |
| 1856 | ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command); |
| 1857 | } |
| 1858 | |
| 1859 | exit: |
| 1860 | |
| 1861 | return ret; |
| 1862 | } |
| 1863 | |
| 1864 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1865 | #endif/*End of FEATURE_WLAN_BATCH_SCAN*/ |
| 1866 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1867 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 1868 | { |
| 1869 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1870 | hdd_priv_data_t priv_data; |
| 1871 | tANI_U8 *command = NULL; |
| 1872 | int ret = 0; |
| 1873 | |
| 1874 | if (NULL == pAdapter) |
| 1875 | { |
| 1876 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1877 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1878 | ret = -ENODEV; |
| 1879 | goto exit; |
| 1880 | } |
| 1881 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1882 | if ((!ifr) || (!ifr->ifr_data)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1883 | { |
| 1884 | ret = -EINVAL; |
| 1885 | goto exit; |
| 1886 | } |
| 1887 | |
Sameer Thalappil | 8ef3a0e | 2013-04-05 14:36:04 -0700 | [diff] [blame] | 1888 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 1889 | { |
| 1890 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1891 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 1892 | ret = -EBUSY; |
| 1893 | goto exit; |
| 1894 | } |
| 1895 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1896 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(hdd_priv_data_t))) |
| 1897 | { |
| 1898 | ret = -EFAULT; |
| 1899 | goto exit; |
| 1900 | } |
| 1901 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 1902 | if (priv_data.total_len <= 0 || |
| 1903 | priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN) |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 1904 | { |
| 1905 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 1906 | "%s:invalid priv_data.total_len(%d)!!!", __func__, |
| 1907 | priv_data.total_len); |
| 1908 | ret = -EINVAL; |
| 1909 | goto exit; |
| 1910 | } |
| 1911 | |
| 1912 | /* Allocate +1 for '\0' */ |
| 1913 | command = kmalloc(priv_data.total_len + 1, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1914 | if (!command) |
| 1915 | { |
| 1916 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1917 | "%s: failed to allocate memory\n", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1918 | ret = -ENOMEM; |
| 1919 | goto exit; |
| 1920 | } |
| 1921 | |
| 1922 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 1923 | { |
| 1924 | ret = -EFAULT; |
| 1925 | goto exit; |
| 1926 | } |
| 1927 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 1928 | /* Making sure the command is NUL-terminated */ |
| 1929 | command[priv_data.total_len] = '\0'; |
| 1930 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1931 | if ((SIOCDEVPRIVATE + 1) == cmd) |
| 1932 | { |
| 1933 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 1934 | |
| 1935 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 1936 | "%s: Received %s cmd from Wi-Fi GUI***", __func__, command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1937 | |
| 1938 | if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 ) |
| 1939 | { |
| 1940 | if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes, |
| 1941 | sizeof(tSirMacAddr))) |
| 1942 | { |
| 1943 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1944 | "%s: failed to copy data to user buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1945 | ret = -EFAULT; |
| 1946 | } |
| 1947 | } |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 1948 | else if(strncmp(command, "SETBAND", 7) == 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1949 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 1950 | tANI_U8 *ptr = command ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1951 | int ret = 0 ; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 1952 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1953 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 1954 | |
| 1955 | /* First 8 bytes will have "SETBAND " and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1956 | * 9 byte will have band setting value */ |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1957 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 1958 | "%s: SetBandCommand Info comm %s UL %d, TL %d", __func__, command, priv_data.used_len, priv_data.total_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1959 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 1960 | ret = hdd_setBand_helper(dev, ptr); |
| 1961 | } |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 1962 | else if(strncmp(command, "SETWMMPS", 8) == 0) |
| 1963 | { |
| 1964 | tANI_U8 *ptr = command; |
| 1965 | ret = hdd_wmmps_helper(pAdapter, ptr); |
| 1966 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1967 | else if ( strncasecmp(command, "COUNTRY", 7) == 0 ) |
| 1968 | { |
| 1969 | char *country_code; |
| 1970 | |
| 1971 | country_code = command + 8; |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 1972 | |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 1973 | INIT_COMPLETION(pAdapter->change_country_code); |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 1974 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 1975 | #ifndef CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 1976 | hdd_checkandupdate_phymode(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 1977 | #endif |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 1978 | ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 1979 | (void *)(tSmeChangeCountryCallback) |
| 1980 | wlan_hdd_change_country_code_callback, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 1981 | country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 1982 | if (eHAL_STATUS_SUCCESS == ret) |
| 1983 | { |
| 1984 | ret = wait_for_completion_interruptible_timeout( |
| 1985 | &pAdapter->change_country_code, |
| 1986 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 1987 | if (0 >= ret) |
| 1988 | { |
| 1989 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME while setting country code timed out", |
| 1990 | __func__); |
| 1991 | } |
| 1992 | } |
| 1993 | else |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1994 | { |
| 1995 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 1996 | "%s: SME Change Country code fail ret=%d", __func__, ret); |
| 1997 | ret = -EINVAL; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1998 | } |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 1999 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2000 | } |
| 2001 | /* |
| 2002 | command should be a string having format |
| 2003 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 2004 | */ |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2005 | else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2006 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2007 | tANI_U8 *ptr = command; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2008 | |
| 2009 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2010 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2011 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 2012 | ret = sapSetPreferredChannel(ptr); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2013 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2014 | else if(strncmp(command, "SETSUSPENDMODE", 14) == 0) |
| 2015 | { |
| 2016 | int suspend = 0; |
| 2017 | tANI_U8 *ptr = (tANI_U8*)command + 15; |
| 2018 | |
| 2019 | suspend = *ptr - '0'; |
| 2020 | hdd_set_wlan_suspend_mode(suspend); |
| 2021 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2022 | #ifdef WLAN_FEATURE_NEIGHBOR_ROAMING |
| 2023 | else if (strncmp(command, "SETROAMTRIGGER", 14) == 0) |
| 2024 | { |
| 2025 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2026 | tANI_S8 rssi = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2027 | tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
| 2028 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2029 | |
| 2030 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 2031 | value = value + 15; |
| 2032 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2033 | /* Convert the value from ascii to integer */ |
| 2034 | ret = kstrtos8(value, 10, &rssi); |
| 2035 | if (ret < 0) |
| 2036 | { |
| 2037 | /* If the input value is greater than max value of datatype, then also |
| 2038 | kstrtou8 fails */ |
| 2039 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2040 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | fa7157d | 2013-10-31 10:14:22 -0700 | [diff] [blame] | 2041 | __func__, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2042 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2043 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2044 | ret = -EINVAL; |
| 2045 | goto exit; |
| 2046 | } |
| 2047 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2048 | lookUpThreshold = abs(rssi); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2049 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2050 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) || |
| 2051 | (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) |
| 2052 | { |
| 2053 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2054 | "Neighbor lookup threshold value %d is out of range" |
| 2055 | " (Min: %d Max: %d)", lookUpThreshold, |
| 2056 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2057 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2058 | ret = -EINVAL; |
| 2059 | goto exit; |
| 2060 | } |
| 2061 | |
| 2062 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2063 | "%s: Received Command to Set Roam trigger" |
| 2064 | " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold); |
| 2065 | |
| 2066 | pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 2067 | status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold); |
| 2068 | if (eHAL_STATUS_SUCCESS != status) |
| 2069 | { |
| 2070 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2071 | "%s: Failed to set roam trigger, try again", __func__); |
| 2072 | ret = -EPERM; |
| 2073 | goto exit; |
| 2074 | } |
| 2075 | |
| 2076 | /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */ |
| 2077 | sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5); |
| 2078 | } |
| 2079 | else if (strncmp(command, "GETROAMTRIGGER", 14) == 0) |
| 2080 | { |
| 2081 | tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal)); |
| 2082 | int rssi = (-1) * lookUpThreshold; |
| 2083 | char extra[32]; |
| 2084 | tANI_U8 len = 0; |
| 2085 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2086 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2087 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2088 | { |
| 2089 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2090 | "%s: failed to copy data to user buffer", __func__); |
| 2091 | ret = -EFAULT; |
| 2092 | goto exit; |
| 2093 | } |
| 2094 | } |
| 2095 | else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0) |
| 2096 | { |
| 2097 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2098 | tANI_U8 roamScanPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2099 | tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2100 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2101 | /* input refresh period is in terms of seconds */ |
| 2102 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 2103 | value = value + 18; |
| 2104 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2105 | ret = kstrtou8(value, 10, &roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2106 | if (ret < 0) |
| 2107 | { |
| 2108 | /* If the input value is greater than max value of datatype, then also |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2109 | kstrtou8 fails */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2110 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2111 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2112 | __func__, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2113 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2114 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2115 | ret = -EINVAL; |
| 2116 | goto exit; |
| 2117 | } |
| 2118 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2119 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) || |
| 2120 | (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000))) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2121 | { |
| 2122 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2123 | "Roam scan period value %d is out of range" |
| 2124 | " (Min: %d Max: %d)", roamScanPeriod, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2125 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2126 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2127 | ret = -EINVAL; |
| 2128 | goto exit; |
| 2129 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2130 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2131 | |
| 2132 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2133 | "%s: Received Command to Set roam scan period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2134 | " (Empty Scan refresh period) = %d", __func__, roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2135 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2136 | pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod; |
| 2137 | sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2138 | } |
| 2139 | else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0) |
| 2140 | { |
| 2141 | tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2142 | char extra[32]; |
| 2143 | tANI_U8 len = 0; |
| 2144 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2145 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2146 | "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2147 | /* Returned value is in units of seconds */ |
| 2148 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2149 | { |
| 2150 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2151 | "%s: failed to copy data to user buffer", __func__); |
| 2152 | ret = -EFAULT; |
| 2153 | goto exit; |
| 2154 | } |
| 2155 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2156 | else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2157 | { |
| 2158 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2159 | tANI_U8 roamScanRefreshPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2160 | tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2161 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2162 | /* input refresh period is in terms of seconds */ |
| 2163 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 2164 | value = value + 25; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2165 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2166 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2167 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2168 | if (ret < 0) |
| 2169 | { |
| 2170 | /* If the input value is greater than max value of datatype, then also |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2171 | kstrtou8 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2172 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2173 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2174 | __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2175 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2176 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2177 | ret = -EINVAL; |
| 2178 | goto exit; |
| 2179 | } |
| 2180 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2181 | if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) || |
| 2182 | (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000))) |
| 2183 | { |
| 2184 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2185 | "Neighbor scan results refresh period value %d is out of range" |
| 2186 | " (Min: %d Max: %d)", roamScanRefreshPeriod, |
| 2187 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2188 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2189 | ret = -EINVAL; |
| 2190 | goto exit; |
| 2191 | } |
| 2192 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 2193 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2194 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2195 | "%s: Received Command to Set roam scan refresh period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2196 | " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2197 | |
| 2198 | pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod; |
| 2199 | sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod); |
| 2200 | } |
| 2201 | else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2202 | { |
| 2203 | tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2204 | char extra[32]; |
| 2205 | tANI_U8 len = 0; |
| 2206 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2207 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2208 | "GETROAMSCANREFRESHPERIOD", (value/1000)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2209 | /* Returned value is in units of seconds */ |
| 2210 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2211 | { |
| 2212 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2213 | "%s: failed to copy data to user buffer", __func__); |
| 2214 | ret = -EFAULT; |
| 2215 | goto exit; |
| 2216 | } |
| 2217 | } |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2218 | #ifdef FEATURE_WLAN_LFR |
| 2219 | /* SETROAMMODE */ |
| 2220 | else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0) |
| 2221 | { |
| 2222 | tANI_U8 *value = command; |
| 2223 | tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 2224 | |
| 2225 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 2226 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 2227 | |
| 2228 | /* Convert the value from ascii to integer */ |
| 2229 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 2230 | if (ret < 0) |
| 2231 | { |
| 2232 | /* If the input value is greater than max value of datatype, then also |
| 2233 | kstrtou8 fails */ |
| 2234 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2235 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2236 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2237 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2238 | ret = -EINVAL; |
| 2239 | goto exit; |
| 2240 | } |
| 2241 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 2242 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 2243 | { |
| 2244 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2245 | "Roam Mode value %d is out of range" |
| 2246 | " (Min: %d Max: %d)", roamMode, |
| 2247 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2248 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2249 | ret = -EINVAL; |
| 2250 | goto exit; |
| 2251 | } |
| 2252 | |
| 2253 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2254 | "%s: Received Command to Set Roam Mode = %d", __func__, roamMode); |
| 2255 | /* |
| 2256 | * Note that |
| 2257 | * SETROAMMODE 0 is to enable LFR while |
| 2258 | * SETROAMMODE 1 is to disable LFR, but |
| 2259 | * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable. |
| 2260 | * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled. |
| 2261 | */ |
| 2262 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2263 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 2264 | else |
| 2265 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 2266 | |
| 2267 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode; |
| 2268 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode); |
| 2269 | } |
| 2270 | /* GETROAMMODE */ |
| 2271 | else if (strncmp(priv_data.buf, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0) |
| 2272 | { |
| 2273 | tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2274 | char extra[32]; |
| 2275 | tANI_U8 len = 0; |
| 2276 | |
| 2277 | /* |
| 2278 | * roamMode value shall be inverted because the sementics is different. |
| 2279 | */ |
| 2280 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2281 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 2282 | else |
| 2283 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 2284 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2285 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2286 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2287 | { |
| 2288 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2289 | "%s: failed to copy data to user buffer", __func__); |
| 2290 | ret = -EFAULT; |
| 2291 | goto exit; |
| 2292 | } |
| 2293 | } |
| 2294 | #endif |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2295 | #endif |
| 2296 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 2297 | else if (strncmp(command, "SETROAMDELTA", 12) == 0) |
| 2298 | { |
| 2299 | tANI_U8 *value = command; |
| 2300 | tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 2301 | |
| 2302 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 2303 | value = value + 13; |
| 2304 | /* Convert the value from ascii to integer */ |
| 2305 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 2306 | if (ret < 0) |
| 2307 | { |
| 2308 | /* If the input value is greater than max value of datatype, then also |
| 2309 | kstrtou8 fails */ |
| 2310 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2311 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2312 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2313 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2314 | ret = -EINVAL; |
| 2315 | goto exit; |
| 2316 | } |
| 2317 | |
| 2318 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 2319 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) |
| 2320 | { |
| 2321 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2322 | "Roam rssi diff value %d is out of range" |
| 2323 | " (Min: %d Max: %d)", roamRssiDiff, |
| 2324 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2325 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2326 | ret = -EINVAL; |
| 2327 | goto exit; |
| 2328 | } |
| 2329 | |
| 2330 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2331 | "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff); |
| 2332 | |
| 2333 | pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff; |
| 2334 | sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff); |
| 2335 | } |
| 2336 | else if (strncmp(priv_data.buf, "GETROAMDELTA", 12) == 0) |
| 2337 | { |
| 2338 | tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal)); |
| 2339 | char extra[32]; |
| 2340 | tANI_U8 len = 0; |
| 2341 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2342 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2343 | command, roamRssiDiff); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2344 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2345 | { |
| 2346 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2347 | "%s: failed to copy data to user buffer", __func__); |
| 2348 | ret = -EFAULT; |
| 2349 | goto exit; |
| 2350 | } |
| 2351 | } |
| 2352 | #endif |
| 2353 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 2354 | else if (strncmp(command, "GETBAND", 7) == 0) |
| 2355 | { |
| 2356 | int band = -1; |
| 2357 | char extra[32]; |
| 2358 | tANI_U8 len = 0; |
| 2359 | hdd_getBand_helper(pHddCtx, &band); |
| 2360 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2361 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2362 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2363 | { |
| 2364 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2365 | "%s: failed to copy data to user buffer", __func__); |
| 2366 | ret = -EFAULT; |
| 2367 | goto exit; |
| 2368 | } |
| 2369 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2370 | else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0) |
| 2371 | { |
| 2372 | tANI_U8 *value = command; |
| 2373 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2374 | tANI_U8 numChannels = 0; |
| 2375 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2376 | |
| 2377 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 2378 | if (eHAL_STATUS_SUCCESS != status) |
| 2379 | { |
| 2380 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2381 | "%s: Failed to parse channel list information", __func__); |
| 2382 | ret = -EINVAL; |
| 2383 | goto exit; |
| 2384 | } |
| 2385 | |
| 2386 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 2387 | { |
| 2388 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2389 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 2390 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 2391 | ret = -EINVAL; |
| 2392 | goto exit; |
| 2393 | } |
| 2394 | status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList, |
| 2395 | numChannels); |
| 2396 | if (eHAL_STATUS_SUCCESS != status) |
| 2397 | { |
| 2398 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2399 | "%s: Failed to update channel list information", __func__); |
| 2400 | ret = -EINVAL; |
| 2401 | goto exit; |
| 2402 | } |
| 2403 | } |
| 2404 | else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0) |
| 2405 | { |
| 2406 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2407 | tANI_U8 numChannels = 0; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2408 | tANI_U8 j = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2409 | char extra[128] = {0}; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2410 | int len; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2411 | |
| 2412 | if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal), |
| 2413 | ChannelList, &numChannels )) |
| 2414 | { |
| 2415 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2416 | "%s: failed to get roam scan channel list", __func__); |
| 2417 | ret = -EFAULT; |
| 2418 | goto exit; |
| 2419 | } |
| 2420 | /* output channel list is of the format |
| 2421 | [Number of roam scan channels][Channel1][Channel2]... */ |
| 2422 | /* copy the number of channels in the 0th index */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2423 | len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2424 | for (j = 0; (j < numChannels); j++) |
| 2425 | { |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2426 | len += scnprintf(extra + len, sizeof(extra) - len, " %d", |
| 2427 | ChannelList[j]); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2428 | } |
| 2429 | |
| 2430 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2431 | { |
| 2432 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2433 | "%s: failed to copy data to user buffer", __func__); |
| 2434 | ret = -EFAULT; |
| 2435 | goto exit; |
| 2436 | } |
| 2437 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2438 | else if (strncmp(command, "GETCCXMODE", 10) == 0) |
| 2439 | { |
| 2440 | tANI_BOOLEAN ccxMode = sme_getIsCcxFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2441 | char extra[32]; |
| 2442 | tANI_U8 len = 0; |
| 2443 | |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2444 | /* Check if the features OKC/CCX/11R are supported simultaneously, |
| 2445 | then this operation is not permitted (return FAILURE) */ |
| 2446 | if (ccxMode && |
| 2447 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 2448 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2449 | { |
| 2450 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 2451 | "%s: OKC/CCX/11R are supported simultaneously" |
| 2452 | " hence this operation is not permitted!", __func__); |
| 2453 | ret = -EPERM; |
| 2454 | goto exit; |
| 2455 | } |
| 2456 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2457 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2458 | "GETCCXMODE", ccxMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2459 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2460 | { |
| 2461 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2462 | "%s: failed to copy data to user buffer", __func__); |
| 2463 | ret = -EFAULT; |
| 2464 | goto exit; |
| 2465 | } |
| 2466 | } |
| 2467 | else if (strncmp(command, "GETOKCMODE", 10) == 0) |
| 2468 | { |
| 2469 | tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx); |
| 2470 | char extra[32]; |
| 2471 | tANI_U8 len = 0; |
| 2472 | |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2473 | /* Check if the features OKC/CCX/11R are supported simultaneously, |
| 2474 | then this operation is not permitted (return FAILURE) */ |
| 2475 | if (okcMode && |
| 2476 | sme_getIsCcxFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
| 2477 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2478 | { |
| 2479 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 2480 | "%s: OKC/CCX/11R are supported simultaneously" |
| 2481 | " hence this operation is not permitted!", __func__); |
| 2482 | ret = -EPERM; |
| 2483 | goto exit; |
| 2484 | } |
| 2485 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2486 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2487 | "GETOKCMODE", okcMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2488 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2489 | { |
| 2490 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2491 | "%s: failed to copy data to user buffer", __func__); |
| 2492 | ret = -EFAULT; |
| 2493 | goto exit; |
| 2494 | } |
| 2495 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2496 | else if (strncmp(command, "GETFASTROAM", 11) == 0) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2497 | { |
| 2498 | tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2499 | char extra[32]; |
| 2500 | tANI_U8 len = 0; |
| 2501 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2502 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2503 | "GETFASTROAM", lfrMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2504 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2505 | { |
| 2506 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2507 | "%s: failed to copy data to user buffer", __func__); |
| 2508 | ret = -EFAULT; |
| 2509 | goto exit; |
| 2510 | } |
| 2511 | } |
| 2512 | else if (strncmp(command, "GETFASTTRANSITION", 17) == 0) |
| 2513 | { |
| 2514 | tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2515 | char extra[32]; |
| 2516 | tANI_U8 len = 0; |
| 2517 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2518 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2519 | "GETFASTTRANSITION", ft); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2520 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2521 | { |
| 2522 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2523 | "%s: failed to copy data to user buffer", __func__); |
| 2524 | ret = -EFAULT; |
| 2525 | goto exit; |
| 2526 | } |
| 2527 | } |
| 2528 | else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2529 | { |
| 2530 | tANI_U8 *value = command; |
| 2531 | tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 2532 | |
| 2533 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 2534 | value = value + 26; |
| 2535 | /* Convert the value from ascii to integer */ |
| 2536 | ret = kstrtou8(value, 10, &minTime); |
| 2537 | if (ret < 0) |
| 2538 | { |
| 2539 | /* If the input value is greater than max value of datatype, then also |
| 2540 | kstrtou8 fails */ |
| 2541 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2542 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2543 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2544 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2545 | ret = -EINVAL; |
| 2546 | goto exit; |
| 2547 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2548 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 2549 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) |
| 2550 | { |
| 2551 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2552 | "scan min channel time value %d is out of range" |
| 2553 | " (Min: %d Max: %d)", minTime, |
| 2554 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2555 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2556 | ret = -EINVAL; |
| 2557 | goto exit; |
| 2558 | } |
| 2559 | |
| 2560 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2561 | "%s: Received Command to change channel min time = %d", __func__, minTime); |
| 2562 | |
| 2563 | pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime; |
| 2564 | sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime); |
| 2565 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2566 | else if (strncmp(command, "SENDACTIONFRAME", 15) == 0) |
| 2567 | { |
| 2568 | tANI_U8 *value = command; |
| 2569 | tANI_U8 channel = 0; |
| 2570 | tANI_U8 dwellTime = 0; |
| 2571 | tANI_U8 bufLen = 0; |
| 2572 | tANI_U8 *buf = NULL; |
| 2573 | tSirMacAddr targetApBssid; |
| 2574 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2575 | struct ieee80211_channel chan; |
| 2576 | tANI_U8 finalLen = 0; |
| 2577 | tANI_U8 *finalBuf = NULL; |
| 2578 | tANI_U8 temp = 0; |
| 2579 | u64 cookie; |
| 2580 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 2581 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2582 | |
| 2583 | /* if not associated, no need to send action frame */ |
| 2584 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 2585 | { |
| 2586 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 2587 | ret = -EINVAL; |
| 2588 | goto exit; |
| 2589 | } |
| 2590 | |
| 2591 | status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel, |
| 2592 | &dwellTime, &buf, &bufLen); |
| 2593 | if (eHAL_STATUS_SUCCESS != status) |
| 2594 | { |
| 2595 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2596 | "%s: Failed to parse send action frame data", __func__); |
| 2597 | ret = -EINVAL; |
| 2598 | goto exit; |
| 2599 | } |
| 2600 | |
| 2601 | /* if the target bssid is different from currently associated AP, |
| 2602 | then no need to send action frame */ |
| 2603 | if (VOS_TRUE != vos_mem_compare(targetApBssid, |
| 2604 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 2605 | { |
| 2606 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__); |
| 2607 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2608 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2609 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2610 | goto exit; |
| 2611 | } |
| 2612 | |
| 2613 | /* if the channel number is different from operating channel then |
| 2614 | no need to send action frame */ |
| 2615 | if (channel != pHddStaCtx->conn_info.operationChannel) |
| 2616 | { |
| 2617 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2618 | "%s: channel(%d) is different from operating channel(%d)", |
| 2619 | __func__, channel, pHddStaCtx->conn_info.operationChannel); |
| 2620 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2621 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2622 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2623 | goto exit; |
| 2624 | } |
| 2625 | chan.center_freq = sme_ChnToFreq(channel); |
| 2626 | |
| 2627 | finalLen = bufLen + 24; |
| 2628 | finalBuf = vos_mem_malloc(finalLen); |
| 2629 | if (NULL == finalBuf) |
| 2630 | { |
| 2631 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__); |
| 2632 | ret = -ENOMEM; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2633 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2634 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2635 | goto exit; |
| 2636 | } |
| 2637 | vos_mem_zero(finalBuf, finalLen); |
| 2638 | |
| 2639 | /* Fill subtype */ |
| 2640 | temp = SIR_MAC_MGMT_ACTION << 4; |
| 2641 | vos_mem_copy(finalBuf + 0, &temp, sizeof(temp)); |
| 2642 | |
| 2643 | /* Fill type */ |
| 2644 | temp = SIR_MAC_MGMT_FRAME; |
| 2645 | vos_mem_copy(finalBuf + 2, &temp, sizeof(temp)); |
| 2646 | |
| 2647 | /* Fill destination address (bssid of the AP) */ |
| 2648 | vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid)); |
| 2649 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 2650 | /* Fill source address (STA mac address) */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2651 | vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes)); |
| 2652 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 2653 | /* Fill BSSID (AP mac address) */ |
| 2654 | vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid)); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2655 | |
| 2656 | /* Fill received buffer from 24th address */ |
| 2657 | vos_mem_copy(finalBuf + 24, buf, bufLen); |
| 2658 | |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2659 | /* done with the parsed buffer */ |
| 2660 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2661 | buf = NULL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2662 | |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2663 | wlan_hdd_action( NULL, |
| 2664 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2665 | &(pAdapter->wdev), |
| 2666 | #else |
| 2667 | dev, |
| 2668 | #endif |
| 2669 | &chan, 0, |
| 2670 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 2671 | NL80211_CHAN_HT20, 1, |
| 2672 | #endif |
| 2673 | dwellTime, finalBuf, finalLen, 1, |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2674 | 1, &cookie ); |
| 2675 | vos_mem_free(finalBuf); |
| 2676 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2677 | else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2678 | { |
| 2679 | tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal)); |
| 2680 | char extra[32]; |
| 2681 | tANI_U8 len = 0; |
| 2682 | |
| 2683 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2684 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2685 | "GETROAMSCANCHANNELMINTIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2686 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2687 | { |
| 2688 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2689 | "%s: failed to copy data to user buffer", __func__); |
| 2690 | ret = -EFAULT; |
| 2691 | goto exit; |
| 2692 | } |
| 2693 | } |
| 2694 | else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0) |
| 2695 | { |
| 2696 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2697 | tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2698 | |
| 2699 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 2700 | value = value + 19; |
| 2701 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2702 | ret = kstrtou16(value, 10, &maxTime); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2703 | if (ret < 0) |
| 2704 | { |
| 2705 | /* If the input value is greater than max value of datatype, then also |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2706 | kstrtou16 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2707 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2708 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2709 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 2710 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 2711 | ret = -EINVAL; |
| 2712 | goto exit; |
| 2713 | } |
| 2714 | |
| 2715 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 2716 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) |
| 2717 | { |
| 2718 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2719 | "lfr mode value %d is out of range" |
| 2720 | " (Min: %d Max: %d)", maxTime, |
| 2721 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 2722 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 2723 | ret = -EINVAL; |
| 2724 | goto exit; |
| 2725 | } |
| 2726 | |
| 2727 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2728 | "%s: Received Command to change channel max time = %d", __func__, maxTime); |
| 2729 | |
| 2730 | pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime; |
| 2731 | sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime); |
| 2732 | } |
| 2733 | else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0) |
| 2734 | { |
| 2735 | tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal)); |
| 2736 | char extra[32]; |
| 2737 | tANI_U8 len = 0; |
| 2738 | |
| 2739 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2740 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2741 | "GETSCANCHANNELTIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2742 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2743 | { |
| 2744 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2745 | "%s: failed to copy data to user buffer", __func__); |
| 2746 | ret = -EFAULT; |
| 2747 | goto exit; |
| 2748 | } |
| 2749 | } |
| 2750 | else if (strncmp(command, "SETSCANHOMETIME", 15) == 0) |
| 2751 | { |
| 2752 | tANI_U8 *value = command; |
| 2753 | tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 2754 | |
| 2755 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 2756 | value = value + 16; |
| 2757 | /* Convert the value from ascii to integer */ |
| 2758 | ret = kstrtou16(value, 10, &val); |
| 2759 | if (ret < 0) |
| 2760 | { |
| 2761 | /* If the input value is greater than max value of datatype, then also |
| 2762 | kstrtou16 fails */ |
| 2763 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2764 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
| 2765 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 2766 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 2767 | ret = -EINVAL; |
| 2768 | goto exit; |
| 2769 | } |
| 2770 | |
| 2771 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 2772 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) |
| 2773 | { |
| 2774 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2775 | "scan home time value %d is out of range" |
| 2776 | " (Min: %d Max: %d)", val, |
| 2777 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 2778 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 2779 | ret = -EINVAL; |
| 2780 | goto exit; |
| 2781 | } |
| 2782 | |
| 2783 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2784 | "%s: Received Command to change scan home time = %d", __func__, val); |
| 2785 | |
| 2786 | pHddCtx->cfg_ini->nNeighborScanPeriod = val; |
| 2787 | sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val); |
| 2788 | } |
| 2789 | else if (strncmp(command, "GETSCANHOMETIME", 15) == 0) |
| 2790 | { |
| 2791 | tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2792 | char extra[32]; |
| 2793 | tANI_U8 len = 0; |
| 2794 | |
| 2795 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2796 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2797 | "GETSCANHOMETIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2798 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2799 | { |
| 2800 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2801 | "%s: failed to copy data to user buffer", __func__); |
| 2802 | ret = -EFAULT; |
| 2803 | goto exit; |
| 2804 | } |
| 2805 | } |
| 2806 | else if (strncmp(command, "SETROAMINTRABAND", 16) == 0) |
| 2807 | { |
| 2808 | tANI_U8 *value = command; |
| 2809 | tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 2810 | |
| 2811 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 2812 | value = value + 17; |
| 2813 | /* Convert the value from ascii to integer */ |
| 2814 | ret = kstrtou8(value, 10, &val); |
| 2815 | if (ret < 0) |
| 2816 | { |
| 2817 | /* If the input value is greater than max value of datatype, then also |
| 2818 | kstrtou8 fails */ |
| 2819 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2820 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2821 | CFG_ROAM_INTRA_BAND_MIN, |
| 2822 | CFG_ROAM_INTRA_BAND_MAX); |
| 2823 | ret = -EINVAL; |
| 2824 | goto exit; |
| 2825 | } |
| 2826 | |
| 2827 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 2828 | (val > CFG_ROAM_INTRA_BAND_MAX)) |
| 2829 | { |
| 2830 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2831 | "intra band mode value %d is out of range" |
| 2832 | " (Min: %d Max: %d)", val, |
| 2833 | CFG_ROAM_INTRA_BAND_MIN, |
| 2834 | CFG_ROAM_INTRA_BAND_MAX); |
| 2835 | ret = -EINVAL; |
| 2836 | goto exit; |
| 2837 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2838 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2839 | "%s: Received Command to change intra band = %d", __func__, val); |
| 2840 | |
| 2841 | pHddCtx->cfg_ini->nRoamIntraBand = val; |
| 2842 | sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val); |
| 2843 | } |
| 2844 | else if (strncmp(command, "GETROAMINTRABAND", 16) == 0) |
| 2845 | { |
| 2846 | tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal)); |
| 2847 | char extra[32]; |
| 2848 | tANI_U8 len = 0; |
| 2849 | |
| 2850 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2851 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2852 | "GETROAMINTRABAND", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2853 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2854 | { |
| 2855 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2856 | "%s: failed to copy data to user buffer", __func__); |
| 2857 | ret = -EFAULT; |
| 2858 | goto exit; |
| 2859 | } |
| 2860 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 2861 | else if (strncmp(command, "SETSCANNPROBES", 14) == 0) |
| 2862 | { |
| 2863 | tANI_U8 *value = command; |
| 2864 | tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 2865 | |
| 2866 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 2867 | value = value + 15; |
| 2868 | /* Convert the value from ascii to integer */ |
| 2869 | ret = kstrtou8(value, 10, &nProbes); |
| 2870 | if (ret < 0) |
| 2871 | { |
| 2872 | /* If the input value is greater than max value of datatype, then also |
| 2873 | kstrtou8 fails */ |
| 2874 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2875 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2876 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 2877 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 2878 | ret = -EINVAL; |
| 2879 | goto exit; |
| 2880 | } |
| 2881 | |
| 2882 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 2883 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) |
| 2884 | { |
| 2885 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2886 | "NProbes value %d is out of range" |
| 2887 | " (Min: %d Max: %d)", nProbes, |
| 2888 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 2889 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 2890 | ret = -EINVAL; |
| 2891 | goto exit; |
| 2892 | } |
| 2893 | |
| 2894 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2895 | "%s: Received Command to Set nProbes = %d", __func__, nProbes); |
| 2896 | |
| 2897 | pHddCtx->cfg_ini->nProbes = nProbes; |
| 2898 | sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes); |
| 2899 | } |
| 2900 | else if (strncmp(priv_data.buf, "GETSCANNPROBES", 14) == 0) |
| 2901 | { |
| 2902 | tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal)); |
| 2903 | char extra[32]; |
| 2904 | tANI_U8 len = 0; |
| 2905 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2906 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 2907 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2908 | { |
| 2909 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2910 | "%s: failed to copy data to user buffer", __func__); |
| 2911 | ret = -EFAULT; |
| 2912 | goto exit; |
| 2913 | } |
| 2914 | } |
| 2915 | else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0) |
| 2916 | { |
| 2917 | tANI_U8 *value = command; |
| 2918 | tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 2919 | |
| 2920 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 2921 | /* input value is in units of msec */ |
| 2922 | value = value + 20; |
| 2923 | /* Convert the value from ascii to integer */ |
| 2924 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 2925 | if (ret < 0) |
| 2926 | { |
| 2927 | /* If the input value is greater than max value of datatype, then also |
| 2928 | kstrtou8 fails */ |
| 2929 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2930 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2931 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 2932 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 2933 | ret = -EINVAL; |
| 2934 | goto exit; |
| 2935 | } |
| 2936 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 2937 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 2938 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) |
| 2939 | { |
| 2940 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2941 | "homeAwayTime value %d is out of range" |
| 2942 | " (Min: %d Max: %d)", homeAwayTime, |
| 2943 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 2944 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 2945 | ret = -EINVAL; |
| 2946 | goto exit; |
| 2947 | } |
| 2948 | |
| 2949 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2950 | "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime); |
Srinivas Girigowda | 6cf0b82 | 2013-06-27 14:00:20 -0700 | [diff] [blame] | 2951 | if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime) |
| 2952 | { |
| 2953 | pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime; |
| 2954 | sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE); |
| 2955 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 2956 | } |
| 2957 | else if (strncmp(priv_data.buf, "GETSCANHOMEAWAYTIME", 19) == 0) |
| 2958 | { |
| 2959 | tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal)); |
| 2960 | char extra[32]; |
| 2961 | tANI_U8 len = 0; |
| 2962 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2963 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 2964 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2965 | { |
| 2966 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2967 | "%s: failed to copy data to user buffer", __func__); |
| 2968 | ret = -EFAULT; |
| 2969 | goto exit; |
| 2970 | } |
| 2971 | } |
| 2972 | else if (strncmp(command, "REASSOC", 7) == 0) |
| 2973 | { |
| 2974 | tANI_U8 *value = command; |
| 2975 | tANI_U8 channel = 0; |
| 2976 | tSirMacAddr targetApBssid; |
| 2977 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 2978 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2979 | tCsrHandoffRequest handoffInfo; |
| 2980 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 2981 | hdd_station_ctx_t *pHddStaCtx = NULL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 2982 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2983 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 2984 | /* if not associated, no need to proceed with reassoc */ |
| 2985 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 2986 | { |
| 2987 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 2988 | ret = -EINVAL; |
| 2989 | goto exit; |
| 2990 | } |
| 2991 | |
| 2992 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
| 2993 | if (eHAL_STATUS_SUCCESS != status) |
| 2994 | { |
| 2995 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2996 | "%s: Failed to parse reassoc command data", __func__); |
| 2997 | ret = -EINVAL; |
| 2998 | goto exit; |
| 2999 | } |
| 3000 | |
| 3001 | /* if the target bssid is same as currently associated AP, |
| 3002 | then no need to proceed with reassoc */ |
| 3003 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3004 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3005 | { |
| 3006 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__); |
| 3007 | ret = -EINVAL; |
| 3008 | goto exit; |
| 3009 | } |
| 3010 | |
| 3011 | /* Check channel number is a valid channel number */ |
| 3012 | if(VOS_STATUS_SUCCESS != |
| 3013 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3014 | { |
| 3015 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3016 | "%s: Invalid Channel [%d]", __func__, channel); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3017 | return -EINVAL; |
| 3018 | } |
| 3019 | |
| 3020 | /* Proceed with reassoc */ |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3021 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3022 | handoffInfo.channel = channel; |
| 3023 | vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr)); |
| 3024 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 3025 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3026 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3027 | else if (strncmp(command, "SETWESMODE", 10) == 0) |
| 3028 | { |
| 3029 | tANI_U8 *value = command; |
| 3030 | tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 3031 | |
| 3032 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 3033 | value = value + 11; |
| 3034 | /* Convert the value from ascii to integer */ |
| 3035 | ret = kstrtou8(value, 10, &wesMode); |
| 3036 | if (ret < 0) |
| 3037 | { |
| 3038 | /* If the input value is greater than max value of datatype, then also |
| 3039 | kstrtou8 fails */ |
| 3040 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3041 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3042 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3043 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3044 | ret = -EINVAL; |
| 3045 | goto exit; |
| 3046 | } |
| 3047 | |
| 3048 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 3049 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) |
| 3050 | { |
| 3051 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3052 | "WES Mode value %d is out of range" |
| 3053 | " (Min: %d Max: %d)", wesMode, |
| 3054 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3055 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3056 | ret = -EINVAL; |
| 3057 | goto exit; |
| 3058 | } |
| 3059 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3060 | "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode); |
| 3061 | |
| 3062 | pHddCtx->cfg_ini->isWESModeEnabled = wesMode; |
| 3063 | sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode); |
| 3064 | } |
| 3065 | else if (strncmp(priv_data.buf, "GETWESMODE", 10) == 0) |
| 3066 | { |
| 3067 | tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal)); |
| 3068 | char extra[32]; |
| 3069 | tANI_U8 len = 0; |
| 3070 | |
Arif Hussain | 826d941 | 2013-11-12 16:44:54 -0800 | [diff] [blame] | 3071 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3072 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3073 | { |
| 3074 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3075 | "%s: failed to copy data to user buffer", __func__); |
| 3076 | ret = -EFAULT; |
| 3077 | goto exit; |
| 3078 | } |
| 3079 | } |
| 3080 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_CCX || FEATURE_WLAN_LFR */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3081 | #ifdef FEATURE_WLAN_LFR |
| 3082 | else if (strncmp(command, "SETFASTROAM", 11) == 0) |
| 3083 | { |
| 3084 | tANI_U8 *value = command; |
| 3085 | tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 3086 | |
| 3087 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3088 | value = value + 12; |
| 3089 | /* Convert the value from ascii to integer */ |
| 3090 | ret = kstrtou8(value, 10, &lfrMode); |
| 3091 | if (ret < 0) |
| 3092 | { |
| 3093 | /* If the input value is greater than max value of datatype, then also |
| 3094 | kstrtou8 fails */ |
| 3095 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3096 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3097 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3098 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3099 | ret = -EINVAL; |
| 3100 | goto exit; |
| 3101 | } |
| 3102 | |
| 3103 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 3104 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 3105 | { |
| 3106 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3107 | "lfr mode value %d is out of range" |
| 3108 | " (Min: %d Max: %d)", lfrMode, |
| 3109 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3110 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3111 | ret = -EINVAL; |
| 3112 | goto exit; |
| 3113 | } |
| 3114 | |
| 3115 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3116 | "%s: Received Command to change lfr mode = %d", __func__, lfrMode); |
| 3117 | |
| 3118 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode; |
| 3119 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode); |
| 3120 | } |
| 3121 | #endif |
| 3122 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 3123 | else if (strncmp(command, "SETFASTTRANSITION", 17) == 0) |
| 3124 | { |
| 3125 | tANI_U8 *value = command; |
| 3126 | tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 3127 | |
| 3128 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3129 | value = value + 18; |
| 3130 | /* Convert the value from ascii to integer */ |
| 3131 | ret = kstrtou8(value, 10, &ft); |
| 3132 | if (ret < 0) |
| 3133 | { |
| 3134 | /* If the input value is greater than max value of datatype, then also |
| 3135 | kstrtou8 fails */ |
| 3136 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3137 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3138 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3139 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3140 | ret = -EINVAL; |
| 3141 | goto exit; |
| 3142 | } |
| 3143 | |
| 3144 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 3145 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) |
| 3146 | { |
| 3147 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3148 | "ft mode value %d is out of range" |
| 3149 | " (Min: %d Max: %d)", ft, |
| 3150 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3151 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3152 | ret = -EINVAL; |
| 3153 | goto exit; |
| 3154 | } |
| 3155 | |
| 3156 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3157 | "%s: Received Command to change ft mode = %d", __func__, ft); |
| 3158 | |
| 3159 | pHddCtx->cfg_ini->isFastTransitionEnabled = ft; |
| 3160 | sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft); |
| 3161 | } |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3162 | |
| 3163 | else if (strncmp(command, "FASTREASSOC", 11) == 0) |
| 3164 | { |
| 3165 | tANI_U8 *value = command; |
| 3166 | tSirMacAddr targetApBssid; |
| 3167 | tANI_U8 trigger = 0; |
| 3168 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3169 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3170 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3171 | |
| 3172 | /* if not associated, no need to proceed with reassoc */ |
| 3173 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3174 | { |
| 3175 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3176 | ret = -EINVAL; |
| 3177 | goto exit; |
| 3178 | } |
| 3179 | |
| 3180 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &trigger); |
| 3181 | if (eHAL_STATUS_SUCCESS != status) |
| 3182 | { |
| 3183 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3184 | "%s: Failed to parse reassoc command data", __func__); |
| 3185 | ret = -EINVAL; |
| 3186 | goto exit; |
| 3187 | } |
| 3188 | |
| 3189 | /* if the target bssid is same as currently associated AP, |
| 3190 | then no need to proceed with reassoc */ |
| 3191 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3192 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3193 | { |
| 3194 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3195 | "%s:11r Reassoc BSSID is same as currently associated AP bssid", |
| 3196 | __func__); |
| 3197 | ret = -EINVAL; |
| 3198 | goto exit; |
| 3199 | } |
| 3200 | |
| 3201 | /* Proceed with scan/roam */ |
| 3202 | smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3203 | &targetApBssid[0], |
| 3204 | (tSmeFastRoamTrigger)(trigger)); |
| 3205 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3206 | #endif |
| 3207 | #ifdef FEATURE_WLAN_CCX |
| 3208 | else if (strncmp(command, "SETCCXMODE", 10) == 0) |
| 3209 | { |
| 3210 | tANI_U8 *value = command; |
| 3211 | tANI_U8 ccxMode = CFG_CCX_FEATURE_ENABLED_DEFAULT; |
| 3212 | |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3213 | /* Check if the features OKC/CCX/11R are supported simultaneously, |
| 3214 | then this operation is not permitted (return FAILURE) */ |
| 3215 | if (sme_getIsCcxFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
| 3216 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3217 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3218 | { |
| 3219 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 3220 | "%s: OKC/CCX/11R are supported simultaneously" |
| 3221 | " hence this operation is not permitted!", __func__); |
| 3222 | ret = -EPERM; |
| 3223 | goto exit; |
| 3224 | } |
| 3225 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3226 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 3227 | value = value + 11; |
| 3228 | /* Convert the value from ascii to integer */ |
| 3229 | ret = kstrtou8(value, 10, &ccxMode); |
| 3230 | if (ret < 0) |
| 3231 | { |
| 3232 | /* If the input value is greater than max value of datatype, then also |
| 3233 | kstrtou8 fails */ |
| 3234 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3235 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3236 | CFG_CCX_FEATURE_ENABLED_MIN, |
| 3237 | CFG_CCX_FEATURE_ENABLED_MAX); |
| 3238 | ret = -EINVAL; |
| 3239 | goto exit; |
| 3240 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3241 | if ((ccxMode < CFG_CCX_FEATURE_ENABLED_MIN) || |
| 3242 | (ccxMode > CFG_CCX_FEATURE_ENABLED_MAX)) |
| 3243 | { |
| 3244 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3245 | "Ccx mode value %d is out of range" |
| 3246 | " (Min: %d Max: %d)", ccxMode, |
| 3247 | CFG_CCX_FEATURE_ENABLED_MIN, |
| 3248 | CFG_CCX_FEATURE_ENABLED_MAX); |
| 3249 | ret = -EINVAL; |
| 3250 | goto exit; |
| 3251 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3252 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3253 | "%s: Received Command to change ccx mode = %d", __func__, ccxMode); |
| 3254 | |
| 3255 | pHddCtx->cfg_ini->isCcxIniFeatureEnabled = ccxMode; |
| 3256 | sme_UpdateIsCcxFeatureEnabled((tHalHandle)(pHddCtx->hHal), ccxMode); |
| 3257 | } |
| 3258 | #endif |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3259 | else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0) |
| 3260 | { |
| 3261 | tANI_U8 *value = command; |
| 3262 | tANI_BOOLEAN roamScanControl = 0; |
| 3263 | |
| 3264 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 3265 | value = value + 19; |
| 3266 | /* Convert the value from ascii to integer */ |
| 3267 | ret = kstrtou8(value, 10, &roamScanControl); |
| 3268 | if (ret < 0) |
| 3269 | { |
| 3270 | /* If the input value is greater than max value of datatype, then also |
| 3271 | kstrtou8 fails */ |
| 3272 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3273 | "%s: kstrtou8 failed ", __func__); |
| 3274 | ret = -EINVAL; |
| 3275 | goto exit; |
| 3276 | } |
| 3277 | |
| 3278 | if (0 != roamScanControl) |
| 3279 | { |
| 3280 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3281 | "roam scan control invalid value = %d", |
| 3282 | roamScanControl); |
| 3283 | ret = -EINVAL; |
| 3284 | goto exit; |
| 3285 | } |
| 3286 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3287 | "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl); |
| 3288 | |
| 3289 | sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl); |
| 3290 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3291 | #ifdef FEATURE_WLAN_OKC |
| 3292 | else if (strncmp(command, "SETOKCMODE", 10) == 0) |
| 3293 | { |
| 3294 | tANI_U8 *value = command; |
| 3295 | tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 3296 | |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3297 | /* Check if the features OKC/CCX/11R are supported simultaneously, |
| 3298 | then this operation is not permitted (return FAILURE) */ |
| 3299 | if (sme_getIsCcxFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
| 3300 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3301 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3302 | { |
| 3303 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 3304 | "%s: OKC/CCX/11R are supported simultaneously" |
| 3305 | " hence this operation is not permitted!", __func__); |
| 3306 | ret = -EPERM; |
| 3307 | goto exit; |
| 3308 | } |
| 3309 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3310 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 3311 | value = value + 11; |
| 3312 | /* Convert the value from ascii to integer */ |
| 3313 | ret = kstrtou8(value, 10, &okcMode); |
| 3314 | if (ret < 0) |
| 3315 | { |
| 3316 | /* If the input value is greater than max value of datatype, then also |
| 3317 | kstrtou8 fails */ |
| 3318 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3319 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3320 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3321 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3322 | ret = -EINVAL; |
| 3323 | goto exit; |
| 3324 | } |
| 3325 | |
| 3326 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 3327 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) |
| 3328 | { |
| 3329 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3330 | "Okc mode value %d is out of range" |
| 3331 | " (Min: %d Max: %d)", okcMode, |
| 3332 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3333 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3334 | ret = -EINVAL; |
| 3335 | goto exit; |
| 3336 | } |
| 3337 | |
| 3338 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3339 | "%s: Received Command to change okc mode = %d", __func__, okcMode); |
| 3340 | |
| 3341 | pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode; |
| 3342 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3343 | #endif /* FEATURE_WLAN_OKC */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3344 | else if (strncmp(priv_data.buf, "GETROAMSCANCONTROL", 18) == 0) |
| 3345 | { |
| 3346 | tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal)); |
| 3347 | char extra[32]; |
| 3348 | tANI_U8 len = 0; |
| 3349 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3350 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3351 | command, roamScanControl); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3352 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3353 | { |
| 3354 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3355 | "%s: failed to copy data to user buffer", __func__); |
| 3356 | ret = -EFAULT; |
| 3357 | goto exit; |
| 3358 | } |
| 3359 | } |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 3360 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3361 | else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0) |
| 3362 | { |
| 3363 | tANI_U8 filterType = 0; |
| 3364 | tANI_U8 *value = command; |
| 3365 | |
| 3366 | /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */ |
| 3367 | value = value + 22; |
| 3368 | |
| 3369 | /* Convert the value from ascii to integer */ |
| 3370 | ret = kstrtou8(value, 10, &filterType); |
| 3371 | if (ret < 0) |
| 3372 | { |
| 3373 | /* If the input value is greater than max value of datatype, |
| 3374 | * then also kstrtou8 fails |
| 3375 | */ |
| 3376 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3377 | "%s: kstrtou8 failed range ", __func__); |
| 3378 | ret = -EINVAL; |
| 3379 | goto exit; |
| 3380 | } |
| 3381 | |
| 3382 | if (filterType != 0 && filterType != 1) |
| 3383 | { |
| 3384 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3385 | "%s: Accepted Values are 0 and 1 ", __func__); |
| 3386 | ret = -EINVAL; |
| 3387 | goto exit; |
| 3388 | } |
| 3389 | wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType, |
| 3390 | pAdapter->sessionId); |
| 3391 | } |
| 3392 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3393 | else if (strncmp(command, "BTCOEXMODE", 10) == 0 ) |
| 3394 | { |
| 3395 | char *dhcpPhase; |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3396 | dhcpPhase = command + 11; |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3397 | if ('1' == *dhcpPhase) |
| 3398 | { |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3399 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3400 | FL("BTCOEXMODE %d"), *dhcpPhase); |
| 3401 | |
| 3402 | pHddCtx->btCoexModeSet = TRUE; |
| 3403 | |
| 3404 | /* Firmware failing to process DHCP START/STOP indications. |
| 3405 | * So, for now commentig below code, once issue is resolved, |
| 3406 | * follwing will be uncommented. |
| 3407 | */ |
| 3408 | #if 0 |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3409 | sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode, |
| 3410 | pAdapter->macAddressCurrent.bytes); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3411 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3412 | } |
| 3413 | else if ('2' == *dhcpPhase) |
| 3414 | { |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3415 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3416 | FL("BTCOEXMODE %d"), *dhcpPhase); |
| 3417 | |
| 3418 | pHddCtx->btCoexModeSet = FALSE; |
| 3419 | |
| 3420 | /* Firmware failing to process DHCP START/STOP indications. |
| 3421 | * So, for now commentig below code, once issue is resolved, |
| 3422 | * follwing will be uncommented. |
| 3423 | */ |
| 3424 | #if 0 |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3425 | sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode, |
| 3426 | pAdapter->macAddressCurrent.bytes); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3427 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3428 | } |
| 3429 | } |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3430 | else if (strncmp(command, "SCAN-ACTIVE", 11) == 0) |
| 3431 | { |
| 3432 | pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
| 3433 | } |
| 3434 | else if (strncmp(command, "SCAN-PASSIVE", 12) == 0) |
| 3435 | { |
| 3436 | pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
| 3437 | } |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3438 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 3439 | { |
| 3440 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 3441 | char extra[32]; |
| 3442 | tANI_U8 len = 0; |
| 3443 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3444 | len = scnprintf(extra, sizeof(extra), "GETDWELLTIME %u\n", |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3445 | (int)pCfg->nActiveMaxChnTime); |
| 3446 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3447 | { |
| 3448 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3449 | "%s: failed to copy data to user buffer", __func__); |
| 3450 | ret = -EFAULT; |
| 3451 | goto exit; |
| 3452 | } |
| 3453 | ret = len; |
| 3454 | } |
| 3455 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 3456 | { |
| 3457 | tANI_U8 *value = command; |
| 3458 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 3459 | int val = 0, temp; |
| 3460 | |
| 3461 | value = value + 13; |
| 3462 | temp = kstrtou32(value, 10, &val); |
| 3463 | if ( temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 3464 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 3465 | { |
| 3466 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3467 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 3468 | ret = -EFAULT; |
| 3469 | goto exit; |
| 3470 | } |
| 3471 | pCfg->nActiveMaxChnTime = val; |
| 3472 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3473 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 3474 | { |
| 3475 | tANI_U8 filterType = 0; |
| 3476 | tANI_U8 *value; |
| 3477 | value = command + 9; |
| 3478 | |
| 3479 | /* Convert the value from ascii to integer */ |
| 3480 | ret = kstrtou8(value, 10, &filterType); |
| 3481 | if (ret < 0) |
| 3482 | { |
| 3483 | /* If the input value is greater than max value of datatype, |
| 3484 | * then also kstrtou8 fails |
| 3485 | */ |
| 3486 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3487 | "%s: kstrtou8 failed range ", __func__); |
| 3488 | ret = -EINVAL; |
| 3489 | goto exit; |
| 3490 | } |
| 3491 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 3492 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 3493 | { |
| 3494 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3495 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 3496 | " 2-Sink ", __func__); |
| 3497 | ret = -EINVAL; |
| 3498 | goto exit; |
| 3499 | } |
| 3500 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 3501 | pHddCtx->drvr_miracast = filterType; |
| 3502 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
| 3503 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3504 | else if (strncmp(command, "SETMCRATE", 9) == 0) |
| 3505 | { |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3506 | tANI_U8 *value = command; |
| 3507 | int targetRate; |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3508 | tSirRateUpdateInd *rateUpdate; |
| 3509 | eHalStatus status; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3510 | |
| 3511 | /* Only valid for SAP mode */ |
| 3512 | if (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
| 3513 | { |
| 3514 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3515 | "%s: SAP mode is not running", __func__); |
| 3516 | ret = -EFAULT; |
| 3517 | goto exit; |
| 3518 | } |
| 3519 | |
| 3520 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 3521 | /* input value is in units of hundred kbps */ |
| 3522 | value = value + 10; |
| 3523 | /* Convert the value from ascii to integer, decimal base */ |
| 3524 | ret = kstrtouint(value, 10, &targetRate); |
| 3525 | |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3526 | rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 3527 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3528 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3529 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3530 | "%s: SETMCRATE indication alloc fail", __func__); |
| 3531 | ret = -EFAULT; |
| 3532 | goto exit; |
| 3533 | } |
| 3534 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 3535 | |
| 3536 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3537 | "MC Target rate %d", targetRate); |
| 3538 | /* Ignore unicast */ |
| 3539 | rateUpdate->ucastDataRate = -1; |
| 3540 | rateUpdate->mcastDataRate24GHz = targetRate; |
| 3541 | rateUpdate->mcastDataRate5GHz = targetRate; |
| 3542 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 3543 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 3544 | status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate); |
| 3545 | if (eHAL_STATUS_SUCCESS != status) |
| 3546 | { |
| 3547 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3548 | "%s: SET_MC_RATE failed", __func__); |
| 3549 | vos_mem_free(rateUpdate); |
| 3550 | ret = -EFAULT; |
| 3551 | goto exit; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3552 | } |
| 3553 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3554 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3555 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3556 | { |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3557 | ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3558 | } |
| 3559 | #endif |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3560 | #if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD) |
| 3561 | else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0) |
| 3562 | { |
| 3563 | tANI_U8 *value = command; |
| 3564 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3565 | tANI_U8 numChannels = 0; |
| 3566 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3567 | |
| 3568 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 3569 | if (eHAL_STATUS_SUCCESS != status) |
| 3570 | { |
| 3571 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3572 | "%s: Failed to parse channel list information", __func__); |
| 3573 | ret = -EINVAL; |
| 3574 | goto exit; |
| 3575 | } |
| 3576 | |
| 3577 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 3578 | { |
| 3579 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3580 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 3581 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3582 | ret = -EINVAL; |
| 3583 | goto exit; |
| 3584 | } |
| 3585 | status = sme_SetCcxRoamScanChannelList((tHalHandle)(pHddCtx->hHal), |
| 3586 | ChannelList, |
| 3587 | numChannels); |
| 3588 | if (eHAL_STATUS_SUCCESS != status) |
| 3589 | { |
| 3590 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3591 | "%s: Failed to update channel list information", __func__); |
| 3592 | ret = -EINVAL; |
| 3593 | goto exit; |
| 3594 | } |
| 3595 | } |
| 3596 | else if (strncmp(command, "GETTSMSTATS", 11) == 0) |
| 3597 | { |
| 3598 | tANI_U8 *value = command; |
| 3599 | char extra[128] = {0}; |
| 3600 | int len = 0; |
| 3601 | tANI_U8 tid = 0; |
| 3602 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3603 | tAniTrafStrmMetrics tsmMetrics; |
| 3604 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3605 | |
| 3606 | /* if not associated, return error */ |
| 3607 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3608 | { |
| 3609 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__); |
| 3610 | ret = -EINVAL; |
| 3611 | goto exit; |
| 3612 | } |
| 3613 | |
| 3614 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 3615 | value = value + 12; |
| 3616 | /* Convert the value from ascii to integer */ |
| 3617 | ret = kstrtou8(value, 10, &tid); |
| 3618 | if (ret < 0) |
| 3619 | { |
| 3620 | /* If the input value is greater than max value of datatype, then also |
| 3621 | kstrtou8 fails */ |
| 3622 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3623 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3624 | TID_MIN_VALUE, |
| 3625 | TID_MAX_VALUE); |
| 3626 | ret = -EINVAL; |
| 3627 | goto exit; |
| 3628 | } |
| 3629 | |
| 3630 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) |
| 3631 | { |
| 3632 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3633 | "tid value %d is out of range" |
| 3634 | " (Min: %d Max: %d)", tid, |
| 3635 | TID_MIN_VALUE, |
| 3636 | TID_MAX_VALUE); |
| 3637 | ret = -EINVAL; |
| 3638 | goto exit; |
| 3639 | } |
| 3640 | |
| 3641 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3642 | "%s: Received Command to get tsm stats tid = %d", __func__, tid); |
| 3643 | |
| 3644 | if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics)) |
| 3645 | { |
| 3646 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3647 | "%s: failed to get tsm stats", __func__); |
| 3648 | ret = -EFAULT; |
| 3649 | goto exit; |
| 3650 | } |
| 3651 | |
| 3652 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3653 | "UplinkPktQueueDly(%d)\n" |
| 3654 | "UplinkPktQueueDlyHist[0](%d)\n" |
| 3655 | "UplinkPktQueueDlyHist[1](%d)\n" |
| 3656 | "UplinkPktQueueDlyHist[2](%d)\n" |
| 3657 | "UplinkPktQueueDlyHist[3](%d)\n" |
| 3658 | "UplinkPktTxDly(%lu)\n" |
| 3659 | "UplinkPktLoss(%d)\n" |
| 3660 | "UplinkPktCount(%d)\n" |
| 3661 | "RoamingCount(%d)\n" |
| 3662 | "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly, |
| 3663 | tsmMetrics.UplinkPktQueueDlyHist[0], |
| 3664 | tsmMetrics.UplinkPktQueueDlyHist[1], |
| 3665 | tsmMetrics.UplinkPktQueueDlyHist[2], |
| 3666 | tsmMetrics.UplinkPktQueueDlyHist[3], |
| 3667 | tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss, |
| 3668 | tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly); |
| 3669 | |
| 3670 | /* Output TSM stats is of the format |
| 3671 | GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 3672 | eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */ |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3673 | len = scnprintf(extra, sizeof(extra), "%s %d %d:%d:%d:%d %u %d %d %d %d", command, |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3674 | tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0], |
| 3675 | tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2], |
| 3676 | tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly, |
| 3677 | tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, |
| 3678 | tsmMetrics.RoamingDly); |
| 3679 | |
| 3680 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3681 | { |
| 3682 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3683 | "%s: failed to copy data to user buffer", __func__); |
| 3684 | ret = -EFAULT; |
| 3685 | goto exit; |
| 3686 | } |
| 3687 | } |
| 3688 | else if (strncmp(command, "SETCCKMIE", 9) == 0) |
| 3689 | { |
| 3690 | tANI_U8 *value = command; |
| 3691 | tANI_U8 *cckmIe = NULL; |
| 3692 | tANI_U8 cckmIeLen = 0; |
| 3693 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3694 | |
| 3695 | status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 3696 | if (eHAL_STATUS_SUCCESS != status) |
| 3697 | { |
| 3698 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3699 | "%s: Failed to parse cckm ie data", __func__); |
| 3700 | ret = -EINVAL; |
| 3701 | goto exit; |
| 3702 | } |
| 3703 | |
| 3704 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) |
| 3705 | { |
| 3706 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3707 | "%s: CCKM Ie input length is more than max[%d]", __func__, |
| 3708 | DOT11F_IE_RSN_MAX_LEN); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3709 | vos_mem_free(cckmIe); |
| 3710 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3711 | ret = -EINVAL; |
| 3712 | goto exit; |
| 3713 | } |
| 3714 | sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3715 | vos_mem_free(cckmIe); |
| 3716 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3717 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3718 | else if (strncmp(command, "CCXBEACONREQ", 12) == 0) |
| 3719 | { |
| 3720 | tANI_U8 *value = command; |
| 3721 | tCsrCcxBeaconReq ccxBcnReq; |
| 3722 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3723 | status = hdd_parse_ccx_beacon_req(value, &ccxBcnReq); |
| 3724 | if (eHAL_STATUS_SUCCESS != status) |
| 3725 | { |
| 3726 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3727 | "%s: Failed to parse ccx beacon req", __func__); |
| 3728 | ret = -EINVAL; |
| 3729 | goto exit; |
| 3730 | } |
| 3731 | |
| 3732 | sme_SetCcxBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &ccxBcnReq); |
| 3733 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3734 | #endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */ |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 3735 | else { |
| 3736 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s", |
| 3737 | __func__, command); |
| 3738 | } |
| 3739 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3740 | } |
| 3741 | exit: |
| 3742 | if (command) |
| 3743 | { |
| 3744 | kfree(command); |
| 3745 | } |
| 3746 | return ret; |
| 3747 | } |
| 3748 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3749 | |
| 3750 | |
| 3751 | #if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3752 | /**--------------------------------------------------------------------------- |
| 3753 | |
| 3754 | \brief hdd_parse_ccx_beacon_req() - Parse ccx beacon request |
| 3755 | |
| 3756 | This function parses the ccx beacon request passed in the format |
| 3757 | CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 3758 | <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 3759 | <space>Scan Mode N<space>Meas Duration N |
| 3760 | if the Number of bcn req fields (N) does not match with the actual number of fields passed |
| 3761 | then take N. |
| 3762 | <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair |
| 3763 | For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 3764 | This function does not take care of removing duplicate channels from the list |
| 3765 | |
| 3766 | \param - pValue Pointer to data |
| 3767 | \param - pCcxBcnReq output pointer to store parsed ie information |
| 3768 | |
| 3769 | \return - 0 for success non-zero for failure |
| 3770 | |
| 3771 | --------------------------------------------------------------------------*/ |
| 3772 | static VOS_STATUS hdd_parse_ccx_beacon_req(tANI_U8 *pValue, |
| 3773 | tCsrCcxBeaconReq *pCcxBcnReq) |
| 3774 | { |
| 3775 | tANI_U8 *inPtr = pValue; |
| 3776 | int tempInt = 0; |
| 3777 | int j = 0, i = 0, v = 0; |
| 3778 | char buf[32]; |
| 3779 | |
| 3780 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 3781 | /*no argument after the command*/ |
| 3782 | if (NULL == inPtr) |
| 3783 | { |
| 3784 | return -EINVAL; |
| 3785 | } |
| 3786 | /*no space after the command*/ |
| 3787 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 3788 | { |
| 3789 | return -EINVAL; |
| 3790 | } |
| 3791 | |
| 3792 | /*removing empty spaces*/ |
| 3793 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 3794 | |
| 3795 | /*no argument followed by spaces*/ |
| 3796 | if ('\0' == *inPtr) return -EINVAL; |
| 3797 | |
| 3798 | /*getting the first argument ie measurement token*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 3799 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3800 | if (1 != v) return -EINVAL; |
| 3801 | |
| 3802 | v = kstrtos32(buf, 10, &tempInt); |
| 3803 | if ( v < 0) return -EINVAL; |
| 3804 | |
| 3805 | pCcxBcnReq->numBcnReqIe = tempInt; |
| 3806 | |
| 3807 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 3808 | "Number of Bcn Req Ie fields(%d)", pCcxBcnReq->numBcnReqIe); |
| 3809 | |
| 3810 | for (j = 0; j < (pCcxBcnReq->numBcnReqIe); j++) |
| 3811 | { |
| 3812 | for (i = 0; i < 4; i++) |
| 3813 | { |
| 3814 | /*inPtr pointing to the beginning of first space after number of ie fields*/ |
| 3815 | inPtr = strpbrk( inPtr, " " ); |
| 3816 | /*no ie data after the number of ie fields argument*/ |
| 3817 | if (NULL == inPtr) return -EINVAL; |
| 3818 | |
| 3819 | /*removing empty space*/ |
| 3820 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 3821 | |
| 3822 | /*no ie data after the number of ie fields argument and spaces*/ |
| 3823 | if ( '\0' == *inPtr ) return -EINVAL; |
| 3824 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 3825 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3826 | if (1 != v) return -EINVAL; |
| 3827 | |
| 3828 | v = kstrtos32(buf, 10, &tempInt); |
| 3829 | if (v < 0) return -EINVAL; |
| 3830 | |
| 3831 | switch (i) |
| 3832 | { |
| 3833 | case 0: /* Measurement token */ |
| 3834 | if (tempInt <= 0) |
| 3835 | { |
| 3836 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3837 | "Invalid Measurement Token(%d)", tempInt); |
| 3838 | return -EINVAL; |
| 3839 | } |
| 3840 | pCcxBcnReq->bcnReq[j].measurementToken = tempInt; |
| 3841 | break; |
| 3842 | |
| 3843 | case 1: /* Channel number */ |
| 3844 | if ((tempInt <= 0) || |
| 3845 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 3846 | { |
| 3847 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3848 | "Invalid Channel Number(%d)", tempInt); |
| 3849 | return -EINVAL; |
| 3850 | } |
| 3851 | pCcxBcnReq->bcnReq[j].channel = tempInt; |
| 3852 | break; |
| 3853 | |
| 3854 | case 2: /* Scan mode */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 3855 | if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE)) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3856 | { |
| 3857 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3858 | "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt); |
| 3859 | return -EINVAL; |
| 3860 | } |
| 3861 | pCcxBcnReq->bcnReq[j].scanMode= tempInt; |
| 3862 | break; |
| 3863 | |
| 3864 | case 3: /* Measurement duration */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 3865 | if (((tempInt <= 0) && (pCcxBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) || |
| 3866 | ((tempInt < 0) && (pCcxBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE))) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3867 | { |
| 3868 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3869 | "Invalid Measurement Duration(%d)", tempInt); |
| 3870 | return -EINVAL; |
| 3871 | } |
| 3872 | pCcxBcnReq->bcnReq[j].measurementDuration = tempInt; |
| 3873 | break; |
| 3874 | } |
| 3875 | } |
| 3876 | } |
| 3877 | |
| 3878 | for (j = 0; j < pCcxBcnReq->numBcnReqIe; j++) |
| 3879 | { |
| 3880 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3881 | "Index(%d) Measurement Token(%lu)Channel(%lu) Scan Mode(%lu) Measurement Duration(%lu)\n", |
| 3882 | j, |
| 3883 | pCcxBcnReq->bcnReq[j].measurementToken, |
| 3884 | pCcxBcnReq->bcnReq[j].channel, |
| 3885 | pCcxBcnReq->bcnReq[j].scanMode, |
| 3886 | pCcxBcnReq->bcnReq[j].measurementDuration); |
| 3887 | } |
| 3888 | |
| 3889 | return VOS_STATUS_SUCCESS; |
| 3890 | } |
| 3891 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3892 | static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext ) |
| 3893 | { |
| 3894 | struct statsContext *pStatsContext = NULL; |
| 3895 | hdd_adapter_t *pAdapter = NULL; |
| 3896 | |
| 3897 | if (NULL == pContext) |
| 3898 | { |
| 3899 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3900 | "%s: Bad param, pContext [%p]", |
| 3901 | __func__, pContext); |
| 3902 | return; |
| 3903 | } |
| 3904 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 3905 | /* there is a race condition that exists between this callback |
| 3906 | function and the caller since the caller could time out either |
| 3907 | before or while this code is executing. we use a spinlock to |
| 3908 | serialize these actions */ |
| 3909 | spin_lock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3910 | |
| 3911 | pStatsContext = pContext; |
| 3912 | pAdapter = pStatsContext->pAdapter; |
| 3913 | if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic)) |
| 3914 | { |
| 3915 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 3916 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3917 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 3918 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 3919 | __func__, pAdapter, pStatsContext->magic); |
| 3920 | return; |
| 3921 | } |
| 3922 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 3923 | /* context is valid so caller is still waiting */ |
| 3924 | |
| 3925 | /* paranoia: invalidate the magic */ |
| 3926 | pStatsContext->magic = 0; |
| 3927 | |
| 3928 | /* copy over the tsm stats */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3929 | pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly; |
| 3930 | vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 3931 | tsmMetrics.UplinkPktQueueDlyHist, |
| 3932 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 3933 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 3934 | pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly; |
| 3935 | pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss; |
| 3936 | pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount; |
| 3937 | pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount; |
| 3938 | pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly; |
| 3939 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 3940 | /* notify the caller */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3941 | complete(&pStatsContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 3942 | |
| 3943 | /* serialization is complete */ |
| 3944 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3945 | } |
| 3946 | |
| 3947 | |
| 3948 | |
| 3949 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 3950 | tAniTrafStrmMetrics* pTsmMetrics) |
| 3951 | { |
| 3952 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3953 | eHalStatus hstatus; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 3954 | VOS_STATUS vstatus = VOS_STATUS_SUCCESS; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3955 | long lrc; |
| 3956 | struct statsContext context; |
| 3957 | hdd_context_t *pHddCtx = NULL; |
| 3958 | |
| 3959 | if (NULL == pAdapter) |
| 3960 | { |
| 3961 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__); |
| 3962 | return VOS_STATUS_E_FAULT; |
| 3963 | } |
| 3964 | |
| 3965 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3966 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3967 | |
| 3968 | /* we are connected prepare our callback context */ |
| 3969 | init_completion(&context.completion); |
| 3970 | context.pAdapter = pAdapter; |
| 3971 | context.magic = STATS_CONTEXT_MAGIC; |
| 3972 | |
| 3973 | /* query tsm stats */ |
| 3974 | hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB, |
| 3975 | pHddStaCtx->conn_info.staId[ 0 ], |
| 3976 | pHddStaCtx->conn_info.bssId, |
| 3977 | &context, pHddCtx->pvosContext, tid); |
| 3978 | |
| 3979 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 3980 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 3981 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics", |
| 3982 | __func__); |
| 3983 | vstatus = VOS_STATUS_E_FAULT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3984 | } |
| 3985 | else |
| 3986 | { |
| 3987 | /* request was sent -- wait for the response */ |
| 3988 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 3989 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3990 | if (lrc <= 0) |
| 3991 | { |
| 3992 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3993 | "%s: SME %s while retrieving statistics", |
| 3994 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 3995 | vstatus = VOS_STATUS_E_TIMEOUT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3996 | } |
| 3997 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3998 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 3999 | /* either we never sent a request, we sent a request and received a |
| 4000 | response or we sent a request and timed out. if we never sent a |
| 4001 | request or if we sent a request and got a response, we want to |
| 4002 | clear the magic out of paranoia. if we timed out there is a |
| 4003 | race condition such that the callback function could be |
| 4004 | executing at the same time we are. of primary concern is if the |
| 4005 | callback function had already verified the "magic" but had not |
| 4006 | yet set the completion variable when a timeout occurred. we |
| 4007 | serialize these activities by invalidating the magic while |
| 4008 | holding a shared spinlock which will cause us to block if the |
| 4009 | callback is currently executing */ |
| 4010 | spin_lock(&hdd_context_lock); |
| 4011 | context.magic = 0; |
| 4012 | spin_unlock(&hdd_context_lock); |
| 4013 | |
| 4014 | if (VOS_STATUS_SUCCESS == vstatus) |
| 4015 | { |
| 4016 | pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly; |
| 4017 | vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist, |
| 4018 | pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4019 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4020 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4021 | pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly; |
| 4022 | pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss; |
| 4023 | pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount; |
| 4024 | pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount; |
| 4025 | pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly; |
| 4026 | } |
| 4027 | return vstatus; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4028 | } |
| 4029 | #endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */ |
| 4030 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4031 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 4032 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand) |
| 4033 | { |
| 4034 | eCsrBand band = -1; |
| 4035 | sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band); |
| 4036 | switch (band) |
| 4037 | { |
| 4038 | case eCSR_BAND_ALL: |
| 4039 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 4040 | break; |
| 4041 | |
| 4042 | case eCSR_BAND_24: |
| 4043 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 4044 | break; |
| 4045 | |
| 4046 | case eCSR_BAND_5G: |
| 4047 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 4048 | break; |
| 4049 | |
| 4050 | default: |
| 4051 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band); |
| 4052 | *pBand = -1; |
| 4053 | break; |
| 4054 | } |
| 4055 | } |
| 4056 | |
| 4057 | /**--------------------------------------------------------------------------- |
| 4058 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4059 | \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 4060 | |
| 4061 | This function parses the send action frame data passed in the format |
| 4062 | SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 4063 | |
Srinivas Girigowda | 5607685 | 2013-08-20 14:00:50 -0700 | [diff] [blame] | 4064 | \param - pValue Pointer to input data |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4065 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4066 | \param - pChannel Pointer to the Target AP channel |
| 4067 | \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame |
| 4068 | \param - pBuf Pointer to data |
| 4069 | \param - pBufLen Pointer to data length |
| 4070 | |
| 4071 | \return - 0 for success non-zero for failure |
| 4072 | |
| 4073 | --------------------------------------------------------------------------*/ |
| 4074 | VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel, |
| 4075 | tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen) |
| 4076 | { |
| 4077 | tANI_U8 *inPtr = pValue; |
| 4078 | tANI_U8 *dataEnd; |
| 4079 | int tempInt; |
| 4080 | int j = 0; |
| 4081 | int i = 0; |
| 4082 | int v = 0; |
| 4083 | tANI_U8 tempBuf[32]; |
| 4084 | tANI_U8 tempByte = 0; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4085 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 4086 | tANI_U8 macAddress[18]; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4087 | |
| 4088 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4089 | /*no argument after the command*/ |
| 4090 | if (NULL == inPtr) |
| 4091 | { |
| 4092 | return -EINVAL; |
| 4093 | } |
| 4094 | |
| 4095 | /*no space after the command*/ |
| 4096 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4097 | { |
| 4098 | return -EINVAL; |
| 4099 | } |
| 4100 | |
| 4101 | /*removing empty spaces*/ |
| 4102 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4103 | |
| 4104 | /*no argument followed by spaces*/ |
| 4105 | if ('\0' == *inPtr) |
| 4106 | { |
| 4107 | return -EINVAL; |
| 4108 | } |
| 4109 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4110 | v = sscanf(inPtr, "%17s", macAddress); |
| 4111 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4112 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4113 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4114 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4115 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4116 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4117 | |
| 4118 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4119 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4120 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4121 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4122 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4123 | pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4124 | |
| 4125 | /* point to the next argument */ |
| 4126 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4127 | /*no argument after the command*/ |
| 4128 | if (NULL == inPtr) return -EINVAL; |
| 4129 | |
| 4130 | /*removing empty spaces*/ |
| 4131 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4132 | |
| 4133 | /*no argument followed by spaces*/ |
| 4134 | if ('\0' == *inPtr) |
| 4135 | { |
| 4136 | return -EINVAL; |
| 4137 | } |
| 4138 | |
| 4139 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4140 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4141 | if (1 != v) return -EINVAL; |
| 4142 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4143 | v = kstrtos32(tempBuf, 10, &tempInt); |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4144 | if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX ) |
| 4145 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4146 | |
| 4147 | *pChannel = tempInt; |
| 4148 | |
| 4149 | /* point to the next argument */ |
| 4150 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4151 | /*no argument after the command*/ |
| 4152 | if (NULL == inPtr) return -EINVAL; |
| 4153 | /*removing empty spaces*/ |
| 4154 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4155 | |
| 4156 | /*no argument followed by spaces*/ |
| 4157 | if ('\0' == *inPtr) |
| 4158 | { |
| 4159 | return -EINVAL; |
| 4160 | } |
| 4161 | |
| 4162 | /*getting the next argument ie the dwell time */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4163 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4164 | if (1 != v) return -EINVAL; |
| 4165 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4166 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 5a6e067 | 2014-01-09 14:42:57 -0800 | [diff] [blame] | 4167 | if ( v < 0 || tempInt < 0) return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4168 | |
| 4169 | *pDwellTime = tempInt; |
| 4170 | |
| 4171 | /* point to the next argument */ |
| 4172 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4173 | /*no argument after the command*/ |
| 4174 | if (NULL == inPtr) return -EINVAL; |
| 4175 | /*removing empty spaces*/ |
| 4176 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4177 | |
| 4178 | /*no argument followed by spaces*/ |
| 4179 | if ('\0' == *inPtr) |
| 4180 | { |
| 4181 | return -EINVAL; |
| 4182 | } |
| 4183 | |
| 4184 | /* find the length of data */ |
| 4185 | dataEnd = inPtr; |
| 4186 | while(('\0' != *dataEnd) ) |
| 4187 | { |
| 4188 | dataEnd++; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4189 | } |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4190 | *pBufLen = dataEnd - inPtr ; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4191 | if ( *pBufLen <= 0) return -EINVAL; |
| 4192 | |
Srinivas Girigowda | b5ae85d | 2013-06-03 10:51:45 -0700 | [diff] [blame] | 4193 | /* Allocate the number of bytes based on the number of input characters |
| 4194 | whether it is even or odd. |
| 4195 | if the number of input characters are even, then we need N/2 byte. |
| 4196 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 4197 | compensate rounding off. |
| 4198 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 4199 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 4200 | *pBuf = vos_mem_malloc((*pBufLen + 1)/2); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4201 | if (NULL == *pBuf) |
| 4202 | { |
| 4203 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4204 | "%s: vos_mem_alloc failed ", __func__); |
| 4205 | return -EINVAL; |
| 4206 | } |
| 4207 | |
| 4208 | /* the buffer received from the upper layer is character buffer, |
| 4209 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 4210 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 4211 | and f0 in 3rd location */ |
| 4212 | for (i = 0, j = 0; j < *pBufLen; j += 2) |
| 4213 | { |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4214 | if( j+1 == *pBufLen) |
| 4215 | { |
| 4216 | tempByte = hdd_parse_hex(inPtr[j]); |
| 4217 | } |
| 4218 | else |
| 4219 | { |
| 4220 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 4221 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4222 | (*pBuf)[i++] = tempByte; |
| 4223 | } |
| 4224 | *pBufLen = i; |
| 4225 | return VOS_STATUS_SUCCESS; |
| 4226 | } |
| 4227 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4228 | /**--------------------------------------------------------------------------- |
| 4229 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4230 | \brief hdd_parse_channellist() - HDD Parse channel list |
| 4231 | |
| 4232 | This function parses the channel list passed in the format |
| 4233 | SETROAMSCANCHANNELS<space><Number of channels><space>Channel 1<space>Channel 2<space>Channel N |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 4234 | if the Number of channels (N) does not match with the actual number of channels passed |
| 4235 | then take the minimum of N and count of (Ch1, Ch2, ...Ch M) |
| 4236 | For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken. |
| 4237 | If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48. |
| 4238 | This function does not take care of removing duplicate channels from the list |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4239 | |
| 4240 | \param - pValue Pointer to input channel list |
| 4241 | \param - ChannelList Pointer to local output array to record channel list |
| 4242 | \param - pNumChannels Pointer to number of roam scan channels |
| 4243 | |
| 4244 | \return - 0 for success non-zero for failure |
| 4245 | |
| 4246 | --------------------------------------------------------------------------*/ |
| 4247 | VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels) |
| 4248 | { |
| 4249 | tANI_U8 *inPtr = pValue; |
| 4250 | int tempInt; |
| 4251 | int j = 0; |
| 4252 | int v = 0; |
| 4253 | char buf[32]; |
| 4254 | |
| 4255 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4256 | /*no argument after the command*/ |
| 4257 | if (NULL == inPtr) |
| 4258 | { |
| 4259 | return -EINVAL; |
| 4260 | } |
| 4261 | |
| 4262 | /*no space after the command*/ |
| 4263 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4264 | { |
| 4265 | return -EINVAL; |
| 4266 | } |
| 4267 | |
| 4268 | /*removing empty spaces*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4269 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4270 | |
| 4271 | /*no argument followed by spaces*/ |
| 4272 | if ('\0' == *inPtr) |
| 4273 | { |
| 4274 | return -EINVAL; |
| 4275 | } |
| 4276 | |
| 4277 | /*getting the first argument ie the number of channels*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4278 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4279 | if (1 != v) return -EINVAL; |
| 4280 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4281 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4282 | if ((v < 0) || |
| 4283 | (tempInt <= 0) || |
| 4284 | (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 4285 | { |
| 4286 | return -EINVAL; |
| 4287 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4288 | |
| 4289 | *pNumChannels = tempInt; |
| 4290 | |
| 4291 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 4292 | "Number of channels are: %d", *pNumChannels); |
| 4293 | |
| 4294 | for (j = 0; j < (*pNumChannels); j++) |
| 4295 | { |
| 4296 | /*inPtr pointing to the beginning of first space after number of channels*/ |
| 4297 | inPtr = strpbrk( inPtr, " " ); |
| 4298 | /*no channel list after the number of channels argument*/ |
| 4299 | if (NULL == inPtr) |
| 4300 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 4301 | if (0 != j) |
| 4302 | { |
| 4303 | *pNumChannels = j; |
| 4304 | return VOS_STATUS_SUCCESS; |
| 4305 | } |
| 4306 | else |
| 4307 | { |
| 4308 | return -EINVAL; |
| 4309 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4310 | } |
| 4311 | |
| 4312 | /*removing empty space*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4313 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4314 | |
| 4315 | /*no channel list after the number of channels argument and spaces*/ |
| 4316 | if ( '\0' == *inPtr ) |
| 4317 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 4318 | if (0 != j) |
| 4319 | { |
| 4320 | *pNumChannels = j; |
| 4321 | return VOS_STATUS_SUCCESS; |
| 4322 | } |
| 4323 | else |
| 4324 | { |
| 4325 | return -EINVAL; |
| 4326 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4327 | } |
| 4328 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4329 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4330 | if (1 != v) return -EINVAL; |
| 4331 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4332 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4333 | if ((v < 0) || |
| 4334 | (tempInt <= 0) || |
| 4335 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4336 | { |
| 4337 | return -EINVAL; |
| 4338 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4339 | pChannelList[j] = tempInt; |
| 4340 | |
| 4341 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 4342 | "Channel %d added to preferred channel list", |
| 4343 | pChannelList[j] ); |
| 4344 | } |
| 4345 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4346 | return VOS_STATUS_SUCCESS; |
| 4347 | } |
| 4348 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4349 | |
| 4350 | /**--------------------------------------------------------------------------- |
| 4351 | |
| 4352 | \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
| 4353 | |
| 4354 | This function parses the reasoc command data passed in the format |
| 4355 | REASSOC<space><bssid><space><channel> |
| 4356 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4357 | \param - pValue Pointer to input data (its a NUL terminated string) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4358 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4359 | \param - pChannel Pointer to the Target AP channel |
| 4360 | |
| 4361 | \return - 0 for success non-zero for failure |
| 4362 | |
| 4363 | --------------------------------------------------------------------------*/ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4364 | VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 4365 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4366 | { |
| 4367 | tANI_U8 *inPtr = pValue; |
| 4368 | int tempInt; |
| 4369 | int v = 0; |
| 4370 | tANI_U8 tempBuf[32]; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4371 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 4372 | tANI_U8 macAddress[18]; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4373 | |
| 4374 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4375 | /*no argument after the command*/ |
| 4376 | if (NULL == inPtr) |
| 4377 | { |
| 4378 | return -EINVAL; |
| 4379 | } |
| 4380 | |
| 4381 | /*no space after the command*/ |
| 4382 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4383 | { |
| 4384 | return -EINVAL; |
| 4385 | } |
| 4386 | |
| 4387 | /*removing empty spaces*/ |
| 4388 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4389 | |
| 4390 | /*no argument followed by spaces*/ |
| 4391 | if ('\0' == *inPtr) |
| 4392 | { |
| 4393 | return -EINVAL; |
| 4394 | } |
| 4395 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4396 | v = sscanf(inPtr, "%17s", macAddress); |
| 4397 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4398 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4399 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4400 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4401 | return -EINVAL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4402 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4403 | |
| 4404 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4405 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4406 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4407 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4408 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4409 | pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4410 | |
| 4411 | /* point to the next argument */ |
| 4412 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4413 | /*no argument after the command*/ |
| 4414 | if (NULL == inPtr) return -EINVAL; |
| 4415 | |
| 4416 | /*removing empty spaces*/ |
| 4417 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4418 | |
| 4419 | /*no argument followed by spaces*/ |
| 4420 | if ('\0' == *inPtr) |
| 4421 | { |
| 4422 | return -EINVAL; |
| 4423 | } |
| 4424 | |
| 4425 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4426 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4427 | if (1 != v) return -EINVAL; |
| 4428 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4429 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4430 | if ((v < 0) || |
| 4431 | (tempInt <= 0) || |
| 4432 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4433 | { |
| 4434 | return -EINVAL; |
| 4435 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4436 | |
| 4437 | *pChannel = tempInt; |
| 4438 | return VOS_STATUS_SUCCESS; |
| 4439 | } |
| 4440 | |
| 4441 | #endif |
| 4442 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4443 | #if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD) |
| 4444 | /**--------------------------------------------------------------------------- |
| 4445 | |
| 4446 | \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 4447 | |
| 4448 | This function parses the SETCCKM IE command |
| 4449 | SETCCKMIE<space><ie data> |
| 4450 | |
| 4451 | \param - pValue Pointer to input data |
| 4452 | \param - pCckmIe Pointer to output cckm Ie |
| 4453 | \param - pCckmIeLen Pointer to output cckm ie length |
| 4454 | |
| 4455 | \return - 0 for success non-zero for failure |
| 4456 | |
| 4457 | --------------------------------------------------------------------------*/ |
| 4458 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, |
| 4459 | tANI_U8 *pCckmIeLen) |
| 4460 | { |
| 4461 | tANI_U8 *inPtr = pValue; |
| 4462 | tANI_U8 *dataEnd; |
| 4463 | int j = 0; |
| 4464 | int i = 0; |
| 4465 | tANI_U8 tempByte = 0; |
| 4466 | |
| 4467 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4468 | /*no argument after the command*/ |
| 4469 | if (NULL == inPtr) |
| 4470 | { |
| 4471 | return -EINVAL; |
| 4472 | } |
| 4473 | |
| 4474 | /*no space after the command*/ |
| 4475 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4476 | { |
| 4477 | return -EINVAL; |
| 4478 | } |
| 4479 | |
| 4480 | /*removing empty spaces*/ |
| 4481 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4482 | |
| 4483 | /*no argument followed by spaces*/ |
| 4484 | if ('\0' == *inPtr) |
| 4485 | { |
| 4486 | return -EINVAL; |
| 4487 | } |
| 4488 | |
| 4489 | /* find the length of data */ |
| 4490 | dataEnd = inPtr; |
| 4491 | while(('\0' != *dataEnd) ) |
| 4492 | { |
| 4493 | dataEnd++; |
| 4494 | ++(*pCckmIeLen); |
| 4495 | } |
| 4496 | if ( *pCckmIeLen <= 0) return -EINVAL; |
| 4497 | |
| 4498 | /* Allocate the number of bytes based on the number of input characters |
| 4499 | whether it is even or odd. |
| 4500 | if the number of input characters are even, then we need N/2 byte. |
| 4501 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 4502 | compensate rounding off. |
| 4503 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 4504 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 4505 | *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2); |
| 4506 | if (NULL == *pCckmIe) |
| 4507 | { |
| 4508 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4509 | "%s: vos_mem_alloc failed ", __func__); |
| 4510 | return -EINVAL; |
| 4511 | } |
| 4512 | vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2); |
| 4513 | /* the buffer received from the upper layer is character buffer, |
| 4514 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 4515 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 4516 | and f0 in 3rd location */ |
| 4517 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) |
| 4518 | { |
| 4519 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 4520 | (*pCckmIe)[i++] = tempByte; |
| 4521 | } |
| 4522 | *pCckmIeLen = i; |
| 4523 | |
| 4524 | return VOS_STATUS_SUCCESS; |
| 4525 | } |
| 4526 | #endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */ |
| 4527 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4528 | /**--------------------------------------------------------------------------- |
| 4529 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4530 | \brief hdd_is_valid_mac_address() - Validate MAC address |
| 4531 | |
| 4532 | This function validates whether the given MAC address is valid or not |
| 4533 | Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 4534 | where X is the hexa decimal digit character and separated by ':' |
| 4535 | This algorithm works even if MAC address is not separated by ':' |
| 4536 | |
| 4537 | This code checks given input string mac contains exactly 12 hexadecimal digits. |
| 4538 | and a separator colon : appears in the input string only after |
| 4539 | an even number of hex digits. |
| 4540 | |
| 4541 | \param - pMacAddr pointer to the input MAC address |
| 4542 | \return - 1 for valid and 0 for invalid |
| 4543 | |
| 4544 | --------------------------------------------------------------------------*/ |
| 4545 | |
| 4546 | v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr) |
| 4547 | { |
| 4548 | int xdigit = 0; |
| 4549 | int separator = 0; |
| 4550 | while (*pMacAddr) |
| 4551 | { |
| 4552 | if (isxdigit(*pMacAddr)) |
| 4553 | { |
| 4554 | xdigit++; |
| 4555 | } |
| 4556 | else if (':' == *pMacAddr) |
| 4557 | { |
| 4558 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 4559 | break; |
| 4560 | |
| 4561 | ++separator; |
| 4562 | } |
| 4563 | else |
| 4564 | { |
| 4565 | separator = -1; |
| 4566 | /* Invalid MAC found */ |
| 4567 | return 0; |
| 4568 | } |
| 4569 | ++pMacAddr; |
| 4570 | } |
| 4571 | return (xdigit == 12 && (separator == 5 || separator == 0)); |
| 4572 | } |
| 4573 | |
| 4574 | /**--------------------------------------------------------------------------- |
| 4575 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4576 | \brief hdd_open() - HDD Open function |
| 4577 | |
| 4578 | This is called in response to ifconfig up |
| 4579 | |
| 4580 | \param - dev Pointer to net_device structure |
| 4581 | |
| 4582 | \return - 0 for success non-zero for failure |
| 4583 | |
| 4584 | --------------------------------------------------------------------------*/ |
| 4585 | int hdd_open (struct net_device *dev) |
| 4586 | { |
| 4587 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4588 | hdd_context_t *pHddCtx; |
| 4589 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4590 | VOS_STATUS status; |
| 4591 | v_BOOL_t in_standby = TRUE; |
| 4592 | |
| 4593 | if (NULL == pAdapter) |
| 4594 | { |
| 4595 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4596 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4597 | return -ENODEV; |
| 4598 | } |
| 4599 | |
| 4600 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 4601 | if (NULL == pHddCtx) |
| 4602 | { |
| 4603 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4604 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4605 | return -ENODEV; |
| 4606 | } |
| 4607 | |
| 4608 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4609 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 4610 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 4611 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 4612 | { |
| 4613 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 4614 | __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 4615 | in_standby = FALSE; |
| 4616 | break; |
| 4617 | } |
| 4618 | else |
| 4619 | { |
| 4620 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4621 | pAdapterNode = pNext; |
| 4622 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4623 | } |
| 4624 | |
| 4625 | if (TRUE == in_standby) |
| 4626 | { |
| 4627 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 4628 | { |
| 4629 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 4630 | "wlan out of power save", __func__); |
| 4631 | return -EINVAL; |
| 4632 | } |
| 4633 | } |
| 4634 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 4635 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4636 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 4637 | { |
| 4638 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4639 | "%s: Enabling Tx Queues", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4640 | /* Enable TX queues only when we are connected */ |
| 4641 | netif_tx_start_all_queues(dev); |
| 4642 | } |
| 4643 | |
| 4644 | return 0; |
| 4645 | } |
| 4646 | |
| 4647 | int hdd_mon_open (struct net_device *dev) |
| 4648 | { |
| 4649 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4650 | |
| 4651 | if(pAdapter == NULL) { |
| 4652 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4653 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 4654 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4655 | } |
| 4656 | |
| 4657 | netif_start_queue(dev); |
| 4658 | |
| 4659 | return 0; |
| 4660 | } |
| 4661 | /**--------------------------------------------------------------------------- |
| 4662 | |
| 4663 | \brief hdd_stop() - HDD stop function |
| 4664 | |
| 4665 | This is called in response to ifconfig down |
| 4666 | |
| 4667 | \param - dev Pointer to net_device structure |
| 4668 | |
| 4669 | \return - 0 for success non-zero for failure |
| 4670 | |
| 4671 | --------------------------------------------------------------------------*/ |
| 4672 | |
| 4673 | int hdd_stop (struct net_device *dev) |
| 4674 | { |
| 4675 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4676 | hdd_context_t *pHddCtx; |
| 4677 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4678 | VOS_STATUS status; |
| 4679 | v_BOOL_t enter_standby = TRUE; |
| 4680 | |
| 4681 | ENTER(); |
| 4682 | |
| 4683 | if (NULL == pAdapter) |
| 4684 | { |
| 4685 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4686 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4687 | return -ENODEV; |
| 4688 | } |
| 4689 | |
| 4690 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 4691 | if (NULL == pHddCtx) |
| 4692 | { |
| 4693 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4694 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4695 | return -ENODEV; |
| 4696 | } |
| 4697 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 4698 | clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4699 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__); |
| 4700 | netif_tx_disable(pAdapter->dev); |
| 4701 | netif_carrier_off(pAdapter->dev); |
| 4702 | |
| 4703 | |
| 4704 | /* SoftAP ifaces should never go in power save mode |
| 4705 | making sure same here. */ |
| 4706 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 4707 | || (WLAN_HDD_MONITOR == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4708 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4709 | ) |
| 4710 | { |
| 4711 | /* SoftAP mode, so return from here */ |
| 4712 | EXIT(); |
| 4713 | return 0; |
| 4714 | } |
| 4715 | |
| 4716 | /* Find if any iface is up then |
| 4717 | if any iface is up then can't put device to sleep/ power save mode. */ |
| 4718 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4719 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 4720 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 4721 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 4722 | { |
| 4723 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot " |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 4724 | "put device to sleep", __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 4725 | enter_standby = FALSE; |
| 4726 | break; |
| 4727 | } |
| 4728 | else |
| 4729 | { |
| 4730 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4731 | pAdapterNode = pNext; |
| 4732 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4733 | } |
| 4734 | |
| 4735 | if (TRUE == enter_standby) |
| 4736 | { |
| 4737 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down " |
| 4738 | "entering standby", __func__); |
| 4739 | if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx)) |
| 4740 | { |
| 4741 | /*log and return success*/ |
| 4742 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put " |
| 4743 | "wlan in power save", __func__); |
| 4744 | } |
| 4745 | } |
| 4746 | |
| 4747 | EXIT(); |
| 4748 | return 0; |
| 4749 | } |
| 4750 | |
| 4751 | /**--------------------------------------------------------------------------- |
| 4752 | |
| 4753 | \brief hdd_uninit() - HDD uninit function |
| 4754 | |
| 4755 | This is called during the netdev unregister to uninitialize all data |
| 4756 | associated with the device |
| 4757 | |
| 4758 | \param - dev Pointer to net_device structure |
| 4759 | |
| 4760 | \return - void |
| 4761 | |
| 4762 | --------------------------------------------------------------------------*/ |
| 4763 | static void hdd_uninit (struct net_device *dev) |
| 4764 | { |
| 4765 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4766 | |
| 4767 | ENTER(); |
| 4768 | |
| 4769 | do |
| 4770 | { |
| 4771 | if (NULL == pAdapter) |
| 4772 | { |
| 4773 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4774 | "%s: NULL pAdapter", __func__); |
| 4775 | break; |
| 4776 | } |
| 4777 | |
| 4778 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 4779 | { |
| 4780 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4781 | "%s: Invalid magic", __func__); |
| 4782 | break; |
| 4783 | } |
| 4784 | |
| 4785 | if (NULL == pAdapter->pHddCtx) |
| 4786 | { |
| 4787 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4788 | "%s: NULL pHddCtx", __func__); |
| 4789 | break; |
| 4790 | } |
| 4791 | |
| 4792 | if (dev != pAdapter->dev) |
| 4793 | { |
| 4794 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4795 | "%s: Invalid device reference", __func__); |
| 4796 | /* we haven't validated all cases so let this go for now */ |
| 4797 | } |
| 4798 | |
| 4799 | hdd_deinit_adapter(pAdapter->pHddCtx, pAdapter); |
| 4800 | |
| 4801 | /* after uninit our adapter structure will no longer be valid */ |
| 4802 | pAdapter->dev = NULL; |
| 4803 | pAdapter->magic = 0; |
| 4804 | } while (0); |
| 4805 | |
| 4806 | EXIT(); |
| 4807 | } |
| 4808 | |
| 4809 | /**--------------------------------------------------------------------------- |
| 4810 | |
| 4811 | \brief hdd_release_firmware() - |
| 4812 | |
| 4813 | This function calls the release firmware API to free the firmware buffer. |
| 4814 | |
| 4815 | \param - pFileName Pointer to the File Name. |
| 4816 | pCtx - Pointer to the adapter . |
| 4817 | |
| 4818 | |
| 4819 | \return - 0 for success, non zero for failure |
| 4820 | |
| 4821 | --------------------------------------------------------------------------*/ |
| 4822 | |
| 4823 | VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx) |
| 4824 | { |
| 4825 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 4826 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 4827 | ENTER(); |
| 4828 | |
| 4829 | |
| 4830 | if (!strcmp(WLAN_FW_FILE, pFileName)) { |
| 4831 | |
| 4832 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName); |
| 4833 | |
| 4834 | if(pHddCtx->fw) { |
| 4835 | release_firmware(pHddCtx->fw); |
| 4836 | pHddCtx->fw = NULL; |
| 4837 | } |
| 4838 | else |
| 4839 | status = VOS_STATUS_E_FAILURE; |
| 4840 | } |
| 4841 | else if (!strcmp(WLAN_NV_FILE,pFileName)) { |
| 4842 | if(pHddCtx->nv) { |
| 4843 | release_firmware(pHddCtx->nv); |
| 4844 | pHddCtx->nv = NULL; |
| 4845 | } |
| 4846 | else |
| 4847 | status = VOS_STATUS_E_FAILURE; |
| 4848 | |
| 4849 | } |
| 4850 | |
| 4851 | EXIT(); |
| 4852 | return status; |
| 4853 | } |
| 4854 | |
| 4855 | /**--------------------------------------------------------------------------- |
| 4856 | |
| 4857 | \brief hdd_request_firmware() - |
| 4858 | |
| 4859 | This function reads the firmware file using the request firmware |
| 4860 | API and returns the the firmware data and the firmware file size. |
| 4861 | |
| 4862 | \param - pfileName - Pointer to the file name. |
| 4863 | - pCtx - Pointer to the adapter . |
| 4864 | - ppfw_data - Pointer to the pointer of the firmware data. |
| 4865 | - pSize - Pointer to the file size. |
| 4866 | |
| 4867 | \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure |
| 4868 | |
| 4869 | --------------------------------------------------------------------------*/ |
| 4870 | |
| 4871 | |
| 4872 | VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize) |
| 4873 | { |
| 4874 | int status; |
| 4875 | VOS_STATUS retval = VOS_STATUS_SUCCESS; |
| 4876 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 4877 | ENTER(); |
| 4878 | |
| 4879 | if( (!strcmp(WLAN_FW_FILE, pfileName)) ) { |
| 4880 | |
| 4881 | status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev); |
| 4882 | |
| 4883 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 4884 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed", |
| 4885 | __func__, pfileName); |
| 4886 | retval = VOS_STATUS_E_FAILURE; |
| 4887 | } |
| 4888 | |
| 4889 | else { |
| 4890 | *ppfw_data = (v_VOID_t *)pHddCtx->fw->data; |
| 4891 | *pSize = pHddCtx->fw->size; |
| 4892 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d", |
| 4893 | __func__, *pSize); |
| 4894 | } |
| 4895 | } |
| 4896 | else if(!strcmp(WLAN_NV_FILE, pfileName)) { |
| 4897 | |
| 4898 | status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev); |
| 4899 | |
| 4900 | if(status || !pHddCtx->nv || !pHddCtx->nv->data) { |
| 4901 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed", |
| 4902 | __func__, pfileName); |
| 4903 | retval = VOS_STATUS_E_FAILURE; |
| 4904 | } |
| 4905 | |
| 4906 | else { |
| 4907 | *ppfw_data = (v_VOID_t *)pHddCtx->nv->data; |
| 4908 | *pSize = pHddCtx->nv->size; |
| 4909 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d", |
| 4910 | __func__, *pSize); |
| 4911 | } |
| 4912 | } |
| 4913 | |
| 4914 | EXIT(); |
| 4915 | return retval; |
| 4916 | } |
| 4917 | /**--------------------------------------------------------------------------- |
| 4918 | \brief hdd_full_pwr_cbk() - HDD full power callbackfunction |
| 4919 | |
| 4920 | This is the function invoked by SME to inform the result of a full power |
| 4921 | request issued by HDD |
| 4922 | |
| 4923 | \param - callbackcontext - Pointer to cookie |
| 4924 | status - result of request |
| 4925 | |
| 4926 | \return - None |
| 4927 | |
| 4928 | --------------------------------------------------------------------------*/ |
| 4929 | void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status) |
| 4930 | { |
| 4931 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 4932 | |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 4933 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"HDD full Power callback status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4934 | if(&pHddCtx->full_pwr_comp_var) |
| 4935 | { |
| 4936 | complete(&pHddCtx->full_pwr_comp_var); |
| 4937 | } |
| 4938 | } |
| 4939 | |
| 4940 | /**--------------------------------------------------------------------------- |
| 4941 | |
| 4942 | \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function |
| 4943 | |
| 4944 | This is the function invoked by SME to inform the result of BMPS |
| 4945 | request issued by HDD |
| 4946 | |
| 4947 | \param - callbackcontext - Pointer to cookie |
| 4948 | status - result of request |
| 4949 | |
| 4950 | \return - None |
| 4951 | |
| 4952 | --------------------------------------------------------------------------*/ |
| 4953 | void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status) |
| 4954 | { |
| 4955 | |
| 4956 | struct completion *completion_var = (struct completion*) callbackContext; |
| 4957 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4958 | hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4959 | if(completion_var != NULL) |
| 4960 | { |
| 4961 | complete(completion_var); |
| 4962 | } |
| 4963 | } |
| 4964 | |
| 4965 | /**--------------------------------------------------------------------------- |
| 4966 | |
| 4967 | \brief hdd_get_cfg_file_size() - |
| 4968 | |
| 4969 | This function reads the configuration file using the request firmware |
| 4970 | API and returns the configuration file size. |
| 4971 | |
| 4972 | \param - pCtx - Pointer to the adapter . |
| 4973 | - pFileName - Pointer to the file name. |
| 4974 | - pBufSize - Pointer to the buffer size. |
| 4975 | |
| 4976 | \return - 0 for success, non zero for failure |
| 4977 | |
| 4978 | --------------------------------------------------------------------------*/ |
| 4979 | |
| 4980 | VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize) |
| 4981 | { |
| 4982 | int status; |
| 4983 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 4984 | |
| 4985 | ENTER(); |
| 4986 | |
| 4987 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 4988 | |
| 4989 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 4990 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 4991 | status = VOS_STATUS_E_FAILURE; |
| 4992 | } |
| 4993 | else { |
| 4994 | *pBufSize = pHddCtx->fw->size; |
| 4995 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize); |
| 4996 | release_firmware(pHddCtx->fw); |
| 4997 | pHddCtx->fw = NULL; |
| 4998 | } |
| 4999 | |
| 5000 | EXIT(); |
| 5001 | return VOS_STATUS_SUCCESS; |
| 5002 | } |
| 5003 | |
| 5004 | /**--------------------------------------------------------------------------- |
| 5005 | |
| 5006 | \brief hdd_read_cfg_file() - |
| 5007 | |
| 5008 | This function reads the configuration file using the request firmware |
| 5009 | API and returns the cfg data and the buffer size of the configuration file. |
| 5010 | |
| 5011 | \param - pCtx - Pointer to the adapter . |
| 5012 | - pFileName - Pointer to the file name. |
| 5013 | - pBuffer - Pointer to the data buffer. |
| 5014 | - pBufSize - Pointer to the buffer size. |
| 5015 | |
| 5016 | \return - 0 for success, non zero for failure |
| 5017 | |
| 5018 | --------------------------------------------------------------------------*/ |
| 5019 | |
| 5020 | VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName, |
| 5021 | v_VOID_t *pBuffer, v_SIZE_t *pBufSize) |
| 5022 | { |
| 5023 | int status; |
| 5024 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5025 | |
| 5026 | ENTER(); |
| 5027 | |
| 5028 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5029 | |
| 5030 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5031 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5032 | return VOS_STATUS_E_FAILURE; |
| 5033 | } |
| 5034 | else { |
| 5035 | if(*pBufSize != pHddCtx->fw->size) { |
| 5036 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG " |
| 5037 | "file size", __func__); |
| 5038 | release_firmware(pHddCtx->fw); |
| 5039 | pHddCtx->fw = NULL; |
| 5040 | return VOS_STATUS_E_FAILURE; |
| 5041 | } |
| 5042 | else { |
| 5043 | if(pBuffer) { |
| 5044 | vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize); |
| 5045 | } |
| 5046 | release_firmware(pHddCtx->fw); |
| 5047 | pHddCtx->fw = NULL; |
| 5048 | } |
| 5049 | } |
| 5050 | |
| 5051 | EXIT(); |
| 5052 | |
| 5053 | return VOS_STATUS_SUCCESS; |
| 5054 | } |
| 5055 | |
| 5056 | /**--------------------------------------------------------------------------- |
| 5057 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5058 | \brief hdd_set_mac_address() - |
| 5059 | |
| 5060 | This function sets the user specified mac address using |
| 5061 | the command ifconfig wlanX hw ether <mac adress>. |
| 5062 | |
| 5063 | \param - dev - Pointer to the net device. |
| 5064 | - addr - Pointer to the sockaddr. |
| 5065 | \return - 0 for success, non zero for failure |
| 5066 | |
| 5067 | --------------------------------------------------------------------------*/ |
| 5068 | |
| 5069 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 5070 | { |
| 5071 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5072 | struct sockaddr *psta_mac_addr = addr; |
| 5073 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5074 | |
| 5075 | ENTER(); |
| 5076 | |
| 5077 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
| 5078 | |
| 5079 | #ifdef HDD_SESSIONIZE |
| 5080 | // set the MAC address though the STA ID CFG. |
| 5081 | halStatus = ccmCfgSetStr( pAdapter->hHal, WNI_CFG_STA_ID, |
| 5082 | (v_U8_t *)&pAdapter->macAddressCurrent, |
| 5083 | sizeof( pAdapter->macAddressCurrent ), |
| 5084 | hdd_set_mac_addr_cb, VOS_FALSE ); |
| 5085 | #endif |
| 5086 | |
| 5087 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 5088 | |
| 5089 | EXIT(); |
| 5090 | return halStatus; |
| 5091 | } |
| 5092 | |
| 5093 | tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx) |
| 5094 | { |
| 5095 | int i; |
| 5096 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5097 | { |
| 5098 | if( 0 == (pHddCtx->cfg_ini->intfAddrMask >> i)) |
| 5099 | break; |
| 5100 | } |
| 5101 | |
| 5102 | if( VOS_MAX_CONCURRENCY_PERSONA == i) |
| 5103 | return NULL; |
| 5104 | |
| 5105 | pHddCtx->cfg_ini->intfAddrMask |= (1 << i); |
| 5106 | return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0]; |
| 5107 | } |
| 5108 | |
| 5109 | void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr) |
| 5110 | { |
| 5111 | int i; |
| 5112 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5113 | { |
| 5114 | if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) ) |
| 5115 | { |
| 5116 | pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i); |
| 5117 | break; |
| 5118 | } |
| 5119 | } |
| 5120 | return; |
| 5121 | } |
| 5122 | |
| 5123 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 5124 | static struct net_device_ops wlan_drv_ops = { |
| 5125 | .ndo_open = hdd_open, |
| 5126 | .ndo_stop = hdd_stop, |
| 5127 | .ndo_uninit = hdd_uninit, |
| 5128 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 5129 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5130 | .ndo_get_stats = hdd_stats, |
| 5131 | .ndo_do_ioctl = hdd_ioctl, |
| 5132 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5133 | .ndo_select_queue = hdd_select_queue, |
| 5134 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 5135 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) |
| 5136 | .ndo_set_rx_mode = hdd_set_multicast_list, |
| 5137 | #else |
| 5138 | .ndo_set_multicast_list = hdd_set_multicast_list, |
| 5139 | #endif //LINUX_VERSION_CODE |
| 5140 | #endif |
| 5141 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5142 | static struct net_device_ops wlan_mon_drv_ops = { |
| 5143 | .ndo_open = hdd_mon_open, |
| 5144 | .ndo_stop = hdd_stop, |
| 5145 | .ndo_uninit = hdd_uninit, |
| 5146 | .ndo_start_xmit = hdd_mon_hard_start_xmit, |
| 5147 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5148 | .ndo_get_stats = hdd_stats, |
| 5149 | .ndo_do_ioctl = hdd_ioctl, |
| 5150 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5151 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5152 | |
| 5153 | #endif |
| 5154 | |
| 5155 | void hdd_set_station_ops( struct net_device *pWlanDev ) |
| 5156 | { |
| 5157 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5158 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 5159 | #else |
| 5160 | pWlanDev->open = hdd_open; |
| 5161 | pWlanDev->stop = hdd_stop; |
| 5162 | pWlanDev->uninit = hdd_uninit; |
| 5163 | pWlanDev->hard_start_xmit = NULL; |
| 5164 | pWlanDev->tx_timeout = hdd_tx_timeout; |
| 5165 | pWlanDev->get_stats = hdd_stats; |
| 5166 | pWlanDev->do_ioctl = hdd_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5167 | pWlanDev->set_mac_address = hdd_set_mac_address; |
| 5168 | #endif |
| 5169 | } |
| 5170 | |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 5171 | static hdd_adapter_t* hdd_alloc_station_adapter( hdd_context_t *pHddCtx, tSirMacAddr macAddr, const char* name ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5172 | { |
| 5173 | struct net_device *pWlanDev = NULL; |
| 5174 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5175 | /* |
| 5176 | * cfg80211 initialization and registration.... |
| 5177 | */ |
| 5178 | pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, ether_setup, NUM_TX_QUEUES); |
| 5179 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5180 | if(pWlanDev != NULL) |
| 5181 | { |
| 5182 | |
| 5183 | //Save the pointer to the net_device in the HDD adapter |
| 5184 | pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev ); |
| 5185 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5186 | vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) ); |
| 5187 | |
| 5188 | pAdapter->dev = pWlanDev; |
| 5189 | pAdapter->pHddCtx = pHddCtx; |
| 5190 | pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
| 5191 | |
| 5192 | init_completion(&pAdapter->session_open_comp_var); |
| 5193 | init_completion(&pAdapter->session_close_comp_var); |
| 5194 | init_completion(&pAdapter->disconnect_comp_var); |
| 5195 | init_completion(&pAdapter->linkup_event_var); |
| 5196 | init_completion(&pAdapter->cancel_rem_on_chan_var); |
| 5197 | init_completion(&pAdapter->rem_on_chan_ready_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5198 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 5199 | init_completion(&pAdapter->offchannel_tx_event); |
| 5200 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5201 | init_completion(&pAdapter->tx_action_cnf_event); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5202 | #ifdef FEATURE_WLAN_TDLS |
| 5203 | init_completion(&pAdapter->tdls_add_station_comp); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 5204 | init_completion(&pAdapter->tdls_del_station_comp); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 5205 | init_completion(&pAdapter->tdls_mgmt_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 5206 | init_completion(&pAdapter->tdls_link_establish_req_comp); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5207 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5208 | init_completion(&pHddCtx->mc_sus_event_var); |
| 5209 | init_completion(&pHddCtx->tx_sus_event_var); |
Gopichand Nakkala | 0562141 | 2013-06-19 19:37:38 +0530 | [diff] [blame] | 5210 | init_completion(&pHddCtx->rx_sus_event_var); |
Jeff Johnson | 9efb9aa | 2013-03-15 13:59:27 -0700 | [diff] [blame] | 5211 | init_completion(&pAdapter->ula_complete); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 5212 | init_completion(&pAdapter->change_country_code); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5213 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5214 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 5215 | init_completion(&pAdapter->hdd_set_batch_scan_req_var); |
| 5216 | init_completion(&pAdapter->hdd_get_batch_scan_req_var); |
| 5217 | pAdapter->pBatchScanRsp = NULL; |
| 5218 | pAdapter->numScanList = 0; |
Rajeev Kumar | 20140c1 | 2013-10-21 19:39:02 -0700 | [diff] [blame] | 5219 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
Rajeev Kumar | b20d8c8 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 5220 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5221 | mutex_init(&pAdapter->hdd_batch_scan_lock); |
| 5222 | #endif |
| 5223 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5224 | pAdapter->isLinkUpSvcNeeded = FALSE; |
| 5225 | pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE; |
| 5226 | //Init the net_device structure |
| 5227 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 5228 | |
| 5229 | vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr)); |
| 5230 | vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr)); |
| 5231 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 5232 | pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM; |
| 5233 | |
| 5234 | hdd_set_station_ops( pAdapter->dev ); |
| 5235 | |
| 5236 | pWlanDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5237 | pWlanDev->ieee80211_ptr = &pAdapter->wdev ; |
| 5238 | pAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 5239 | pAdapter->wdev.netdev = pWlanDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5240 | /* set pWlanDev's parent to underlying device */ |
| 5241 | SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev); |
| 5242 | } |
| 5243 | |
| 5244 | return pAdapter; |
| 5245 | } |
| 5246 | |
| 5247 | VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 5248 | { |
| 5249 | struct net_device *pWlanDev = pAdapter->dev; |
| 5250 | //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 5251 | //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 5252 | //eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5253 | |
| 5254 | if( rtnl_lock_held ) |
| 5255 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 5256 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5257 | if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 ) |
| 5258 | { |
| 5259 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__); |
| 5260 | return VOS_STATUS_E_FAILURE; |
| 5261 | } |
| 5262 | } |
| 5263 | if (register_netdevice(pWlanDev)) |
| 5264 | { |
| 5265 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__); |
| 5266 | return VOS_STATUS_E_FAILURE; |
| 5267 | } |
| 5268 | } |
| 5269 | else |
| 5270 | { |
| 5271 | if(register_netdev(pWlanDev)) |
| 5272 | { |
| 5273 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__); |
| 5274 | return VOS_STATUS_E_FAILURE; |
| 5275 | } |
| 5276 | } |
| 5277 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 5278 | |
| 5279 | return VOS_STATUS_SUCCESS; |
| 5280 | } |
| 5281 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5282 | static eHalStatus hdd_smeCloseSessionCallback(void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5283 | { |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5284 | hdd_adapter_t *pAdapter = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5285 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5286 | if (NULL == pAdapter) |
| 5287 | { |
| 5288 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__); |
| 5289 | return eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5290 | } |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5291 | |
| 5292 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 5293 | { |
| 5294 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__); |
| 5295 | return eHAL_STATUS_NOT_INITIALIZED; |
| 5296 | } |
| 5297 | |
| 5298 | clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags); |
| 5299 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5300 | #ifndef WLAN_OPEN_SOURCE |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5301 | /* need to make sure all of our scheduled work has completed. |
| 5302 | * This callback is called from MC thread context, so it is safe to |
| 5303 | * to call below flush workqueue API from here. |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5304 | * |
| 5305 | * Even though this is called from MC thread context, if there is a faulty |
| 5306 | * work item in the system, that can hang this call forever. So flushing |
| 5307 | * this global work queue is not safe; and now we make sure that |
| 5308 | * individual work queues are stopped correctly. But the cancel work queue |
| 5309 | * is a GPL only API, so the proprietary version of the driver would still |
| 5310 | * rely on the global work queue flush. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5311 | */ |
| 5312 | flush_scheduled_work(); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5313 | #endif |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5314 | |
| 5315 | /* We can be blocked while waiting for scheduled work to be |
| 5316 | * flushed, and the adapter structure can potentially be freed, in |
| 5317 | * which case the magic will have been reset. So make sure the |
| 5318 | * magic is still good, and hence the adapter structure is still |
| 5319 | * valid, before signaling completion */ |
| 5320 | if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic) |
| 5321 | { |
| 5322 | complete(&pAdapter->session_close_comp_var); |
| 5323 | } |
| 5324 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5325 | return eHAL_STATUS_SUCCESS; |
| 5326 | } |
| 5327 | |
| 5328 | VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter ) |
| 5329 | { |
| 5330 | struct net_device *pWlanDev = pAdapter->dev; |
| 5331 | hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 5332 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 5333 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5334 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 5335 | int rc = 0; |
| 5336 | |
| 5337 | INIT_COMPLETION(pAdapter->session_open_comp_var); |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 5338 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5339 | //Open a SME session for future operation |
| 5340 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 5341 | (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5342 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 5343 | { |
| 5344 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5345 | "sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5346 | halStatus, halStatus ); |
| 5347 | status = VOS_STATUS_E_FAILURE; |
| 5348 | goto error_sme_open; |
| 5349 | } |
| 5350 | |
| 5351 | //Block on a completion variable. Can't wait forever though. |
| 5352 | rc = wait_for_completion_interruptible_timeout( |
| 5353 | &pAdapter->session_open_comp_var, |
| 5354 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 5355 | if (!rc) |
| 5356 | { |
| 5357 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5358 | "Session is not opened within timeout period code %08d", rc ); |
| 5359 | status = VOS_STATUS_E_FAILURE; |
| 5360 | goto error_sme_open; |
| 5361 | } |
| 5362 | |
| 5363 | // Register wireless extensions |
| 5364 | if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev))) |
| 5365 | { |
| 5366 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5367 | "hdd_register_wext() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5368 | halStatus, halStatus ); |
| 5369 | status = VOS_STATUS_E_FAILURE; |
| 5370 | goto error_register_wext; |
| 5371 | } |
| 5372 | //Safe to register the hard_start_xmit function again |
| 5373 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 5374 | wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit; |
| 5375 | #else |
| 5376 | pWlanDev->hard_start_xmit = hdd_hard_start_xmit; |
| 5377 | #endif |
| 5378 | |
| 5379 | //Set the Connection State to Not Connected |
| 5380 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5381 | |
| 5382 | //Set the default operation channel |
| 5383 | pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel; |
| 5384 | |
| 5385 | /* Make the default Auth Type as OPEN*/ |
| 5386 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5387 | |
| 5388 | if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) ) |
| 5389 | { |
| 5390 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5391 | "hdd_init_tx_rx() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5392 | status, status ); |
| 5393 | goto error_init_txrx; |
| 5394 | } |
| 5395 | |
| 5396 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5397 | |
| 5398 | if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) ) |
| 5399 | { |
| 5400 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5401 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5402 | status, status ); |
| 5403 | goto error_wmm_init; |
| 5404 | } |
| 5405 | |
| 5406 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5407 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5408 | #ifdef FEATURE_WLAN_TDLS |
| 5409 | if(0 != wlan_hdd_tdls_init(pAdapter)) |
| 5410 | { |
| 5411 | status = VOS_STATUS_E_FAILURE; |
| 5412 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_tdls_init failed",__func__); |
| 5413 | goto error_tdls_init; |
| 5414 | } |
| 5415 | set_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 5416 | #endif |
| 5417 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5418 | return VOS_STATUS_SUCCESS; |
| 5419 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5420 | #ifdef FEATURE_WLAN_TDLS |
| 5421 | error_tdls_init: |
| 5422 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5423 | hdd_wmm_adapter_close(pAdapter); |
| 5424 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5425 | error_wmm_init: |
| 5426 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5427 | hdd_deinit_tx_rx(pAdapter); |
| 5428 | error_init_txrx: |
| 5429 | hdd_UnregisterWext(pWlanDev); |
| 5430 | error_register_wext: |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5431 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5432 | { |
| 5433 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5434 | if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5435 | pAdapter->sessionId, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5436 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5437 | { |
| 5438 | //Block on a completion variable. Can't wait forever though. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5439 | wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5440 | &pAdapter->session_close_comp_var, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5441 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5442 | } |
| 5443 | } |
| 5444 | error_sme_open: |
| 5445 | return status; |
| 5446 | } |
| 5447 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5448 | void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 5449 | { |
| 5450 | hdd_cfg80211_state_t *cfgState; |
| 5451 | |
| 5452 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 5453 | |
| 5454 | if( NULL != cfgState->buf ) |
| 5455 | { |
| 5456 | int rc; |
| 5457 | INIT_COMPLETION(pAdapter->tx_action_cnf_event); |
| 5458 | rc = wait_for_completion_interruptible_timeout( |
| 5459 | &pAdapter->tx_action_cnf_event, |
| 5460 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
| 5461 | if(!rc) |
| 5462 | { |
Sudhir Sattayappa Kohalli | 8ee532d | 2013-02-15 13:16:26 -0800 | [diff] [blame] | 5463 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5464 | ("ERROR: HDD Wait for Action Confirmation Failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5465 | } |
| 5466 | } |
| 5467 | return; |
| 5468 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5469 | |
| 5470 | void hdd_deinit_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 5471 | { |
| 5472 | ENTER(); |
| 5473 | switch ( pAdapter->device_mode ) |
| 5474 | { |
| 5475 | case WLAN_HDD_INFRA_STATION: |
| 5476 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5477 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5478 | { |
| 5479 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 5480 | { |
| 5481 | hdd_deinit_tx_rx( pAdapter ); |
| 5482 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5483 | } |
| 5484 | |
| 5485 | if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 5486 | { |
| 5487 | hdd_wmm_adapter_close( pAdapter ); |
| 5488 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5489 | } |
| 5490 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5491 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5492 | #ifdef FEATURE_WLAN_TDLS |
| 5493 | if(test_bit(TDLS_INIT_DONE, &pAdapter->event_flags)) |
| 5494 | { |
| 5495 | wlan_hdd_tdls_exit(pAdapter); |
| 5496 | clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 5497 | } |
| 5498 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5499 | |
| 5500 | break; |
| 5501 | } |
| 5502 | |
| 5503 | case WLAN_HDD_SOFTAP: |
| 5504 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5505 | { |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 5506 | |
| 5507 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 5508 | { |
| 5509 | hdd_wmm_adapter_close( pAdapter ); |
| 5510 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5511 | } |
| 5512 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5513 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5514 | |
| 5515 | hdd_unregister_hostapd(pAdapter); |
| 5516 | hdd_set_conparam( 0 ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5517 | wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), NULL ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5518 | break; |
| 5519 | } |
| 5520 | |
| 5521 | case WLAN_HDD_MONITOR: |
| 5522 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5523 | hdd_adapter_t* pAdapterforTx = pAdapter->sessionCtx.monitor.pAdapterForTx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5524 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 5525 | { |
| 5526 | hdd_deinit_tx_rx( pAdapter ); |
| 5527 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5528 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5529 | if(NULL != pAdapterforTx) |
| 5530 | { |
| 5531 | hdd_cleanup_actionframe(pHddCtx, pAdapterforTx); |
| 5532 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5533 | break; |
| 5534 | } |
| 5535 | |
| 5536 | |
| 5537 | default: |
| 5538 | break; |
| 5539 | } |
| 5540 | |
| 5541 | EXIT(); |
| 5542 | } |
| 5543 | |
| 5544 | void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
| 5545 | { |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5546 | struct net_device *pWlanDev; |
| 5547 | |
| 5548 | ENTER(); |
| 5549 | if (NULL == pAdapter) |
| 5550 | { |
| 5551 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5552 | "%s: HDD adapter is Null", __func__); |
| 5553 | return; |
| 5554 | } |
| 5555 | |
| 5556 | pWlanDev = pAdapter->dev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5557 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5558 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5559 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 5560 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 5561 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5562 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
| 5563 | ) |
| 5564 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 5565 | if (pAdapter) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5566 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 5567 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 5568 | { |
| 5569 | hdd_deinit_batch_scan(pAdapter); |
| 5570 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5571 | } |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 5572 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5573 | #endif |
| 5574 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5575 | if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) { |
| 5576 | if( rtnl_held ) |
| 5577 | { |
| 5578 | unregister_netdevice(pWlanDev); |
| 5579 | } |
| 5580 | else |
| 5581 | { |
| 5582 | unregister_netdev(pWlanDev); |
| 5583 | } |
| 5584 | // note that the pAdapter is no longer valid at this point |
| 5585 | // since the memory has been reclaimed |
| 5586 | } |
| 5587 | |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5588 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5589 | } |
| 5590 | |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5591 | void hdd_set_pwrparams(hdd_context_t *pHddCtx) |
| 5592 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5593 | VOS_STATUS status; |
| 5594 | hdd_adapter_t *pAdapter = NULL; |
| 5595 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5596 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5597 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5598 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5599 | /*loop through all adapters.*/ |
| 5600 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5601 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5602 | pAdapter = pAdapterNode->pAdapter; |
| 5603 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 5604 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5605 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5606 | { // we skip this registration for modes other than STA and P2P client modes. |
| 5607 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5608 | pAdapterNode = pNext; |
| 5609 | continue; |
| 5610 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5611 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5612 | //Apply Dynamic DTIM For P2P |
| 5613 | //Only if ignoreDynamicDtimInP2pMode is not set in ini |
| 5614 | if ((pHddCtx->cfg_ini->enableDynamicDTIM || |
| 5615 | pHddCtx->cfg_ini->enableModulatedDTIM) && |
| 5616 | ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 5617 | ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) && |
| 5618 | !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) && |
| 5619 | (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) && |
| 5620 | (eConnectionState_Associated == |
| 5621 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) && |
| 5622 | (pHddCtx->cfg_ini->fIsBmpsEnabled)) |
| 5623 | { |
| 5624 | tSirSetPowerParamsReq powerRequest = { 0 }; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5625 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5626 | powerRequest.uIgnoreDTIM = 1; |
| 5627 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
| 5628 | |
| 5629 | if (pHddCtx->cfg_ini->enableModulatedDTIM) |
| 5630 | { |
| 5631 | powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM; |
| 5632 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
| 5633 | } |
| 5634 | else |
| 5635 | { |
| 5636 | powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM; |
| 5637 | } |
| 5638 | |
| 5639 | /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM |
| 5640 | * specified during Enter/Exit BMPS when LCD off*/ |
| 5641 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 5642 | NULL, eANI_BOOLEAN_FALSE); |
| 5643 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 5644 | NULL, eANI_BOOLEAN_FALSE); |
| 5645 | |
| 5646 | /* switch to the DTIM specified in cfg.ini */ |
| 5647 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5648 | "Switch to DTIM %d", powerRequest.uListenInterval); |
| 5649 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 5650 | break; |
| 5651 | |
| 5652 | } |
| 5653 | |
| 5654 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5655 | pAdapterNode = pNext; |
| 5656 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5657 | } |
| 5658 | |
| 5659 | void hdd_reset_pwrparams(hdd_context_t *pHddCtx) |
| 5660 | { |
| 5661 | /*Switch back to DTIM 1*/ |
| 5662 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 5663 | |
| 5664 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 5665 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 5666 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5667 | |
| 5668 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 5669 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 5670 | NULL, eANI_BOOLEAN_FALSE); |
| 5671 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 5672 | NULL, eANI_BOOLEAN_FALSE); |
| 5673 | |
| 5674 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5675 | "Switch to DTIM%d",powerRequest.uListenInterval); |
| 5676 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 5677 | |
| 5678 | } |
| 5679 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5680 | VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx) |
| 5681 | { |
| 5682 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 5683 | |
| 5684 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 5685 | { |
| 5686 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 5687 | } |
| 5688 | |
| 5689 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 5690 | { |
| 5691 | sme_StartAutoBmpsTimer(pHddCtx->hHal); |
| 5692 | } |
| 5693 | |
| 5694 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 5695 | { |
| 5696 | sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 5697 | } |
| 5698 | |
| 5699 | return status; |
| 5700 | } |
| 5701 | |
| 5702 | VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type) |
| 5703 | { |
| 5704 | hdd_adapter_t *pAdapter = NULL; |
| 5705 | eHalStatus halStatus; |
| 5706 | VOS_STATUS status = VOS_STATUS_E_INVAL; |
| 5707 | v_BOOL_t disableBmps = FALSE; |
| 5708 | v_BOOL_t disableImps = FALSE; |
| 5709 | |
| 5710 | switch(session_type) |
| 5711 | { |
| 5712 | case WLAN_HDD_INFRA_STATION: |
| 5713 | case WLAN_HDD_SOFTAP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5714 | case WLAN_HDD_P2P_CLIENT: |
| 5715 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5716 | //Exit BMPS -> Is Sta/P2P Client is already connected |
| 5717 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 5718 | if((NULL != pAdapter)&& |
| 5719 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 5720 | { |
| 5721 | disableBmps = TRUE; |
| 5722 | } |
| 5723 | |
| 5724 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 5725 | if((NULL != pAdapter)&& |
| 5726 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 5727 | { |
| 5728 | disableBmps = TRUE; |
| 5729 | } |
| 5730 | |
| 5731 | //Exit both Bmps and Imps incase of Go/SAP Mode |
| 5732 | if((WLAN_HDD_SOFTAP == session_type) || |
| 5733 | (WLAN_HDD_P2P_GO == session_type)) |
| 5734 | { |
| 5735 | disableBmps = TRUE; |
| 5736 | disableImps = TRUE; |
| 5737 | } |
| 5738 | |
| 5739 | if(TRUE == disableImps) |
| 5740 | { |
| 5741 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 5742 | { |
| 5743 | sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 5744 | } |
| 5745 | } |
| 5746 | |
| 5747 | if(TRUE == disableBmps) |
| 5748 | { |
| 5749 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 5750 | { |
| 5751 | halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 5752 | |
| 5753 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 5754 | { |
| 5755 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5756 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5757 | VOS_ASSERT(0); |
| 5758 | return status; |
| 5759 | } |
| 5760 | } |
| 5761 | |
| 5762 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 5763 | { |
| 5764 | halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal); |
| 5765 | |
| 5766 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 5767 | { |
| 5768 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5769 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Stop Auto Bmps Timer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5770 | VOS_ASSERT(0); |
| 5771 | return status; |
| 5772 | } |
| 5773 | } |
| 5774 | } |
| 5775 | |
| 5776 | if((TRUE == disableBmps) || |
| 5777 | (TRUE == disableImps)) |
| 5778 | { |
| 5779 | /* Now, get the chip into Full Power now */ |
| 5780 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 5781 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk, |
| 5782 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 5783 | |
| 5784 | if(halStatus != eHAL_STATUS_SUCCESS) |
| 5785 | { |
| 5786 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 5787 | { |
| 5788 | //Block on a completion variable. Can't wait forever though |
| 5789 | wait_for_completion_interruptible_timeout( |
| 5790 | &pHddCtx->full_pwr_comp_var, msecs_to_jiffies(1000)); |
| 5791 | } |
| 5792 | else |
| 5793 | { |
| 5794 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5795 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5796 | VOS_ASSERT(0); |
| 5797 | return status; |
| 5798 | } |
| 5799 | } |
| 5800 | |
| 5801 | status = VOS_STATUS_SUCCESS; |
| 5802 | } |
| 5803 | |
| 5804 | break; |
| 5805 | } |
| 5806 | return status; |
| 5807 | } |
| 5808 | |
| 5809 | hdd_adapter_t* hdd_open_adapter( hdd_context_t *pHddCtx, tANI_U8 session_type, |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 5810 | const char *iface_name, tSirMacAddr macAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5811 | tANI_U8 rtnl_held ) |
| 5812 | { |
| 5813 | hdd_adapter_t *pAdapter = NULL; |
| 5814 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
| 5815 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 5816 | VOS_STATUS exitbmpsStatus; |
| 5817 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5818 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s iface =%s type = %d",__func__,iface_name,session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5819 | |
| 5820 | //Disable BMPS incase of Concurrency |
| 5821 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type); |
| 5822 | |
| 5823 | if(VOS_STATUS_E_FAILURE == exitbmpsStatus) |
| 5824 | { |
| 5825 | //Fail to Exit BMPS |
| 5826 | VOS_ASSERT(0); |
| 5827 | return NULL; |
| 5828 | } |
| 5829 | |
| 5830 | switch(session_type) |
| 5831 | { |
| 5832 | case WLAN_HDD_INFRA_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5833 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5834 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5835 | { |
| 5836 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 5837 | |
| 5838 | if( NULL == pAdapter ) |
| 5839 | return NULL; |
| 5840 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 5841 | #ifdef FEATURE_WLAN_TDLS |
| 5842 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 5843 | * protect the concurrent access for the Adapters by TDLS module. |
| 5844 | */ |
| 5845 | if (mutex_lock_interruptible(&pHddCtx->tdls_lock)) |
| 5846 | { |
| 5847 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5848 | "%s: unable to lock list", __func__); |
| 5849 | return NULL; |
| 5850 | } |
| 5851 | #endif |
| 5852 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5853 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ? |
| 5854 | NL80211_IFTYPE_P2P_CLIENT: |
| 5855 | NL80211_IFTYPE_STATION; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5856 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5857 | pAdapter->device_mode = session_type; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 5858 | #ifdef FEATURE_WLAN_TDLS |
| 5859 | mutex_unlock(&pHddCtx->tdls_lock); |
| 5860 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 5861 | |
| 5862 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5863 | if( VOS_STATUS_SUCCESS != status ) |
| 5864 | goto err_free_netdev; |
| 5865 | |
| 5866 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 5867 | if( VOS_STATUS_SUCCESS != status ) |
| 5868 | { |
| 5869 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 5870 | goto err_free_netdev; |
| 5871 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 5872 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 5873 | // Workqueue which gets scheduled in IPv4 notification callback. |
| 5874 | INIT_WORK(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue); |
| 5875 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 5876 | #ifdef WLAN_NS_OFFLOAD |
| 5877 | // Workqueue which gets scheduled in IPv6 notification callback. |
| 5878 | INIT_WORK(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue); |
| 5879 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5880 | //Stop the Interface TX queue. |
| 5881 | netif_tx_disable(pAdapter->dev); |
| 5882 | //netif_tx_disable(pWlanDev); |
| 5883 | netif_carrier_off(pAdapter->dev); |
| 5884 | |
| 5885 | break; |
| 5886 | } |
| 5887 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5888 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5889 | case WLAN_HDD_SOFTAP: |
| 5890 | { |
| 5891 | pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name ); |
| 5892 | if( NULL == pAdapter ) |
| 5893 | return NULL; |
| 5894 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5895 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ? |
| 5896 | NL80211_IFTYPE_AP: |
| 5897 | NL80211_IFTYPE_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5898 | pAdapter->device_mode = session_type; |
| 5899 | |
| 5900 | status = hdd_init_ap_mode(pAdapter); |
| 5901 | if( VOS_STATUS_SUCCESS != status ) |
| 5902 | goto err_free_netdev; |
| 5903 | |
| 5904 | status = hdd_register_hostapd( pAdapter, rtnl_held ); |
| 5905 | if( VOS_STATUS_SUCCESS != status ) |
| 5906 | { |
| 5907 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 5908 | goto err_free_netdev; |
| 5909 | } |
| 5910 | |
| 5911 | netif_tx_disable(pAdapter->dev); |
| 5912 | netif_carrier_off(pAdapter->dev); |
| 5913 | |
| 5914 | hdd_set_conparam( 1 ); |
| 5915 | break; |
| 5916 | } |
| 5917 | case WLAN_HDD_MONITOR: |
| 5918 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5919 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 5920 | if( NULL == pAdapter ) |
| 5921 | return NULL; |
| 5922 | |
| 5923 | pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
| 5924 | pAdapter->device_mode = session_type; |
| 5925 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 5926 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 5927 | pAdapter->dev->netdev_ops = &wlan_mon_drv_ops; |
| 5928 | #else |
| 5929 | pAdapter->dev->open = hdd_mon_open; |
| 5930 | pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit; |
| 5931 | #endif |
| 5932 | hdd_init_tx_rx( pAdapter ); |
| 5933 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5934 | //Set adapter to be used for data tx. It will use either GO or softap. |
| 5935 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 5936 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_SOFTAP); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5937 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) |
| 5938 | { |
| 5939 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 5940 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_GO); |
| 5941 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5942 | /* This workqueue will be used to transmit management packet over |
| 5943 | * monitor interface. */ |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 5944 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) { |
| 5945 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:hdd_get_adapter",__func__); |
| 5946 | return NULL; |
| 5947 | } |
Madan Mohan Koyyalamudi | 9f40ceb | 2012-10-18 19:22:56 -0700 | [diff] [blame] | 5948 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5949 | INIT_WORK(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue, |
| 5950 | hdd_mon_tx_work_queue); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5951 | } |
| 5952 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5953 | case WLAN_HDD_FTM: |
| 5954 | { |
| 5955 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 5956 | |
| 5957 | if( NULL == pAdapter ) |
| 5958 | return NULL; |
| 5959 | /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning |
| 5960 | * message while loading driver in FTM mode. */ |
| 5961 | pAdapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5962 | pAdapter->device_mode = session_type; |
| 5963 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 5964 | |
| 5965 | hdd_init_tx_rx( pAdapter ); |
| 5966 | |
| 5967 | //Stop the Interface TX queue. |
| 5968 | netif_tx_disable(pAdapter->dev); |
| 5969 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5970 | } |
| 5971 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5972 | default: |
| 5973 | { |
| 5974 | VOS_ASSERT(0); |
| 5975 | return NULL; |
| 5976 | } |
| 5977 | } |
| 5978 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5979 | if( VOS_STATUS_SUCCESS == status ) |
| 5980 | { |
| 5981 | //Add it to the hdd's session list. |
| 5982 | pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) ); |
| 5983 | if( NULL == pHddAdapterNode ) |
| 5984 | { |
| 5985 | status = VOS_STATUS_E_NOMEM; |
| 5986 | } |
| 5987 | else |
| 5988 | { |
| 5989 | pHddAdapterNode->pAdapter = pAdapter; |
| 5990 | status = hdd_add_adapter_back ( pHddCtx, |
| 5991 | pHddAdapterNode ); |
| 5992 | } |
| 5993 | } |
| 5994 | |
| 5995 | if( VOS_STATUS_SUCCESS != status ) |
| 5996 | { |
| 5997 | if( NULL != pAdapter ) |
| 5998 | { |
| 5999 | hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held ); |
| 6000 | pAdapter = NULL; |
| 6001 | } |
| 6002 | if( NULL != pHddAdapterNode ) |
| 6003 | { |
| 6004 | vos_mem_free( pHddAdapterNode ); |
| 6005 | } |
| 6006 | |
| 6007 | goto resume_bmps; |
| 6008 | } |
| 6009 | |
| 6010 | if(VOS_STATUS_SUCCESS == status) |
| 6011 | { |
| 6012 | wlan_hdd_set_concurrency_mode(pHddCtx, session_type); |
| 6013 | |
Madan Mohan Koyyalamudi | 96dd30d | 2012-10-05 17:24:51 -0700 | [diff] [blame] | 6014 | //Initialize the WoWL service |
| 6015 | if(!hdd_init_wowl(pAdapter)) |
| 6016 | { |
| 6017 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__); |
| 6018 | goto err_free_netdev; |
| 6019 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6020 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6021 | return pAdapter; |
| 6022 | |
| 6023 | err_free_netdev: |
| 6024 | free_netdev(pAdapter->dev); |
| 6025 | wlan_hdd_release_intf_addr( pHddCtx, |
| 6026 | pAdapter->macAddressCurrent.bytes ); |
| 6027 | |
| 6028 | resume_bmps: |
| 6029 | //If bmps disabled enable it |
| 6030 | if(VOS_STATUS_SUCCESS == exitbmpsStatus) |
| 6031 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6032 | if (pHddCtx->hdd_wlan_suspended) |
| 6033 | { |
| 6034 | hdd_set_pwrparams(pHddCtx); |
| 6035 | } |
| 6036 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6037 | } |
| 6038 | return NULL; |
| 6039 | } |
| 6040 | |
| 6041 | VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 6042 | tANI_U8 rtnl_held ) |
| 6043 | { |
| 6044 | hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext; |
| 6045 | VOS_STATUS status; |
| 6046 | |
| 6047 | status = hdd_get_front_adapter ( pHddCtx, &pCurrent ); |
| 6048 | if( VOS_STATUS_SUCCESS != status ) |
| 6049 | return status; |
| 6050 | |
| 6051 | while ( pCurrent->pAdapter != pAdapter ) |
| 6052 | { |
| 6053 | status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext ); |
| 6054 | if( VOS_STATUS_SUCCESS != status ) |
| 6055 | break; |
| 6056 | |
| 6057 | pCurrent = pNext; |
| 6058 | } |
| 6059 | pAdapterNode = pCurrent; |
| 6060 | if( VOS_STATUS_SUCCESS == status ) |
| 6061 | { |
| 6062 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 6063 | hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6064 | |
| 6065 | #ifdef FEATURE_WLAN_TDLS |
| 6066 | |
| 6067 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6068 | * protect the concurrent access for the Adapters by TDLS module. |
| 6069 | */ |
| 6070 | if (mutex_lock_interruptible(&pHddCtx->tdls_lock)) |
| 6071 | { |
| 6072 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6073 | "%s: unable to lock list", __func__); |
| 6074 | return VOS_STATUS_E_FAILURE; |
| 6075 | } |
| 6076 | #endif |
| 6077 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6078 | hdd_remove_adapter( pHddCtx, pAdapterNode ); |
| 6079 | vos_mem_free( pAdapterNode ); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6080 | pAdapterNode = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6081 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6082 | #ifdef FEATURE_WLAN_TDLS |
| 6083 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6084 | #endif |
| 6085 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6086 | |
| 6087 | /* If there is a single session of STA/P2P client, re-enable BMPS */ |
| 6088 | if ((!vos_concurrent_sessions_running()) && |
| 6089 | ((pHddCtx->no_of_sessions[VOS_STA_MODE] >= 1) || |
| 6090 | (pHddCtx->no_of_sessions[VOS_P2P_CLIENT_MODE] >= 1))) |
| 6091 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6092 | if (pHddCtx->hdd_wlan_suspended) |
| 6093 | { |
| 6094 | hdd_set_pwrparams(pHddCtx); |
| 6095 | } |
| 6096 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6097 | } |
| 6098 | |
| 6099 | return VOS_STATUS_SUCCESS; |
| 6100 | } |
| 6101 | |
| 6102 | return VOS_STATUS_E_FAILURE; |
| 6103 | } |
| 6104 | |
| 6105 | VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx ) |
| 6106 | { |
| 6107 | hdd_adapter_list_node_t *pHddAdapterNode; |
| 6108 | VOS_STATUS status; |
| 6109 | |
| 6110 | ENTER(); |
| 6111 | |
| 6112 | do |
| 6113 | { |
| 6114 | status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode ); |
| 6115 | if( pHddAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6116 | { |
| 6117 | hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE ); |
| 6118 | vos_mem_free( pHddAdapterNode ); |
| 6119 | } |
| 6120 | }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status ); |
| 6121 | |
| 6122 | EXIT(); |
| 6123 | |
| 6124 | return VOS_STATUS_SUCCESS; |
| 6125 | } |
| 6126 | |
| 6127 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter) |
| 6128 | { |
| 6129 | v_U8_t addIE[1] = {0}; |
| 6130 | |
| 6131 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6132 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL, |
| 6133 | eANI_BOOLEAN_FALSE) ) |
| 6134 | { |
| 6135 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6136 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6137 | } |
| 6138 | |
| 6139 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6140 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 6141 | eANI_BOOLEAN_FALSE) ) |
| 6142 | { |
| 6143 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6144 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6145 | } |
| 6146 | |
| 6147 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6148 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 6149 | eANI_BOOLEAN_FALSE) ) |
| 6150 | { |
| 6151 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6152 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6153 | } |
| 6154 | } |
| 6155 | |
| 6156 | VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 6157 | { |
| 6158 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 6159 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6160 | union iwreq_data wrqu; |
| 6161 | |
| 6162 | ENTER(); |
| 6163 | |
| 6164 | switch(pAdapter->device_mode) |
| 6165 | { |
| 6166 | case WLAN_HDD_INFRA_STATION: |
| 6167 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6168 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6169 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 6170 | { |
| 6171 | if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 6172 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 6173 | pAdapter->sessionId, |
| 6174 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6175 | else |
| 6176 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 6177 | pAdapter->sessionId, |
| 6178 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 6179 | //success implies disconnect command got queued up successfully |
| 6180 | if(halStatus == eHAL_STATUS_SUCCESS) |
| 6181 | { |
| 6182 | wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
| 6183 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6184 | } |
| 6185 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6186 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6187 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 6188 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
| 6189 | } |
| 6190 | else |
| 6191 | { |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 6192 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6193 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6194 | #ifdef WLAN_OPEN_SOURCE |
| 6195 | #ifdef WLAN_NS_OFFLOAD |
| 6196 | cancel_work_sync(&pAdapter->ipv6NotifierWorkQueue); |
| 6197 | #endif |
| 6198 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6199 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6200 | #ifdef WLAN_OPEN_SOURCE |
| 6201 | cancel_work_sync(&pAdapter->ipv4NotifierWorkQueue); |
| 6202 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6203 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
| 6204 | { |
| 6205 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
| 6206 | if (eHAL_STATUS_SUCCESS == |
| 6207 | sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, |
| 6208 | hdd_smeCloseSessionCallback, pAdapter)) |
| 6209 | { |
| 6210 | //Block on a completion variable. Can't wait forever though. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6211 | wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6212 | &pAdapter->session_close_comp_var, |
| 6213 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 6214 | } |
| 6215 | } |
| 6216 | |
| 6217 | break; |
| 6218 | |
| 6219 | case WLAN_HDD_SOFTAP: |
| 6220 | case WLAN_HDD_P2P_GO: |
| 6221 | //Any softap specific cleanup here... |
| 6222 | mutex_lock(&pHddCtx->sap_lock); |
| 6223 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 6224 | { |
| 6225 | VOS_STATUS status; |
| 6226 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6227 | |
| 6228 | //Stop Bss. |
| 6229 | status = WLANSAP_StopBss(pHddCtx->pvosContext); |
| 6230 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 6231 | { |
| 6232 | hdd_hostapd_state_t *pHostapdState = |
| 6233 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 6234 | |
| 6235 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 6236 | |
| 6237 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 6238 | { |
| 6239 | hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6240 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6241 | } |
| 6242 | } |
| 6243 | else |
| 6244 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6245 | hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6246 | } |
| 6247 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 6248 | |
| 6249 | if (eHAL_STATUS_FAILURE == |
| 6250 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 6251 | 0, NULL, eANI_BOOLEAN_FALSE)) |
| 6252 | { |
| 6253 | hddLog(LOGE, |
| 6254 | "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6255 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6256 | } |
| 6257 | |
| 6258 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 6259 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 6260 | eANI_BOOLEAN_FALSE) ) |
| 6261 | { |
| 6262 | hddLog(LOGE, |
| 6263 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
| 6264 | } |
| 6265 | |
| 6266 | // Reset WNI_CFG_PROBE_RSP Flags |
| 6267 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 6268 | kfree(pAdapter->sessionCtx.ap.beacon); |
| 6269 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 6270 | } |
| 6271 | mutex_unlock(&pHddCtx->sap_lock); |
| 6272 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6273 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6274 | case WLAN_HDD_MONITOR: |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6275 | #ifdef WLAN_OPEN_SOURCE |
| 6276 | cancel_work_sync(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue); |
| 6277 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6278 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6279 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6280 | default: |
| 6281 | break; |
| 6282 | } |
| 6283 | |
| 6284 | EXIT(); |
| 6285 | return VOS_STATUS_SUCCESS; |
| 6286 | } |
| 6287 | |
| 6288 | VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx ) |
| 6289 | { |
| 6290 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6291 | VOS_STATUS status; |
| 6292 | hdd_adapter_t *pAdapter; |
| 6293 | |
| 6294 | ENTER(); |
| 6295 | |
| 6296 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6297 | |
| 6298 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6299 | { |
| 6300 | pAdapter = pAdapterNode->pAdapter; |
| 6301 | netif_tx_disable(pAdapter->dev); |
| 6302 | netif_carrier_off(pAdapter->dev); |
| 6303 | |
| 6304 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 6305 | |
| 6306 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6307 | pAdapterNode = pNext; |
| 6308 | } |
| 6309 | |
| 6310 | EXIT(); |
| 6311 | |
| 6312 | return VOS_STATUS_SUCCESS; |
| 6313 | } |
| 6314 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6315 | |
| 6316 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 6317 | /**--------------------------------------------------------------------------- |
| 6318 | |
| 6319 | \brief hdd_deinit_batch_scan () - This function cleans up batch scan data |
| 6320 | structures |
| 6321 | |
| 6322 | \param - pAdapter Pointer to HDD adapter |
| 6323 | |
| 6324 | \return - None |
| 6325 | |
| 6326 | --------------------------------------------------------------------------*/ |
| 6327 | void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter) |
| 6328 | { |
| 6329 | tHddBatchScanRsp *pNode; |
| 6330 | tHddBatchScanRsp *pPrev; |
| 6331 | |
| 6332 | if (pAdapter) |
| 6333 | { |
| 6334 | pNode = pAdapter->pBatchScanRsp; |
| 6335 | while (pNode) |
| 6336 | { |
| 6337 | pPrev = pNode; |
| 6338 | pNode = pNode->pNext; |
| 6339 | vos_mem_free((v_VOID_t * )pPrev); |
| 6340 | } |
| 6341 | pAdapter->pBatchScanRsp = NULL; |
| 6342 | } |
| 6343 | |
| 6344 | pAdapter->pBatchScanRsp = NULL; |
| 6345 | pAdapter->numScanList = 0; |
| 6346 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 6347 | pAdapter->prev_batch_id = 0; |
| 6348 | |
| 6349 | return; |
| 6350 | } |
| 6351 | #endif |
| 6352 | |
| 6353 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6354 | VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx ) |
| 6355 | { |
| 6356 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6357 | VOS_STATUS status; |
| 6358 | hdd_adapter_t *pAdapter; |
| 6359 | |
| 6360 | ENTER(); |
| 6361 | |
| 6362 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6363 | |
| 6364 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6365 | { |
| 6366 | pAdapter = pAdapterNode->pAdapter; |
| 6367 | netif_tx_disable(pAdapter->dev); |
| 6368 | netif_carrier_off(pAdapter->dev); |
| 6369 | |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 6370 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
| 6371 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6372 | hdd_deinit_tx_rx(pAdapter); |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 6373 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6374 | { |
| 6375 | hdd_wmm_adapter_close( pAdapter ); |
| 6376 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6377 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6378 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6379 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 6380 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 6381 | { |
| 6382 | hdd_deinit_batch_scan(pAdapter); |
| 6383 | } |
| 6384 | #endif |
| 6385 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6386 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6387 | pAdapterNode = pNext; |
| 6388 | } |
| 6389 | |
| 6390 | EXIT(); |
| 6391 | |
| 6392 | return VOS_STATUS_SUCCESS; |
| 6393 | } |
| 6394 | |
| 6395 | VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx ) |
| 6396 | { |
| 6397 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6398 | VOS_STATUS status; |
| 6399 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6400 | eConnectionState connState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6401 | |
| 6402 | ENTER(); |
| 6403 | |
| 6404 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6405 | |
| 6406 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6407 | { |
| 6408 | pAdapter = pAdapterNode->pAdapter; |
| 6409 | |
| 6410 | switch(pAdapter->device_mode) |
| 6411 | { |
| 6412 | case WLAN_HDD_INFRA_STATION: |
| 6413 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6414 | case WLAN_HDD_P2P_DEVICE: |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6415 | |
| 6416 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState; |
| 6417 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6418 | hdd_init_station_mode(pAdapter); |
| 6419 | /* Open the gates for HDD to receive Wext commands */ |
| 6420 | pAdapter->isLinkUpSvcNeeded = FALSE; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6421 | pHddCtx->scan_info.mScanPending = FALSE; |
| 6422 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6423 | |
| 6424 | //Trigger the initial scan |
| 6425 | hdd_wlan_initial_scan(pAdapter); |
| 6426 | |
| 6427 | //Indicate disconnect event to supplicant if associated previously |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6428 | if (eConnectionState_Associated == connState || |
| 6429 | eConnectionState_IbssConnected == connState ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6430 | { |
| 6431 | union iwreq_data wrqu; |
| 6432 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6433 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6434 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 6435 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 6436 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6437 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6438 | /* indicate disconnected event to nl80211 */ |
| 6439 | cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED, |
| 6440 | NULL, 0, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6441 | } |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6442 | else if (eConnectionState_Connecting == connState) |
| 6443 | { |
| 6444 | /* |
| 6445 | * Indicate connect failure to supplicant if we were in the |
| 6446 | * process of connecting |
| 6447 | */ |
| 6448 | cfg80211_connect_result(pAdapter->dev, NULL, |
| 6449 | NULL, 0, NULL, 0, |
| 6450 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 6451 | GFP_KERNEL); |
| 6452 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6453 | break; |
| 6454 | |
| 6455 | case WLAN_HDD_SOFTAP: |
| 6456 | /* softAP can handle SSR */ |
| 6457 | break; |
| 6458 | |
| 6459 | case WLAN_HDD_P2P_GO: |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 6460 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6461 | __func__); |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 6462 | cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6463 | break; |
| 6464 | |
| 6465 | case WLAN_HDD_MONITOR: |
| 6466 | /* monitor interface start */ |
| 6467 | break; |
| 6468 | default: |
| 6469 | break; |
| 6470 | } |
| 6471 | |
| 6472 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6473 | pAdapterNode = pNext; |
| 6474 | } |
| 6475 | |
| 6476 | EXIT(); |
| 6477 | |
| 6478 | return VOS_STATUS_SUCCESS; |
| 6479 | } |
| 6480 | |
| 6481 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ) |
| 6482 | { |
| 6483 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6484 | hdd_adapter_t *pAdapter; |
| 6485 | VOS_STATUS status; |
| 6486 | v_U32_t roamId; |
| 6487 | |
| 6488 | ENTER(); |
| 6489 | |
| 6490 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6491 | |
| 6492 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6493 | { |
| 6494 | pAdapter = pAdapterNode->pAdapter; |
| 6495 | |
| 6496 | if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 6497 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 6498 | { |
| 6499 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6500 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6501 | |
| 6502 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 6503 | init_completion(&pAdapter->disconnect_comp_var); |
| 6504 | sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, |
| 6505 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 6506 | |
| 6507 | wait_for_completion_interruptible_timeout( |
| 6508 | &pAdapter->disconnect_comp_var, |
| 6509 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6510 | |
| 6511 | pWextState->roamProfile.csrPersona = pAdapter->device_mode; |
| 6512 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 6513 | sme_RoamConnect(pHddCtx->hHal, |
| 6514 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 6515 | &roamId); |
| 6516 | } |
| 6517 | |
| 6518 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6519 | pAdapterNode = pNext; |
| 6520 | } |
| 6521 | |
| 6522 | EXIT(); |
| 6523 | |
| 6524 | return VOS_STATUS_SUCCESS; |
| 6525 | } |
| 6526 | |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 6527 | void hdd_dump_concurrency_info(hdd_context_t *pHddCtx) |
| 6528 | { |
| 6529 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6530 | VOS_STATUS status; |
| 6531 | hdd_adapter_t *pAdapter; |
| 6532 | hdd_station_ctx_t *pHddStaCtx; |
| 6533 | hdd_ap_ctx_t *pHddApCtx; |
| 6534 | hdd_hostapd_state_t * pHostapdState; |
| 6535 | tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 }; |
| 6536 | v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 6537 | const char *p2pMode = "DEV"; |
| 6538 | const char *ccMode = "Standalone"; |
| 6539 | int n; |
| 6540 | |
| 6541 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6542 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6543 | { |
| 6544 | pAdapter = pAdapterNode->pAdapter; |
| 6545 | switch (pAdapter->device_mode) { |
| 6546 | case WLAN_HDD_INFRA_STATION: |
| 6547 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6548 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 6549 | staChannel = pHddStaCtx->conn_info.operationChannel; |
| 6550 | memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid)); |
| 6551 | } |
| 6552 | break; |
| 6553 | case WLAN_HDD_P2P_CLIENT: |
| 6554 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6555 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 6556 | p2pChannel = pHddStaCtx->conn_info.operationChannel; |
| 6557 | memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid)); |
| 6558 | p2pMode = "CLI"; |
| 6559 | } |
| 6560 | break; |
| 6561 | case WLAN_HDD_P2P_GO: |
| 6562 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 6563 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 6564 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 6565 | p2pChannel = pHddApCtx->operatingChannel; |
| 6566 | memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid)); |
| 6567 | } |
| 6568 | p2pMode = "GO"; |
| 6569 | break; |
| 6570 | case WLAN_HDD_SOFTAP: |
| 6571 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 6572 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 6573 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 6574 | apChannel = pHddApCtx->operatingChannel; |
| 6575 | memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid)); |
| 6576 | } |
| 6577 | break; |
| 6578 | default: |
| 6579 | break; |
| 6580 | } |
| 6581 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6582 | pAdapterNode = pNext; |
| 6583 | } |
| 6584 | if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) { |
| 6585 | ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC"; |
| 6586 | } |
| 6587 | n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s", |
| 6588 | staChannel, MAC_ADDR_ARRAY(staBssid), ccMode); |
| 6589 | if (p2pChannel > 0) { |
| 6590 | n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR, |
| 6591 | p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid)); |
| 6592 | } |
| 6593 | if (apChannel > 0) { |
| 6594 | n += pr_info("AP(%d) " MAC_ADDRESS_STR, |
| 6595 | apChannel, MAC_ADDR_ARRAY(apBssid)); |
| 6596 | } |
| 6597 | |
| 6598 | if (p2pChannel > 0 && apChannel > 0) { |
| 6599 | hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel); |
| 6600 | } |
| 6601 | } |
| 6602 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 6603 | bool hdd_is_ssr_required( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6604 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 6605 | return (isSsrRequired == HDD_SSR_REQUIRED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6606 | } |
| 6607 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 6608 | /* Once SSR is disabled then it cannot be set. */ |
| 6609 | void hdd_set_ssr_required( e_hdd_ssr_required value) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6610 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 6611 | if (HDD_SSR_DISABLED == isSsrRequired) |
| 6612 | return; |
| 6613 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6614 | isSsrRequired = value; |
| 6615 | } |
| 6616 | |
| 6617 | VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx, |
| 6618 | hdd_adapter_list_node_t** ppAdapterNode) |
| 6619 | { |
| 6620 | VOS_STATUS status; |
| 6621 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 6622 | status = hdd_list_peek_front ( &pHddCtx->hddAdapters, |
| 6623 | (hdd_list_node_t**) ppAdapterNode ); |
| 6624 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 6625 | return status; |
| 6626 | } |
| 6627 | |
| 6628 | VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx, |
| 6629 | hdd_adapter_list_node_t* pAdapterNode, |
| 6630 | hdd_adapter_list_node_t** pNextAdapterNode) |
| 6631 | { |
| 6632 | VOS_STATUS status; |
| 6633 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 6634 | status = hdd_list_peek_next ( &pHddCtx->hddAdapters, |
| 6635 | (hdd_list_node_t*) pAdapterNode, |
| 6636 | (hdd_list_node_t**)pNextAdapterNode ); |
| 6637 | |
| 6638 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 6639 | return status; |
| 6640 | } |
| 6641 | |
| 6642 | VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx, |
| 6643 | hdd_adapter_list_node_t* pAdapterNode) |
| 6644 | { |
| 6645 | VOS_STATUS status; |
| 6646 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 6647 | status = hdd_list_remove_node ( &pHddCtx->hddAdapters, |
| 6648 | &pAdapterNode->node ); |
| 6649 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 6650 | return status; |
| 6651 | } |
| 6652 | |
| 6653 | VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx, |
| 6654 | hdd_adapter_list_node_t** ppAdapterNode) |
| 6655 | { |
| 6656 | VOS_STATUS status; |
| 6657 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 6658 | status = hdd_list_remove_front( &pHddCtx->hddAdapters, |
| 6659 | (hdd_list_node_t**) ppAdapterNode ); |
| 6660 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 6661 | return status; |
| 6662 | } |
| 6663 | |
| 6664 | VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx, |
| 6665 | hdd_adapter_list_node_t* pAdapterNode) |
| 6666 | { |
| 6667 | VOS_STATUS status; |
| 6668 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 6669 | status = hdd_list_insert_back ( &pHddCtx->hddAdapters, |
| 6670 | (hdd_list_node_t*) pAdapterNode ); |
| 6671 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 6672 | return status; |
| 6673 | } |
| 6674 | |
| 6675 | VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx, |
| 6676 | hdd_adapter_list_node_t* pAdapterNode) |
| 6677 | { |
| 6678 | VOS_STATUS status; |
| 6679 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 6680 | status = hdd_list_insert_front ( &pHddCtx->hddAdapters, |
| 6681 | (hdd_list_node_t*) pAdapterNode ); |
| 6682 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 6683 | return status; |
| 6684 | } |
| 6685 | |
| 6686 | hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx, |
| 6687 | tSirMacAddr macAddr ) |
| 6688 | { |
| 6689 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6690 | hdd_adapter_t *pAdapter; |
| 6691 | VOS_STATUS status; |
| 6692 | |
| 6693 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6694 | |
| 6695 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6696 | { |
| 6697 | pAdapter = pAdapterNode->pAdapter; |
| 6698 | |
| 6699 | if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes, |
| 6700 | macAddr, sizeof(tSirMacAddr) ) ) |
| 6701 | { |
| 6702 | return pAdapter; |
| 6703 | } |
| 6704 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6705 | pAdapterNode = pNext; |
| 6706 | } |
| 6707 | |
| 6708 | return NULL; |
| 6709 | |
| 6710 | } |
| 6711 | |
| 6712 | hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name ) |
| 6713 | { |
| 6714 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6715 | hdd_adapter_t *pAdapter; |
| 6716 | VOS_STATUS status; |
| 6717 | |
| 6718 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6719 | |
| 6720 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6721 | { |
| 6722 | pAdapter = pAdapterNode->pAdapter; |
| 6723 | |
| 6724 | if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name, |
| 6725 | IFNAMSIZ ) ) |
| 6726 | { |
| 6727 | return pAdapter; |
| 6728 | } |
| 6729 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6730 | pAdapterNode = pNext; |
| 6731 | } |
| 6732 | |
| 6733 | return NULL; |
| 6734 | |
| 6735 | } |
| 6736 | |
| 6737 | hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 6738 | { |
| 6739 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6740 | hdd_adapter_t *pAdapter; |
| 6741 | VOS_STATUS status; |
| 6742 | |
| 6743 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6744 | |
| 6745 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6746 | { |
| 6747 | pAdapter = pAdapterNode->pAdapter; |
| 6748 | |
| 6749 | if( pAdapter && (mode == pAdapter->device_mode) ) |
| 6750 | { |
| 6751 | return pAdapter; |
| 6752 | } |
| 6753 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6754 | pAdapterNode = pNext; |
| 6755 | } |
| 6756 | |
| 6757 | return NULL; |
| 6758 | |
| 6759 | } |
| 6760 | |
| 6761 | //Remove this function later |
| 6762 | hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx ) |
| 6763 | { |
| 6764 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6765 | hdd_adapter_t *pAdapter; |
| 6766 | VOS_STATUS status; |
| 6767 | |
| 6768 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6769 | |
| 6770 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6771 | { |
| 6772 | pAdapter = pAdapterNode->pAdapter; |
| 6773 | |
| 6774 | if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode ) |
| 6775 | { |
| 6776 | return pAdapter; |
| 6777 | } |
| 6778 | |
| 6779 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6780 | pAdapterNode = pNext; |
| 6781 | } |
| 6782 | |
| 6783 | return NULL; |
| 6784 | |
| 6785 | } |
| 6786 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6787 | /**--------------------------------------------------------------------------- |
| 6788 | |
| 6789 | \brief hdd_set_monitor_tx_adapter() - |
| 6790 | |
| 6791 | This API initializes the adapter to be used while transmitting on monitor |
| 6792 | adapter. |
| 6793 | |
| 6794 | \param - pHddCtx - Pointer to the HDD context. |
| 6795 | pAdapter - Adapter that will used for TX. This can be NULL. |
| 6796 | \return - None. |
| 6797 | --------------------------------------------------------------------------*/ |
| 6798 | void wlan_hdd_set_monitor_tx_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 6799 | { |
| 6800 | hdd_adapter_t *pMonAdapter; |
| 6801 | |
| 6802 | pMonAdapter = hdd_get_adapter( pHddCtx, WLAN_HDD_MONITOR ); |
| 6803 | |
| 6804 | if( NULL != pMonAdapter ) |
| 6805 | { |
| 6806 | pMonAdapter->sessionCtx.monitor.pAdapterForTx = pAdapter; |
| 6807 | } |
| 6808 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6809 | /**--------------------------------------------------------------------------- |
| 6810 | |
| 6811 | \brief hdd_select_queue() - |
| 6812 | |
| 6813 | This API returns the operating channel of the requested device mode |
| 6814 | |
| 6815 | \param - pHddCtx - Pointer to the HDD context. |
| 6816 | - mode - Device mode for which operating channel is required |
| 6817 | suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT |
| 6818 | WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO. |
| 6819 | \return - channel number. "0" id the requested device is not found OR it is not connected. |
| 6820 | --------------------------------------------------------------------------*/ |
| 6821 | v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 6822 | { |
| 6823 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6824 | VOS_STATUS status; |
| 6825 | hdd_adapter_t *pAdapter; |
| 6826 | v_U8_t operatingChannel = 0; |
| 6827 | |
| 6828 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6829 | |
| 6830 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6831 | { |
| 6832 | pAdapter = pAdapterNode->pAdapter; |
| 6833 | |
| 6834 | if( mode == pAdapter->device_mode ) |
| 6835 | { |
| 6836 | switch(pAdapter->device_mode) |
| 6837 | { |
| 6838 | case WLAN_HDD_INFRA_STATION: |
| 6839 | case WLAN_HDD_P2P_CLIENT: |
| 6840 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 6841 | operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel; |
| 6842 | break; |
| 6843 | case WLAN_HDD_SOFTAP: |
| 6844 | case WLAN_HDD_P2P_GO: |
| 6845 | /*softap connection info */ |
| 6846 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 6847 | operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel; |
| 6848 | break; |
| 6849 | default: |
| 6850 | break; |
| 6851 | } |
| 6852 | |
| 6853 | break; //Found the device of interest. break the loop |
| 6854 | } |
| 6855 | |
| 6856 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6857 | pAdapterNode = pNext; |
| 6858 | } |
| 6859 | return operatingChannel; |
| 6860 | } |
| 6861 | |
| 6862 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 6863 | /**--------------------------------------------------------------------------- |
| 6864 | |
| 6865 | \brief hdd_set_multicast_list() - |
| 6866 | |
| 6867 | This used to set the multicast address list. |
| 6868 | |
| 6869 | \param - dev - Pointer to the WLAN device. |
| 6870 | - skb - Pointer to OS packet (sk_buff). |
| 6871 | \return - success/fail |
| 6872 | |
| 6873 | --------------------------------------------------------------------------*/ |
| 6874 | static void hdd_set_multicast_list(struct net_device *dev) |
| 6875 | { |
| 6876 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6877 | int mc_count; |
| 6878 | int i = 0; |
| 6879 | struct netdev_hw_addr *ha; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 6880 | |
| 6881 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6882 | { |
| 6883 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 6884 | "%s: Adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6885 | return; |
| 6886 | } |
| 6887 | |
| 6888 | if (dev->flags & IFF_ALLMULTI) |
| 6889 | { |
| 6890 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6891 | "%s: allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 6892 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6893 | } |
| 6894 | else |
| 6895 | { |
| 6896 | mc_count = netdev_mc_count(dev); |
| 6897 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6898 | "%s: mc_count = %u", __func__, mc_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6899 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) |
| 6900 | { |
| 6901 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6902 | "%s: No free filter available; allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 6903 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6904 | return; |
| 6905 | } |
| 6906 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 6907 | pAdapter->mc_addr_list.mc_cnt = mc_count; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6908 | |
| 6909 | netdev_for_each_mc_addr(ha, dev) { |
| 6910 | if (i == mc_count) |
| 6911 | break; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 6912 | memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN); |
| 6913 | memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6914 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6915 | __func__, i, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 6916 | MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i])); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6917 | i++; |
| 6918 | } |
| 6919 | } |
| 6920 | return; |
| 6921 | } |
| 6922 | #endif |
| 6923 | |
| 6924 | /**--------------------------------------------------------------------------- |
| 6925 | |
| 6926 | \brief hdd_select_queue() - |
| 6927 | |
| 6928 | This function is registered with the Linux OS for network |
| 6929 | core to decide which queue to use first. |
| 6930 | |
| 6931 | \param - dev - Pointer to the WLAN device. |
| 6932 | - skb - Pointer to OS packet (sk_buff). |
| 6933 | \return - ac, Queue Index/access category corresponding to UP in IP header |
| 6934 | |
| 6935 | --------------------------------------------------------------------------*/ |
| 6936 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 6937 | struct sk_buff *skb) |
| 6938 | { |
| 6939 | return hdd_wmm_select_queue(dev, skb); |
| 6940 | } |
| 6941 | |
| 6942 | |
| 6943 | /**--------------------------------------------------------------------------- |
| 6944 | |
| 6945 | \brief hdd_wlan_initial_scan() - |
| 6946 | |
| 6947 | This function triggers the initial scan |
| 6948 | |
| 6949 | \param - pAdapter - Pointer to the HDD adapter. |
| 6950 | |
| 6951 | --------------------------------------------------------------------------*/ |
| 6952 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter) |
| 6953 | { |
| 6954 | tCsrScanRequest scanReq; |
| 6955 | tCsrChannelInfo channelInfo; |
| 6956 | eHalStatus halStatus; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 6957 | tANI_U32 scanId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6958 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6959 | |
| 6960 | vos_mem_zero(&scanReq, sizeof(tCsrScanRequest)); |
| 6961 | vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff); |
| 6962 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 6963 | |
| 6964 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 6965 | { |
| 6966 | halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo ); |
| 6967 | if ( HAL_STATUS_SUCCESS( halStatus ) ) |
| 6968 | { |
| 6969 | scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels); |
| 6970 | if( !scanReq.ChannelInfo.ChannelList ) |
| 6971 | { |
| 6972 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__); |
| 6973 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6974 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6975 | return; |
| 6976 | } |
| 6977 | vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList, |
| 6978 | channelInfo.numOfChannels); |
| 6979 | scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels; |
| 6980 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6981 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6982 | } |
| 6983 | |
| 6984 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 6985 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 6986 | scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime; |
| 6987 | scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime; |
| 6988 | } |
| 6989 | else |
| 6990 | { |
| 6991 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 6992 | scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 6993 | scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime; |
| 6994 | scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime; |
| 6995 | } |
| 6996 | |
| 6997 | halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL); |
| 6998 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 6999 | { |
| 7000 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d", |
| 7001 | __func__, halStatus ); |
| 7002 | } |
| 7003 | |
| 7004 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 7005 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
| 7006 | } |
| 7007 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7008 | /**--------------------------------------------------------------------------- |
| 7009 | |
| 7010 | \brief hdd_full_power_callback() - HDD full power callback function |
| 7011 | |
| 7012 | This is the function invoked by SME to inform the result of a full power |
| 7013 | request issued by HDD |
| 7014 | |
| 7015 | \param - callbackcontext - Pointer to cookie |
| 7016 | \param - status - result of request |
| 7017 | |
| 7018 | \return - None |
| 7019 | |
| 7020 | --------------------------------------------------------------------------*/ |
| 7021 | static void hdd_full_power_callback(void *callbackContext, eHalStatus status) |
| 7022 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7023 | struct statsContext *pContext = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7024 | |
| 7025 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 7026 | "%s: context = %p, status = %d", __func__, pContext, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7027 | |
| 7028 | if (NULL == callbackContext) |
| 7029 | { |
| 7030 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7031 | "%s: Bad param, context [%p]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7032 | __func__, callbackContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7033 | return; |
| 7034 | } |
| 7035 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7036 | /* there is a race condition that exists between this callback |
| 7037 | function and the caller since the caller could time out either |
| 7038 | before or while this code is executing. we use a spinlock to |
| 7039 | serialize these actions */ |
| 7040 | spin_lock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7041 | |
| 7042 | if (POWER_CONTEXT_MAGIC != pContext->magic) |
| 7043 | { |
| 7044 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7045 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7046 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 7047 | "%s: Invalid context, magic [%08x]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7048 | __func__, pContext->magic); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7049 | return; |
| 7050 | } |
| 7051 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7052 | /* context is valid so caller is still waiting */ |
| 7053 | |
| 7054 | /* paranoia: invalidate the magic */ |
| 7055 | pContext->magic = 0; |
| 7056 | |
| 7057 | /* notify the caller */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7058 | complete(&pContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7059 | |
| 7060 | /* serialization is complete */ |
| 7061 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7062 | } |
| 7063 | |
| 7064 | /**--------------------------------------------------------------------------- |
| 7065 | |
| 7066 | \brief hdd_wlan_exit() - HDD WLAN exit function |
| 7067 | |
| 7068 | This is the driver exit point (invoked during rmmod) |
| 7069 | |
| 7070 | \param - pHddCtx - Pointer to the HDD Context |
| 7071 | |
| 7072 | \return - None |
| 7073 | |
| 7074 | --------------------------------------------------------------------------*/ |
| 7075 | void hdd_wlan_exit(hdd_context_t *pHddCtx) |
| 7076 | { |
| 7077 | eHalStatus halStatus; |
| 7078 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
| 7079 | VOS_STATUS vosStatus; |
Gopichand Nakkala | 66923aa | 2013-03-06 23:17:24 +0530 | [diff] [blame] | 7080 | struct wiphy *wiphy = pHddCtx->wiphy; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7081 | hdd_adapter_t* pAdapter; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7082 | struct statsContext powerContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7083 | long lrc; |
| 7084 | |
| 7085 | ENTER(); |
| 7086 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7087 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 7088 | { |
| 7089 | // Unloading, restart logic is no more required. |
| 7090 | wlan_hdd_restart_deinit(pHddCtx); |
| 7091 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7092 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7093 | if (VOS_STA_SAP_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7094 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7095 | if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7096 | { |
| 7097 | hdd_adapter_t* pAdapter = hdd_get_adapter(pHddCtx, |
| 7098 | WLAN_HDD_INFRA_STATION); |
| 7099 | if (pAdapter == NULL) |
| 7100 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 7101 | |
| 7102 | if (pAdapter != NULL) |
| 7103 | { |
| 7104 | wlan_hdd_cfg80211_pre_voss_stop(pAdapter); |
| 7105 | hdd_UnregisterWext(pAdapter->dev); |
| 7106 | } |
| 7107 | } |
| 7108 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7109 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7110 | if (VOS_FTM_MODE == hdd_get_conparam()) |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7111 | { |
| 7112 | wlan_hdd_ftm_close(pHddCtx); |
| 7113 | goto free_hdd_ctx; |
| 7114 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7115 | //Stop the Interface TX queue. |
| 7116 | //netif_tx_disable(pWlanDev); |
| 7117 | //netif_carrier_off(pWlanDev); |
| 7118 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7119 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 7120 | { |
| 7121 | pAdapter = hdd_get_adapter(pHddCtx, |
| 7122 | WLAN_HDD_SOFTAP); |
| 7123 | } |
| 7124 | else |
| 7125 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7126 | if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7127 | { |
| 7128 | pAdapter = hdd_get_adapter(pHddCtx, |
| 7129 | WLAN_HDD_INFRA_STATION); |
Praveen Kumar Sirisilla | 47ce6ea | 2013-09-24 15:08:08 -0700 | [diff] [blame] | 7130 | if (pAdapter == NULL) |
| 7131 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_IBSS); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7132 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7133 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7134 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 7135 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 7136 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 7137 | { |
| 7138 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 7139 | VOS_ASSERT(0); |
| 7140 | } |
| 7141 | |
| 7142 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 7143 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 7144 | { |
| 7145 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 7146 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7147 | |
| 7148 | // Cancel any outstanding scan requests. We are about to close all |
| 7149 | // of our adapters, but an adapter structure is what SME passes back |
| 7150 | // to our callback function. Hence if there are any outstanding scan |
| 7151 | // requests then there is a race condition between when the adapter |
| 7152 | // is closed and when the callback is invoked. We try to resolve that |
| 7153 | // race condition here by canceling any outstanding scans before we |
| 7154 | // close the adapters. |
| 7155 | // Note that the scans may be cancelled in an asynchronous manner, so |
| 7156 | // ideally there needs to be some kind of synchronization. Rather than |
| 7157 | // introduce a new synchronization here, we will utilize the fact that |
| 7158 | // we are about to Request Full Power, and since that is synchronized, |
| 7159 | // the expectation is that by the time Request Full Power has completed, |
| 7160 | // all scans will be cancelled. |
Praveen Kumar Sirisilla | 47ce6ea | 2013-09-24 15:08:08 -0700 | [diff] [blame] | 7161 | if (NULL != pAdapter) |
| 7162 | hdd_abort_mac_scan( pHddCtx, pAdapter->sessionId); |
| 7163 | else |
| 7164 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7165 | "%s: pAdapter is NULL, cannot Abort scan", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7166 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 7167 | //Stop the traffic monitor timer |
| 7168 | if ( VOS_TIMER_STATE_RUNNING == |
| 7169 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) |
| 7170 | { |
| 7171 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 7172 | } |
| 7173 | |
| 7174 | // Destroy the traffic monitor timer |
| 7175 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 7176 | &pHddCtx->tx_rx_trafficTmr))) |
| 7177 | { |
| 7178 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7179 | "%s: Cannot deallocate Traffic monitor timer", __func__); |
| 7180 | } |
| 7181 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7182 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 7183 | //save mode during shutdown |
| 7184 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 7185 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 7186 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 7187 | |
| 7188 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 7189 | init_completion(&powerContext.completion); |
| 7190 | powerContext.magic = POWER_CONTEXT_MAGIC; |
| 7191 | |
| 7192 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback, |
| 7193 | &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 7194 | |
| 7195 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 7196 | { |
| 7197 | if (eHAL_STATUS_PMC_PENDING == halStatus) |
| 7198 | { |
| 7199 | /* request was sent -- wait for the response */ |
| 7200 | lrc = wait_for_completion_interruptible_timeout( |
| 7201 | &powerContext.completion, |
| 7202 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7203 | if (lrc <= 0) |
| 7204 | { |
| 7205 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7206 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7207 | } |
| 7208 | } |
| 7209 | else |
| 7210 | { |
| 7211 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7212 | "%s: Request for Full Power failed, status %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7213 | __func__, halStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7214 | /* continue -- need to clean up as much as possible */ |
| 7215 | } |
| 7216 | } |
| 7217 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7218 | /* either we never sent a request, we sent a request and received a |
| 7219 | response or we sent a request and timed out. if we never sent a |
| 7220 | request or if we sent a request and got a response, we want to |
| 7221 | clear the magic out of paranoia. if we timed out there is a |
| 7222 | race condition such that the callback function could be |
| 7223 | executing at the same time we are. of primary concern is if the |
| 7224 | callback function had already verified the "magic" but had not |
| 7225 | yet set the completion variable when a timeout occurred. we |
| 7226 | serialize these activities by invalidating the magic while |
| 7227 | holding a shared spinlock which will cause us to block if the |
| 7228 | callback is currently executing */ |
| 7229 | spin_lock(&hdd_context_lock); |
| 7230 | powerContext.magic = 0; |
| 7231 | spin_unlock(&hdd_context_lock); |
| 7232 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 7233 | hdd_debugfs_exit(pHddCtx); |
| 7234 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7235 | // Unregister the Net Device Notifier |
| 7236 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7237 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7238 | hdd_stop_all_adapters( pHddCtx ); |
| 7239 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7240 | #ifdef WLAN_BTAMP_FEATURE |
| 7241 | vosStatus = WLANBAP_Stop(pVosContext); |
| 7242 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 7243 | { |
| 7244 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 7245 | "%s: Failed to stop BAP",__func__); |
| 7246 | } |
| 7247 | #endif //WLAN_BTAMP_FEATURE |
| 7248 | |
| 7249 | //Stop all the modules |
| 7250 | vosStatus = vos_stop( pVosContext ); |
| 7251 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 7252 | { |
| 7253 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7254 | "%s: Failed to stop VOSS",__func__); |
| 7255 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7256 | } |
| 7257 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7258 | //Assert Deep sleep signal now to put Libra HW in lowest power state |
| 7259 | vosStatus = vos_chipAssertDeepSleep( NULL, NULL, NULL ); |
| 7260 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7261 | |
| 7262 | //Vote off any PMIC voltage supplies |
| 7263 | vos_chipPowerDown(NULL, NULL, NULL); |
| 7264 | |
| 7265 | vos_chipVoteOffXOBuffer(NULL, NULL, NULL); |
| 7266 | |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 7267 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7268 | //This requires pMac access, Call this before vos_close(). |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7269 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7270 | |
| 7271 | //Close the scheduler before calling vos_close to make sure no thread is |
| 7272 | // scheduled after the each module close is called i.e after all the data |
| 7273 | // structures are freed. |
| 7274 | vosStatus = vos_sched_close( pVosContext ); |
| 7275 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 7276 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 7277 | "%s: Failed to close VOSS Scheduler",__func__); |
| 7278 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7279 | } |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 7280 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7281 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 7282 | /* Destroy the wake lock */ |
| 7283 | wake_lock_destroy(&pHddCtx->rx_wake_lock); |
| 7284 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 7285 | /* Destroy the wake lock */ |
| 7286 | wake_lock_destroy(&pHddCtx->sap_wake_lock); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 7287 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7288 | |
Mihir Shete | 7a24b5f | 2013-12-21 12:18:31 +0530 | [diff] [blame] | 7289 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 7290 | vosStatus = vos_nv_close(); |
| 7291 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 7292 | { |
| 7293 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 7294 | "%s: Failed to close NV", __func__); |
| 7295 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7296 | } |
| 7297 | #endif |
| 7298 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7299 | //Close VOSS |
| 7300 | //This frees pMac(HAL) context. There should not be any call that requires pMac access after this. |
| 7301 | vos_close(pVosContext); |
| 7302 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7303 | //Close Watchdog |
| 7304 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 7305 | vos_watchdog_close(pVosContext); |
| 7306 | |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 7307 | //Clean up HDD Nlink Service |
| 7308 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 7309 | #ifdef WLAN_KD_READY_NOTIFIER |
| 7310 | nl_srv_exit(pHddCtx->ptt_pid); |
| 7311 | #else |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 7312 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 7313 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 7314 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7315 | /* Cancel the vote for XO Core ON. |
| 7316 | * This is done here to ensure there is no race condition since MC, TX and WD threads have |
| 7317 | * exited at this point |
| 7318 | */ |
| 7319 | hddLog(VOS_TRACE_LEVEL_WARN, "In module exit: Cancel the vote for XO Core ON" |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7320 | " when WLAN is turned OFF"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7321 | if (vos_chipVoteXOCore(NULL, NULL, NULL, VOS_FALSE) != VOS_STATUS_SUCCESS) |
| 7322 | { |
| 7323 | hddLog(VOS_TRACE_LEVEL_ERROR, "Could not cancel the vote for XO Core ON." |
| 7324 | " Not returning failure." |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7325 | " Power consumed will be high"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7326 | } |
| 7327 | |
| 7328 | hdd_close_all_adapters( pHddCtx ); |
| 7329 | |
| 7330 | |
| 7331 | //Free up dynamically allocated members inside HDD Adapter |
| 7332 | kfree(pHddCtx->cfg_ini); |
| 7333 | pHddCtx->cfg_ini= NULL; |
| 7334 | |
| 7335 | /* free the power on lock from platform driver */ |
| 7336 | if (free_riva_power_on_lock("wlan")) |
| 7337 | { |
| 7338 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 7339 | __func__); |
| 7340 | } |
| 7341 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7342 | free_hdd_ctx: |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 7343 | /* FTM mode, WIPHY did not registered |
| 7344 | If un-register here, system crash will happen */ |
| 7345 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 7346 | { |
| 7347 | wiphy_unregister(wiphy) ; |
| 7348 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7349 | wiphy_free(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7350 | if (hdd_is_ssr_required()) |
| 7351 | { |
| 7352 | /* WDI timeout had happened during unload, so SSR is needed here */ |
Madan Mohan Koyyalamudi | 3246f5b | 2012-10-15 15:40:02 -0700 | [diff] [blame] | 7353 | subsystem_restart("wcnss"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7354 | msleep(5000); |
| 7355 | } |
| 7356 | hdd_set_ssr_required (VOS_FALSE); |
| 7357 | } |
| 7358 | |
| 7359 | |
| 7360 | /**--------------------------------------------------------------------------- |
| 7361 | |
| 7362 | \brief hdd_update_config_from_nv() - Function to update the contents of |
| 7363 | the running configuration with parameters taken from NV storage |
| 7364 | |
| 7365 | \param - pHddCtx - Pointer to the HDD global context |
| 7366 | |
| 7367 | \return - VOS_STATUS_SUCCESS if successful |
| 7368 | |
| 7369 | --------------------------------------------------------------------------*/ |
| 7370 | static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx) |
| 7371 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7372 | v_BOOL_t itemIsValid = VOS_FALSE; |
| 7373 | VOS_STATUS status; |
| 7374 | v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA]; |
| 7375 | v_U8_t macLoop; |
| 7376 | |
| 7377 | /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/ |
| 7378 | status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid); |
| 7379 | if(status != VOS_STATUS_SUCCESS) |
| 7380 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7381 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7382 | return VOS_STATUS_E_FAILURE; |
| 7383 | } |
| 7384 | |
| 7385 | if (itemIsValid == VOS_TRUE) |
| 7386 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7387 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7388 | status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0], |
| 7389 | VOS_MAX_CONCURRENCY_PERSONA); |
| 7390 | if(status != VOS_STATUS_SUCCESS) |
| 7391 | { |
| 7392 | /* Get MAC from NV fail, not update CFG info |
| 7393 | * INI MAC value will be used for MAC setting */ |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7394 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7395 | return VOS_STATUS_E_FAILURE; |
| 7396 | } |
| 7397 | |
| 7398 | /* If first MAC is not valid, treat all others are not valid |
| 7399 | * Then all MACs will be got from ini file */ |
| 7400 | if(vos_is_macaddr_zero(&macFromNV[0])) |
| 7401 | { |
| 7402 | /* MAC address in NV file is not configured yet */ |
| 7403 | hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file"); |
| 7404 | return VOS_STATUS_E_INVAL; |
| 7405 | } |
| 7406 | |
| 7407 | /* Get MAC address from NV, update CFG info */ |
| 7408 | for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++) |
| 7409 | { |
| 7410 | if(vos_is_macaddr_zero(&macFromNV[macLoop])) |
| 7411 | { |
| 7412 | printk(KERN_ERR "not valid MAC from NV for %d", macLoop); |
| 7413 | /* This MAC is not valid, skip it |
| 7414 | * This MAC will be got from ini file */ |
| 7415 | } |
| 7416 | else |
| 7417 | { |
| 7418 | vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0], |
| 7419 | (v_U8_t *)&macFromNV[macLoop].bytes[0], |
| 7420 | VOS_MAC_ADDR_SIZE); |
| 7421 | } |
| 7422 | } |
| 7423 | } |
| 7424 | else |
| 7425 | { |
| 7426 | hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid"); |
| 7427 | return VOS_STATUS_E_FAILURE; |
| 7428 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7429 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7430 | |
| 7431 | return VOS_STATUS_SUCCESS; |
| 7432 | } |
| 7433 | |
| 7434 | /**--------------------------------------------------------------------------- |
| 7435 | |
| 7436 | \brief hdd_post_voss_start_config() - HDD post voss start config helper |
| 7437 | |
| 7438 | \param - pAdapter - Pointer to the HDD |
| 7439 | |
| 7440 | \return - None |
| 7441 | |
| 7442 | --------------------------------------------------------------------------*/ |
| 7443 | VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx) |
| 7444 | { |
| 7445 | eHalStatus halStatus; |
| 7446 | v_U32_t listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 7447 | tANI_U32 ignoreDtim; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7448 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7449 | |
| 7450 | // Send ready indication to the HDD. This will kick off the MAC |
| 7451 | // into a 'running' state and should kick off an initial scan. |
| 7452 | halStatus = sme_HDDReadyInd( pHddCtx->hHal ); |
| 7453 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 7454 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 7455 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7456 | "code %08d [x%08x]",__func__, halStatus, halStatus ); |
| 7457 | return VOS_STATUS_E_FAILURE; |
| 7458 | } |
| 7459 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 7460 | // Set default LI and ignoreDtim into HDD context, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7461 | // otherwise under some race condition, HDD will set 0 LI value into RIVA, |
| 7462 | // And RIVA will crash |
| 7463 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval); |
| 7464 | pHddCtx->hdd_actual_LI_value = listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 7465 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim); |
| 7466 | pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim; |
| 7467 | |
| 7468 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7469 | return VOS_STATUS_SUCCESS; |
| 7470 | } |
| 7471 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7472 | /* wake lock APIs for HDD */ |
| 7473 | void hdd_prevent_suspend(void) |
| 7474 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 7475 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7476 | wake_lock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7477 | #else |
| 7478 | wcnss_prevent_suspend(); |
| 7479 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7480 | } |
| 7481 | |
| 7482 | void hdd_allow_suspend(void) |
| 7483 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 7484 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7485 | wake_unlock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7486 | #else |
| 7487 | wcnss_allow_suspend(); |
| 7488 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7489 | } |
| 7490 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 7491 | void hdd_allow_suspend_timeout(v_U32_t timeout) |
| 7492 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 7493 | #ifdef WLAN_OPEN_SOURCE |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 7494 | wake_lock_timeout(&wlan_wake_lock, msecs_to_jiffies(timeout)); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 7495 | #else |
| 7496 | /* Do nothing as there is no API in wcnss for timeout*/ |
| 7497 | #endif |
| 7498 | } |
| 7499 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7500 | /**--------------------------------------------------------------------------- |
| 7501 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 7502 | \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability |
| 7503 | information between Host and Riva |
| 7504 | |
| 7505 | This function gets reported version of FW |
| 7506 | It also finds the version of Riva headers used to compile the host |
| 7507 | It compares the above two and prints a warning if they are different |
| 7508 | It gets the SW and HW version string |
| 7509 | Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg |
| 7510 | indicating the features they support through a bitmap |
| 7511 | |
| 7512 | \param - pHddCtx - Pointer to HDD context |
| 7513 | |
| 7514 | \return - void |
| 7515 | |
| 7516 | --------------------------------------------------------------------------*/ |
| 7517 | |
| 7518 | void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx) |
| 7519 | { |
| 7520 | |
| 7521 | tSirVersionType versionCompiled; |
| 7522 | tSirVersionType versionReported; |
| 7523 | tSirVersionString versionString; |
| 7524 | tANI_U8 fwFeatCapsMsgSupported = 0; |
| 7525 | VOS_STATUS vstatus; |
| 7526 | |
| 7527 | /* retrieve and display WCNSS version information */ |
| 7528 | do { |
| 7529 | |
| 7530 | vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal, |
| 7531 | &versionCompiled); |
| 7532 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 7533 | { |
| 7534 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7535 | "%s: unable to retrieve WCNSS WLAN compiled version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7536 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 7537 | break; |
| 7538 | } |
| 7539 | |
| 7540 | vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal, |
| 7541 | &versionReported); |
| 7542 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 7543 | { |
| 7544 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7545 | "%s: unable to retrieve WCNSS WLAN reported version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7546 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 7547 | break; |
| 7548 | } |
| 7549 | |
| 7550 | if ((versionCompiled.major != versionReported.major) || |
| 7551 | (versionCompiled.minor != versionReported.minor) || |
| 7552 | (versionCompiled.version != versionReported.version) || |
| 7553 | (versionCompiled.revision != versionReported.revision)) |
| 7554 | { |
| 7555 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 7556 | "Host expected %u.%u.%u.%u\n", |
| 7557 | WLAN_MODULE_NAME, |
| 7558 | (int)versionReported.major, |
| 7559 | (int)versionReported.minor, |
| 7560 | (int)versionReported.version, |
| 7561 | (int)versionReported.revision, |
| 7562 | (int)versionCompiled.major, |
| 7563 | (int)versionCompiled.minor, |
| 7564 | (int)versionCompiled.version, |
| 7565 | (int)versionCompiled.revision); |
| 7566 | } |
| 7567 | else |
| 7568 | { |
| 7569 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 7570 | WLAN_MODULE_NAME, |
| 7571 | (int)versionReported.major, |
| 7572 | (int)versionReported.minor, |
| 7573 | (int)versionReported.version, |
| 7574 | (int)versionReported.revision); |
| 7575 | } |
| 7576 | |
| 7577 | vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal, |
| 7578 | versionString, |
| 7579 | sizeof(versionString)); |
| 7580 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 7581 | { |
| 7582 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7583 | "%s: unable to retrieve WCNSS software version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7584 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 7585 | break; |
| 7586 | } |
| 7587 | |
| 7588 | pr_info("%s: WCNSS software version %s\n", |
| 7589 | WLAN_MODULE_NAME, versionString); |
| 7590 | |
| 7591 | vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal, |
| 7592 | versionString, |
| 7593 | sizeof(versionString)); |
| 7594 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 7595 | { |
| 7596 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7597 | "%s: unable to retrieve WCNSS hardware version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7598 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 7599 | break; |
| 7600 | } |
| 7601 | |
| 7602 | pr_info("%s: WCNSS hardware version %s\n", |
| 7603 | WLAN_MODULE_NAME, versionString); |
| 7604 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 7605 | /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message |
| 7606 | 2.Host-FW capability exchange message is only present on riva 1.1 so |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 7607 | send the message only if it the riva is 1.1 |
| 7608 | minor numbers for different riva branches: |
| 7609 | 0 -> (1.0)Mainline Build |
| 7610 | 1 -> (1.1)Mainline Build |
| 7611 | 2->(1.04) Stability Build |
| 7612 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 7613 | if (((versionReported.major>0) || (versionReported.minor>1) || |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 7614 | ((versionReported.minor>=1) && (versionReported.version>=1))) |
| 7615 | && ((versionReported.major == 1) && (versionReported.minor >= 1))) |
| 7616 | fwFeatCapsMsgSupported = 1; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 7617 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 7618 | if (fwFeatCapsMsgSupported) |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 7619 | { |
| 7620 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 7621 | if(!pHddCtx->cfg_ini->fEnableActiveModeOffload) |
| 7622 | sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD); |
| 7623 | #endif |
Ravi Joshi | d2ca7c4 | 2013-07-23 08:37:49 -0700 | [diff] [blame] | 7624 | /* Indicate if IBSS heartbeat monitoring needs to be offloaded */ |
| 7625 | if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload) |
| 7626 | { |
| 7627 | sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD); |
| 7628 | } |
| 7629 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 7630 | sme_featureCapsExchange(pHddCtx->hHal); |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 7631 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 7632 | |
| 7633 | } while (0); |
| 7634 | |
| 7635 | } |
| 7636 | |
| 7637 | /**--------------------------------------------------------------------------- |
| 7638 | |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 7639 | \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz |
| 7640 | |
| 7641 | \param - pHddCtx - Pointer to the hdd context |
| 7642 | |
| 7643 | \return - true if hardware supports 5GHz |
| 7644 | |
| 7645 | --------------------------------------------------------------------------*/ |
| 7646 | static boolean hdd_is_5g_supported(hdd_context_t * pHddCtx) |
| 7647 | { |
| 7648 | /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1); |
| 7649 | * then hardware support 5Ghz. |
| 7650 | */ |
| 7651 | if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode()) |
| 7652 | { |
| 7653 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Hardware supports 5Ghz", __func__); |
| 7654 | return true; |
| 7655 | } |
| 7656 | else |
| 7657 | { |
| 7658 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Hardware doesn't supports 5Ghz", |
| 7659 | __func__); |
| 7660 | return false; |
| 7661 | } |
| 7662 | } |
| 7663 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 7664 | /**--------------------------------------------------------------------------- |
| 7665 | |
| 7666 | \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto |
| 7667 | generate function |
| 7668 | |
| 7669 | This is generate the random mac address for WLAN interface |
| 7670 | |
| 7671 | \param - pHddCtx - Pointer to HDD context |
| 7672 | idx - Start interface index to get auto |
| 7673 | generated mac addr. |
| 7674 | mac_addr - Mac address |
| 7675 | |
| 7676 | \return - 0 for success, < 0 for failure |
| 7677 | |
| 7678 | --------------------------------------------------------------------------*/ |
| 7679 | |
| 7680 | static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx, |
| 7681 | int idx, v_MACADDR_t mac_addr) |
| 7682 | { |
| 7683 | int i; |
| 7684 | unsigned int serialno; |
| 7685 | serialno = wcnss_get_serial_number(); |
| 7686 | |
| 7687 | if (0 != serialno) |
| 7688 | { |
| 7689 | /* MAC address has 3 bytes of OUI so we have a maximum of 3 |
| 7690 | bytes of the serial number that can be used to generate |
| 7691 | the other 3 bytes of the MAC address. Mask off all but |
| 7692 | the lower 3 bytes (this will also make sure we don't |
| 7693 | overflow in the next step) */ |
| 7694 | serialno &= 0x00FFFFFF; |
| 7695 | |
| 7696 | /* we need a unique address for each session */ |
| 7697 | serialno *= VOS_MAX_CONCURRENCY_PERSONA; |
| 7698 | |
| 7699 | /* autogen other Mac addresses */ |
| 7700 | for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 7701 | { |
| 7702 | /* start with the entire default address */ |
| 7703 | pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr; |
| 7704 | /* then replace the lower 3 bytes */ |
| 7705 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF; |
| 7706 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF; |
| 7707 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF; |
| 7708 | |
| 7709 | serialno++; |
| 7710 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7711 | "%s: Derived Mac Addr: " |
| 7712 | MAC_ADDRESS_STR, __func__, |
| 7713 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes)); |
| 7714 | } |
| 7715 | |
| 7716 | } |
| 7717 | else |
| 7718 | { |
| 7719 | hddLog(LOGE, FL("Failed to Get Serial NO")); |
| 7720 | return -1; |
| 7721 | } |
| 7722 | return 0; |
| 7723 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 7724 | |
| 7725 | /**--------------------------------------------------------------------------- |
| 7726 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7727 | \brief hdd_wlan_startup() - HDD init function |
| 7728 | |
| 7729 | This is the driver startup code executed once a WLAN device has been detected |
| 7730 | |
| 7731 | \param - dev - Pointer to the underlying device |
| 7732 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 7733 | \return - 0 for success, < 0 for failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7734 | |
| 7735 | --------------------------------------------------------------------------*/ |
| 7736 | |
| 7737 | int hdd_wlan_startup(struct device *dev ) |
| 7738 | { |
| 7739 | VOS_STATUS status; |
| 7740 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7741 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7742 | hdd_context_t *pHddCtx = NULL; |
| 7743 | v_CONTEXT_t pVosContext= NULL; |
| 7744 | #ifdef WLAN_BTAMP_FEATURE |
| 7745 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 7746 | WLANBAP_ConfigType btAmpConfig; |
| 7747 | hdd_config_t *pConfig; |
| 7748 | #endif |
| 7749 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7750 | struct wiphy *wiphy; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 7751 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7752 | |
| 7753 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7754 | /* |
| 7755 | * cfg80211: wiphy allocation |
| 7756 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 7757 | wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7758 | |
| 7759 | if(wiphy == NULL) |
| 7760 | { |
| 7761 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 7762 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7763 | } |
| 7764 | |
| 7765 | pHddCtx = wiphy_priv(wiphy); |
| 7766 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7767 | //Initialize the adapter context to zeros. |
| 7768 | vos_mem_zero(pHddCtx, sizeof( hdd_context_t )); |
| 7769 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7770 | pHddCtx->wiphy = wiphy; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7771 | hdd_prevent_suspend(); |
| 7772 | pHddCtx->isLoadUnloadInProgress = TRUE; |
| 7773 | |
| 7774 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 7775 | |
| 7776 | /*Get vos context here bcoz vos_open requires it*/ |
| 7777 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 7778 | |
Madan Mohan Koyyalamudi | 0b78e15 | 2012-11-28 15:46:51 -0800 | [diff] [blame] | 7779 | if(pVosContext == NULL) |
| 7780 | { |
| 7781 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__); |
| 7782 | goto err_free_hdd_context; |
| 7783 | } |
| 7784 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7785 | //Save the Global VOSS context in adapter context for future. |
| 7786 | pHddCtx->pvosContext = pVosContext; |
| 7787 | |
| 7788 | //Save the adapter context in global context for future. |
| 7789 | ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx; |
| 7790 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7791 | pHddCtx->parent_dev = dev; |
| 7792 | |
| 7793 | init_completion(&pHddCtx->full_pwr_comp_var); |
| 7794 | init_completion(&pHddCtx->standby_comp_var); |
| 7795 | init_completion(&pHddCtx->req_bmps_comp_var); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 7796 | init_completion(&pHddCtx->scan_info.scan_req_completion_event); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 7797 | init_completion(&pHddCtx->scan_info.abortscan_event_var); |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 7798 | init_completion(&pHddCtx->wiphy_channel_update_event); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 7799 | |
| 7800 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 7801 | init_completion(&pHddCtx->linux_reg_req); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 7802 | #else |
| 7803 | init_completion(&pHddCtx->driver_crda_req); |
| 7804 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7805 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7806 | spin_lock_init(&pHddCtx->schedScan_lock); |
| 7807 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7808 | hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS ); |
| 7809 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 7810 | #ifdef FEATURE_WLAN_TDLS |
| 7811 | /* tdls_lock is initialized before an hdd_open_adapter ( which is |
| 7812 | * invoked by other instances also) to protect the concurrent |
| 7813 | * access for the Adapters by TDLS module. |
| 7814 | */ |
| 7815 | mutex_init(&pHddCtx->tdls_lock); |
| 7816 | #endif |
| 7817 | |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 7818 | pHddCtx->nEnableStrictRegulatoryForFCC = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7819 | // Load all config first as TL config is needed during vos_open |
| 7820 | pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL); |
| 7821 | if(pHddCtx->cfg_ini == NULL) |
| 7822 | { |
| 7823 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__); |
| 7824 | goto err_free_hdd_context; |
| 7825 | } |
| 7826 | |
| 7827 | vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t )); |
| 7828 | |
| 7829 | // Read and parse the qcom_cfg.ini file |
| 7830 | status = hdd_parse_config_ini( pHddCtx ); |
| 7831 | if ( VOS_STATUS_SUCCESS != status ) |
| 7832 | { |
| 7833 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s", |
| 7834 | __func__, WLAN_INI_FILE); |
| 7835 | goto err_config; |
| 7836 | } |
Arif Hussain | d521891 | 2013-12-05 01:10:55 -0800 | [diff] [blame] | 7837 | #ifdef MEMORY_DEBUG |
| 7838 | if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled) |
| 7839 | vos_mem_init(); |
| 7840 | |
| 7841 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d", |
| 7842 | __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled); |
| 7843 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7844 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 7845 | /* INI has been read, initialise the configuredMcastBcastFilter with |
| 7846 | * INI value as this will serve as the default value |
| 7847 | */ |
| 7848 | pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting; |
| 7849 | hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d", |
| 7850 | pHddCtx->cfg_ini->mcastBcastFilterSetting); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 7851 | |
| 7852 | if (false == hdd_is_5g_supported(pHddCtx)) |
| 7853 | { |
| 7854 | //5Ghz is not supported. |
| 7855 | if (1 != pHddCtx->cfg_ini->nBandCapability) |
| 7856 | { |
| 7857 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7858 | "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__); |
| 7859 | pHddCtx->cfg_ini->nBandCapability = 1; |
| 7860 | } |
| 7861 | } |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 7862 | |
| 7863 | /* If SNR Monitoring is enabled, FW has to parse all beacons |
| 7864 | * for calcaluting and storing the average SNR, so set Nth beacon |
| 7865 | * filter to 1 to enable FW to parse all the beaocons |
| 7866 | */ |
| 7867 | if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring) |
| 7868 | { |
| 7869 | /* The log level is deliberately set to WARN as overriding |
| 7870 | * nthBeaconFilter to 1 will increase power cosumption and this |
| 7871 | * might just prove helpful to detect the power issue. |
| 7872 | */ |
| 7873 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 7874 | "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__); |
| 7875 | pHddCtx->cfg_ini->nthBeaconFilter = 1; |
| 7876 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7877 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 7878 | * cfg80211: Initialization ... |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7879 | */ |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame^] | 7880 | if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7881 | { |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame^] | 7882 | if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini)) |
| 7883 | { |
| 7884 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7885 | "%s: wlan_hdd_cfg80211_init return failure", __func__); |
| 7886 | goto err_config; |
| 7887 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7888 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7889 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 7890 | // Update VOS trace levels based upon the cfg.ini |
| 7891 | hdd_vos_trace_enable(VOS_MODULE_ID_BAP, |
| 7892 | pHddCtx->cfg_ini->vosTraceEnableBAP); |
| 7893 | hdd_vos_trace_enable(VOS_MODULE_ID_TL, |
| 7894 | pHddCtx->cfg_ini->vosTraceEnableTL); |
| 7895 | hdd_vos_trace_enable(VOS_MODULE_ID_WDI, |
| 7896 | pHddCtx->cfg_ini->vosTraceEnableWDI); |
| 7897 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD, |
| 7898 | pHddCtx->cfg_ini->vosTraceEnableHDD); |
| 7899 | hdd_vos_trace_enable(VOS_MODULE_ID_SME, |
| 7900 | pHddCtx->cfg_ini->vosTraceEnableSME); |
| 7901 | hdd_vos_trace_enable(VOS_MODULE_ID_PE, |
| 7902 | pHddCtx->cfg_ini->vosTraceEnablePE); |
Katya Nigam | 70d6833 | 2013-09-16 16:49:45 +0530 | [diff] [blame] | 7903 | hdd_vos_trace_enable(VOS_MODULE_ID_PMC, |
| 7904 | pHddCtx->cfg_ini->vosTraceEnablePMC); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 7905 | hdd_vos_trace_enable(VOS_MODULE_ID_WDA, |
| 7906 | pHddCtx->cfg_ini->vosTraceEnableWDA); |
| 7907 | hdd_vos_trace_enable(VOS_MODULE_ID_SYS, |
| 7908 | pHddCtx->cfg_ini->vosTraceEnableSYS); |
| 7909 | hdd_vos_trace_enable(VOS_MODULE_ID_VOSS, |
| 7910 | pHddCtx->cfg_ini->vosTraceEnableVOSS); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 7911 | hdd_vos_trace_enable(VOS_MODULE_ID_SAP, |
| 7912 | pHddCtx->cfg_ini->vosTraceEnableSAP); |
| 7913 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP, |
| 7914 | pHddCtx->cfg_ini->vosTraceEnableHDDSAP); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 7915 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7916 | // Update WDI trace levels based upon the cfg.ini |
| 7917 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL, |
| 7918 | pHddCtx->cfg_ini->wdiTraceEnableDAL); |
| 7919 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL, |
| 7920 | pHddCtx->cfg_ini->wdiTraceEnableCTL); |
| 7921 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA, |
| 7922 | pHddCtx->cfg_ini->wdiTraceEnableDAT); |
| 7923 | hdd_wdi_trace_enable(eWLAN_MODULE_PAL, |
| 7924 | pHddCtx->cfg_ini->wdiTraceEnablePAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7925 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7926 | if (VOS_FTM_MODE == hdd_get_conparam()) |
| 7927 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7928 | if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) ) |
| 7929 | { |
| 7930 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__); |
| 7931 | goto err_free_hdd_context; |
| 7932 | } |
| 7933 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__); |
| 7934 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7935 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7936 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7937 | //Open watchdog module |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7938 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 7939 | { |
| 7940 | status = vos_watchdog_open(pVosContext, |
| 7941 | &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext)); |
| 7942 | |
| 7943 | if(!VOS_IS_STATUS_SUCCESS( status )) |
| 7944 | { |
| 7945 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 7946 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7947 | } |
| 7948 | } |
| 7949 | |
| 7950 | pHddCtx->isLogpInProgress = FALSE; |
| 7951 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 7952 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7953 | status = vos_chipVoteOnXOBuffer(NULL, NULL, NULL); |
| 7954 | if(!VOS_IS_STATUS_SUCCESS(status)) |
| 7955 | { |
| 7956 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed to configure 19.2 MHz Clock", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7957 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7958 | } |
| 7959 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 7960 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 7961 | /* initialize the NV module. This is required so that |
| 7962 | we can initialize the channel information in wiphy |
| 7963 | from the NV.bin data. The channel information in |
| 7964 | wiphy needs to be initialized before wiphy registration */ |
| 7965 | |
| 7966 | status = vos_nv_open(); |
| 7967 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 7968 | { |
| 7969 | /* NV module cannot be initialized */ |
| 7970 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 7971 | "%s: vos_nv_open failed", __func__); |
| 7972 | goto err_clkvote; |
| 7973 | } |
| 7974 | |
| 7975 | status = vos_init_wiphy_from_nv_bin(); |
| 7976 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 7977 | { |
| 7978 | /* NV module cannot be initialized */ |
| 7979 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 7980 | "%s: vos_init_wiphy failed", __func__); |
| 7981 | goto err_vos_nv_close; |
| 7982 | } |
| 7983 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 7984 | /* registration of wiphy dev with cfg80211 */ |
| 7985 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 7986 | { |
| 7987 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 7988 | goto err_vos_nv_close; |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 7989 | } |
| 7990 | #endif |
| 7991 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7992 | status = vos_open( &pVosContext, 0); |
| 7993 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 7994 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 7995 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 7996 | goto err_wiphy_unregister; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7997 | } |
| 7998 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7999 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 8000 | |
| 8001 | if ( NULL == pHddCtx->hHal ) |
| 8002 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8003 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8004 | goto err_vosclose; |
| 8005 | } |
| 8006 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8007 | status = vos_preStart( pHddCtx->pvosContext ); |
| 8008 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8009 | { |
| 8010 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__); |
| 8011 | goto err_vosclose; |
| 8012 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8013 | |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 8014 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) |
| 8015 | { |
| 8016 | pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan; |
| 8017 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d", |
| 8018 | __func__, enable_dfs_chan_scan); |
| 8019 | } |
| 8020 | if (0 == enable_11d || 1 == enable_11d) |
| 8021 | { |
| 8022 | pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d; |
| 8023 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d", |
| 8024 | __func__, enable_11d); |
| 8025 | } |
| 8026 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8027 | /* Note that the vos_preStart() sequence triggers the cfg download. |
| 8028 | The cfg download must occur before we update the SME config |
| 8029 | since the SME config operation must access the cfg database */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8030 | status = hdd_set_sme_config( pHddCtx ); |
| 8031 | |
| 8032 | if ( VOS_STATUS_SUCCESS != status ) |
| 8033 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8034 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed hdd_set_sme_config", __func__); |
| 8035 | goto err_vosclose; |
| 8036 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8037 | |
| 8038 | //Initialize the WMM module |
| 8039 | status = hdd_wmm_init(pHddCtx); |
| 8040 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8041 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8042 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_wmm_init failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8043 | goto err_vosclose; |
| 8044 | } |
| 8045 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8046 | /* In the integrated architecture we update the configuration from |
| 8047 | the INI file and from NV before vOSS has been started so that |
| 8048 | the final contents are available to send down to the cCPU */ |
| 8049 | |
| 8050 | // Apply the cfg.ini to cfg.dat |
| 8051 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 8052 | { |
| 8053 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
| 8054 | goto err_vosclose; |
| 8055 | } |
| 8056 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8057 | // Get mac addr from platform driver |
| 8058 | ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes); |
| 8059 | |
| 8060 | if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8061 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8062 | /* Store the mac addr for first interface */ |
| 8063 | pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr; |
| 8064 | |
| 8065 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8066 | "%s: WLAN Mac Addr: " |
| 8067 | MAC_ADDRESS_STR, __func__, |
| 8068 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 8069 | |
| 8070 | /* Here, passing Arg2 as 1 because we do not want to change the |
| 8071 | last 3 bytes (means non OUI bytes) of first interface mac |
| 8072 | addr. |
| 8073 | */ |
| 8074 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr)) |
| 8075 | { |
| 8076 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8077 | "%s: Failed to generate wlan interface mac addr " |
| 8078 | "using MAC from ini file ", __func__); |
| 8079 | } |
| 8080 | } |
| 8081 | else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx)) |
| 8082 | { |
| 8083 | // Apply the NV to cfg.dat |
| 8084 | /* Prima Update MAC address only at here */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8085 | #ifdef WLAN_AUTOGEN_MACADDR_FEATURE |
| 8086 | /* There was not a valid set of MAC Addresses in NV. See if the |
| 8087 | default addresses were modified by the cfg.ini settings. If so, |
| 8088 | we'll use them, but if not, we'll autogenerate a set of MAC |
| 8089 | addresses based upon the device serial number */ |
| 8090 | |
| 8091 | static const v_MACADDR_t default_address = |
| 8092 | {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8093 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8094 | if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0], |
| 8095 | sizeof(default_address))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8096 | { |
| 8097 | /* cfg.ini has the default address, invoke autogen logic */ |
| 8098 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8099 | /* Here, passing Arg2 as 0 because we want to change the |
| 8100 | last 3 bytes (means non OUI bytes) of all the interfaces |
| 8101 | mac addr. |
| 8102 | */ |
| 8103 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0, |
| 8104 | default_address)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8105 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8106 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8107 | "%s: Failed to generate wlan interface mac addr " |
| 8108 | "using MAC from ini file " MAC_ADDRESS_STR, __func__, |
| 8109 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8110 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8111 | } |
| 8112 | else |
| 8113 | #endif //WLAN_AUTOGEN_MACADDR_FEATURE |
| 8114 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8115 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8116 | "%s: Invalid MAC address in NV, using MAC from ini file " |
| 8117 | MAC_ADDRESS_STR, __func__, |
| 8118 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 8119 | } |
| 8120 | } |
| 8121 | { |
| 8122 | eHalStatus halStatus; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8123 | |
| 8124 | /* Set the MAC Address Currently this is used by HAL to |
| 8125 | * add self sta. Remove this once self sta is added as |
| 8126 | * part of session open. |
| 8127 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8128 | halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID, |
| 8129 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 8130 | sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) ); |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8131 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8132 | if (!HAL_STATUS_SUCCESS( halStatus )) |
| 8133 | { |
| 8134 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 8135 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus ); |
Madan Mohan Koyyalamudi | b8b126b | 2012-11-15 17:37:30 -0800 | [diff] [blame] | 8136 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8137 | } |
| 8138 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8139 | |
| 8140 | /*Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 8141 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 8142 | status = vos_start( pHddCtx->pvosContext ); |
| 8143 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8144 | { |
| 8145 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
| 8146 | goto err_vosclose; |
| 8147 | } |
| 8148 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8149 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 8150 | hdd_exchange_version_and_caps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8151 | |
| 8152 | status = hdd_post_voss_start_config( pHddCtx ); |
| 8153 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8154 | { |
| 8155 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 8156 | __func__); |
| 8157 | goto err_vosstop; |
| 8158 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8159 | |
| 8160 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8161 | wlan_hdd_cfg80211_update_reg_info( wiphy ); |
| 8162 | |
| 8163 | /* registration of wiphy dev with cfg80211 */ |
| 8164 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 8165 | { |
| 8166 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 8167 | goto err_vosstop; |
| 8168 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8169 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8170 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8171 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 8172 | { |
| 8173 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d", |
| 8174 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 8175 | } |
| 8176 | else |
| 8177 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8178 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d", |
| 8179 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 8180 | if (pAdapter != NULL) |
| 8181 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 8182 | if ( pHddCtx->cfg_ini->isP2pDeviceAddrAdministrated ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8183 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 8184 | vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes, |
| 8185 | pHddCtx->cfg_ini->intfMacAddr[0].bytes, |
| 8186 | sizeof(tSirMacAddr)); |
Madan Mohan Koyyalamudi | edfc1b7 | 2012-10-18 20:25:55 -0700 | [diff] [blame] | 8187 | |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 8188 | /* Generate the P2P Device Address. This consists of the device's |
| 8189 | * primary MAC address with the locally administered bit set. |
| 8190 | */ |
| 8191 | pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8192 | } |
| 8193 | else |
| 8194 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 8195 | tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx); |
| 8196 | if (p2p_dev_addr != NULL) |
| 8197 | { |
| 8198 | vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0], |
| 8199 | p2p_dev_addr, VOS_MAC_ADDR_SIZE); |
| 8200 | } |
| 8201 | else |
| 8202 | { |
| 8203 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8204 | "%s: Failed to allocate mac_address for p2p_device", |
| 8205 | __func__); |
| 8206 | goto err_close_adapter; |
| 8207 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8208 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8209 | |
| 8210 | pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 8211 | &pHddCtx->p2pDeviceAddress.bytes[0], FALSE ); |
| 8212 | if ( NULL == pP2pAdapter ) |
| 8213 | { |
| 8214 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8215 | "%s: Failed to do hdd_open_adapter for P2P Device Interface", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8216 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8217 | goto err_close_adapter; |
| 8218 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8219 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8220 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8221 | |
| 8222 | if( pAdapter == NULL ) |
| 8223 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8224 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 8225 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8226 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8227 | |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8228 | if (country_code) |
| 8229 | { |
| 8230 | eHalStatus ret; |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 8231 | INIT_COMPLETION(pAdapter->change_country_code); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8232 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
| 8233 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 8234 | hdd_checkandupdate_phymode(pAdapter, country_code); |
| 8235 | #endif |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 8236 | ret = sme_ChangeCountryCode(pHddCtx->hHal, |
| 8237 | (void *)(tSmeChangeCountryCallback) |
| 8238 | wlan_hdd_change_country_code_callback, |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8239 | country_code, |
| 8240 | pAdapter, pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 8241 | eSIR_TRUE, eSIR_TRUE); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8242 | if (eHAL_STATUS_SUCCESS == ret) |
| 8243 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 8244 | ret = wait_for_completion_interruptible_timeout( |
| 8245 | &pAdapter->change_country_code, |
| 8246 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 8247 | |
| 8248 | if (0 >= ret) |
| 8249 | { |
| 8250 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8251 | "%s: SME while setting country code timed out", __func__); |
| 8252 | } |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8253 | } |
| 8254 | else |
| 8255 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 8256 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8257 | "%s: SME Change Country code from module param fail ret=%d", |
| 8258 | __func__, ret); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8259 | } |
| 8260 | } |
| 8261 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8262 | #ifdef WLAN_BTAMP_FEATURE |
| 8263 | vStatus = WLANBAP_Open(pVosContext); |
| 8264 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 8265 | { |
| 8266 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8267 | "%s: Failed to open BAP",__func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8268 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8269 | } |
| 8270 | |
| 8271 | vStatus = BSL_Init(pVosContext); |
| 8272 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 8273 | { |
| 8274 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8275 | "%s: Failed to Init BSL",__func__); |
| 8276 | goto err_bap_close; |
| 8277 | } |
| 8278 | vStatus = WLANBAP_Start(pVosContext); |
| 8279 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 8280 | { |
| 8281 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8282 | "%s: Failed to start TL",__func__); |
| 8283 | goto err_bap_close; |
| 8284 | } |
| 8285 | |
| 8286 | pConfig = pHddCtx->cfg_ini; |
| 8287 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 8288 | status = WLANBAP_SetConfig(&btAmpConfig); |
| 8289 | |
| 8290 | #endif //WLAN_BTAMP_FEATURE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8291 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 8292 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 8293 | if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE)) |
| 8294 | { |
| 8295 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__); |
| 8296 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0; |
| 8297 | sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal), |
| 8298 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled); |
| 8299 | } |
| 8300 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8301 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 8302 | /*SME must send channel update configuration to RIVA*/ |
| 8303 | sme_UpdateChannelConfig(pHddCtx->hHal); |
| 8304 | #endif |
| 8305 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8306 | /* Register with platform driver as client for Suspend/Resume */ |
| 8307 | status = hddRegisterPmOps(pHddCtx); |
| 8308 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8309 | { |
| 8310 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 8311 | #ifdef WLAN_BTAMP_FEATURE |
| 8312 | goto err_bap_stop; |
| 8313 | #else |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8314 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8315 | #endif //WLAN_BTAMP_FEATURE |
| 8316 | } |
| 8317 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8318 | /* Open debugfs interface */ |
| 8319 | if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter)) |
| 8320 | { |
| 8321 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8322 | "%s: hdd_debugfs_init failed!", __func__); |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8323 | } |
| 8324 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8325 | /* Register TM level change handler function to the platform */ |
| 8326 | status = hddDevTmRegisterNotifyCallback(pHddCtx); |
| 8327 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8328 | { |
| 8329 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__); |
| 8330 | goto err_unregister_pmops; |
| 8331 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8332 | |
| 8333 | /* register for riva power on lock to platform driver */ |
| 8334 | if (req_riva_power_on_lock("wlan")) |
| 8335 | { |
| 8336 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 8337 | __func__); |
| 8338 | goto err_unregister_pmops; |
| 8339 | } |
| 8340 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8341 | // register net device notifier for device change notification |
| 8342 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 8343 | |
| 8344 | if(ret < 0) |
| 8345 | { |
| 8346 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__); |
| 8347 | goto err_free_power_on_lock; |
| 8348 | } |
| 8349 | |
| 8350 | //Initialize the nlink service |
| 8351 | if(nl_srv_init() != 0) |
| 8352 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8353 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8354 | goto err_reg_netdev; |
| 8355 | } |
| 8356 | |
Leo Chang | 4ce1cc5 | 2013-10-21 18:27:15 -0700 | [diff] [blame] | 8357 | #ifdef WLAN_KD_READY_NOTIFIER |
| 8358 | pHddCtx->kd_nl_init = 1; |
| 8359 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 8360 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8361 | //Initialize the BTC service |
| 8362 | if(btc_activate_service(pHddCtx) != 0) |
| 8363 | { |
| 8364 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__); |
| 8365 | goto err_nl_srv; |
| 8366 | } |
| 8367 | |
| 8368 | #ifdef PTT_SOCK_SVC_ENABLE |
| 8369 | //Initialize the PTT service |
| 8370 | if(ptt_sock_activate_svc(pHddCtx) != 0) |
| 8371 | { |
| 8372 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__); |
| 8373 | goto err_nl_srv; |
| 8374 | } |
| 8375 | #endif |
| 8376 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8377 | hdd_register_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8378 | if (VOS_STA_SAP_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8379 | { |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 8380 | /* Action frame registered in one adapter which will |
| 8381 | * applicable to all interfaces |
| 8382 | */ |
Madan Mohan Koyyalamudi | e233e29 | 2012-09-18 17:38:02 -0700 | [diff] [blame] | 8383 | wlan_hdd_cfg80211_post_voss_start(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8384 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8385 | |
| 8386 | mutex_init(&pHddCtx->sap_lock); |
| 8387 | |
| 8388 | pHddCtx->isLoadUnloadInProgress = FALSE; |
| 8389 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8390 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8391 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 8392 | /* Initialize the wake lcok */ |
| 8393 | wake_lock_init(&pHddCtx->rx_wake_lock, |
| 8394 | WAKE_LOCK_SUSPEND, |
| 8395 | "qcom_rx_wakelock"); |
| 8396 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 8397 | /* Initialize the wake lcok */ |
| 8398 | wake_lock_init(&pHddCtx->sap_wake_lock, |
| 8399 | WAKE_LOCK_SUSPEND, |
| 8400 | "qcom_sap_wakelock"); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8401 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8402 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8403 | vos_event_init(&pHddCtx->scan_info.scan_finished_event); |
| 8404 | pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8405 | |
| 8406 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 8407 | hdd_allow_suspend(); |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 8408 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 8409 | /*updating wiphy so that regulatory user hints can be processed*/ |
| 8410 | if (wiphy) |
| 8411 | { |
| 8412 | regulatory_hint(wiphy, "00"); |
| 8413 | } |
| 8414 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8415 | // Initialize the restart logic |
| 8416 | wlan_hdd_restart_init(pHddCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 8417 | |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 8418 | #ifdef FEATURE_WLAN_CH_AVOID |
| 8419 | /* Plug in avoid channel notification callback */ |
| 8420 | sme_AddChAvoidCallback(pHddCtx->hHal, |
| 8421 | hdd_hostapd_ch_avoid_cb); |
| 8422 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 8423 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 8424 | //Register the traffic monitor timer now |
| 8425 | if ( pHddCtx->cfg_ini->dynSplitscan) |
| 8426 | { |
| 8427 | vos_timer_init(&pHddCtx->tx_rx_trafficTmr, |
| 8428 | VOS_TIMER_TYPE_SW, |
| 8429 | hdd_tx_rx_pkt_cnt_stat_timer_handler, |
| 8430 | (void *)pHddCtx); |
| 8431 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8432 | goto success; |
| 8433 | |
| 8434 | err_nl_srv: |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 8435 | #ifdef WLAN_KD_READY_NOTIFIER |
| 8436 | nl_srv_exit(pHddCtx->ptt_pid); |
| 8437 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8438 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 8439 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8440 | err_reg_netdev: |
| 8441 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 8442 | |
| 8443 | err_free_power_on_lock: |
| 8444 | free_riva_power_on_lock("wlan"); |
| 8445 | |
| 8446 | err_unregister_pmops: |
| 8447 | hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 8448 | hddDeregisterPmOps(pHddCtx); |
| 8449 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8450 | hdd_debugfs_exit(pHddCtx); |
| 8451 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8452 | #ifdef WLAN_BTAMP_FEATURE |
| 8453 | err_bap_stop: |
| 8454 | WLANBAP_Stop(pVosContext); |
| 8455 | #endif |
| 8456 | |
| 8457 | #ifdef WLAN_BTAMP_FEATURE |
| 8458 | err_bap_close: |
| 8459 | WLANBAP_Close(pVosContext); |
| 8460 | #endif |
| 8461 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8462 | err_close_adapter: |
| 8463 | hdd_close_all_adapters( pHddCtx ); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8464 | |
| 8465 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8466 | wiphy_unregister(wiphy) ; |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8467 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8468 | |
| 8469 | err_vosstop: |
| 8470 | vos_stop(pVosContext); |
| 8471 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8472 | err_vosclose: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8473 | status = vos_sched_close( pVosContext ); |
| 8474 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 8475 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 8476 | "%s: Failed to close VOSS Scheduler", __func__); |
| 8477 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 8478 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8479 | vos_close(pVosContext ); |
| 8480 | |
| 8481 | err_wiphy_unregister: |
| 8482 | |
| 8483 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 8484 | wiphy_unregister(wiphy); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8485 | |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 8486 | err_vos_nv_close: |
| 8487 | |
| 8488 | vos_nv_close(); |
| 8489 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8490 | err_clkvote: |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8491 | #endif |
| 8492 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8493 | vos_chipVoteOffXOBuffer(NULL, NULL, NULL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8494 | |
| 8495 | err_wdclose: |
| 8496 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 8497 | vos_watchdog_close(pVosContext); |
| 8498 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8499 | err_config: |
| 8500 | kfree(pHddCtx->cfg_ini); |
| 8501 | pHddCtx->cfg_ini= NULL; |
| 8502 | |
| 8503 | err_free_hdd_context: |
| 8504 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8505 | wiphy_free(wiphy) ; |
| 8506 | //kfree(wdev) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8507 | VOS_BUG(1); |
| 8508 | |
Madan Mohan Koyyalamudi | d57ae63 | 2012-11-06 18:42:48 -0800 | [diff] [blame] | 8509 | if (hdd_is_ssr_required()) |
| 8510 | { |
| 8511 | /* WDI timeout had happened during load, so SSR is needed here */ |
| 8512 | subsystem_restart("wcnss"); |
| 8513 | msleep(5000); |
| 8514 | } |
| 8515 | hdd_set_ssr_required (VOS_FALSE); |
| 8516 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8517 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8518 | |
| 8519 | success: |
| 8520 | EXIT(); |
| 8521 | return 0; |
| 8522 | } |
| 8523 | |
| 8524 | /**--------------------------------------------------------------------------- |
| 8525 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8526 | \brief hdd_driver_init() - Core Driver Init Function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8527 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8528 | This is the driver entry point - called in different timeline depending |
| 8529 | on whether the driver is statically or dynamically linked |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8530 | |
| 8531 | \param - None |
| 8532 | |
| 8533 | \return - 0 for success, non zero for failure |
| 8534 | |
| 8535 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8536 | static int hdd_driver_init( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8537 | { |
| 8538 | VOS_STATUS status; |
| 8539 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8540 | struct device *dev = NULL; |
| 8541 | int ret_status = 0; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 8542 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 8543 | int max_retries = 0; |
| 8544 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8545 | |
Gopichand Nakkala | d077496 | 2013-05-24 11:32:21 +0530 | [diff] [blame] | 8546 | #ifdef WCONN_TRACE_KMSG_LOG_BUFF |
| 8547 | vos_wconn_trace_init(); |
| 8548 | #endif |
| 8549 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8550 | ENTER(); |
| 8551 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8552 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8553 | wake_lock_init(&wlan_wake_lock, WAKE_LOCK_SUSPEND, "wlan"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8554 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8555 | |
| 8556 | pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME, |
| 8557 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 8558 | |
| 8559 | //Power Up Libra WLAN card first if not already powered up |
| 8560 | status = vos_chipPowerUp(NULL,NULL,NULL); |
| 8561 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8562 | { |
| 8563 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Libra WLAN not Powered Up. " |
| 8564 | "exiting", __func__); |
madan mohan koyyalamudi | 8c96ce1 | 2013-07-10 19:14:39 +0530 | [diff] [blame] | 8565 | #ifdef WLAN_OPEN_SOURCE |
| 8566 | wake_lock_destroy(&wlan_wake_lock); |
| 8567 | #endif |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8568 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8569 | } |
| 8570 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8571 | #ifdef ANI_BUS_TYPE_PCI |
| 8572 | |
| 8573 | dev = wcnss_wlan_get_device(); |
| 8574 | |
| 8575 | #endif // ANI_BUS_TYPE_PCI |
| 8576 | |
| 8577 | #ifdef ANI_BUS_TYPE_PLATFORM |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 8578 | |
| 8579 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 8580 | /* wait until WCNSS driver downloads NV */ |
| 8581 | while (!wcnss_device_ready() && 5 >= ++max_retries) { |
| 8582 | msleep(1000); |
| 8583 | } |
| 8584 | if (max_retries >= 5) { |
| 8585 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
madan mohan koyyalamudi | 8c96ce1 | 2013-07-10 19:14:39 +0530 | [diff] [blame] | 8586 | #ifdef WLAN_OPEN_SOURCE |
| 8587 | wake_lock_destroy(&wlan_wake_lock); |
| 8588 | #endif |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 8589 | return -ENODEV; |
| 8590 | } |
| 8591 | #endif |
| 8592 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8593 | dev = wcnss_wlan_get_device(); |
| 8594 | #endif // ANI_BUS_TYPE_PLATFORM |
| 8595 | |
| 8596 | |
| 8597 | do { |
| 8598 | if (NULL == dev) { |
| 8599 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__); |
| 8600 | ret_status = -1; |
| 8601 | break; |
| 8602 | } |
| 8603 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8604 | #ifdef TIMER_MANAGER |
| 8605 | vos_timer_manager_init(); |
| 8606 | #endif |
| 8607 | |
| 8608 | /* Preopen VOSS so that it is ready to start at least SAL */ |
| 8609 | status = vos_preOpen(&pVosContext); |
| 8610 | |
| 8611 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8612 | { |
| 8613 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__); |
| 8614 | ret_status = -1; |
| 8615 | break; |
| 8616 | } |
| 8617 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8618 | #ifndef MODULE |
| 8619 | /* For statically linked driver, call hdd_set_conparam to update curr_con_mode |
| 8620 | */ |
| 8621 | hdd_set_conparam((v_UINT_t)con_mode); |
| 8622 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8623 | |
| 8624 | // Call our main init function |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8625 | if (hdd_wlan_startup(dev)) |
| 8626 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8627 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed", |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8628 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8629 | vos_preClose( &pVosContext ); |
| 8630 | ret_status = -1; |
| 8631 | break; |
| 8632 | } |
| 8633 | |
| 8634 | /* Cancel the vote for XO Core ON |
| 8635 | * This is done here for safety purposes in case we re-initialize without turning |
| 8636 | * it OFF in any error scenario. |
| 8637 | */ |
Madan Mohan Koyyalamudi | 8b7f1e6 | 2012-10-05 14:56:51 -0700 | [diff] [blame] | 8638 | hddLog(VOS_TRACE_LEVEL_INFO, "In module init: Ensure Force XO Core is OFF" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8639 | " when WLAN is turned ON so Core toggles" |
Madan Mohan Koyyalamudi | 8b7f1e6 | 2012-10-05 14:56:51 -0700 | [diff] [blame] | 8640 | " unless we enter PSD"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8641 | if (vos_chipVoteXOCore(NULL, NULL, NULL, VOS_FALSE) != VOS_STATUS_SUCCESS) |
| 8642 | { |
| 8643 | hddLog(VOS_TRACE_LEVEL_ERROR, "Could not cancel XO Core ON vote. Not returning failure." |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8644 | " Power consumed will be high"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8645 | } |
| 8646 | } while (0); |
| 8647 | |
| 8648 | if (0 != ret_status) |
| 8649 | { |
| 8650 | //Assert Deep sleep signal now to put Libra HW in lowest power state |
| 8651 | status = vos_chipAssertDeepSleep( NULL, NULL, NULL ); |
| 8652 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status) ); |
| 8653 | |
| 8654 | //Vote off any PMIC voltage supplies |
| 8655 | vos_chipPowerDown(NULL, NULL, NULL); |
| 8656 | #ifdef TIMER_MANAGER |
| 8657 | vos_timer_exit(); |
| 8658 | #endif |
| 8659 | #ifdef MEMORY_DEBUG |
| 8660 | vos_mem_exit(); |
| 8661 | #endif |
| 8662 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8663 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8664 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8665 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8666 | pr_err("%s: driver load failure\n", WLAN_MODULE_NAME); |
| 8667 | } |
| 8668 | else |
| 8669 | { |
| 8670 | //Send WLAN UP indication to Nlink Service |
| 8671 | send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); |
| 8672 | |
| 8673 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8674 | } |
| 8675 | |
| 8676 | EXIT(); |
| 8677 | |
| 8678 | return ret_status; |
| 8679 | } |
| 8680 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8681 | /**--------------------------------------------------------------------------- |
| 8682 | |
| 8683 | \brief hdd_module_init() - Init Function |
| 8684 | |
| 8685 | This is the driver entry point (invoked when module is loaded using insmod) |
| 8686 | |
| 8687 | \param - None |
| 8688 | |
| 8689 | \return - 0 for success, non zero for failure |
| 8690 | |
| 8691 | --------------------------------------------------------------------------*/ |
| 8692 | #ifdef MODULE |
| 8693 | static int __init hdd_module_init ( void) |
| 8694 | { |
| 8695 | return hdd_driver_init(); |
| 8696 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8697 | #else /* #ifdef MODULE */ |
| 8698 | static int __init hdd_module_init ( void) |
| 8699 | { |
| 8700 | /* Driver initialization is delayed to fwpath_changed_handler */ |
| 8701 | return 0; |
| 8702 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8703 | #endif /* #ifdef MODULE */ |
| 8704 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8705 | |
| 8706 | /**--------------------------------------------------------------------------- |
| 8707 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8708 | \brief hdd_driver_exit() - Exit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8709 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8710 | This is the driver exit point (invoked when module is unloaded using rmmod |
| 8711 | or con_mode was changed by userspace) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8712 | |
| 8713 | \param - None |
| 8714 | |
| 8715 | \return - None |
| 8716 | |
| 8717 | --------------------------------------------------------------------------*/ |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8718 | static void hdd_driver_exit(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8719 | { |
| 8720 | hdd_context_t *pHddCtx = NULL; |
| 8721 | v_CONTEXT_t pVosContext = NULL; |
Sameer Thalappil | 451ebb9 | 2013-06-28 15:49:58 -0700 | [diff] [blame] | 8722 | int retry = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8723 | |
| 8724 | pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR); |
| 8725 | |
| 8726 | //Get the global vos context |
| 8727 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 8728 | |
| 8729 | if(!pVosContext) |
| 8730 | { |
| 8731 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 8732 | goto done; |
| 8733 | } |
| 8734 | |
| 8735 | //Get the HDD context. |
| 8736 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 8737 | |
| 8738 | if(!pHddCtx) |
| 8739 | { |
| 8740 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__); |
| 8741 | } |
| 8742 | else |
| 8743 | { |
Sameer Thalappil | 451ebb9 | 2013-06-28 15:49:58 -0700 | [diff] [blame] | 8744 | while(isWDresetInProgress()) { |
| 8745 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8746 | "%s:SSR in Progress; block rmmod for 1 second!!!", __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8747 | msleep(1000); |
Sameer Thalappil | 451ebb9 | 2013-06-28 15:49:58 -0700 | [diff] [blame] | 8748 | |
| 8749 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 8750 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8751 | "%s:SSR never completed, fatal error", __func__); |
| 8752 | VOS_BUG(0); |
| 8753 | } |
| 8754 | } |
| 8755 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8756 | |
| 8757 | pHddCtx->isLoadUnloadInProgress = TRUE; |
| 8758 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 8759 | |
| 8760 | //Do all the cleanup before deregistering the driver |
| 8761 | hdd_wlan_exit(pHddCtx); |
| 8762 | } |
| 8763 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8764 | vos_preClose( &pVosContext ); |
| 8765 | |
| 8766 | #ifdef TIMER_MANAGER |
| 8767 | vos_timer_exit(); |
| 8768 | #endif |
| 8769 | #ifdef MEMORY_DEBUG |
| 8770 | vos_mem_exit(); |
| 8771 | #endif |
| 8772 | |
Gopichand Nakkala | d077496 | 2013-05-24 11:32:21 +0530 | [diff] [blame] | 8773 | #ifdef WCONN_TRACE_KMSG_LOG_BUFF |
| 8774 | vos_wconn_trace_exit(); |
| 8775 | #endif |
| 8776 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8777 | done: |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8778 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8779 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8780 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8781 | pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME); |
| 8782 | } |
| 8783 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8784 | /**--------------------------------------------------------------------------- |
| 8785 | |
| 8786 | \brief hdd_module_exit() - Exit function |
| 8787 | |
| 8788 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 8789 | |
| 8790 | \param - None |
| 8791 | |
| 8792 | \return - None |
| 8793 | |
| 8794 | --------------------------------------------------------------------------*/ |
| 8795 | static void __exit hdd_module_exit(void) |
| 8796 | { |
| 8797 | hdd_driver_exit(); |
| 8798 | } |
| 8799 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8800 | #ifdef MODULE |
| 8801 | static int fwpath_changed_handler(const char *kmessage, |
| 8802 | struct kernel_param *kp) |
| 8803 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8804 | return param_set_copystring(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8805 | } |
| 8806 | |
| 8807 | static int con_mode_handler(const char *kmessage, |
| 8808 | struct kernel_param *kp) |
| 8809 | { |
Madan Mohan Koyyalamudi | f2f8d8b | 2012-10-11 17:06:59 -0700 | [diff] [blame] | 8810 | return param_set_int(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8811 | } |
| 8812 | #else /* #ifdef MODULE */ |
| 8813 | /**--------------------------------------------------------------------------- |
| 8814 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8815 | \brief kickstart_driver |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8816 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8817 | This is the driver entry point |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8818 | - delayed driver initialization when driver is statically linked |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8819 | - invoked when module parameter fwpath is modified from userspace to signal |
| 8820 | initializing the WLAN driver or when con_mode is modified from userspace |
| 8821 | to signal a switch in operating mode |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8822 | |
| 8823 | \return - 0 for success, non zero for failure |
| 8824 | |
| 8825 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8826 | static int kickstart_driver(void) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8827 | { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 8828 | int ret_status; |
| 8829 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8830 | if (!wlan_hdd_inited) { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 8831 | ret_status = hdd_driver_init(); |
| 8832 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 8833 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8834 | } |
| 8835 | |
| 8836 | hdd_driver_exit(); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8837 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8838 | msleep(200); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8839 | |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 8840 | ret_status = hdd_driver_init(); |
| 8841 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 8842 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 8843 | } |
| 8844 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8845 | /**--------------------------------------------------------------------------- |
| 8846 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8847 | \brief fwpath_changed_handler() - Handler Function |
| 8848 | |
| 8849 | Handle changes to the fwpath parameter |
| 8850 | |
| 8851 | \return - 0 for success, non zero for failure |
| 8852 | |
| 8853 | --------------------------------------------------------------------------*/ |
| 8854 | static int fwpath_changed_handler(const char *kmessage, |
| 8855 | struct kernel_param *kp) |
| 8856 | { |
| 8857 | int ret; |
| 8858 | |
| 8859 | ret = param_set_copystring(kmessage, kp); |
| 8860 | if (0 == ret) |
| 8861 | ret = kickstart_driver(); |
| 8862 | return ret; |
| 8863 | } |
| 8864 | |
| 8865 | /**--------------------------------------------------------------------------- |
| 8866 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8867 | \brief con_mode_handler() - |
| 8868 | |
| 8869 | Handler function for module param con_mode when it is changed by userspace |
| 8870 | Dynamically linked - do nothing |
| 8871 | Statically linked - exit and init driver, as in rmmod and insmod |
| 8872 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8873 | \param - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8874 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8875 | \return - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8876 | |
| 8877 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8878 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8879 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8880 | int ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8881 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 8882 | ret = param_set_int(kmessage, kp); |
| 8883 | if (0 == ret) |
| 8884 | ret = kickstart_driver(); |
| 8885 | return ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8886 | } |
| 8887 | #endif /* #ifdef MODULE */ |
| 8888 | |
| 8889 | /**--------------------------------------------------------------------------- |
| 8890 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8891 | \brief hdd_get_conparam() - |
| 8892 | |
| 8893 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 8894 | |
| 8895 | \param - None |
| 8896 | |
| 8897 | \return - tVOS_CON_MODE |
| 8898 | |
| 8899 | --------------------------------------------------------------------------*/ |
| 8900 | tVOS_CON_MODE hdd_get_conparam ( void ) |
| 8901 | { |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8902 | #ifdef MODULE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8903 | return (tVOS_CON_MODE)con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8904 | #else |
| 8905 | return (tVOS_CON_MODE)curr_con_mode; |
| 8906 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8907 | } |
| 8908 | void hdd_set_conparam ( v_UINT_t newParam ) |
| 8909 | { |
| 8910 | con_mode = newParam; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 8911 | #ifndef MODULE |
| 8912 | curr_con_mode = con_mode; |
| 8913 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8914 | } |
| 8915 | /**--------------------------------------------------------------------------- |
| 8916 | |
| 8917 | \brief hdd_softap_sta_deauth() - function |
| 8918 | |
| 8919 | This to take counter measure to handle deauth req from HDD |
| 8920 | |
| 8921 | \param - pAdapter - Pointer to the HDD |
| 8922 | |
| 8923 | \param - enable - boolean value |
| 8924 | |
| 8925 | \return - None |
| 8926 | |
| 8927 | --------------------------------------------------------------------------*/ |
| 8928 | |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 8929 | VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, v_U8_t *pDestMacAddress) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8930 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8931 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 8932 | VOS_STATUS vosStatus = VOS_STATUS_E_FAULT; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8933 | |
| 8934 | ENTER(); |
| 8935 | |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 8936 | hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)", |
| 8937 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8938 | |
| 8939 | //Ignore request to deauth bcmc station |
| 8940 | if( pDestMacAddress[0] & 0x1 ) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 8941 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8942 | |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 8943 | vosStatus = WLANSAP_DeauthSta(pVosContext,pDestMacAddress); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8944 | |
| 8945 | EXIT(); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 8946 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8947 | } |
| 8948 | |
| 8949 | /**--------------------------------------------------------------------------- |
| 8950 | |
| 8951 | \brief hdd_softap_sta_disassoc() - function |
| 8952 | |
| 8953 | This to take counter measure to handle deauth req from HDD |
| 8954 | |
| 8955 | \param - pAdapter - Pointer to the HDD |
| 8956 | |
| 8957 | \param - enable - boolean value |
| 8958 | |
| 8959 | \return - None |
| 8960 | |
| 8961 | --------------------------------------------------------------------------*/ |
| 8962 | |
| 8963 | void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress) |
| 8964 | { |
| 8965 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 8966 | |
| 8967 | ENTER(); |
| 8968 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8969 | hddLog( LOGE, "hdd_softap_sta_disassoc:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8970 | |
| 8971 | //Ignore request to disassoc bcmc station |
| 8972 | if( pDestMacAddress[0] & 0x1 ) |
| 8973 | return; |
| 8974 | |
| 8975 | WLANSAP_DisassocSta(pVosContext,pDestMacAddress); |
| 8976 | } |
| 8977 | |
| 8978 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable) |
| 8979 | { |
| 8980 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 8981 | |
| 8982 | ENTER(); |
| 8983 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8984 | hddLog( LOGE, "hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8985 | |
| 8986 | WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable); |
| 8987 | } |
| 8988 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8989 | /**--------------------------------------------------------------------------- |
| 8990 | * |
| 8991 | * \brief hdd_get__concurrency_mode() - |
| 8992 | * |
| 8993 | * |
| 8994 | * \param - None |
| 8995 | * |
| 8996 | * \return - CONCURRENCY MODE |
| 8997 | * |
| 8998 | * --------------------------------------------------------------------------*/ |
| 8999 | tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void ) |
| 9000 | { |
| 9001 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 9002 | hdd_context_t *pHddCtx; |
| 9003 | |
| 9004 | if (NULL != pVosContext) |
| 9005 | { |
| 9006 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 9007 | if (NULL != pHddCtx) |
| 9008 | { |
| 9009 | return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode; |
| 9010 | } |
| 9011 | } |
| 9012 | |
| 9013 | /* we are in an invalid state :( */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9014 | hddLog(LOGE, "%s: Invalid context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9015 | return VOS_STA; |
| 9016 | } |
| 9017 | |
| 9018 | /* Decide whether to allow/not the apps power collapse. |
| 9019 | * Allow apps power collapse if we are in connected state. |
| 9020 | * if not, allow only if we are in IMPS */ |
| 9021 | v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx) |
| 9022 | { |
| 9023 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9024 | tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal); |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 9025 | tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9026 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 9027 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9028 | hdd_adapter_t *pAdapter = NULL; |
| 9029 | VOS_STATUS status; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 9030 | tVOS_CONCURRENCY_MODE concurrent_state = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9031 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9032 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 9033 | return TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9034 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 9035 | concurrent_state = hdd_get_concurrency_mode(); |
| 9036 | |
| 9037 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 9038 | if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) || |
| 9039 | (concurrent_state == (VOS_STA | VOS_P2P_GO))) && |
| 9040 | (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)) |
| 9041 | return TRUE; |
| 9042 | #endif |
| 9043 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9044 | /*loop through all adapters. TBD fix for Concurrency */ |
| 9045 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9046 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9047 | { |
| 9048 | pAdapter = pAdapterNode->pAdapter; |
| 9049 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 9050 | || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 9051 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9052 | if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9053 | && (pmcState != IMPS && pmcState != BMPS |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9054 | && pmcState != STOPPED && pmcState != STANDBY)) || |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 9055 | (eANI_BOOLEAN_TRUE == scanRspPending) || |
| 9056 | (eANI_BOOLEAN_TRUE == inMiddleOfRoaming)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9057 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9058 | hddLog( LOGE, "%s: do not allow APPS power collapse-" |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 9059 | "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d", |
| 9060 | __func__, pmcState, scanRspPending, inMiddleOfRoaming ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9061 | return FALSE; |
| 9062 | } |
| 9063 | } |
| 9064 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9065 | pAdapterNode = pNext; |
| 9066 | } |
| 9067 | return TRUE; |
| 9068 | } |
| 9069 | |
Madan Mohan Koyyalamudi | c72a4d6 | 2012-11-08 14:59:34 -0800 | [diff] [blame] | 9070 | /* Decides whether to send suspend notification to Riva |
| 9071 | * if any adapter is in BMPS; then it is required */ |
| 9072 | v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx) |
| 9073 | { |
| 9074 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
| 9075 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 9076 | |
| 9077 | if (pConfig->fIsBmpsEnabled && (pmcState == BMPS)) |
| 9078 | { |
| 9079 | return TRUE; |
| 9080 | } |
| 9081 | return FALSE; |
| 9082 | } |
| 9083 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9084 | void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 9085 | { |
| 9086 | switch(mode) |
| 9087 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 9088 | case VOS_STA_MODE: |
| 9089 | case VOS_P2P_CLIENT_MODE: |
| 9090 | case VOS_P2P_GO_MODE: |
| 9091 | case VOS_STA_SAP_MODE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9092 | pHddCtx->concurrency_mode |= (1 << mode); |
| 9093 | pHddCtx->no_of_sessions[mode]++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9094 | break; |
| 9095 | default: |
| 9096 | break; |
| 9097 | |
| 9098 | } |
| 9099 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: concurrency_mode = 0x%x NumberofSessions for mode %d = %d", |
| 9100 | __func__,pHddCtx->concurrency_mode,mode,pHddCtx->no_of_sessions[mode]); |
| 9101 | } |
| 9102 | |
| 9103 | |
| 9104 | void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 9105 | { |
| 9106 | switch(mode) |
| 9107 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 9108 | case VOS_STA_MODE: |
| 9109 | case VOS_P2P_CLIENT_MODE: |
| 9110 | case VOS_P2P_GO_MODE: |
| 9111 | case VOS_STA_SAP_MODE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9112 | pHddCtx->no_of_sessions[mode]--; |
| 9113 | if (!(pHddCtx->no_of_sessions[mode])) |
| 9114 | pHddCtx->concurrency_mode &= (~(1 << mode)); |
| 9115 | break; |
| 9116 | default: |
| 9117 | break; |
| 9118 | } |
| 9119 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: concurrency_mode = 0x%x NumberofSessions for mode %d = %d", |
| 9120 | __func__,pHddCtx->concurrency_mode,mode,pHddCtx->no_of_sessions[mode]); |
| 9121 | } |
| 9122 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9123 | /**--------------------------------------------------------------------------- |
| 9124 | * |
| 9125 | * \brief wlan_hdd_restart_init |
| 9126 | * |
| 9127 | * This function initalizes restart timer/flag. An internal function. |
| 9128 | * |
| 9129 | * \param - pHddCtx |
| 9130 | * |
| 9131 | * \return - None |
| 9132 | * |
| 9133 | * --------------------------------------------------------------------------*/ |
| 9134 | |
| 9135 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx) |
| 9136 | { |
| 9137 | /* Initialize */ |
| 9138 | pHddCtx->hdd_restart_retries = 0; |
| 9139 | atomic_set(&pHddCtx->isRestartInProgress, 0); |
| 9140 | vos_timer_init(&pHddCtx->hdd_restart_timer, |
| 9141 | VOS_TIMER_TYPE_SW, |
| 9142 | wlan_hdd_restart_timer_cb, |
| 9143 | pHddCtx); |
| 9144 | } |
| 9145 | /**--------------------------------------------------------------------------- |
| 9146 | * |
| 9147 | * \brief wlan_hdd_restart_deinit |
| 9148 | * |
| 9149 | * This function cleans up the resources used. An internal function. |
| 9150 | * |
| 9151 | * \param - pHddCtx |
| 9152 | * |
| 9153 | * \return - None |
| 9154 | * |
| 9155 | * --------------------------------------------------------------------------*/ |
| 9156 | |
| 9157 | static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx) |
| 9158 | { |
| 9159 | |
| 9160 | VOS_STATUS vos_status; |
| 9161 | /* Block any further calls */ |
| 9162 | atomic_set(&pHddCtx->isRestartInProgress, 1); |
| 9163 | /* Cleanup */ |
| 9164 | vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer ); |
| 9165 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
Madan Mohan Koyyalamudi | 8b7f1e6 | 2012-10-05 14:56:51 -0700 | [diff] [blame] | 9166 | hddLog(LOGW, FL("Failed to stop HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9167 | vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer); |
| 9168 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
Madan Mohan Koyyalamudi | 8b7f1e6 | 2012-10-05 14:56:51 -0700 | [diff] [blame] | 9169 | hddLog(LOGW, FL("Failed to destroy HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9170 | |
| 9171 | } |
| 9172 | |
| 9173 | /**--------------------------------------------------------------------------- |
| 9174 | * |
| 9175 | * \brief wlan_hdd_framework_restart |
| 9176 | * |
| 9177 | * This function uses a cfg80211 API to start a framework initiated WLAN |
| 9178 | * driver module unload/load. |
| 9179 | * |
| 9180 | * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT). |
| 9181 | * |
| 9182 | * |
| 9183 | * \param - pHddCtx |
| 9184 | * |
| 9185 | * \return - VOS_STATUS_SUCCESS: Success |
| 9186 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 9187 | * VOS_STATUS_E_NOMEM: No memory |
| 9188 | |
| 9189 | * --------------------------------------------------------------------------*/ |
| 9190 | |
| 9191 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx) |
| 9192 | { |
| 9193 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 9194 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 9195 | int len = (sizeof (struct ieee80211_mgmt)); |
| 9196 | struct ieee80211_mgmt *mgmt = NULL; |
| 9197 | |
| 9198 | /* Prepare the DEAUTH managment frame with reason code */ |
| 9199 | mgmt = kzalloc(len, GFP_KERNEL); |
| 9200 | if(mgmt == NULL) |
| 9201 | { |
| 9202 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9203 | "%s: memory allocation failed (%d bytes)", __func__, len); |
| 9204 | return VOS_STATUS_E_NOMEM; |
| 9205 | } |
| 9206 | mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9207 | |
| 9208 | /* Iterate over all adapters/devices */ |
| 9209 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9210 | do |
| 9211 | { |
| 9212 | if( (status == VOS_STATUS_SUCCESS) && |
| 9213 | pAdapterNode && |
| 9214 | pAdapterNode->pAdapter) |
| 9215 | { |
| 9216 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9217 | "restarting the driver(intf:\'%s\' mode:%d :try %d)", |
| 9218 | pAdapterNode->pAdapter->dev->name, |
| 9219 | pAdapterNode->pAdapter->device_mode, |
| 9220 | pHddCtx->hdd_restart_retries + 1); |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 9221 | /* |
| 9222 | * CFG80211 event to restart the driver |
| 9223 | * |
| 9224 | * 'cfg80211_send_unprot_deauth' sends a |
| 9225 | * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state |
| 9226 | * of SME(Linux Kernel) state machine. |
| 9227 | * |
| 9228 | * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart |
| 9229 | * the driver. |
| 9230 | * |
| 9231 | */ |
| 9232 | |
| 9233 | cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9234 | } |
| 9235 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9236 | pAdapterNode = pNext; |
| 9237 | } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)); |
| 9238 | |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 9239 | |
| 9240 | /* Free the allocated management frame */ |
| 9241 | kfree(mgmt); |
| 9242 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9243 | /* Retry until we unload or reach max count */ |
| 9244 | if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT) |
| 9245 | vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS); |
| 9246 | |
| 9247 | return status; |
| 9248 | |
| 9249 | } |
| 9250 | /**--------------------------------------------------------------------------- |
| 9251 | * |
| 9252 | * \brief wlan_hdd_restart_timer_cb |
| 9253 | * |
| 9254 | * Restart timer callback. An internal function. |
| 9255 | * |
| 9256 | * \param - User data: |
| 9257 | * |
| 9258 | * \return - None |
| 9259 | * |
| 9260 | * --------------------------------------------------------------------------*/ |
| 9261 | |
| 9262 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback) |
| 9263 | { |
| 9264 | hdd_context_t *pHddCtx = usrDataForCallback; |
| 9265 | wlan_hdd_framework_restart(pHddCtx); |
| 9266 | return; |
| 9267 | |
| 9268 | } |
| 9269 | |
| 9270 | |
| 9271 | /**--------------------------------------------------------------------------- |
| 9272 | * |
| 9273 | * \brief wlan_hdd_restart_driver |
| 9274 | * |
| 9275 | * This function sends an event to supplicant to restart the WLAN driver. |
| 9276 | * |
| 9277 | * This function is called from vos_wlanRestart. |
| 9278 | * |
| 9279 | * \param - pHddCtx |
| 9280 | * |
| 9281 | * \return - VOS_STATUS_SUCCESS: Success |
| 9282 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 9283 | * VOS_STATUS_E_ALREADY: Request already in progress |
| 9284 | |
| 9285 | * --------------------------------------------------------------------------*/ |
| 9286 | VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx) |
| 9287 | { |
| 9288 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 9289 | |
| 9290 | /* A tight check to make sure reentrancy */ |
| 9291 | if(atomic_xchg(&pHddCtx->isRestartInProgress, 1)) |
| 9292 | { |
| 9293 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 9294 | "%s: WLAN restart is already in progress", __func__); |
| 9295 | |
| 9296 | return VOS_STATUS_E_ALREADY; |
| 9297 | } |
Sameer Thalappil | 0c164f5 | 2013-03-28 15:27:56 -0700 | [diff] [blame] | 9298 | /* Send reset FIQ to WCNSS to invoke SSR. */ |
Madan Mohan Koyyalamudi | e388b34 | 2012-11-08 15:03:16 -0800 | [diff] [blame] | 9299 | #ifdef HAVE_WCNSS_RESET_INTR |
Madan Mohan Koyyalamudi | bb8f017 | 2012-09-28 15:36:06 -0700 | [diff] [blame] | 9300 | wcnss_reset_intr(); |
| 9301 | #endif |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 9302 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9303 | return status; |
| 9304 | } |
| 9305 | |
Sudhir Sattayappa Kohalli | b1d8c3a | 2013-06-18 14:47:20 -0700 | [diff] [blame] | 9306 | /* |
| 9307 | * API to find if there is any STA or P2P-Client is connected |
| 9308 | */ |
| 9309 | VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx) |
| 9310 | { |
| 9311 | return sme_isSta_p2p_clientConnected(pHddCtx->hHal); |
| 9312 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9313 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9314 | //Register the module init/exit functions |
| 9315 | module_init(hdd_module_init); |
| 9316 | module_exit(hdd_module_exit); |
| 9317 | |
| 9318 | MODULE_LICENSE("Dual BSD/GPL"); |
| 9319 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 9320 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 9321 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9322 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 9323 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9324 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9325 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9326 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9327 | |
| 9328 | module_param(enable_dfs_chan_scan, int, |
| 9329 | S_IRUSR | S_IRGRP | S_IROTH); |
| 9330 | |
| 9331 | module_param(enable_11d, int, |
| 9332 | S_IRUSR | S_IRGRP | S_IROTH); |
| 9333 | |
| 9334 | module_param(country_code, charp, |
| 9335 | S_IRUSR | S_IRGRP | S_IROTH); |