Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
Kiet Lam | a7f454d | 2014-07-24 12:04:06 -0700 | [diff] [blame] | 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 26 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 27 | |
| 28 | |
Kiet Lam | a7f454d | 2014-07-24 12:04:06 -0700 | [diff] [blame] | 29 | |
| 30 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 31 | /*======================================================================== |
| 32 | |
| 33 | \file wlan_hdd_main.c |
| 34 | |
| 35 | \brief WLAN Host Device Driver implementation |
| 36 | |
| 37 | Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved. |
| 38 | |
| 39 | Qualcomm Confidential and Proprietary. |
| 40 | |
| 41 | ========================================================================*/ |
| 42 | |
| 43 | /**========================================================================= |
| 44 | |
| 45 | EDIT HISTORY FOR FILE |
| 46 | |
| 47 | |
| 48 | This section contains comments describing changes made to the module. |
| 49 | Notice that changes are listed in reverse chronological order. |
| 50 | |
| 51 | |
| 52 | $Header:$ $DateTime: $ $Author: $ |
| 53 | |
| 54 | |
| 55 | when who what, where, why |
| 56 | -------- --- -------------------------------------------------------- |
| 57 | 04/5/09 Shailender Created module. |
| 58 | 02/24/10 Sudhir.S.Kohalli Added to support param for SoftAP module |
| 59 | 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure |
| 60 | ==========================================================================*/ |
| 61 | |
| 62 | /*-------------------------------------------------------------------------- |
| 63 | Include Files |
| 64 | ------------------------------------------------------------------------*/ |
| 65 | //#include <wlan_qct_driver.h> |
| 66 | #include <wlan_hdd_includes.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 67 | #include <vos_api.h> |
| 68 | #include <vos_sched.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 69 | #include <linux/etherdevice.h> |
| 70 | #include <linux/firmware.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 71 | #ifdef ANI_BUS_TYPE_PLATFORM |
| 72 | #include <linux/wcnss_wlan.h> |
| 73 | #endif //ANI_BUS_TYPE_PLATFORM |
| 74 | #ifdef ANI_BUS_TYPE_PCI |
| 75 | #include "wcnss_wlan.h" |
| 76 | #endif /* ANI_BUS_TYPE_PCI */ |
| 77 | #include <wlan_hdd_tx_rx.h> |
| 78 | #include <palTimer.h> |
| 79 | #include <wniApi.h> |
| 80 | #include <wlan_nlink_srv.h> |
| 81 | #include <wlan_btc_svc.h> |
| 82 | #include <wlan_hdd_cfg.h> |
| 83 | #include <wlan_ptt_sock_svc.h> |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 84 | #include <wlan_logging_sock_svc.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 85 | #include <wlan_hdd_wowl.h> |
| 86 | #include <wlan_hdd_misc.h> |
| 87 | #include <wlan_hdd_wext.h> |
| 88 | #ifdef WLAN_BTAMP_FEATURE |
| 89 | #include <bap_hdd_main.h> |
| 90 | #include <bapInternal.h> |
| 91 | #endif // WLAN_BTAMP_FEATURE |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 92 | #include "wlan_hdd_trace.h" |
| 93 | #include "vos_types.h" |
| 94 | #include "vos_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 95 | #include <linux/wireless.h> |
| 96 | #include <net/cfg80211.h> |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 97 | #include <linux/inetdevice.h> |
| 98 | #include <net/addrconf.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 99 | #include "wlan_hdd_cfg80211.h" |
| 100 | #include "wlan_hdd_p2p.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 101 | #include <linux/rtnetlink.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 102 | int wlan_hdd_ftm_start(hdd_context_t *pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 103 | #include "sapApi.h" |
| 104 | #include <linux/semaphore.h> |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 105 | #include <linux/ctype.h> |
Arun Kumar Khandavalli | 74fe303 | 2014-03-17 20:35:34 +0530 | [diff] [blame] | 106 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) |
| 107 | #include <soc/qcom/subsystem_restart.h> |
| 108 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 109 | #include <mach/subsystem_restart.h> |
Arun Kumar Khandavalli | 74fe303 | 2014-03-17 20:35:34 +0530 | [diff] [blame] | 110 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 111 | #include <wlan_hdd_hostapd.h> |
| 112 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 113 | #include "cfgApi.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 114 | #include "wlan_hdd_dev_pwr.h" |
| 115 | #ifdef WLAN_BTAMP_FEATURE |
| 116 | #include "bap_hdd_misc.h" |
| 117 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 118 | #include "wlan_qct_pal_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 119 | #include "qwlan_version.h" |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 120 | #include "wlan_qct_wda.h" |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 121 | #ifdef FEATURE_WLAN_TDLS |
| 122 | #include "wlan_hdd_tdls.h" |
| 123 | #endif |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 124 | #include "wlan_hdd_debugfs.h" |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 125 | #include "sapInternal.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 126 | |
| 127 | #ifdef MODULE |
| 128 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 129 | #else |
| 130 | #define WLAN_MODULE_NAME "wlan" |
| 131 | #endif |
| 132 | |
| 133 | #ifdef TIMER_MANAGER |
| 134 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 135 | #else |
| 136 | #define TIMER_MANAGER_STR "" |
| 137 | #endif |
| 138 | |
| 139 | #ifdef MEMORY_DEBUG |
| 140 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 141 | #else |
| 142 | #define MEMORY_DEBUG_STR "" |
| 143 | #endif |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 144 | #define MAX_WAIT_FOR_ROC_COMPLETION 3 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 145 | /* the Android framework expects this param even though we don't use it */ |
| 146 | #define BUF_LEN 20 |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 147 | static char fwpath_buffer[BUF_LEN]; |
| 148 | static struct kparam_string fwpath = { |
| 149 | .string = fwpath_buffer, |
| 150 | .maxlen = BUF_LEN, |
| 151 | }; |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 152 | |
| 153 | static char *country_code; |
| 154 | static int enable_11d = -1; |
| 155 | static int enable_dfs_chan_scan = -1; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 156 | static int gbcnMissRate = -1; |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 157 | |
Madan Mohan Koyyalamudi | 05f313c | 2012-09-18 19:19:15 -0700 | [diff] [blame] | 158 | #ifndef MODULE |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 159 | static int wlan_hdd_inited; |
Madan Mohan Koyyalamudi | 05f313c | 2012-09-18 19:19:15 -0700 | [diff] [blame] | 160 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 161 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 162 | /* |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 163 | * spinlock for synchronizing asynchronous request/response |
| 164 | * (full description of use in wlan_hdd_main.h) |
| 165 | */ |
| 166 | DEFINE_SPINLOCK(hdd_context_lock); |
| 167 | |
| 168 | /* |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 169 | * The rate at which the driver sends RESTART event to supplicant |
| 170 | * once the function 'vos_wlanRestart()' is called |
| 171 | * |
| 172 | */ |
| 173 | #define WLAN_HDD_RESTART_RETRY_DELAY_MS 5000 /* 5 second */ |
| 174 | #define WLAN_HDD_RESTART_RETRY_MAX_CNT 5 /* 5 retries */ |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 175 | |
| 176 | /* |
| 177 | * Size of Driver command strings from upper layer |
| 178 | */ |
| 179 | #define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */ |
| 180 | #define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */ |
| 181 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 182 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 183 | #define TID_MIN_VALUE 0 |
| 184 | #define TID_MAX_VALUE 15 |
| 185 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 186 | tAniTrafStrmMetrics* pTsmMetrics); |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 187 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 188 | tCsrEseBeaconReq *pEseBcnReq); |
| 189 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 190 | |
Atul Mittal | 1d72242 | 2014-03-19 11:15:07 +0530 | [diff] [blame] | 191 | /* |
| 192 | * Maximum buffer size used for returning the data back to user space |
| 193 | */ |
| 194 | #define WLAN_MAX_BUF_SIZE 1024 |
| 195 | #define WLAN_PRIV_DATA_MAX_LEN 8192 |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 196 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 197 | //wait time for beacon miss rate. |
| 198 | #define BCN_MISS_RATE_TIME 500 |
| 199 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 200 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 201 | static struct wake_lock wlan_wake_lock; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 202 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 203 | /* set when SSR is needed after unload */ |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 204 | static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 205 | |
| 206 | //internal function declaration |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 207 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx); |
| 208 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx); |
| 209 | static void wlan_hdd_restart_deinit(hdd_context_t *pHddCtx); |
| 210 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 211 | void hdd_set_wlan_suspend_mode(bool suspend); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 212 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 213 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 214 | struct sk_buff *skb); |
| 215 | |
| 216 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 217 | static void hdd_set_multicast_list(struct net_device *dev); |
| 218 | #endif |
| 219 | |
| 220 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter); |
| 221 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 222 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 223 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand); |
| 224 | 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] | 225 | static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, |
| 226 | tANI_U8 *pChannel, tANI_U8 *pDwellTime, |
| 227 | tANI_U8 **pBuf, tANI_U8 *pBufLen); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 228 | static VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 229 | tANI_U8 *pTargetApBssid, |
| 230 | tANI_U8 *pChannel); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 231 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 232 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 233 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, tANI_U8 *pCckmIeLen); |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 234 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 235 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 236 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 237 | const char * hdd_device_modetoString(v_U8_t device_mode) |
| 238 | { |
| 239 | switch(device_mode) |
| 240 | { |
| 241 | CASE_RETURN_STRING( WLAN_HDD_INFRA_STATION ); |
| 242 | CASE_RETURN_STRING( WLAN_HDD_SOFTAP ); |
| 243 | CASE_RETURN_STRING( WLAN_HDD_P2P_CLIENT ); |
| 244 | CASE_RETURN_STRING( WLAN_HDD_P2P_GO ); |
| 245 | CASE_RETURN_STRING( WLAN_HDD_MONITOR); |
| 246 | CASE_RETURN_STRING( WLAN_HDD_FTM ); |
| 247 | CASE_RETURN_STRING( WLAN_HDD_IBSS ); |
| 248 | CASE_RETURN_STRING( WLAN_HDD_P2P_DEVICE ); |
| 249 | default: |
| 250 | return "device_mode Unknown"; |
| 251 | } |
| 252 | } |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 253 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 254 | static int hdd_netdev_notifier_call(struct notifier_block * nb, |
| 255 | unsigned long state, |
| 256 | void *ndev) |
| 257 | { |
| 258 | struct net_device *dev = ndev; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 259 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 260 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 261 | #ifdef WLAN_BTAMP_FEATURE |
| 262 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 263 | #endif |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 264 | long result; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 265 | |
| 266 | //Make sure that this callback corresponds to our device. |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 267 | if ((strncmp(dev->name, "wlan", 4)) && |
Amar Singhal | 4c723bd | 2013-03-25 18:14:15 -0700 | [diff] [blame] | 268 | (strncmp(dev->name, "p2p", 3))) |
| 269 | return NOTIFY_DONE; |
| 270 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 271 | if (!dev->ieee80211_ptr) |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 272 | return NOTIFY_DONE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 273 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 274 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 275 | { |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 276 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 277 | VOS_ASSERT(0); |
| 278 | return NOTIFY_DONE; |
| 279 | } |
| 280 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 281 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 282 | if (NULL == pHddCtx) |
| 283 | { |
| 284 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__); |
| 285 | VOS_ASSERT(0); |
| 286 | return NOTIFY_DONE; |
| 287 | } |
Sameer Thalappil | 1406797 | 2014-01-23 14:54:54 -0800 | [diff] [blame] | 288 | if (pHddCtx->isLogpInProgress) |
| 289 | return NOTIFY_DONE; |
| 290 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 291 | |
| 292 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu", |
| 293 | __func__, dev->name, state); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 294 | |
| 295 | switch (state) { |
| 296 | case NETDEV_REGISTER: |
| 297 | break; |
| 298 | |
| 299 | case NETDEV_UNREGISTER: |
| 300 | break; |
| 301 | |
| 302 | case NETDEV_UP: |
| 303 | break; |
| 304 | |
| 305 | case NETDEV_DOWN: |
| 306 | break; |
| 307 | |
| 308 | case NETDEV_CHANGE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 309 | if(TRUE == pAdapter->isLinkUpSvcNeeded) |
| 310 | complete(&pAdapter->linkup_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | break; |
| 312 | |
| 313 | case NETDEV_GOING_DOWN: |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 314 | result = wlan_hdd_scan_abort(pAdapter); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 315 | if (result < 0) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 316 | { |
| 317 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 318 | "%s: Timeout occurred while waiting for abortscan %ld", |
| 319 | __func__, result); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 320 | } |
| 321 | else |
| 322 | { |
| 323 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 324 | "%s: Scan Abort Successful" , __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 325 | } |
| 326 | #ifdef WLAN_BTAMP_FEATURE |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 327 | 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] | 328 | status = WLANBAP_StopAmp(); |
| 329 | if(VOS_STATUS_SUCCESS != status ) |
| 330 | { |
| 331 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 332 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 333 | "%s: Failed to stop AMP", __func__); |
| 334 | } |
| 335 | else |
| 336 | { |
| 337 | //a state m/c implementation in PAL is TBD to avoid this delay |
| 338 | msleep(500); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 339 | if ( pHddCtx->isAmpAllowed ) |
| 340 | { |
| 341 | WLANBAP_DeregisterFromHCI(); |
| 342 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 343 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 344 | } |
| 345 | #endif //WLAN_BTAMP_FEATURE |
| 346 | break; |
| 347 | |
| 348 | default: |
| 349 | break; |
| 350 | } |
| 351 | |
| 352 | return NOTIFY_DONE; |
| 353 | } |
| 354 | |
| 355 | struct notifier_block hdd_netdev_notifier = { |
| 356 | .notifier_call = hdd_netdev_notifier_call, |
| 357 | }; |
| 358 | |
| 359 | /*--------------------------------------------------------------------------- |
| 360 | * Function definitions |
| 361 | *-------------------------------------------------------------------------*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 362 | void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx); |
| 363 | void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 364 | //variable to hold the insmod parameters |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 365 | static int con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 366 | #ifndef MODULE |
| 367 | /* current con_mode - used only for statically linked driver |
| 368 | * con_mode is changed by userspace to indicate a mode change which will |
| 369 | * result in calling the module exit and init functions. The module |
| 370 | * exit function will clean up based on the value of con_mode prior to it |
| 371 | * being changed by userspace. So curr_con_mode records the current con_mode |
| 372 | * for exit when con_mode becomes the next mode for init |
| 373 | */ |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 374 | static int curr_con_mode; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 375 | #endif |
| 376 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 377 | /**--------------------------------------------------------------------------- |
| 378 | |
| 379 | \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable |
| 380 | |
| 381 | Called immediately after the cfg.ini is read in order to configure |
| 382 | the desired trace levels. |
| 383 | |
| 384 | \param - moduleId - module whose trace level is being configured |
| 385 | \param - bitmask - bitmask of log levels to be enabled |
| 386 | |
| 387 | \return - void |
| 388 | |
| 389 | --------------------------------------------------------------------------*/ |
| 390 | static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask) |
| 391 | { |
| 392 | wpt_tracelevel level; |
| 393 | |
| 394 | /* if the bitmask is the default value, then a bitmask was not |
| 395 | specified in cfg.ini, so leave the logging level alone (it |
| 396 | will remain at the "compiled in" default value) */ |
| 397 | if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask) |
| 398 | { |
| 399 | return; |
| 400 | } |
| 401 | |
| 402 | /* a mask was specified. start by disabling all logging */ |
| 403 | vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0); |
| 404 | |
| 405 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 406 | level = VOS_TRACE_LEVEL_FATAL; |
| 407 | while (0 != bitmask) |
| 408 | { |
| 409 | if (bitmask & 1) |
| 410 | { |
| 411 | vos_trace_setValue(moduleId, level, 1); |
| 412 | } |
| 413 | level++; |
| 414 | bitmask >>= 1; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 419 | /**--------------------------------------------------------------------------- |
| 420 | |
| 421 | \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable |
| 422 | |
| 423 | Called immediately after the cfg.ini is read in order to configure |
| 424 | the desired trace levels in the WDI. |
| 425 | |
| 426 | \param - moduleId - module whose trace level is being configured |
| 427 | \param - bitmask - bitmask of log levels to be enabled |
| 428 | |
| 429 | \return - void |
| 430 | |
| 431 | --------------------------------------------------------------------------*/ |
| 432 | static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask) |
| 433 | { |
| 434 | wpt_tracelevel level; |
| 435 | |
| 436 | /* if the bitmask is the default value, then a bitmask was not |
| 437 | specified in cfg.ini, so leave the logging level alone (it |
| 438 | will remain at the "compiled in" default value) */ |
| 439 | if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask) |
| 440 | { |
| 441 | return; |
| 442 | } |
| 443 | |
| 444 | /* a mask was specified. start by disabling all logging */ |
| 445 | wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0); |
| 446 | |
| 447 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 448 | level = eWLAN_PAL_TRACE_LEVEL_FATAL; |
| 449 | while (0 != bitmask) |
| 450 | { |
| 451 | if (bitmask & 1) |
| 452 | { |
| 453 | wpalTraceSetLevel(moduleId, level, 1); |
| 454 | } |
| 455 | level++; |
| 456 | bitmask >>= 1; |
| 457 | } |
| 458 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 459 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 460 | /* |
| 461 | * FUNCTION: wlan_hdd_validate_context |
| 462 | * This function is used to check the HDD context |
| 463 | */ |
| 464 | int wlan_hdd_validate_context(hdd_context_t *pHddCtx) |
| 465 | { |
| 466 | ENTER(); |
| 467 | |
| 468 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
| 469 | { |
| 470 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 471 | "%s: HDD context is Null", __func__); |
| 472 | return -ENODEV; |
| 473 | } |
| 474 | |
| 475 | if (pHddCtx->isLogpInProgress) |
| 476 | { |
| 477 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 478 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 479 | return -EAGAIN; |
| 480 | } |
| 481 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 482 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 483 | { |
| 484 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 485 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 486 | return -EAGAIN; |
| 487 | } |
| 488 | return 0; |
| 489 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 490 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 491 | void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx) |
| 492 | { |
| 493 | hdd_adapter_t *pAdapter = NULL; |
| 494 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 495 | eCsrPhyMode phyMode; |
| 496 | hdd_config_t *cfg_param = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 497 | |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 498 | if (NULL == pHddCtx) |
| 499 | { |
| 500 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 501 | "HDD Context is null !!"); |
| 502 | return ; |
| 503 | } |
| 504 | |
| 505 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 506 | if (NULL == pAdapter) |
| 507 | { |
| 508 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 509 | "pAdapter is null !!"); |
| 510 | return ; |
| 511 | } |
| 512 | |
| 513 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 514 | if (NULL == pHddStaCtx) |
| 515 | { |
| 516 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 517 | "pHddStaCtx is null !!"); |
| 518 | return ; |
| 519 | } |
| 520 | |
| 521 | cfg_param = pHddCtx->cfg_ini; |
| 522 | if (NULL == cfg_param) |
| 523 | { |
| 524 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 525 | "cfg_params not available !!"); |
| 526 | return ; |
| 527 | } |
| 528 | |
| 529 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 530 | |
| 531 | if (!pHddCtx->isVHT80Allowed) |
| 532 | { |
| 533 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 534 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 535 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 536 | { |
| 537 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 538 | "Setting phymode to 11n!!"); |
| 539 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 540 | } |
| 541 | } |
| 542 | else |
| 543 | { |
| 544 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 545 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 546 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 547 | return ; |
| 548 | } |
| 549 | |
| 550 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 551 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 552 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 553 | { |
| 554 | VOS_STATUS vosStatus; |
| 555 | |
| 556 | // need to issue a disconnect to CSR. |
| 557 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 558 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 559 | pAdapter->sessionId, |
| 560 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 561 | |
| 562 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 563 | { |
| 564 | long ret; |
| 565 | |
| 566 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 567 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 568 | if (0 >= ret) |
| 569 | hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"), |
| 570 | ret); |
| 571 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 572 | |
| 573 | } |
| 574 | } |
| 575 | #else |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 576 | void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code) |
| 577 | { |
| 578 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 579 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 580 | hdd_config_t *cfg_param; |
| 581 | eCsrPhyMode phyMode; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 582 | long ret; |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 583 | |
| 584 | if (NULL == pHddCtx) |
| 585 | { |
| 586 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 587 | "HDD Context is null !!"); |
| 588 | return ; |
| 589 | } |
| 590 | |
| 591 | cfg_param = pHddCtx->cfg_ini; |
| 592 | |
| 593 | if (NULL == cfg_param) |
| 594 | { |
| 595 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 596 | "cfg_params not available !!"); |
| 597 | return ; |
| 598 | } |
| 599 | |
| 600 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 601 | |
| 602 | if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code)) |
| 603 | { |
| 604 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 605 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 606 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 607 | { |
| 608 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 609 | "Setting phymode to 11n!!"); |
| 610 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 611 | } |
| 612 | } |
| 613 | else |
| 614 | { |
| 615 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 616 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 617 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 618 | return ; |
| 619 | } |
| 620 | |
| 621 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 622 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 623 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 624 | { |
| 625 | VOS_STATUS vosStatus; |
| 626 | |
| 627 | // need to issue a disconnect to CSR. |
| 628 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 629 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 630 | pAdapter->sessionId, |
| 631 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 632 | |
| 633 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 634 | { |
| 635 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 636 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 637 | if (ret <= 0) |
| 638 | { |
| 639 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 640 | "wait on disconnect_comp_var is failed %ld", ret); |
| 641 | } |
| 642 | } |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 643 | |
| 644 | } |
| 645 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 646 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 647 | |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 648 | void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code) |
| 649 | { |
| 650 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 651 | hdd_config_t *cfg_param; |
| 652 | |
| 653 | if (NULL == pHddCtx) |
| 654 | { |
| 655 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 656 | "HDD Context is null !!"); |
| 657 | return ; |
| 658 | } |
| 659 | |
| 660 | cfg_param = pHddCtx->cfg_ini; |
| 661 | |
| 662 | if (NULL == cfg_param) |
| 663 | { |
| 664 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 665 | "cfg_params not available !!"); |
| 666 | return ; |
| 667 | } |
| 668 | |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 669 | if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code) || |
| 670 | pHddCtx->disable_dfs_flag == TRUE) |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 671 | { |
| 672 | /*New country doesn't support DFS */ |
| 673 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
| 674 | } |
| 675 | else |
| 676 | { |
| 677 | /*New country Supports DFS as well resetting value back from .ini*/ |
| 678 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan); |
| 679 | } |
| 680 | |
| 681 | } |
| 682 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 683 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 684 | |
| 685 | /**--------------------------------------------------------------------------- |
| 686 | |
| 687 | \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from |
| 688 | input string |
| 689 | |
| 690 | This function extracts assigned integer from string in below format: |
| 691 | "STRING=10" : extracts integer 10 from this string |
| 692 | |
| 693 | \param - pInPtr Pointer to input string |
| 694 | \param - base Base for string to int conversion(10 for decimal 16 for hex) |
| 695 | \param - pOutPtr Pointer to variable in which extracted integer needs to be |
| 696 | assigned |
| 697 | \param - pLastArg to tell whether it is last arguement in input string or |
| 698 | not |
| 699 | |
| 700 | \return - NULL for failure cases |
| 701 | pointer to next arguement in input string for success cases |
| 702 | --------------------------------------------------------------------------*/ |
| 703 | static tANI_U8 * |
| 704 | hdd_extract_assigned_int_from_str |
| 705 | ( |
| 706 | tANI_U8 *pInPtr, |
| 707 | tANI_U8 base, |
| 708 | tANI_U32 *pOutPtr, |
| 709 | tANI_U8 *pLastArg |
| 710 | ) |
| 711 | { |
| 712 | int tempInt; |
| 713 | int v = 0; |
| 714 | char buf[32]; |
| 715 | int val = 0; |
| 716 | *pLastArg = FALSE; |
| 717 | |
| 718 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 719 | if (NULL == pInPtr) |
| 720 | { |
| 721 | return NULL; |
| 722 | } |
| 723 | |
| 724 | pInPtr++; |
| 725 | |
| 726 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 727 | |
| 728 | val = sscanf(pInPtr, "%32s ", buf); |
| 729 | if (val < 0 && val > strlen(pInPtr)) |
| 730 | { |
| 731 | return NULL; |
| 732 | } |
| 733 | pInPtr += val; |
| 734 | v = kstrtos32(buf, base, &tempInt); |
| 735 | if (v < 0) |
| 736 | { |
| 737 | return NULL; |
| 738 | } |
Rajeev Kumar | 4d93d84 | 2014-01-02 18:31:21 -0800 | [diff] [blame] | 739 | if (tempInt < 0) |
| 740 | { |
| 741 | tempInt = 0; |
| 742 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 743 | *pOutPtr = tempInt; |
| 744 | |
| 745 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 746 | if (NULL == pInPtr) |
| 747 | { |
| 748 | *pLastArg = TRUE; |
| 749 | return NULL; |
| 750 | } |
| 751 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 752 | |
| 753 | return pInPtr; |
| 754 | } |
| 755 | |
| 756 | /**--------------------------------------------------------------------------- |
| 757 | |
| 758 | \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from |
| 759 | input string |
| 760 | |
| 761 | This function extracts assigned character from string in below format: |
| 762 | "STRING=A" : extracts char 'A' from this string |
| 763 | |
| 764 | \param - pInPtr Pointer to input string |
| 765 | \param - pOutPtr Pointer to variable in which extracted char needs to be |
| 766 | assigned |
| 767 | \param - pLastArg to tell whether it is last arguement in input string or |
| 768 | not |
| 769 | |
| 770 | \return - NULL for failure cases |
| 771 | pointer to next arguement in input string for success cases |
| 772 | --------------------------------------------------------------------------*/ |
| 773 | static tANI_U8 * |
| 774 | hdd_extract_assigned_char_from_str |
| 775 | ( |
| 776 | tANI_U8 *pInPtr, |
| 777 | tANI_U8 *pOutPtr, |
| 778 | tANI_U8 *pLastArg |
| 779 | ) |
| 780 | { |
| 781 | *pLastArg = FALSE; |
| 782 | |
| 783 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 784 | if (NULL == pInPtr) |
| 785 | { |
| 786 | return NULL; |
| 787 | } |
| 788 | |
| 789 | pInPtr++; |
| 790 | |
| 791 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 792 | |
| 793 | *pOutPtr = *pInPtr; |
| 794 | |
| 795 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 796 | if (NULL == pInPtr) |
| 797 | { |
| 798 | *pLastArg = TRUE; |
| 799 | return NULL; |
| 800 | } |
| 801 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 802 | |
| 803 | return pInPtr; |
| 804 | } |
| 805 | |
| 806 | |
| 807 | /**--------------------------------------------------------------------------- |
| 808 | |
| 809 | \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command |
| 810 | |
| 811 | This function parses set batch scan command in below format: |
| 812 | WLS_BATCHING_SET <space> followed by below arguements |
| 813 | "SCANFREQ=XX" : Optional defaults to 30 sec |
| 814 | "MSCAN=XX" : Required number of scans to attempt to batch |
| 815 | "BESTN=XX" : Best Network (RSSI) defaults to 16 |
| 816 | "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B. |
| 817 | A. implies only 5 GHz , B. implies only 2.4GHz |
| 818 | "RTT=X" : optional defaults to 0 |
| 819 | returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on |
| 820 | error |
| 821 | |
| 822 | For example input commands: |
| 823 | 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is |
| 824 | translated into set batch scan with following parameters: |
| 825 | a) Frequence 60 seconds |
| 826 | b) Batch 10 scans together |
| 827 | c) Best RSSI to be 20 |
| 828 | d) 5GHz band only |
| 829 | e) RTT is equal to 0 |
| 830 | |
| 831 | \param - pValue Pointer to input channel list |
| 832 | \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure |
| 833 | |
| 834 | \return - 0 for success non-zero for failure |
| 835 | |
| 836 | --------------------------------------------------------------------------*/ |
| 837 | static int |
| 838 | hdd_parse_set_batchscan_command |
| 839 | ( |
| 840 | tANI_U8 *pValue, |
| 841 | tSirSetBatchScanReq *pHddSetBatchScanReq |
| 842 | ) |
| 843 | { |
| 844 | tANI_U8 *inPtr = pValue; |
| 845 | tANI_U8 val = 0; |
| 846 | tANI_U8 lastArg = 0; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 847 | tANI_U32 nScanFreq; |
| 848 | tANI_U32 nMscan; |
| 849 | tANI_U32 nBestN; |
| 850 | tANI_U8 ucRfBand; |
| 851 | tANI_U32 nRtt; |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 852 | tANI_U32 temp; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 853 | |
| 854 | /*initialize default values*/ |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 855 | nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ; |
| 856 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 857 | nRtt = 0; |
| 858 | nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 859 | |
| 860 | /*go to space after WLS_BATCHING_SET command*/ |
| 861 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 862 | /*no argument after the command*/ |
| 863 | if (NULL == inPtr) |
| 864 | { |
| 865 | return -EINVAL; |
| 866 | } |
| 867 | |
| 868 | /*no space after the command*/ |
| 869 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 870 | { |
| 871 | return -EINVAL; |
| 872 | } |
| 873 | |
| 874 | /*removing empty spaces*/ |
| 875 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 876 | |
| 877 | /*no argument followed by spaces*/ |
| 878 | if ('\0' == *inPtr) |
| 879 | { |
| 880 | return -EINVAL; |
| 881 | } |
| 882 | |
| 883 | /*check and parse SCANFREQ*/ |
| 884 | if ((strncmp(inPtr, "SCANFREQ", 8) == 0)) |
| 885 | { |
| 886 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 887 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 888 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 889 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 890 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 891 | nScanFreq = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 892 | } |
| 893 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 894 | if ( (NULL == inPtr) || (TRUE == lastArg)) |
| 895 | { |
| 896 | return -EINVAL; |
| 897 | } |
| 898 | } |
| 899 | |
| 900 | /*check and parse MSCAN*/ |
| 901 | if ((strncmp(inPtr, "MSCAN", 5) == 0)) |
| 902 | { |
| 903 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 904 | &nMscan, &lastArg); |
| 905 | |
| 906 | if (0 == nMscan) |
| 907 | { |
| 908 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 909 | "invalid MSCAN=%d", nMscan); |
| 910 | return -EINVAL; |
| 911 | } |
| 912 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 913 | if (TRUE == lastArg) |
| 914 | { |
| 915 | goto done; |
| 916 | } |
| 917 | else if (NULL == inPtr) |
| 918 | { |
| 919 | return -EINVAL; |
| 920 | } |
| 921 | } |
| 922 | else |
| 923 | { |
| 924 | return -EINVAL; |
| 925 | } |
| 926 | |
| 927 | /*check and parse BESTN*/ |
| 928 | if ((strncmp(inPtr, "BESTN", 5) == 0)) |
| 929 | { |
| 930 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 931 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 932 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 933 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 934 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 935 | nBestN = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 936 | } |
| 937 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 938 | if (TRUE == lastArg) |
| 939 | { |
| 940 | goto done; |
| 941 | } |
| 942 | else if (NULL == inPtr) |
| 943 | { |
| 944 | return -EINVAL; |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | /*check and parse CHANNEL*/ |
| 949 | if ((strncmp(inPtr, "CHANNEL", 7) == 0)) |
| 950 | { |
| 951 | inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg); |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 952 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 953 | if (('A' == val) || ('a' == val)) |
| 954 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 955 | ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 956 | } |
| 957 | else if (('B' == val) || ('b' == val)) |
| 958 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 959 | ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 960 | } |
| 961 | else |
| 962 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 963 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 964 | } |
| 965 | |
| 966 | if (TRUE == lastArg) |
| 967 | { |
| 968 | goto done; |
| 969 | } |
| 970 | else if (NULL == inPtr) |
| 971 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 972 | return -EINVAL; |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | /*check and parse RTT*/ |
| 977 | if ((strncmp(inPtr, "RTT", 3) == 0)) |
| 978 | { |
| 979 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 980 | &nRtt, &lastArg); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 981 | if (TRUE == lastArg) |
| 982 | { |
| 983 | goto done; |
| 984 | } |
| 985 | if (NULL == inPtr) |
| 986 | { |
| 987 | return -EINVAL; |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | |
| 992 | done: |
| 993 | |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 994 | pHddSetBatchScanReq->scanFrequency = nScanFreq; |
| 995 | pHddSetBatchScanReq->numberOfScansToBatch = nMscan; |
| 996 | pHddSetBatchScanReq->bestNetwork = nBestN; |
| 997 | pHddSetBatchScanReq->rfBand = ucRfBand; |
| 998 | pHddSetBatchScanReq->rtt = nRtt; |
| 999 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1000 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1001 | "Received WLS_BATCHING_SET with SCANFREQ=%d " |
| 1002 | "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d", |
| 1003 | pHddSetBatchScanReq->scanFrequency, |
| 1004 | pHddSetBatchScanReq->numberOfScansToBatch, |
| 1005 | pHddSetBatchScanReq->bestNetwork, |
| 1006 | pHddSetBatchScanReq->rfBand, |
| 1007 | pHddSetBatchScanReq->rtt); |
| 1008 | |
| 1009 | return 0; |
| 1010 | }/*End of hdd_parse_set_batchscan_command*/ |
| 1011 | |
| 1012 | /**--------------------------------------------------------------------------- |
| 1013 | |
| 1014 | \brief hdd_set_batch_scan_req_callback () - This function is called after |
| 1015 | receiving set batch scan response from FW and it saves set batch scan |
| 1016 | response data FW to HDD context and sets the completion event on |
| 1017 | which hdd_ioctl is waiting |
| 1018 | |
| 1019 | \param - callbackContext Pointer to HDD adapter |
| 1020 | \param - pRsp Pointer to set batch scan response data received from FW |
| 1021 | |
| 1022 | \return - nothing |
| 1023 | |
| 1024 | --------------------------------------------------------------------------*/ |
| 1025 | static void hdd_set_batch_scan_req_callback |
| 1026 | ( |
| 1027 | void *callbackContext, |
| 1028 | tSirSetBatchScanRsp *pRsp |
| 1029 | ) |
| 1030 | { |
| 1031 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 1032 | tSirSetBatchScanRsp *pHddSetBatchScanRsp; |
| 1033 | |
| 1034 | /*sanity check*/ |
| 1035 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 1036 | { |
| 1037 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1038 | "%s: Invalid pAdapter magic", __func__); |
| 1039 | VOS_ASSERT(0); |
| 1040 | return; |
| 1041 | } |
| 1042 | pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp; |
| 1043 | |
| 1044 | /*save set batch scan response*/ |
| 1045 | pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch; |
| 1046 | |
| 1047 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1048 | "Received set batch scan rsp from FW with nScansToBatch=%d", |
| 1049 | pHddSetBatchScanRsp->nScansToBatch); |
| 1050 | |
| 1051 | pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE; |
| 1052 | complete(&pAdapter->hdd_set_batch_scan_req_var); |
| 1053 | |
| 1054 | return; |
| 1055 | }/*End of hdd_set_batch_scan_req_callback*/ |
| 1056 | |
| 1057 | |
| 1058 | /**--------------------------------------------------------------------------- |
| 1059 | |
| 1060 | \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta |
| 1061 | info in hdd batch scan response queue |
| 1062 | |
| 1063 | \param - pAdapter Pointer to hdd adapter |
| 1064 | \param - pAPMetaInfo Pointer to access point meta info |
| 1065 | \param - scanId scan ID of batch scan response |
| 1066 | \param - isLastAp tells whether AP is last AP in batch scan response or not |
| 1067 | |
| 1068 | \return - nothing |
| 1069 | |
| 1070 | --------------------------------------------------------------------------*/ |
| 1071 | static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter, |
| 1072 | tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp) |
| 1073 | { |
| 1074 | tHddBatchScanRsp *pHead; |
| 1075 | tHddBatchScanRsp *pNode; |
| 1076 | tHddBatchScanRsp *pPrev; |
| 1077 | tHddBatchScanRsp *pTemp; |
| 1078 | tANI_U8 ssidLen; |
| 1079 | |
| 1080 | /*head of hdd batch scan response queue*/ |
| 1081 | pHead = pAdapter->pBatchScanRsp; |
| 1082 | |
| 1083 | pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp)); |
| 1084 | if (NULL == pNode) |
| 1085 | { |
| 1086 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1087 | "%s: Could not allocate memory", __func__); |
| 1088 | VOS_ASSERT(0); |
| 1089 | return; |
| 1090 | } |
| 1091 | |
| 1092 | vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid, |
| 1093 | sizeof(pNode->ApInfo.bssid)); |
| 1094 | ssidLen = strlen(pApMetaInfo->ssid); |
| 1095 | if (SIR_MAX_SSID_SIZE < ssidLen) |
| 1096 | { |
| 1097 | /*invalid scan result*/ |
| 1098 | vos_mem_free(pNode); |
| 1099 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1100 | "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen); |
| 1101 | return; |
| 1102 | } |
| 1103 | vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen); |
| 1104 | /*null terminate ssid*/ |
| 1105 | pNode->ApInfo.ssid[ssidLen] = '\0'; |
| 1106 | pNode->ApInfo.ch = pApMetaInfo->ch; |
| 1107 | pNode->ApInfo.rssi = pApMetaInfo->rssi; |
| 1108 | pNode->ApInfo.age = pApMetaInfo->timestamp; |
| 1109 | pNode->ApInfo.batchId = scanId; |
| 1110 | pNode->ApInfo.isLastAp = isLastAp; |
| 1111 | |
| 1112 | pNode->pNext = NULL; |
| 1113 | if (NULL == pHead) |
| 1114 | { |
| 1115 | pAdapter->pBatchScanRsp = pNode; |
| 1116 | } |
| 1117 | else |
| 1118 | { |
| 1119 | pTemp = pHead; |
| 1120 | while (NULL != pTemp) |
| 1121 | { |
| 1122 | pPrev = pTemp; |
| 1123 | pTemp = pTemp->pNext; |
| 1124 | } |
| 1125 | pPrev->pNext = pNode; |
| 1126 | } |
| 1127 | |
| 1128 | return; |
| 1129 | }/*End of hdd_populate_batch_scan_rsp_queue*/ |
| 1130 | |
| 1131 | /**--------------------------------------------------------------------------- |
| 1132 | |
| 1133 | \brief hdd_batch_scan_result_ind_callback () - This function is called after |
| 1134 | receiving batch scan response indication from FW. It saves get batch scan |
| 1135 | response data in HDD batch scan response queue. This callback sets the |
| 1136 | completion event on which hdd_ioctl is waiting only after getting complete |
| 1137 | batch scan response data from FW |
| 1138 | |
| 1139 | \param - callbackContext Pointer to HDD adapter |
| 1140 | \param - pRsp Pointer to get batch scan response data received from FW |
| 1141 | |
| 1142 | \return - nothing |
| 1143 | |
| 1144 | --------------------------------------------------------------------------*/ |
| 1145 | static void hdd_batch_scan_result_ind_callback |
| 1146 | ( |
| 1147 | void *callbackContext, |
| 1148 | void *pRsp |
| 1149 | ) |
| 1150 | { |
| 1151 | v_BOOL_t isLastAp; |
| 1152 | tANI_U32 numApMetaInfo; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1153 | tANI_U32 numNetworkInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1154 | tANI_U32 numberScanList; |
| 1155 | tANI_U32 nextScanListOffset; |
| 1156 | tANI_U32 nextApMetaInfoOffset; |
| 1157 | hdd_adapter_t* pAdapter; |
| 1158 | tpSirBatchScanList pScanList; |
| 1159 | tpSirBatchScanNetworkInfo pApMetaInfo; |
| 1160 | tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/ |
| 1161 | tSirSetBatchScanReq *pReq; |
| 1162 | |
| 1163 | pAdapter = (hdd_adapter_t *)callbackContext; |
| 1164 | /*sanity check*/ |
Rajeev Kumar | 5286bb9 | 2013-12-05 11:52:10 -0800 | [diff] [blame] | 1165 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1166 | { |
| 1167 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1168 | "%s: Invalid pAdapter magic", __func__); |
| 1169 | VOS_ASSERT(0); |
| 1170 | return; |
| 1171 | } |
| 1172 | |
| 1173 | /*initialize locals*/ |
| 1174 | pReq = &pAdapter->hddSetBatchScanReq; |
| 1175 | pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp; |
| 1176 | isLastAp = FALSE; |
| 1177 | numApMetaInfo = 0; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1178 | numNetworkInScanList = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1179 | numberScanList = 0; |
| 1180 | nextScanListOffset = 0; |
| 1181 | nextApMetaInfoOffset = 0; |
| 1182 | pScanList = NULL; |
| 1183 | pApMetaInfo = NULL; |
| 1184 | |
| 1185 | if ((NULL == pBatchScanRsp) || (NULL == pReq)) |
| 1186 | { |
| 1187 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1188 | "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq); |
| 1189 | isLastAp = TRUE; |
| 1190 | goto done; |
| 1191 | } |
| 1192 | |
| 1193 | pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists; |
| 1194 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1195 | "Batch scan rsp: numberScalList %d", numberScanList); |
| 1196 | |
| 1197 | if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch)) |
| 1198 | { |
| 1199 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1200 | "%s: numberScanList %d", __func__, numberScanList); |
| 1201 | isLastAp = TRUE; |
| 1202 | goto done; |
| 1203 | } |
| 1204 | |
| 1205 | while (numberScanList) |
| 1206 | { |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1207 | pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults + |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1208 | nextScanListOffset); |
| 1209 | if (NULL == pScanList) |
| 1210 | { |
| 1211 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1212 | "%s: pScanList is %p", __func__, pScanList); |
| 1213 | isLastAp = TRUE; |
| 1214 | goto done; |
| 1215 | } |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1216 | numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1217 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1218 | "Batch scan rsp: numApMetaInfo %d scanId %d", |
| 1219 | numApMetaInfo, pScanList->scanId); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1220 | |
| 1221 | if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork)) |
| 1222 | { |
| 1223 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1224 | "%s: numApMetaInfo %d", __func__, numApMetaInfo); |
| 1225 | isLastAp = TRUE; |
| 1226 | goto done; |
| 1227 | } |
| 1228 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1229 | /*Initialize next AP meta info offset for next scan list*/ |
| 1230 | nextApMetaInfoOffset = 0; |
| 1231 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1232 | while (numApMetaInfo) |
| 1233 | { |
| 1234 | pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList + |
| 1235 | nextApMetaInfoOffset); |
| 1236 | if (NULL == pApMetaInfo) |
| 1237 | { |
| 1238 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1239 | "%s: pApMetaInfo is %p", __func__, pApMetaInfo); |
| 1240 | isLastAp = TRUE; |
| 1241 | goto done; |
| 1242 | } |
| 1243 | /*calculate AP age*/ |
| 1244 | pApMetaInfo->timestamp = |
| 1245 | pBatchScanRsp->timestamp - pApMetaInfo->timestamp; |
| 1246 | |
| 1247 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1248 | "%s: bssId "MAC_ADDRESS_STR |
| 1249 | " ch %d rssi %d timestamp %d", __func__, |
| 1250 | MAC_ADDR_ARRAY(pApMetaInfo->bssid), |
| 1251 | pApMetaInfo->ch, pApMetaInfo->rssi, |
| 1252 | pApMetaInfo->timestamp); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1253 | |
| 1254 | /*mark last AP in batch scan response*/ |
| 1255 | if ((TRUE == pBatchScanRsp->isLastResult) && |
| 1256 | (1 == numberScanList) && (1 == numApMetaInfo)) |
| 1257 | { |
| 1258 | isLastAp = TRUE; |
| 1259 | } |
| 1260 | |
| 1261 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1262 | /*store batch scan repsonse in hdd queue*/ |
| 1263 | hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo, |
| 1264 | pScanList->scanId, isLastAp); |
| 1265 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1266 | |
| 1267 | nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo); |
| 1268 | numApMetaInfo--; |
| 1269 | } |
| 1270 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1271 | nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8)) |
| 1272 | + (sizeof(tSirBatchScanNetworkInfo) |
| 1273 | * numNetworkInScanList)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1274 | numberScanList--; |
| 1275 | } |
| 1276 | |
| 1277 | done: |
| 1278 | |
| 1279 | /*notify hdd_ioctl only if complete batch scan rsp is received and it was |
| 1280 | requested from hdd_ioctl*/ |
| 1281 | if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) && |
| 1282 | (TRUE == isLastAp)) |
| 1283 | { |
| 1284 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1285 | complete(&pAdapter->hdd_get_batch_scan_req_var); |
| 1286 | } |
| 1287 | |
| 1288 | return; |
| 1289 | }/*End of hdd_batch_scan_result_ind_callback*/ |
| 1290 | |
| 1291 | /**--------------------------------------------------------------------------- |
| 1292 | |
| 1293 | \brief hdd_format_batch_scan_rsp () - This function formats batch scan |
| 1294 | response as per batch scan FR request format by putting proper markers |
| 1295 | |
| 1296 | \param - pDest pointer to destination buffer |
| 1297 | \param - cur_len current length |
| 1298 | \param - tot_len total remaining size which can be written to user space |
| 1299 | \param - pApMetaInfo Pointer to get batch scan response AP meta info |
| 1300 | \param - pAdapter Pointer to HDD adapter |
| 1301 | |
| 1302 | \return - ret no of characters written |
| 1303 | |
| 1304 | --------------------------------------------------------------------------*/ |
| 1305 | static tANI_U32 |
| 1306 | hdd_format_batch_scan_rsp |
| 1307 | ( |
| 1308 | tANI_U8 *pDest, |
| 1309 | tANI_U32 cur_len, |
| 1310 | tANI_U32 tot_len, |
| 1311 | tHddBatchScanRsp *pApMetaInfo, |
| 1312 | hdd_adapter_t* pAdapter |
| 1313 | ) |
| 1314 | { |
| 1315 | tANI_U32 ret = 0; |
| 1316 | tANI_U32 rem_len = 0; |
| 1317 | tANI_U8 temp_len = 0; |
| 1318 | tANI_U8 temp_total_len = 0; |
| 1319 | tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE]; |
| 1320 | tANI_U8 *pTemp = temp; |
| 1321 | |
| 1322 | /*Batch scan reponse needs to be returned to user space in |
| 1323 | following format: |
| 1324 | "scancount=X\n" where X is the number of scans in current batch |
| 1325 | batch |
| 1326 | "trunc\n" optional present if current scan truncated |
| 1327 | "bssid=XX:XX:XX:XX:XX:XX\n" |
| 1328 | "ssid=XXXX\n" |
| 1329 | "freq=X\n" frequency in Mhz |
| 1330 | "level=XX\n" |
| 1331 | "age=X\n" ms |
| 1332 | "dist=X\n" cm (-1 if not available) |
| 1333 | "errror=X\n" (-1if not available) |
| 1334 | "====\n" (end of ap marker) |
| 1335 | "####\n" (end of scan marker) |
| 1336 | "----\n" (end of results)*/ |
| 1337 | /*send scan result in above format to user space based on |
| 1338 | available length*/ |
| 1339 | /*The GET response may have more data than the driver can return in its |
| 1340 | buffer. In that case the buffer should be filled to the nearest complete |
| 1341 | scan, ending with "%%%%".Subsequent callsshould return the remaining data |
| 1342 | starting with the next scan (optional .trunc\n., .apcount=X\n., etc). |
| 1343 | The final buffer should end with "----\n"*/ |
| 1344 | |
| 1345 | /*sanity*/ |
| 1346 | if (cur_len > tot_len) |
| 1347 | { |
| 1348 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1349 | "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len); |
| 1350 | return 0; |
| 1351 | } |
| 1352 | else |
| 1353 | { |
| 1354 | rem_len = (tot_len - cur_len); |
| 1355 | } |
| 1356 | |
| 1357 | /*end scan marker*/ |
| 1358 | if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id) |
| 1359 | { |
| 1360 | temp_len = snprintf(pTemp, sizeof(temp), "####\n"); |
| 1361 | pTemp += temp_len; |
| 1362 | temp_total_len += temp_len; |
| 1363 | } |
| 1364 | |
| 1365 | /*bssid*/ |
| 1366 | temp_len = snprintf(pTemp, sizeof(temp), |
| 1367 | "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", |
| 1368 | pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1], |
| 1369 | pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3], |
| 1370 | pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]); |
| 1371 | pTemp += temp_len; |
| 1372 | temp_total_len += temp_len; |
| 1373 | |
| 1374 | /*ssid*/ |
| 1375 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n", |
| 1376 | pApMetaInfo->ApInfo.ssid); |
| 1377 | pTemp += temp_len; |
| 1378 | temp_total_len += temp_len; |
| 1379 | |
| 1380 | /*freq*/ |
| 1381 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n", |
Rajeev Kumar | c40f751 | 2013-11-04 14:13:23 -0800 | [diff] [blame] | 1382 | sme_ChnToFreq(pApMetaInfo->ApInfo.ch)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1383 | pTemp += temp_len; |
| 1384 | temp_total_len += temp_len; |
| 1385 | |
| 1386 | /*level*/ |
| 1387 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n", |
| 1388 | pApMetaInfo->ApInfo.rssi); |
| 1389 | pTemp += temp_len; |
| 1390 | temp_total_len += temp_len; |
| 1391 | |
| 1392 | /*age*/ |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1393 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n", |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1394 | pApMetaInfo->ApInfo.age); |
| 1395 | pTemp += temp_len; |
| 1396 | temp_total_len += temp_len; |
| 1397 | |
| 1398 | /*dist*/ |
| 1399 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n"); |
| 1400 | pTemp += temp_len; |
| 1401 | temp_total_len += temp_len; |
| 1402 | |
| 1403 | /*error*/ |
| 1404 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n"); |
| 1405 | pTemp += temp_len; |
| 1406 | temp_total_len += temp_len; |
| 1407 | |
| 1408 | /*end AP marker*/ |
| 1409 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n"); |
| 1410 | pTemp += temp_len; |
| 1411 | temp_total_len += temp_len; |
| 1412 | |
| 1413 | /*last AP in batch scan response*/ |
| 1414 | if(TRUE == pApMetaInfo->ApInfo.isLastAp) |
| 1415 | { |
| 1416 | /*end scan marker*/ |
| 1417 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n"); |
| 1418 | pTemp += temp_len; |
| 1419 | temp_total_len += temp_len; |
| 1420 | |
| 1421 | /*end batch scan result marker*/ |
| 1422 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n"); |
| 1423 | pTemp += temp_len; |
| 1424 | temp_total_len += temp_len; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1425 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1426 | } |
| 1427 | |
| 1428 | if (temp_total_len < rem_len) |
| 1429 | { |
| 1430 | ret = temp_total_len + 1; |
| 1431 | strlcpy(pDest, temp, ret); |
| 1432 | pAdapter->isTruncated = FALSE; |
| 1433 | } |
| 1434 | else |
| 1435 | { |
| 1436 | pAdapter->isTruncated = TRUE; |
| 1437 | if (rem_len >= strlen("%%%%")) |
| 1438 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1439 | ret = snprintf(pDest, sizeof(temp), "%%%%"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1440 | } |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1441 | else |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1442 | { |
| 1443 | ret = 0; |
| 1444 | } |
| 1445 | } |
| 1446 | |
| 1447 | return ret; |
| 1448 | |
| 1449 | }/*End of hdd_format_batch_scan_rsp*/ |
| 1450 | |
| 1451 | /**--------------------------------------------------------------------------- |
| 1452 | |
| 1453 | \brief hdd_populate_user_batch_scan_rsp() - This function populates user data |
| 1454 | buffer starting with head of hdd batch scan response queue |
| 1455 | |
| 1456 | \param - pAdapter Pointer to HDD adapter |
| 1457 | \param - pDest Pointer to user data buffer |
| 1458 | \param - cur_len current offset in user buffer |
| 1459 | \param - rem_len remaining no of bytes in user buffer |
| 1460 | |
| 1461 | \return - number of bytes written in user buffer |
| 1462 | |
| 1463 | --------------------------------------------------------------------------*/ |
| 1464 | |
| 1465 | tANI_U32 hdd_populate_user_batch_scan_rsp |
| 1466 | ( |
| 1467 | hdd_adapter_t* pAdapter, |
| 1468 | tANI_U8 *pDest, |
| 1469 | tANI_U32 cur_len, |
| 1470 | tANI_U32 rem_len |
| 1471 | ) |
| 1472 | { |
| 1473 | tHddBatchScanRsp *pHead; |
| 1474 | tHddBatchScanRsp *pPrev; |
| 1475 | tANI_U32 len; |
| 1476 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1477 | pAdapter->isTruncated = FALSE; |
| 1478 | |
| 1479 | /*head of hdd batch scan response queue*/ |
| 1480 | pHead = pAdapter->pBatchScanRsp; |
| 1481 | while (pHead) |
| 1482 | { |
| 1483 | len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead, |
| 1484 | pAdapter); |
| 1485 | pDest += len; |
Rajeev Kumar | 292d2bb | 2013-10-23 15:01:44 -0700 | [diff] [blame] | 1486 | pDest--; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1487 | cur_len += len; |
| 1488 | if(TRUE == pAdapter->isTruncated) |
| 1489 | { |
| 1490 | /*result is truncated return rest of scan rsp in next req*/ |
| 1491 | cur_len = rem_len; |
| 1492 | break; |
| 1493 | } |
| 1494 | pPrev = pHead; |
| 1495 | pHead = pHead->pNext; |
| 1496 | pAdapter->pBatchScanRsp = pHead; |
Rajeev Kumar | be17d8b | 2014-01-10 15:39:45 -0800 | [diff] [blame] | 1497 | if (TRUE == pPrev->ApInfo.isLastAp) |
| 1498 | { |
| 1499 | pAdapter->prev_batch_id = 0; |
| 1500 | } |
| 1501 | else |
| 1502 | { |
| 1503 | pAdapter->prev_batch_id = pPrev->ApInfo.batchId; |
| 1504 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1505 | vos_mem_free(pPrev); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 1506 | pPrev = NULL; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1507 | } |
| 1508 | |
| 1509 | return cur_len; |
| 1510 | }/*End of hdd_populate_user_batch_scan_rsp*/ |
| 1511 | |
| 1512 | /**--------------------------------------------------------------------------- |
| 1513 | |
| 1514 | \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch |
| 1515 | scan response data from HDD queue to user space |
| 1516 | It does following in detail: |
| 1517 | a) if HDD has enough data in its queue then it 1st copies data to user |
| 1518 | space and then send get batch scan indication message to FW. In this |
| 1519 | case it does not wait on any event and batch scan response data will |
| 1520 | be populated in HDD response queue in MC thread context after receiving |
| 1521 | indication from FW |
| 1522 | b) else send get batch scan indication message to FW and wait on an event |
| 1523 | which will be set once HDD receives complete batch scan response from |
| 1524 | FW and then this function returns batch scan response to user space |
| 1525 | |
| 1526 | \param - pAdapter Pointer to HDD adapter |
| 1527 | \param - pPrivData Pointer to priv_data |
| 1528 | |
| 1529 | \return - 0 for success -EFAULT for failure |
| 1530 | |
| 1531 | --------------------------------------------------------------------------*/ |
| 1532 | |
| 1533 | int hdd_return_batch_scan_rsp_to_user |
| 1534 | ( |
| 1535 | hdd_adapter_t* pAdapter, |
| 1536 | hdd_priv_data_t *pPrivData, |
| 1537 | tANI_U8 *command |
| 1538 | ) |
| 1539 | { |
| 1540 | tANI_U8 *pDest; |
| 1541 | tANI_U32 count = 0; |
| 1542 | tANI_U32 len = 0; |
| 1543 | tANI_U32 cur_len = 0; |
| 1544 | tANI_U32 rem_len = 0; |
| 1545 | eHalStatus halStatus; |
| 1546 | unsigned long rc; |
| 1547 | tSirTriggerBatchScanResultInd *pReq; |
| 1548 | |
| 1549 | pReq = &pAdapter->hddTriggerBatchScanResultInd; |
| 1550 | pReq->param = 0;/*batch scan client*/ |
| 1551 | pDest = (tANI_U8 *)(command + pPrivData->used_len); |
| 1552 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1553 | |
| 1554 | cur_len = pPrivData->used_len; |
| 1555 | if (pPrivData->total_len > pPrivData->used_len) |
| 1556 | { |
| 1557 | rem_len = pPrivData->total_len - pPrivData->used_len; |
| 1558 | } |
| 1559 | else |
| 1560 | { |
| 1561 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1562 | "%s: Invalid user data buffer total_len %d used_len %d", |
| 1563 | __func__, pPrivData->total_len, pPrivData->used_len); |
| 1564 | return -EFAULT; |
| 1565 | } |
| 1566 | |
| 1567 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1568 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1569 | cur_len, rem_len); |
| 1570 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1571 | |
| 1572 | /*enough scan result available in cache to return to user space or |
| 1573 | scan result needs to be fetched 1st from fw and then return*/ |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1574 | if (len == cur_len) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1575 | { |
| 1576 | pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE; |
| 1577 | halStatus = sme_TriggerBatchScanResultInd( |
| 1578 | WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1579 | pAdapter->sessionId, hdd_batch_scan_result_ind_callback, |
| 1580 | pAdapter); |
| 1581 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1582 | { |
| 1583 | if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) |
| 1584 | { |
| 1585 | INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var); |
| 1586 | rc = wait_for_completion_timeout( |
| 1587 | &pAdapter->hdd_get_batch_scan_req_var, |
| 1588 | msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT)); |
| 1589 | if (0 == rc) |
| 1590 | { |
| 1591 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1592 | "%s: Timeout waiting to fetch batch scan rsp from fw", |
| 1593 | __func__); |
| 1594 | return -EFAULT; |
| 1595 | } |
| 1596 | } |
| 1597 | |
| 1598 | len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE, |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1599 | "scancount=%u\n", pAdapter->numScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1600 | pDest += len; |
| 1601 | cur_len += len; |
| 1602 | |
| 1603 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1604 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1605 | cur_len, rem_len); |
| 1606 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1607 | |
| 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 | "NEW 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 | } |
| 1618 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1619 | "%s: copy %d data to user buffer", __func__, len); |
| 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 | } |
| 1626 | } |
| 1627 | else |
| 1628 | { |
| 1629 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1630 | "sme_GetBatchScanScan returned failure halStatus %d", |
| 1631 | halStatus); |
| 1632 | return -EINVAL; |
| 1633 | } |
| 1634 | } |
| 1635 | else |
| 1636 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1637 | count = 0; |
| 1638 | len = (len - pPrivData->used_len); |
| 1639 | pDest = (command + pPrivData->used_len); |
| 1640 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1641 | "REMAINING TRUNCATED BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1642 | while(count < len) |
| 1643 | { |
| 1644 | printk("%c", *(pDest + count)); |
| 1645 | count++; |
| 1646 | } |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1647 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1648 | "%s: copy %d data to user buffer", __func__, len); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1649 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1650 | { |
| 1651 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1652 | "%s: failed to copy data to user buffer", __func__); |
| 1653 | return -EFAULT; |
| 1654 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1655 | } |
| 1656 | |
| 1657 | return 0; |
| 1658 | } /*End of hdd_return_batch_scan_rsp_to_user*/ |
| 1659 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1660 | |
| 1661 | /**--------------------------------------------------------------------------- |
| 1662 | |
| 1663 | \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING |
| 1664 | IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled: |
| 1665 | WLS_BATCHING VERSION |
| 1666 | WLS_BATCHING SET |
| 1667 | WLS_BATCHING GET |
| 1668 | WLS_BATCHING STOP |
| 1669 | |
| 1670 | \param - pAdapter Pointer to HDD adapter |
| 1671 | \param - pPrivdata Pointer to priv_data |
| 1672 | \param - command Pointer to command |
| 1673 | |
| 1674 | \return - 0 for success -EFAULT for failure |
| 1675 | |
| 1676 | --------------------------------------------------------------------------*/ |
| 1677 | |
| 1678 | int hdd_handle_batch_scan_ioctl |
| 1679 | ( |
| 1680 | hdd_adapter_t *pAdapter, |
| 1681 | hdd_priv_data_t *pPrivdata, |
| 1682 | tANI_U8 *command |
| 1683 | ) |
| 1684 | { |
| 1685 | int ret = 0; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 1686 | hdd_context_t *pHddCtx; |
| 1687 | |
| 1688 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1689 | ret = wlan_hdd_validate_context(pHddCtx); |
| 1690 | if (ret) |
| 1691 | { |
| 1692 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1693 | "%s: HDD context is not valid!", __func__); |
| 1694 | goto exit; |
| 1695 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1696 | |
| 1697 | if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0) |
| 1698 | { |
| 1699 | char extra[32]; |
| 1700 | tANI_U8 len = 0; |
| 1701 | tANI_U8 version = HDD_BATCH_SCAN_VERSION; |
| 1702 | |
| 1703 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1704 | { |
| 1705 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1706 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1707 | ret = -EINVAL; |
| 1708 | goto exit; |
| 1709 | } |
| 1710 | |
| 1711 | len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d", |
| 1712 | version); |
| 1713 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1714 | { |
| 1715 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1716 | "%s: failed to copy data to user buffer", __func__); |
| 1717 | ret = -EFAULT; |
| 1718 | goto exit; |
| 1719 | } |
| 1720 | ret = HDD_BATCH_SCAN_VERSION; |
| 1721 | } |
| 1722 | else if (strncmp(command, "WLS_BATCHING SET", 16) == 0) |
| 1723 | { |
| 1724 | int status; |
| 1725 | tANI_U8 *value = (command + 16); |
| 1726 | eHalStatus halStatus; |
| 1727 | unsigned long rc; |
| 1728 | tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq; |
| 1729 | tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp; |
| 1730 | |
| 1731 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1732 | { |
| 1733 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1734 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1735 | ret = -EINVAL; |
| 1736 | goto exit; |
| 1737 | } |
| 1738 | |
| 1739 | if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) && |
| 1740 | (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) && |
| 1741 | (WLAN_HDD_P2P_GO != pAdapter->device_mode) && |
| 1742 | (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode)) |
| 1743 | { |
| 1744 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 1745 | "Received WLS_BATCHING SET command in invalid mode %s (%d) " |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1746 | "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode", |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 1747 | hdd_device_modetoString(pAdapter->device_mode), |
| 1748 | pAdapter->device_mode); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1749 | ret = -EINVAL; |
| 1750 | goto exit; |
| 1751 | } |
| 1752 | |
| 1753 | status = hdd_parse_set_batchscan_command(value, pReq); |
| 1754 | if (status) |
| 1755 | { |
| 1756 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1757 | "Invalid WLS_BATCHING SET command"); |
| 1758 | ret = -EINVAL; |
| 1759 | goto exit; |
| 1760 | } |
| 1761 | |
| 1762 | |
| 1763 | pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE; |
| 1764 | halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1765 | pAdapter->sessionId, hdd_set_batch_scan_req_callback, |
| 1766 | pAdapter); |
| 1767 | |
| 1768 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1769 | { |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1770 | char extra[32]; |
| 1771 | tANI_U8 len = 0; |
| 1772 | tANI_U8 mScan = 0; |
| 1773 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1774 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1775 | "sme_SetBatchScanReq returned success halStatus %d", |
| 1776 | halStatus); |
| 1777 | if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp) |
| 1778 | { |
| 1779 | INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var); |
| 1780 | rc = wait_for_completion_timeout( |
| 1781 | &pAdapter->hdd_set_batch_scan_req_var, |
| 1782 | msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT)); |
| 1783 | if (0 == rc) |
| 1784 | { |
| 1785 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1786 | "%s: Timeout waiting for set batch scan to complete", |
| 1787 | __func__); |
| 1788 | ret = -EINVAL; |
| 1789 | goto exit; |
| 1790 | } |
| 1791 | } |
| 1792 | if ( !pRsp->nScansToBatch ) |
| 1793 | { |
| 1794 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1795 | "%s: Received set batch scan failure response from FW", |
| 1796 | __func__); |
| 1797 | ret = -EINVAL; |
| 1798 | goto exit; |
| 1799 | } |
| 1800 | /*As per the Batch Scan Framework API we should return the MIN of |
| 1801 | either MSCAN or the max # of scans firmware can cache*/ |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1802 | mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1803 | |
| 1804 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED; |
| 1805 | |
| 1806 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1807 | "%s: request MSCAN %d response MSCAN %d ret %d", |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1808 | __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan); |
| 1809 | len = scnprintf(extra, sizeof(extra), "%d", mScan); |
| 1810 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1811 | { |
| 1812 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1813 | "%s: failed to copy MSCAN value to user buffer", __func__); |
| 1814 | ret = -EFAULT; |
| 1815 | goto exit; |
| 1816 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1817 | } |
| 1818 | else |
| 1819 | { |
| 1820 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1821 | "sme_SetBatchScanReq returned failure halStatus %d", |
| 1822 | halStatus); |
| 1823 | ret = -EINVAL; |
| 1824 | goto exit; |
| 1825 | } |
| 1826 | } |
| 1827 | else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0) |
| 1828 | { |
| 1829 | eHalStatus halStatus; |
| 1830 | tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd; |
| 1831 | pInd->param = 0; |
| 1832 | |
| 1833 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1834 | { |
| 1835 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1836 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1837 | ret = -EINVAL; |
| 1838 | goto exit; |
| 1839 | } |
| 1840 | |
| 1841 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1842 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 1843 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1844 | "Batch scan is not yet enabled batch scan state %d", |
| 1845 | pAdapter->batchScanState); |
| 1846 | ret = -EINVAL; |
| 1847 | goto exit; |
| 1848 | } |
| 1849 | |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1850 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1851 | hdd_deinit_batch_scan(pAdapter); |
| 1852 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1853 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1854 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 1855 | |
| 1856 | halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd, |
| 1857 | pAdapter->sessionId); |
| 1858 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1859 | { |
| 1860 | ret = 0; |
| 1861 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1862 | "sme_StopBatchScanInd returned success halStatus %d", |
| 1863 | halStatus); |
| 1864 | } |
| 1865 | else |
| 1866 | { |
| 1867 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1868 | "sme_StopBatchScanInd returned failure halStatus %d", |
| 1869 | halStatus); |
| 1870 | ret = -EINVAL; |
| 1871 | goto exit; |
| 1872 | } |
| 1873 | } |
| 1874 | else if (strncmp(command, "WLS_BATCHING GET", 16) == 0) |
| 1875 | { |
| 1876 | tANI_U32 remain_len; |
| 1877 | |
| 1878 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1879 | { |
| 1880 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1881 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1882 | ret = -EINVAL; |
| 1883 | goto exit; |
| 1884 | } |
| 1885 | |
| 1886 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1887 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 1888 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1889 | "Batch scan is not yet enabled could not return results" |
| 1890 | "Batch Scan state %d", |
| 1891 | pAdapter->batchScanState); |
| 1892 | ret = -EINVAL; |
| 1893 | goto exit; |
| 1894 | } |
| 1895 | |
| 1896 | pPrivdata->used_len = 16; |
| 1897 | remain_len = pPrivdata->total_len - pPrivdata->used_len; |
| 1898 | if (remain_len < pPrivdata->total_len) |
| 1899 | { |
| 1900 | /*Clear previous batch scan response data if any*/ |
| 1901 | vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len); |
| 1902 | } |
| 1903 | else |
| 1904 | { |
| 1905 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1906 | "Invalid total length from user space can't fetch batch" |
| 1907 | " scan response total_len %d used_len %d remain len %d", |
| 1908 | pPrivdata->total_len, pPrivdata->used_len, remain_len); |
| 1909 | ret = -EINVAL; |
| 1910 | goto exit; |
| 1911 | } |
| 1912 | ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command); |
| 1913 | } |
| 1914 | |
| 1915 | exit: |
| 1916 | |
| 1917 | return ret; |
| 1918 | } |
| 1919 | |
| 1920 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1921 | #endif/*End of FEATURE_WLAN_BATCH_SCAN*/ |
| 1922 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1923 | static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data) |
| 1924 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1925 | bcnMissRateContext_t *pCBCtx; |
| 1926 | |
| 1927 | if (NULL == data) |
| 1928 | { |
| 1929 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 1930 | return; |
| 1931 | } |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1932 | |
| 1933 | /* there is a race condition that exists between this callback |
| 1934 | function and the caller since the caller could time out either |
| 1935 | before or while this code is executing. we use a spinlock to |
| 1936 | serialize these actions */ |
| 1937 | spin_lock(&hdd_context_lock); |
| 1938 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1939 | pCBCtx = (bcnMissRateContext_t *)data; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1940 | gbcnMissRate = -1; |
| 1941 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1942 | if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC) |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1943 | { |
| 1944 | hddLog(VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1945 | FL("invalid context magic: %08x"), pCBCtx->magic); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1946 | spin_unlock(&hdd_context_lock); |
| 1947 | return ; |
| 1948 | } |
| 1949 | |
| 1950 | if (VOS_STATUS_SUCCESS == status) |
| 1951 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1952 | gbcnMissRate = bcnMissRate; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1953 | } |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1954 | else |
| 1955 | { |
| 1956 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate")); |
| 1957 | } |
| 1958 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1959 | complete(&(pCBCtx->completion)); |
| 1960 | spin_unlock(&hdd_context_lock); |
| 1961 | |
| 1962 | return; |
| 1963 | } |
| 1964 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 1965 | static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len) |
| 1966 | { |
| 1967 | int ret = 0; |
| 1968 | |
| 1969 | if (!pCfg || !command || !extra || !len) |
| 1970 | { |
| 1971 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1972 | "%s: argument passsed for GETDWELLTIME is incorrect", __func__); |
| 1973 | ret = -EINVAL; |
| 1974 | return ret; |
| 1975 | } |
| 1976 | |
| 1977 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) |
| 1978 | { |
| 1979 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", |
| 1980 | (int)pCfg->nActiveMaxChnTime); |
| 1981 | return ret; |
| 1982 | } |
| 1983 | else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0) |
| 1984 | { |
| 1985 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n", |
| 1986 | (int)pCfg->nActiveMinChnTime); |
| 1987 | return ret; |
| 1988 | } |
| 1989 | else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) |
| 1990 | { |
| 1991 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
| 1992 | (int)pCfg->nPassiveMaxChnTime); |
| 1993 | return ret; |
| 1994 | } |
| 1995 | else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0) |
| 1996 | { |
| 1997 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n", |
| 1998 | (int)pCfg->nPassiveMinChnTime); |
| 1999 | return ret; |
| 2000 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2001 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 2002 | { |
| 2003 | *len = scnprintf(extra, n, "GETDWELLTIME %u \n", |
| 2004 | (int)pCfg->nActiveMaxChnTime); |
| 2005 | return ret; |
| 2006 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2007 | else |
| 2008 | { |
| 2009 | ret = -EINVAL; |
| 2010 | } |
| 2011 | |
| 2012 | return ret; |
| 2013 | } |
| 2014 | |
| 2015 | static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 2016 | { |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2017 | tHalHandle hHal; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2018 | hdd_config_t *pCfg; |
| 2019 | tANI_U8 *value = command; |
| 2020 | int val = 0, ret = 0, temp = 0; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2021 | tSmeConfigParams smeConfig; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2022 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2023 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini) |
| 2024 | || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter)))) |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2025 | { |
| 2026 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2027 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2028 | ret = -EINVAL; |
| 2029 | return ret; |
| 2030 | } |
| 2031 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2032 | vos_mem_zero(&smeConfig, sizeof(smeConfig)); |
| 2033 | sme_GetConfigParam(hHal, &smeConfig); |
| 2034 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2035 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 ) |
| 2036 | { |
| 2037 | value = value + 24; |
| 2038 | temp = kstrtou32(value, 10, &val); |
| 2039 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2040 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2041 | { |
| 2042 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2043 | "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__); |
| 2044 | ret = -EFAULT; |
| 2045 | return ret; |
| 2046 | } |
| 2047 | pCfg->nActiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2048 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2049 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2050 | } |
| 2051 | else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2052 | { |
| 2053 | value = value + 24; |
| 2054 | temp = kstrtou32(value, 10, &val); |
| 2055 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN || |
| 2056 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX ) |
| 2057 | { |
| 2058 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2059 | "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__); |
| 2060 | ret = -EFAULT; |
| 2061 | return ret; |
| 2062 | } |
| 2063 | pCfg->nActiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2064 | smeConfig.csrConfig.nActiveMinChnTime = val; |
| 2065 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2066 | } |
| 2067 | else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2068 | { |
| 2069 | value = value + 25; |
| 2070 | temp = kstrtou32(value, 10, &val); |
| 2071 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN || |
| 2072 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX ) |
| 2073 | { |
| 2074 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2075 | "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__); |
| 2076 | ret = -EFAULT; |
| 2077 | return ret; |
| 2078 | } |
| 2079 | pCfg->nPassiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2080 | smeConfig.csrConfig.nPassiveMaxChnTime = val; |
| 2081 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2082 | } |
| 2083 | else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2084 | { |
| 2085 | value = value + 25; |
| 2086 | temp = kstrtou32(value, 10, &val); |
| 2087 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN || |
| 2088 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX ) |
| 2089 | { |
| 2090 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2091 | "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__); |
| 2092 | ret = -EFAULT; |
| 2093 | return ret; |
| 2094 | } |
| 2095 | pCfg->nPassiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2096 | smeConfig.csrConfig.nPassiveMinChnTime = val; |
| 2097 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2098 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2099 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 2100 | { |
| 2101 | value = value + 13; |
| 2102 | temp = kstrtou32(value, 10, &val); |
| 2103 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2104 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2105 | { |
| 2106 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2107 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2108 | ret = -EFAULT; |
| 2109 | return ret; |
| 2110 | } |
| 2111 | pCfg->nActiveMaxChnTime = val; |
| 2112 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2113 | sme_UpdateConfig(hHal, &smeConfig); |
| 2114 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2115 | else |
| 2116 | { |
| 2117 | ret = -EINVAL; |
| 2118 | } |
| 2119 | |
| 2120 | return ret; |
| 2121 | } |
| 2122 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2123 | static int hdd_driver_command(hdd_adapter_t *pAdapter, |
| 2124 | hdd_priv_data_t *ppriv_data) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2125 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2126 | hdd_priv_data_t priv_data; |
| 2127 | tANI_U8 *command = NULL; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2128 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2129 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2130 | int ret = 0; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2131 | int status; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2132 | /* |
| 2133 | * Note that valid pointers are provided by caller |
| 2134 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2135 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2136 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 2137 | priv_data = *ppriv_data; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2138 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2139 | if (priv_data.total_len <= 0 || |
| 2140 | priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN) |
Sameer Thalappil | 8ef3a0e | 2013-04-05 14:36:04 -0700 | [diff] [blame] | 2141 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2142 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 2143 | "%s:invalid priv_data.total_len(%d)!!!", __func__, |
| 2144 | priv_data.total_len); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2145 | ret = -EINVAL; |
| 2146 | goto exit; |
| 2147 | } |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2148 | status = wlan_hdd_validate_context(pHddCtx); |
| 2149 | if (0 != status) |
| 2150 | { |
| 2151 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2152 | "%s: HDD context is not valid", __func__); |
| 2153 | return status; |
| 2154 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2155 | /* Allocate +1 for '\0' */ |
| 2156 | command = kmalloc(priv_data.total_len + 1, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2157 | if (!command) |
| 2158 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2159 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2160 | "%s: failed to allocate memory", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2161 | ret = -ENOMEM; |
| 2162 | goto exit; |
| 2163 | } |
| 2164 | |
| 2165 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 2166 | { |
| 2167 | ret = -EFAULT; |
| 2168 | goto exit; |
| 2169 | } |
| 2170 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2171 | /* Make sure the command is NUL-terminated */ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2172 | command[priv_data.total_len] = '\0'; |
| 2173 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2174 | /* at one time the following block of code was conditional. braces |
| 2175 | * have been retained to avoid re-indenting the legacy code |
| 2176 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2177 | { |
| 2178 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 2179 | |
| 2180 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 2181 | "%s: Received %s cmd from Wi-Fi GUI***", __func__, command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2182 | |
| 2183 | if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 ) |
| 2184 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2185 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2186 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
| 2187 | pAdapter->sessionId, (unsigned) |
| 2188 | (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 | |
| 2189 | *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 | |
| 2190 | *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 | |
| 2191 | *(pHddCtx->p2pDeviceAddress.bytes+5)))); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2192 | if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes, |
| 2193 | sizeof(tSirMacAddr))) |
| 2194 | { |
| 2195 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2196 | "%s: failed to copy data to user buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2197 | ret = -EFAULT; |
| 2198 | } |
| 2199 | } |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2200 | else if(strncmp(command, "SETBAND", 7) == 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2201 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2202 | tANI_U8 *ptr = command ; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2203 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2204 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2205 | |
| 2206 | /* First 8 bytes will have "SETBAND " and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2207 | * 9 byte will have band setting value */ |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 2208 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2209 | "%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] | 2210 | /* Change band request received */ |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2211 | ret = hdd_setBand_helper(pAdapter->dev, ptr); |
Abhishek Singh | 2ec36ab | 2014-08-07 16:14:25 +0530 | [diff] [blame] | 2212 | if(ret < 0) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2213 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2214 | "%s: failed to set band ret=%d", __func__, ret); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2215 | } |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 2216 | else if(strncmp(command, "SETWMMPS", 8) == 0) |
| 2217 | { |
| 2218 | tANI_U8 *ptr = command; |
| 2219 | ret = hdd_wmmps_helper(pAdapter, ptr); |
| 2220 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2221 | else if ( strncasecmp(command, "COUNTRY", 7) == 0 ) |
| 2222 | { |
| 2223 | char *country_code; |
| 2224 | |
| 2225 | country_code = command + 8; |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2226 | |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2227 | INIT_COMPLETION(pAdapter->change_country_code); |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2228 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2229 | #ifndef CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 2230 | hdd_checkandupdate_phymode(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2231 | #endif |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2232 | ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 2233 | (void *)(tSmeChangeCountryCallback) |
| 2234 | wlan_hdd_change_country_code_callback, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 2235 | country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2236 | if (eHAL_STATUS_SUCCESS == ret) |
| 2237 | { |
| 2238 | ret = wait_for_completion_interruptible_timeout( |
| 2239 | &pAdapter->change_country_code, |
| 2240 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 2241 | if (0 >= ret) |
| 2242 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2243 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME while setting country code timed out %d", |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2244 | __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2245 | } |
| 2246 | } |
| 2247 | else |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2248 | { |
| 2249 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2250 | "%s: SME Change Country code fail ret=%d", __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2251 | ret = -EINVAL; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2252 | } |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2253 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2254 | } |
| 2255 | /* |
| 2256 | command should be a string having format |
| 2257 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 2258 | */ |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2259 | else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2260 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2261 | tANI_U8 *ptr = command; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2262 | |
| 2263 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2264 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2265 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 2266 | ret = sapSetPreferredChannel(ptr); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2267 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2268 | else if(strncmp(command, "SETSUSPENDMODE", 14) == 0) |
| 2269 | { |
| 2270 | int suspend = 0; |
| 2271 | tANI_U8 *ptr = (tANI_U8*)command + 15; |
| 2272 | |
| 2273 | suspend = *ptr - '0'; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2274 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2275 | TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL, |
| 2276 | pAdapter->sessionId, suspend)); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2277 | hdd_set_wlan_suspend_mode(suspend); |
| 2278 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2279 | #ifdef WLAN_FEATURE_NEIGHBOR_ROAMING |
| 2280 | else if (strncmp(command, "SETROAMTRIGGER", 14) == 0) |
| 2281 | { |
| 2282 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2283 | tANI_S8 rssi = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2284 | tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
| 2285 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2286 | |
| 2287 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 2288 | value = value + 15; |
| 2289 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2290 | /* Convert the value from ascii to integer */ |
| 2291 | ret = kstrtos8(value, 10, &rssi); |
| 2292 | if (ret < 0) |
| 2293 | { |
| 2294 | /* If the input value is greater than max value of datatype, then also |
| 2295 | kstrtou8 fails */ |
| 2296 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2297 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | fa7157d | 2013-10-31 10:14:22 -0700 | [diff] [blame] | 2298 | __func__, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2299 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2300 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2301 | ret = -EINVAL; |
| 2302 | goto exit; |
| 2303 | } |
| 2304 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2305 | lookUpThreshold = abs(rssi); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2306 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2307 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) || |
| 2308 | (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) |
| 2309 | { |
| 2310 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2311 | "Neighbor lookup threshold value %d is out of range" |
| 2312 | " (Min: %d Max: %d)", lookUpThreshold, |
| 2313 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2314 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2315 | ret = -EINVAL; |
| 2316 | goto exit; |
| 2317 | } |
| 2318 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2319 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2320 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
| 2321 | pAdapter->sessionId, lookUpThreshold)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2322 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2323 | "%s: Received Command to Set Roam trigger" |
| 2324 | " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold); |
| 2325 | |
| 2326 | pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 2327 | status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold); |
| 2328 | if (eHAL_STATUS_SUCCESS != status) |
| 2329 | { |
| 2330 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2331 | "%s: Failed to set roam trigger, try again", __func__); |
| 2332 | ret = -EPERM; |
| 2333 | goto exit; |
| 2334 | } |
| 2335 | |
| 2336 | /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */ |
mukul sharma | d6e1fdd | 2014-06-23 19:19:09 +0530 | [diff] [blame] | 2337 | pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2338 | sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5); |
| 2339 | } |
| 2340 | else if (strncmp(command, "GETROAMTRIGGER", 14) == 0) |
| 2341 | { |
| 2342 | tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal)); |
| 2343 | int rssi = (-1) * lookUpThreshold; |
| 2344 | char extra[32]; |
| 2345 | tANI_U8 len = 0; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2346 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2347 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
| 2348 | pAdapter->sessionId, lookUpThreshold)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2349 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2350 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2351 | { |
| 2352 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2353 | "%s: failed to copy data to user buffer", __func__); |
| 2354 | ret = -EFAULT; |
| 2355 | goto exit; |
| 2356 | } |
| 2357 | } |
| 2358 | else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0) |
| 2359 | { |
| 2360 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2361 | tANI_U8 roamScanPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2362 | tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2363 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2364 | /* input refresh period is in terms of seconds */ |
| 2365 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 2366 | value = value + 18; |
| 2367 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2368 | ret = kstrtou8(value, 10, &roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2369 | if (ret < 0) |
| 2370 | { |
| 2371 | /* 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] | 2372 | kstrtou8 fails */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2373 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2374 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2375 | __func__, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2376 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2377 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2378 | ret = -EINVAL; |
| 2379 | goto exit; |
| 2380 | } |
| 2381 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2382 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) || |
| 2383 | (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000))) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2384 | { |
| 2385 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2386 | "Roam scan period value %d is out of range" |
| 2387 | " (Min: %d Max: %d)", roamScanPeriod, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2388 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2389 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2390 | ret = -EINVAL; |
| 2391 | goto exit; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2392 | } |
| 2393 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2394 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
| 2395 | pAdapter->sessionId, roamScanPeriod)); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2396 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2397 | |
| 2398 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2399 | "%s: Received Command to Set roam scan period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2400 | " (Empty Scan refresh period) = %d", __func__, roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2401 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2402 | pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod; |
| 2403 | sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2404 | } |
| 2405 | else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0) |
| 2406 | { |
| 2407 | tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2408 | char extra[32]; |
| 2409 | tANI_U8 len = 0; |
| 2410 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2411 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2412 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
| 2413 | pAdapter->sessionId, nEmptyScanRefreshPeriod)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2414 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2415 | "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2416 | /* Returned value is in units of seconds */ |
| 2417 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2418 | { |
| 2419 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2420 | "%s: failed to copy data to user buffer", __func__); |
| 2421 | ret = -EFAULT; |
| 2422 | goto exit; |
| 2423 | } |
| 2424 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2425 | else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2426 | { |
| 2427 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2428 | tANI_U8 roamScanRefreshPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2429 | tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2430 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2431 | /* input refresh period is in terms of seconds */ |
| 2432 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 2433 | value = value + 25; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2434 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2435 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2436 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2437 | if (ret < 0) |
| 2438 | { |
| 2439 | /* 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] | 2440 | kstrtou8 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2441 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2442 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2443 | __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2444 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2445 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2446 | ret = -EINVAL; |
| 2447 | goto exit; |
| 2448 | } |
| 2449 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2450 | if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) || |
| 2451 | (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000))) |
| 2452 | { |
| 2453 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2454 | "Neighbor scan results refresh period value %d is out of range" |
| 2455 | " (Min: %d Max: %d)", roamScanRefreshPeriod, |
| 2456 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2457 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2458 | ret = -EINVAL; |
| 2459 | goto exit; |
| 2460 | } |
| 2461 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 2462 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2463 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2464 | "%s: Received Command to Set roam scan refresh period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2465 | " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2466 | |
| 2467 | pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod; |
| 2468 | sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod); |
| 2469 | } |
| 2470 | else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2471 | { |
| 2472 | tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2473 | char extra[32]; |
| 2474 | tANI_U8 len = 0; |
| 2475 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2476 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2477 | "GETROAMSCANREFRESHPERIOD", (value/1000)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2478 | /* Returned value is in units of seconds */ |
| 2479 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2480 | { |
| 2481 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2482 | "%s: failed to copy data to user buffer", __func__); |
| 2483 | ret = -EFAULT; |
| 2484 | goto exit; |
| 2485 | } |
| 2486 | } |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2487 | #ifdef FEATURE_WLAN_LFR |
| 2488 | /* SETROAMMODE */ |
| 2489 | else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0) |
| 2490 | { |
| 2491 | tANI_U8 *value = command; |
| 2492 | tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 2493 | |
| 2494 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 2495 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 2496 | |
| 2497 | /* Convert the value from ascii to integer */ |
| 2498 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 2499 | if (ret < 0) |
| 2500 | { |
| 2501 | /* If the input value is greater than max value of datatype, then also |
| 2502 | kstrtou8 fails */ |
| 2503 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2504 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2505 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2506 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2507 | ret = -EINVAL; |
| 2508 | goto exit; |
| 2509 | } |
| 2510 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 2511 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 2512 | { |
| 2513 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2514 | "Roam Mode value %d is out of range" |
| 2515 | " (Min: %d Max: %d)", roamMode, |
| 2516 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2517 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2518 | ret = -EINVAL; |
| 2519 | goto exit; |
| 2520 | } |
| 2521 | |
| 2522 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2523 | "%s: Received Command to Set Roam Mode = %d", __func__, roamMode); |
| 2524 | /* |
| 2525 | * Note that |
| 2526 | * SETROAMMODE 0 is to enable LFR while |
| 2527 | * SETROAMMODE 1 is to disable LFR, but |
| 2528 | * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable. |
| 2529 | * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled. |
| 2530 | */ |
| 2531 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2532 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 2533 | else |
| 2534 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 2535 | |
| 2536 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode; |
| 2537 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode); |
| 2538 | } |
| 2539 | /* GETROAMMODE */ |
| 2540 | else if (strncmp(priv_data.buf, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0) |
| 2541 | { |
| 2542 | tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2543 | char extra[32]; |
| 2544 | tANI_U8 len = 0; |
| 2545 | |
| 2546 | /* |
| 2547 | * roamMode value shall be inverted because the sementics is different. |
| 2548 | */ |
| 2549 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2550 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 2551 | else |
| 2552 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 2553 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2554 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2555 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2556 | { |
| 2557 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2558 | "%s: failed to copy data to user buffer", __func__); |
| 2559 | ret = -EFAULT; |
| 2560 | goto exit; |
| 2561 | } |
| 2562 | } |
| 2563 | #endif |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2564 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2565 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2566 | else if (strncmp(command, "SETROAMDELTA", 12) == 0) |
| 2567 | { |
| 2568 | tANI_U8 *value = command; |
| 2569 | tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 2570 | |
| 2571 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 2572 | value = value + 13; |
| 2573 | /* Convert the value from ascii to integer */ |
| 2574 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 2575 | if (ret < 0) |
| 2576 | { |
| 2577 | /* If the input value is greater than max value of datatype, then also |
| 2578 | kstrtou8 fails */ |
| 2579 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2580 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2581 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2582 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2583 | ret = -EINVAL; |
| 2584 | goto exit; |
| 2585 | } |
| 2586 | |
| 2587 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 2588 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) |
| 2589 | { |
| 2590 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2591 | "Roam rssi diff value %d is out of range" |
| 2592 | " (Min: %d Max: %d)", roamRssiDiff, |
| 2593 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2594 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2595 | ret = -EINVAL; |
| 2596 | goto exit; |
| 2597 | } |
| 2598 | |
| 2599 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2600 | "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff); |
| 2601 | |
| 2602 | pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff; |
| 2603 | sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff); |
| 2604 | } |
| 2605 | else if (strncmp(priv_data.buf, "GETROAMDELTA", 12) == 0) |
| 2606 | { |
| 2607 | tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal)); |
| 2608 | char extra[32]; |
| 2609 | tANI_U8 len = 0; |
| 2610 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2611 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2612 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
| 2613 | pAdapter->sessionId, roamRssiDiff)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2614 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2615 | command, roamRssiDiff); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2616 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2617 | { |
| 2618 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2619 | "%s: failed to copy data to user buffer", __func__); |
| 2620 | ret = -EFAULT; |
| 2621 | goto exit; |
| 2622 | } |
| 2623 | } |
| 2624 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2625 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2626 | else if (strncmp(command, "GETBAND", 7) == 0) |
| 2627 | { |
| 2628 | int band = -1; |
| 2629 | char extra[32]; |
| 2630 | tANI_U8 len = 0; |
| 2631 | hdd_getBand_helper(pHddCtx, &band); |
| 2632 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2633 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2634 | TRACE_CODE_HDD_GETBAND_IOCTL, |
| 2635 | pAdapter->sessionId, band)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2636 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2637 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2638 | { |
| 2639 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2640 | "%s: failed to copy data to user buffer", __func__); |
| 2641 | ret = -EFAULT; |
| 2642 | goto exit; |
| 2643 | } |
| 2644 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2645 | else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0) |
| 2646 | { |
| 2647 | tANI_U8 *value = command; |
| 2648 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2649 | tANI_U8 numChannels = 0; |
| 2650 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2651 | |
| 2652 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 2653 | if (eHAL_STATUS_SUCCESS != status) |
| 2654 | { |
| 2655 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2656 | "%s: Failed to parse channel list information", __func__); |
| 2657 | ret = -EINVAL; |
| 2658 | goto exit; |
| 2659 | } |
| 2660 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2661 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2662 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 2663 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2664 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 2665 | { |
| 2666 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2667 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 2668 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 2669 | ret = -EINVAL; |
| 2670 | goto exit; |
| 2671 | } |
| 2672 | status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList, |
| 2673 | numChannels); |
| 2674 | if (eHAL_STATUS_SUCCESS != status) |
| 2675 | { |
| 2676 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2677 | "%s: Failed to update channel list information", __func__); |
| 2678 | ret = -EINVAL; |
| 2679 | goto exit; |
| 2680 | } |
| 2681 | } |
| 2682 | else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0) |
| 2683 | { |
| 2684 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2685 | tANI_U8 numChannels = 0; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2686 | tANI_U8 j = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2687 | char extra[128] = {0}; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2688 | int len; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2689 | |
| 2690 | if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal), |
| 2691 | ChannelList, &numChannels )) |
| 2692 | { |
| 2693 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2694 | "%s: failed to get roam scan channel list", __func__); |
| 2695 | ret = -EFAULT; |
| 2696 | goto exit; |
| 2697 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2698 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2699 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
| 2700 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2701 | /* output channel list is of the format |
| 2702 | [Number of roam scan channels][Channel1][Channel2]... */ |
| 2703 | /* copy the number of channels in the 0th index */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2704 | len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2705 | for (j = 0; (j < numChannels); j++) |
| 2706 | { |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2707 | len += scnprintf(extra + len, sizeof(extra) - len, " %d", |
| 2708 | ChannelList[j]); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2709 | } |
| 2710 | |
| 2711 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2712 | { |
| 2713 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2714 | "%s: failed to copy data to user buffer", __func__); |
| 2715 | ret = -EFAULT; |
| 2716 | goto exit; |
| 2717 | } |
| 2718 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2719 | else if (strncmp(command, "GETCCXMODE", 10) == 0) |
| 2720 | { |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2721 | tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2722 | char extra[32]; |
| 2723 | tANI_U8 len = 0; |
| 2724 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2725 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2726 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2727 | if (eseMode && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2728 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 2729 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2730 | { |
| 2731 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2732 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2733 | " hence this operation is not permitted!", __func__); |
| 2734 | ret = -EPERM; |
| 2735 | goto exit; |
| 2736 | } |
| 2737 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2738 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2739 | "GETCCXMODE", eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2740 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2741 | { |
| 2742 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2743 | "%s: failed to copy data to user buffer", __func__); |
| 2744 | ret = -EFAULT; |
| 2745 | goto exit; |
| 2746 | } |
| 2747 | } |
| 2748 | else if (strncmp(command, "GETOKCMODE", 10) == 0) |
| 2749 | { |
| 2750 | tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx); |
| 2751 | char extra[32]; |
| 2752 | tANI_U8 len = 0; |
| 2753 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2754 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2755 | then this operation is not permitted (return FAILURE) */ |
| 2756 | if (okcMode && |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2757 | sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2758 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2759 | { |
| 2760 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2761 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2762 | " hence this operation is not permitted!", __func__); |
| 2763 | ret = -EPERM; |
| 2764 | goto exit; |
| 2765 | } |
| 2766 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2767 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2768 | "GETOKCMODE", okcMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2769 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2770 | { |
| 2771 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2772 | "%s: failed to copy data to user buffer", __func__); |
| 2773 | ret = -EFAULT; |
| 2774 | goto exit; |
| 2775 | } |
| 2776 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2777 | else if (strncmp(command, "GETFASTROAM", 11) == 0) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2778 | { |
| 2779 | tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2780 | char extra[32]; |
| 2781 | tANI_U8 len = 0; |
| 2782 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2783 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2784 | "GETFASTROAM", lfrMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2785 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2786 | { |
| 2787 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2788 | "%s: failed to copy data to user buffer", __func__); |
| 2789 | ret = -EFAULT; |
| 2790 | goto exit; |
| 2791 | } |
| 2792 | } |
| 2793 | else if (strncmp(command, "GETFASTTRANSITION", 17) == 0) |
| 2794 | { |
| 2795 | tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2796 | char extra[32]; |
| 2797 | tANI_U8 len = 0; |
| 2798 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2799 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2800 | "GETFASTTRANSITION", ft); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2801 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2802 | { |
| 2803 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2804 | "%s: failed to copy data to user buffer", __func__); |
| 2805 | ret = -EFAULT; |
| 2806 | goto exit; |
| 2807 | } |
| 2808 | } |
| 2809 | else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2810 | { |
| 2811 | tANI_U8 *value = command; |
| 2812 | tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 2813 | |
| 2814 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 2815 | value = value + 26; |
| 2816 | /* Convert the value from ascii to integer */ |
| 2817 | ret = kstrtou8(value, 10, &minTime); |
| 2818 | if (ret < 0) |
| 2819 | { |
| 2820 | /* If the input value is greater than max value of datatype, then also |
| 2821 | kstrtou8 fails */ |
| 2822 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2823 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2824 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2825 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2826 | ret = -EINVAL; |
| 2827 | goto exit; |
| 2828 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2829 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 2830 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) |
| 2831 | { |
| 2832 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2833 | "scan min channel time value %d is out of range" |
| 2834 | " (Min: %d Max: %d)", minTime, |
| 2835 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2836 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2837 | ret = -EINVAL; |
| 2838 | goto exit; |
| 2839 | } |
| 2840 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2841 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2842 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
| 2843 | pAdapter->sessionId, minTime)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2844 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2845 | "%s: Received Command to change channel min time = %d", __func__, minTime); |
| 2846 | |
| 2847 | pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime; |
| 2848 | sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime); |
| 2849 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2850 | else if (strncmp(command, "SENDACTIONFRAME", 15) == 0) |
| 2851 | { |
| 2852 | tANI_U8 *value = command; |
| 2853 | tANI_U8 channel = 0; |
| 2854 | tANI_U8 dwellTime = 0; |
| 2855 | tANI_U8 bufLen = 0; |
| 2856 | tANI_U8 *buf = NULL; |
| 2857 | tSirMacAddr targetApBssid; |
| 2858 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2859 | struct ieee80211_channel chan; |
| 2860 | tANI_U8 finalLen = 0; |
| 2861 | tANI_U8 *finalBuf = NULL; |
| 2862 | tANI_U8 temp = 0; |
| 2863 | u64 cookie; |
| 2864 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 2865 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2866 | |
| 2867 | /* if not associated, no need to send action frame */ |
| 2868 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 2869 | { |
| 2870 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 2871 | ret = -EINVAL; |
| 2872 | goto exit; |
| 2873 | } |
| 2874 | |
| 2875 | status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel, |
| 2876 | &dwellTime, &buf, &bufLen); |
| 2877 | if (eHAL_STATUS_SUCCESS != status) |
| 2878 | { |
| 2879 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2880 | "%s: Failed to parse send action frame data", __func__); |
| 2881 | ret = -EINVAL; |
| 2882 | goto exit; |
| 2883 | } |
| 2884 | |
| 2885 | /* if the target bssid is different from currently associated AP, |
| 2886 | then no need to send action frame */ |
| 2887 | if (VOS_TRUE != vos_mem_compare(targetApBssid, |
| 2888 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 2889 | { |
| 2890 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__); |
| 2891 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2892 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2893 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2894 | goto exit; |
| 2895 | } |
| 2896 | |
| 2897 | /* if the channel number is different from operating channel then |
| 2898 | no need to send action frame */ |
| 2899 | if (channel != pHddStaCtx->conn_info.operationChannel) |
| 2900 | { |
| 2901 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2902 | "%s: channel(%d) is different from operating channel(%d)", |
| 2903 | __func__, channel, pHddStaCtx->conn_info.operationChannel); |
| 2904 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2905 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2906 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2907 | goto exit; |
| 2908 | } |
| 2909 | chan.center_freq = sme_ChnToFreq(channel); |
| 2910 | |
| 2911 | finalLen = bufLen + 24; |
| 2912 | finalBuf = vos_mem_malloc(finalLen); |
| 2913 | if (NULL == finalBuf) |
| 2914 | { |
| 2915 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__); |
| 2916 | ret = -ENOMEM; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2917 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2918 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2919 | goto exit; |
| 2920 | } |
| 2921 | vos_mem_zero(finalBuf, finalLen); |
| 2922 | |
| 2923 | /* Fill subtype */ |
| 2924 | temp = SIR_MAC_MGMT_ACTION << 4; |
| 2925 | vos_mem_copy(finalBuf + 0, &temp, sizeof(temp)); |
| 2926 | |
| 2927 | /* Fill type */ |
| 2928 | temp = SIR_MAC_MGMT_FRAME; |
| 2929 | vos_mem_copy(finalBuf + 2, &temp, sizeof(temp)); |
| 2930 | |
| 2931 | /* Fill destination address (bssid of the AP) */ |
| 2932 | vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid)); |
| 2933 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 2934 | /* Fill source address (STA mac address) */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2935 | vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes)); |
| 2936 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 2937 | /* Fill BSSID (AP mac address) */ |
| 2938 | vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid)); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2939 | |
| 2940 | /* Fill received buffer from 24th address */ |
| 2941 | vos_mem_copy(finalBuf + 24, buf, bufLen); |
| 2942 | |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2943 | /* done with the parsed buffer */ |
| 2944 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2945 | buf = NULL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2946 | |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 2947 | wlan_hdd_mgmt_tx( NULL, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2948 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2949 | &(pAdapter->wdev), |
| 2950 | #else |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2951 | pAdapter->dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2952 | #endif |
| 2953 | &chan, 0, |
| 2954 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 2955 | NL80211_CHAN_HT20, 1, |
| 2956 | #endif |
| 2957 | dwellTime, finalBuf, finalLen, 1, |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2958 | 1, &cookie ); |
| 2959 | vos_mem_free(finalBuf); |
| 2960 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2961 | else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2962 | { |
| 2963 | tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal)); |
| 2964 | char extra[32]; |
| 2965 | tANI_U8 len = 0; |
| 2966 | |
| 2967 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2968 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2969 | "GETROAMSCANCHANNELMINTIME", val); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2970 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2971 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
| 2972 | pAdapter->sessionId, val)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2973 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2974 | { |
| 2975 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2976 | "%s: failed to copy data to user buffer", __func__); |
| 2977 | ret = -EFAULT; |
| 2978 | goto exit; |
| 2979 | } |
| 2980 | } |
| 2981 | else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0) |
| 2982 | { |
| 2983 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2984 | tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2985 | |
| 2986 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 2987 | value = value + 19; |
| 2988 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2989 | ret = kstrtou16(value, 10, &maxTime); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2990 | if (ret < 0) |
| 2991 | { |
| 2992 | /* 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] | 2993 | kstrtou16 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2994 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2995 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2996 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 2997 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 2998 | ret = -EINVAL; |
| 2999 | goto exit; |
| 3000 | } |
| 3001 | |
| 3002 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 3003 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) |
| 3004 | { |
| 3005 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3006 | "lfr mode value %d is out of range" |
| 3007 | " (Min: %d Max: %d)", maxTime, |
| 3008 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3009 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 3010 | ret = -EINVAL; |
| 3011 | goto exit; |
| 3012 | } |
| 3013 | |
| 3014 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3015 | "%s: Received Command to change channel max time = %d", __func__, maxTime); |
| 3016 | |
| 3017 | pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime; |
| 3018 | sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime); |
| 3019 | } |
| 3020 | else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0) |
| 3021 | { |
| 3022 | tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal)); |
| 3023 | char extra[32]; |
| 3024 | tANI_U8 len = 0; |
| 3025 | |
| 3026 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3027 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3028 | "GETSCANCHANNELTIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3029 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3030 | { |
| 3031 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3032 | "%s: failed to copy data to user buffer", __func__); |
| 3033 | ret = -EFAULT; |
| 3034 | goto exit; |
| 3035 | } |
| 3036 | } |
| 3037 | else if (strncmp(command, "SETSCANHOMETIME", 15) == 0) |
| 3038 | { |
| 3039 | tANI_U8 *value = command; |
| 3040 | tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 3041 | |
| 3042 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 3043 | value = value + 16; |
| 3044 | /* Convert the value from ascii to integer */ |
| 3045 | ret = kstrtou16(value, 10, &val); |
| 3046 | if (ret < 0) |
| 3047 | { |
| 3048 | /* If the input value is greater than max value of datatype, then also |
| 3049 | kstrtou16 fails */ |
| 3050 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3051 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
| 3052 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3053 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3054 | ret = -EINVAL; |
| 3055 | goto exit; |
| 3056 | } |
| 3057 | |
| 3058 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 3059 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) |
| 3060 | { |
| 3061 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3062 | "scan home time value %d is out of range" |
| 3063 | " (Min: %d Max: %d)", val, |
| 3064 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3065 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3066 | ret = -EINVAL; |
| 3067 | goto exit; |
| 3068 | } |
| 3069 | |
| 3070 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3071 | "%s: Received Command to change scan home time = %d", __func__, val); |
| 3072 | |
| 3073 | pHddCtx->cfg_ini->nNeighborScanPeriod = val; |
| 3074 | sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val); |
| 3075 | } |
| 3076 | else if (strncmp(command, "GETSCANHOMETIME", 15) == 0) |
| 3077 | { |
| 3078 | tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3079 | char extra[32]; |
| 3080 | tANI_U8 len = 0; |
| 3081 | |
| 3082 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3083 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3084 | "GETSCANHOMETIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3085 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3086 | { |
| 3087 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3088 | "%s: failed to copy data to user buffer", __func__); |
| 3089 | ret = -EFAULT; |
| 3090 | goto exit; |
| 3091 | } |
| 3092 | } |
| 3093 | else if (strncmp(command, "SETROAMINTRABAND", 16) == 0) |
| 3094 | { |
| 3095 | tANI_U8 *value = command; |
| 3096 | tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 3097 | |
| 3098 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 3099 | value = value + 17; |
| 3100 | /* Convert the value from ascii to integer */ |
| 3101 | ret = kstrtou8(value, 10, &val); |
| 3102 | if (ret < 0) |
| 3103 | { |
| 3104 | /* If the input value is greater than max value of datatype, then also |
| 3105 | kstrtou8 fails */ |
| 3106 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3107 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3108 | CFG_ROAM_INTRA_BAND_MIN, |
| 3109 | CFG_ROAM_INTRA_BAND_MAX); |
| 3110 | ret = -EINVAL; |
| 3111 | goto exit; |
| 3112 | } |
| 3113 | |
| 3114 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 3115 | (val > CFG_ROAM_INTRA_BAND_MAX)) |
| 3116 | { |
| 3117 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3118 | "intra band mode value %d is out of range" |
| 3119 | " (Min: %d Max: %d)", val, |
| 3120 | CFG_ROAM_INTRA_BAND_MIN, |
| 3121 | CFG_ROAM_INTRA_BAND_MAX); |
| 3122 | ret = -EINVAL; |
| 3123 | goto exit; |
| 3124 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3125 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3126 | "%s: Received Command to change intra band = %d", __func__, val); |
| 3127 | |
| 3128 | pHddCtx->cfg_ini->nRoamIntraBand = val; |
| 3129 | sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val); |
| 3130 | } |
| 3131 | else if (strncmp(command, "GETROAMINTRABAND", 16) == 0) |
| 3132 | { |
| 3133 | tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal)); |
| 3134 | char extra[32]; |
| 3135 | tANI_U8 len = 0; |
| 3136 | |
| 3137 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3138 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3139 | "GETROAMINTRABAND", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3140 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3141 | { |
| 3142 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3143 | "%s: failed to copy data to user buffer", __func__); |
| 3144 | ret = -EFAULT; |
| 3145 | goto exit; |
| 3146 | } |
| 3147 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3148 | else if (strncmp(command, "SETSCANNPROBES", 14) == 0) |
| 3149 | { |
| 3150 | tANI_U8 *value = command; |
| 3151 | tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 3152 | |
| 3153 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 3154 | value = value + 15; |
| 3155 | /* Convert the value from ascii to integer */ |
| 3156 | ret = kstrtou8(value, 10, &nProbes); |
| 3157 | if (ret < 0) |
| 3158 | { |
| 3159 | /* If the input value is greater than max value of datatype, then also |
| 3160 | kstrtou8 fails */ |
| 3161 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3162 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3163 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3164 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3165 | ret = -EINVAL; |
| 3166 | goto exit; |
| 3167 | } |
| 3168 | |
| 3169 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 3170 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) |
| 3171 | { |
| 3172 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3173 | "NProbes value %d is out of range" |
| 3174 | " (Min: %d Max: %d)", nProbes, |
| 3175 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3176 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3177 | ret = -EINVAL; |
| 3178 | goto exit; |
| 3179 | } |
| 3180 | |
| 3181 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3182 | "%s: Received Command to Set nProbes = %d", __func__, nProbes); |
| 3183 | |
| 3184 | pHddCtx->cfg_ini->nProbes = nProbes; |
| 3185 | sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes); |
| 3186 | } |
| 3187 | else if (strncmp(priv_data.buf, "GETSCANNPROBES", 14) == 0) |
| 3188 | { |
| 3189 | tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal)); |
| 3190 | char extra[32]; |
| 3191 | tANI_U8 len = 0; |
| 3192 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3193 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3194 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3195 | { |
| 3196 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3197 | "%s: failed to copy data to user buffer", __func__); |
| 3198 | ret = -EFAULT; |
| 3199 | goto exit; |
| 3200 | } |
| 3201 | } |
| 3202 | else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0) |
| 3203 | { |
| 3204 | tANI_U8 *value = command; |
| 3205 | tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 3206 | |
| 3207 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 3208 | /* input value is in units of msec */ |
| 3209 | value = value + 20; |
| 3210 | /* Convert the value from ascii to integer */ |
| 3211 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 3212 | if (ret < 0) |
| 3213 | { |
| 3214 | /* If the input value is greater than max value of datatype, then also |
| 3215 | kstrtou8 fails */ |
| 3216 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3217 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3218 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3219 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3220 | ret = -EINVAL; |
| 3221 | goto exit; |
| 3222 | } |
| 3223 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3224 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 3225 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) |
| 3226 | { |
| 3227 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3228 | "homeAwayTime value %d is out of range" |
| 3229 | " (Min: %d Max: %d)", homeAwayTime, |
| 3230 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3231 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3232 | ret = -EINVAL; |
| 3233 | goto exit; |
| 3234 | } |
| 3235 | |
| 3236 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3237 | "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime); |
Srinivas Girigowda | 6cf0b82 | 2013-06-27 14:00:20 -0700 | [diff] [blame] | 3238 | if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime) |
| 3239 | { |
| 3240 | pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime; |
| 3241 | sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE); |
| 3242 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3243 | } |
| 3244 | else if (strncmp(priv_data.buf, "GETSCANHOMEAWAYTIME", 19) == 0) |
| 3245 | { |
| 3246 | tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal)); |
| 3247 | char extra[32]; |
| 3248 | tANI_U8 len = 0; |
| 3249 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3250 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3251 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3252 | { |
| 3253 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3254 | "%s: failed to copy data to user buffer", __func__); |
| 3255 | ret = -EFAULT; |
| 3256 | goto exit; |
| 3257 | } |
| 3258 | } |
| 3259 | else if (strncmp(command, "REASSOC", 7) == 0) |
| 3260 | { |
| 3261 | tANI_U8 *value = command; |
| 3262 | tANI_U8 channel = 0; |
| 3263 | tSirMacAddr targetApBssid; |
| 3264 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3265 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3266 | tCsrHandoffRequest handoffInfo; |
| 3267 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3268 | hdd_station_ctx_t *pHddStaCtx = NULL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3269 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3270 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3271 | /* if not associated, no need to proceed with reassoc */ |
| 3272 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3273 | { |
| 3274 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3275 | ret = -EINVAL; |
| 3276 | goto exit; |
| 3277 | } |
| 3278 | |
| 3279 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
| 3280 | if (eHAL_STATUS_SUCCESS != status) |
| 3281 | { |
| 3282 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3283 | "%s: Failed to parse reassoc command data", __func__); |
| 3284 | ret = -EINVAL; |
| 3285 | goto exit; |
| 3286 | } |
| 3287 | |
| 3288 | /* if the target bssid is same as currently associated AP, |
| 3289 | then no need to proceed with reassoc */ |
| 3290 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3291 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3292 | { |
| 3293 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__); |
| 3294 | ret = -EINVAL; |
| 3295 | goto exit; |
| 3296 | } |
| 3297 | |
| 3298 | /* Check channel number is a valid channel number */ |
| 3299 | if(VOS_STATUS_SUCCESS != |
| 3300 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3301 | { |
| 3302 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3303 | "%s: Invalid Channel [%d]", __func__, channel); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3304 | return -EINVAL; |
| 3305 | } |
| 3306 | |
| 3307 | /* Proceed with reassoc */ |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3308 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3309 | handoffInfo.channel = channel; |
| 3310 | vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr)); |
| 3311 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 3312 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3313 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3314 | else if (strncmp(command, "SETWESMODE", 10) == 0) |
| 3315 | { |
| 3316 | tANI_U8 *value = command; |
| 3317 | tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 3318 | |
| 3319 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 3320 | value = value + 11; |
| 3321 | /* Convert the value from ascii to integer */ |
| 3322 | ret = kstrtou8(value, 10, &wesMode); |
| 3323 | if (ret < 0) |
| 3324 | { |
| 3325 | /* If the input value is greater than max value of datatype, then also |
| 3326 | kstrtou8 fails */ |
| 3327 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3328 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3329 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3330 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3331 | ret = -EINVAL; |
| 3332 | goto exit; |
| 3333 | } |
| 3334 | |
| 3335 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 3336 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) |
| 3337 | { |
| 3338 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3339 | "WES Mode value %d is out of range" |
| 3340 | " (Min: %d Max: %d)", wesMode, |
| 3341 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3342 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3343 | ret = -EINVAL; |
| 3344 | goto exit; |
| 3345 | } |
| 3346 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3347 | "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode); |
| 3348 | |
| 3349 | pHddCtx->cfg_ini->isWESModeEnabled = wesMode; |
| 3350 | sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode); |
| 3351 | } |
| 3352 | else if (strncmp(priv_data.buf, "GETWESMODE", 10) == 0) |
| 3353 | { |
| 3354 | tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal)); |
| 3355 | char extra[32]; |
| 3356 | tANI_U8 len = 0; |
| 3357 | |
Arif Hussain | 826d941 | 2013-11-12 16:44:54 -0800 | [diff] [blame] | 3358 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3359 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3360 | { |
| 3361 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3362 | "%s: failed to copy data to user buffer", __func__); |
| 3363 | ret = -EFAULT; |
| 3364 | goto exit; |
| 3365 | } |
| 3366 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3367 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3368 | #ifdef FEATURE_WLAN_LFR |
| 3369 | else if (strncmp(command, "SETFASTROAM", 11) == 0) |
| 3370 | { |
| 3371 | tANI_U8 *value = command; |
| 3372 | tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 3373 | |
| 3374 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3375 | value = value + 12; |
| 3376 | /* Convert the value from ascii to integer */ |
| 3377 | ret = kstrtou8(value, 10, &lfrMode); |
| 3378 | if (ret < 0) |
| 3379 | { |
| 3380 | /* If the input value is greater than max value of datatype, then also |
| 3381 | kstrtou8 fails */ |
| 3382 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3383 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3384 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3385 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3386 | ret = -EINVAL; |
| 3387 | goto exit; |
| 3388 | } |
| 3389 | |
| 3390 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 3391 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 3392 | { |
| 3393 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3394 | "lfr mode value %d is out of range" |
| 3395 | " (Min: %d Max: %d)", lfrMode, |
| 3396 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3397 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3398 | ret = -EINVAL; |
| 3399 | goto exit; |
| 3400 | } |
| 3401 | |
| 3402 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3403 | "%s: Received Command to change lfr mode = %d", __func__, lfrMode); |
| 3404 | |
| 3405 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode; |
| 3406 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode); |
| 3407 | } |
| 3408 | #endif |
| 3409 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 3410 | else if (strncmp(command, "SETFASTTRANSITION", 17) == 0) |
| 3411 | { |
| 3412 | tANI_U8 *value = command; |
| 3413 | tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 3414 | |
| 3415 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3416 | value = value + 18; |
| 3417 | /* Convert the value from ascii to integer */ |
| 3418 | ret = kstrtou8(value, 10, &ft); |
| 3419 | if (ret < 0) |
| 3420 | { |
| 3421 | /* If the input value is greater than max value of datatype, then also |
| 3422 | kstrtou8 fails */ |
| 3423 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3424 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3425 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3426 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3427 | ret = -EINVAL; |
| 3428 | goto exit; |
| 3429 | } |
| 3430 | |
| 3431 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 3432 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) |
| 3433 | { |
| 3434 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3435 | "ft mode value %d is out of range" |
| 3436 | " (Min: %d Max: %d)", ft, |
| 3437 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3438 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3439 | ret = -EINVAL; |
| 3440 | goto exit; |
| 3441 | } |
| 3442 | |
| 3443 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3444 | "%s: Received Command to change ft mode = %d", __func__, ft); |
| 3445 | |
| 3446 | pHddCtx->cfg_ini->isFastTransitionEnabled = ft; |
| 3447 | sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft); |
| 3448 | } |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3449 | |
| 3450 | else if (strncmp(command, "FASTREASSOC", 11) == 0) |
| 3451 | { |
| 3452 | tANI_U8 *value = command; |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3453 | tANI_U8 channel = 0; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3454 | tSirMacAddr targetApBssid; |
| 3455 | tANI_U8 trigger = 0; |
| 3456 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3457 | tHalHandle hHal; |
| 3458 | v_U32_t roamId = 0; |
| 3459 | tCsrRoamModifyProfileFields modProfileFields; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3460 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3461 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3462 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3463 | |
| 3464 | /* if not associated, no need to proceed with reassoc */ |
| 3465 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3466 | { |
| 3467 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3468 | ret = -EINVAL; |
| 3469 | goto exit; |
| 3470 | } |
| 3471 | |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3472 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3473 | if (eHAL_STATUS_SUCCESS != status) |
| 3474 | { |
| 3475 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3476 | "%s: Failed to parse reassoc command data", __func__); |
| 3477 | ret = -EINVAL; |
| 3478 | goto exit; |
| 3479 | } |
| 3480 | |
| 3481 | /* if the target bssid is same as currently associated AP, |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3482 | issue reassoc to same AP */ |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3483 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3484 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3485 | { |
| 3486 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3487 | "%s:11r Reassoc BSSID is same as currently associated AP bssid", |
| 3488 | __func__); |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3489 | sme_GetModifyProfileFields(hHal, pAdapter->sessionId, |
| 3490 | &modProfileFields); |
| 3491 | sme_RoamReassoc(hHal, pAdapter->sessionId, |
| 3492 | NULL, modProfileFields, &roamId, 1); |
| 3493 | return 0; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3494 | } |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 3495 | |
| 3496 | /* Check channel number is a valid channel number */ |
| 3497 | if(VOS_STATUS_SUCCESS != |
| 3498 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3499 | { |
| 3500 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3501 | "%s: Invalid Channel [%d]", __func__, channel); |
| 3502 | return -EINVAL; |
| 3503 | } |
| 3504 | |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3505 | trigger = eSME_ROAM_TRIGGER_SCAN; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3506 | |
| 3507 | /* Proceed with scan/roam */ |
| 3508 | smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3509 | &targetApBssid[0], |
| 3510 | (tSmeFastRoamTrigger)(trigger)); |
| 3511 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3512 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3513 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3514 | else if (strncmp(command, "SETCCXMODE", 10) == 0) |
| 3515 | { |
| 3516 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3517 | tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3518 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3519 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3520 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3521 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3522 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3523 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3524 | { |
| 3525 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3526 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3527 | " hence this operation is not permitted!", __func__); |
| 3528 | ret = -EPERM; |
| 3529 | goto exit; |
| 3530 | } |
| 3531 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3532 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 3533 | value = value + 11; |
| 3534 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3535 | ret = kstrtou8(value, 10, &eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3536 | if (ret < 0) |
| 3537 | { |
| 3538 | /* If the input value is greater than max value of datatype, then also |
| 3539 | kstrtou8 fails */ |
| 3540 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3541 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3542 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3543 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3544 | ret = -EINVAL; |
| 3545 | goto exit; |
| 3546 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3547 | if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) || |
| 3548 | (eseMode > CFG_ESE_FEATURE_ENABLED_MAX)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3549 | { |
| 3550 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3551 | "Ese mode value %d is out of range" |
| 3552 | " (Min: %d Max: %d)", eseMode, |
| 3553 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3554 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3555 | ret = -EINVAL; |
| 3556 | goto exit; |
| 3557 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3558 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3559 | "%s: Received Command to change ese mode = %d", __func__, eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3560 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3561 | pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode; |
| 3562 | sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3563 | } |
| 3564 | #endif |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3565 | else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0) |
| 3566 | { |
| 3567 | tANI_U8 *value = command; |
| 3568 | tANI_BOOLEAN roamScanControl = 0; |
| 3569 | |
| 3570 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 3571 | value = value + 19; |
| 3572 | /* Convert the value from ascii to integer */ |
| 3573 | ret = kstrtou8(value, 10, &roamScanControl); |
| 3574 | if (ret < 0) |
| 3575 | { |
| 3576 | /* If the input value is greater than max value of datatype, then also |
| 3577 | kstrtou8 fails */ |
| 3578 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3579 | "%s: kstrtou8 failed ", __func__); |
| 3580 | ret = -EINVAL; |
| 3581 | goto exit; |
| 3582 | } |
| 3583 | |
| 3584 | if (0 != roamScanControl) |
| 3585 | { |
| 3586 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3587 | "roam scan control invalid value = %d", |
| 3588 | roamScanControl); |
| 3589 | ret = -EINVAL; |
| 3590 | goto exit; |
| 3591 | } |
| 3592 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3593 | "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl); |
| 3594 | |
| 3595 | sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl); |
| 3596 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3597 | #ifdef FEATURE_WLAN_OKC |
| 3598 | else if (strncmp(command, "SETOKCMODE", 10) == 0) |
| 3599 | { |
| 3600 | tANI_U8 *value = command; |
| 3601 | tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 3602 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3603 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3604 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3605 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3606 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3607 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3608 | { |
| 3609 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3610 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3611 | " hence this operation is not permitted!", __func__); |
| 3612 | ret = -EPERM; |
| 3613 | goto exit; |
| 3614 | } |
| 3615 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3616 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 3617 | value = value + 11; |
| 3618 | /* Convert the value from ascii to integer */ |
| 3619 | ret = kstrtou8(value, 10, &okcMode); |
| 3620 | if (ret < 0) |
| 3621 | { |
| 3622 | /* If the input value is greater than max value of datatype, then also |
| 3623 | kstrtou8 fails */ |
| 3624 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3625 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3626 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3627 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3628 | ret = -EINVAL; |
| 3629 | goto exit; |
| 3630 | } |
| 3631 | |
| 3632 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 3633 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) |
| 3634 | { |
| 3635 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3636 | "Okc mode value %d is out of range" |
| 3637 | " (Min: %d Max: %d)", okcMode, |
| 3638 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3639 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3640 | ret = -EINVAL; |
| 3641 | goto exit; |
| 3642 | } |
| 3643 | |
| 3644 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3645 | "%s: Received Command to change okc mode = %d", __func__, okcMode); |
| 3646 | |
| 3647 | pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode; |
| 3648 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3649 | #endif /* FEATURE_WLAN_OKC */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3650 | else if (strncmp(priv_data.buf, "GETROAMSCANCONTROL", 18) == 0) |
| 3651 | { |
| 3652 | tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal)); |
| 3653 | char extra[32]; |
| 3654 | tANI_U8 len = 0; |
| 3655 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3656 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3657 | command, roamScanControl); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3658 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3659 | { |
| 3660 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3661 | "%s: failed to copy data to user buffer", __func__); |
| 3662 | ret = -EFAULT; |
| 3663 | goto exit; |
| 3664 | } |
| 3665 | } |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 3666 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3667 | else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0) |
| 3668 | { |
| 3669 | tANI_U8 filterType = 0; |
| 3670 | tANI_U8 *value = command; |
| 3671 | |
| 3672 | /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */ |
| 3673 | value = value + 22; |
| 3674 | |
| 3675 | /* Convert the value from ascii to integer */ |
| 3676 | ret = kstrtou8(value, 10, &filterType); |
| 3677 | if (ret < 0) |
| 3678 | { |
| 3679 | /* If the input value is greater than max value of datatype, |
| 3680 | * then also kstrtou8 fails |
| 3681 | */ |
| 3682 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3683 | "%s: kstrtou8 failed range ", __func__); |
| 3684 | ret = -EINVAL; |
| 3685 | goto exit; |
| 3686 | } |
| 3687 | |
| 3688 | if (filterType != 0 && filterType != 1) |
| 3689 | { |
| 3690 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3691 | "%s: Accepted Values are 0 and 1 ", __func__); |
| 3692 | ret = -EINVAL; |
| 3693 | goto exit; |
| 3694 | } |
| 3695 | wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType, |
| 3696 | pAdapter->sessionId); |
| 3697 | } |
| 3698 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3699 | else if (strncmp(command, "BTCOEXMODE", 10) == 0 ) |
| 3700 | { |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3701 | char *dhcpPhase; |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 3702 | int ret; |
| 3703 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3704 | dhcpPhase = command + 11; |
| 3705 | if ('1' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3706 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 3707 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3708 | FL("send DHCP START indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3709 | |
| 3710 | pHddCtx->btCoexModeSet = TRUE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3711 | |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 3712 | ret = wlan_hdd_scan_abort(pAdapter); |
| 3713 | if (ret < 0) |
| 3714 | { |
| 3715 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3716 | FL("failed to abort existing scan %d"), ret); |
| 3717 | } |
| 3718 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3719 | sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode, |
| 3720 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3721 | } |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3722 | else if ('2' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3723 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 3724 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3725 | FL("send DHCP STOP indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3726 | |
| 3727 | pHddCtx->btCoexModeSet = FALSE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3728 | |
| 3729 | sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode, |
| 3730 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3731 | } |
| 3732 | } |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3733 | else if (strncmp(command, "SCAN-ACTIVE", 11) == 0) |
| 3734 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3735 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3736 | FL("making default scan to ACTIVE")); |
| 3737 | pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3738 | } |
| 3739 | else if (strncmp(command, "SCAN-PASSIVE", 12) == 0) |
| 3740 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3741 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3742 | FL("making default scan to PASSIVE")); |
| 3743 | pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3744 | } |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3745 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 3746 | { |
| 3747 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 3748 | char extra[32]; |
| 3749 | tANI_U8 len = 0; |
| 3750 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3751 | memset(extra, 0, sizeof(extra)); |
| 3752 | ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len); |
| 3753 | if (ret != 0 || copy_to_user(priv_data.buf, &extra, len + 1)) |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3754 | { |
| 3755 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3756 | "%s: failed to copy data to user buffer", __func__); |
| 3757 | ret = -EFAULT; |
| 3758 | goto exit; |
| 3759 | } |
| 3760 | ret = len; |
| 3761 | } |
| 3762 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 3763 | { |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3764 | ret = hdd_set_dwell_time(pAdapter, command); |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3765 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3766 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 3767 | { |
| 3768 | tANI_U8 filterType = 0; |
| 3769 | tANI_U8 *value; |
| 3770 | value = command + 9; |
| 3771 | |
| 3772 | /* Convert the value from ascii to integer */ |
| 3773 | ret = kstrtou8(value, 10, &filterType); |
| 3774 | if (ret < 0) |
| 3775 | { |
| 3776 | /* If the input value is greater than max value of datatype, |
| 3777 | * then also kstrtou8 fails |
| 3778 | */ |
| 3779 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3780 | "%s: kstrtou8 failed range ", __func__); |
| 3781 | ret = -EINVAL; |
| 3782 | goto exit; |
| 3783 | } |
| 3784 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 3785 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 3786 | { |
| 3787 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3788 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 3789 | " 2-Sink ", __func__); |
| 3790 | ret = -EINVAL; |
| 3791 | goto exit; |
| 3792 | } |
| 3793 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 3794 | pHddCtx->drvr_miracast = filterType; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3795 | pScanInfo = &pHddCtx->scan_info; |
| 3796 | if (filterType && pScanInfo != NULL && |
| 3797 | pHddCtx->scan_info.mScanPending) |
| 3798 | { |
| 3799 | /*Miracast Session started. Abort Scan */ |
| 3800 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3801 | "%s, Aborting Scan For Miracast",__func__); |
| 3802 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 3803 | eCSR_SCAN_ABORT_DEFAULT); |
| 3804 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3805 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
Ganesh Kondabattini | 8f6e3b3 | 2014-08-25 16:07:54 +0530 | [diff] [blame] | 3806 | sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast); |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3807 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3808 | else if (strncmp(command, "SETMCRATE", 9) == 0) |
| 3809 | { |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3810 | tANI_U8 *value = command; |
| 3811 | int targetRate; |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3812 | tSirRateUpdateInd *rateUpdate; |
| 3813 | eHalStatus status; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3814 | |
| 3815 | /* Only valid for SAP mode */ |
| 3816 | if (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
| 3817 | { |
| 3818 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3819 | "%s: SAP mode is not running", __func__); |
| 3820 | ret = -EFAULT; |
| 3821 | goto exit; |
| 3822 | } |
| 3823 | |
| 3824 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 3825 | /* input value is in units of hundred kbps */ |
| 3826 | value = value + 10; |
| 3827 | /* Convert the value from ascii to integer, decimal base */ |
| 3828 | ret = kstrtouint(value, 10, &targetRate); |
| 3829 | |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3830 | rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 3831 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3832 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3833 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3834 | "%s: SETMCRATE indication alloc fail", __func__); |
| 3835 | ret = -EFAULT; |
| 3836 | goto exit; |
| 3837 | } |
| 3838 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 3839 | |
| 3840 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3841 | "MC Target rate %d", targetRate); |
| 3842 | /* Ignore unicast */ |
| 3843 | rateUpdate->ucastDataRate = -1; |
| 3844 | rateUpdate->mcastDataRate24GHz = targetRate; |
| 3845 | rateUpdate->mcastDataRate5GHz = targetRate; |
| 3846 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 3847 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 3848 | status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate); |
| 3849 | if (eHAL_STATUS_SUCCESS != status) |
| 3850 | { |
| 3851 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3852 | "%s: SET_MC_RATE failed", __func__); |
| 3853 | vos_mem_free(rateUpdate); |
| 3854 | ret = -EFAULT; |
| 3855 | goto exit; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3856 | } |
| 3857 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3858 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3859 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3860 | { |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3861 | ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3862 | } |
| 3863 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3864 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3865 | else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0) |
| 3866 | { |
| 3867 | tANI_U8 *value = command; |
| 3868 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3869 | tANI_U8 numChannels = 0; |
| 3870 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3871 | |
| 3872 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 3873 | if (eHAL_STATUS_SUCCESS != status) |
| 3874 | { |
| 3875 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3876 | "%s: Failed to parse channel list information", __func__); |
| 3877 | ret = -EINVAL; |
| 3878 | goto exit; |
| 3879 | } |
| 3880 | |
| 3881 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 3882 | { |
| 3883 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3884 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 3885 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3886 | ret = -EINVAL; |
| 3887 | goto exit; |
| 3888 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3889 | status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal), |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3890 | ChannelList, |
| 3891 | numChannels); |
| 3892 | if (eHAL_STATUS_SUCCESS != status) |
| 3893 | { |
| 3894 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3895 | "%s: Failed to update channel list information", __func__); |
| 3896 | ret = -EINVAL; |
| 3897 | goto exit; |
| 3898 | } |
| 3899 | } |
| 3900 | else if (strncmp(command, "GETTSMSTATS", 11) == 0) |
| 3901 | { |
| 3902 | tANI_U8 *value = command; |
| 3903 | char extra[128] = {0}; |
| 3904 | int len = 0; |
| 3905 | tANI_U8 tid = 0; |
| 3906 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3907 | tAniTrafStrmMetrics tsmMetrics; |
| 3908 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3909 | |
| 3910 | /* if not associated, return error */ |
| 3911 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3912 | { |
| 3913 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__); |
| 3914 | ret = -EINVAL; |
| 3915 | goto exit; |
| 3916 | } |
| 3917 | |
| 3918 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 3919 | value = value + 12; |
| 3920 | /* Convert the value from ascii to integer */ |
| 3921 | ret = kstrtou8(value, 10, &tid); |
| 3922 | if (ret < 0) |
| 3923 | { |
| 3924 | /* If the input value is greater than max value of datatype, then also |
| 3925 | kstrtou8 fails */ |
| 3926 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3927 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3928 | TID_MIN_VALUE, |
| 3929 | TID_MAX_VALUE); |
| 3930 | ret = -EINVAL; |
| 3931 | goto exit; |
| 3932 | } |
| 3933 | |
| 3934 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) |
| 3935 | { |
| 3936 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3937 | "tid value %d is out of range" |
| 3938 | " (Min: %d Max: %d)", tid, |
| 3939 | TID_MIN_VALUE, |
| 3940 | TID_MAX_VALUE); |
| 3941 | ret = -EINVAL; |
| 3942 | goto exit; |
| 3943 | } |
| 3944 | |
| 3945 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3946 | "%s: Received Command to get tsm stats tid = %d", __func__, tid); |
| 3947 | |
| 3948 | if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics)) |
| 3949 | { |
| 3950 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3951 | "%s: failed to get tsm stats", __func__); |
| 3952 | ret = -EFAULT; |
| 3953 | goto exit; |
| 3954 | } |
| 3955 | |
| 3956 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3957 | "UplinkPktQueueDly(%d)\n" |
| 3958 | "UplinkPktQueueDlyHist[0](%d)\n" |
| 3959 | "UplinkPktQueueDlyHist[1](%d)\n" |
| 3960 | "UplinkPktQueueDlyHist[2](%d)\n" |
| 3961 | "UplinkPktQueueDlyHist[3](%d)\n" |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 3962 | "UplinkPktTxDly(%u)\n" |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3963 | "UplinkPktLoss(%d)\n" |
| 3964 | "UplinkPktCount(%d)\n" |
| 3965 | "RoamingCount(%d)\n" |
| 3966 | "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly, |
| 3967 | tsmMetrics.UplinkPktQueueDlyHist[0], |
| 3968 | tsmMetrics.UplinkPktQueueDlyHist[1], |
| 3969 | tsmMetrics.UplinkPktQueueDlyHist[2], |
| 3970 | tsmMetrics.UplinkPktQueueDlyHist[3], |
| 3971 | tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss, |
| 3972 | tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly); |
| 3973 | |
| 3974 | /* Output TSM stats is of the format |
| 3975 | GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 3976 | eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */ |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3977 | 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] | 3978 | tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0], |
| 3979 | tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2], |
| 3980 | tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly, |
| 3981 | tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, |
| 3982 | tsmMetrics.RoamingDly); |
| 3983 | |
| 3984 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3985 | { |
| 3986 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3987 | "%s: failed to copy data to user buffer", __func__); |
| 3988 | ret = -EFAULT; |
| 3989 | goto exit; |
| 3990 | } |
| 3991 | } |
| 3992 | else if (strncmp(command, "SETCCKMIE", 9) == 0) |
| 3993 | { |
| 3994 | tANI_U8 *value = command; |
| 3995 | tANI_U8 *cckmIe = NULL; |
| 3996 | tANI_U8 cckmIeLen = 0; |
| 3997 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3998 | |
| 3999 | status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 4000 | if (eHAL_STATUS_SUCCESS != status) |
| 4001 | { |
| 4002 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4003 | "%s: Failed to parse cckm ie data", __func__); |
| 4004 | ret = -EINVAL; |
| 4005 | goto exit; |
| 4006 | } |
| 4007 | |
| 4008 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) |
| 4009 | { |
| 4010 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4011 | "%s: CCKM Ie input length is more than max[%d]", __func__, |
| 4012 | DOT11F_IE_RSN_MAX_LEN); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4013 | vos_mem_free(cckmIe); |
| 4014 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4015 | ret = -EINVAL; |
| 4016 | goto exit; |
| 4017 | } |
| 4018 | sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4019 | vos_mem_free(cckmIe); |
| 4020 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4021 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4022 | else if (strncmp(command, "CCXBEACONREQ", 12) == 0) |
| 4023 | { |
| 4024 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4025 | tCsrEseBeaconReq eseBcnReq; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4026 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 4027 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4028 | status = hdd_parse_ese_beacon_req(value, &eseBcnReq); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4029 | if (eHAL_STATUS_SUCCESS != status) |
| 4030 | { |
| 4031 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4032 | "%s: Failed to parse ese beacon req", __func__); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4033 | ret = -EINVAL; |
| 4034 | goto exit; |
| 4035 | } |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 4036 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 4037 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated")); |
| 4038 | hdd_indicateEseBcnReportNoResults (pAdapter, |
| 4039 | eseBcnReq.bcnReq[0].measurementToken, |
| 4040 | 0x02, //BIT(1) set for measurement done |
| 4041 | 0); // no BSS |
| 4042 | goto exit; |
| 4043 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4044 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4045 | status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq); |
| 4046 | if (eHAL_STATUS_SUCCESS != status) |
| 4047 | { |
| 4048 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4049 | "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status); |
| 4050 | ret = -EINVAL; |
| 4051 | goto exit; |
| 4052 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4053 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4054 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 4055 | else if (strncmp(command, "GETBCNMISSRATE", 14) == 0) |
| 4056 | { |
| 4057 | eHalStatus status; |
| 4058 | char buf[32], len; |
| 4059 | long waitRet; |
| 4060 | bcnMissRateContext_t getBcnMissRateCtx; |
| 4061 | |
| 4062 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4063 | |
| 4064 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 4065 | { |
| 4066 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4067 | FL("GETBCNMISSRATE: STA is not in connected state")); |
| 4068 | ret = -1; |
| 4069 | goto exit; |
| 4070 | } |
| 4071 | |
| 4072 | init_completion(&(getBcnMissRateCtx.completion)); |
| 4073 | getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC; |
| 4074 | |
| 4075 | status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal), |
| 4076 | pAdapter->sessionId, |
| 4077 | (void *)getBcnMissRateCB, |
| 4078 | (void *)(&getBcnMissRateCtx)); |
| 4079 | if( eHAL_STATUS_SUCCESS != status) |
| 4080 | { |
| 4081 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4082 | FL("GETBCNMISSRATE: fail to post WDA cmd")); |
| 4083 | ret = -EINVAL; |
| 4084 | goto exit; |
| 4085 | } |
| 4086 | |
| 4087 | waitRet = wait_for_completion_interruptible_timeout |
| 4088 | (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME); |
| 4089 | if(waitRet <= 0) |
| 4090 | { |
| 4091 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4092 | FL("failed to wait on bcnMissRateComp %d"), ret); |
| 4093 | |
| 4094 | //Make magic number to zero so that callback is not called. |
| 4095 | spin_lock(&hdd_context_lock); |
| 4096 | getBcnMissRateCtx.magic = 0x0; |
| 4097 | spin_unlock(&hdd_context_lock); |
| 4098 | ret = -EINVAL; |
| 4099 | goto exit; |
| 4100 | } |
| 4101 | |
| 4102 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4103 | FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate); |
| 4104 | |
| 4105 | len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate); |
| 4106 | if (copy_to_user(priv_data.buf, &buf, len + 1)) |
| 4107 | { |
| 4108 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4109 | "%s: failed to copy data to user buffer", __func__); |
| 4110 | ret = -EFAULT; |
| 4111 | goto exit; |
| 4112 | } |
| 4113 | ret = len; |
| 4114 | } |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 4115 | #ifdef FEATURE_WLAN_TDLS |
| 4116 | else if (strncmp(command, "TDLSSECONDARYCHANNELOFFSET", 26) == 0) { |
| 4117 | tANI_U8 *value = command; |
| 4118 | int set_value; |
| 4119 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 4120 | value += 26; |
| 4121 | sscanf(value, "%d", &set_value); |
| 4122 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4123 | "%s: Tdls offchannel offset:%d", |
| 4124 | __func__, set_value); |
| 4125 | ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value); |
| 4126 | if (ret < 0) |
| 4127 | { |
| 4128 | ret = -EINVAL; |
| 4129 | goto exit; |
| 4130 | } |
| 4131 | |
| 4132 | } else if (strncmp(command, "TDLSOFFCHANNELMODE", 18) == 0) { |
| 4133 | tANI_U8 *value = command; |
| 4134 | int set_value; |
| 4135 | /* Move pointer to ahead of tdlsoffchnmode*/ |
| 4136 | value += 18; |
| 4137 | sscanf(value, "%d", &set_value); |
| 4138 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4139 | "%s: Tdls offchannel mode:%d", |
| 4140 | __func__, set_value); |
| 4141 | ret = iw_set_tdlsoffchannelmode(pAdapter, set_value); |
| 4142 | if (ret < 0) |
| 4143 | { |
| 4144 | ret = -EINVAL; |
| 4145 | goto exit; |
| 4146 | } |
| 4147 | } else if (strncmp(command, "TDLSOFFCHANNEL", 14) == 0) { |
| 4148 | tANI_U8 *value = command; |
| 4149 | int set_value; |
| 4150 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 4151 | value += 14; |
| 4152 | sscanf(value, "%d", &set_value); |
| 4153 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4154 | "%s: Tdls offchannel num: %d", |
| 4155 | __func__, set_value); |
| 4156 | ret = iw_set_tdlsoffchannel(pHddCtx, set_value); |
| 4157 | if (ret < 0) |
| 4158 | { |
| 4159 | ret = -EINVAL; |
| 4160 | goto exit; |
| 4161 | } |
| 4162 | } |
| 4163 | #endif |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4164 | else { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4165 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4166 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 4167 | pAdapter->sessionId, 0)); |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4168 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s", |
| 4169 | __func__, command); |
| 4170 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4171 | } |
| 4172 | exit: |
| 4173 | if (command) |
| 4174 | { |
| 4175 | kfree(command); |
| 4176 | } |
| 4177 | return ret; |
| 4178 | } |
| 4179 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4180 | #ifdef CONFIG_COMPAT |
| 4181 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4182 | { |
| 4183 | struct { |
| 4184 | compat_uptr_t buf; |
| 4185 | int used_len; |
| 4186 | int total_len; |
| 4187 | } compat_priv_data; |
| 4188 | hdd_priv_data_t priv_data; |
| 4189 | int ret = 0; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4190 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4191 | /* |
| 4192 | * Note that pAdapter and ifr have already been verified by caller, |
| 4193 | * and HDD context has also been validated |
| 4194 | */ |
| 4195 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 4196 | sizeof(compat_priv_data))) { |
| 4197 | ret = -EFAULT; |
| 4198 | goto exit; |
| 4199 | } |
| 4200 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 4201 | priv_data.used_len = compat_priv_data.used_len; |
| 4202 | priv_data.total_len = compat_priv_data.total_len; |
| 4203 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4204 | exit: |
| 4205 | return ret; |
| 4206 | } |
| 4207 | #else /* CONFIG_COMPAT */ |
| 4208 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4209 | { |
| 4210 | /* will never be invoked */ |
| 4211 | return 0; |
| 4212 | } |
| 4213 | #endif /* CONFIG_COMPAT */ |
| 4214 | |
| 4215 | static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4216 | { |
| 4217 | hdd_priv_data_t priv_data; |
| 4218 | int ret = 0; |
| 4219 | |
| 4220 | /* |
| 4221 | * Note that pAdapter and ifr have already been verified by caller, |
| 4222 | * and HDD context has also been validated |
| 4223 | */ |
| 4224 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) { |
| 4225 | ret = -EFAULT; |
| 4226 | } else { |
| 4227 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4228 | } |
| 4229 | return ret; |
| 4230 | } |
| 4231 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 4232 | int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4233 | { |
| 4234 | hdd_adapter_t *pAdapter; |
| 4235 | hdd_context_t *pHddCtx; |
| 4236 | int ret; |
| 4237 | |
| 4238 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4239 | if (NULL == pAdapter) { |
| 4240 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4241 | "%s: HDD adapter context is Null", __func__); |
| 4242 | ret = -ENODEV; |
| 4243 | goto exit; |
| 4244 | } |
| 4245 | if (dev != pAdapter->dev) { |
| 4246 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4247 | "%s: HDD adapter/dev inconsistency", __func__); |
| 4248 | ret = -ENODEV; |
| 4249 | goto exit; |
| 4250 | } |
| 4251 | |
| 4252 | if ((!ifr) || (!ifr->ifr_data)) { |
| 4253 | ret = -EINVAL; |
| 4254 | goto exit; |
| 4255 | } |
| 4256 | |
| 4257 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4258 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4259 | if (ret) { |
Mahesh A Saptasagar | 5b16d0a | 2014-11-03 17:55:29 +0530 | [diff] [blame] | 4260 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4261 | "%s: invalid context", __func__); |
| 4262 | ret = -EBUSY; |
| 4263 | goto exit; |
| 4264 | } |
| 4265 | |
| 4266 | switch (cmd) { |
| 4267 | case (SIOCDEVPRIVATE + 1): |
| 4268 | if (is_compat_task()) |
| 4269 | ret = hdd_driver_compat_ioctl(pAdapter, ifr); |
| 4270 | else |
| 4271 | ret = hdd_driver_ioctl(pAdapter, ifr); |
| 4272 | break; |
| 4273 | default: |
| 4274 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d", |
| 4275 | __func__, cmd); |
| 4276 | ret = -EINVAL; |
| 4277 | break; |
| 4278 | } |
| 4279 | exit: |
| 4280 | return ret; |
| 4281 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4282 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 4283 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 4284 | { |
| 4285 | int ret; |
| 4286 | |
| 4287 | vos_ssr_protect(__func__); |
| 4288 | ret = __hdd_ioctl(dev, ifr, cmd); |
| 4289 | vos_ssr_unprotect(__func__); |
| 4290 | |
| 4291 | return ret; |
| 4292 | } |
| 4293 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4294 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4295 | /**--------------------------------------------------------------------------- |
| 4296 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4297 | \brief hdd_parse_ese_beacon_req() - Parse ese beacon request |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4298 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4299 | This function parses the ese beacon request passed in the format |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4300 | CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 4301 | <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 4302 | <space>Scan Mode N<space>Meas Duration N |
| 4303 | if the Number of bcn req fields (N) does not match with the actual number of fields passed |
| 4304 | then take N. |
| 4305 | <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair |
| 4306 | For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 4307 | This function does not take care of removing duplicate channels from the list |
| 4308 | |
| 4309 | \param - pValue Pointer to data |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4310 | \param - pEseBcnReq output pointer to store parsed ie information |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4311 | |
| 4312 | \return - 0 for success non-zero for failure |
| 4313 | |
| 4314 | --------------------------------------------------------------------------*/ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4315 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 4316 | tCsrEseBeaconReq *pEseBcnReq) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4317 | { |
| 4318 | tANI_U8 *inPtr = pValue; |
| 4319 | int tempInt = 0; |
| 4320 | int j = 0, i = 0, v = 0; |
| 4321 | char buf[32]; |
| 4322 | |
| 4323 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4324 | /*no argument after the command*/ |
| 4325 | if (NULL == inPtr) |
| 4326 | { |
| 4327 | return -EINVAL; |
| 4328 | } |
| 4329 | /*no space after the command*/ |
| 4330 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4331 | { |
| 4332 | return -EINVAL; |
| 4333 | } |
| 4334 | |
| 4335 | /*removing empty spaces*/ |
| 4336 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4337 | |
| 4338 | /*no argument followed by spaces*/ |
| 4339 | if ('\0' == *inPtr) return -EINVAL; |
| 4340 | |
| 4341 | /*getting the first argument ie measurement token*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4342 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4343 | if (1 != v) return -EINVAL; |
| 4344 | |
| 4345 | v = kstrtos32(buf, 10, &tempInt); |
| 4346 | if ( v < 0) return -EINVAL; |
| 4347 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4348 | pEseBcnReq->numBcnReqIe = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4349 | |
| 4350 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4351 | "Number of Bcn Req Ie fields(%d)", pEseBcnReq->numBcnReqIe); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4352 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4353 | for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4354 | { |
| 4355 | for (i = 0; i < 4; i++) |
| 4356 | { |
| 4357 | /*inPtr pointing to the beginning of first space after number of ie fields*/ |
| 4358 | inPtr = strpbrk( inPtr, " " ); |
| 4359 | /*no ie data after the number of ie fields argument*/ |
| 4360 | if (NULL == inPtr) return -EINVAL; |
| 4361 | |
| 4362 | /*removing empty space*/ |
| 4363 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4364 | |
| 4365 | /*no ie data after the number of ie fields argument and spaces*/ |
| 4366 | if ( '\0' == *inPtr ) return -EINVAL; |
| 4367 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4368 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4369 | if (1 != v) return -EINVAL; |
| 4370 | |
| 4371 | v = kstrtos32(buf, 10, &tempInt); |
| 4372 | if (v < 0) return -EINVAL; |
| 4373 | |
| 4374 | switch (i) |
| 4375 | { |
| 4376 | case 0: /* Measurement token */ |
| 4377 | if (tempInt <= 0) |
| 4378 | { |
| 4379 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4380 | "Invalid Measurement Token(%d)", tempInt); |
| 4381 | return -EINVAL; |
| 4382 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4383 | pEseBcnReq->bcnReq[j].measurementToken = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4384 | break; |
| 4385 | |
| 4386 | case 1: /* Channel number */ |
| 4387 | if ((tempInt <= 0) || |
| 4388 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4389 | { |
| 4390 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4391 | "Invalid Channel Number(%d)", tempInt); |
| 4392 | return -EINVAL; |
| 4393 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4394 | pEseBcnReq->bcnReq[j].channel = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4395 | break; |
| 4396 | |
| 4397 | case 2: /* Scan mode */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 4398 | if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE)) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4399 | { |
| 4400 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4401 | "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt); |
| 4402 | return -EINVAL; |
| 4403 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4404 | pEseBcnReq->bcnReq[j].scanMode= tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4405 | break; |
| 4406 | |
| 4407 | case 3: /* Measurement duration */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4408 | if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) || |
| 4409 | ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE))) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4410 | { |
| 4411 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4412 | "Invalid Measurement Duration(%d)", tempInt); |
| 4413 | return -EINVAL; |
| 4414 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4415 | pEseBcnReq->bcnReq[j].measurementDuration = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4416 | break; |
| 4417 | } |
| 4418 | } |
| 4419 | } |
| 4420 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4421 | for (j = 0; j < pEseBcnReq->numBcnReqIe; j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4422 | { |
| 4423 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 4424 | "Index(%d) Measurement Token(%u)Channel(%u) Scan Mode(%u) Measurement Duration(%u)\n", |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4425 | j, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4426 | pEseBcnReq->bcnReq[j].measurementToken, |
| 4427 | pEseBcnReq->bcnReq[j].channel, |
| 4428 | pEseBcnReq->bcnReq[j].scanMode, |
| 4429 | pEseBcnReq->bcnReq[j].measurementDuration); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4430 | } |
| 4431 | |
| 4432 | return VOS_STATUS_SUCCESS; |
| 4433 | } |
| 4434 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4435 | static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext ) |
| 4436 | { |
| 4437 | struct statsContext *pStatsContext = NULL; |
| 4438 | hdd_adapter_t *pAdapter = NULL; |
| 4439 | |
| 4440 | if (NULL == pContext) |
| 4441 | { |
| 4442 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4443 | "%s: Bad param, pContext [%p]", |
| 4444 | __func__, pContext); |
| 4445 | return; |
| 4446 | } |
| 4447 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4448 | /* there is a race condition that exists between this callback |
| 4449 | function and the caller since the caller could time out either |
| 4450 | before or while this code is executing. we use a spinlock to |
| 4451 | serialize these actions */ |
| 4452 | spin_lock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4453 | |
| 4454 | pStatsContext = pContext; |
| 4455 | pAdapter = pStatsContext->pAdapter; |
| 4456 | if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic)) |
| 4457 | { |
| 4458 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4459 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4460 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4461 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 4462 | __func__, pAdapter, pStatsContext->magic); |
| 4463 | return; |
| 4464 | } |
| 4465 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4466 | /* context is valid so caller is still waiting */ |
| 4467 | |
| 4468 | /* paranoia: invalidate the magic */ |
| 4469 | pStatsContext->magic = 0; |
| 4470 | |
| 4471 | /* copy over the tsm stats */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4472 | pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly; |
| 4473 | vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4474 | tsmMetrics.UplinkPktQueueDlyHist, |
| 4475 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4476 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4477 | pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly; |
| 4478 | pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss; |
| 4479 | pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount; |
| 4480 | pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount; |
| 4481 | pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly; |
| 4482 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4483 | /* notify the caller */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4484 | complete(&pStatsContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4485 | |
| 4486 | /* serialization is complete */ |
| 4487 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4488 | } |
| 4489 | |
| 4490 | |
| 4491 | |
| 4492 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 4493 | tAniTrafStrmMetrics* pTsmMetrics) |
| 4494 | { |
| 4495 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4496 | eHalStatus hstatus; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4497 | VOS_STATUS vstatus = VOS_STATUS_SUCCESS; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4498 | long lrc; |
| 4499 | struct statsContext context; |
| 4500 | hdd_context_t *pHddCtx = NULL; |
| 4501 | |
| 4502 | if (NULL == pAdapter) |
| 4503 | { |
| 4504 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__); |
| 4505 | return VOS_STATUS_E_FAULT; |
| 4506 | } |
| 4507 | |
| 4508 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4509 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4510 | |
| 4511 | /* we are connected prepare our callback context */ |
| 4512 | init_completion(&context.completion); |
| 4513 | context.pAdapter = pAdapter; |
| 4514 | context.magic = STATS_CONTEXT_MAGIC; |
| 4515 | |
| 4516 | /* query tsm stats */ |
| 4517 | hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB, |
| 4518 | pHddStaCtx->conn_info.staId[ 0 ], |
| 4519 | pHddStaCtx->conn_info.bssId, |
| 4520 | &context, pHddCtx->pvosContext, tid); |
| 4521 | |
| 4522 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 4523 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4524 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics", |
| 4525 | __func__); |
| 4526 | vstatus = VOS_STATUS_E_FAULT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4527 | } |
| 4528 | else |
| 4529 | { |
| 4530 | /* request was sent -- wait for the response */ |
| 4531 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 4532 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4533 | if (lrc <= 0) |
| 4534 | { |
| 4535 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4536 | "%s: SME %s while retrieving statistics", |
| 4537 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4538 | vstatus = VOS_STATUS_E_TIMEOUT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4539 | } |
| 4540 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4541 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4542 | /* either we never sent a request, we sent a request and received a |
| 4543 | response or we sent a request and timed out. if we never sent a |
| 4544 | request or if we sent a request and got a response, we want to |
| 4545 | clear the magic out of paranoia. if we timed out there is a |
| 4546 | race condition such that the callback function could be |
| 4547 | executing at the same time we are. of primary concern is if the |
| 4548 | callback function had already verified the "magic" but had not |
| 4549 | yet set the completion variable when a timeout occurred. we |
| 4550 | serialize these activities by invalidating the magic while |
| 4551 | holding a shared spinlock which will cause us to block if the |
| 4552 | callback is currently executing */ |
| 4553 | spin_lock(&hdd_context_lock); |
| 4554 | context.magic = 0; |
| 4555 | spin_unlock(&hdd_context_lock); |
| 4556 | |
| 4557 | if (VOS_STATUS_SUCCESS == vstatus) |
| 4558 | { |
| 4559 | pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly; |
| 4560 | vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist, |
| 4561 | pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4562 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4563 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4564 | pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly; |
| 4565 | pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss; |
| 4566 | pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount; |
| 4567 | pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount; |
| 4568 | pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly; |
| 4569 | } |
| 4570 | return vstatus; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4571 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4572 | #endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4573 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4574 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4575 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand) |
| 4576 | { |
| 4577 | eCsrBand band = -1; |
| 4578 | sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band); |
| 4579 | switch (band) |
| 4580 | { |
| 4581 | case eCSR_BAND_ALL: |
| 4582 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 4583 | break; |
| 4584 | |
| 4585 | case eCSR_BAND_24: |
| 4586 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 4587 | break; |
| 4588 | |
| 4589 | case eCSR_BAND_5G: |
| 4590 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 4591 | break; |
| 4592 | |
| 4593 | default: |
| 4594 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band); |
| 4595 | *pBand = -1; |
| 4596 | break; |
| 4597 | } |
| 4598 | } |
| 4599 | |
| 4600 | /**--------------------------------------------------------------------------- |
| 4601 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4602 | \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 4603 | |
| 4604 | This function parses the send action frame data passed in the format |
| 4605 | SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 4606 | |
Srinivas Girigowda | 5607685 | 2013-08-20 14:00:50 -0700 | [diff] [blame] | 4607 | \param - pValue Pointer to input data |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4608 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4609 | \param - pChannel Pointer to the Target AP channel |
| 4610 | \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame |
| 4611 | \param - pBuf Pointer to data |
| 4612 | \param - pBufLen Pointer to data length |
| 4613 | |
| 4614 | \return - 0 for success non-zero for failure |
| 4615 | |
| 4616 | --------------------------------------------------------------------------*/ |
| 4617 | VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel, |
| 4618 | tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen) |
| 4619 | { |
| 4620 | tANI_U8 *inPtr = pValue; |
| 4621 | tANI_U8 *dataEnd; |
| 4622 | int tempInt; |
| 4623 | int j = 0; |
| 4624 | int i = 0; |
| 4625 | int v = 0; |
| 4626 | tANI_U8 tempBuf[32]; |
| 4627 | tANI_U8 tempByte = 0; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4628 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 4629 | tANI_U8 macAddress[18]; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4630 | |
| 4631 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4632 | /*no argument after the command*/ |
| 4633 | if (NULL == inPtr) |
| 4634 | { |
| 4635 | return -EINVAL; |
| 4636 | } |
| 4637 | |
| 4638 | /*no space after the command*/ |
| 4639 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4640 | { |
| 4641 | return -EINVAL; |
| 4642 | } |
| 4643 | |
| 4644 | /*removing empty spaces*/ |
| 4645 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4646 | |
| 4647 | /*no argument followed by spaces*/ |
| 4648 | if ('\0' == *inPtr) |
| 4649 | { |
| 4650 | return -EINVAL; |
| 4651 | } |
| 4652 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4653 | v = sscanf(inPtr, "%17s", macAddress); |
| 4654 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4655 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4656 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4657 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4658 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4659 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4660 | |
| 4661 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4662 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4663 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4664 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4665 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4666 | 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] | 4667 | |
| 4668 | /* point to the next argument */ |
| 4669 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4670 | /*no argument after the command*/ |
| 4671 | if (NULL == inPtr) return -EINVAL; |
| 4672 | |
| 4673 | /*removing empty spaces*/ |
| 4674 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4675 | |
| 4676 | /*no argument followed by spaces*/ |
| 4677 | if ('\0' == *inPtr) |
| 4678 | { |
| 4679 | return -EINVAL; |
| 4680 | } |
| 4681 | |
| 4682 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4683 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4684 | if (1 != v) return -EINVAL; |
| 4685 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4686 | v = kstrtos32(tempBuf, 10, &tempInt); |
Agarwal Ashish | 353b3a8 | 2014-04-08 14:55:11 +0530 | [diff] [blame] | 4687 | if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX ) |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4688 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4689 | |
| 4690 | *pChannel = tempInt; |
| 4691 | |
| 4692 | /* point to the next argument */ |
| 4693 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4694 | /*no argument after the command*/ |
| 4695 | if (NULL == inPtr) return -EINVAL; |
| 4696 | /*removing empty spaces*/ |
| 4697 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4698 | |
| 4699 | /*no argument followed by spaces*/ |
| 4700 | if ('\0' == *inPtr) |
| 4701 | { |
| 4702 | return -EINVAL; |
| 4703 | } |
| 4704 | |
| 4705 | /*getting the next argument ie the dwell time */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4706 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4707 | if (1 != v) return -EINVAL; |
| 4708 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4709 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 5a6e067 | 2014-01-09 14:42:57 -0800 | [diff] [blame] | 4710 | if ( v < 0 || tempInt < 0) return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4711 | |
| 4712 | *pDwellTime = tempInt; |
| 4713 | |
| 4714 | /* point to the next argument */ |
| 4715 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4716 | /*no argument after the command*/ |
| 4717 | if (NULL == inPtr) return -EINVAL; |
| 4718 | /*removing empty spaces*/ |
| 4719 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4720 | |
| 4721 | /*no argument followed by spaces*/ |
| 4722 | if ('\0' == *inPtr) |
| 4723 | { |
| 4724 | return -EINVAL; |
| 4725 | } |
| 4726 | |
| 4727 | /* find the length of data */ |
| 4728 | dataEnd = inPtr; |
| 4729 | while(('\0' != *dataEnd) ) |
| 4730 | { |
| 4731 | dataEnd++; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4732 | } |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4733 | *pBufLen = dataEnd - inPtr ; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4734 | if ( *pBufLen <= 0) return -EINVAL; |
| 4735 | |
Srinivas Girigowda | b5ae85d | 2013-06-03 10:51:45 -0700 | [diff] [blame] | 4736 | /* Allocate the number of bytes based on the number of input characters |
| 4737 | whether it is even or odd. |
| 4738 | if the number of input characters are even, then we need N/2 byte. |
| 4739 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 4740 | compensate rounding off. |
| 4741 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 4742 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 4743 | *pBuf = vos_mem_malloc((*pBufLen + 1)/2); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4744 | if (NULL == *pBuf) |
| 4745 | { |
| 4746 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4747 | "%s: vos_mem_alloc failed ", __func__); |
| 4748 | return -EINVAL; |
| 4749 | } |
| 4750 | |
| 4751 | /* the buffer received from the upper layer is character buffer, |
| 4752 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 4753 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 4754 | and f0 in 3rd location */ |
| 4755 | for (i = 0, j = 0; j < *pBufLen; j += 2) |
| 4756 | { |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4757 | if( j+1 == *pBufLen) |
| 4758 | { |
| 4759 | tempByte = hdd_parse_hex(inPtr[j]); |
| 4760 | } |
| 4761 | else |
| 4762 | { |
| 4763 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 4764 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4765 | (*pBuf)[i++] = tempByte; |
| 4766 | } |
| 4767 | *pBufLen = i; |
| 4768 | return VOS_STATUS_SUCCESS; |
| 4769 | } |
| 4770 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4771 | /**--------------------------------------------------------------------------- |
| 4772 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4773 | \brief hdd_parse_channellist() - HDD Parse channel list |
| 4774 | |
| 4775 | This function parses the channel list passed in the format |
| 4776 | 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] | 4777 | if the Number of channels (N) does not match with the actual number of channels passed |
| 4778 | then take the minimum of N and count of (Ch1, Ch2, ...Ch M) |
| 4779 | For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken. |
| 4780 | If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48. |
| 4781 | 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] | 4782 | |
| 4783 | \param - pValue Pointer to input channel list |
| 4784 | \param - ChannelList Pointer to local output array to record channel list |
| 4785 | \param - pNumChannels Pointer to number of roam scan channels |
| 4786 | |
| 4787 | \return - 0 for success non-zero for failure |
| 4788 | |
| 4789 | --------------------------------------------------------------------------*/ |
| 4790 | VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels) |
| 4791 | { |
| 4792 | tANI_U8 *inPtr = pValue; |
| 4793 | int tempInt; |
| 4794 | int j = 0; |
| 4795 | int v = 0; |
| 4796 | char buf[32]; |
| 4797 | |
| 4798 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4799 | /*no argument after the command*/ |
| 4800 | if (NULL == inPtr) |
| 4801 | { |
| 4802 | return -EINVAL; |
| 4803 | } |
| 4804 | |
| 4805 | /*no space after the command*/ |
| 4806 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4807 | { |
| 4808 | return -EINVAL; |
| 4809 | } |
| 4810 | |
| 4811 | /*removing empty spaces*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4812 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4813 | |
| 4814 | /*no argument followed by spaces*/ |
| 4815 | if ('\0' == *inPtr) |
| 4816 | { |
| 4817 | return -EINVAL; |
| 4818 | } |
| 4819 | |
| 4820 | /*getting the first argument ie the number of channels*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4821 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4822 | if (1 != v) return -EINVAL; |
| 4823 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4824 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4825 | if ((v < 0) || |
| 4826 | (tempInt <= 0) || |
| 4827 | (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 4828 | { |
| 4829 | return -EINVAL; |
| 4830 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4831 | |
| 4832 | *pNumChannels = tempInt; |
| 4833 | |
| 4834 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 4835 | "Number of channels are: %d", *pNumChannels); |
| 4836 | |
| 4837 | for (j = 0; j < (*pNumChannels); j++) |
| 4838 | { |
| 4839 | /*inPtr pointing to the beginning of first space after number of channels*/ |
| 4840 | inPtr = strpbrk( inPtr, " " ); |
| 4841 | /*no channel list after the number of channels argument*/ |
| 4842 | if (NULL == inPtr) |
| 4843 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 4844 | if (0 != j) |
| 4845 | { |
| 4846 | *pNumChannels = j; |
| 4847 | return VOS_STATUS_SUCCESS; |
| 4848 | } |
| 4849 | else |
| 4850 | { |
| 4851 | return -EINVAL; |
| 4852 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4853 | } |
| 4854 | |
| 4855 | /*removing empty space*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4856 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4857 | |
| 4858 | /*no channel list after the number of channels argument and spaces*/ |
| 4859 | if ( '\0' == *inPtr ) |
| 4860 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 4861 | if (0 != j) |
| 4862 | { |
| 4863 | *pNumChannels = j; |
| 4864 | return VOS_STATUS_SUCCESS; |
| 4865 | } |
| 4866 | else |
| 4867 | { |
| 4868 | return -EINVAL; |
| 4869 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4870 | } |
| 4871 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4872 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4873 | if (1 != v) return -EINVAL; |
| 4874 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4875 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4876 | if ((v < 0) || |
| 4877 | (tempInt <= 0) || |
| 4878 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4879 | { |
| 4880 | return -EINVAL; |
| 4881 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4882 | pChannelList[j] = tempInt; |
| 4883 | |
| 4884 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 4885 | "Channel %d added to preferred channel list", |
| 4886 | pChannelList[j] ); |
| 4887 | } |
| 4888 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4889 | return VOS_STATUS_SUCCESS; |
| 4890 | } |
| 4891 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4892 | |
| 4893 | /**--------------------------------------------------------------------------- |
| 4894 | |
| 4895 | \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
| 4896 | |
| 4897 | This function parses the reasoc command data passed in the format |
| 4898 | REASSOC<space><bssid><space><channel> |
| 4899 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4900 | \param - pValue Pointer to input data (its a NUL terminated string) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4901 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4902 | \param - pChannel Pointer to the Target AP channel |
| 4903 | |
| 4904 | \return - 0 for success non-zero for failure |
| 4905 | |
| 4906 | --------------------------------------------------------------------------*/ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4907 | VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 4908 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4909 | { |
| 4910 | tANI_U8 *inPtr = pValue; |
| 4911 | int tempInt; |
| 4912 | int v = 0; |
| 4913 | tANI_U8 tempBuf[32]; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 4914 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4915 | tANI_U8 macAddress[18]; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4916 | |
| 4917 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4918 | /*no argument after the command*/ |
| 4919 | if (NULL == inPtr) |
| 4920 | { |
| 4921 | return -EINVAL; |
| 4922 | } |
| 4923 | |
| 4924 | /*no space after the command*/ |
| 4925 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4926 | { |
| 4927 | return -EINVAL; |
| 4928 | } |
| 4929 | |
| 4930 | /*removing empty spaces*/ |
| 4931 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4932 | |
| 4933 | /*no argument followed by spaces*/ |
| 4934 | if ('\0' == *inPtr) |
| 4935 | { |
| 4936 | return -EINVAL; |
| 4937 | } |
| 4938 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4939 | v = sscanf(inPtr, "%17s", macAddress); |
| 4940 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4941 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4942 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4943 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4944 | return -EINVAL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4945 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4946 | |
| 4947 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4948 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4949 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4950 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4951 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4952 | 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] | 4953 | |
| 4954 | /* point to the next argument */ |
| 4955 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4956 | /*no argument after the command*/ |
| 4957 | if (NULL == inPtr) return -EINVAL; |
| 4958 | |
| 4959 | /*removing empty spaces*/ |
| 4960 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4961 | |
| 4962 | /*no argument followed by spaces*/ |
| 4963 | if ('\0' == *inPtr) |
| 4964 | { |
| 4965 | return -EINVAL; |
| 4966 | } |
| 4967 | |
| 4968 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4969 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4970 | if (1 != v) return -EINVAL; |
| 4971 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4972 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4973 | if ((v < 0) || |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 4974 | (tempInt < 0) || |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4975 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4976 | { |
| 4977 | return -EINVAL; |
| 4978 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4979 | |
| 4980 | *pChannel = tempInt; |
| 4981 | return VOS_STATUS_SUCCESS; |
| 4982 | } |
| 4983 | |
| 4984 | #endif |
| 4985 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4986 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4987 | /**--------------------------------------------------------------------------- |
| 4988 | |
| 4989 | \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 4990 | |
| 4991 | This function parses the SETCCKM IE command |
| 4992 | SETCCKMIE<space><ie data> |
| 4993 | |
| 4994 | \param - pValue Pointer to input data |
| 4995 | \param - pCckmIe Pointer to output cckm Ie |
| 4996 | \param - pCckmIeLen Pointer to output cckm ie length |
| 4997 | |
| 4998 | \return - 0 for success non-zero for failure |
| 4999 | |
| 5000 | --------------------------------------------------------------------------*/ |
| 5001 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, |
| 5002 | tANI_U8 *pCckmIeLen) |
| 5003 | { |
| 5004 | tANI_U8 *inPtr = pValue; |
| 5005 | tANI_U8 *dataEnd; |
| 5006 | int j = 0; |
| 5007 | int i = 0; |
| 5008 | tANI_U8 tempByte = 0; |
| 5009 | |
| 5010 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 5011 | /*no argument after the command*/ |
| 5012 | if (NULL == inPtr) |
| 5013 | { |
| 5014 | return -EINVAL; |
| 5015 | } |
| 5016 | |
| 5017 | /*no space after the command*/ |
| 5018 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 5019 | { |
| 5020 | return -EINVAL; |
| 5021 | } |
| 5022 | |
| 5023 | /*removing empty spaces*/ |
| 5024 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 5025 | |
| 5026 | /*no argument followed by spaces*/ |
| 5027 | if ('\0' == *inPtr) |
| 5028 | { |
| 5029 | return -EINVAL; |
| 5030 | } |
| 5031 | |
| 5032 | /* find the length of data */ |
| 5033 | dataEnd = inPtr; |
| 5034 | while(('\0' != *dataEnd) ) |
| 5035 | { |
| 5036 | dataEnd++; |
| 5037 | ++(*pCckmIeLen); |
| 5038 | } |
| 5039 | if ( *pCckmIeLen <= 0) return -EINVAL; |
| 5040 | |
| 5041 | /* Allocate the number of bytes based on the number of input characters |
| 5042 | whether it is even or odd. |
| 5043 | if the number of input characters are even, then we need N/2 byte. |
| 5044 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 5045 | compensate rounding off. |
| 5046 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 5047 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 5048 | *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2); |
| 5049 | if (NULL == *pCckmIe) |
| 5050 | { |
| 5051 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5052 | "%s: vos_mem_alloc failed ", __func__); |
| 5053 | return -EINVAL; |
| 5054 | } |
| 5055 | vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2); |
| 5056 | /* the buffer received from the upper layer is character buffer, |
| 5057 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 5058 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 5059 | and f0 in 3rd location */ |
| 5060 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) |
| 5061 | { |
| 5062 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 5063 | (*pCckmIe)[i++] = tempByte; |
| 5064 | } |
| 5065 | *pCckmIeLen = i; |
| 5066 | |
| 5067 | return VOS_STATUS_SUCCESS; |
| 5068 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5069 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5070 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5071 | /**--------------------------------------------------------------------------- |
| 5072 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5073 | \brief hdd_is_valid_mac_address() - Validate MAC address |
| 5074 | |
| 5075 | This function validates whether the given MAC address is valid or not |
| 5076 | Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 5077 | where X is the hexa decimal digit character and separated by ':' |
| 5078 | This algorithm works even if MAC address is not separated by ':' |
| 5079 | |
| 5080 | This code checks given input string mac contains exactly 12 hexadecimal digits. |
| 5081 | and a separator colon : appears in the input string only after |
| 5082 | an even number of hex digits. |
| 5083 | |
| 5084 | \param - pMacAddr pointer to the input MAC address |
| 5085 | \return - 1 for valid and 0 for invalid |
| 5086 | |
| 5087 | --------------------------------------------------------------------------*/ |
| 5088 | |
| 5089 | v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr) |
| 5090 | { |
| 5091 | int xdigit = 0; |
| 5092 | int separator = 0; |
| 5093 | while (*pMacAddr) |
| 5094 | { |
| 5095 | if (isxdigit(*pMacAddr)) |
| 5096 | { |
| 5097 | xdigit++; |
| 5098 | } |
| 5099 | else if (':' == *pMacAddr) |
| 5100 | { |
| 5101 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 5102 | break; |
| 5103 | |
| 5104 | ++separator; |
| 5105 | } |
| 5106 | else |
| 5107 | { |
| 5108 | separator = -1; |
| 5109 | /* Invalid MAC found */ |
| 5110 | return 0; |
| 5111 | } |
| 5112 | ++pMacAddr; |
| 5113 | } |
| 5114 | return (xdigit == 12 && (separator == 5 || separator == 0)); |
| 5115 | } |
| 5116 | |
| 5117 | /**--------------------------------------------------------------------------- |
| 5118 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5119 | \brief __hdd_open() - HDD Open function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5120 | |
| 5121 | \param - dev Pointer to net_device structure |
| 5122 | |
| 5123 | \return - 0 for success non-zero for failure |
| 5124 | |
| 5125 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5126 | int __hdd_open(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5127 | { |
| 5128 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5129 | hdd_context_t *pHddCtx; |
| 5130 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 5131 | VOS_STATUS status; |
| 5132 | v_BOOL_t in_standby = TRUE; |
| 5133 | |
| 5134 | if (NULL == pAdapter) |
| 5135 | { |
| 5136 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5137 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5138 | return -ENODEV; |
| 5139 | } |
| 5140 | |
| 5141 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5142 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 5143 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5144 | if (NULL == pHddCtx) |
| 5145 | { |
| 5146 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5147 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5148 | return -ENODEV; |
| 5149 | } |
| 5150 | |
| 5151 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5152 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5153 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5154 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5155 | { |
| 5156 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5157 | __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5158 | in_standby = FALSE; |
| 5159 | break; |
| 5160 | } |
| 5161 | else |
| 5162 | { |
| 5163 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5164 | pAdapterNode = pNext; |
| 5165 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5166 | } |
| 5167 | |
| 5168 | if (TRUE == in_standby) |
| 5169 | { |
| 5170 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 5171 | { |
| 5172 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 5173 | "wlan out of power save", __func__); |
| 5174 | return -EINVAL; |
| 5175 | } |
| 5176 | } |
| 5177 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5178 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5179 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 5180 | { |
| 5181 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5182 | "%s: Enabling Tx Queues", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5183 | /* Enable TX queues only when we are connected */ |
| 5184 | netif_tx_start_all_queues(dev); |
| 5185 | } |
| 5186 | |
| 5187 | return 0; |
| 5188 | } |
| 5189 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5190 | /**--------------------------------------------------------------------------- |
| 5191 | |
| 5192 | \brief hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 5193 | |
| 5194 | This is called in response to ifconfig up |
| 5195 | |
| 5196 | \param - dev Pointer to net_device structure |
| 5197 | |
| 5198 | \return - 0 for success non-zero for failure |
| 5199 | |
| 5200 | --------------------------------------------------------------------------*/ |
| 5201 | int hdd_open(struct net_device *dev) |
| 5202 | { |
| 5203 | int ret; |
| 5204 | |
| 5205 | vos_ssr_protect(__func__); |
| 5206 | ret = __hdd_open(dev); |
| 5207 | vos_ssr_unprotect(__func__); |
| 5208 | |
| 5209 | return ret; |
| 5210 | } |
| 5211 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5212 | int hdd_mon_open (struct net_device *dev) |
| 5213 | { |
| 5214 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5215 | |
| 5216 | if(pAdapter == NULL) { |
| 5217 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5218 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5219 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5220 | } |
| 5221 | |
| 5222 | netif_start_queue(dev); |
| 5223 | |
| 5224 | return 0; |
| 5225 | } |
| 5226 | /**--------------------------------------------------------------------------- |
| 5227 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5228 | \brief __hdd_stop() - HDD stop function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5229 | |
| 5230 | \param - dev Pointer to net_device structure |
| 5231 | |
| 5232 | \return - 0 for success non-zero for failure |
| 5233 | |
| 5234 | --------------------------------------------------------------------------*/ |
| 5235 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5236 | int __hdd_stop (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5237 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5238 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5239 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5240 | hdd_context_t *pHddCtx; |
| 5241 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 5242 | VOS_STATUS status; |
| 5243 | v_BOOL_t enter_standby = TRUE; |
| 5244 | |
| 5245 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5246 | if (NULL == pAdapter) |
| 5247 | { |
| 5248 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5249 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5250 | return -ENODEV; |
| 5251 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5252 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 5253 | pAdapter->sessionId, pAdapter->device_mode)); |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5254 | |
| 5255 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5256 | ret = wlan_hdd_validate_context(pHddCtx); |
| 5257 | if (ret) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5258 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5259 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5260 | "%s: HDD context is not valid!", __func__); |
| 5261 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5262 | } |
| 5263 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5264 | /* Nothing to be done if the interface is not opened */ |
| 5265 | if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) |
| 5266 | { |
| 5267 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5268 | "%s: NETDEV Interface is not OPENED", __func__); |
| 5269 | return -ENODEV; |
| 5270 | } |
| 5271 | |
| 5272 | /* Make sure the interface is marked as closed */ |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5273 | clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5274 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5275 | |
| 5276 | /* Disable TX on the interface, after this hard_start_xmit() will not |
| 5277 | * be called on that interface |
| 5278 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5279 | netif_tx_disable(pAdapter->dev); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5280 | |
| 5281 | /* Mark the interface status as "down" for outside world */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5282 | netif_carrier_off(pAdapter->dev); |
| 5283 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5284 | /* The interface is marked as down for outside world (aka kernel) |
| 5285 | * But the driver is pretty much alive inside. The driver needs to |
| 5286 | * tear down the existing connection on the netdev (session) |
| 5287 | * cleanup the data pipes and wait until the control plane is stabilized |
| 5288 | * for this interface. The call also needs to wait until the above |
| 5289 | * mentioned actions are completed before returning to the caller. |
| 5290 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 5291 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 5292 | */ |
| 5293 | hdd_stop_adapter(pHddCtx, pAdapter, VOS_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5294 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5295 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 5296 | hdd_deinit_adapter(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5297 | /* SoftAP ifaces should never go in power save mode |
| 5298 | making sure same here. */ |
| 5299 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 5300 | || (WLAN_HDD_MONITOR == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5301 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5302 | ) |
| 5303 | { |
| 5304 | /* SoftAP mode, so return from here */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5305 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5306 | "%s: In SAP MODE", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5307 | EXIT(); |
| 5308 | return 0; |
| 5309 | } |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5310 | /* Find if any iface is up. If any iface is up then can't put device to |
| 5311 | * sleep/power save mode |
| 5312 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5313 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5314 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5315 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5316 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5317 | { |
| 5318 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot " |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5319 | "put device to sleep", __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5320 | enter_standby = FALSE; |
| 5321 | break; |
| 5322 | } |
| 5323 | else |
| 5324 | { |
| 5325 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5326 | pAdapterNode = pNext; |
| 5327 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5328 | } |
| 5329 | |
| 5330 | if (TRUE == enter_standby) |
| 5331 | { |
| 5332 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down " |
| 5333 | "entering standby", __func__); |
| 5334 | if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx)) |
| 5335 | { |
| 5336 | /*log and return success*/ |
| 5337 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put " |
| 5338 | "wlan in power save", __func__); |
| 5339 | } |
| 5340 | } |
| 5341 | |
| 5342 | EXIT(); |
| 5343 | return 0; |
| 5344 | } |
| 5345 | |
| 5346 | /**--------------------------------------------------------------------------- |
| 5347 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5348 | \brief hdd_stop() - wrapper_function for __hdd_stop to protect it from SSR |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5349 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5350 | This is called in response to ifconfig down |
| 5351 | |
| 5352 | \param - dev Pointer to net_device structure |
| 5353 | |
| 5354 | \return - 0 for success non-zero for failure |
| 5355 | -----------------------------------------------------------------------------*/ |
| 5356 | int hdd_stop (struct net_device *dev) |
| 5357 | { |
| 5358 | int ret; |
| 5359 | |
| 5360 | vos_ssr_protect(__func__); |
| 5361 | ret = __hdd_stop(dev); |
| 5362 | vos_ssr_unprotect(__func__); |
| 5363 | |
| 5364 | return ret; |
| 5365 | } |
| 5366 | |
| 5367 | /**--------------------------------------------------------------------------- |
| 5368 | |
| 5369 | \brief __hdd_uninit() - HDD uninit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5370 | |
| 5371 | \param - dev Pointer to net_device structure |
| 5372 | |
| 5373 | \return - void |
| 5374 | |
| 5375 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5376 | static void __hdd_uninit (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5377 | { |
| 5378 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5379 | |
| 5380 | ENTER(); |
| 5381 | |
| 5382 | do |
| 5383 | { |
| 5384 | if (NULL == pAdapter) |
| 5385 | { |
| 5386 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5387 | "%s: NULL pAdapter", __func__); |
| 5388 | break; |
| 5389 | } |
| 5390 | |
| 5391 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 5392 | { |
| 5393 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5394 | "%s: Invalid magic", __func__); |
| 5395 | break; |
| 5396 | } |
| 5397 | |
| 5398 | if (NULL == pAdapter->pHddCtx) |
| 5399 | { |
| 5400 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5401 | "%s: NULL pHddCtx", __func__); |
| 5402 | break; |
| 5403 | } |
| 5404 | |
| 5405 | if (dev != pAdapter->dev) |
| 5406 | { |
| 5407 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5408 | "%s: Invalid device reference", __func__); |
| 5409 | /* we haven't validated all cases so let this go for now */ |
| 5410 | } |
| 5411 | |
| 5412 | hdd_deinit_adapter(pAdapter->pHddCtx, pAdapter); |
| 5413 | |
| 5414 | /* after uninit our adapter structure will no longer be valid */ |
| 5415 | pAdapter->dev = NULL; |
| 5416 | pAdapter->magic = 0; |
| 5417 | } while (0); |
| 5418 | |
| 5419 | EXIT(); |
| 5420 | } |
| 5421 | |
| 5422 | /**--------------------------------------------------------------------------- |
| 5423 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5424 | \brief hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 5425 | |
| 5426 | This is called during the netdev unregister to uninitialize all data |
| 5427 | associated with the device |
| 5428 | |
| 5429 | \param - dev Pointer to net_device structure |
| 5430 | |
| 5431 | \return - void |
| 5432 | |
| 5433 | --------------------------------------------------------------------------*/ |
| 5434 | static void hdd_uninit (struct net_device *dev) |
| 5435 | { |
| 5436 | vos_ssr_protect(__func__); |
| 5437 | __hdd_uninit(dev); |
| 5438 | vos_ssr_unprotect(__func__); |
| 5439 | } |
| 5440 | |
| 5441 | /**--------------------------------------------------------------------------- |
| 5442 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5443 | \brief hdd_release_firmware() - |
| 5444 | |
| 5445 | This function calls the release firmware API to free the firmware buffer. |
| 5446 | |
| 5447 | \param - pFileName Pointer to the File Name. |
| 5448 | pCtx - Pointer to the adapter . |
| 5449 | |
| 5450 | |
| 5451 | \return - 0 for success, non zero for failure |
| 5452 | |
| 5453 | --------------------------------------------------------------------------*/ |
| 5454 | |
| 5455 | VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx) |
| 5456 | { |
| 5457 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 5458 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5459 | ENTER(); |
| 5460 | |
| 5461 | |
| 5462 | if (!strcmp(WLAN_FW_FILE, pFileName)) { |
| 5463 | |
| 5464 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName); |
| 5465 | |
| 5466 | if(pHddCtx->fw) { |
| 5467 | release_firmware(pHddCtx->fw); |
| 5468 | pHddCtx->fw = NULL; |
| 5469 | } |
| 5470 | else |
| 5471 | status = VOS_STATUS_E_FAILURE; |
| 5472 | } |
| 5473 | else if (!strcmp(WLAN_NV_FILE,pFileName)) { |
| 5474 | if(pHddCtx->nv) { |
| 5475 | release_firmware(pHddCtx->nv); |
| 5476 | pHddCtx->nv = NULL; |
| 5477 | } |
| 5478 | else |
| 5479 | status = VOS_STATUS_E_FAILURE; |
| 5480 | |
| 5481 | } |
| 5482 | |
| 5483 | EXIT(); |
| 5484 | return status; |
| 5485 | } |
| 5486 | |
| 5487 | /**--------------------------------------------------------------------------- |
| 5488 | |
| 5489 | \brief hdd_request_firmware() - |
| 5490 | |
| 5491 | This function reads the firmware file using the request firmware |
| 5492 | API and returns the the firmware data and the firmware file size. |
| 5493 | |
| 5494 | \param - pfileName - Pointer to the file name. |
| 5495 | - pCtx - Pointer to the adapter . |
| 5496 | - ppfw_data - Pointer to the pointer of the firmware data. |
| 5497 | - pSize - Pointer to the file size. |
| 5498 | |
| 5499 | \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure |
| 5500 | |
| 5501 | --------------------------------------------------------------------------*/ |
| 5502 | |
| 5503 | |
| 5504 | VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize) |
| 5505 | { |
| 5506 | int status; |
| 5507 | VOS_STATUS retval = VOS_STATUS_SUCCESS; |
| 5508 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5509 | ENTER(); |
| 5510 | |
| 5511 | if( (!strcmp(WLAN_FW_FILE, pfileName)) ) { |
| 5512 | |
| 5513 | status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev); |
| 5514 | |
| 5515 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5516 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed", |
| 5517 | __func__, pfileName); |
| 5518 | retval = VOS_STATUS_E_FAILURE; |
| 5519 | } |
| 5520 | |
| 5521 | else { |
| 5522 | *ppfw_data = (v_VOID_t *)pHddCtx->fw->data; |
| 5523 | *pSize = pHddCtx->fw->size; |
| 5524 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d", |
| 5525 | __func__, *pSize); |
| 5526 | } |
| 5527 | } |
| 5528 | else if(!strcmp(WLAN_NV_FILE, pfileName)) { |
| 5529 | |
| 5530 | status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev); |
| 5531 | |
| 5532 | if(status || !pHddCtx->nv || !pHddCtx->nv->data) { |
| 5533 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed", |
| 5534 | __func__, pfileName); |
| 5535 | retval = VOS_STATUS_E_FAILURE; |
| 5536 | } |
| 5537 | |
| 5538 | else { |
| 5539 | *ppfw_data = (v_VOID_t *)pHddCtx->nv->data; |
| 5540 | *pSize = pHddCtx->nv->size; |
| 5541 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d", |
| 5542 | __func__, *pSize); |
| 5543 | } |
| 5544 | } |
| 5545 | |
| 5546 | EXIT(); |
| 5547 | return retval; |
| 5548 | } |
| 5549 | /**--------------------------------------------------------------------------- |
| 5550 | \brief hdd_full_pwr_cbk() - HDD full power callbackfunction |
| 5551 | |
| 5552 | This is the function invoked by SME to inform the result of a full power |
| 5553 | request issued by HDD |
| 5554 | |
| 5555 | \param - callbackcontext - Pointer to cookie |
| 5556 | status - result of request |
| 5557 | |
| 5558 | \return - None |
| 5559 | |
| 5560 | --------------------------------------------------------------------------*/ |
| 5561 | void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status) |
| 5562 | { |
| 5563 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 5564 | |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 5565 | 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] | 5566 | if(&pHddCtx->full_pwr_comp_var) |
| 5567 | { |
| 5568 | complete(&pHddCtx->full_pwr_comp_var); |
| 5569 | } |
| 5570 | } |
| 5571 | |
| 5572 | /**--------------------------------------------------------------------------- |
| 5573 | |
| 5574 | \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function |
| 5575 | |
| 5576 | This is the function invoked by SME to inform the result of BMPS |
| 5577 | request issued by HDD |
| 5578 | |
| 5579 | \param - callbackcontext - Pointer to cookie |
| 5580 | status - result of request |
| 5581 | |
| 5582 | \return - None |
| 5583 | |
| 5584 | --------------------------------------------------------------------------*/ |
| 5585 | void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status) |
| 5586 | { |
| 5587 | |
| 5588 | struct completion *completion_var = (struct completion*) callbackContext; |
| 5589 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5590 | hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5591 | if(completion_var != NULL) |
| 5592 | { |
| 5593 | complete(completion_var); |
| 5594 | } |
| 5595 | } |
| 5596 | |
| 5597 | /**--------------------------------------------------------------------------- |
| 5598 | |
| 5599 | \brief hdd_get_cfg_file_size() - |
| 5600 | |
| 5601 | This function reads the configuration file using the request firmware |
| 5602 | API and returns the configuration file size. |
| 5603 | |
| 5604 | \param - pCtx - Pointer to the adapter . |
| 5605 | - pFileName - Pointer to the file name. |
| 5606 | - pBufSize - Pointer to the buffer size. |
| 5607 | |
| 5608 | \return - 0 for success, non zero for failure |
| 5609 | |
| 5610 | --------------------------------------------------------------------------*/ |
| 5611 | |
| 5612 | VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize) |
| 5613 | { |
| 5614 | int status; |
| 5615 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5616 | |
| 5617 | ENTER(); |
| 5618 | |
| 5619 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5620 | |
| 5621 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5622 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5623 | status = VOS_STATUS_E_FAILURE; |
| 5624 | } |
| 5625 | else { |
| 5626 | *pBufSize = pHddCtx->fw->size; |
| 5627 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize); |
| 5628 | release_firmware(pHddCtx->fw); |
| 5629 | pHddCtx->fw = NULL; |
| 5630 | } |
| 5631 | |
| 5632 | EXIT(); |
| 5633 | return VOS_STATUS_SUCCESS; |
| 5634 | } |
| 5635 | |
| 5636 | /**--------------------------------------------------------------------------- |
| 5637 | |
| 5638 | \brief hdd_read_cfg_file() - |
| 5639 | |
| 5640 | This function reads the configuration file using the request firmware |
| 5641 | API and returns the cfg data and the buffer size of the configuration file. |
| 5642 | |
| 5643 | \param - pCtx - Pointer to the adapter . |
| 5644 | - pFileName - Pointer to the file name. |
| 5645 | - pBuffer - Pointer to the data buffer. |
| 5646 | - pBufSize - Pointer to the buffer size. |
| 5647 | |
| 5648 | \return - 0 for success, non zero for failure |
| 5649 | |
| 5650 | --------------------------------------------------------------------------*/ |
| 5651 | |
| 5652 | VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName, |
| 5653 | v_VOID_t *pBuffer, v_SIZE_t *pBufSize) |
| 5654 | { |
| 5655 | int status; |
| 5656 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5657 | |
| 5658 | ENTER(); |
| 5659 | |
| 5660 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5661 | |
| 5662 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5663 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5664 | return VOS_STATUS_E_FAILURE; |
| 5665 | } |
| 5666 | else { |
| 5667 | if(*pBufSize != pHddCtx->fw->size) { |
| 5668 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG " |
| 5669 | "file size", __func__); |
| 5670 | release_firmware(pHddCtx->fw); |
| 5671 | pHddCtx->fw = NULL; |
| 5672 | return VOS_STATUS_E_FAILURE; |
| 5673 | } |
| 5674 | else { |
| 5675 | if(pBuffer) { |
| 5676 | vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize); |
| 5677 | } |
| 5678 | release_firmware(pHddCtx->fw); |
| 5679 | pHddCtx->fw = NULL; |
| 5680 | } |
| 5681 | } |
| 5682 | |
| 5683 | EXIT(); |
| 5684 | |
| 5685 | return VOS_STATUS_SUCCESS; |
| 5686 | } |
| 5687 | |
| 5688 | /**--------------------------------------------------------------------------- |
| 5689 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5690 | \brief __hdd_set_mac_address() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5691 | |
| 5692 | This function sets the user specified mac address using |
| 5693 | the command ifconfig wlanX hw ether <mac adress>. |
| 5694 | |
| 5695 | \param - dev - Pointer to the net device. |
| 5696 | - addr - Pointer to the sockaddr. |
| 5697 | \return - 0 for success, non zero for failure |
| 5698 | |
| 5699 | --------------------------------------------------------------------------*/ |
| 5700 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5701 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5702 | { |
| 5703 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5704 | struct sockaddr *psta_mac_addr = addr; |
| 5705 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5706 | |
| 5707 | ENTER(); |
| 5708 | |
| 5709 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5710 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 5711 | |
| 5712 | EXIT(); |
| 5713 | return halStatus; |
| 5714 | } |
| 5715 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5716 | /**--------------------------------------------------------------------------- |
| 5717 | |
| 5718 | \brief hdd_set_mac_address() - |
| 5719 | |
| 5720 | Wrapper function to protect __hdd_set_mac_address() function from ssr |
| 5721 | |
| 5722 | \param - dev - Pointer to the net device. |
| 5723 | - addr - Pointer to the sockaddr. |
| 5724 | \return - 0 for success, non zero for failure |
| 5725 | |
| 5726 | --------------------------------------------------------------------------*/ |
| 5727 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 5728 | { |
| 5729 | int ret; |
| 5730 | |
| 5731 | vos_ssr_protect(__func__); |
| 5732 | ret = __hdd_set_mac_address(dev, addr); |
| 5733 | vos_ssr_unprotect(__func__); |
| 5734 | |
| 5735 | return ret; |
| 5736 | } |
| 5737 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5738 | tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx) |
| 5739 | { |
| 5740 | int i; |
| 5741 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5742 | { |
Abhishek Singh | eb18378 | 2014-02-06 13:37:21 +0530 | [diff] [blame] | 5743 | if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5744 | break; |
| 5745 | } |
| 5746 | |
| 5747 | if( VOS_MAX_CONCURRENCY_PERSONA == i) |
| 5748 | return NULL; |
| 5749 | |
| 5750 | pHddCtx->cfg_ini->intfAddrMask |= (1 << i); |
| 5751 | return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0]; |
| 5752 | } |
| 5753 | |
| 5754 | void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr) |
| 5755 | { |
| 5756 | int i; |
| 5757 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5758 | { |
| 5759 | if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) ) |
| 5760 | { |
| 5761 | pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i); |
| 5762 | break; |
| 5763 | } |
| 5764 | } |
| 5765 | return; |
| 5766 | } |
| 5767 | |
| 5768 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 5769 | static struct net_device_ops wlan_drv_ops = { |
| 5770 | .ndo_open = hdd_open, |
| 5771 | .ndo_stop = hdd_stop, |
| 5772 | .ndo_uninit = hdd_uninit, |
| 5773 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 5774 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5775 | .ndo_get_stats = hdd_stats, |
| 5776 | .ndo_do_ioctl = hdd_ioctl, |
| 5777 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5778 | .ndo_select_queue = hdd_select_queue, |
| 5779 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 5780 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) |
| 5781 | .ndo_set_rx_mode = hdd_set_multicast_list, |
| 5782 | #else |
| 5783 | .ndo_set_multicast_list = hdd_set_multicast_list, |
| 5784 | #endif //LINUX_VERSION_CODE |
| 5785 | #endif |
| 5786 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5787 | static struct net_device_ops wlan_mon_drv_ops = { |
| 5788 | .ndo_open = hdd_mon_open, |
| 5789 | .ndo_stop = hdd_stop, |
| 5790 | .ndo_uninit = hdd_uninit, |
| 5791 | .ndo_start_xmit = hdd_mon_hard_start_xmit, |
| 5792 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5793 | .ndo_get_stats = hdd_stats, |
| 5794 | .ndo_do_ioctl = hdd_ioctl, |
| 5795 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5796 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5797 | |
| 5798 | #endif |
| 5799 | |
| 5800 | void hdd_set_station_ops( struct net_device *pWlanDev ) |
| 5801 | { |
| 5802 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5803 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 5804 | #else |
| 5805 | pWlanDev->open = hdd_open; |
| 5806 | pWlanDev->stop = hdd_stop; |
| 5807 | pWlanDev->uninit = hdd_uninit; |
| 5808 | pWlanDev->hard_start_xmit = NULL; |
| 5809 | pWlanDev->tx_timeout = hdd_tx_timeout; |
| 5810 | pWlanDev->get_stats = hdd_stats; |
| 5811 | pWlanDev->do_ioctl = hdd_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5812 | pWlanDev->set_mac_address = hdd_set_mac_address; |
| 5813 | #endif |
| 5814 | } |
| 5815 | |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 5816 | 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] | 5817 | { |
| 5818 | struct net_device *pWlanDev = NULL; |
| 5819 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5820 | /* |
| 5821 | * cfg80211 initialization and registration.... |
| 5822 | */ |
| 5823 | pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, ether_setup, NUM_TX_QUEUES); |
| 5824 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5825 | if(pWlanDev != NULL) |
| 5826 | { |
| 5827 | |
| 5828 | //Save the pointer to the net_device in the HDD adapter |
| 5829 | pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev ); |
| 5830 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5831 | vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) ); |
| 5832 | |
| 5833 | pAdapter->dev = pWlanDev; |
| 5834 | pAdapter->pHddCtx = pHddCtx; |
| 5835 | pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 5836 | spin_lock_init(&pAdapter->lock_for_active_session); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5837 | |
| 5838 | init_completion(&pAdapter->session_open_comp_var); |
| 5839 | init_completion(&pAdapter->session_close_comp_var); |
| 5840 | init_completion(&pAdapter->disconnect_comp_var); |
| 5841 | init_completion(&pAdapter->linkup_event_var); |
| 5842 | init_completion(&pAdapter->cancel_rem_on_chan_var); |
| 5843 | init_completion(&pAdapter->rem_on_chan_ready_event); |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 5844 | init_completion(&pAdapter->pno_comp_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5845 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 5846 | init_completion(&pAdapter->offchannel_tx_event); |
| 5847 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5848 | init_completion(&pAdapter->tx_action_cnf_event); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5849 | #ifdef FEATURE_WLAN_TDLS |
| 5850 | init_completion(&pAdapter->tdls_add_station_comp); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 5851 | init_completion(&pAdapter->tdls_del_station_comp); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 5852 | init_completion(&pAdapter->tdls_mgmt_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 5853 | init_completion(&pAdapter->tdls_link_establish_req_comp); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5854 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5855 | init_completion(&pHddCtx->mc_sus_event_var); |
| 5856 | init_completion(&pHddCtx->tx_sus_event_var); |
Gopichand Nakkala | 0562141 | 2013-06-19 19:37:38 +0530 | [diff] [blame] | 5857 | init_completion(&pHddCtx->rx_sus_event_var); |
Jeff Johnson | 9efb9aa | 2013-03-15 13:59:27 -0700 | [diff] [blame] | 5858 | init_completion(&pAdapter->ula_complete); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 5859 | init_completion(&pAdapter->change_country_code); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5860 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5861 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 5862 | init_completion(&pAdapter->hdd_set_batch_scan_req_var); |
| 5863 | init_completion(&pAdapter->hdd_get_batch_scan_req_var); |
| 5864 | pAdapter->pBatchScanRsp = NULL; |
| 5865 | pAdapter->numScanList = 0; |
Rajeev Kumar | 20140c1 | 2013-10-21 19:39:02 -0700 | [diff] [blame] | 5866 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 5867 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5868 | mutex_init(&pAdapter->hdd_batch_scan_lock); |
| 5869 | #endif |
| 5870 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5871 | pAdapter->isLinkUpSvcNeeded = FALSE; |
| 5872 | pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE; |
| 5873 | //Init the net_device structure |
| 5874 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 5875 | |
| 5876 | vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr)); |
| 5877 | vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr)); |
| 5878 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 5879 | pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM; |
| 5880 | |
| 5881 | hdd_set_station_ops( pAdapter->dev ); |
| 5882 | |
| 5883 | pWlanDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5884 | pWlanDev->ieee80211_ptr = &pAdapter->wdev ; |
| 5885 | pAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 5886 | pAdapter->wdev.netdev = pWlanDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5887 | /* set pWlanDev's parent to underlying device */ |
| 5888 | SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev); |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 5889 | |
| 5890 | hdd_wmm_init( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5891 | } |
| 5892 | |
| 5893 | return pAdapter; |
| 5894 | } |
| 5895 | |
| 5896 | VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 5897 | { |
| 5898 | struct net_device *pWlanDev = pAdapter->dev; |
| 5899 | //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 5900 | //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 5901 | //eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5902 | |
| 5903 | if( rtnl_lock_held ) |
| 5904 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 5905 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5906 | if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 ) |
| 5907 | { |
| 5908 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__); |
| 5909 | return VOS_STATUS_E_FAILURE; |
| 5910 | } |
| 5911 | } |
| 5912 | if (register_netdevice(pWlanDev)) |
| 5913 | { |
| 5914 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__); |
| 5915 | return VOS_STATUS_E_FAILURE; |
| 5916 | } |
| 5917 | } |
| 5918 | else |
| 5919 | { |
| 5920 | if(register_netdev(pWlanDev)) |
| 5921 | { |
| 5922 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__); |
| 5923 | return VOS_STATUS_E_FAILURE; |
| 5924 | } |
| 5925 | } |
| 5926 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 5927 | |
| 5928 | return VOS_STATUS_SUCCESS; |
| 5929 | } |
| 5930 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5931 | static eHalStatus hdd_smeCloseSessionCallback(void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5932 | { |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5933 | hdd_adapter_t *pAdapter = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5934 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5935 | if (NULL == pAdapter) |
| 5936 | { |
| 5937 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__); |
| 5938 | return eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5939 | } |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5940 | |
| 5941 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 5942 | { |
| 5943 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__); |
| 5944 | return eHAL_STATUS_NOT_INITIALIZED; |
| 5945 | } |
| 5946 | |
| 5947 | clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags); |
| 5948 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5949 | #ifndef WLAN_OPEN_SOURCE |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5950 | /* need to make sure all of our scheduled work has completed. |
| 5951 | * This callback is called from MC thread context, so it is safe to |
| 5952 | * to call below flush workqueue API from here. |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5953 | * |
| 5954 | * Even though this is called from MC thread context, if there is a faulty |
| 5955 | * work item in the system, that can hang this call forever. So flushing |
| 5956 | * this global work queue is not safe; and now we make sure that |
| 5957 | * individual work queues are stopped correctly. But the cancel work queue |
| 5958 | * is a GPL only API, so the proprietary version of the driver would still |
| 5959 | * rely on the global work queue flush. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5960 | */ |
| 5961 | flush_scheduled_work(); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5962 | #endif |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5963 | |
| 5964 | /* We can be blocked while waiting for scheduled work to be |
| 5965 | * flushed, and the adapter structure can potentially be freed, in |
| 5966 | * which case the magic will have been reset. So make sure the |
| 5967 | * magic is still good, and hence the adapter structure is still |
| 5968 | * valid, before signaling completion */ |
| 5969 | if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic) |
| 5970 | { |
| 5971 | complete(&pAdapter->session_close_comp_var); |
| 5972 | } |
| 5973 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5974 | return eHAL_STATUS_SUCCESS; |
| 5975 | } |
| 5976 | |
| 5977 | VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter ) |
| 5978 | { |
| 5979 | struct net_device *pWlanDev = pAdapter->dev; |
| 5980 | hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 5981 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 5982 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5983 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5984 | long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5985 | |
| 5986 | INIT_COMPLETION(pAdapter->session_open_comp_var); |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 5987 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5988 | //Open a SME session for future operation |
| 5989 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 5990 | (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5991 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 5992 | { |
| 5993 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5994 | "sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5995 | halStatus, halStatus ); |
| 5996 | status = VOS_STATUS_E_FAILURE; |
| 5997 | goto error_sme_open; |
| 5998 | } |
| 5999 | |
| 6000 | //Block on a completion variable. Can't wait forever though. |
Vinay Krishna Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 6001 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6002 | &pAdapter->session_open_comp_var, |
| 6003 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6004 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6005 | { |
| 6006 | hddLog(VOS_TRACE_LEVEL_FATAL, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6007 | "Session is not opened within timeout period code %ld", rc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6008 | status = VOS_STATUS_E_FAILURE; |
| 6009 | goto error_sme_open; |
| 6010 | } |
| 6011 | |
| 6012 | // Register wireless extensions |
| 6013 | if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev))) |
| 6014 | { |
| 6015 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6016 | "hdd_register_wext() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6017 | halStatus, halStatus ); |
| 6018 | status = VOS_STATUS_E_FAILURE; |
| 6019 | goto error_register_wext; |
| 6020 | } |
| 6021 | //Safe to register the hard_start_xmit function again |
| 6022 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 6023 | wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit; |
| 6024 | #else |
| 6025 | pWlanDev->hard_start_xmit = hdd_hard_start_xmit; |
| 6026 | #endif |
| 6027 | |
| 6028 | //Set the Connection State to Not Connected |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 6029 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6030 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 6031 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6032 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 6033 | |
| 6034 | //Set the default operation channel |
| 6035 | pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel; |
| 6036 | |
| 6037 | /* Make the default Auth Type as OPEN*/ |
| 6038 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6039 | |
| 6040 | if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) ) |
| 6041 | { |
| 6042 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6043 | "hdd_init_tx_rx() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6044 | status, status ); |
| 6045 | goto error_init_txrx; |
| 6046 | } |
| 6047 | |
| 6048 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6049 | |
| 6050 | if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) ) |
| 6051 | { |
| 6052 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6053 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6054 | status, status ); |
| 6055 | goto error_wmm_init; |
| 6056 | } |
| 6057 | |
| 6058 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6059 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6060 | #ifdef FEATURE_WLAN_TDLS |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 6061 | if(0 != wlan_hdd_sta_tdls_init(pAdapter)) |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6062 | { |
| 6063 | status = VOS_STATUS_E_FAILURE; |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 6064 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_sta_tdls_init failed",__func__); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6065 | goto error_tdls_init; |
| 6066 | } |
| 6067 | set_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 6068 | #endif |
| 6069 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6070 | return VOS_STATUS_SUCCESS; |
| 6071 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6072 | #ifdef FEATURE_WLAN_TDLS |
| 6073 | error_tdls_init: |
| 6074 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6075 | hdd_wmm_adapter_close(pAdapter); |
| 6076 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6077 | error_wmm_init: |
| 6078 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6079 | hdd_deinit_tx_rx(pAdapter); |
| 6080 | error_init_txrx: |
| 6081 | hdd_UnregisterWext(pWlanDev); |
| 6082 | error_register_wext: |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6083 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6084 | { |
| 6085 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6086 | if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6087 | pAdapter->sessionId, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6088 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6089 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6090 | unsigned long rc; |
| 6091 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6092 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6093 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6094 | &pAdapter->session_close_comp_var, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6095 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6096 | if (rc <= 0) |
| 6097 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6098 | FL("Session is not opened within timeout period code %ld"), rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6099 | } |
| 6100 | } |
| 6101 | error_sme_open: |
| 6102 | return status; |
| 6103 | } |
| 6104 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6105 | void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 6106 | { |
| 6107 | hdd_cfg80211_state_t *cfgState; |
| 6108 | |
| 6109 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 6110 | |
| 6111 | if( NULL != cfgState->buf ) |
| 6112 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6113 | long rc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6114 | INIT_COMPLETION(pAdapter->tx_action_cnf_event); |
| 6115 | rc = wait_for_completion_interruptible_timeout( |
| 6116 | &pAdapter->tx_action_cnf_event, |
| 6117 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6118 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6119 | { |
Sudhir Sattayappa Kohalli | 8ee532d | 2013-02-15 13:16:26 -0800 | [diff] [blame] | 6120 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6121 | "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld" |
| 6122 | , __func__, rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6123 | } |
| 6124 | } |
| 6125 | return; |
| 6126 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6127 | |
| 6128 | void hdd_deinit_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 6129 | { |
| 6130 | ENTER(); |
| 6131 | switch ( pAdapter->device_mode ) |
| 6132 | { |
| 6133 | case WLAN_HDD_INFRA_STATION: |
| 6134 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6135 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6136 | { |
| 6137 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 6138 | { |
| 6139 | hdd_deinit_tx_rx( pAdapter ); |
| 6140 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6141 | } |
| 6142 | |
| 6143 | if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6144 | { |
| 6145 | hdd_wmm_adapter_close( pAdapter ); |
| 6146 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6147 | } |
| 6148 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6149 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6150 | #ifdef FEATURE_WLAN_TDLS |
| 6151 | if(test_bit(TDLS_INIT_DONE, &pAdapter->event_flags)) |
| 6152 | { |
| 6153 | wlan_hdd_tdls_exit(pAdapter); |
| 6154 | clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 6155 | } |
| 6156 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6157 | |
| 6158 | break; |
| 6159 | } |
| 6160 | |
| 6161 | case WLAN_HDD_SOFTAP: |
| 6162 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6163 | { |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 6164 | |
| 6165 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6166 | { |
| 6167 | hdd_wmm_adapter_close( pAdapter ); |
| 6168 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6169 | } |
| 6170 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6171 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6172 | |
| 6173 | hdd_unregister_hostapd(pAdapter); |
| 6174 | hdd_set_conparam( 0 ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6175 | wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), NULL ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6176 | break; |
| 6177 | } |
| 6178 | |
| 6179 | case WLAN_HDD_MONITOR: |
| 6180 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6181 | hdd_adapter_t* pAdapterforTx = pAdapter->sessionCtx.monitor.pAdapterForTx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6182 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 6183 | { |
| 6184 | hdd_deinit_tx_rx( pAdapter ); |
| 6185 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6186 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6187 | if(NULL != pAdapterforTx) |
| 6188 | { |
| 6189 | hdd_cleanup_actionframe(pHddCtx, pAdapterforTx); |
| 6190 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6191 | break; |
| 6192 | } |
| 6193 | |
| 6194 | |
| 6195 | default: |
| 6196 | break; |
| 6197 | } |
| 6198 | |
| 6199 | EXIT(); |
| 6200 | } |
| 6201 | |
| 6202 | void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
| 6203 | { |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 6204 | struct net_device *pWlanDev = NULL; |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6205 | |
| 6206 | ENTER(); |
| 6207 | if (NULL == pAdapter) |
| 6208 | { |
| 6209 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6210 | "%s: HDD adapter is Null", __func__); |
| 6211 | return; |
| 6212 | } |
| 6213 | |
| 6214 | pWlanDev = pAdapter->dev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6215 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6216 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6217 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 6218 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6219 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6220 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
| 6221 | ) |
| 6222 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6223 | if (pAdapter) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6224 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6225 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 6226 | { |
| 6227 | hdd_deinit_batch_scan(pAdapter); |
| 6228 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6229 | } |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6230 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6231 | #endif |
| 6232 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6233 | if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) { |
| 6234 | if( rtnl_held ) |
| 6235 | { |
| 6236 | unregister_netdevice(pWlanDev); |
| 6237 | } |
| 6238 | else |
| 6239 | { |
| 6240 | unregister_netdev(pWlanDev); |
| 6241 | } |
| 6242 | // note that the pAdapter is no longer valid at this point |
| 6243 | // since the memory has been reclaimed |
| 6244 | } |
| 6245 | |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6246 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6247 | } |
| 6248 | |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6249 | void hdd_set_pwrparams(hdd_context_t *pHddCtx) |
| 6250 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6251 | VOS_STATUS status; |
| 6252 | hdd_adapter_t *pAdapter = NULL; |
| 6253 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6254 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6255 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6256 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6257 | /*loop through all adapters.*/ |
| 6258 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6259 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6260 | pAdapter = pAdapterNode->pAdapter; |
| 6261 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 6262 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6263 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6264 | { // we skip this registration for modes other than STA and P2P client modes. |
| 6265 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6266 | pAdapterNode = pNext; |
| 6267 | continue; |
| 6268 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6269 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6270 | //Apply Dynamic DTIM For P2P |
| 6271 | //Only if ignoreDynamicDtimInP2pMode is not set in ini |
| 6272 | if ((pHddCtx->cfg_ini->enableDynamicDTIM || |
| 6273 | pHddCtx->cfg_ini->enableModulatedDTIM) && |
| 6274 | ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 6275 | ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) && |
| 6276 | !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) && |
| 6277 | (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) && |
| 6278 | (eConnectionState_Associated == |
| 6279 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) && |
| 6280 | (pHddCtx->cfg_ini->fIsBmpsEnabled)) |
| 6281 | { |
| 6282 | tSirSetPowerParamsReq powerRequest = { 0 }; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6283 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6284 | powerRequest.uIgnoreDTIM = 1; |
| 6285 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
| 6286 | |
| 6287 | if (pHddCtx->cfg_ini->enableModulatedDTIM) |
| 6288 | { |
| 6289 | powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM; |
| 6290 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
| 6291 | } |
| 6292 | else |
| 6293 | { |
| 6294 | powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM; |
| 6295 | } |
| 6296 | |
| 6297 | /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM |
| 6298 | * specified during Enter/Exit BMPS when LCD off*/ |
| 6299 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6300 | NULL, eANI_BOOLEAN_FALSE); |
| 6301 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6302 | NULL, eANI_BOOLEAN_FALSE); |
| 6303 | |
| 6304 | /* switch to the DTIM specified in cfg.ini */ |
| 6305 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6306 | "Switch to DTIM %d", powerRequest.uListenInterval); |
| 6307 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6308 | break; |
| 6309 | |
| 6310 | } |
| 6311 | |
| 6312 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6313 | pAdapterNode = pNext; |
| 6314 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6315 | } |
| 6316 | |
| 6317 | void hdd_reset_pwrparams(hdd_context_t *pHddCtx) |
| 6318 | { |
| 6319 | /*Switch back to DTIM 1*/ |
| 6320 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 6321 | |
| 6322 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 6323 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 6324 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6325 | |
| 6326 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 6327 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6328 | NULL, eANI_BOOLEAN_FALSE); |
| 6329 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6330 | NULL, eANI_BOOLEAN_FALSE); |
| 6331 | |
| 6332 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6333 | "Switch to DTIM%d",powerRequest.uListenInterval); |
| 6334 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6335 | |
| 6336 | } |
| 6337 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6338 | VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx) |
| 6339 | { |
| 6340 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 6341 | |
| 6342 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6343 | { |
| 6344 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6345 | } |
| 6346 | |
| 6347 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6348 | { |
| 6349 | sme_StartAutoBmpsTimer(pHddCtx->hHal); |
| 6350 | } |
| 6351 | |
| 6352 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6353 | { |
| 6354 | sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6355 | } |
| 6356 | |
| 6357 | return status; |
| 6358 | } |
| 6359 | |
| 6360 | VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type) |
| 6361 | { |
| 6362 | hdd_adapter_t *pAdapter = NULL; |
| 6363 | eHalStatus halStatus; |
| 6364 | VOS_STATUS status = VOS_STATUS_E_INVAL; |
| 6365 | v_BOOL_t disableBmps = FALSE; |
| 6366 | v_BOOL_t disableImps = FALSE; |
| 6367 | |
| 6368 | switch(session_type) |
| 6369 | { |
| 6370 | case WLAN_HDD_INFRA_STATION: |
| 6371 | case WLAN_HDD_SOFTAP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6372 | case WLAN_HDD_P2P_CLIENT: |
| 6373 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6374 | //Exit BMPS -> Is Sta/P2P Client is already connected |
| 6375 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6376 | if((NULL != pAdapter)&& |
| 6377 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6378 | { |
| 6379 | disableBmps = TRUE; |
| 6380 | } |
| 6381 | |
| 6382 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 6383 | if((NULL != pAdapter)&& |
| 6384 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6385 | { |
| 6386 | disableBmps = TRUE; |
| 6387 | } |
| 6388 | |
| 6389 | //Exit both Bmps and Imps incase of Go/SAP Mode |
| 6390 | if((WLAN_HDD_SOFTAP == session_type) || |
| 6391 | (WLAN_HDD_P2P_GO == session_type)) |
| 6392 | { |
| 6393 | disableBmps = TRUE; |
| 6394 | disableImps = TRUE; |
| 6395 | } |
| 6396 | |
| 6397 | if(TRUE == disableImps) |
| 6398 | { |
| 6399 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6400 | { |
| 6401 | sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6402 | } |
| 6403 | } |
| 6404 | |
| 6405 | if(TRUE == disableBmps) |
| 6406 | { |
| 6407 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6408 | { |
| 6409 | halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6410 | |
| 6411 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6412 | { |
| 6413 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6414 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6415 | VOS_ASSERT(0); |
| 6416 | return status; |
| 6417 | } |
| 6418 | } |
| 6419 | |
| 6420 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6421 | { |
| 6422 | halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal); |
| 6423 | |
| 6424 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6425 | { |
| 6426 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6427 | 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] | 6428 | VOS_ASSERT(0); |
| 6429 | return status; |
| 6430 | } |
| 6431 | } |
| 6432 | } |
| 6433 | |
| 6434 | if((TRUE == disableBmps) || |
| 6435 | (TRUE == disableImps)) |
| 6436 | { |
| 6437 | /* Now, get the chip into Full Power now */ |
| 6438 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 6439 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk, |
| 6440 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 6441 | |
| 6442 | if(halStatus != eHAL_STATUS_SUCCESS) |
| 6443 | { |
| 6444 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 6445 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6446 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6447 | //Block on a completion variable. Can't wait forever though |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6448 | ret = wait_for_completion_interruptible_timeout( |
| 6449 | &pHddCtx->full_pwr_comp_var, |
| 6450 | msecs_to_jiffies(1000)); |
| 6451 | if (ret <= 0) |
| 6452 | { |
| 6453 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6454 | "%s: wait on full_pwr_comp_var failed %ld", |
| 6455 | __func__, ret); |
| 6456 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6457 | } |
| 6458 | else |
| 6459 | { |
| 6460 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6461 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6462 | VOS_ASSERT(0); |
| 6463 | return status; |
| 6464 | } |
| 6465 | } |
| 6466 | |
| 6467 | status = VOS_STATUS_SUCCESS; |
| 6468 | } |
| 6469 | |
| 6470 | break; |
| 6471 | } |
| 6472 | return status; |
| 6473 | } |
| 6474 | |
| 6475 | 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] | 6476 | const char *iface_name, tSirMacAddr macAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6477 | tANI_U8 rtnl_held ) |
| 6478 | { |
| 6479 | hdd_adapter_t *pAdapter = NULL; |
| 6480 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
| 6481 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 6482 | VOS_STATUS exitbmpsStatus; |
| 6483 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6484 | 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] | 6485 | |
Nirav Shah | 436658f | 2014-02-28 17:05:45 +0530 | [diff] [blame] | 6486 | if(macAddr == NULL) |
| 6487 | { |
| 6488 | /* Not received valid macAddr */ |
| 6489 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6490 | "%s:Unable to add virtual intf: Not able to get" |
| 6491 | "valid mac address",__func__); |
| 6492 | return NULL; |
| 6493 | } |
| 6494 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6495 | //Disable BMPS incase of Concurrency |
| 6496 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type); |
| 6497 | |
| 6498 | if(VOS_STATUS_E_FAILURE == exitbmpsStatus) |
| 6499 | { |
| 6500 | //Fail to Exit BMPS |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6501 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6502 | VOS_ASSERT(0); |
| 6503 | return NULL; |
| 6504 | } |
| 6505 | |
| 6506 | switch(session_type) |
| 6507 | { |
| 6508 | case WLAN_HDD_INFRA_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6509 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6510 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6511 | { |
| 6512 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6513 | |
| 6514 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6515 | { |
| 6516 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6517 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6518 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6519 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6520 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6521 | #ifdef FEATURE_WLAN_TDLS |
| 6522 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6523 | * protect the concurrent access for the Adapters by TDLS module. |
| 6524 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6525 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6526 | #endif |
| 6527 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6528 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ? |
| 6529 | NL80211_IFTYPE_P2P_CLIENT: |
| 6530 | NL80211_IFTYPE_STATION; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6531 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6532 | pAdapter->device_mode = session_type; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6533 | #ifdef FEATURE_WLAN_TDLS |
| 6534 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6535 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 6536 | |
| 6537 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6538 | if( VOS_STATUS_SUCCESS != status ) |
| 6539 | goto err_free_netdev; |
| 6540 | |
| 6541 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6542 | if( VOS_STATUS_SUCCESS != status ) |
| 6543 | { |
| 6544 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 6545 | goto err_free_netdev; |
| 6546 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6547 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6548 | // Workqueue which gets scheduled in IPv4 notification callback. |
| 6549 | INIT_WORK(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue); |
| 6550 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6551 | #ifdef WLAN_NS_OFFLOAD |
| 6552 | // Workqueue which gets scheduled in IPv6 notification callback. |
| 6553 | INIT_WORK(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue); |
| 6554 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6555 | //Stop the Interface TX queue. |
| 6556 | netif_tx_disable(pAdapter->dev); |
| 6557 | //netif_tx_disable(pWlanDev); |
| 6558 | netif_carrier_off(pAdapter->dev); |
| 6559 | |
| 6560 | break; |
| 6561 | } |
| 6562 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6563 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6564 | case WLAN_HDD_SOFTAP: |
| 6565 | { |
| 6566 | pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name ); |
| 6567 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6568 | { |
| 6569 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6570 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6571 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6572 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6573 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6574 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ? |
| 6575 | NL80211_IFTYPE_AP: |
| 6576 | NL80211_IFTYPE_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6577 | pAdapter->device_mode = session_type; |
| 6578 | |
| 6579 | status = hdd_init_ap_mode(pAdapter); |
| 6580 | if( VOS_STATUS_SUCCESS != status ) |
| 6581 | goto err_free_netdev; |
| 6582 | |
| 6583 | status = hdd_register_hostapd( pAdapter, rtnl_held ); |
| 6584 | if( VOS_STATUS_SUCCESS != status ) |
| 6585 | { |
| 6586 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 6587 | goto err_free_netdev; |
| 6588 | } |
| 6589 | |
| 6590 | netif_tx_disable(pAdapter->dev); |
| 6591 | netif_carrier_off(pAdapter->dev); |
| 6592 | |
| 6593 | hdd_set_conparam( 1 ); |
| 6594 | break; |
| 6595 | } |
| 6596 | case WLAN_HDD_MONITOR: |
| 6597 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6598 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6599 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6600 | { |
| 6601 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6602 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6603 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6604 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6605 | |
| 6606 | pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
| 6607 | pAdapter->device_mode = session_type; |
| 6608 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6609 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 6610 | pAdapter->dev->netdev_ops = &wlan_mon_drv_ops; |
| 6611 | #else |
| 6612 | pAdapter->dev->open = hdd_mon_open; |
| 6613 | pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit; |
| 6614 | #endif |
| 6615 | hdd_init_tx_rx( pAdapter ); |
| 6616 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6617 | //Set adapter to be used for data tx. It will use either GO or softap. |
| 6618 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6619 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_SOFTAP); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6620 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) |
| 6621 | { |
| 6622 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6623 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_GO); |
| 6624 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6625 | /* This workqueue will be used to transmit management packet over |
| 6626 | * monitor interface. */ |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6627 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) { |
| 6628 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:hdd_get_adapter",__func__); |
| 6629 | return NULL; |
| 6630 | } |
Madan Mohan Koyyalamudi | 9f40ceb | 2012-10-18 19:22:56 -0700 | [diff] [blame] | 6631 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6632 | INIT_WORK(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue, |
| 6633 | hdd_mon_tx_work_queue); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6634 | } |
| 6635 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6636 | case WLAN_HDD_FTM: |
| 6637 | { |
| 6638 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6639 | |
| 6640 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6641 | { |
| 6642 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6643 | FL("failed to allocate adapter for session %d"), session_type); |
| 6644 | return NULL; |
| 6645 | } |
| 6646 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6647 | /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning |
| 6648 | * message while loading driver in FTM mode. */ |
| 6649 | pAdapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 6650 | pAdapter->device_mode = session_type; |
| 6651 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 6652 | |
| 6653 | hdd_init_tx_rx( pAdapter ); |
| 6654 | |
| 6655 | //Stop the Interface TX queue. |
| 6656 | netif_tx_disable(pAdapter->dev); |
| 6657 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6658 | } |
| 6659 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6660 | default: |
| 6661 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6662 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d", |
| 6663 | __func__, session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6664 | VOS_ASSERT(0); |
| 6665 | return NULL; |
| 6666 | } |
| 6667 | } |
| 6668 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6669 | if( VOS_STATUS_SUCCESS == status ) |
| 6670 | { |
| 6671 | //Add it to the hdd's session list. |
| 6672 | pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) ); |
| 6673 | if( NULL == pHddAdapterNode ) |
| 6674 | { |
| 6675 | status = VOS_STATUS_E_NOMEM; |
| 6676 | } |
| 6677 | else |
| 6678 | { |
| 6679 | pHddAdapterNode->pAdapter = pAdapter; |
| 6680 | status = hdd_add_adapter_back ( pHddCtx, |
| 6681 | pHddAdapterNode ); |
| 6682 | } |
| 6683 | } |
| 6684 | |
| 6685 | if( VOS_STATUS_SUCCESS != status ) |
| 6686 | { |
| 6687 | if( NULL != pAdapter ) |
| 6688 | { |
| 6689 | hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held ); |
| 6690 | pAdapter = NULL; |
| 6691 | } |
| 6692 | if( NULL != pHddAdapterNode ) |
| 6693 | { |
| 6694 | vos_mem_free( pHddAdapterNode ); |
| 6695 | } |
| 6696 | |
| 6697 | goto resume_bmps; |
| 6698 | } |
| 6699 | |
| 6700 | if(VOS_STATUS_SUCCESS == status) |
| 6701 | { |
| 6702 | wlan_hdd_set_concurrency_mode(pHddCtx, session_type); |
| 6703 | |
Madan Mohan Koyyalamudi | 96dd30d | 2012-10-05 17:24:51 -0700 | [diff] [blame] | 6704 | //Initialize the WoWL service |
| 6705 | if(!hdd_init_wowl(pAdapter)) |
| 6706 | { |
| 6707 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__); |
| 6708 | goto err_free_netdev; |
| 6709 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6710 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6711 | return pAdapter; |
| 6712 | |
| 6713 | err_free_netdev: |
| 6714 | free_netdev(pAdapter->dev); |
| 6715 | wlan_hdd_release_intf_addr( pHddCtx, |
| 6716 | pAdapter->macAddressCurrent.bytes ); |
| 6717 | |
| 6718 | resume_bmps: |
| 6719 | //If bmps disabled enable it |
| 6720 | if(VOS_STATUS_SUCCESS == exitbmpsStatus) |
| 6721 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6722 | if (pHddCtx->hdd_wlan_suspended) |
| 6723 | { |
| 6724 | hdd_set_pwrparams(pHddCtx); |
| 6725 | } |
| 6726 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6727 | } |
| 6728 | return NULL; |
| 6729 | } |
| 6730 | |
| 6731 | VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 6732 | tANI_U8 rtnl_held ) |
| 6733 | { |
| 6734 | hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext; |
| 6735 | VOS_STATUS status; |
| 6736 | |
| 6737 | status = hdd_get_front_adapter ( pHddCtx, &pCurrent ); |
| 6738 | if( VOS_STATUS_SUCCESS != status ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6739 | { |
| 6740 | hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d", |
| 6741 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6742 | return status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6743 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6744 | |
| 6745 | while ( pCurrent->pAdapter != pAdapter ) |
| 6746 | { |
| 6747 | status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext ); |
| 6748 | if( VOS_STATUS_SUCCESS != status ) |
| 6749 | break; |
| 6750 | |
| 6751 | pCurrent = pNext; |
| 6752 | } |
| 6753 | pAdapterNode = pCurrent; |
| 6754 | if( VOS_STATUS_SUCCESS == status ) |
| 6755 | { |
| 6756 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 6757 | hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6758 | |
| 6759 | #ifdef FEATURE_WLAN_TDLS |
| 6760 | |
| 6761 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6762 | * protect the concurrent access for the Adapters by TDLS module. |
| 6763 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6764 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6765 | #endif |
| 6766 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6767 | hdd_remove_adapter( pHddCtx, pAdapterNode ); |
| 6768 | vos_mem_free( pAdapterNode ); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6769 | pAdapterNode = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6770 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6771 | #ifdef FEATURE_WLAN_TDLS |
| 6772 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6773 | #endif |
| 6774 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6775 | |
| 6776 | /* If there is a single session of STA/P2P client, re-enable BMPS */ |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 6777 | if ((!vos_concurrent_open_sessions_running()) && |
| 6778 | ((pHddCtx->no_of_open_sessions[VOS_STA_MODE] >= 1) || |
| 6779 | (pHddCtx->no_of_open_sessions[VOS_P2P_CLIENT_MODE] >= 1))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6780 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6781 | if (pHddCtx->hdd_wlan_suspended) |
| 6782 | { |
| 6783 | hdd_set_pwrparams(pHddCtx); |
| 6784 | } |
| 6785 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6786 | } |
| 6787 | |
| 6788 | return VOS_STATUS_SUCCESS; |
| 6789 | } |
| 6790 | |
| 6791 | return VOS_STATUS_E_FAILURE; |
| 6792 | } |
| 6793 | |
| 6794 | VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx ) |
| 6795 | { |
| 6796 | hdd_adapter_list_node_t *pHddAdapterNode; |
| 6797 | VOS_STATUS status; |
| 6798 | |
| 6799 | ENTER(); |
| 6800 | |
| 6801 | do |
| 6802 | { |
| 6803 | status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode ); |
| 6804 | if( pHddAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6805 | { |
| 6806 | hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE ); |
| 6807 | vos_mem_free( pHddAdapterNode ); |
| 6808 | } |
| 6809 | }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status ); |
| 6810 | |
| 6811 | EXIT(); |
| 6812 | |
| 6813 | return VOS_STATUS_SUCCESS; |
| 6814 | } |
| 6815 | |
| 6816 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter) |
| 6817 | { |
| 6818 | v_U8_t addIE[1] = {0}; |
| 6819 | |
| 6820 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6821 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL, |
| 6822 | eANI_BOOLEAN_FALSE) ) |
| 6823 | { |
| 6824 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6825 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6826 | } |
| 6827 | |
| 6828 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6829 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 6830 | eANI_BOOLEAN_FALSE) ) |
| 6831 | { |
| 6832 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6833 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6834 | } |
| 6835 | |
| 6836 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6837 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 6838 | eANI_BOOLEAN_FALSE) ) |
| 6839 | { |
| 6840 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6841 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6842 | } |
| 6843 | } |
| 6844 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6845 | VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 6846 | const v_BOOL_t bCloseSession ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6847 | { |
| 6848 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 6849 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 6850 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6851 | union iwreq_data wrqu; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 6852 | v_U8_t retry = 0; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6853 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6854 | |
| 6855 | ENTER(); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 6856 | pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6857 | switch(pAdapter->device_mode) |
| 6858 | { |
| 6859 | case WLAN_HDD_INFRA_STATION: |
| 6860 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6861 | case WLAN_HDD_P2P_DEVICE: |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 6862 | { |
| 6863 | hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6864 | if( hdd_connIsConnected(pstation) || |
| 6865 | (pstation->conn_info.connState == eConnectionState_Connecting) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6866 | { |
| 6867 | if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 6868 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 6869 | pAdapter->sessionId, |
| 6870 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6871 | else |
| 6872 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 6873 | pAdapter->sessionId, |
| 6874 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 6875 | //success implies disconnect command got queued up successfully |
| 6876 | if(halStatus == eHAL_STATUS_SUCCESS) |
| 6877 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6878 | ret = wait_for_completion_interruptible_timeout( |
| 6879 | &pAdapter->disconnect_comp_var, |
| 6880 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6881 | if (ret <= 0) |
| 6882 | { |
| 6883 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6884 | "%s: wait on disconnect_comp_var failed %ld", |
| 6885 | __func__, ret); |
| 6886 | } |
| 6887 | } |
| 6888 | else |
| 6889 | { |
| 6890 | hddLog(LOGE, "%s: failed to post disconnect event to SME", |
| 6891 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6892 | } |
| 6893 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6894 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6895 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 6896 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
| 6897 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 6898 | else if(pstation->conn_info.connState == |
| 6899 | eConnectionState_Disconnecting) |
| 6900 | { |
| 6901 | ret = wait_for_completion_interruptible_timeout( |
| 6902 | &pAdapter->disconnect_comp_var, |
| 6903 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6904 | if (ret <= 0) |
| 6905 | { |
| 6906 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6907 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 6908 | } |
| 6909 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 6910 | else if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6911 | { |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 6912 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 6913 | eCSR_SCAN_ABORT_DEFAULT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6914 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 6915 | if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION) |
| 6916 | { |
| 6917 | while (pAdapter->is_roc_inprogress) |
| 6918 | { |
| 6919 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6920 | "%s: ROC in progress for session %d!!!", |
| 6921 | __func__, pAdapter->sessionId); |
| 6922 | // waiting for ROC to expire |
| 6923 | msleep(500); |
| 6924 | /* In GO present case , if retry exceeds 3, |
| 6925 | it means something went wrong. */ |
| 6926 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) |
| 6927 | { |
| 6928 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6929 | "%s: ROC completion is not received.!!!", __func__); |
| 6930 | sme_CancelRemainOnChannel(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6931 | pAdapter->sessionId); |
| 6932 | wait_for_completion_interruptible_timeout( |
| 6933 | &pAdapter->cancel_rem_on_chan_var, |
| 6934 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 6935 | break; |
| 6936 | } |
| 6937 | } |
| 6938 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6939 | #ifdef WLAN_NS_OFFLOAD |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 6940 | #ifdef WLAN_OPEN_SOURCE |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6941 | cancel_work_sync(&pAdapter->ipv6NotifierWorkQueue); |
| 6942 | #endif |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 6943 | if (pAdapter->ipv6_notifier_registered) |
| 6944 | { |
| 6945 | hddLog(LOG1, FL("Unregistered IPv6 notifier")); |
| 6946 | unregister_inet6addr_notifier(&pAdapter->ipv6_notifier); |
| 6947 | pAdapter->ipv6_notifier_registered = false; |
| 6948 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6949 | #endif |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 6950 | if (pAdapter->ipv4_notifier_registered) |
| 6951 | { |
| 6952 | hddLog(LOG1, FL("Unregistered IPv4 notifier")); |
| 6953 | unregister_inetaddr_notifier(&pAdapter->ipv4_notifier); |
| 6954 | pAdapter->ipv4_notifier_registered = false; |
| 6955 | } |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6956 | #ifdef WLAN_OPEN_SOURCE |
| 6957 | cancel_work_sync(&pAdapter->ipv4NotifierWorkQueue); |
| 6958 | #endif |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6959 | /* It is possible that the caller of this function does not |
| 6960 | * wish to close the session |
| 6961 | */ |
| 6962 | if (VOS_TRUE == bCloseSession && |
| 6963 | test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6964 | { |
| 6965 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
| 6966 | if (eHAL_STATUS_SUCCESS == |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6967 | sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, |
| 6968 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6969 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6970 | unsigned long ret; |
| 6971 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6972 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6973 | ret = wait_for_completion_timeout( |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6974 | &pAdapter->session_close_comp_var, |
| 6975 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6976 | if ( 0 >= ret) |
| 6977 | { |
| 6978 | hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld", |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6979 | __func__, ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6980 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6981 | } |
| 6982 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 6983 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6984 | break; |
| 6985 | |
| 6986 | case WLAN_HDD_SOFTAP: |
| 6987 | case WLAN_HDD_P2P_GO: |
| 6988 | //Any softap specific cleanup here... |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 6989 | if (pAdapter->device_mode == WLAN_HDD_P2P_GO) { |
| 6990 | while (pAdapter->is_roc_inprogress) { |
| 6991 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6992 | "%s: ROC in progress for session %d!!!", |
| 6993 | __func__, pAdapter->sessionId); |
| 6994 | msleep(500); |
| 6995 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) { |
| 6996 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6997 | "%s: ROC completion is not received.!!!", __func__); |
| 6998 | WLANSAP_CancelRemainOnChannel( |
| 6999 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
| 7000 | wait_for_completion_interruptible_timeout( |
| 7001 | &pAdapter->cancel_rem_on_chan_var, |
| 7002 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 7003 | break; |
| 7004 | } |
| 7005 | } |
| 7006 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7007 | mutex_lock(&pHddCtx->sap_lock); |
| 7008 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7009 | { |
| 7010 | VOS_STATUS status; |
| 7011 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7012 | |
| 7013 | //Stop Bss. |
| 7014 | status = WLANSAP_StopBss(pHddCtx->pvosContext); |
| 7015 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 7016 | { |
| 7017 | hdd_hostapd_state_t *pHostapdState = |
| 7018 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7019 | |
| 7020 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 7021 | |
| 7022 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 7023 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7024 | hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d", |
| 7025 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7026 | } |
| 7027 | } |
| 7028 | else |
| 7029 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7030 | hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7031 | } |
| 7032 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 7033 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7034 | |
| 7035 | if (eHAL_STATUS_FAILURE == |
| 7036 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 7037 | 0, NULL, eANI_BOOLEAN_FALSE)) |
| 7038 | { |
| 7039 | hddLog(LOGE, |
| 7040 | "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7041 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7042 | } |
| 7043 | |
| 7044 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 7045 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 7046 | eANI_BOOLEAN_FALSE) ) |
| 7047 | { |
| 7048 | hddLog(LOGE, |
| 7049 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
| 7050 | } |
| 7051 | |
| 7052 | // Reset WNI_CFG_PROBE_RSP Flags |
| 7053 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 7054 | kfree(pAdapter->sessionCtx.ap.beacon); |
| 7055 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 7056 | } |
| 7057 | mutex_unlock(&pHddCtx->sap_lock); |
| 7058 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7059 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7060 | case WLAN_HDD_MONITOR: |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7061 | #ifdef WLAN_OPEN_SOURCE |
| 7062 | cancel_work_sync(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue); |
| 7063 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7064 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7065 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7066 | default: |
| 7067 | break; |
| 7068 | } |
| 7069 | |
| 7070 | EXIT(); |
| 7071 | return VOS_STATUS_SUCCESS; |
| 7072 | } |
| 7073 | |
| 7074 | VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx ) |
| 7075 | { |
| 7076 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7077 | VOS_STATUS status; |
| 7078 | hdd_adapter_t *pAdapter; |
| 7079 | |
| 7080 | ENTER(); |
| 7081 | |
| 7082 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7083 | |
| 7084 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7085 | { |
| 7086 | pAdapter = pAdapterNode->pAdapter; |
| 7087 | netif_tx_disable(pAdapter->dev); |
| 7088 | netif_carrier_off(pAdapter->dev); |
| 7089 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7090 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7091 | |
| 7092 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7093 | pAdapterNode = pNext; |
| 7094 | } |
| 7095 | |
| 7096 | EXIT(); |
| 7097 | |
| 7098 | return VOS_STATUS_SUCCESS; |
| 7099 | } |
| 7100 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7101 | |
| 7102 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 7103 | /**--------------------------------------------------------------------------- |
| 7104 | |
| 7105 | \brief hdd_deinit_batch_scan () - This function cleans up batch scan data |
| 7106 | structures |
| 7107 | |
| 7108 | \param - pAdapter Pointer to HDD adapter |
| 7109 | |
| 7110 | \return - None |
| 7111 | |
| 7112 | --------------------------------------------------------------------------*/ |
| 7113 | void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter) |
| 7114 | { |
| 7115 | tHddBatchScanRsp *pNode; |
| 7116 | tHddBatchScanRsp *pPrev; |
| 7117 | |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 7118 | if (NULL == pAdapter) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7119 | { |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 7120 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7121 | "%s: Adapter context is Null", __func__); |
| 7122 | return; |
| 7123 | } |
| 7124 | |
| 7125 | pNode = pAdapter->pBatchScanRsp; |
| 7126 | while (pNode) |
| 7127 | { |
| 7128 | pPrev = pNode; |
| 7129 | pNode = pNode->pNext; |
| 7130 | vos_mem_free((v_VOID_t * )pPrev); |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7131 | } |
| 7132 | |
| 7133 | pAdapter->pBatchScanRsp = NULL; |
| 7134 | pAdapter->numScanList = 0; |
| 7135 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 7136 | pAdapter->prev_batch_id = 0; |
| 7137 | |
| 7138 | return; |
| 7139 | } |
| 7140 | #endif |
| 7141 | |
| 7142 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7143 | VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx ) |
| 7144 | { |
| 7145 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7146 | VOS_STATUS status; |
| 7147 | hdd_adapter_t *pAdapter; |
| 7148 | |
| 7149 | ENTER(); |
| 7150 | |
| 7151 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7152 | |
| 7153 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7154 | { |
| 7155 | pAdapter = pAdapterNode->pAdapter; |
| 7156 | netif_tx_disable(pAdapter->dev); |
| 7157 | netif_carrier_off(pAdapter->dev); |
| 7158 | |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 7159 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
| 7160 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7161 | hdd_deinit_tx_rx(pAdapter); |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 7162 | |
| 7163 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 7164 | |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 7165 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 7166 | { |
| 7167 | hdd_wmm_adapter_close( pAdapter ); |
| 7168 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 7169 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7170 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7171 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 7172 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 7173 | { |
| 7174 | hdd_deinit_batch_scan(pAdapter); |
| 7175 | } |
| 7176 | #endif |
| 7177 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7178 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7179 | pAdapterNode = pNext; |
| 7180 | } |
| 7181 | |
| 7182 | EXIT(); |
| 7183 | |
| 7184 | return VOS_STATUS_SUCCESS; |
| 7185 | } |
| 7186 | |
| 7187 | VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx ) |
| 7188 | { |
| 7189 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7190 | VOS_STATUS status; |
| 7191 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7192 | eConnectionState connState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7193 | |
| 7194 | ENTER(); |
| 7195 | |
| 7196 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7197 | |
| 7198 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7199 | { |
| 7200 | pAdapter = pAdapterNode->pAdapter; |
| 7201 | |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 7202 | hdd_wmm_init( pAdapter ); |
| 7203 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7204 | switch(pAdapter->device_mode) |
| 7205 | { |
| 7206 | case WLAN_HDD_INFRA_STATION: |
| 7207 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7208 | case WLAN_HDD_P2P_DEVICE: |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7209 | |
| 7210 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState; |
| 7211 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7212 | hdd_init_station_mode(pAdapter); |
| 7213 | /* Open the gates for HDD to receive Wext commands */ |
| 7214 | pAdapter->isLinkUpSvcNeeded = FALSE; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 7215 | pHddCtx->scan_info.mScanPending = FALSE; |
| 7216 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7217 | |
| 7218 | //Trigger the initial scan |
| 7219 | hdd_wlan_initial_scan(pAdapter); |
| 7220 | |
| 7221 | //Indicate disconnect event to supplicant if associated previously |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7222 | if (eConnectionState_Associated == connState || |
| 7223 | eConnectionState_IbssConnected == connState ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7224 | { |
| 7225 | union iwreq_data wrqu; |
| 7226 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 7227 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 7228 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 7229 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 7230 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7231 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7232 | /* indicate disconnected event to nl80211 */ |
| 7233 | cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED, |
| 7234 | NULL, 0, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7235 | } |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7236 | else if (eConnectionState_Connecting == connState) |
| 7237 | { |
| 7238 | /* |
| 7239 | * Indicate connect failure to supplicant if we were in the |
| 7240 | * process of connecting |
| 7241 | */ |
| 7242 | cfg80211_connect_result(pAdapter->dev, NULL, |
| 7243 | NULL, 0, NULL, 0, |
| 7244 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 7245 | GFP_KERNEL); |
| 7246 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7247 | break; |
| 7248 | |
| 7249 | case WLAN_HDD_SOFTAP: |
| 7250 | /* softAP can handle SSR */ |
| 7251 | break; |
| 7252 | |
| 7253 | case WLAN_HDD_P2P_GO: |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 7254 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7255 | __func__); |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 7256 | cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7257 | break; |
| 7258 | |
| 7259 | case WLAN_HDD_MONITOR: |
| 7260 | /* monitor interface start */ |
| 7261 | break; |
| 7262 | default: |
| 7263 | break; |
| 7264 | } |
| 7265 | |
| 7266 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7267 | pAdapterNode = pNext; |
| 7268 | } |
| 7269 | |
| 7270 | EXIT(); |
| 7271 | |
| 7272 | return VOS_STATUS_SUCCESS; |
| 7273 | } |
| 7274 | |
| 7275 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ) |
| 7276 | { |
| 7277 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7278 | hdd_adapter_t *pAdapter; |
| 7279 | VOS_STATUS status; |
| 7280 | v_U32_t roamId; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7281 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7282 | |
| 7283 | ENTER(); |
| 7284 | |
| 7285 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7286 | |
| 7287 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7288 | { |
| 7289 | pAdapter = pAdapterNode->pAdapter; |
| 7290 | |
| 7291 | if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 7292 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 7293 | { |
| 7294 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7295 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 7296 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 7297 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7298 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 7299 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7300 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 7301 | init_completion(&pAdapter->disconnect_comp_var); |
| 7302 | sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, |
| 7303 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7304 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7305 | ret = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7306 | &pAdapter->disconnect_comp_var, |
| 7307 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7308 | if (0 >= ret) |
| 7309 | hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld", |
| 7310 | __func__, ret); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7311 | |
| 7312 | pWextState->roamProfile.csrPersona = pAdapter->device_mode; |
| 7313 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 7314 | sme_RoamConnect(pHddCtx->hHal, |
| 7315 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 7316 | &roamId); |
| 7317 | } |
| 7318 | |
| 7319 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7320 | pAdapterNode = pNext; |
| 7321 | } |
| 7322 | |
| 7323 | EXIT(); |
| 7324 | |
| 7325 | return VOS_STATUS_SUCCESS; |
| 7326 | } |
| 7327 | |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 7328 | void hdd_dump_concurrency_info(hdd_context_t *pHddCtx) |
| 7329 | { |
| 7330 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7331 | VOS_STATUS status; |
| 7332 | hdd_adapter_t *pAdapter; |
| 7333 | hdd_station_ctx_t *pHddStaCtx; |
| 7334 | hdd_ap_ctx_t *pHddApCtx; |
| 7335 | hdd_hostapd_state_t * pHostapdState; |
| 7336 | tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 }; |
| 7337 | v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 7338 | const char *p2pMode = "DEV"; |
| 7339 | const char *ccMode = "Standalone"; |
| 7340 | int n; |
| 7341 | |
| 7342 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7343 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7344 | { |
| 7345 | pAdapter = pAdapterNode->pAdapter; |
| 7346 | switch (pAdapter->device_mode) { |
| 7347 | case WLAN_HDD_INFRA_STATION: |
| 7348 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7349 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7350 | staChannel = pHddStaCtx->conn_info.operationChannel; |
| 7351 | memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid)); |
| 7352 | } |
| 7353 | break; |
| 7354 | case WLAN_HDD_P2P_CLIENT: |
| 7355 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7356 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7357 | p2pChannel = pHddStaCtx->conn_info.operationChannel; |
| 7358 | memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid)); |
| 7359 | p2pMode = "CLI"; |
| 7360 | } |
| 7361 | break; |
| 7362 | case WLAN_HDD_P2P_GO: |
| 7363 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7364 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7365 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7366 | p2pChannel = pHddApCtx->operatingChannel; |
| 7367 | memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid)); |
| 7368 | } |
| 7369 | p2pMode = "GO"; |
| 7370 | break; |
| 7371 | case WLAN_HDD_SOFTAP: |
| 7372 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7373 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7374 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7375 | apChannel = pHddApCtx->operatingChannel; |
| 7376 | memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid)); |
| 7377 | } |
| 7378 | break; |
| 7379 | default: |
| 7380 | break; |
| 7381 | } |
| 7382 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7383 | pAdapterNode = pNext; |
| 7384 | } |
| 7385 | if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) { |
| 7386 | ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC"; |
| 7387 | } |
| 7388 | n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s", |
| 7389 | staChannel, MAC_ADDR_ARRAY(staBssid), ccMode); |
| 7390 | if (p2pChannel > 0) { |
| 7391 | n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR, |
| 7392 | p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid)); |
| 7393 | } |
| 7394 | if (apChannel > 0) { |
| 7395 | n += pr_info("AP(%d) " MAC_ADDRESS_STR, |
| 7396 | apChannel, MAC_ADDR_ARRAY(apBssid)); |
| 7397 | } |
| 7398 | |
| 7399 | if (p2pChannel > 0 && apChannel > 0) { |
| 7400 | hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel); |
| 7401 | } |
| 7402 | } |
| 7403 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7404 | bool hdd_is_ssr_required( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7405 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7406 | return (isSsrRequired == HDD_SSR_REQUIRED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7407 | } |
| 7408 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7409 | /* Once SSR is disabled then it cannot be set. */ |
| 7410 | void hdd_set_ssr_required( e_hdd_ssr_required value) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7411 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7412 | if (HDD_SSR_DISABLED == isSsrRequired) |
| 7413 | return; |
| 7414 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7415 | isSsrRequired = value; |
| 7416 | } |
| 7417 | |
| 7418 | VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx, |
| 7419 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7420 | { |
| 7421 | VOS_STATUS status; |
| 7422 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7423 | status = hdd_list_peek_front ( &pHddCtx->hddAdapters, |
| 7424 | (hdd_list_node_t**) ppAdapterNode ); |
| 7425 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7426 | return status; |
| 7427 | } |
| 7428 | |
| 7429 | VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx, |
| 7430 | hdd_adapter_list_node_t* pAdapterNode, |
| 7431 | hdd_adapter_list_node_t** pNextAdapterNode) |
| 7432 | { |
| 7433 | VOS_STATUS status; |
| 7434 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7435 | status = hdd_list_peek_next ( &pHddCtx->hddAdapters, |
| 7436 | (hdd_list_node_t*) pAdapterNode, |
| 7437 | (hdd_list_node_t**)pNextAdapterNode ); |
| 7438 | |
| 7439 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7440 | return status; |
| 7441 | } |
| 7442 | |
| 7443 | VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx, |
| 7444 | hdd_adapter_list_node_t* pAdapterNode) |
| 7445 | { |
| 7446 | VOS_STATUS status; |
| 7447 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7448 | status = hdd_list_remove_node ( &pHddCtx->hddAdapters, |
| 7449 | &pAdapterNode->node ); |
| 7450 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7451 | return status; |
| 7452 | } |
| 7453 | |
| 7454 | VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx, |
| 7455 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7456 | { |
| 7457 | VOS_STATUS status; |
| 7458 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7459 | status = hdd_list_remove_front( &pHddCtx->hddAdapters, |
| 7460 | (hdd_list_node_t**) ppAdapterNode ); |
| 7461 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7462 | return status; |
| 7463 | } |
| 7464 | |
| 7465 | VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx, |
| 7466 | hdd_adapter_list_node_t* pAdapterNode) |
| 7467 | { |
| 7468 | VOS_STATUS status; |
| 7469 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7470 | status = hdd_list_insert_back ( &pHddCtx->hddAdapters, |
| 7471 | (hdd_list_node_t*) pAdapterNode ); |
| 7472 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7473 | return status; |
| 7474 | } |
| 7475 | |
| 7476 | VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx, |
| 7477 | hdd_adapter_list_node_t* pAdapterNode) |
| 7478 | { |
| 7479 | VOS_STATUS status; |
| 7480 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7481 | status = hdd_list_insert_front ( &pHddCtx->hddAdapters, |
| 7482 | (hdd_list_node_t*) pAdapterNode ); |
| 7483 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7484 | return status; |
| 7485 | } |
| 7486 | |
| 7487 | hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx, |
| 7488 | tSirMacAddr macAddr ) |
| 7489 | { |
| 7490 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7491 | hdd_adapter_t *pAdapter; |
| 7492 | VOS_STATUS status; |
| 7493 | |
| 7494 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7495 | |
| 7496 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7497 | { |
| 7498 | pAdapter = pAdapterNode->pAdapter; |
| 7499 | |
| 7500 | if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes, |
| 7501 | macAddr, sizeof(tSirMacAddr) ) ) |
| 7502 | { |
| 7503 | return pAdapter; |
| 7504 | } |
| 7505 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7506 | pAdapterNode = pNext; |
| 7507 | } |
| 7508 | |
| 7509 | return NULL; |
| 7510 | |
| 7511 | } |
| 7512 | |
| 7513 | hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name ) |
| 7514 | { |
| 7515 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7516 | hdd_adapter_t *pAdapter; |
| 7517 | VOS_STATUS status; |
| 7518 | |
| 7519 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7520 | |
| 7521 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7522 | { |
| 7523 | pAdapter = pAdapterNode->pAdapter; |
| 7524 | |
| 7525 | if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name, |
| 7526 | IFNAMSIZ ) ) |
| 7527 | { |
| 7528 | return pAdapter; |
| 7529 | } |
| 7530 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7531 | pAdapterNode = pNext; |
| 7532 | } |
| 7533 | |
| 7534 | return NULL; |
| 7535 | |
| 7536 | } |
| 7537 | |
| 7538 | hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7539 | { |
| 7540 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7541 | hdd_adapter_t *pAdapter; |
| 7542 | VOS_STATUS status; |
| 7543 | |
| 7544 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7545 | |
| 7546 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7547 | { |
| 7548 | pAdapter = pAdapterNode->pAdapter; |
| 7549 | |
| 7550 | if( pAdapter && (mode == pAdapter->device_mode) ) |
| 7551 | { |
| 7552 | return pAdapter; |
| 7553 | } |
| 7554 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7555 | pAdapterNode = pNext; |
| 7556 | } |
| 7557 | |
| 7558 | return NULL; |
| 7559 | |
| 7560 | } |
| 7561 | |
| 7562 | //Remove this function later |
| 7563 | hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx ) |
| 7564 | { |
| 7565 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7566 | hdd_adapter_t *pAdapter; |
| 7567 | VOS_STATUS status; |
| 7568 | |
| 7569 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7570 | |
| 7571 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7572 | { |
| 7573 | pAdapter = pAdapterNode->pAdapter; |
| 7574 | |
| 7575 | if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode ) |
| 7576 | { |
| 7577 | return pAdapter; |
| 7578 | } |
| 7579 | |
| 7580 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7581 | pAdapterNode = pNext; |
| 7582 | } |
| 7583 | |
| 7584 | return NULL; |
| 7585 | |
| 7586 | } |
| 7587 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7588 | /**--------------------------------------------------------------------------- |
| 7589 | |
| 7590 | \brief hdd_set_monitor_tx_adapter() - |
| 7591 | |
| 7592 | This API initializes the adapter to be used while transmitting on monitor |
| 7593 | adapter. |
| 7594 | |
| 7595 | \param - pHddCtx - Pointer to the HDD context. |
| 7596 | pAdapter - Adapter that will used for TX. This can be NULL. |
| 7597 | \return - None. |
| 7598 | --------------------------------------------------------------------------*/ |
| 7599 | void wlan_hdd_set_monitor_tx_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 7600 | { |
| 7601 | hdd_adapter_t *pMonAdapter; |
| 7602 | |
| 7603 | pMonAdapter = hdd_get_adapter( pHddCtx, WLAN_HDD_MONITOR ); |
| 7604 | |
| 7605 | if( NULL != pMonAdapter ) |
| 7606 | { |
| 7607 | pMonAdapter->sessionCtx.monitor.pAdapterForTx = pAdapter; |
| 7608 | } |
| 7609 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7610 | /**--------------------------------------------------------------------------- |
| 7611 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7612 | \brief hdd_get_operating_channel() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7613 | |
| 7614 | This API returns the operating channel of the requested device mode |
| 7615 | |
| 7616 | \param - pHddCtx - Pointer to the HDD context. |
| 7617 | - mode - Device mode for which operating channel is required |
| 7618 | suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT |
| 7619 | WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO. |
| 7620 | \return - channel number. "0" id the requested device is not found OR it is not connected. |
| 7621 | --------------------------------------------------------------------------*/ |
| 7622 | v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7623 | { |
| 7624 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7625 | VOS_STATUS status; |
| 7626 | hdd_adapter_t *pAdapter; |
| 7627 | v_U8_t operatingChannel = 0; |
| 7628 | |
| 7629 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7630 | |
| 7631 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7632 | { |
| 7633 | pAdapter = pAdapterNode->pAdapter; |
| 7634 | |
| 7635 | if( mode == pAdapter->device_mode ) |
| 7636 | { |
| 7637 | switch(pAdapter->device_mode) |
| 7638 | { |
| 7639 | case WLAN_HDD_INFRA_STATION: |
| 7640 | case WLAN_HDD_P2P_CLIENT: |
| 7641 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 7642 | operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel; |
| 7643 | break; |
| 7644 | case WLAN_HDD_SOFTAP: |
| 7645 | case WLAN_HDD_P2P_GO: |
| 7646 | /*softap connection info */ |
| 7647 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7648 | operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel; |
| 7649 | break; |
| 7650 | default: |
| 7651 | break; |
| 7652 | } |
| 7653 | |
| 7654 | break; //Found the device of interest. break the loop |
| 7655 | } |
| 7656 | |
| 7657 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7658 | pAdapterNode = pNext; |
| 7659 | } |
| 7660 | return operatingChannel; |
| 7661 | } |
| 7662 | |
| 7663 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 7664 | /**--------------------------------------------------------------------------- |
| 7665 | |
| 7666 | \brief hdd_set_multicast_list() - |
| 7667 | |
| 7668 | This used to set the multicast address list. |
| 7669 | |
| 7670 | \param - dev - Pointer to the WLAN device. |
| 7671 | - skb - Pointer to OS packet (sk_buff). |
| 7672 | \return - success/fail |
| 7673 | |
| 7674 | --------------------------------------------------------------------------*/ |
| 7675 | static void hdd_set_multicast_list(struct net_device *dev) |
| 7676 | { |
| 7677 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7678 | int mc_count; |
| 7679 | int i = 0; |
| 7680 | struct netdev_hw_addr *ha; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7681 | |
| 7682 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7683 | { |
| 7684 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7685 | "%s: Adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7686 | return; |
| 7687 | } |
| 7688 | |
| 7689 | if (dev->flags & IFF_ALLMULTI) |
| 7690 | { |
| 7691 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7692 | "%s: allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7693 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7694 | } |
| 7695 | else |
| 7696 | { |
| 7697 | mc_count = netdev_mc_count(dev); |
| 7698 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7699 | "%s: mc_count = %u", __func__, mc_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7700 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) |
| 7701 | { |
| 7702 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7703 | "%s: No free filter available; allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7704 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7705 | return; |
| 7706 | } |
| 7707 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7708 | pAdapter->mc_addr_list.mc_cnt = mc_count; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7709 | |
| 7710 | netdev_for_each_mc_addr(ha, dev) { |
| 7711 | if (i == mc_count) |
| 7712 | break; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7713 | memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN); |
| 7714 | memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7715 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7716 | __func__, i, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7717 | MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i])); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7718 | i++; |
| 7719 | } |
| 7720 | } |
| 7721 | return; |
| 7722 | } |
| 7723 | #endif |
| 7724 | |
| 7725 | /**--------------------------------------------------------------------------- |
| 7726 | |
| 7727 | \brief hdd_select_queue() - |
| 7728 | |
| 7729 | This function is registered with the Linux OS for network |
| 7730 | core to decide which queue to use first. |
| 7731 | |
| 7732 | \param - dev - Pointer to the WLAN device. |
| 7733 | - skb - Pointer to OS packet (sk_buff). |
| 7734 | \return - ac, Queue Index/access category corresponding to UP in IP header |
| 7735 | |
| 7736 | --------------------------------------------------------------------------*/ |
| 7737 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 7738 | struct sk_buff *skb) |
| 7739 | { |
| 7740 | return hdd_wmm_select_queue(dev, skb); |
| 7741 | } |
| 7742 | |
| 7743 | |
| 7744 | /**--------------------------------------------------------------------------- |
| 7745 | |
| 7746 | \brief hdd_wlan_initial_scan() - |
| 7747 | |
| 7748 | This function triggers the initial scan |
| 7749 | |
| 7750 | \param - pAdapter - Pointer to the HDD adapter. |
| 7751 | |
| 7752 | --------------------------------------------------------------------------*/ |
| 7753 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter) |
| 7754 | { |
| 7755 | tCsrScanRequest scanReq; |
| 7756 | tCsrChannelInfo channelInfo; |
| 7757 | eHalStatus halStatus; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 7758 | tANI_U32 scanId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7759 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7760 | |
| 7761 | vos_mem_zero(&scanReq, sizeof(tCsrScanRequest)); |
| 7762 | vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff); |
| 7763 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 7764 | |
| 7765 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 7766 | { |
| 7767 | halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo ); |
| 7768 | if ( HAL_STATUS_SUCCESS( halStatus ) ) |
| 7769 | { |
| 7770 | scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels); |
| 7771 | if( !scanReq.ChannelInfo.ChannelList ) |
| 7772 | { |
| 7773 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__); |
| 7774 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 7775 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7776 | return; |
| 7777 | } |
| 7778 | vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList, |
| 7779 | channelInfo.numOfChannels); |
| 7780 | scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels; |
| 7781 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 7782 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7783 | } |
| 7784 | |
| 7785 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 7786 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 7787 | scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime; |
| 7788 | scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime; |
| 7789 | } |
| 7790 | else |
| 7791 | { |
| 7792 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 7793 | scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 7794 | scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime; |
| 7795 | scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime; |
| 7796 | } |
| 7797 | |
| 7798 | halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL); |
| 7799 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 7800 | { |
| 7801 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d", |
| 7802 | __func__, halStatus ); |
| 7803 | } |
| 7804 | |
| 7805 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 7806 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
| 7807 | } |
| 7808 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7809 | /**--------------------------------------------------------------------------- |
| 7810 | |
| 7811 | \brief hdd_full_power_callback() - HDD full power callback function |
| 7812 | |
| 7813 | This is the function invoked by SME to inform the result of a full power |
| 7814 | request issued by HDD |
| 7815 | |
| 7816 | \param - callbackcontext - Pointer to cookie |
| 7817 | \param - status - result of request |
| 7818 | |
| 7819 | \return - None |
| 7820 | |
| 7821 | --------------------------------------------------------------------------*/ |
| 7822 | static void hdd_full_power_callback(void *callbackContext, eHalStatus status) |
| 7823 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7824 | struct statsContext *pContext = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7825 | |
| 7826 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 7827 | "%s: context = %p, status = %d", __func__, pContext, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7828 | |
| 7829 | if (NULL == callbackContext) |
| 7830 | { |
| 7831 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7832 | "%s: Bad param, context [%p]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7833 | __func__, callbackContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7834 | return; |
| 7835 | } |
| 7836 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7837 | /* there is a race condition that exists between this callback |
| 7838 | function and the caller since the caller could time out either |
| 7839 | before or while this code is executing. we use a spinlock to |
| 7840 | serialize these actions */ |
| 7841 | spin_lock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7842 | |
| 7843 | if (POWER_CONTEXT_MAGIC != pContext->magic) |
| 7844 | { |
| 7845 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7846 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7847 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 7848 | "%s: Invalid context, magic [%08x]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7849 | __func__, pContext->magic); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7850 | return; |
| 7851 | } |
| 7852 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7853 | /* context is valid so caller is still waiting */ |
| 7854 | |
| 7855 | /* paranoia: invalidate the magic */ |
| 7856 | pContext->magic = 0; |
| 7857 | |
| 7858 | /* notify the caller */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7859 | complete(&pContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7860 | |
| 7861 | /* serialization is complete */ |
| 7862 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7863 | } |
| 7864 | |
| 7865 | /**--------------------------------------------------------------------------- |
| 7866 | |
| 7867 | \brief hdd_wlan_exit() - HDD WLAN exit function |
| 7868 | |
| 7869 | This is the driver exit point (invoked during rmmod) |
| 7870 | |
| 7871 | \param - pHddCtx - Pointer to the HDD Context |
| 7872 | |
| 7873 | \return - None |
| 7874 | |
| 7875 | --------------------------------------------------------------------------*/ |
| 7876 | void hdd_wlan_exit(hdd_context_t *pHddCtx) |
| 7877 | { |
| 7878 | eHalStatus halStatus; |
| 7879 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
| 7880 | VOS_STATUS vosStatus; |
Gopichand Nakkala | 66923aa | 2013-03-06 23:17:24 +0530 | [diff] [blame] | 7881 | struct wiphy *wiphy = pHddCtx->wiphy; |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 7882 | hdd_adapter_t* pAdapter = NULL; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7883 | struct statsContext powerContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7884 | long lrc; |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7885 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7886 | |
| 7887 | ENTER(); |
| 7888 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7889 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 7890 | { |
| 7891 | // Unloading, restart logic is no more required. |
| 7892 | wlan_hdd_restart_deinit(pHddCtx); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7893 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7894 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7895 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7896 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7897 | pAdapter = pAdapterNode->pAdapter; |
| 7898 | if (NULL != pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7899 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7900 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 7901 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
| 7902 | { |
| 7903 | wlan_hdd_cfg80211_deregister_frames(pAdapter); |
| 7904 | hdd_UnregisterWext(pAdapter->dev); |
| 7905 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7906 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7907 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7908 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7909 | pAdapterNode = pNext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7910 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7911 | // Cancel any outstanding scan requests. We are about to close all |
| 7912 | // of our adapters, but an adapter structure is what SME passes back |
| 7913 | // to our callback function. Hence if there are any outstanding scan |
| 7914 | // requests then there is a race condition between when the adapter |
| 7915 | // is closed and when the callback is invoked.We try to resolve that |
| 7916 | // race condition here by canceling any outstanding scans before we |
| 7917 | // close the adapters. |
| 7918 | // Note that the scans may be cancelled in an asynchronous manner, |
| 7919 | // so ideally there needs to be some kind of synchronization. Rather |
| 7920 | // than introduce a new synchronization here, we will utilize the |
| 7921 | // fact that we are about to Request Full Power, and since that is |
| 7922 | // synchronized, the expectation is that by the time Request Full |
| 7923 | // Power has completed all scans will be cancelled. |
| 7924 | if (pHddCtx->scan_info.mScanPending) |
| 7925 | { |
| 7926 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7927 | FL("abort scan mode: %d sessionId: %d"), |
| 7928 | pAdapter->device_mode, |
| 7929 | pAdapter->sessionId); |
| 7930 | hdd_abort_mac_scan(pHddCtx, |
| 7931 | pHddCtx->scan_info.sessionId, |
| 7932 | eCSR_SCAN_ABORT_DEFAULT); |
| 7933 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7934 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7935 | else |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7936 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7937 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__); |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7938 | wlan_hdd_ftm_close(pHddCtx); |
| 7939 | goto free_hdd_ctx; |
| 7940 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7941 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7942 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 7943 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 7944 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 7945 | { |
| 7946 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 7947 | VOS_ASSERT(0); |
| 7948 | } |
| 7949 | |
| 7950 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 7951 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 7952 | { |
| 7953 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 7954 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7955 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 7956 | //Stop the traffic monitor timer |
| 7957 | if ( VOS_TIMER_STATE_RUNNING == |
| 7958 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) |
| 7959 | { |
| 7960 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 7961 | } |
| 7962 | |
| 7963 | // Destroy the traffic monitor timer |
| 7964 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 7965 | &pHddCtx->tx_rx_trafficTmr))) |
| 7966 | { |
| 7967 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7968 | "%s: Cannot deallocate Traffic monitor timer", __func__); |
| 7969 | } |
| 7970 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7971 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 7972 | //save mode during shutdown |
| 7973 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 7974 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 7975 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 7976 | |
| 7977 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 7978 | init_completion(&powerContext.completion); |
| 7979 | powerContext.magic = POWER_CONTEXT_MAGIC; |
| 7980 | |
| 7981 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback, |
| 7982 | &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 7983 | |
| 7984 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 7985 | { |
| 7986 | if (eHAL_STATUS_PMC_PENDING == halStatus) |
| 7987 | { |
| 7988 | /* request was sent -- wait for the response */ |
| 7989 | lrc = wait_for_completion_interruptible_timeout( |
| 7990 | &powerContext.completion, |
| 7991 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7992 | if (lrc <= 0) |
| 7993 | { |
| 7994 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7995 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7996 | } |
| 7997 | } |
| 7998 | else |
| 7999 | { |
| 8000 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8001 | "%s: Request for Full Power failed, status %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8002 | __func__, halStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8003 | /* continue -- need to clean up as much as possible */ |
| 8004 | } |
| 8005 | } |
| 8006 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8007 | /* either we never sent a request, we sent a request and received a |
| 8008 | response or we sent a request and timed out. if we never sent a |
| 8009 | request or if we sent a request and got a response, we want to |
| 8010 | clear the magic out of paranoia. if we timed out there is a |
| 8011 | race condition such that the callback function could be |
| 8012 | executing at the same time we are. of primary concern is if the |
| 8013 | callback function had already verified the "magic" but had not |
| 8014 | yet set the completion variable when a timeout occurred. we |
| 8015 | serialize these activities by invalidating the magic while |
| 8016 | holding a shared spinlock which will cause us to block if the |
| 8017 | callback is currently executing */ |
| 8018 | spin_lock(&hdd_context_lock); |
| 8019 | powerContext.magic = 0; |
| 8020 | spin_unlock(&hdd_context_lock); |
| 8021 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8022 | hdd_debugfs_exit(pHddCtx); |
| 8023 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8024 | // Unregister the Net Device Notifier |
| 8025 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 8026 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8027 | hdd_stop_all_adapters( pHddCtx ); |
| 8028 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8029 | #ifdef WLAN_BTAMP_FEATURE |
| 8030 | vosStatus = WLANBAP_Stop(pVosContext); |
| 8031 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8032 | { |
| 8033 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8034 | "%s: Failed to stop BAP",__func__); |
| 8035 | } |
| 8036 | #endif //WLAN_BTAMP_FEATURE |
| 8037 | |
| 8038 | //Stop all the modules |
| 8039 | vosStatus = vos_stop( pVosContext ); |
| 8040 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8041 | { |
| 8042 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8043 | "%s: Failed to stop VOSS",__func__); |
| 8044 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8045 | } |
| 8046 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8047 | //This requires pMac access, Call this before vos_close(). |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8048 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8049 | |
| 8050 | //Close the scheduler before calling vos_close to make sure no thread is |
| 8051 | // scheduled after the each module close is called i.e after all the data |
| 8052 | // structures are freed. |
| 8053 | vosStatus = vos_sched_close( pVosContext ); |
| 8054 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 8055 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 8056 | "%s: Failed to close VOSS Scheduler",__func__); |
| 8057 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8058 | } |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8059 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8060 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 8061 | /* Destroy the wake lock */ |
| 8062 | wake_lock_destroy(&pHddCtx->rx_wake_lock); |
| 8063 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 8064 | /* Destroy the wake lock */ |
| 8065 | wake_lock_destroy(&pHddCtx->sap_wake_lock); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8066 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8067 | |
Mihir Shete | 7a24b5f | 2013-12-21 12:18:31 +0530 | [diff] [blame] | 8068 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 8069 | vosStatus = vos_nv_close(); |
| 8070 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8071 | { |
| 8072 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8073 | "%s: Failed to close NV", __func__); |
| 8074 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8075 | } |
| 8076 | #endif |
| 8077 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8078 | //Close VOSS |
| 8079 | //This frees pMac(HAL) context. There should not be any call that requires pMac access after this. |
| 8080 | vos_close(pVosContext); |
| 8081 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8082 | //Close Watchdog |
| 8083 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 8084 | vos_watchdog_close(pVosContext); |
| 8085 | |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 8086 | //Clean up HDD Nlink Service |
| 8087 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 8088 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 8089 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 8090 | if (pHddCtx->cfg_ini->wlanLoggingEnable) |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 8091 | { |
| 8092 | wlan_logging_sock_deactivate_svc(); |
| 8093 | } |
| 8094 | #endif |
| 8095 | |
Vinay Krishna Eranna | ef30b52 | 2014-08-26 17:48:16 +0530 | [diff] [blame] | 8096 | #ifdef WLAN_KD_READY_NOTIFIER |
| 8097 | nl_srv_exit(pHddCtx->ptt_pid); |
| 8098 | #else |
| 8099 | nl_srv_exit(); |
| 8100 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 8101 | |
| 8102 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8103 | hdd_close_all_adapters( pHddCtx ); |
| 8104 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8105 | /* free the power on lock from platform driver */ |
| 8106 | if (free_riva_power_on_lock("wlan")) |
| 8107 | { |
| 8108 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 8109 | __func__); |
| 8110 | } |
| 8111 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8112 | free_hdd_ctx: |
c_hpothu | 78c7b60 | 2014-05-17 17:35:49 +0530 | [diff] [blame] | 8113 | |
| 8114 | //Free up dynamically allocated members inside HDD Adapter |
| 8115 | if (pHddCtx->cfg_ini) |
| 8116 | { |
| 8117 | kfree(pHddCtx->cfg_ini); |
| 8118 | pHddCtx->cfg_ini= NULL; |
| 8119 | } |
| 8120 | |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 8121 | /* FTM mode, WIPHY did not registered |
| 8122 | If un-register here, system crash will happen */ |
| 8123 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 8124 | { |
| 8125 | wiphy_unregister(wiphy) ; |
| 8126 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8127 | wiphy_free(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8128 | if (hdd_is_ssr_required()) |
| 8129 | { |
| 8130 | /* WDI timeout had happened during unload, so SSR is needed here */ |
Madan Mohan Koyyalamudi | 3246f5b | 2012-10-15 15:40:02 -0700 | [diff] [blame] | 8131 | subsystem_restart("wcnss"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8132 | msleep(5000); |
| 8133 | } |
| 8134 | hdd_set_ssr_required (VOS_FALSE); |
| 8135 | } |
| 8136 | |
| 8137 | |
| 8138 | /**--------------------------------------------------------------------------- |
| 8139 | |
| 8140 | \brief hdd_update_config_from_nv() - Function to update the contents of |
| 8141 | the running configuration with parameters taken from NV storage |
| 8142 | |
| 8143 | \param - pHddCtx - Pointer to the HDD global context |
| 8144 | |
| 8145 | \return - VOS_STATUS_SUCCESS if successful |
| 8146 | |
| 8147 | --------------------------------------------------------------------------*/ |
| 8148 | static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx) |
| 8149 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8150 | v_BOOL_t itemIsValid = VOS_FALSE; |
| 8151 | VOS_STATUS status; |
| 8152 | v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA]; |
| 8153 | v_U8_t macLoop; |
| 8154 | |
| 8155 | /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/ |
| 8156 | status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid); |
| 8157 | if(status != VOS_STATUS_SUCCESS) |
| 8158 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8159 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8160 | return VOS_STATUS_E_FAILURE; |
| 8161 | } |
| 8162 | |
| 8163 | if (itemIsValid == VOS_TRUE) |
| 8164 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8165 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8166 | status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0], |
| 8167 | VOS_MAX_CONCURRENCY_PERSONA); |
| 8168 | if(status != VOS_STATUS_SUCCESS) |
| 8169 | { |
| 8170 | /* Get MAC from NV fail, not update CFG info |
| 8171 | * INI MAC value will be used for MAC setting */ |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8172 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8173 | return VOS_STATUS_E_FAILURE; |
| 8174 | } |
| 8175 | |
| 8176 | /* If first MAC is not valid, treat all others are not valid |
| 8177 | * Then all MACs will be got from ini file */ |
| 8178 | if(vos_is_macaddr_zero(&macFromNV[0])) |
| 8179 | { |
| 8180 | /* MAC address in NV file is not configured yet */ |
| 8181 | hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file"); |
| 8182 | return VOS_STATUS_E_INVAL; |
| 8183 | } |
| 8184 | |
| 8185 | /* Get MAC address from NV, update CFG info */ |
| 8186 | for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++) |
| 8187 | { |
| 8188 | if(vos_is_macaddr_zero(&macFromNV[macLoop])) |
| 8189 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8190 | hddLog(VOS_TRACE_LEVEL_ERROR,"not valid MAC from NV for %d", macLoop); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8191 | /* This MAC is not valid, skip it |
| 8192 | * This MAC will be got from ini file */ |
| 8193 | } |
| 8194 | else |
| 8195 | { |
| 8196 | vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0], |
| 8197 | (v_U8_t *)&macFromNV[macLoop].bytes[0], |
| 8198 | VOS_MAC_ADDR_SIZE); |
| 8199 | } |
| 8200 | } |
| 8201 | } |
| 8202 | else |
| 8203 | { |
| 8204 | hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid"); |
| 8205 | return VOS_STATUS_E_FAILURE; |
| 8206 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8207 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8208 | |
| 8209 | return VOS_STATUS_SUCCESS; |
| 8210 | } |
| 8211 | |
| 8212 | /**--------------------------------------------------------------------------- |
| 8213 | |
| 8214 | \brief hdd_post_voss_start_config() - HDD post voss start config helper |
| 8215 | |
| 8216 | \param - pAdapter - Pointer to the HDD |
| 8217 | |
| 8218 | \return - None |
| 8219 | |
| 8220 | --------------------------------------------------------------------------*/ |
| 8221 | VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx) |
| 8222 | { |
| 8223 | eHalStatus halStatus; |
| 8224 | v_U32_t listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8225 | tANI_U32 ignoreDtim; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8226 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8227 | |
| 8228 | // Send ready indication to the HDD. This will kick off the MAC |
| 8229 | // into a 'running' state and should kick off an initial scan. |
| 8230 | halStatus = sme_HDDReadyInd( pHddCtx->hHal ); |
| 8231 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 8232 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8233 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8234 | "code %08d [x%08x]",__func__, halStatus, halStatus ); |
| 8235 | return VOS_STATUS_E_FAILURE; |
| 8236 | } |
| 8237 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8238 | // Set default LI and ignoreDtim into HDD context, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8239 | // otherwise under some race condition, HDD will set 0 LI value into RIVA, |
| 8240 | // And RIVA will crash |
| 8241 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval); |
| 8242 | pHddCtx->hdd_actual_LI_value = listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8243 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim); |
| 8244 | pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim; |
| 8245 | |
| 8246 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8247 | return VOS_STATUS_SUCCESS; |
| 8248 | } |
| 8249 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8250 | /* wake lock APIs for HDD */ |
| 8251 | void hdd_prevent_suspend(void) |
| 8252 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8253 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8254 | wake_lock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8255 | #else |
| 8256 | wcnss_prevent_suspend(); |
| 8257 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8258 | } |
| 8259 | |
| 8260 | void hdd_allow_suspend(void) |
| 8261 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8262 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8263 | wake_unlock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8264 | #else |
| 8265 | wcnss_allow_suspend(); |
| 8266 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8267 | } |
| 8268 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 8269 | void hdd_prevent_suspend_timeout(v_U32_t timeout) |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8270 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8271 | #ifdef WLAN_OPEN_SOURCE |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 8272 | wake_lock_timeout(&wlan_wake_lock, msecs_to_jiffies(timeout)); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8273 | #else |
| 8274 | /* Do nothing as there is no API in wcnss for timeout*/ |
| 8275 | #endif |
| 8276 | } |
| 8277 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8278 | /**--------------------------------------------------------------------------- |
| 8279 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8280 | \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability |
| 8281 | information between Host and Riva |
| 8282 | |
| 8283 | This function gets reported version of FW |
| 8284 | It also finds the version of Riva headers used to compile the host |
| 8285 | It compares the above two and prints a warning if they are different |
| 8286 | It gets the SW and HW version string |
| 8287 | Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg |
| 8288 | indicating the features they support through a bitmap |
| 8289 | |
| 8290 | \param - pHddCtx - Pointer to HDD context |
| 8291 | |
| 8292 | \return - void |
| 8293 | |
| 8294 | --------------------------------------------------------------------------*/ |
| 8295 | |
| 8296 | void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx) |
| 8297 | { |
| 8298 | |
| 8299 | tSirVersionType versionCompiled; |
| 8300 | tSirVersionType versionReported; |
| 8301 | tSirVersionString versionString; |
| 8302 | tANI_U8 fwFeatCapsMsgSupported = 0; |
| 8303 | VOS_STATUS vstatus; |
| 8304 | |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8305 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 8306 | memset(&versionReported, 0, sizeof(versionReported)); |
| 8307 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8308 | /* retrieve and display WCNSS version information */ |
| 8309 | do { |
| 8310 | |
| 8311 | vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal, |
| 8312 | &versionCompiled); |
| 8313 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8314 | { |
| 8315 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8316 | "%s: unable to retrieve WCNSS WLAN compiled version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8317 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8318 | break; |
| 8319 | } |
| 8320 | |
| 8321 | vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal, |
| 8322 | &versionReported); |
| 8323 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8324 | { |
| 8325 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8326 | "%s: unable to retrieve WCNSS WLAN reported version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8327 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8328 | break; |
| 8329 | } |
| 8330 | |
| 8331 | if ((versionCompiled.major != versionReported.major) || |
| 8332 | (versionCompiled.minor != versionReported.minor) || |
| 8333 | (versionCompiled.version != versionReported.version) || |
| 8334 | (versionCompiled.revision != versionReported.revision)) |
| 8335 | { |
| 8336 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 8337 | "Host expected %u.%u.%u.%u\n", |
| 8338 | WLAN_MODULE_NAME, |
| 8339 | (int)versionReported.major, |
| 8340 | (int)versionReported.minor, |
| 8341 | (int)versionReported.version, |
| 8342 | (int)versionReported.revision, |
| 8343 | (int)versionCompiled.major, |
| 8344 | (int)versionCompiled.minor, |
| 8345 | (int)versionCompiled.version, |
| 8346 | (int)versionCompiled.revision); |
| 8347 | } |
| 8348 | else |
| 8349 | { |
| 8350 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 8351 | WLAN_MODULE_NAME, |
| 8352 | (int)versionReported.major, |
| 8353 | (int)versionReported.minor, |
| 8354 | (int)versionReported.version, |
| 8355 | (int)versionReported.revision); |
| 8356 | } |
| 8357 | |
| 8358 | vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal, |
| 8359 | versionString, |
| 8360 | sizeof(versionString)); |
| 8361 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8362 | { |
| 8363 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8364 | "%s: unable to retrieve WCNSS software version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8365 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8366 | break; |
| 8367 | } |
| 8368 | |
| 8369 | pr_info("%s: WCNSS software version %s\n", |
| 8370 | WLAN_MODULE_NAME, versionString); |
| 8371 | |
| 8372 | vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal, |
| 8373 | versionString, |
| 8374 | sizeof(versionString)); |
| 8375 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8376 | { |
| 8377 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8378 | "%s: unable to retrieve WCNSS hardware version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8379 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8380 | break; |
| 8381 | } |
| 8382 | |
| 8383 | pr_info("%s: WCNSS hardware version %s\n", |
| 8384 | WLAN_MODULE_NAME, versionString); |
| 8385 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8386 | /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message |
| 8387 | 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] | 8388 | send the message only if it the riva is 1.1 |
| 8389 | minor numbers for different riva branches: |
| 8390 | 0 -> (1.0)Mainline Build |
| 8391 | 1 -> (1.1)Mainline Build |
| 8392 | 2->(1.04) Stability Build |
| 8393 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8394 | if (((versionReported.major>0) || (versionReported.minor>1) || |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8395 | ((versionReported.minor>=1) && (versionReported.version>=1))) |
| 8396 | && ((versionReported.major == 1) && (versionReported.minor >= 1))) |
| 8397 | fwFeatCapsMsgSupported = 1; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8398 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8399 | if (fwFeatCapsMsgSupported) |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8400 | { |
| 8401 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 8402 | if(!pHddCtx->cfg_ini->fEnableActiveModeOffload) |
| 8403 | sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD); |
| 8404 | #endif |
Ravi Joshi | d2ca7c4 | 2013-07-23 08:37:49 -0700 | [diff] [blame] | 8405 | /* Indicate if IBSS heartbeat monitoring needs to be offloaded */ |
| 8406 | if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload) |
| 8407 | { |
| 8408 | sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD); |
| 8409 | } |
| 8410 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8411 | sme_featureCapsExchange(pHddCtx->hHal); |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8412 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8413 | |
| 8414 | } while (0); |
| 8415 | |
| 8416 | } |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 8417 | void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len) |
| 8418 | { |
| 8419 | struct sk_buff *skb; |
| 8420 | struct nlmsghdr *nlh; |
| 8421 | tAniMsgHdr *ani_hdr; |
| 8422 | |
| 8423 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), GFP_KERNEL); |
| 8424 | |
| 8425 | if(skb == NULL) { |
| 8426 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8427 | "%s: alloc_skb failed", __func__); |
| 8428 | return; |
| 8429 | } |
| 8430 | |
| 8431 | nlh = (struct nlmsghdr *)skb->data; |
| 8432 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 8433 | nlh->nlmsg_flags = 0; |
| 8434 | nlh->nlmsg_seq = 0; |
| 8435 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 8436 | |
| 8437 | ani_hdr = NLMSG_DATA(nlh); |
| 8438 | ani_hdr->type = type; |
| 8439 | |
| 8440 | switch(type) { |
| 8441 | case WLAN_SVC_SAP_RESTART_IND: |
| 8442 | ani_hdr->length = 0; |
| 8443 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
| 8444 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr))); |
| 8445 | break; |
| 8446 | default: |
| 8447 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8448 | "Attempt to send unknown nlink message %d", type); |
| 8449 | kfree_skb(skb); |
| 8450 | return; |
| 8451 | } |
| 8452 | |
| 8453 | nl_srv_bcast(skb); |
| 8454 | |
| 8455 | return; |
| 8456 | } |
| 8457 | |
| 8458 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8459 | |
| 8460 | /**--------------------------------------------------------------------------- |
| 8461 | |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8462 | \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz |
| 8463 | |
| 8464 | \param - pHddCtx - Pointer to the hdd context |
| 8465 | |
| 8466 | \return - true if hardware supports 5GHz |
| 8467 | |
| 8468 | --------------------------------------------------------------------------*/ |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 8469 | boolean hdd_is_5g_supported(hdd_context_t * pHddCtx) |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8470 | { |
| 8471 | /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1); |
| 8472 | * then hardware support 5Ghz. |
| 8473 | */ |
| 8474 | if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode()) |
| 8475 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8476 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8477 | return true; |
| 8478 | } |
| 8479 | else |
| 8480 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8481 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz", |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8482 | __func__); |
| 8483 | return false; |
| 8484 | } |
| 8485 | } |
| 8486 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8487 | /**--------------------------------------------------------------------------- |
| 8488 | |
| 8489 | \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto |
| 8490 | generate function |
| 8491 | |
| 8492 | This is generate the random mac address for WLAN interface |
| 8493 | |
| 8494 | \param - pHddCtx - Pointer to HDD context |
| 8495 | idx - Start interface index to get auto |
| 8496 | generated mac addr. |
| 8497 | mac_addr - Mac address |
| 8498 | |
| 8499 | \return - 0 for success, < 0 for failure |
| 8500 | |
| 8501 | --------------------------------------------------------------------------*/ |
| 8502 | |
| 8503 | static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx, |
| 8504 | int idx, v_MACADDR_t mac_addr) |
| 8505 | { |
| 8506 | int i; |
| 8507 | unsigned int serialno; |
| 8508 | serialno = wcnss_get_serial_number(); |
| 8509 | |
| 8510 | if (0 != serialno) |
| 8511 | { |
| 8512 | /* MAC address has 3 bytes of OUI so we have a maximum of 3 |
| 8513 | bytes of the serial number that can be used to generate |
| 8514 | the other 3 bytes of the MAC address. Mask off all but |
| 8515 | the lower 3 bytes (this will also make sure we don't |
| 8516 | overflow in the next step) */ |
| 8517 | serialno &= 0x00FFFFFF; |
| 8518 | |
| 8519 | /* we need a unique address for each session */ |
| 8520 | serialno *= VOS_MAX_CONCURRENCY_PERSONA; |
| 8521 | |
| 8522 | /* autogen other Mac addresses */ |
| 8523 | for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 8524 | { |
| 8525 | /* start with the entire default address */ |
| 8526 | pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr; |
| 8527 | /* then replace the lower 3 bytes */ |
| 8528 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF; |
| 8529 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF; |
| 8530 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF; |
| 8531 | |
| 8532 | serialno++; |
| 8533 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8534 | "%s: Derived Mac Addr: " |
| 8535 | MAC_ADDRESS_STR, __func__, |
| 8536 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes)); |
| 8537 | } |
| 8538 | |
| 8539 | } |
| 8540 | else |
| 8541 | { |
| 8542 | hddLog(LOGE, FL("Failed to Get Serial NO")); |
| 8543 | return -1; |
| 8544 | } |
| 8545 | return 0; |
| 8546 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8547 | |
| 8548 | /**--------------------------------------------------------------------------- |
| 8549 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 8550 | \brief hdd_11d_scan_done - callback to be executed when 11d scan is |
| 8551 | completed to flush out the scan results |
| 8552 | |
| 8553 | 11d scan is done during driver load and is a passive scan on all |
| 8554 | channels supported by the device, 11d scans may find some APs on |
| 8555 | frequencies which are forbidden to be used in the regulatory domain |
| 8556 | the device is operating in. If these APs are notified to the supplicant |
| 8557 | it may try to connect to these APs, thus flush out all the scan results |
| 8558 | which are present in SME after 11d scan is done. |
| 8559 | |
| 8560 | \return - eHalStatus |
| 8561 | |
| 8562 | --------------------------------------------------------------------------*/ |
| 8563 | static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
| 8564 | tANI_U32 scanId, eCsrScanStatus status) |
| 8565 | { |
| 8566 | ENTER(); |
| 8567 | |
| 8568 | sme_ScanFlushResult(halHandle, 0); |
| 8569 | |
| 8570 | EXIT(); |
| 8571 | |
| 8572 | return eHAL_STATUS_SUCCESS; |
| 8573 | } |
| 8574 | |
| 8575 | /**--------------------------------------------------------------------------- |
| 8576 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8577 | \brief hdd_wlan_startup() - HDD init function |
| 8578 | |
| 8579 | This is the driver startup code executed once a WLAN device has been detected |
| 8580 | |
| 8581 | \param - dev - Pointer to the underlying device |
| 8582 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8583 | \return - 0 for success, < 0 for failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8584 | |
| 8585 | --------------------------------------------------------------------------*/ |
| 8586 | |
| 8587 | int hdd_wlan_startup(struct device *dev ) |
| 8588 | { |
| 8589 | VOS_STATUS status; |
| 8590 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8591 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8592 | hdd_context_t *pHddCtx = NULL; |
| 8593 | v_CONTEXT_t pVosContext= NULL; |
| 8594 | #ifdef WLAN_BTAMP_FEATURE |
| 8595 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 8596 | WLANBAP_ConfigType btAmpConfig; |
| 8597 | hdd_config_t *pConfig; |
| 8598 | #endif |
| 8599 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8600 | struct wiphy *wiphy; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8601 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8602 | |
| 8603 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8604 | /* |
| 8605 | * cfg80211: wiphy allocation |
| 8606 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8607 | wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8608 | |
| 8609 | if(wiphy == NULL) |
| 8610 | { |
| 8611 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8612 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8613 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8614 | pHddCtx = wiphy_priv(wiphy); |
| 8615 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8616 | //Initialize the adapter context to zeros. |
| 8617 | vos_mem_zero(pHddCtx, sizeof( hdd_context_t )); |
| 8618 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8619 | pHddCtx->wiphy = wiphy; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8620 | hdd_prevent_suspend(); |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 8621 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8622 | |
| 8623 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 8624 | |
| 8625 | /*Get vos context here bcoz vos_open requires it*/ |
| 8626 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 8627 | |
Madan Mohan Koyyalamudi | 0b78e15 | 2012-11-28 15:46:51 -0800 | [diff] [blame] | 8628 | if(pVosContext == NULL) |
| 8629 | { |
| 8630 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__); |
| 8631 | goto err_free_hdd_context; |
| 8632 | } |
| 8633 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8634 | //Save the Global VOSS context in adapter context for future. |
| 8635 | pHddCtx->pvosContext = pVosContext; |
| 8636 | |
| 8637 | //Save the adapter context in global context for future. |
| 8638 | ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx; |
| 8639 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8640 | pHddCtx->parent_dev = dev; |
| 8641 | |
| 8642 | init_completion(&pHddCtx->full_pwr_comp_var); |
| 8643 | init_completion(&pHddCtx->standby_comp_var); |
| 8644 | init_completion(&pHddCtx->req_bmps_comp_var); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8645 | init_completion(&pHddCtx->scan_info.scan_req_completion_event); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 8646 | init_completion(&pHddCtx->scan_info.abortscan_event_var); |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 8647 | init_completion(&pHddCtx->wiphy_channel_update_event); |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 8648 | init_completion(&pHddCtx->ssr_comp_var); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8649 | |
| 8650 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 8651 | init_completion(&pHddCtx->linux_reg_req); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8652 | #else |
| 8653 | init_completion(&pHddCtx->driver_crda_req); |
| 8654 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8655 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8656 | spin_lock_init(&pHddCtx->schedScan_lock); |
| 8657 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8658 | hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS ); |
| 8659 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8660 | #ifdef FEATURE_WLAN_TDLS |
| 8661 | /* tdls_lock is initialized before an hdd_open_adapter ( which is |
| 8662 | * invoked by other instances also) to protect the concurrent |
| 8663 | * access for the Adapters by TDLS module. |
| 8664 | */ |
| 8665 | mutex_init(&pHddCtx->tdls_lock); |
| 8666 | #endif |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 8667 | mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock); |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 8668 | /* By default Strict Regulatory For FCC should be false */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8669 | |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 8670 | pHddCtx->nEnableStrictRegulatoryForFCC = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8671 | // Load all config first as TL config is needed during vos_open |
| 8672 | pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL); |
| 8673 | if(pHddCtx->cfg_ini == NULL) |
| 8674 | { |
| 8675 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__); |
| 8676 | goto err_free_hdd_context; |
| 8677 | } |
| 8678 | |
| 8679 | vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t )); |
| 8680 | |
| 8681 | // Read and parse the qcom_cfg.ini file |
| 8682 | status = hdd_parse_config_ini( pHddCtx ); |
| 8683 | if ( VOS_STATUS_SUCCESS != status ) |
| 8684 | { |
| 8685 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s", |
| 8686 | __func__, WLAN_INI_FILE); |
| 8687 | goto err_config; |
| 8688 | } |
Arif Hussain | d521891 | 2013-12-05 01:10:55 -0800 | [diff] [blame] | 8689 | #ifdef MEMORY_DEBUG |
| 8690 | if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled) |
| 8691 | vos_mem_init(); |
| 8692 | |
| 8693 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d", |
| 8694 | __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled); |
| 8695 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8696 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 8697 | /* INI has been read, initialise the configuredMcastBcastFilter with |
| 8698 | * INI value as this will serve as the default value |
| 8699 | */ |
| 8700 | pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting; |
| 8701 | hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d", |
| 8702 | pHddCtx->cfg_ini->mcastBcastFilterSetting); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8703 | |
| 8704 | if (false == hdd_is_5g_supported(pHddCtx)) |
| 8705 | { |
| 8706 | //5Ghz is not supported. |
| 8707 | if (1 != pHddCtx->cfg_ini->nBandCapability) |
| 8708 | { |
| 8709 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8710 | "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__); |
| 8711 | pHddCtx->cfg_ini->nBandCapability = 1; |
| 8712 | } |
| 8713 | } |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8714 | |
| 8715 | /* If SNR Monitoring is enabled, FW has to parse all beacons |
| 8716 | * for calcaluting and storing the average SNR, so set Nth beacon |
| 8717 | * filter to 1 to enable FW to parse all the beaocons |
| 8718 | */ |
| 8719 | if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring) |
| 8720 | { |
| 8721 | /* The log level is deliberately set to WARN as overriding |
| 8722 | * nthBeaconFilter to 1 will increase power cosumption and this |
| 8723 | * might just prove helpful to detect the power issue. |
| 8724 | */ |
| 8725 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 8726 | "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__); |
| 8727 | pHddCtx->cfg_ini->nthBeaconFilter = 1; |
| 8728 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8729 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8730 | * cfg80211: Initialization ... |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8731 | */ |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 8732 | if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8733 | { |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 8734 | if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini)) |
| 8735 | { |
| 8736 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8737 | "%s: wlan_hdd_cfg80211_init return failure", __func__); |
| 8738 | goto err_config; |
| 8739 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8740 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8741 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8742 | // Update VOS trace levels based upon the cfg.ini |
| 8743 | hdd_vos_trace_enable(VOS_MODULE_ID_BAP, |
| 8744 | pHddCtx->cfg_ini->vosTraceEnableBAP); |
| 8745 | hdd_vos_trace_enable(VOS_MODULE_ID_TL, |
| 8746 | pHddCtx->cfg_ini->vosTraceEnableTL); |
| 8747 | hdd_vos_trace_enable(VOS_MODULE_ID_WDI, |
| 8748 | pHddCtx->cfg_ini->vosTraceEnableWDI); |
| 8749 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD, |
| 8750 | pHddCtx->cfg_ini->vosTraceEnableHDD); |
| 8751 | hdd_vos_trace_enable(VOS_MODULE_ID_SME, |
| 8752 | pHddCtx->cfg_ini->vosTraceEnableSME); |
| 8753 | hdd_vos_trace_enable(VOS_MODULE_ID_PE, |
| 8754 | pHddCtx->cfg_ini->vosTraceEnablePE); |
Katya Nigam | 70d6833 | 2013-09-16 16:49:45 +0530 | [diff] [blame] | 8755 | hdd_vos_trace_enable(VOS_MODULE_ID_PMC, |
| 8756 | pHddCtx->cfg_ini->vosTraceEnablePMC); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8757 | hdd_vos_trace_enable(VOS_MODULE_ID_WDA, |
| 8758 | pHddCtx->cfg_ini->vosTraceEnableWDA); |
| 8759 | hdd_vos_trace_enable(VOS_MODULE_ID_SYS, |
| 8760 | pHddCtx->cfg_ini->vosTraceEnableSYS); |
| 8761 | hdd_vos_trace_enable(VOS_MODULE_ID_VOSS, |
| 8762 | pHddCtx->cfg_ini->vosTraceEnableVOSS); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8763 | hdd_vos_trace_enable(VOS_MODULE_ID_SAP, |
| 8764 | pHddCtx->cfg_ini->vosTraceEnableSAP); |
| 8765 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP, |
| 8766 | pHddCtx->cfg_ini->vosTraceEnableHDDSAP); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8767 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8768 | // Update WDI trace levels based upon the cfg.ini |
| 8769 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL, |
| 8770 | pHddCtx->cfg_ini->wdiTraceEnableDAL); |
| 8771 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL, |
| 8772 | pHddCtx->cfg_ini->wdiTraceEnableCTL); |
| 8773 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA, |
| 8774 | pHddCtx->cfg_ini->wdiTraceEnableDAT); |
| 8775 | hdd_wdi_trace_enable(eWLAN_MODULE_PAL, |
| 8776 | pHddCtx->cfg_ini->wdiTraceEnablePAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8777 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8778 | if (VOS_FTM_MODE == hdd_get_conparam()) |
| 8779 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8780 | if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) ) |
| 8781 | { |
| 8782 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__); |
| 8783 | goto err_free_hdd_context; |
| 8784 | } |
| 8785 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__); |
c_hpothu | 2de0ef6 | 2014-04-15 16:16:15 +0530 | [diff] [blame] | 8786 | |
| 8787 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8788 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8789 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8790 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8791 | //Open watchdog module |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8792 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 8793 | { |
| 8794 | status = vos_watchdog_open(pVosContext, |
| 8795 | &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext)); |
| 8796 | |
| 8797 | if(!VOS_IS_STATUS_SUCCESS( status )) |
| 8798 | { |
| 8799 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8800 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8801 | } |
| 8802 | } |
| 8803 | |
| 8804 | pHddCtx->isLogpInProgress = FALSE; |
| 8805 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 8806 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8807 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 8808 | /* initialize the NV module. This is required so that |
| 8809 | we can initialize the channel information in wiphy |
| 8810 | from the NV.bin data. The channel information in |
| 8811 | wiphy needs to be initialized before wiphy registration */ |
| 8812 | |
| 8813 | status = vos_nv_open(); |
| 8814 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8815 | { |
| 8816 | /* NV module cannot be initialized */ |
| 8817 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 8818 | "%s: vos_nv_open failed", __func__); |
Vinay Krishna Eranna | 2025d89 | 2014-09-18 16:51:42 +0530 | [diff] [blame] | 8819 | goto err_wdclose; |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 8820 | } |
| 8821 | |
| 8822 | status = vos_init_wiphy_from_nv_bin(); |
| 8823 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8824 | { |
| 8825 | /* NV module cannot be initialized */ |
| 8826 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 8827 | "%s: vos_init_wiphy failed", __func__); |
| 8828 | goto err_vos_nv_close; |
| 8829 | } |
| 8830 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8831 | #endif |
| 8832 | |
Arun Kumar Khandavalli | ebb1948 | 2014-03-25 13:56:53 +0530 | [diff] [blame] | 8833 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8834 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 8835 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8836 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 8837 | goto err_vos_nv_close; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8838 | } |
| 8839 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8840 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 8841 | |
| 8842 | if ( NULL == pHddCtx->hHal ) |
| 8843 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8844 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8845 | goto err_vosclose; |
| 8846 | } |
| 8847 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8848 | status = vos_preStart( pHddCtx->pvosContext ); |
| 8849 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8850 | { |
| 8851 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8852 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8853 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8854 | |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 8855 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) |
| 8856 | { |
| 8857 | pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan; |
| 8858 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d", |
| 8859 | __func__, enable_dfs_chan_scan); |
| 8860 | } |
| 8861 | if (0 == enable_11d || 1 == enable_11d) |
| 8862 | { |
| 8863 | pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d; |
| 8864 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d", |
| 8865 | __func__, enable_11d); |
| 8866 | } |
| 8867 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8868 | /* Note that the vos_preStart() sequence triggers the cfg download. |
| 8869 | The cfg download must occur before we update the SME config |
| 8870 | since the SME config operation must access the cfg database */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8871 | status = hdd_set_sme_config( pHddCtx ); |
| 8872 | |
| 8873 | if ( VOS_STATUS_SUCCESS != status ) |
| 8874 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8875 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed hdd_set_sme_config", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8876 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8877 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8878 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8879 | /* In the integrated architecture we update the configuration from |
| 8880 | the INI file and from NV before vOSS has been started so that |
| 8881 | the final contents are available to send down to the cCPU */ |
| 8882 | |
| 8883 | // Apply the cfg.ini to cfg.dat |
| 8884 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 8885 | { |
| 8886 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8887 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8888 | } |
| 8889 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8890 | // Get mac addr from platform driver |
| 8891 | ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes); |
| 8892 | |
| 8893 | if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8894 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8895 | /* Store the mac addr for first interface */ |
| 8896 | pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr; |
| 8897 | |
| 8898 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8899 | "%s: WLAN Mac Addr: " |
| 8900 | MAC_ADDRESS_STR, __func__, |
| 8901 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 8902 | |
| 8903 | /* Here, passing Arg2 as 1 because we do not want to change the |
| 8904 | last 3 bytes (means non OUI bytes) of first interface mac |
| 8905 | addr. |
| 8906 | */ |
| 8907 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr)) |
| 8908 | { |
| 8909 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8910 | "%s: Failed to generate wlan interface mac addr " |
| 8911 | "using MAC from ini file ", __func__); |
| 8912 | } |
| 8913 | } |
| 8914 | else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx)) |
| 8915 | { |
| 8916 | // Apply the NV to cfg.dat |
| 8917 | /* Prima Update MAC address only at here */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8918 | #ifdef WLAN_AUTOGEN_MACADDR_FEATURE |
| 8919 | /* There was not a valid set of MAC Addresses in NV. See if the |
| 8920 | default addresses were modified by the cfg.ini settings. If so, |
| 8921 | we'll use them, but if not, we'll autogenerate a set of MAC |
| 8922 | addresses based upon the device serial number */ |
| 8923 | |
| 8924 | static const v_MACADDR_t default_address = |
| 8925 | {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8926 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8927 | if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0], |
| 8928 | sizeof(default_address))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8929 | { |
| 8930 | /* cfg.ini has the default address, invoke autogen logic */ |
| 8931 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8932 | /* Here, passing Arg2 as 0 because we want to change the |
| 8933 | last 3 bytes (means non OUI bytes) of all the interfaces |
| 8934 | mac addr. |
| 8935 | */ |
| 8936 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0, |
| 8937 | default_address)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8938 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8939 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8940 | "%s: Failed to generate wlan interface mac addr " |
| 8941 | "using MAC from ini file " MAC_ADDRESS_STR, __func__, |
| 8942 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8943 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8944 | } |
| 8945 | else |
| 8946 | #endif //WLAN_AUTOGEN_MACADDR_FEATURE |
| 8947 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8948 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8949 | "%s: Invalid MAC address in NV, using MAC from ini file " |
| 8950 | MAC_ADDRESS_STR, __func__, |
| 8951 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 8952 | } |
| 8953 | } |
| 8954 | { |
| 8955 | eHalStatus halStatus; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8956 | |
| 8957 | /* Set the MAC Address Currently this is used by HAL to |
| 8958 | * add self sta. Remove this once self sta is added as |
| 8959 | * part of session open. |
| 8960 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8961 | halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID, |
| 8962 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 8963 | sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) ); |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8964 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8965 | if (!HAL_STATUS_SUCCESS( halStatus )) |
| 8966 | { |
| 8967 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 8968 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8969 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8970 | } |
| 8971 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8972 | |
| 8973 | /*Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 8974 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 8975 | status = vos_start( pHddCtx->pvosContext ); |
| 8976 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8977 | { |
| 8978 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8979 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8980 | } |
| 8981 | |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 8982 | #ifdef FEATURE_WLAN_CH_AVOID |
| 8983 | /* Plug in avoid channel notification callback |
| 8984 | * This should happen before ADD_SELF_STA |
| 8985 | * FW will send first IND with ADD_SELF_STA REQ from host */ |
Pradeep Reddy POTTETI | 5c2e16d | 2014-06-27 16:47:38 +0530 | [diff] [blame] | 8986 | |
| 8987 | /* check the Channel Avoidance is enabled */ |
| 8988 | if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance) |
| 8989 | { |
| 8990 | sme_AddChAvoidCallback(pHddCtx->hHal, |
| 8991 | hdd_hostapd_ch_avoid_cb); |
| 8992 | } |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 8993 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 8994 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8995 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 8996 | hdd_exchange_version_and_caps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8997 | |
Agarwal Ashish | ad9281b | 2014-06-10 14:57:30 +0530 | [diff] [blame] | 8998 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 8999 | status = wlan_hdd_init_channels(pHddCtx); |
| 9000 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9001 | { |
| 9002 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed", |
| 9003 | __func__); |
| 9004 | goto err_vosstop; |
| 9005 | } |
| 9006 | #endif |
| 9007 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9008 | status = hdd_post_voss_start_config( pHddCtx ); |
| 9009 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9010 | { |
| 9011 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 9012 | __func__); |
| 9013 | goto err_vosstop; |
| 9014 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9015 | |
| 9016 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9017 | wlan_hdd_cfg80211_update_reg_info( wiphy ); |
| 9018 | |
| 9019 | /* registration of wiphy dev with cfg80211 */ |
| 9020 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 9021 | { |
| 9022 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 9023 | goto err_vosstop; |
| 9024 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9025 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9026 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9027 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9028 | /* registration of wiphy dev with cfg80211 */ |
| 9029 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 9030 | { |
| 9031 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 9032 | goto err_vosstop; |
| 9033 | } |
| 9034 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 9035 | status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9036 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9037 | { |
| 9038 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed", |
| 9039 | __func__); |
| 9040 | goto err_unregister_wiphy; |
| 9041 | } |
| 9042 | #endif |
| 9043 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9044 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 9045 | { |
| 9046 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d", |
| 9047 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 9048 | } |
| 9049 | else |
| 9050 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9051 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d", |
| 9052 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 9053 | if (pAdapter != NULL) |
| 9054 | { |
Katya Nigam | a7d81d7 | 2014-11-12 12:44:34 +0530 | [diff] [blame] | 9055 | if (pHddCtx->cfg_ini->isP2pDeviceAddrAdministrated && !(pHddCtx->cfg_ini->intfMacAddr[0].bytes[0] & 0x02)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9056 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9057 | vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes, |
| 9058 | pHddCtx->cfg_ini->intfMacAddr[0].bytes, |
| 9059 | sizeof(tSirMacAddr)); |
Madan Mohan Koyyalamudi | edfc1b7 | 2012-10-18 20:25:55 -0700 | [diff] [blame] | 9060 | |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9061 | /* Generate the P2P Device Address. This consists of the device's |
| 9062 | * primary MAC address with the locally administered bit set. |
| 9063 | */ |
| 9064 | pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9065 | } |
| 9066 | else |
| 9067 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9068 | tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx); |
| 9069 | if (p2p_dev_addr != NULL) |
| 9070 | { |
| 9071 | vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0], |
| 9072 | p2p_dev_addr, VOS_MAC_ADDR_SIZE); |
| 9073 | } |
| 9074 | else |
| 9075 | { |
| 9076 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9077 | "%s: Failed to allocate mac_address for p2p_device", |
| 9078 | __func__); |
| 9079 | goto err_close_adapter; |
| 9080 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9081 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9082 | |
| 9083 | pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 9084 | &pHddCtx->p2pDeviceAddress.bytes[0], FALSE ); |
| 9085 | if ( NULL == pP2pAdapter ) |
| 9086 | { |
| 9087 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9088 | "%s: Failed to do hdd_open_adapter for P2P Device Interface", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9089 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9090 | goto err_close_adapter; |
| 9091 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9092 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9093 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9094 | |
| 9095 | if( pAdapter == NULL ) |
| 9096 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9097 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 9098 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9099 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9100 | |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9101 | if (country_code) |
| 9102 | { |
| 9103 | eHalStatus ret; |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9104 | INIT_COMPLETION(pAdapter->change_country_code); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9105 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
| 9106 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 9107 | hdd_checkandupdate_phymode(pAdapter, country_code); |
| 9108 | #endif |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 9109 | ret = sme_ChangeCountryCode(pHddCtx->hHal, |
| 9110 | (void *)(tSmeChangeCountryCallback) |
| 9111 | wlan_hdd_change_country_code_callback, |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9112 | country_code, |
| 9113 | pAdapter, pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 9114 | eSIR_TRUE, eSIR_TRUE); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9115 | if (eHAL_STATUS_SUCCESS == ret) |
| 9116 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9117 | ret = wait_for_completion_interruptible_timeout( |
| 9118 | &pAdapter->change_country_code, |
| 9119 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 9120 | |
| 9121 | if (0 >= ret) |
| 9122 | { |
| 9123 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9124 | "%s: SME while setting country code timed out", __func__); |
| 9125 | } |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9126 | } |
| 9127 | else |
| 9128 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9129 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9130 | "%s: SME Change Country code from module param fail ret=%d", |
| 9131 | __func__, ret); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9132 | } |
| 9133 | } |
| 9134 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9135 | #ifdef WLAN_BTAMP_FEATURE |
| 9136 | vStatus = WLANBAP_Open(pVosContext); |
| 9137 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9138 | { |
| 9139 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9140 | "%s: Failed to open BAP",__func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9141 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9142 | } |
| 9143 | |
| 9144 | vStatus = BSL_Init(pVosContext); |
| 9145 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9146 | { |
| 9147 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9148 | "%s: Failed to Init BSL",__func__); |
| 9149 | goto err_bap_close; |
| 9150 | } |
| 9151 | vStatus = WLANBAP_Start(pVosContext); |
| 9152 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9153 | { |
| 9154 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9155 | "%s: Failed to start TL",__func__); |
| 9156 | goto err_bap_close; |
| 9157 | } |
| 9158 | |
| 9159 | pConfig = pHddCtx->cfg_ini; |
| 9160 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 9161 | status = WLANBAP_SetConfig(&btAmpConfig); |
| 9162 | |
| 9163 | #endif //WLAN_BTAMP_FEATURE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9164 | |
Mihir Shete | 9c23877 | 2014-10-15 14:35:16 +0530 | [diff] [blame] | 9165 | /* |
| 9166 | * UapsdMask is 0xf if U-APSD is enbaled for all AC's... |
| 9167 | * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value) |
| 9168 | * which is greater than 0xf. So the below check is safe to make |
| 9169 | * sure that there is no entry for UapsdMask in the ini |
| 9170 | */ |
| 9171 | if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask) |
| 9172 | { |
| 9173 | if(IS_DYNAMIC_WMM_PS_ENABLED) |
| 9174 | { |
| 9175 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO", |
| 9176 | __func__); |
| 9177 | pHddCtx->cfg_ini->UapsdMask = |
| 9178 | CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT; |
| 9179 | } |
| 9180 | else |
| 9181 | { |
| 9182 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD", |
| 9183 | __func__); |
| 9184 | pHddCtx->cfg_ini->UapsdMask = |
| 9185 | CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT; |
| 9186 | } |
| 9187 | } |
| 9188 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 9189 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 9190 | if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE)) |
| 9191 | { |
| 9192 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__); |
| 9193 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0; |
| 9194 | sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal), |
| 9195 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled); |
| 9196 | } |
| 9197 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9198 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 9199 | wlan_hdd_tdls_init(pHddCtx); |
| 9200 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 9201 | sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done); |
| 9202 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9203 | /* Register with platform driver as client for Suspend/Resume */ |
| 9204 | status = hddRegisterPmOps(pHddCtx); |
| 9205 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9206 | { |
| 9207 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 9208 | #ifdef WLAN_BTAMP_FEATURE |
| 9209 | goto err_bap_stop; |
| 9210 | #else |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9211 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9212 | #endif //WLAN_BTAMP_FEATURE |
| 9213 | } |
| 9214 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9215 | /* Open debugfs interface */ |
| 9216 | if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter)) |
| 9217 | { |
| 9218 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9219 | "%s: hdd_debugfs_init failed!", __func__); |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9220 | } |
| 9221 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9222 | /* Register TM level change handler function to the platform */ |
| 9223 | status = hddDevTmRegisterNotifyCallback(pHddCtx); |
| 9224 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9225 | { |
| 9226 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__); |
| 9227 | goto err_unregister_pmops; |
| 9228 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9229 | |
| 9230 | /* register for riva power on lock to platform driver */ |
| 9231 | if (req_riva_power_on_lock("wlan")) |
| 9232 | { |
| 9233 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 9234 | __func__); |
| 9235 | goto err_unregister_pmops; |
| 9236 | } |
| 9237 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9238 | // register net device notifier for device change notification |
| 9239 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 9240 | |
| 9241 | if(ret < 0) |
| 9242 | { |
| 9243 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__); |
| 9244 | goto err_free_power_on_lock; |
| 9245 | } |
| 9246 | |
| 9247 | //Initialize the nlink service |
| 9248 | if(nl_srv_init() != 0) |
| 9249 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9250 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9251 | goto err_reg_netdev; |
| 9252 | } |
| 9253 | |
Leo Chang | 4ce1cc5 | 2013-10-21 18:27:15 -0700 | [diff] [blame] | 9254 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9255 | pHddCtx->kd_nl_init = 1; |
| 9256 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 9257 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9258 | //Initialize the BTC service |
| 9259 | if(btc_activate_service(pHddCtx) != 0) |
| 9260 | { |
| 9261 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__); |
| 9262 | goto err_nl_srv; |
| 9263 | } |
| 9264 | |
| 9265 | #ifdef PTT_SOCK_SVC_ENABLE |
| 9266 | //Initialize the PTT service |
| 9267 | if(ptt_sock_activate_svc(pHddCtx) != 0) |
| 9268 | { |
| 9269 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__); |
| 9270 | goto err_nl_srv; |
| 9271 | } |
| 9272 | #endif |
| 9273 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 9274 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9275 | if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable) |
| 9276 | { |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 9277 | if(wlan_logging_sock_activate_svc( |
| 9278 | pHddCtx->cfg_ini->wlanLoggingFEToConsole, |
| 9279 | pHddCtx->cfg_ini->wlanLoggingNumBuf)) |
| 9280 | { |
| 9281 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc" |
| 9282 | " failed", __func__); |
| 9283 | goto err_nl_srv; |
| 9284 | } |
| 9285 | //TODO: To Remove enableDhcpDebug and use gEnableDebugLog for |
| 9286 | //EAPOL and DHCP |
| 9287 | pHddCtx->cfg_ini->enableDhcpDebug = CFG_DEBUG_DHCP_ENABLE; |
| 9288 | pHddCtx->cfg_ini->gEnableDebugLog = VOS_PKT_PROTO_TYPE_EAPOL; |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 9289 | } |
| 9290 | #endif |
| 9291 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9292 | hdd_register_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9293 | if (VOS_STA_SAP_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9294 | { |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 9295 | /* Action frame registered in one adapter which will |
| 9296 | * applicable to all interfaces |
| 9297 | */ |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 9298 | wlan_hdd_cfg80211_register_frames(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9299 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9300 | |
| 9301 | mutex_init(&pHddCtx->sap_lock); |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 9302 | mutex_init(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9303 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9304 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9305 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9306 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 9307 | /* Initialize the wake lcok */ |
| 9308 | wake_lock_init(&pHddCtx->rx_wake_lock, |
| 9309 | WAKE_LOCK_SUSPEND, |
| 9310 | "qcom_rx_wakelock"); |
| 9311 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 9312 | /* Initialize the wake lcok */ |
| 9313 | wake_lock_init(&pHddCtx->sap_wake_lock, |
| 9314 | WAKE_LOCK_SUSPEND, |
| 9315 | "qcom_sap_wakelock"); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9316 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9317 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 9318 | vos_event_init(&pHddCtx->scan_info.scan_finished_event); |
| 9319 | pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9320 | |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 9321 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9322 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 9323 | hdd_allow_suspend(); |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 9324 | |
| 9325 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9326 | /*SME must send channel update configuration to RIVA*/ |
| 9327 | sme_UpdateChannelConfig(pHddCtx->hHal); |
| 9328 | #endif |
Abhishek Singh | f644b27 | 2014-08-21 02:59:39 +0530 | [diff] [blame] | 9329 | /* Send the update default channel list to the FW*/ |
| 9330 | sme_UpdateChannelList(pHddCtx->hHal); |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 9331 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 9332 | /*updating wiphy so that regulatory user hints can be processed*/ |
| 9333 | if (wiphy) |
| 9334 | { |
| 9335 | regulatory_hint(wiphy, "00"); |
| 9336 | } |
| 9337 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9338 | // Initialize the restart logic |
| 9339 | wlan_hdd_restart_init(pHddCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 9340 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 9341 | //Register the traffic monitor timer now |
| 9342 | if ( pHddCtx->cfg_ini->dynSplitscan) |
| 9343 | { |
| 9344 | vos_timer_init(&pHddCtx->tx_rx_trafficTmr, |
| 9345 | VOS_TIMER_TYPE_SW, |
| 9346 | hdd_tx_rx_pkt_cnt_stat_timer_handler, |
| 9347 | (void *)pHddCtx); |
| 9348 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 9349 | #ifdef WLAN_FEATURE_EXTSCAN |
| 9350 | sme_EXTScanRegisterCallback(pHddCtx->hHal, |
| 9351 | wlan_hdd_cfg80211_extscan_callback, |
| 9352 | pHddCtx); |
| 9353 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9354 | goto success; |
| 9355 | |
| 9356 | err_nl_srv: |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9357 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9358 | nl_srv_exit(pHddCtx->ptt_pid); |
| 9359 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9360 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9361 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9362 | err_reg_netdev: |
| 9363 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 9364 | |
| 9365 | err_free_power_on_lock: |
| 9366 | free_riva_power_on_lock("wlan"); |
| 9367 | |
| 9368 | err_unregister_pmops: |
| 9369 | hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 9370 | hddDeregisterPmOps(pHddCtx); |
| 9371 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9372 | hdd_debugfs_exit(pHddCtx); |
| 9373 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9374 | #ifdef WLAN_BTAMP_FEATURE |
| 9375 | err_bap_stop: |
| 9376 | WLANBAP_Stop(pVosContext); |
| 9377 | #endif |
| 9378 | |
| 9379 | #ifdef WLAN_BTAMP_FEATURE |
| 9380 | err_bap_close: |
| 9381 | WLANBAP_Close(pVosContext); |
| 9382 | #endif |
| 9383 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9384 | err_close_adapter: |
| 9385 | hdd_close_all_adapters( pHddCtx ); |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 9386 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9387 | err_unregister_wiphy: |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 9388 | #endif |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9389 | wiphy_unregister(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9390 | err_vosstop: |
| 9391 | vos_stop(pVosContext); |
| 9392 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9393 | err_vosclose: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9394 | status = vos_sched_close( pVosContext ); |
| 9395 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 9396 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 9397 | "%s: Failed to close VOSS Scheduler", __func__); |
| 9398 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 9399 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9400 | vos_close(pVosContext ); |
| 9401 | |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9402 | err_vos_nv_close: |
| 9403 | |
c_hpothu | e6a3628 | 2014-03-19 12:27:38 +0530 | [diff] [blame] | 9404 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9405 | vos_nv_close(); |
| 9406 | |
c_hpothu | 70f8d81 | 2014-03-22 22:59:23 +0530 | [diff] [blame] | 9407 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9408 | |
| 9409 | err_wdclose: |
| 9410 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 9411 | vos_watchdog_close(pVosContext); |
| 9412 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9413 | err_config: |
| 9414 | kfree(pHddCtx->cfg_ini); |
| 9415 | pHddCtx->cfg_ini= NULL; |
| 9416 | |
| 9417 | err_free_hdd_context: |
| 9418 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9419 | wiphy_free(wiphy) ; |
| 9420 | //kfree(wdev) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9421 | VOS_BUG(1); |
| 9422 | |
Madan Mohan Koyyalamudi | d57ae63 | 2012-11-06 18:42:48 -0800 | [diff] [blame] | 9423 | if (hdd_is_ssr_required()) |
| 9424 | { |
| 9425 | /* WDI timeout had happened during load, so SSR is needed here */ |
| 9426 | subsystem_restart("wcnss"); |
| 9427 | msleep(5000); |
| 9428 | } |
| 9429 | hdd_set_ssr_required (VOS_FALSE); |
| 9430 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 9431 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9432 | |
| 9433 | success: |
| 9434 | EXIT(); |
| 9435 | return 0; |
| 9436 | } |
| 9437 | |
| 9438 | /**--------------------------------------------------------------------------- |
| 9439 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9440 | \brief hdd_driver_init() - Core Driver Init Function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9441 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9442 | This is the driver entry point - called in different timeline depending |
| 9443 | on whether the driver is statically or dynamically linked |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9444 | |
| 9445 | \param - None |
| 9446 | |
| 9447 | \return - 0 for success, non zero for failure |
| 9448 | |
| 9449 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9450 | static int hdd_driver_init( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9451 | { |
| 9452 | VOS_STATUS status; |
| 9453 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9454 | struct device *dev = NULL; |
| 9455 | int ret_status = 0; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9456 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 9457 | int max_retries = 0; |
| 9458 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9459 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9460 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9461 | wlan_logging_sock_init_svc(); |
| 9462 | #endif |
| 9463 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9464 | ENTER(); |
| 9465 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9466 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9467 | wake_lock_init(&wlan_wake_lock, WAKE_LOCK_SUSPEND, "wlan"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9468 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9469 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9470 | hddTraceInit(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9471 | pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME, |
| 9472 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 9473 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9474 | #ifdef ANI_BUS_TYPE_PCI |
| 9475 | |
| 9476 | dev = wcnss_wlan_get_device(); |
| 9477 | |
| 9478 | #endif // ANI_BUS_TYPE_PCI |
| 9479 | |
| 9480 | #ifdef ANI_BUS_TYPE_PLATFORM |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9481 | |
| 9482 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 9483 | /* wait until WCNSS driver downloads NV */ |
| 9484 | while (!wcnss_device_ready() && 5 >= ++max_retries) { |
| 9485 | msleep(1000); |
| 9486 | } |
| 9487 | if (max_retries >= 5) { |
| 9488 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
madan mohan koyyalamudi | 8c96ce1 | 2013-07-10 19:14:39 +0530 | [diff] [blame] | 9489 | #ifdef WLAN_OPEN_SOURCE |
| 9490 | wake_lock_destroy(&wlan_wake_lock); |
| 9491 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9492 | |
| 9493 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9494 | wlan_logging_sock_deinit_svc(); |
| 9495 | #endif |
| 9496 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9497 | return -ENODEV; |
| 9498 | } |
| 9499 | #endif |
| 9500 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9501 | dev = wcnss_wlan_get_device(); |
| 9502 | #endif // ANI_BUS_TYPE_PLATFORM |
| 9503 | |
| 9504 | |
| 9505 | do { |
| 9506 | if (NULL == dev) { |
| 9507 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__); |
| 9508 | ret_status = -1; |
| 9509 | break; |
| 9510 | } |
| 9511 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9512 | #ifdef TIMER_MANAGER |
| 9513 | vos_timer_manager_init(); |
| 9514 | #endif |
| 9515 | |
| 9516 | /* Preopen VOSS so that it is ready to start at least SAL */ |
| 9517 | status = vos_preOpen(&pVosContext); |
| 9518 | |
| 9519 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9520 | { |
| 9521 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__); |
| 9522 | ret_status = -1; |
| 9523 | break; |
| 9524 | } |
| 9525 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9526 | #ifndef MODULE |
| 9527 | /* For statically linked driver, call hdd_set_conparam to update curr_con_mode |
| 9528 | */ |
| 9529 | hdd_set_conparam((v_UINT_t)con_mode); |
| 9530 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9531 | |
| 9532 | // Call our main init function |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9533 | if (hdd_wlan_startup(dev)) |
| 9534 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9535 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed", |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9536 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9537 | vos_preClose( &pVosContext ); |
| 9538 | ret_status = -1; |
| 9539 | break; |
| 9540 | } |
| 9541 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9542 | } while (0); |
| 9543 | |
| 9544 | if (0 != ret_status) |
| 9545 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9546 | #ifdef TIMER_MANAGER |
| 9547 | vos_timer_exit(); |
| 9548 | #endif |
| 9549 | #ifdef MEMORY_DEBUG |
| 9550 | vos_mem_exit(); |
| 9551 | #endif |
| 9552 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9553 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9554 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9555 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9556 | |
| 9557 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9558 | wlan_logging_sock_deinit_svc(); |
| 9559 | #endif |
| 9560 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9561 | pr_err("%s: driver load failure\n", WLAN_MODULE_NAME); |
| 9562 | } |
| 9563 | else |
| 9564 | { |
| 9565 | //Send WLAN UP indication to Nlink Service |
| 9566 | send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); |
| 9567 | |
| 9568 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9569 | } |
| 9570 | |
| 9571 | EXIT(); |
| 9572 | |
| 9573 | return ret_status; |
| 9574 | } |
| 9575 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9576 | /**--------------------------------------------------------------------------- |
| 9577 | |
| 9578 | \brief hdd_module_init() - Init Function |
| 9579 | |
| 9580 | This is the driver entry point (invoked when module is loaded using insmod) |
| 9581 | |
| 9582 | \param - None |
| 9583 | |
| 9584 | \return - 0 for success, non zero for failure |
| 9585 | |
| 9586 | --------------------------------------------------------------------------*/ |
| 9587 | #ifdef MODULE |
| 9588 | static int __init hdd_module_init ( void) |
| 9589 | { |
| 9590 | return hdd_driver_init(); |
| 9591 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9592 | #else /* #ifdef MODULE */ |
| 9593 | static int __init hdd_module_init ( void) |
| 9594 | { |
| 9595 | /* Driver initialization is delayed to fwpath_changed_handler */ |
| 9596 | return 0; |
| 9597 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9598 | #endif /* #ifdef MODULE */ |
| 9599 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9600 | |
| 9601 | /**--------------------------------------------------------------------------- |
| 9602 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9603 | \brief hdd_driver_exit() - Exit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9604 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9605 | This is the driver exit point (invoked when module is unloaded using rmmod |
| 9606 | or con_mode was changed by userspace) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9607 | |
| 9608 | \param - None |
| 9609 | |
| 9610 | \return - None |
| 9611 | |
| 9612 | --------------------------------------------------------------------------*/ |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9613 | static void hdd_driver_exit(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9614 | { |
| 9615 | hdd_context_t *pHddCtx = NULL; |
| 9616 | v_CONTEXT_t pVosContext = NULL; |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 9617 | v_REGDOMAIN_t regId; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9618 | unsigned long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9619 | |
| 9620 | pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR); |
| 9621 | |
| 9622 | //Get the global vos context |
| 9623 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 9624 | |
| 9625 | if(!pVosContext) |
| 9626 | { |
| 9627 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 9628 | goto done; |
| 9629 | } |
| 9630 | |
| 9631 | //Get the HDD context. |
| 9632 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 9633 | |
| 9634 | if(!pHddCtx) |
| 9635 | { |
| 9636 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__); |
| 9637 | } |
| 9638 | else |
| 9639 | { |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9640 | INIT_COMPLETION(pHddCtx->ssr_comp_var); |
| 9641 | |
| 9642 | if (pHddCtx->isLogpInProgress) |
| 9643 | { |
Sameer Thalappil | 451ebb9 | 2013-06-28 15:49:58 -0700 | [diff] [blame] | 9644 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9645 | "%s:SSR in Progress; block rmmod !!!", __func__); |
| 9646 | rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var, |
| 9647 | msecs_to_jiffies(30000)); |
| 9648 | if(!rc) |
| 9649 | { |
| 9650 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9651 | "%s:SSR timedout, fatal error", __func__); |
| 9652 | VOS_BUG(0); |
Sameer Thalappil | 451ebb9 | 2013-06-28 15:49:58 -0700 | [diff] [blame] | 9653 | } |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9654 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9655 | |
Vinay Krishna Eranna | e362b45 | 2014-09-23 13:09:46 +0530 | [diff] [blame] | 9656 | rtnl_lock(); |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 9657 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9658 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
Vinay Krishna Eranna | e362b45 | 2014-09-23 13:09:46 +0530 | [diff] [blame] | 9659 | rtnl_unlock(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9660 | |
Agarwal Ashish | 8db3988 | 2014-07-30 21:56:07 +0530 | [diff] [blame] | 9661 | /* Driver Need to send country code 00 in below condition |
| 9662 | * 1) If gCountryCodePriority is set to 1; and last country |
| 9663 | * code set is through 11d. This needs to be done in case |
| 9664 | * when NV country code is 00. |
| 9665 | * This Needs to be done as when kernel store last country |
| 9666 | * code and if stored country code is not through 11d, |
| 9667 | * in sme_HandleChangeCountryCodeByUser we will disable 11d |
| 9668 | * in next load/unload as soon as we get any country through |
| 9669 | * 11d. In sme_HandleChangeCountryCodeByUser |
| 9670 | * pMsg->countryCode will be last countryCode and |
| 9671 | * pMac->scan.countryCode11d will be country through 11d so |
| 9672 | * due to mismatch driver will disable 11d. |
| 9673 | * |
Agarwal Ashish | 8db3988 | 2014-07-30 21:56:07 +0530 | [diff] [blame] | 9674 | */ |
| 9675 | |
| 9676 | if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) && |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 9677 | pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority && |
Abhishek Singh | 2a70596 | 2014-10-30 14:47:28 +0530 | [diff] [blame] | 9678 | sme_Is11dSupported(pHddCtx->hHal))) |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 9679 | { |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 9680 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9681 | FL("CountryCode 00 is being set while unloading driver")); |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 9682 | vos_nv_getRegDomainFromCountryCode(®Id , "00", COUNTRY_USER); |
| 9683 | } |
| 9684 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9685 | //Do all the cleanup before deregistering the driver |
| 9686 | hdd_wlan_exit(pHddCtx); |
| 9687 | } |
| 9688 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9689 | vos_preClose( &pVosContext ); |
| 9690 | |
| 9691 | #ifdef TIMER_MANAGER |
| 9692 | vos_timer_exit(); |
| 9693 | #endif |
| 9694 | #ifdef MEMORY_DEBUG |
| 9695 | vos_mem_exit(); |
| 9696 | #endif |
| 9697 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9698 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9699 | wlan_logging_sock_deinit_svc(); |
| 9700 | #endif |
| 9701 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9702 | done: |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9703 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9704 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9705 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9706 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9707 | pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME); |
| 9708 | } |
| 9709 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9710 | /**--------------------------------------------------------------------------- |
| 9711 | |
| 9712 | \brief hdd_module_exit() - Exit function |
| 9713 | |
| 9714 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9715 | |
| 9716 | \param - None |
| 9717 | |
| 9718 | \return - None |
| 9719 | |
| 9720 | --------------------------------------------------------------------------*/ |
| 9721 | static void __exit hdd_module_exit(void) |
| 9722 | { |
| 9723 | hdd_driver_exit(); |
| 9724 | } |
| 9725 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9726 | #ifdef MODULE |
| 9727 | static int fwpath_changed_handler(const char *kmessage, |
| 9728 | struct kernel_param *kp) |
| 9729 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9730 | return param_set_copystring(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9731 | } |
| 9732 | |
| 9733 | static int con_mode_handler(const char *kmessage, |
| 9734 | struct kernel_param *kp) |
| 9735 | { |
Madan Mohan Koyyalamudi | f2f8d8b | 2012-10-11 17:06:59 -0700 | [diff] [blame] | 9736 | return param_set_int(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9737 | } |
| 9738 | #else /* #ifdef MODULE */ |
| 9739 | /**--------------------------------------------------------------------------- |
| 9740 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9741 | \brief kickstart_driver |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9742 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9743 | This is the driver entry point |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9744 | - delayed driver initialization when driver is statically linked |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9745 | - invoked when module parameter fwpath is modified from userspace to signal |
| 9746 | initializing the WLAN driver or when con_mode is modified from userspace |
| 9747 | to signal a switch in operating mode |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9748 | |
| 9749 | \return - 0 for success, non zero for failure |
| 9750 | |
| 9751 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9752 | static int kickstart_driver(void) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9753 | { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9754 | int ret_status; |
| 9755 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9756 | if (!wlan_hdd_inited) { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9757 | ret_status = hdd_driver_init(); |
| 9758 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 9759 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9760 | } |
| 9761 | |
| 9762 | hdd_driver_exit(); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9763 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9764 | msleep(200); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9765 | |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9766 | ret_status = hdd_driver_init(); |
| 9767 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 9768 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9769 | } |
| 9770 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9771 | /**--------------------------------------------------------------------------- |
| 9772 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9773 | \brief fwpath_changed_handler() - Handler Function |
| 9774 | |
| 9775 | Handle changes to the fwpath parameter |
| 9776 | |
| 9777 | \return - 0 for success, non zero for failure |
| 9778 | |
| 9779 | --------------------------------------------------------------------------*/ |
| 9780 | static int fwpath_changed_handler(const char *kmessage, |
| 9781 | struct kernel_param *kp) |
| 9782 | { |
| 9783 | int ret; |
| 9784 | |
| 9785 | ret = param_set_copystring(kmessage, kp); |
| 9786 | if (0 == ret) |
| 9787 | ret = kickstart_driver(); |
| 9788 | return ret; |
| 9789 | } |
| 9790 | |
| 9791 | /**--------------------------------------------------------------------------- |
| 9792 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9793 | \brief con_mode_handler() - |
| 9794 | |
| 9795 | Handler function for module param con_mode when it is changed by userspace |
| 9796 | Dynamically linked - do nothing |
| 9797 | Statically linked - exit and init driver, as in rmmod and insmod |
| 9798 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9799 | \param - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9800 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9801 | \return - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9802 | |
| 9803 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9804 | 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] | 9805 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9806 | int ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9807 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9808 | ret = param_set_int(kmessage, kp); |
| 9809 | if (0 == ret) |
| 9810 | ret = kickstart_driver(); |
| 9811 | return ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9812 | } |
| 9813 | #endif /* #ifdef MODULE */ |
| 9814 | |
| 9815 | /**--------------------------------------------------------------------------- |
| 9816 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9817 | \brief hdd_get_conparam() - |
| 9818 | |
| 9819 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9820 | |
| 9821 | \param - None |
| 9822 | |
| 9823 | \return - tVOS_CON_MODE |
| 9824 | |
| 9825 | --------------------------------------------------------------------------*/ |
| 9826 | tVOS_CON_MODE hdd_get_conparam ( void ) |
| 9827 | { |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9828 | #ifdef MODULE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9829 | return (tVOS_CON_MODE)con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9830 | #else |
| 9831 | return (tVOS_CON_MODE)curr_con_mode; |
| 9832 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9833 | } |
| 9834 | void hdd_set_conparam ( v_UINT_t newParam ) |
| 9835 | { |
| 9836 | con_mode = newParam; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9837 | #ifndef MODULE |
| 9838 | curr_con_mode = con_mode; |
| 9839 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9840 | } |
| 9841 | /**--------------------------------------------------------------------------- |
| 9842 | |
| 9843 | \brief hdd_softap_sta_deauth() - function |
| 9844 | |
| 9845 | This to take counter measure to handle deauth req from HDD |
| 9846 | |
| 9847 | \param - pAdapter - Pointer to the HDD |
| 9848 | |
| 9849 | \param - enable - boolean value |
| 9850 | |
| 9851 | \return - None |
| 9852 | |
| 9853 | --------------------------------------------------------------------------*/ |
| 9854 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 9855 | VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, |
| 9856 | struct tagCsrDelStaParams *pDelStaParams) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9857 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9858 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9859 | VOS_STATUS vosStatus = VOS_STATUS_E_FAULT; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9860 | |
| 9861 | ENTER(); |
| 9862 | |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 9863 | hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)", |
| 9864 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9865 | |
| 9866 | //Ignore request to deauth bcmc station |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 9867 | if (pDelStaParams->peerMacAddr[0] & 0x1) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9868 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9869 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 9870 | vosStatus = WLANSAP_DeauthSta(pVosContext, pDelStaParams); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9871 | |
| 9872 | EXIT(); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9873 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9874 | } |
| 9875 | |
| 9876 | /**--------------------------------------------------------------------------- |
| 9877 | |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 9878 | \brief hdd_del_all_sta() - function |
| 9879 | |
| 9880 | This function removes all the stations associated on stopping AP/P2P GO. |
| 9881 | |
| 9882 | \param - pAdapter - Pointer to the HDD |
| 9883 | |
| 9884 | \return - None |
| 9885 | |
| 9886 | --------------------------------------------------------------------------*/ |
| 9887 | |
| 9888 | int hdd_del_all_sta(hdd_adapter_t *pAdapter) |
| 9889 | { |
| 9890 | v_U16_t i; |
| 9891 | VOS_STATUS vos_status; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 9892 | v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 9893 | ptSapContext pSapCtx = NULL; |
| 9894 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 9895 | if(pSapCtx == NULL){ |
| 9896 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9897 | FL("psapCtx is NULL")); |
| 9898 | return 1; |
| 9899 | } |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 9900 | ENTER(); |
| 9901 | |
| 9902 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9903 | "%s: Delete all STAs associated.",__func__); |
| 9904 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 9905 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 9906 | ) |
| 9907 | { |
| 9908 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 9909 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 9910 | if ((pSapCtx->aStaInfo[i].isUsed) && |
| 9911 | (!pSapCtx->aStaInfo[i].isDeauthInProgress)) |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 9912 | { |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 9913 | struct tagCsrDelStaParams delStaParams; |
| 9914 | |
| 9915 | WLANSAP_PopulateDelStaParams( |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 9916 | pSapCtx->aStaInfo[i].macAddrSTA.bytes, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 9917 | eCsrForcedDeauthSta, SIR_MAC_MGMT_DEAUTH >> 4, |
| 9918 | &delStaParams); |
| 9919 | vos_status = hdd_softap_sta_deauth(pAdapter, &delStaParams); |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 9920 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 9921 | pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE; |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 9922 | } |
| 9923 | } |
| 9924 | } |
| 9925 | |
| 9926 | EXIT(); |
| 9927 | return 0; |
| 9928 | } |
| 9929 | |
| 9930 | /**--------------------------------------------------------------------------- |
| 9931 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9932 | \brief hdd_softap_sta_disassoc() - function |
| 9933 | |
| 9934 | This to take counter measure to handle deauth req from HDD |
| 9935 | |
| 9936 | \param - pAdapter - Pointer to the HDD |
| 9937 | |
| 9938 | \param - enable - boolean value |
| 9939 | |
| 9940 | \return - None |
| 9941 | |
| 9942 | --------------------------------------------------------------------------*/ |
| 9943 | |
| 9944 | void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress) |
| 9945 | { |
| 9946 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 9947 | |
| 9948 | ENTER(); |
| 9949 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9950 | 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] | 9951 | |
| 9952 | //Ignore request to disassoc bcmc station |
| 9953 | if( pDestMacAddress[0] & 0x1 ) |
| 9954 | return; |
| 9955 | |
| 9956 | WLANSAP_DisassocSta(pVosContext,pDestMacAddress); |
| 9957 | } |
| 9958 | |
| 9959 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable) |
| 9960 | { |
| 9961 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 9962 | |
| 9963 | ENTER(); |
| 9964 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9965 | 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] | 9966 | |
| 9967 | WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable); |
| 9968 | } |
| 9969 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9970 | /**--------------------------------------------------------------------------- |
| 9971 | * |
| 9972 | * \brief hdd_get__concurrency_mode() - |
| 9973 | * |
| 9974 | * |
| 9975 | * \param - None |
| 9976 | * |
| 9977 | * \return - CONCURRENCY MODE |
| 9978 | * |
| 9979 | * --------------------------------------------------------------------------*/ |
| 9980 | tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void ) |
| 9981 | { |
| 9982 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 9983 | hdd_context_t *pHddCtx; |
| 9984 | |
| 9985 | if (NULL != pVosContext) |
| 9986 | { |
| 9987 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 9988 | if (NULL != pHddCtx) |
| 9989 | { |
| 9990 | return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode; |
| 9991 | } |
| 9992 | } |
| 9993 | |
| 9994 | /* we are in an invalid state :( */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9995 | hddLog(LOGE, "%s: Invalid context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9996 | return VOS_STA; |
| 9997 | } |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 9998 | v_BOOL_t |
| 9999 | wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx) |
| 10000 | { |
| 10001 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10002 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10003 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO); |
| 10004 | if (pAdapter == NULL) |
| 10005 | { |
| 10006 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10007 | FL("GO doesn't exist")); |
| 10008 | return TRUE; |
| 10009 | } |
| 10010 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 10011 | { |
| 10012 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10013 | FL("GO started")); |
| 10014 | return TRUE; |
| 10015 | } |
| 10016 | else |
| 10017 | /* wait till GO changes its interface to p2p device */ |
| 10018 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10019 | FL("Del_bss called, avoid apps suspend")); |
| 10020 | return FALSE; |
| 10021 | |
| 10022 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10023 | /* Decide whether to allow/not the apps power collapse. |
| 10024 | * Allow apps power collapse if we are in connected state. |
| 10025 | * if not, allow only if we are in IMPS */ |
| 10026 | v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx) |
| 10027 | { |
| 10028 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10029 | tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal); |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10030 | tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10031 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 10032 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10033 | hdd_adapter_t *pAdapter = NULL; |
| 10034 | VOS_STATUS status; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10035 | tVOS_CONCURRENCY_MODE concurrent_state = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10036 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10037 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 10038 | return TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10039 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10040 | concurrent_state = hdd_get_concurrency_mode(); |
| 10041 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10042 | if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) && |
| 10043 | !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx))) |
| 10044 | return FALSE; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10045 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10046 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10047 | if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) || |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10048 | (concurrent_state == (VOS_STA | VOS_P2P_GO)))&& |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10049 | (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)) |
| 10050 | return TRUE; |
| 10051 | #endif |
| 10052 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10053 | /*loop through all adapters. TBD fix for Concurrency */ |
| 10054 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10055 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10056 | { |
| 10057 | pAdapter = pAdapterNode->pAdapter; |
| 10058 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 10059 | || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 10060 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10061 | if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled) |
c_hpothu | 4e8faac | 2014-05-16 17:38:44 +0530 | [diff] [blame] | 10062 | && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10063 | && pmcState != STOPPED && pmcState != STANDBY)) || |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10064 | (eANI_BOOLEAN_TRUE == scanRspPending) || |
| 10065 | (eANI_BOOLEAN_TRUE == inMiddleOfRoaming)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10066 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10067 | hddLog( LOGE, "%s: do not allow APPS power collapse-" |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10068 | "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d", |
| 10069 | __func__, pmcState, scanRspPending, inMiddleOfRoaming ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10070 | return FALSE; |
| 10071 | } |
| 10072 | } |
| 10073 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10074 | pAdapterNode = pNext; |
| 10075 | } |
| 10076 | return TRUE; |
| 10077 | } |
| 10078 | |
Madan Mohan Koyyalamudi | c72a4d6 | 2012-11-08 14:59:34 -0800 | [diff] [blame] | 10079 | /* Decides whether to send suspend notification to Riva |
| 10080 | * if any adapter is in BMPS; then it is required */ |
| 10081 | v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx) |
| 10082 | { |
| 10083 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
| 10084 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 10085 | |
| 10086 | if (pConfig->fIsBmpsEnabled && (pmcState == BMPS)) |
| 10087 | { |
| 10088 | return TRUE; |
| 10089 | } |
| 10090 | return FALSE; |
| 10091 | } |
| 10092 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10093 | void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10094 | { |
| 10095 | switch(mode) |
| 10096 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 10097 | case VOS_STA_MODE: |
| 10098 | case VOS_P2P_CLIENT_MODE: |
| 10099 | case VOS_P2P_GO_MODE: |
| 10100 | case VOS_STA_SAP_MODE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10101 | pHddCtx->concurrency_mode |= (1 << mode); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10102 | pHddCtx->no_of_open_sessions[mode]++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10103 | break; |
| 10104 | default: |
| 10105 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10106 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10107 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 10108 | "Number of open sessions for mode %d = %d"), |
| 10109 | pHddCtx->concurrency_mode, mode, |
| 10110 | pHddCtx->no_of_open_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10111 | } |
| 10112 | |
| 10113 | |
| 10114 | void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10115 | { |
| 10116 | switch(mode) |
| 10117 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 10118 | case VOS_STA_MODE: |
| 10119 | case VOS_P2P_CLIENT_MODE: |
| 10120 | case VOS_P2P_GO_MODE: |
| 10121 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10122 | pHddCtx->no_of_open_sessions[mode]--; |
| 10123 | if (!(pHddCtx->no_of_open_sessions[mode])) |
| 10124 | pHddCtx->concurrency_mode &= (~(1 << mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10125 | break; |
| 10126 | default: |
| 10127 | break; |
| 10128 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10129 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 10130 | "Number of open sessions for mode %d = %d"), |
| 10131 | pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]); |
| 10132 | |
| 10133 | } |
| 10134 | /**--------------------------------------------------------------------------- |
| 10135 | * |
| 10136 | * \brief wlan_hdd_incr_active_session() |
| 10137 | * |
| 10138 | * This function increments the number of active sessions |
| 10139 | * maintained per device mode |
| 10140 | * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented |
| 10141 | * Incase of SAP/P2P GO upon bss start it is incremented |
| 10142 | * |
| 10143 | * \param pHddCtx - HDD Context |
| 10144 | * \param mode - device mode |
| 10145 | * |
| 10146 | * \return - None |
| 10147 | * |
| 10148 | * --------------------------------------------------------------------------*/ |
| 10149 | void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10150 | { |
| 10151 | switch (mode) { |
| 10152 | case VOS_STA_MODE: |
| 10153 | case VOS_P2P_CLIENT_MODE: |
| 10154 | case VOS_P2P_GO_MODE: |
| 10155 | case VOS_STA_SAP_MODE: |
| 10156 | pHddCtx->no_of_active_sessions[mode]++; |
| 10157 | break; |
| 10158 | default: |
| 10159 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 10160 | break; |
| 10161 | } |
| 10162 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 10163 | mode, |
| 10164 | pHddCtx->no_of_active_sessions[mode]); |
| 10165 | } |
| 10166 | |
| 10167 | /**--------------------------------------------------------------------------- |
| 10168 | * |
| 10169 | * \brief wlan_hdd_decr_active_session() |
| 10170 | * |
| 10171 | * This function decrements the number of active sessions |
| 10172 | * maintained per device mode |
| 10173 | * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented |
| 10174 | * Incase of SAP/P2P GO upon bss stop it is decremented |
| 10175 | * |
| 10176 | * \param pHddCtx - HDD Context |
| 10177 | * \param mode - device mode |
| 10178 | * |
| 10179 | * \return - None |
| 10180 | * |
| 10181 | * --------------------------------------------------------------------------*/ |
| 10182 | void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10183 | { |
| 10184 | switch (mode) { |
| 10185 | case VOS_STA_MODE: |
| 10186 | case VOS_P2P_CLIENT_MODE: |
| 10187 | case VOS_P2P_GO_MODE: |
| 10188 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 5325f52 | 2014-08-06 00:58:44 +0530 | [diff] [blame] | 10189 | if (pHddCtx->no_of_active_sessions[mode] > 0) |
| 10190 | pHddCtx->no_of_active_sessions[mode]--; |
| 10191 | else |
| 10192 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions" |
| 10193 | "is already Zero")); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10194 | break; |
| 10195 | default: |
| 10196 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 10197 | break; |
| 10198 | } |
| 10199 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 10200 | mode, |
| 10201 | pHddCtx->no_of_active_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10202 | } |
| 10203 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10204 | /**--------------------------------------------------------------------------- |
| 10205 | * |
| 10206 | * \brief wlan_hdd_restart_init |
| 10207 | * |
| 10208 | * This function initalizes restart timer/flag. An internal function. |
| 10209 | * |
| 10210 | * \param - pHddCtx |
| 10211 | * |
| 10212 | * \return - None |
| 10213 | * |
| 10214 | * --------------------------------------------------------------------------*/ |
| 10215 | |
| 10216 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx) |
| 10217 | { |
| 10218 | /* Initialize */ |
| 10219 | pHddCtx->hdd_restart_retries = 0; |
| 10220 | atomic_set(&pHddCtx->isRestartInProgress, 0); |
| 10221 | vos_timer_init(&pHddCtx->hdd_restart_timer, |
| 10222 | VOS_TIMER_TYPE_SW, |
| 10223 | wlan_hdd_restart_timer_cb, |
| 10224 | pHddCtx); |
| 10225 | } |
| 10226 | /**--------------------------------------------------------------------------- |
| 10227 | * |
| 10228 | * \brief wlan_hdd_restart_deinit |
| 10229 | * |
| 10230 | * This function cleans up the resources used. An internal function. |
| 10231 | * |
| 10232 | * \param - pHddCtx |
| 10233 | * |
| 10234 | * \return - None |
| 10235 | * |
| 10236 | * --------------------------------------------------------------------------*/ |
| 10237 | |
| 10238 | static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx) |
| 10239 | { |
| 10240 | |
| 10241 | VOS_STATUS vos_status; |
| 10242 | /* Block any further calls */ |
| 10243 | atomic_set(&pHddCtx->isRestartInProgress, 1); |
| 10244 | /* Cleanup */ |
| 10245 | vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer ); |
| 10246 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10247 | hddLog(LOGE, FL("Failed to stop HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10248 | vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer); |
| 10249 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10250 | hddLog(LOGE, FL("Failed to destroy HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10251 | |
| 10252 | } |
| 10253 | |
| 10254 | /**--------------------------------------------------------------------------- |
| 10255 | * |
| 10256 | * \brief wlan_hdd_framework_restart |
| 10257 | * |
| 10258 | * This function uses a cfg80211 API to start a framework initiated WLAN |
| 10259 | * driver module unload/load. |
| 10260 | * |
| 10261 | * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT). |
| 10262 | * |
| 10263 | * |
| 10264 | * \param - pHddCtx |
| 10265 | * |
| 10266 | * \return - VOS_STATUS_SUCCESS: Success |
| 10267 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 10268 | * VOS_STATUS_E_NOMEM: No memory |
| 10269 | |
| 10270 | * --------------------------------------------------------------------------*/ |
| 10271 | |
| 10272 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx) |
| 10273 | { |
| 10274 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 10275 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10276 | int len = (sizeof (struct ieee80211_mgmt)); |
| 10277 | struct ieee80211_mgmt *mgmt = NULL; |
| 10278 | |
| 10279 | /* Prepare the DEAUTH managment frame with reason code */ |
| 10280 | mgmt = kzalloc(len, GFP_KERNEL); |
| 10281 | if(mgmt == NULL) |
| 10282 | { |
| 10283 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10284 | "%s: memory allocation failed (%d bytes)", __func__, len); |
| 10285 | return VOS_STATUS_E_NOMEM; |
| 10286 | } |
| 10287 | mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10288 | |
| 10289 | /* Iterate over all adapters/devices */ |
| 10290 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10291 | do |
| 10292 | { |
| 10293 | if( (status == VOS_STATUS_SUCCESS) && |
| 10294 | pAdapterNode && |
| 10295 | pAdapterNode->pAdapter) |
| 10296 | { |
| 10297 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10298 | "restarting the driver(intf:\'%s\' mode:%d :try %d)", |
| 10299 | pAdapterNode->pAdapter->dev->name, |
| 10300 | pAdapterNode->pAdapter->device_mode, |
| 10301 | pHddCtx->hdd_restart_retries + 1); |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10302 | /* |
| 10303 | * CFG80211 event to restart the driver |
| 10304 | * |
| 10305 | * 'cfg80211_send_unprot_deauth' sends a |
| 10306 | * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state |
| 10307 | * of SME(Linux Kernel) state machine. |
| 10308 | * |
| 10309 | * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart |
| 10310 | * the driver. |
| 10311 | * |
| 10312 | */ |
| 10313 | |
| 10314 | cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10315 | } |
| 10316 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10317 | pAdapterNode = pNext; |
| 10318 | } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)); |
| 10319 | |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10320 | |
| 10321 | /* Free the allocated management frame */ |
| 10322 | kfree(mgmt); |
| 10323 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10324 | /* Retry until we unload or reach max count */ |
| 10325 | if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT) |
| 10326 | vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS); |
| 10327 | |
| 10328 | return status; |
| 10329 | |
| 10330 | } |
| 10331 | /**--------------------------------------------------------------------------- |
| 10332 | * |
| 10333 | * \brief wlan_hdd_restart_timer_cb |
| 10334 | * |
| 10335 | * Restart timer callback. An internal function. |
| 10336 | * |
| 10337 | * \param - User data: |
| 10338 | * |
| 10339 | * \return - None |
| 10340 | * |
| 10341 | * --------------------------------------------------------------------------*/ |
| 10342 | |
| 10343 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback) |
| 10344 | { |
| 10345 | hdd_context_t *pHddCtx = usrDataForCallback; |
| 10346 | wlan_hdd_framework_restart(pHddCtx); |
| 10347 | return; |
| 10348 | |
| 10349 | } |
| 10350 | |
| 10351 | |
| 10352 | /**--------------------------------------------------------------------------- |
| 10353 | * |
| 10354 | * \brief wlan_hdd_restart_driver |
| 10355 | * |
| 10356 | * This function sends an event to supplicant to restart the WLAN driver. |
| 10357 | * |
| 10358 | * This function is called from vos_wlanRestart. |
| 10359 | * |
| 10360 | * \param - pHddCtx |
| 10361 | * |
| 10362 | * \return - VOS_STATUS_SUCCESS: Success |
| 10363 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 10364 | * VOS_STATUS_E_ALREADY: Request already in progress |
| 10365 | |
| 10366 | * --------------------------------------------------------------------------*/ |
| 10367 | VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx) |
| 10368 | { |
| 10369 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 10370 | |
| 10371 | /* A tight check to make sure reentrancy */ |
| 10372 | if(atomic_xchg(&pHddCtx->isRestartInProgress, 1)) |
| 10373 | { |
Mihir Shete | fd52865 | 2014-06-23 19:07:50 +0530 | [diff] [blame] | 10374 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10375 | "%s: WLAN restart is already in progress", __func__); |
| 10376 | |
| 10377 | return VOS_STATUS_E_ALREADY; |
| 10378 | } |
Sameer Thalappil | 0c164f5 | 2013-03-28 15:27:56 -0700 | [diff] [blame] | 10379 | /* Send reset FIQ to WCNSS to invoke SSR. */ |
Madan Mohan Koyyalamudi | e388b34 | 2012-11-08 15:03:16 -0800 | [diff] [blame] | 10380 | #ifdef HAVE_WCNSS_RESET_INTR |
Madan Mohan Koyyalamudi | bb8f017 | 2012-09-28 15:36:06 -0700 | [diff] [blame] | 10381 | wcnss_reset_intr(); |
| 10382 | #endif |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 10383 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10384 | return status; |
| 10385 | } |
| 10386 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 10387 | /**--------------------------------------------------------------------------- |
| 10388 | * |
| 10389 | * \brief wlan_hdd_init_channels |
| 10390 | * |
| 10391 | * This function is used to initialize the channel list in CSR |
| 10392 | * |
| 10393 | * This function is called from hdd_wlan_startup |
| 10394 | * |
| 10395 | * \param - pHddCtx: HDD context |
| 10396 | * |
| 10397 | * \return - VOS_STATUS_SUCCESS: Success |
| 10398 | * VOS_STATUS_E_FAULT: Failure reported by SME |
| 10399 | |
| 10400 | * --------------------------------------------------------------------------*/ |
| 10401 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx) |
| 10402 | { |
| 10403 | eHalStatus status; |
| 10404 | |
| 10405 | status = sme_InitChannels(pHddCtx->hHal); |
| 10406 | if (HAL_STATUS_SUCCESS(status)) |
| 10407 | { |
| 10408 | return VOS_STATUS_SUCCESS; |
| 10409 | } |
| 10410 | else |
| 10411 | { |
| 10412 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)", |
| 10413 | __func__, status); |
| 10414 | return VOS_STATUS_E_FAULT; |
| 10415 | } |
| 10416 | } |
| 10417 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 10418 | VOS_STATUS wlan_hdd_init_channels_for_cc(hdd_context_t *pHddCtx, driver_load_type init ) |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 10419 | { |
| 10420 | eHalStatus status; |
| 10421 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 10422 | status = sme_InitChannelsForCC(pHddCtx->hHal, init); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 10423 | if (HAL_STATUS_SUCCESS(status)) |
| 10424 | { |
| 10425 | return VOS_STATUS_SUCCESS; |
| 10426 | } |
| 10427 | else |
| 10428 | { |
| 10429 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)", |
| 10430 | __func__, status); |
| 10431 | return VOS_STATUS_E_FAULT; |
| 10432 | } |
| 10433 | } |
Sudhir Sattayappa Kohalli | b1d8c3a | 2013-06-18 14:47:20 -0700 | [diff] [blame] | 10434 | /* |
| 10435 | * API to find if there is any STA or P2P-Client is connected |
| 10436 | */ |
| 10437 | VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx) |
| 10438 | { |
| 10439 | return sme_isSta_p2p_clientConnected(pHddCtx->hHal); |
| 10440 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10441 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10442 | int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter) |
| 10443 | { |
| 10444 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10445 | hdd_scaninfo_t *pScanInfo = NULL; |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10446 | long status = 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10447 | |
| 10448 | pScanInfo = &pHddCtx->scan_info; |
| 10449 | if (pScanInfo->mScanPending) |
| 10450 | { |
| 10451 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 10452 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10453 | eCSR_SCAN_ABORT_DEFAULT); |
| 10454 | |
| 10455 | status = wait_for_completion_interruptible_timeout( |
| 10456 | &pScanInfo->abortscan_event_var, |
| 10457 | msecs_to_jiffies(5000)); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10458 | if (0 >= status) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10459 | { |
| 10460 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10461 | "%s: Timeout or Interrupt occurred while waiting for abort" |
| 10462 | "scan, status- %ld", __func__, status); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10463 | return -ETIMEDOUT; |
| 10464 | } |
| 10465 | } |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10466 | return 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10467 | } |
| 10468 | |
c_hpothu | 225aa7c | 2014-10-22 17:45:13 +0530 | [diff] [blame] | 10469 | VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx) |
| 10470 | { |
| 10471 | hdd_adapter_t *pAdapter; |
| 10472 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10473 | VOS_STATUS vosStatus; |
| 10474 | |
| 10475 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10476 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 10477 | { |
| 10478 | pAdapter = pAdapterNode->pAdapter; |
| 10479 | if (NULL != pAdapter) |
| 10480 | { |
| 10481 | if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode || |
| 10482 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode || |
| 10483 | WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 10484 | { |
| 10485 | hddLog(LOG1, FL("abort ROC deviceMode: %d"), |
| 10486 | pAdapter->device_mode); |
| 10487 | if (VOS_STATUS_SUCCESS != |
| 10488 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter)) |
| 10489 | { |
| 10490 | hddLog(LOGE, FL("failed to abort ROC")); |
| 10491 | return VOS_STATUS_E_FAILURE; |
| 10492 | } |
| 10493 | } |
| 10494 | } |
| 10495 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10496 | pAdapterNode = pNext; |
| 10497 | } |
| 10498 | return VOS_STATUS_SUCCESS; |
| 10499 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10500 | //Register the module init/exit functions |
| 10501 | module_init(hdd_module_init); |
| 10502 | module_exit(hdd_module_exit); |
| 10503 | |
| 10504 | MODULE_LICENSE("Dual BSD/GPL"); |
| 10505 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 10506 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 10507 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10508 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 10509 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10510 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10511 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10512 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 10513 | |
| 10514 | module_param(enable_dfs_chan_scan, int, |
| 10515 | S_IRUSR | S_IRGRP | S_IROTH); |
| 10516 | |
| 10517 | module_param(enable_11d, int, |
| 10518 | S_IRUSR | S_IRGRP | S_IROTH); |
| 10519 | |
| 10520 | module_param(country_code, charp, |
| 10521 | S_IRUSR | S_IRGRP | S_IROTH); |