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, |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 478 | "%s: LOGP %s. Ignore!!", __func__, |
| 479 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL) |
| 480 | ?"failed":"in Progress"); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 481 | return -EAGAIN; |
| 482 | } |
| 483 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 484 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 485 | { |
| 486 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 487 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 488 | return -EAGAIN; |
| 489 | } |
| 490 | return 0; |
| 491 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 492 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 493 | void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx) |
| 494 | { |
| 495 | hdd_adapter_t *pAdapter = NULL; |
| 496 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 497 | eCsrPhyMode phyMode; |
| 498 | hdd_config_t *cfg_param = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 499 | |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 500 | if (NULL == pHddCtx) |
| 501 | { |
| 502 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 503 | "HDD Context is null !!"); |
| 504 | return ; |
| 505 | } |
| 506 | |
| 507 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 508 | if (NULL == pAdapter) |
| 509 | { |
| 510 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 511 | "pAdapter is null !!"); |
| 512 | return ; |
| 513 | } |
| 514 | |
| 515 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 516 | if (NULL == pHddStaCtx) |
| 517 | { |
| 518 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 519 | "pHddStaCtx is null !!"); |
| 520 | return ; |
| 521 | } |
| 522 | |
| 523 | cfg_param = pHddCtx->cfg_ini; |
| 524 | if (NULL == cfg_param) |
| 525 | { |
| 526 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 527 | "cfg_params not available !!"); |
| 528 | return ; |
| 529 | } |
| 530 | |
| 531 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 532 | |
| 533 | if (!pHddCtx->isVHT80Allowed) |
| 534 | { |
| 535 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 536 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 537 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 538 | { |
| 539 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 540 | "Setting phymode to 11n!!"); |
| 541 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 542 | } |
| 543 | } |
| 544 | else |
| 545 | { |
| 546 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 547 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 548 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 549 | return ; |
| 550 | } |
| 551 | |
| 552 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 553 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 554 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 555 | { |
| 556 | VOS_STATUS vosStatus; |
| 557 | |
| 558 | // need to issue a disconnect to CSR. |
| 559 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 560 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 561 | pAdapter->sessionId, |
| 562 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 563 | |
| 564 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 565 | { |
| 566 | long ret; |
| 567 | |
| 568 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 569 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 570 | if (0 >= ret) |
| 571 | hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"), |
| 572 | ret); |
| 573 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 574 | |
| 575 | } |
| 576 | } |
| 577 | #else |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 578 | void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code) |
| 579 | { |
| 580 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 581 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 582 | hdd_config_t *cfg_param; |
| 583 | eCsrPhyMode phyMode; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 584 | long ret; |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 585 | |
| 586 | if (NULL == pHddCtx) |
| 587 | { |
| 588 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 589 | "HDD Context is null !!"); |
| 590 | return ; |
| 591 | } |
| 592 | |
| 593 | cfg_param = pHddCtx->cfg_ini; |
| 594 | |
| 595 | if (NULL == cfg_param) |
| 596 | { |
| 597 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 598 | "cfg_params not available !!"); |
| 599 | return ; |
| 600 | } |
| 601 | |
| 602 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 603 | |
| 604 | if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code)) |
| 605 | { |
| 606 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 607 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 608 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 609 | { |
| 610 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 611 | "Setting phymode to 11n!!"); |
| 612 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 613 | } |
| 614 | } |
| 615 | else |
| 616 | { |
| 617 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 618 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 619 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 620 | return ; |
| 621 | } |
| 622 | |
| 623 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 624 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 625 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 626 | { |
| 627 | VOS_STATUS vosStatus; |
| 628 | |
| 629 | // need to issue a disconnect to CSR. |
| 630 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 631 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 632 | pAdapter->sessionId, |
| 633 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 634 | |
| 635 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 636 | { |
| 637 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 638 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 639 | if (ret <= 0) |
| 640 | { |
| 641 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 642 | "wait on disconnect_comp_var is failed %ld", ret); |
| 643 | } |
| 644 | } |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 645 | |
| 646 | } |
| 647 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 648 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 649 | |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 650 | void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code) |
| 651 | { |
| 652 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 653 | hdd_config_t *cfg_param; |
| 654 | |
| 655 | if (NULL == pHddCtx) |
| 656 | { |
| 657 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 658 | "HDD Context is null !!"); |
| 659 | return ; |
| 660 | } |
| 661 | |
| 662 | cfg_param = pHddCtx->cfg_ini; |
| 663 | |
| 664 | if (NULL == cfg_param) |
| 665 | { |
| 666 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 667 | "cfg_params not available !!"); |
| 668 | return ; |
| 669 | } |
| 670 | |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 671 | if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code) || |
| 672 | pHddCtx->disable_dfs_flag == TRUE) |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 673 | { |
| 674 | /*New country doesn't support DFS */ |
| 675 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
| 676 | } |
| 677 | else |
| 678 | { |
| 679 | /*New country Supports DFS as well resetting value back from .ini*/ |
| 680 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan); |
| 681 | } |
| 682 | |
| 683 | } |
| 684 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 685 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 686 | |
| 687 | /**--------------------------------------------------------------------------- |
| 688 | |
| 689 | \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from |
| 690 | input string |
| 691 | |
| 692 | This function extracts assigned integer from string in below format: |
| 693 | "STRING=10" : extracts integer 10 from this string |
| 694 | |
| 695 | \param - pInPtr Pointer to input string |
| 696 | \param - base Base for string to int conversion(10 for decimal 16 for hex) |
| 697 | \param - pOutPtr Pointer to variable in which extracted integer needs to be |
| 698 | assigned |
| 699 | \param - pLastArg to tell whether it is last arguement in input string or |
| 700 | not |
| 701 | |
| 702 | \return - NULL for failure cases |
| 703 | pointer to next arguement in input string for success cases |
| 704 | --------------------------------------------------------------------------*/ |
| 705 | static tANI_U8 * |
| 706 | hdd_extract_assigned_int_from_str |
| 707 | ( |
| 708 | tANI_U8 *pInPtr, |
| 709 | tANI_U8 base, |
| 710 | tANI_U32 *pOutPtr, |
| 711 | tANI_U8 *pLastArg |
| 712 | ) |
| 713 | { |
| 714 | int tempInt; |
| 715 | int v = 0; |
| 716 | char buf[32]; |
| 717 | int val = 0; |
| 718 | *pLastArg = FALSE; |
| 719 | |
| 720 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 721 | if (NULL == pInPtr) |
| 722 | { |
| 723 | return NULL; |
| 724 | } |
| 725 | |
| 726 | pInPtr++; |
| 727 | |
| 728 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 729 | |
| 730 | val = sscanf(pInPtr, "%32s ", buf); |
| 731 | if (val < 0 && val > strlen(pInPtr)) |
| 732 | { |
| 733 | return NULL; |
| 734 | } |
| 735 | pInPtr += val; |
| 736 | v = kstrtos32(buf, base, &tempInt); |
| 737 | if (v < 0) |
| 738 | { |
| 739 | return NULL; |
| 740 | } |
Rajeev Kumar | 4d93d84 | 2014-01-02 18:31:21 -0800 | [diff] [blame] | 741 | if (tempInt < 0) |
| 742 | { |
| 743 | tempInt = 0; |
| 744 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 745 | *pOutPtr = tempInt; |
| 746 | |
| 747 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 748 | if (NULL == pInPtr) |
| 749 | { |
| 750 | *pLastArg = TRUE; |
| 751 | return NULL; |
| 752 | } |
| 753 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 754 | |
| 755 | return pInPtr; |
| 756 | } |
| 757 | |
| 758 | /**--------------------------------------------------------------------------- |
| 759 | |
| 760 | \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from |
| 761 | input string |
| 762 | |
| 763 | This function extracts assigned character from string in below format: |
| 764 | "STRING=A" : extracts char 'A' from this string |
| 765 | |
| 766 | \param - pInPtr Pointer to input string |
| 767 | \param - pOutPtr Pointer to variable in which extracted char needs to be |
| 768 | assigned |
| 769 | \param - pLastArg to tell whether it is last arguement in input string or |
| 770 | not |
| 771 | |
| 772 | \return - NULL for failure cases |
| 773 | pointer to next arguement in input string for success cases |
| 774 | --------------------------------------------------------------------------*/ |
| 775 | static tANI_U8 * |
| 776 | hdd_extract_assigned_char_from_str |
| 777 | ( |
| 778 | tANI_U8 *pInPtr, |
| 779 | tANI_U8 *pOutPtr, |
| 780 | tANI_U8 *pLastArg |
| 781 | ) |
| 782 | { |
| 783 | *pLastArg = FALSE; |
| 784 | |
| 785 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 786 | if (NULL == pInPtr) |
| 787 | { |
| 788 | return NULL; |
| 789 | } |
| 790 | |
| 791 | pInPtr++; |
| 792 | |
| 793 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 794 | |
| 795 | *pOutPtr = *pInPtr; |
| 796 | |
| 797 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 798 | if (NULL == pInPtr) |
| 799 | { |
| 800 | *pLastArg = TRUE; |
| 801 | return NULL; |
| 802 | } |
| 803 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 804 | |
| 805 | return pInPtr; |
| 806 | } |
| 807 | |
| 808 | |
| 809 | /**--------------------------------------------------------------------------- |
| 810 | |
| 811 | \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command |
| 812 | |
| 813 | This function parses set batch scan command in below format: |
| 814 | WLS_BATCHING_SET <space> followed by below arguements |
| 815 | "SCANFREQ=XX" : Optional defaults to 30 sec |
| 816 | "MSCAN=XX" : Required number of scans to attempt to batch |
| 817 | "BESTN=XX" : Best Network (RSSI) defaults to 16 |
| 818 | "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B. |
| 819 | A. implies only 5 GHz , B. implies only 2.4GHz |
| 820 | "RTT=X" : optional defaults to 0 |
| 821 | returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on |
| 822 | error |
| 823 | |
| 824 | For example input commands: |
| 825 | 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is |
| 826 | translated into set batch scan with following parameters: |
| 827 | a) Frequence 60 seconds |
| 828 | b) Batch 10 scans together |
| 829 | c) Best RSSI to be 20 |
| 830 | d) 5GHz band only |
| 831 | e) RTT is equal to 0 |
| 832 | |
| 833 | \param - pValue Pointer to input channel list |
| 834 | \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure |
| 835 | |
| 836 | \return - 0 for success non-zero for failure |
| 837 | |
| 838 | --------------------------------------------------------------------------*/ |
| 839 | static int |
| 840 | hdd_parse_set_batchscan_command |
| 841 | ( |
| 842 | tANI_U8 *pValue, |
| 843 | tSirSetBatchScanReq *pHddSetBatchScanReq |
| 844 | ) |
| 845 | { |
| 846 | tANI_U8 *inPtr = pValue; |
| 847 | tANI_U8 val = 0; |
| 848 | tANI_U8 lastArg = 0; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 849 | tANI_U32 nScanFreq; |
| 850 | tANI_U32 nMscan; |
| 851 | tANI_U32 nBestN; |
| 852 | tANI_U8 ucRfBand; |
| 853 | tANI_U32 nRtt; |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 854 | tANI_U32 temp; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 855 | |
| 856 | /*initialize default values*/ |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 857 | nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ; |
| 858 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 859 | nRtt = 0; |
| 860 | nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 861 | |
| 862 | /*go to space after WLS_BATCHING_SET command*/ |
| 863 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 864 | /*no argument after the command*/ |
| 865 | if (NULL == inPtr) |
| 866 | { |
| 867 | return -EINVAL; |
| 868 | } |
| 869 | |
| 870 | /*no space after the command*/ |
| 871 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 872 | { |
| 873 | return -EINVAL; |
| 874 | } |
| 875 | |
| 876 | /*removing empty spaces*/ |
| 877 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 878 | |
| 879 | /*no argument followed by spaces*/ |
| 880 | if ('\0' == *inPtr) |
| 881 | { |
| 882 | return -EINVAL; |
| 883 | } |
| 884 | |
| 885 | /*check and parse SCANFREQ*/ |
| 886 | if ((strncmp(inPtr, "SCANFREQ", 8) == 0)) |
| 887 | { |
| 888 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 889 | &temp, &lastArg); |
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 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 892 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 893 | nScanFreq = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 894 | } |
| 895 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 896 | if ( (NULL == inPtr) || (TRUE == lastArg)) |
| 897 | { |
| 898 | return -EINVAL; |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | /*check and parse MSCAN*/ |
| 903 | if ((strncmp(inPtr, "MSCAN", 5) == 0)) |
| 904 | { |
| 905 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 906 | &nMscan, &lastArg); |
| 907 | |
| 908 | if (0 == nMscan) |
| 909 | { |
| 910 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 911 | "invalid MSCAN=%d", nMscan); |
| 912 | return -EINVAL; |
| 913 | } |
| 914 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 915 | if (TRUE == lastArg) |
| 916 | { |
| 917 | goto done; |
| 918 | } |
| 919 | else if (NULL == inPtr) |
| 920 | { |
| 921 | return -EINVAL; |
| 922 | } |
| 923 | } |
| 924 | else |
| 925 | { |
| 926 | return -EINVAL; |
| 927 | } |
| 928 | |
| 929 | /*check and parse BESTN*/ |
| 930 | if ((strncmp(inPtr, "BESTN", 5) == 0)) |
| 931 | { |
| 932 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 933 | &temp, &lastArg); |
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 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 936 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 937 | nBestN = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 938 | } |
| 939 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 940 | if (TRUE == lastArg) |
| 941 | { |
| 942 | goto done; |
| 943 | } |
| 944 | else if (NULL == inPtr) |
| 945 | { |
| 946 | return -EINVAL; |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | /*check and parse CHANNEL*/ |
| 951 | if ((strncmp(inPtr, "CHANNEL", 7) == 0)) |
| 952 | { |
| 953 | inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg); |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 954 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 955 | if (('A' == val) || ('a' == val)) |
| 956 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 957 | ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 958 | } |
| 959 | else if (('B' == val) || ('b' == val)) |
| 960 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 961 | ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 962 | } |
| 963 | else |
| 964 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 965 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 966 | } |
| 967 | |
| 968 | if (TRUE == lastArg) |
| 969 | { |
| 970 | goto done; |
| 971 | } |
| 972 | else if (NULL == inPtr) |
| 973 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 974 | return -EINVAL; |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | /*check and parse RTT*/ |
| 979 | if ((strncmp(inPtr, "RTT", 3) == 0)) |
| 980 | { |
| 981 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 982 | &nRtt, &lastArg); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 983 | if (TRUE == lastArg) |
| 984 | { |
| 985 | goto done; |
| 986 | } |
| 987 | if (NULL == inPtr) |
| 988 | { |
| 989 | return -EINVAL; |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | |
| 994 | done: |
| 995 | |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 996 | pHddSetBatchScanReq->scanFrequency = nScanFreq; |
| 997 | pHddSetBatchScanReq->numberOfScansToBatch = nMscan; |
| 998 | pHddSetBatchScanReq->bestNetwork = nBestN; |
| 999 | pHddSetBatchScanReq->rfBand = ucRfBand; |
| 1000 | pHddSetBatchScanReq->rtt = nRtt; |
| 1001 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1002 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1003 | "Received WLS_BATCHING_SET with SCANFREQ=%d " |
| 1004 | "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d", |
| 1005 | pHddSetBatchScanReq->scanFrequency, |
| 1006 | pHddSetBatchScanReq->numberOfScansToBatch, |
| 1007 | pHddSetBatchScanReq->bestNetwork, |
| 1008 | pHddSetBatchScanReq->rfBand, |
| 1009 | pHddSetBatchScanReq->rtt); |
| 1010 | |
| 1011 | return 0; |
| 1012 | }/*End of hdd_parse_set_batchscan_command*/ |
| 1013 | |
| 1014 | /**--------------------------------------------------------------------------- |
| 1015 | |
| 1016 | \brief hdd_set_batch_scan_req_callback () - This function is called after |
| 1017 | receiving set batch scan response from FW and it saves set batch scan |
| 1018 | response data FW to HDD context and sets the completion event on |
| 1019 | which hdd_ioctl is waiting |
| 1020 | |
| 1021 | \param - callbackContext Pointer to HDD adapter |
| 1022 | \param - pRsp Pointer to set batch scan response data received from FW |
| 1023 | |
| 1024 | \return - nothing |
| 1025 | |
| 1026 | --------------------------------------------------------------------------*/ |
| 1027 | static void hdd_set_batch_scan_req_callback |
| 1028 | ( |
| 1029 | void *callbackContext, |
| 1030 | tSirSetBatchScanRsp *pRsp |
| 1031 | ) |
| 1032 | { |
| 1033 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 1034 | tSirSetBatchScanRsp *pHddSetBatchScanRsp; |
| 1035 | |
| 1036 | /*sanity check*/ |
| 1037 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 1038 | { |
| 1039 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1040 | "%s: Invalid pAdapter magic", __func__); |
| 1041 | VOS_ASSERT(0); |
| 1042 | return; |
| 1043 | } |
| 1044 | pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp; |
| 1045 | |
| 1046 | /*save set batch scan response*/ |
| 1047 | pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch; |
| 1048 | |
| 1049 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1050 | "Received set batch scan rsp from FW with nScansToBatch=%d", |
| 1051 | pHddSetBatchScanRsp->nScansToBatch); |
| 1052 | |
| 1053 | pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE; |
| 1054 | complete(&pAdapter->hdd_set_batch_scan_req_var); |
| 1055 | |
| 1056 | return; |
| 1057 | }/*End of hdd_set_batch_scan_req_callback*/ |
| 1058 | |
| 1059 | |
| 1060 | /**--------------------------------------------------------------------------- |
| 1061 | |
| 1062 | \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta |
| 1063 | info in hdd batch scan response queue |
| 1064 | |
| 1065 | \param - pAdapter Pointer to hdd adapter |
| 1066 | \param - pAPMetaInfo Pointer to access point meta info |
| 1067 | \param - scanId scan ID of batch scan response |
| 1068 | \param - isLastAp tells whether AP is last AP in batch scan response or not |
| 1069 | |
| 1070 | \return - nothing |
| 1071 | |
| 1072 | --------------------------------------------------------------------------*/ |
| 1073 | static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter, |
| 1074 | tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp) |
| 1075 | { |
| 1076 | tHddBatchScanRsp *pHead; |
| 1077 | tHddBatchScanRsp *pNode; |
| 1078 | tHddBatchScanRsp *pPrev; |
| 1079 | tHddBatchScanRsp *pTemp; |
| 1080 | tANI_U8 ssidLen; |
| 1081 | |
| 1082 | /*head of hdd batch scan response queue*/ |
| 1083 | pHead = pAdapter->pBatchScanRsp; |
| 1084 | |
| 1085 | pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp)); |
| 1086 | if (NULL == pNode) |
| 1087 | { |
| 1088 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1089 | "%s: Could not allocate memory", __func__); |
| 1090 | VOS_ASSERT(0); |
| 1091 | return; |
| 1092 | } |
| 1093 | |
| 1094 | vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid, |
| 1095 | sizeof(pNode->ApInfo.bssid)); |
| 1096 | ssidLen = strlen(pApMetaInfo->ssid); |
| 1097 | if (SIR_MAX_SSID_SIZE < ssidLen) |
| 1098 | { |
| 1099 | /*invalid scan result*/ |
| 1100 | vos_mem_free(pNode); |
| 1101 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1102 | "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen); |
| 1103 | return; |
| 1104 | } |
| 1105 | vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen); |
| 1106 | /*null terminate ssid*/ |
| 1107 | pNode->ApInfo.ssid[ssidLen] = '\0'; |
| 1108 | pNode->ApInfo.ch = pApMetaInfo->ch; |
| 1109 | pNode->ApInfo.rssi = pApMetaInfo->rssi; |
| 1110 | pNode->ApInfo.age = pApMetaInfo->timestamp; |
| 1111 | pNode->ApInfo.batchId = scanId; |
| 1112 | pNode->ApInfo.isLastAp = isLastAp; |
| 1113 | |
| 1114 | pNode->pNext = NULL; |
| 1115 | if (NULL == pHead) |
| 1116 | { |
| 1117 | pAdapter->pBatchScanRsp = pNode; |
| 1118 | } |
| 1119 | else |
| 1120 | { |
| 1121 | pTemp = pHead; |
| 1122 | while (NULL != pTemp) |
| 1123 | { |
| 1124 | pPrev = pTemp; |
| 1125 | pTemp = pTemp->pNext; |
| 1126 | } |
| 1127 | pPrev->pNext = pNode; |
| 1128 | } |
| 1129 | |
| 1130 | return; |
| 1131 | }/*End of hdd_populate_batch_scan_rsp_queue*/ |
| 1132 | |
| 1133 | /**--------------------------------------------------------------------------- |
| 1134 | |
| 1135 | \brief hdd_batch_scan_result_ind_callback () - This function is called after |
| 1136 | receiving batch scan response indication from FW. It saves get batch scan |
| 1137 | response data in HDD batch scan response queue. This callback sets the |
| 1138 | completion event on which hdd_ioctl is waiting only after getting complete |
| 1139 | batch scan response data from FW |
| 1140 | |
| 1141 | \param - callbackContext Pointer to HDD adapter |
| 1142 | \param - pRsp Pointer to get batch scan response data received from FW |
| 1143 | |
| 1144 | \return - nothing |
| 1145 | |
| 1146 | --------------------------------------------------------------------------*/ |
| 1147 | static void hdd_batch_scan_result_ind_callback |
| 1148 | ( |
| 1149 | void *callbackContext, |
| 1150 | void *pRsp |
| 1151 | ) |
| 1152 | { |
| 1153 | v_BOOL_t isLastAp; |
| 1154 | tANI_U32 numApMetaInfo; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1155 | tANI_U32 numNetworkInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1156 | tANI_U32 numberScanList; |
| 1157 | tANI_U32 nextScanListOffset; |
| 1158 | tANI_U32 nextApMetaInfoOffset; |
| 1159 | hdd_adapter_t* pAdapter; |
| 1160 | tpSirBatchScanList pScanList; |
| 1161 | tpSirBatchScanNetworkInfo pApMetaInfo; |
| 1162 | tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/ |
| 1163 | tSirSetBatchScanReq *pReq; |
| 1164 | |
| 1165 | pAdapter = (hdd_adapter_t *)callbackContext; |
| 1166 | /*sanity check*/ |
Rajeev Kumar | 5286bb9 | 2013-12-05 11:52:10 -0800 | [diff] [blame] | 1167 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1168 | { |
| 1169 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1170 | "%s: Invalid pAdapter magic", __func__); |
| 1171 | VOS_ASSERT(0); |
| 1172 | return; |
| 1173 | } |
| 1174 | |
| 1175 | /*initialize locals*/ |
| 1176 | pReq = &pAdapter->hddSetBatchScanReq; |
| 1177 | pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp; |
| 1178 | isLastAp = FALSE; |
| 1179 | numApMetaInfo = 0; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1180 | numNetworkInScanList = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1181 | numberScanList = 0; |
| 1182 | nextScanListOffset = 0; |
| 1183 | nextApMetaInfoOffset = 0; |
| 1184 | pScanList = NULL; |
| 1185 | pApMetaInfo = NULL; |
| 1186 | |
| 1187 | if ((NULL == pBatchScanRsp) || (NULL == pReq)) |
| 1188 | { |
| 1189 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1190 | "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq); |
| 1191 | isLastAp = TRUE; |
| 1192 | goto done; |
| 1193 | } |
| 1194 | |
| 1195 | pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists; |
| 1196 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1197 | "Batch scan rsp: numberScalList %d", numberScanList); |
| 1198 | |
| 1199 | if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch)) |
| 1200 | { |
| 1201 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1202 | "%s: numberScanList %d", __func__, numberScanList); |
| 1203 | isLastAp = TRUE; |
| 1204 | goto done; |
| 1205 | } |
| 1206 | |
| 1207 | while (numberScanList) |
| 1208 | { |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1209 | pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults + |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1210 | nextScanListOffset); |
| 1211 | if (NULL == pScanList) |
| 1212 | { |
| 1213 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1214 | "%s: pScanList is %p", __func__, pScanList); |
| 1215 | isLastAp = TRUE; |
| 1216 | goto done; |
| 1217 | } |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1218 | numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1219 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1220 | "Batch scan rsp: numApMetaInfo %d scanId %d", |
| 1221 | numApMetaInfo, pScanList->scanId); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1222 | |
| 1223 | if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork)) |
| 1224 | { |
| 1225 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1226 | "%s: numApMetaInfo %d", __func__, numApMetaInfo); |
| 1227 | isLastAp = TRUE; |
| 1228 | goto done; |
| 1229 | } |
| 1230 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1231 | /*Initialize next AP meta info offset for next scan list*/ |
| 1232 | nextApMetaInfoOffset = 0; |
| 1233 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1234 | while (numApMetaInfo) |
| 1235 | { |
| 1236 | pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList + |
| 1237 | nextApMetaInfoOffset); |
| 1238 | if (NULL == pApMetaInfo) |
| 1239 | { |
| 1240 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1241 | "%s: pApMetaInfo is %p", __func__, pApMetaInfo); |
| 1242 | isLastAp = TRUE; |
| 1243 | goto done; |
| 1244 | } |
| 1245 | /*calculate AP age*/ |
| 1246 | pApMetaInfo->timestamp = |
| 1247 | pBatchScanRsp->timestamp - pApMetaInfo->timestamp; |
| 1248 | |
| 1249 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1250 | "%s: bssId "MAC_ADDRESS_STR |
| 1251 | " ch %d rssi %d timestamp %d", __func__, |
| 1252 | MAC_ADDR_ARRAY(pApMetaInfo->bssid), |
| 1253 | pApMetaInfo->ch, pApMetaInfo->rssi, |
| 1254 | pApMetaInfo->timestamp); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1255 | |
| 1256 | /*mark last AP in batch scan response*/ |
| 1257 | if ((TRUE == pBatchScanRsp->isLastResult) && |
| 1258 | (1 == numberScanList) && (1 == numApMetaInfo)) |
| 1259 | { |
| 1260 | isLastAp = TRUE; |
| 1261 | } |
| 1262 | |
| 1263 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1264 | /*store batch scan repsonse in hdd queue*/ |
| 1265 | hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo, |
| 1266 | pScanList->scanId, isLastAp); |
| 1267 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1268 | |
| 1269 | nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo); |
| 1270 | numApMetaInfo--; |
| 1271 | } |
| 1272 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1273 | nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8)) |
| 1274 | + (sizeof(tSirBatchScanNetworkInfo) |
| 1275 | * numNetworkInScanList)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1276 | numberScanList--; |
| 1277 | } |
| 1278 | |
| 1279 | done: |
| 1280 | |
| 1281 | /*notify hdd_ioctl only if complete batch scan rsp is received and it was |
| 1282 | requested from hdd_ioctl*/ |
| 1283 | if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) && |
| 1284 | (TRUE == isLastAp)) |
| 1285 | { |
| 1286 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1287 | complete(&pAdapter->hdd_get_batch_scan_req_var); |
| 1288 | } |
| 1289 | |
| 1290 | return; |
| 1291 | }/*End of hdd_batch_scan_result_ind_callback*/ |
| 1292 | |
| 1293 | /**--------------------------------------------------------------------------- |
| 1294 | |
| 1295 | \brief hdd_format_batch_scan_rsp () - This function formats batch scan |
| 1296 | response as per batch scan FR request format by putting proper markers |
| 1297 | |
| 1298 | \param - pDest pointer to destination buffer |
| 1299 | \param - cur_len current length |
| 1300 | \param - tot_len total remaining size which can be written to user space |
| 1301 | \param - pApMetaInfo Pointer to get batch scan response AP meta info |
| 1302 | \param - pAdapter Pointer to HDD adapter |
| 1303 | |
| 1304 | \return - ret no of characters written |
| 1305 | |
| 1306 | --------------------------------------------------------------------------*/ |
| 1307 | static tANI_U32 |
| 1308 | hdd_format_batch_scan_rsp |
| 1309 | ( |
| 1310 | tANI_U8 *pDest, |
| 1311 | tANI_U32 cur_len, |
| 1312 | tANI_U32 tot_len, |
| 1313 | tHddBatchScanRsp *pApMetaInfo, |
| 1314 | hdd_adapter_t* pAdapter |
| 1315 | ) |
| 1316 | { |
| 1317 | tANI_U32 ret = 0; |
| 1318 | tANI_U32 rem_len = 0; |
| 1319 | tANI_U8 temp_len = 0; |
| 1320 | tANI_U8 temp_total_len = 0; |
| 1321 | tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE]; |
| 1322 | tANI_U8 *pTemp = temp; |
| 1323 | |
| 1324 | /*Batch scan reponse needs to be returned to user space in |
| 1325 | following format: |
| 1326 | "scancount=X\n" where X is the number of scans in current batch |
| 1327 | batch |
| 1328 | "trunc\n" optional present if current scan truncated |
| 1329 | "bssid=XX:XX:XX:XX:XX:XX\n" |
| 1330 | "ssid=XXXX\n" |
| 1331 | "freq=X\n" frequency in Mhz |
| 1332 | "level=XX\n" |
| 1333 | "age=X\n" ms |
| 1334 | "dist=X\n" cm (-1 if not available) |
| 1335 | "errror=X\n" (-1if not available) |
| 1336 | "====\n" (end of ap marker) |
| 1337 | "####\n" (end of scan marker) |
| 1338 | "----\n" (end of results)*/ |
| 1339 | /*send scan result in above format to user space based on |
| 1340 | available length*/ |
| 1341 | /*The GET response may have more data than the driver can return in its |
| 1342 | buffer. In that case the buffer should be filled to the nearest complete |
| 1343 | scan, ending with "%%%%".Subsequent callsshould return the remaining data |
| 1344 | starting with the next scan (optional .trunc\n., .apcount=X\n., etc). |
| 1345 | The final buffer should end with "----\n"*/ |
| 1346 | |
| 1347 | /*sanity*/ |
| 1348 | if (cur_len > tot_len) |
| 1349 | { |
| 1350 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1351 | "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len); |
| 1352 | return 0; |
| 1353 | } |
| 1354 | else |
| 1355 | { |
| 1356 | rem_len = (tot_len - cur_len); |
| 1357 | } |
| 1358 | |
| 1359 | /*end scan marker*/ |
| 1360 | if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id) |
| 1361 | { |
| 1362 | temp_len = snprintf(pTemp, sizeof(temp), "####\n"); |
| 1363 | pTemp += temp_len; |
| 1364 | temp_total_len += temp_len; |
| 1365 | } |
| 1366 | |
| 1367 | /*bssid*/ |
| 1368 | temp_len = snprintf(pTemp, sizeof(temp), |
| 1369 | "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", |
| 1370 | pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1], |
| 1371 | pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3], |
| 1372 | pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]); |
| 1373 | pTemp += temp_len; |
| 1374 | temp_total_len += temp_len; |
| 1375 | |
| 1376 | /*ssid*/ |
| 1377 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n", |
| 1378 | pApMetaInfo->ApInfo.ssid); |
| 1379 | pTemp += temp_len; |
| 1380 | temp_total_len += temp_len; |
| 1381 | |
| 1382 | /*freq*/ |
| 1383 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n", |
Rajeev Kumar | c40f751 | 2013-11-04 14:13:23 -0800 | [diff] [blame] | 1384 | sme_ChnToFreq(pApMetaInfo->ApInfo.ch)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1385 | pTemp += temp_len; |
| 1386 | temp_total_len += temp_len; |
| 1387 | |
| 1388 | /*level*/ |
| 1389 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n", |
| 1390 | pApMetaInfo->ApInfo.rssi); |
| 1391 | pTemp += temp_len; |
| 1392 | temp_total_len += temp_len; |
| 1393 | |
| 1394 | /*age*/ |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1395 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n", |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1396 | pApMetaInfo->ApInfo.age); |
| 1397 | pTemp += temp_len; |
| 1398 | temp_total_len += temp_len; |
| 1399 | |
| 1400 | /*dist*/ |
| 1401 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n"); |
| 1402 | pTemp += temp_len; |
| 1403 | temp_total_len += temp_len; |
| 1404 | |
| 1405 | /*error*/ |
| 1406 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n"); |
| 1407 | pTemp += temp_len; |
| 1408 | temp_total_len += temp_len; |
| 1409 | |
| 1410 | /*end AP marker*/ |
| 1411 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n"); |
| 1412 | pTemp += temp_len; |
| 1413 | temp_total_len += temp_len; |
| 1414 | |
| 1415 | /*last AP in batch scan response*/ |
| 1416 | if(TRUE == pApMetaInfo->ApInfo.isLastAp) |
| 1417 | { |
| 1418 | /*end scan marker*/ |
| 1419 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n"); |
| 1420 | pTemp += temp_len; |
| 1421 | temp_total_len += temp_len; |
| 1422 | |
| 1423 | /*end batch scan result marker*/ |
| 1424 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n"); |
| 1425 | pTemp += temp_len; |
| 1426 | temp_total_len += temp_len; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1427 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1428 | } |
| 1429 | |
| 1430 | if (temp_total_len < rem_len) |
| 1431 | { |
| 1432 | ret = temp_total_len + 1; |
| 1433 | strlcpy(pDest, temp, ret); |
| 1434 | pAdapter->isTruncated = FALSE; |
| 1435 | } |
| 1436 | else |
| 1437 | { |
| 1438 | pAdapter->isTruncated = TRUE; |
| 1439 | if (rem_len >= strlen("%%%%")) |
| 1440 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1441 | ret = snprintf(pDest, sizeof(temp), "%%%%"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1442 | } |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1443 | else |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1444 | { |
| 1445 | ret = 0; |
| 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | return ret; |
| 1450 | |
| 1451 | }/*End of hdd_format_batch_scan_rsp*/ |
| 1452 | |
| 1453 | /**--------------------------------------------------------------------------- |
| 1454 | |
| 1455 | \brief hdd_populate_user_batch_scan_rsp() - This function populates user data |
| 1456 | buffer starting with head of hdd batch scan response queue |
| 1457 | |
| 1458 | \param - pAdapter Pointer to HDD adapter |
| 1459 | \param - pDest Pointer to user data buffer |
| 1460 | \param - cur_len current offset in user buffer |
| 1461 | \param - rem_len remaining no of bytes in user buffer |
| 1462 | |
| 1463 | \return - number of bytes written in user buffer |
| 1464 | |
| 1465 | --------------------------------------------------------------------------*/ |
| 1466 | |
| 1467 | tANI_U32 hdd_populate_user_batch_scan_rsp |
| 1468 | ( |
| 1469 | hdd_adapter_t* pAdapter, |
| 1470 | tANI_U8 *pDest, |
| 1471 | tANI_U32 cur_len, |
| 1472 | tANI_U32 rem_len |
| 1473 | ) |
| 1474 | { |
| 1475 | tHddBatchScanRsp *pHead; |
| 1476 | tHddBatchScanRsp *pPrev; |
| 1477 | tANI_U32 len; |
| 1478 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1479 | pAdapter->isTruncated = FALSE; |
| 1480 | |
| 1481 | /*head of hdd batch scan response queue*/ |
| 1482 | pHead = pAdapter->pBatchScanRsp; |
| 1483 | while (pHead) |
| 1484 | { |
| 1485 | len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead, |
| 1486 | pAdapter); |
| 1487 | pDest += len; |
Rajeev Kumar | 292d2bb | 2013-10-23 15:01:44 -0700 | [diff] [blame] | 1488 | pDest--; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1489 | cur_len += len; |
| 1490 | if(TRUE == pAdapter->isTruncated) |
| 1491 | { |
| 1492 | /*result is truncated return rest of scan rsp in next req*/ |
| 1493 | cur_len = rem_len; |
| 1494 | break; |
| 1495 | } |
| 1496 | pPrev = pHead; |
| 1497 | pHead = pHead->pNext; |
| 1498 | pAdapter->pBatchScanRsp = pHead; |
Rajeev Kumar | be17d8b | 2014-01-10 15:39:45 -0800 | [diff] [blame] | 1499 | if (TRUE == pPrev->ApInfo.isLastAp) |
| 1500 | { |
| 1501 | pAdapter->prev_batch_id = 0; |
| 1502 | } |
| 1503 | else |
| 1504 | { |
| 1505 | pAdapter->prev_batch_id = pPrev->ApInfo.batchId; |
| 1506 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1507 | vos_mem_free(pPrev); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 1508 | pPrev = NULL; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1509 | } |
| 1510 | |
| 1511 | return cur_len; |
| 1512 | }/*End of hdd_populate_user_batch_scan_rsp*/ |
| 1513 | |
| 1514 | /**--------------------------------------------------------------------------- |
| 1515 | |
| 1516 | \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch |
| 1517 | scan response data from HDD queue to user space |
| 1518 | It does following in detail: |
| 1519 | a) if HDD has enough data in its queue then it 1st copies data to user |
| 1520 | space and then send get batch scan indication message to FW. In this |
| 1521 | case it does not wait on any event and batch scan response data will |
| 1522 | be populated in HDD response queue in MC thread context after receiving |
| 1523 | indication from FW |
| 1524 | b) else send get batch scan indication message to FW and wait on an event |
| 1525 | which will be set once HDD receives complete batch scan response from |
| 1526 | FW and then this function returns batch scan response to user space |
| 1527 | |
| 1528 | \param - pAdapter Pointer to HDD adapter |
| 1529 | \param - pPrivData Pointer to priv_data |
| 1530 | |
| 1531 | \return - 0 for success -EFAULT for failure |
| 1532 | |
| 1533 | --------------------------------------------------------------------------*/ |
| 1534 | |
| 1535 | int hdd_return_batch_scan_rsp_to_user |
| 1536 | ( |
| 1537 | hdd_adapter_t* pAdapter, |
| 1538 | hdd_priv_data_t *pPrivData, |
| 1539 | tANI_U8 *command |
| 1540 | ) |
| 1541 | { |
| 1542 | tANI_U8 *pDest; |
| 1543 | tANI_U32 count = 0; |
| 1544 | tANI_U32 len = 0; |
| 1545 | tANI_U32 cur_len = 0; |
| 1546 | tANI_U32 rem_len = 0; |
| 1547 | eHalStatus halStatus; |
| 1548 | unsigned long rc; |
| 1549 | tSirTriggerBatchScanResultInd *pReq; |
| 1550 | |
| 1551 | pReq = &pAdapter->hddTriggerBatchScanResultInd; |
| 1552 | pReq->param = 0;/*batch scan client*/ |
| 1553 | pDest = (tANI_U8 *)(command + pPrivData->used_len); |
| 1554 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1555 | |
| 1556 | cur_len = pPrivData->used_len; |
| 1557 | if (pPrivData->total_len > pPrivData->used_len) |
| 1558 | { |
| 1559 | rem_len = pPrivData->total_len - pPrivData->used_len; |
| 1560 | } |
| 1561 | else |
| 1562 | { |
| 1563 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1564 | "%s: Invalid user data buffer total_len %d used_len %d", |
| 1565 | __func__, pPrivData->total_len, pPrivData->used_len); |
| 1566 | return -EFAULT; |
| 1567 | } |
| 1568 | |
| 1569 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1570 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1571 | cur_len, rem_len); |
| 1572 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1573 | |
| 1574 | /*enough scan result available in cache to return to user space or |
| 1575 | scan result needs to be fetched 1st from fw and then return*/ |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1576 | if (len == cur_len) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1577 | { |
| 1578 | pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE; |
| 1579 | halStatus = sme_TriggerBatchScanResultInd( |
| 1580 | WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1581 | pAdapter->sessionId, hdd_batch_scan_result_ind_callback, |
| 1582 | pAdapter); |
| 1583 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1584 | { |
| 1585 | if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) |
| 1586 | { |
| 1587 | INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var); |
| 1588 | rc = wait_for_completion_timeout( |
| 1589 | &pAdapter->hdd_get_batch_scan_req_var, |
| 1590 | msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT)); |
| 1591 | if (0 == rc) |
| 1592 | { |
| 1593 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1594 | "%s: Timeout waiting to fetch batch scan rsp from fw", |
| 1595 | __func__); |
| 1596 | return -EFAULT; |
| 1597 | } |
| 1598 | } |
| 1599 | |
| 1600 | len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE, |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1601 | "scancount=%u\n", pAdapter->numScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1602 | pDest += len; |
| 1603 | cur_len += len; |
| 1604 | |
| 1605 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1606 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1607 | cur_len, rem_len); |
| 1608 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1609 | |
| 1610 | count = 0; |
| 1611 | len = (len - pPrivData->used_len); |
| 1612 | pDest = (command + pPrivData->used_len); |
| 1613 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1614 | "NEW BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1615 | while(count < len) |
| 1616 | { |
| 1617 | printk("%c", *(pDest + count)); |
| 1618 | count++; |
| 1619 | } |
| 1620 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1621 | "%s: copy %d data to user buffer", __func__, len); |
| 1622 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1623 | { |
| 1624 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1625 | "%s: failed to copy data to user buffer", __func__); |
| 1626 | return -EFAULT; |
| 1627 | } |
| 1628 | } |
| 1629 | else |
| 1630 | { |
| 1631 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1632 | "sme_GetBatchScanScan returned failure halStatus %d", |
| 1633 | halStatus); |
| 1634 | return -EINVAL; |
| 1635 | } |
| 1636 | } |
| 1637 | else |
| 1638 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1639 | count = 0; |
| 1640 | len = (len - pPrivData->used_len); |
| 1641 | pDest = (command + pPrivData->used_len); |
| 1642 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1643 | "REMAINING TRUNCATED BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1644 | while(count < len) |
| 1645 | { |
| 1646 | printk("%c", *(pDest + count)); |
| 1647 | count++; |
| 1648 | } |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1649 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1650 | "%s: copy %d data to user buffer", __func__, len); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1651 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1652 | { |
| 1653 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1654 | "%s: failed to copy data to user buffer", __func__); |
| 1655 | return -EFAULT; |
| 1656 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1657 | } |
| 1658 | |
| 1659 | return 0; |
| 1660 | } /*End of hdd_return_batch_scan_rsp_to_user*/ |
| 1661 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1662 | |
| 1663 | /**--------------------------------------------------------------------------- |
| 1664 | |
| 1665 | \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING |
| 1666 | IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled: |
| 1667 | WLS_BATCHING VERSION |
| 1668 | WLS_BATCHING SET |
| 1669 | WLS_BATCHING GET |
| 1670 | WLS_BATCHING STOP |
| 1671 | |
| 1672 | \param - pAdapter Pointer to HDD adapter |
| 1673 | \param - pPrivdata Pointer to priv_data |
| 1674 | \param - command Pointer to command |
| 1675 | |
| 1676 | \return - 0 for success -EFAULT for failure |
| 1677 | |
| 1678 | --------------------------------------------------------------------------*/ |
| 1679 | |
| 1680 | int hdd_handle_batch_scan_ioctl |
| 1681 | ( |
| 1682 | hdd_adapter_t *pAdapter, |
| 1683 | hdd_priv_data_t *pPrivdata, |
| 1684 | tANI_U8 *command |
| 1685 | ) |
| 1686 | { |
| 1687 | int ret = 0; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 1688 | hdd_context_t *pHddCtx; |
| 1689 | |
| 1690 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1691 | ret = wlan_hdd_validate_context(pHddCtx); |
| 1692 | if (ret) |
| 1693 | { |
| 1694 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1695 | "%s: HDD context is not valid!", __func__); |
| 1696 | goto exit; |
| 1697 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1698 | |
| 1699 | if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0) |
| 1700 | { |
| 1701 | char extra[32]; |
| 1702 | tANI_U8 len = 0; |
| 1703 | tANI_U8 version = HDD_BATCH_SCAN_VERSION; |
| 1704 | |
| 1705 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1706 | { |
| 1707 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1708 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1709 | ret = -EINVAL; |
| 1710 | goto exit; |
| 1711 | } |
| 1712 | |
| 1713 | len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d", |
| 1714 | version); |
| 1715 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1716 | { |
| 1717 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1718 | "%s: failed to copy data to user buffer", __func__); |
| 1719 | ret = -EFAULT; |
| 1720 | goto exit; |
| 1721 | } |
| 1722 | ret = HDD_BATCH_SCAN_VERSION; |
| 1723 | } |
| 1724 | else if (strncmp(command, "WLS_BATCHING SET", 16) == 0) |
| 1725 | { |
| 1726 | int status; |
| 1727 | tANI_U8 *value = (command + 16); |
| 1728 | eHalStatus halStatus; |
| 1729 | unsigned long rc; |
| 1730 | tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq; |
| 1731 | tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp; |
| 1732 | |
| 1733 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1734 | { |
| 1735 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1736 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1737 | ret = -EINVAL; |
| 1738 | goto exit; |
| 1739 | } |
| 1740 | |
| 1741 | if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) && |
| 1742 | (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) && |
| 1743 | (WLAN_HDD_P2P_GO != pAdapter->device_mode) && |
| 1744 | (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode)) |
| 1745 | { |
| 1746 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 1747 | "Received WLS_BATCHING SET command in invalid mode %s (%d) " |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1748 | "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode", |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 1749 | hdd_device_modetoString(pAdapter->device_mode), |
| 1750 | pAdapter->device_mode); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1751 | ret = -EINVAL; |
| 1752 | goto exit; |
| 1753 | } |
| 1754 | |
| 1755 | status = hdd_parse_set_batchscan_command(value, pReq); |
| 1756 | if (status) |
| 1757 | { |
| 1758 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1759 | "Invalid WLS_BATCHING SET command"); |
| 1760 | ret = -EINVAL; |
| 1761 | goto exit; |
| 1762 | } |
| 1763 | |
| 1764 | |
| 1765 | pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE; |
| 1766 | halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1767 | pAdapter->sessionId, hdd_set_batch_scan_req_callback, |
| 1768 | pAdapter); |
| 1769 | |
| 1770 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1771 | { |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1772 | char extra[32]; |
| 1773 | tANI_U8 len = 0; |
| 1774 | tANI_U8 mScan = 0; |
| 1775 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1776 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1777 | "sme_SetBatchScanReq returned success halStatus %d", |
| 1778 | halStatus); |
| 1779 | if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp) |
| 1780 | { |
| 1781 | INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var); |
| 1782 | rc = wait_for_completion_timeout( |
| 1783 | &pAdapter->hdd_set_batch_scan_req_var, |
| 1784 | msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT)); |
| 1785 | if (0 == rc) |
| 1786 | { |
| 1787 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1788 | "%s: Timeout waiting for set batch scan to complete", |
| 1789 | __func__); |
| 1790 | ret = -EINVAL; |
| 1791 | goto exit; |
| 1792 | } |
| 1793 | } |
| 1794 | if ( !pRsp->nScansToBatch ) |
| 1795 | { |
| 1796 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1797 | "%s: Received set batch scan failure response from FW", |
| 1798 | __func__); |
| 1799 | ret = -EINVAL; |
| 1800 | goto exit; |
| 1801 | } |
| 1802 | /*As per the Batch Scan Framework API we should return the MIN of |
| 1803 | either MSCAN or the max # of scans firmware can cache*/ |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1804 | mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1805 | |
| 1806 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED; |
| 1807 | |
| 1808 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1809 | "%s: request MSCAN %d response MSCAN %d ret %d", |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1810 | __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan); |
| 1811 | len = scnprintf(extra, sizeof(extra), "%d", mScan); |
| 1812 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1813 | { |
| 1814 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1815 | "%s: failed to copy MSCAN value to user buffer", __func__); |
| 1816 | ret = -EFAULT; |
| 1817 | goto exit; |
| 1818 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1819 | } |
| 1820 | else |
| 1821 | { |
| 1822 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1823 | "sme_SetBatchScanReq returned failure halStatus %d", |
| 1824 | halStatus); |
| 1825 | ret = -EINVAL; |
| 1826 | goto exit; |
| 1827 | } |
| 1828 | } |
| 1829 | else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0) |
| 1830 | { |
| 1831 | eHalStatus halStatus; |
| 1832 | tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd; |
| 1833 | pInd->param = 0; |
| 1834 | |
| 1835 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1836 | { |
| 1837 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1838 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1839 | ret = -EINVAL; |
| 1840 | goto exit; |
| 1841 | } |
| 1842 | |
| 1843 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1844 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 1845 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1846 | "Batch scan is not yet enabled batch scan state %d", |
| 1847 | pAdapter->batchScanState); |
| 1848 | ret = -EINVAL; |
| 1849 | goto exit; |
| 1850 | } |
| 1851 | |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1852 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1853 | hdd_deinit_batch_scan(pAdapter); |
| 1854 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1855 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1856 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 1857 | |
| 1858 | halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd, |
| 1859 | pAdapter->sessionId); |
| 1860 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1861 | { |
| 1862 | ret = 0; |
| 1863 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1864 | "sme_StopBatchScanInd returned success halStatus %d", |
| 1865 | halStatus); |
| 1866 | } |
| 1867 | else |
| 1868 | { |
| 1869 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1870 | "sme_StopBatchScanInd returned failure halStatus %d", |
| 1871 | halStatus); |
| 1872 | ret = -EINVAL; |
| 1873 | goto exit; |
| 1874 | } |
| 1875 | } |
| 1876 | else if (strncmp(command, "WLS_BATCHING GET", 16) == 0) |
| 1877 | { |
| 1878 | tANI_U32 remain_len; |
| 1879 | |
| 1880 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1881 | { |
| 1882 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1883 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1884 | ret = -EINVAL; |
| 1885 | goto exit; |
| 1886 | } |
| 1887 | |
| 1888 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1889 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 1890 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1891 | "Batch scan is not yet enabled could not return results" |
| 1892 | "Batch Scan state %d", |
| 1893 | pAdapter->batchScanState); |
| 1894 | ret = -EINVAL; |
| 1895 | goto exit; |
| 1896 | } |
| 1897 | |
| 1898 | pPrivdata->used_len = 16; |
| 1899 | remain_len = pPrivdata->total_len - pPrivdata->used_len; |
| 1900 | if (remain_len < pPrivdata->total_len) |
| 1901 | { |
| 1902 | /*Clear previous batch scan response data if any*/ |
| 1903 | vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len); |
| 1904 | } |
| 1905 | else |
| 1906 | { |
| 1907 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1908 | "Invalid total length from user space can't fetch batch" |
| 1909 | " scan response total_len %d used_len %d remain len %d", |
| 1910 | pPrivdata->total_len, pPrivdata->used_len, remain_len); |
| 1911 | ret = -EINVAL; |
| 1912 | goto exit; |
| 1913 | } |
| 1914 | ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command); |
| 1915 | } |
| 1916 | |
| 1917 | exit: |
| 1918 | |
| 1919 | return ret; |
| 1920 | } |
| 1921 | |
| 1922 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1923 | #endif/*End of FEATURE_WLAN_BATCH_SCAN*/ |
| 1924 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1925 | static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data) |
| 1926 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1927 | bcnMissRateContext_t *pCBCtx; |
| 1928 | |
| 1929 | if (NULL == data) |
| 1930 | { |
| 1931 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 1932 | return; |
| 1933 | } |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1934 | |
| 1935 | /* there is a race condition that exists between this callback |
| 1936 | function and the caller since the caller could time out either |
| 1937 | before or while this code is executing. we use a spinlock to |
| 1938 | serialize these actions */ |
| 1939 | spin_lock(&hdd_context_lock); |
| 1940 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1941 | pCBCtx = (bcnMissRateContext_t *)data; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1942 | gbcnMissRate = -1; |
| 1943 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1944 | if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC) |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1945 | { |
| 1946 | hddLog(VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1947 | FL("invalid context magic: %08x"), pCBCtx->magic); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1948 | spin_unlock(&hdd_context_lock); |
| 1949 | return ; |
| 1950 | } |
| 1951 | |
| 1952 | if (VOS_STATUS_SUCCESS == status) |
| 1953 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1954 | gbcnMissRate = bcnMissRate; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1955 | } |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1956 | else |
| 1957 | { |
| 1958 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate")); |
| 1959 | } |
| 1960 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1961 | complete(&(pCBCtx->completion)); |
| 1962 | spin_unlock(&hdd_context_lock); |
| 1963 | |
| 1964 | return; |
| 1965 | } |
| 1966 | |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 1967 | void hdd_FWStatisCB( VOS_STATUS status, void *fwStats, void *data ) |
| 1968 | { |
| 1969 | fwStatsContext_t *fwStatsCtx; |
| 1970 | fwStatsResult_t *fwStatsResult; |
| 1971 | hdd_adapter_t *pAdapter; |
| 1972 | |
| 1973 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" with status = %d"),status); |
| 1974 | |
| 1975 | if (NULL == data) |
| 1976 | { |
| 1977 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 1978 | return; |
| 1979 | } |
| 1980 | /* there is a race condition that exists between this callback |
| 1981 | function and the caller since the caller could time out either |
| 1982 | before or while this code is executing. we use a spinlock to |
| 1983 | serialize these actions */ |
| 1984 | spin_lock(&hdd_context_lock); |
| 1985 | fwStatsCtx = (fwStatsContext_t *) data; |
| 1986 | if (fwStatsCtx->magic != FW_STATS_CONTEXT_MAGIC) |
| 1987 | { |
| 1988 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1989 | FL("invalid context magic: %08x"), fwStatsCtx->magic); |
| 1990 | spin_unlock(&hdd_context_lock); |
| 1991 | return; |
| 1992 | } |
| 1993 | pAdapter = fwStatsCtx->pAdapter; |
| 1994 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 1995 | { |
| 1996 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1997 | FL("pAdapter returned is NULL or invalid")); |
| 1998 | spin_unlock(&hdd_context_lock); |
| 1999 | return; |
| 2000 | } |
| 2001 | pAdapter->fwStatsRsp.type = 0; |
| 2002 | if ((VOS_STATUS_SUCCESS == status) && (NULL != fwStats)) |
| 2003 | { |
| 2004 | fwStatsResult = (fwStatsResult_t *)fwStats; |
| 2005 | switch( fwStatsResult->type ) |
| 2006 | { |
| 2007 | case FW_UBSP_STATS: |
| 2008 | { |
| 2009 | memcpy(&pAdapter->fwStatsRsp,fwStatsResult,sizeof(fwStatsResult_t)); |
| 2010 | |
| 2011 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2012 | FL("ubsp_enter_cnt = %d ubsp_jump_ddr_cnt = %d"), |
| 2013 | pAdapter->fwStatsRsp.hddFwStatsData.ubspStats.ubsp_enter_cnt, |
| 2014 | pAdapter->fwStatsRsp.hddFwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
| 2015 | } |
| 2016 | break; |
| 2017 | default: |
| 2018 | { |
| 2019 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2020 | FL(" No handling for stats type %d"),fwStatsResult->type); |
| 2021 | } |
| 2022 | } |
| 2023 | } |
| 2024 | complete(&(fwStatsCtx->completion)); |
| 2025 | spin_unlock(&hdd_context_lock); |
| 2026 | return; |
| 2027 | } |
| 2028 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2029 | static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len) |
| 2030 | { |
| 2031 | int ret = 0; |
| 2032 | |
| 2033 | if (!pCfg || !command || !extra || !len) |
| 2034 | { |
| 2035 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2036 | "%s: argument passsed for GETDWELLTIME is incorrect", __func__); |
| 2037 | ret = -EINVAL; |
| 2038 | return ret; |
| 2039 | } |
| 2040 | |
| 2041 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) |
| 2042 | { |
| 2043 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", |
| 2044 | (int)pCfg->nActiveMaxChnTime); |
| 2045 | return ret; |
| 2046 | } |
| 2047 | else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2048 | { |
| 2049 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n", |
| 2050 | (int)pCfg->nActiveMinChnTime); |
| 2051 | return ret; |
| 2052 | } |
| 2053 | else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2054 | { |
| 2055 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
| 2056 | (int)pCfg->nPassiveMaxChnTime); |
| 2057 | return ret; |
| 2058 | } |
| 2059 | else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2060 | { |
| 2061 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n", |
| 2062 | (int)pCfg->nPassiveMinChnTime); |
| 2063 | return ret; |
| 2064 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2065 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 2066 | { |
| 2067 | *len = scnprintf(extra, n, "GETDWELLTIME %u \n", |
| 2068 | (int)pCfg->nActiveMaxChnTime); |
| 2069 | return ret; |
| 2070 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2071 | else |
| 2072 | { |
| 2073 | ret = -EINVAL; |
| 2074 | } |
| 2075 | |
| 2076 | return ret; |
| 2077 | } |
| 2078 | |
| 2079 | static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 2080 | { |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2081 | tHalHandle hHal; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2082 | hdd_config_t *pCfg; |
| 2083 | tANI_U8 *value = command; |
| 2084 | int val = 0, ret = 0, temp = 0; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2085 | tSmeConfigParams smeConfig; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2086 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2087 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini) |
| 2088 | || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter)))) |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2089 | { |
| 2090 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2091 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2092 | ret = -EINVAL; |
| 2093 | return ret; |
| 2094 | } |
| 2095 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2096 | vos_mem_zero(&smeConfig, sizeof(smeConfig)); |
| 2097 | sme_GetConfigParam(hHal, &smeConfig); |
| 2098 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2099 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 ) |
| 2100 | { |
| 2101 | value = value + 24; |
| 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 ACTIVE MAX is incorrect", __func__); |
| 2108 | ret = -EFAULT; |
| 2109 | return ret; |
| 2110 | } |
| 2111 | pCfg->nActiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2112 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2113 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2114 | } |
| 2115 | else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2116 | { |
| 2117 | value = value + 24; |
| 2118 | temp = kstrtou32(value, 10, &val); |
| 2119 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN || |
| 2120 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX ) |
| 2121 | { |
| 2122 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2123 | "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__); |
| 2124 | ret = -EFAULT; |
| 2125 | return ret; |
| 2126 | } |
| 2127 | pCfg->nActiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2128 | smeConfig.csrConfig.nActiveMinChnTime = val; |
| 2129 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2130 | } |
| 2131 | else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2132 | { |
| 2133 | value = value + 25; |
| 2134 | temp = kstrtou32(value, 10, &val); |
| 2135 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN || |
| 2136 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX ) |
| 2137 | { |
| 2138 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2139 | "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__); |
| 2140 | ret = -EFAULT; |
| 2141 | return ret; |
| 2142 | } |
| 2143 | pCfg->nPassiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2144 | smeConfig.csrConfig.nPassiveMaxChnTime = val; |
| 2145 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2146 | } |
| 2147 | else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2148 | { |
| 2149 | value = value + 25; |
| 2150 | temp = kstrtou32(value, 10, &val); |
| 2151 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN || |
| 2152 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX ) |
| 2153 | { |
| 2154 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2155 | "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__); |
| 2156 | ret = -EFAULT; |
| 2157 | return ret; |
| 2158 | } |
| 2159 | pCfg->nPassiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2160 | smeConfig.csrConfig.nPassiveMinChnTime = val; |
| 2161 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2162 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2163 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 2164 | { |
| 2165 | value = value + 13; |
| 2166 | temp = kstrtou32(value, 10, &val); |
| 2167 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2168 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2169 | { |
| 2170 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2171 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2172 | ret = -EFAULT; |
| 2173 | return ret; |
| 2174 | } |
| 2175 | pCfg->nActiveMaxChnTime = val; |
| 2176 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2177 | sme_UpdateConfig(hHal, &smeConfig); |
| 2178 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2179 | else |
| 2180 | { |
| 2181 | ret = -EINVAL; |
| 2182 | } |
| 2183 | |
| 2184 | return ret; |
| 2185 | } |
| 2186 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2187 | static int hdd_driver_command(hdd_adapter_t *pAdapter, |
| 2188 | hdd_priv_data_t *ppriv_data) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2189 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2190 | hdd_priv_data_t priv_data; |
| 2191 | tANI_U8 *command = NULL; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2192 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2193 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2194 | int ret = 0; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2195 | int status; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2196 | /* |
| 2197 | * Note that valid pointers are provided by caller |
| 2198 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2199 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2200 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 2201 | priv_data = *ppriv_data; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2202 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2203 | if (priv_data.total_len <= 0 || |
| 2204 | priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN) |
Sameer Thalappil | 8ef3a0e | 2013-04-05 14:36:04 -0700 | [diff] [blame] | 2205 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2206 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 2207 | "%s:invalid priv_data.total_len(%d)!!!", __func__, |
| 2208 | priv_data.total_len); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2209 | ret = -EINVAL; |
| 2210 | goto exit; |
| 2211 | } |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2212 | status = wlan_hdd_validate_context(pHddCtx); |
| 2213 | if (0 != status) |
| 2214 | { |
| 2215 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2216 | "%s: HDD context is not valid", __func__); |
| 2217 | return status; |
| 2218 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2219 | /* Allocate +1 for '\0' */ |
| 2220 | command = kmalloc(priv_data.total_len + 1, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2221 | if (!command) |
| 2222 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2223 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2224 | "%s: failed to allocate memory", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2225 | ret = -ENOMEM; |
| 2226 | goto exit; |
| 2227 | } |
| 2228 | |
| 2229 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 2230 | { |
| 2231 | ret = -EFAULT; |
| 2232 | goto exit; |
| 2233 | } |
| 2234 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2235 | /* Make sure the command is NUL-terminated */ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2236 | command[priv_data.total_len] = '\0'; |
| 2237 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2238 | /* at one time the following block of code was conditional. braces |
| 2239 | * have been retained to avoid re-indenting the legacy code |
| 2240 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2241 | { |
| 2242 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 2243 | |
| 2244 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 2245 | "%s: Received %s cmd from Wi-Fi GUI***", __func__, command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2246 | |
| 2247 | if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 ) |
| 2248 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2249 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2250 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
| 2251 | pAdapter->sessionId, (unsigned) |
| 2252 | (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 | |
| 2253 | *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 | |
| 2254 | *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 | |
| 2255 | *(pHddCtx->p2pDeviceAddress.bytes+5)))); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2256 | if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes, |
| 2257 | sizeof(tSirMacAddr))) |
| 2258 | { |
| 2259 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2260 | "%s: failed to copy data to user buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2261 | ret = -EFAULT; |
| 2262 | } |
| 2263 | } |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2264 | else if(strncmp(command, "SETBAND", 7) == 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2265 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2266 | tANI_U8 *ptr = command ; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2267 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2268 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2269 | |
| 2270 | /* First 8 bytes will have "SETBAND " and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2271 | * 9 byte will have band setting value */ |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 2272 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2273 | "%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] | 2274 | /* Change band request received */ |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2275 | ret = hdd_setBand_helper(pAdapter->dev, ptr); |
Abhishek Singh | 2ec36ab | 2014-08-07 16:14:25 +0530 | [diff] [blame] | 2276 | if(ret < 0) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2277 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2278 | "%s: failed to set band ret=%d", __func__, ret); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2279 | } |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 2280 | else if(strncmp(command, "SETWMMPS", 8) == 0) |
| 2281 | { |
| 2282 | tANI_U8 *ptr = command; |
| 2283 | ret = hdd_wmmps_helper(pAdapter, ptr); |
| 2284 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2285 | else if ( strncasecmp(command, "COUNTRY", 7) == 0 ) |
| 2286 | { |
| 2287 | char *country_code; |
| 2288 | |
| 2289 | country_code = command + 8; |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2290 | |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2291 | INIT_COMPLETION(pAdapter->change_country_code); |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2292 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2293 | #ifndef CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 2294 | hdd_checkandupdate_phymode(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2295 | #endif |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2296 | ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 2297 | (void *)(tSmeChangeCountryCallback) |
| 2298 | wlan_hdd_change_country_code_callback, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 2299 | country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2300 | if (eHAL_STATUS_SUCCESS == ret) |
| 2301 | { |
| 2302 | ret = wait_for_completion_interruptible_timeout( |
| 2303 | &pAdapter->change_country_code, |
| 2304 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 2305 | if (0 >= ret) |
| 2306 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2307 | 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] | 2308 | __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2309 | } |
| 2310 | } |
| 2311 | else |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2312 | { |
| 2313 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2314 | "%s: SME Change Country code fail ret=%d", __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2315 | ret = -EINVAL; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2316 | } |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2317 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2318 | } |
| 2319 | /* |
| 2320 | command should be a string having format |
| 2321 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 2322 | */ |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2323 | else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2324 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2325 | tANI_U8 *ptr = command; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2326 | |
| 2327 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2328 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2329 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 2330 | ret = sapSetPreferredChannel(ptr); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2331 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2332 | else if(strncmp(command, "SETSUSPENDMODE", 14) == 0) |
| 2333 | { |
| 2334 | int suspend = 0; |
| 2335 | tANI_U8 *ptr = (tANI_U8*)command + 15; |
| 2336 | |
| 2337 | suspend = *ptr - '0'; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2338 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2339 | TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL, |
| 2340 | pAdapter->sessionId, suspend)); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2341 | hdd_set_wlan_suspend_mode(suspend); |
| 2342 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2343 | #ifdef WLAN_FEATURE_NEIGHBOR_ROAMING |
| 2344 | else if (strncmp(command, "SETROAMTRIGGER", 14) == 0) |
| 2345 | { |
| 2346 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2347 | tANI_S8 rssi = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2348 | tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
| 2349 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2350 | |
| 2351 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 2352 | value = value + 15; |
| 2353 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2354 | /* Convert the value from ascii to integer */ |
| 2355 | ret = kstrtos8(value, 10, &rssi); |
| 2356 | if (ret < 0) |
| 2357 | { |
| 2358 | /* If the input value is greater than max value of datatype, then also |
| 2359 | kstrtou8 fails */ |
| 2360 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2361 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | fa7157d | 2013-10-31 10:14:22 -0700 | [diff] [blame] | 2362 | __func__, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2363 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2364 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2365 | ret = -EINVAL; |
| 2366 | goto exit; |
| 2367 | } |
| 2368 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2369 | lookUpThreshold = abs(rssi); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2370 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2371 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) || |
| 2372 | (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) |
| 2373 | { |
| 2374 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2375 | "Neighbor lookup threshold value %d is out of range" |
| 2376 | " (Min: %d Max: %d)", lookUpThreshold, |
| 2377 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2378 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2379 | ret = -EINVAL; |
| 2380 | goto exit; |
| 2381 | } |
| 2382 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2383 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2384 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
| 2385 | pAdapter->sessionId, lookUpThreshold)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2386 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2387 | "%s: Received Command to Set Roam trigger" |
| 2388 | " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold); |
| 2389 | |
| 2390 | pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 2391 | status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold); |
| 2392 | if (eHAL_STATUS_SUCCESS != status) |
| 2393 | { |
| 2394 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2395 | "%s: Failed to set roam trigger, try again", __func__); |
| 2396 | ret = -EPERM; |
| 2397 | goto exit; |
| 2398 | } |
| 2399 | |
| 2400 | /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */ |
mukul sharma | d6e1fdd | 2014-06-23 19:19:09 +0530 | [diff] [blame] | 2401 | pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2402 | sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5); |
| 2403 | } |
| 2404 | else if (strncmp(command, "GETROAMTRIGGER", 14) == 0) |
| 2405 | { |
| 2406 | tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal)); |
| 2407 | int rssi = (-1) * lookUpThreshold; |
| 2408 | char extra[32]; |
| 2409 | tANI_U8 len = 0; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2410 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2411 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
| 2412 | pAdapter->sessionId, lookUpThreshold)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2413 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2414 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2415 | { |
| 2416 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2417 | "%s: failed to copy data to user buffer", __func__); |
| 2418 | ret = -EFAULT; |
| 2419 | goto exit; |
| 2420 | } |
| 2421 | } |
| 2422 | else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0) |
| 2423 | { |
| 2424 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2425 | tANI_U8 roamScanPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2426 | tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2427 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2428 | /* input refresh period is in terms of seconds */ |
| 2429 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 2430 | value = value + 18; |
| 2431 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2432 | ret = kstrtou8(value, 10, &roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2433 | if (ret < 0) |
| 2434 | { |
| 2435 | /* 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] | 2436 | kstrtou8 fails */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2437 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2438 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2439 | __func__, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2440 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2441 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2442 | ret = -EINVAL; |
| 2443 | goto exit; |
| 2444 | } |
| 2445 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2446 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) || |
| 2447 | (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000))) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2448 | { |
| 2449 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2450 | "Roam scan period value %d is out of range" |
| 2451 | " (Min: %d Max: %d)", roamScanPeriod, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2452 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2453 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2454 | ret = -EINVAL; |
| 2455 | goto exit; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2456 | } |
| 2457 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2458 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
| 2459 | pAdapter->sessionId, roamScanPeriod)); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2460 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2461 | |
| 2462 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2463 | "%s: Received Command to Set roam scan period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2464 | " (Empty Scan refresh period) = %d", __func__, roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2465 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2466 | pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod; |
| 2467 | sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2468 | } |
| 2469 | else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0) |
| 2470 | { |
| 2471 | tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2472 | char extra[32]; |
| 2473 | tANI_U8 len = 0; |
| 2474 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2475 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2476 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
| 2477 | pAdapter->sessionId, nEmptyScanRefreshPeriod)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2478 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2479 | "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2480 | /* Returned value is in units of seconds */ |
| 2481 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2482 | { |
| 2483 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2484 | "%s: failed to copy data to user buffer", __func__); |
| 2485 | ret = -EFAULT; |
| 2486 | goto exit; |
| 2487 | } |
| 2488 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2489 | else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2490 | { |
| 2491 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2492 | tANI_U8 roamScanRefreshPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2493 | tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2494 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2495 | /* input refresh period is in terms of seconds */ |
| 2496 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 2497 | value = value + 25; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2498 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2499 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2500 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2501 | if (ret < 0) |
| 2502 | { |
| 2503 | /* 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] | 2504 | kstrtou8 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2505 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2506 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2507 | __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2508 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2509 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2510 | ret = -EINVAL; |
| 2511 | goto exit; |
| 2512 | } |
| 2513 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2514 | if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) || |
| 2515 | (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000))) |
| 2516 | { |
| 2517 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2518 | "Neighbor scan results refresh period value %d is out of range" |
| 2519 | " (Min: %d Max: %d)", roamScanRefreshPeriod, |
| 2520 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2521 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2522 | ret = -EINVAL; |
| 2523 | goto exit; |
| 2524 | } |
| 2525 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 2526 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2527 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2528 | "%s: Received Command to Set roam scan refresh period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2529 | " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2530 | |
| 2531 | pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod; |
| 2532 | sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod); |
| 2533 | } |
| 2534 | else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2535 | { |
| 2536 | tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2537 | char extra[32]; |
| 2538 | tANI_U8 len = 0; |
| 2539 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2540 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2541 | "GETROAMSCANREFRESHPERIOD", (value/1000)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2542 | /* Returned value is in units of seconds */ |
| 2543 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2544 | { |
| 2545 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2546 | "%s: failed to copy data to user buffer", __func__); |
| 2547 | ret = -EFAULT; |
| 2548 | goto exit; |
| 2549 | } |
| 2550 | } |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2551 | #ifdef FEATURE_WLAN_LFR |
| 2552 | /* SETROAMMODE */ |
| 2553 | else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0) |
| 2554 | { |
| 2555 | tANI_U8 *value = command; |
| 2556 | tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 2557 | |
| 2558 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 2559 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 2560 | |
| 2561 | /* Convert the value from ascii to integer */ |
| 2562 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 2563 | if (ret < 0) |
| 2564 | { |
| 2565 | /* If the input value is greater than max value of datatype, then also |
| 2566 | kstrtou8 fails */ |
| 2567 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2568 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2569 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2570 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2571 | ret = -EINVAL; |
| 2572 | goto exit; |
| 2573 | } |
| 2574 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 2575 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 2576 | { |
| 2577 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2578 | "Roam Mode value %d is out of range" |
| 2579 | " (Min: %d Max: %d)", roamMode, |
| 2580 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2581 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2582 | ret = -EINVAL; |
| 2583 | goto exit; |
| 2584 | } |
| 2585 | |
| 2586 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2587 | "%s: Received Command to Set Roam Mode = %d", __func__, roamMode); |
| 2588 | /* |
| 2589 | * Note that |
| 2590 | * SETROAMMODE 0 is to enable LFR while |
| 2591 | * SETROAMMODE 1 is to disable LFR, but |
| 2592 | * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable. |
| 2593 | * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled. |
| 2594 | */ |
| 2595 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2596 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 2597 | else |
| 2598 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 2599 | |
| 2600 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode; |
| 2601 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode); |
| 2602 | } |
| 2603 | /* GETROAMMODE */ |
| 2604 | else if (strncmp(priv_data.buf, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0) |
| 2605 | { |
| 2606 | tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2607 | char extra[32]; |
| 2608 | tANI_U8 len = 0; |
| 2609 | |
| 2610 | /* |
| 2611 | * roamMode value shall be inverted because the sementics is different. |
| 2612 | */ |
| 2613 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2614 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 2615 | else |
| 2616 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 2617 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2618 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2619 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2620 | { |
| 2621 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2622 | "%s: failed to copy data to user buffer", __func__); |
| 2623 | ret = -EFAULT; |
| 2624 | goto exit; |
| 2625 | } |
| 2626 | } |
| 2627 | #endif |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2628 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2629 | #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] | 2630 | else if (strncmp(command, "SETROAMDELTA", 12) == 0) |
| 2631 | { |
| 2632 | tANI_U8 *value = command; |
| 2633 | tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 2634 | |
| 2635 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 2636 | value = value + 13; |
| 2637 | /* Convert the value from ascii to integer */ |
| 2638 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 2639 | if (ret < 0) |
| 2640 | { |
| 2641 | /* If the input value is greater than max value of datatype, then also |
| 2642 | kstrtou8 fails */ |
| 2643 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2644 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2645 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2646 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2647 | ret = -EINVAL; |
| 2648 | goto exit; |
| 2649 | } |
| 2650 | |
| 2651 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 2652 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) |
| 2653 | { |
| 2654 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2655 | "Roam rssi diff value %d is out of range" |
| 2656 | " (Min: %d Max: %d)", roamRssiDiff, |
| 2657 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2658 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2659 | ret = -EINVAL; |
| 2660 | goto exit; |
| 2661 | } |
| 2662 | |
| 2663 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2664 | "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff); |
| 2665 | |
| 2666 | pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff; |
| 2667 | sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff); |
| 2668 | } |
| 2669 | else if (strncmp(priv_data.buf, "GETROAMDELTA", 12) == 0) |
| 2670 | { |
| 2671 | tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal)); |
| 2672 | char extra[32]; |
| 2673 | tANI_U8 len = 0; |
| 2674 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2675 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2676 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
| 2677 | pAdapter->sessionId, roamRssiDiff)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2678 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2679 | command, roamRssiDiff); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2680 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2681 | { |
| 2682 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2683 | "%s: failed to copy data to user buffer", __func__); |
| 2684 | ret = -EFAULT; |
| 2685 | goto exit; |
| 2686 | } |
| 2687 | } |
| 2688 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2689 | #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] | 2690 | else if (strncmp(command, "GETBAND", 7) == 0) |
| 2691 | { |
| 2692 | int band = -1; |
| 2693 | char extra[32]; |
| 2694 | tANI_U8 len = 0; |
| 2695 | hdd_getBand_helper(pHddCtx, &band); |
| 2696 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2697 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2698 | TRACE_CODE_HDD_GETBAND_IOCTL, |
| 2699 | pAdapter->sessionId, band)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2700 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2701 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2702 | { |
| 2703 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2704 | "%s: failed to copy data to user buffer", __func__); |
| 2705 | ret = -EFAULT; |
| 2706 | goto exit; |
| 2707 | } |
| 2708 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2709 | else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0) |
| 2710 | { |
| 2711 | tANI_U8 *value = command; |
| 2712 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2713 | tANI_U8 numChannels = 0; |
| 2714 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2715 | |
| 2716 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 2717 | if (eHAL_STATUS_SUCCESS != status) |
| 2718 | { |
| 2719 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2720 | "%s: Failed to parse channel list information", __func__); |
| 2721 | ret = -EINVAL; |
| 2722 | goto exit; |
| 2723 | } |
| 2724 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2725 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2726 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 2727 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2728 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 2729 | { |
| 2730 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2731 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 2732 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 2733 | ret = -EINVAL; |
| 2734 | goto exit; |
| 2735 | } |
| 2736 | status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList, |
| 2737 | numChannels); |
| 2738 | if (eHAL_STATUS_SUCCESS != status) |
| 2739 | { |
| 2740 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2741 | "%s: Failed to update channel list information", __func__); |
| 2742 | ret = -EINVAL; |
| 2743 | goto exit; |
| 2744 | } |
| 2745 | } |
| 2746 | else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0) |
| 2747 | { |
| 2748 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2749 | tANI_U8 numChannels = 0; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2750 | tANI_U8 j = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2751 | char extra[128] = {0}; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2752 | int len; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2753 | |
| 2754 | if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal), |
| 2755 | ChannelList, &numChannels )) |
| 2756 | { |
| 2757 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2758 | "%s: failed to get roam scan channel list", __func__); |
| 2759 | ret = -EFAULT; |
| 2760 | goto exit; |
| 2761 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2762 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2763 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
| 2764 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2765 | /* output channel list is of the format |
| 2766 | [Number of roam scan channels][Channel1][Channel2]... */ |
| 2767 | /* copy the number of channels in the 0th index */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2768 | len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2769 | for (j = 0; (j < numChannels); j++) |
| 2770 | { |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2771 | len += scnprintf(extra + len, sizeof(extra) - len, " %d", |
| 2772 | ChannelList[j]); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2773 | } |
| 2774 | |
| 2775 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2776 | { |
| 2777 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2778 | "%s: failed to copy data to user buffer", __func__); |
| 2779 | ret = -EFAULT; |
| 2780 | goto exit; |
| 2781 | } |
| 2782 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2783 | else if (strncmp(command, "GETCCXMODE", 10) == 0) |
| 2784 | { |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2785 | tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2786 | char extra[32]; |
| 2787 | tANI_U8 len = 0; |
| 2788 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2789 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2790 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2791 | if (eseMode && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2792 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 2793 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2794 | { |
| 2795 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2796 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2797 | " hence this operation is not permitted!", __func__); |
| 2798 | ret = -EPERM; |
| 2799 | goto exit; |
| 2800 | } |
| 2801 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2802 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2803 | "GETCCXMODE", eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2804 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2805 | { |
| 2806 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2807 | "%s: failed to copy data to user buffer", __func__); |
| 2808 | ret = -EFAULT; |
| 2809 | goto exit; |
| 2810 | } |
| 2811 | } |
| 2812 | else if (strncmp(command, "GETOKCMODE", 10) == 0) |
| 2813 | { |
| 2814 | tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx); |
| 2815 | char extra[32]; |
| 2816 | tANI_U8 len = 0; |
| 2817 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2818 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2819 | then this operation is not permitted (return FAILURE) */ |
| 2820 | if (okcMode && |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2821 | sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2822 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2823 | { |
| 2824 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2825 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2826 | " hence this operation is not permitted!", __func__); |
| 2827 | ret = -EPERM; |
| 2828 | goto exit; |
| 2829 | } |
| 2830 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2831 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2832 | "GETOKCMODE", okcMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2833 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2834 | { |
| 2835 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2836 | "%s: failed to copy data to user buffer", __func__); |
| 2837 | ret = -EFAULT; |
| 2838 | goto exit; |
| 2839 | } |
| 2840 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2841 | else if (strncmp(command, "GETFASTROAM", 11) == 0) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2842 | { |
| 2843 | tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2844 | char extra[32]; |
| 2845 | tANI_U8 len = 0; |
| 2846 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2847 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2848 | "GETFASTROAM", lfrMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2849 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2850 | { |
| 2851 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2852 | "%s: failed to copy data to user buffer", __func__); |
| 2853 | ret = -EFAULT; |
| 2854 | goto exit; |
| 2855 | } |
| 2856 | } |
| 2857 | else if (strncmp(command, "GETFASTTRANSITION", 17) == 0) |
| 2858 | { |
| 2859 | tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2860 | char extra[32]; |
| 2861 | tANI_U8 len = 0; |
| 2862 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2863 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2864 | "GETFASTTRANSITION", ft); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2865 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2866 | { |
| 2867 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2868 | "%s: failed to copy data to user buffer", __func__); |
| 2869 | ret = -EFAULT; |
| 2870 | goto exit; |
| 2871 | } |
| 2872 | } |
| 2873 | else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2874 | { |
| 2875 | tANI_U8 *value = command; |
| 2876 | tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 2877 | |
| 2878 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 2879 | value = value + 26; |
| 2880 | /* Convert the value from ascii to integer */ |
| 2881 | ret = kstrtou8(value, 10, &minTime); |
| 2882 | if (ret < 0) |
| 2883 | { |
| 2884 | /* If the input value is greater than max value of datatype, then also |
| 2885 | kstrtou8 fails */ |
| 2886 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2887 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2888 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2889 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2890 | ret = -EINVAL; |
| 2891 | goto exit; |
| 2892 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2893 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 2894 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) |
| 2895 | { |
| 2896 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2897 | "scan min channel time value %d is out of range" |
| 2898 | " (Min: %d Max: %d)", minTime, |
| 2899 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2900 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2901 | ret = -EINVAL; |
| 2902 | goto exit; |
| 2903 | } |
| 2904 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2905 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2906 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
| 2907 | pAdapter->sessionId, minTime)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2908 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2909 | "%s: Received Command to change channel min time = %d", __func__, minTime); |
| 2910 | |
| 2911 | pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime; |
| 2912 | sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime); |
| 2913 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2914 | else if (strncmp(command, "SENDACTIONFRAME", 15) == 0) |
| 2915 | { |
| 2916 | tANI_U8 *value = command; |
| 2917 | tANI_U8 channel = 0; |
| 2918 | tANI_U8 dwellTime = 0; |
| 2919 | tANI_U8 bufLen = 0; |
| 2920 | tANI_U8 *buf = NULL; |
| 2921 | tSirMacAddr targetApBssid; |
| 2922 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2923 | struct ieee80211_channel chan; |
| 2924 | tANI_U8 finalLen = 0; |
| 2925 | tANI_U8 *finalBuf = NULL; |
| 2926 | tANI_U8 temp = 0; |
| 2927 | u64 cookie; |
| 2928 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 2929 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2930 | |
| 2931 | /* if not associated, no need to send action frame */ |
| 2932 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 2933 | { |
| 2934 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 2935 | ret = -EINVAL; |
| 2936 | goto exit; |
| 2937 | } |
| 2938 | |
| 2939 | status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel, |
| 2940 | &dwellTime, &buf, &bufLen); |
| 2941 | if (eHAL_STATUS_SUCCESS != status) |
| 2942 | { |
| 2943 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2944 | "%s: Failed to parse send action frame data", __func__); |
| 2945 | ret = -EINVAL; |
| 2946 | goto exit; |
| 2947 | } |
| 2948 | |
| 2949 | /* if the target bssid is different from currently associated AP, |
| 2950 | then no need to send action frame */ |
| 2951 | if (VOS_TRUE != vos_mem_compare(targetApBssid, |
| 2952 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 2953 | { |
| 2954 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__); |
| 2955 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2956 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2957 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2958 | goto exit; |
| 2959 | } |
| 2960 | |
| 2961 | /* if the channel number is different from operating channel then |
| 2962 | no need to send action frame */ |
| 2963 | if (channel != pHddStaCtx->conn_info.operationChannel) |
| 2964 | { |
| 2965 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2966 | "%s: channel(%d) is different from operating channel(%d)", |
| 2967 | __func__, channel, pHddStaCtx->conn_info.operationChannel); |
| 2968 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2969 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2970 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2971 | goto exit; |
| 2972 | } |
| 2973 | chan.center_freq = sme_ChnToFreq(channel); |
| 2974 | |
| 2975 | finalLen = bufLen + 24; |
| 2976 | finalBuf = vos_mem_malloc(finalLen); |
| 2977 | if (NULL == finalBuf) |
| 2978 | { |
| 2979 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__); |
| 2980 | ret = -ENOMEM; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2981 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2982 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2983 | goto exit; |
| 2984 | } |
| 2985 | vos_mem_zero(finalBuf, finalLen); |
| 2986 | |
| 2987 | /* Fill subtype */ |
| 2988 | temp = SIR_MAC_MGMT_ACTION << 4; |
| 2989 | vos_mem_copy(finalBuf + 0, &temp, sizeof(temp)); |
| 2990 | |
| 2991 | /* Fill type */ |
| 2992 | temp = SIR_MAC_MGMT_FRAME; |
| 2993 | vos_mem_copy(finalBuf + 2, &temp, sizeof(temp)); |
| 2994 | |
| 2995 | /* Fill destination address (bssid of the AP) */ |
| 2996 | vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid)); |
| 2997 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 2998 | /* Fill source address (STA mac address) */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2999 | vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes)); |
| 3000 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 3001 | /* Fill BSSID (AP mac address) */ |
| 3002 | vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid)); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3003 | |
| 3004 | /* Fill received buffer from 24th address */ |
| 3005 | vos_mem_copy(finalBuf + 24, buf, bufLen); |
| 3006 | |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3007 | /* done with the parsed buffer */ |
| 3008 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3009 | buf = NULL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3010 | |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 3011 | wlan_hdd_mgmt_tx( NULL, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 3012 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 3013 | &(pAdapter->wdev), |
| 3014 | #else |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3015 | pAdapter->dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 3016 | #endif |
| 3017 | &chan, 0, |
| 3018 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 3019 | NL80211_CHAN_HT20, 1, |
| 3020 | #endif |
| 3021 | dwellTime, finalBuf, finalLen, 1, |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3022 | 1, &cookie ); |
| 3023 | vos_mem_free(finalBuf); |
| 3024 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3025 | else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0) |
| 3026 | { |
| 3027 | tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal)); |
| 3028 | char extra[32]; |
| 3029 | tANI_U8 len = 0; |
| 3030 | |
| 3031 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3032 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3033 | "GETROAMSCANCHANNELMINTIME", val); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3034 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3035 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
| 3036 | pAdapter->sessionId, val)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3037 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3038 | { |
| 3039 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3040 | "%s: failed to copy data to user buffer", __func__); |
| 3041 | ret = -EFAULT; |
| 3042 | goto exit; |
| 3043 | } |
| 3044 | } |
| 3045 | else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0) |
| 3046 | { |
| 3047 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3048 | tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3049 | |
| 3050 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 3051 | value = value + 19; |
| 3052 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3053 | ret = kstrtou16(value, 10, &maxTime); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3054 | if (ret < 0) |
| 3055 | { |
| 3056 | /* 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] | 3057 | kstrtou16 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3058 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3059 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3060 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3061 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 3062 | ret = -EINVAL; |
| 3063 | goto exit; |
| 3064 | } |
| 3065 | |
| 3066 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 3067 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) |
| 3068 | { |
| 3069 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3070 | "lfr mode value %d is out of range" |
| 3071 | " (Min: %d Max: %d)", maxTime, |
| 3072 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3073 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 3074 | ret = -EINVAL; |
| 3075 | goto exit; |
| 3076 | } |
| 3077 | |
| 3078 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3079 | "%s: Received Command to change channel max time = %d", __func__, maxTime); |
| 3080 | |
| 3081 | pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime; |
| 3082 | sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime); |
| 3083 | } |
| 3084 | else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0) |
| 3085 | { |
| 3086 | tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal)); |
| 3087 | char extra[32]; |
| 3088 | tANI_U8 len = 0; |
| 3089 | |
| 3090 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3091 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3092 | "GETSCANCHANNELTIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3093 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3094 | { |
| 3095 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3096 | "%s: failed to copy data to user buffer", __func__); |
| 3097 | ret = -EFAULT; |
| 3098 | goto exit; |
| 3099 | } |
| 3100 | } |
| 3101 | else if (strncmp(command, "SETSCANHOMETIME", 15) == 0) |
| 3102 | { |
| 3103 | tANI_U8 *value = command; |
| 3104 | tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 3105 | |
| 3106 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 3107 | value = value + 16; |
| 3108 | /* Convert the value from ascii to integer */ |
| 3109 | ret = kstrtou16(value, 10, &val); |
| 3110 | if (ret < 0) |
| 3111 | { |
| 3112 | /* If the input value is greater than max value of datatype, then also |
| 3113 | kstrtou16 fails */ |
| 3114 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3115 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
| 3116 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3117 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3118 | ret = -EINVAL; |
| 3119 | goto exit; |
| 3120 | } |
| 3121 | |
| 3122 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 3123 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) |
| 3124 | { |
| 3125 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3126 | "scan home time value %d is out of range" |
| 3127 | " (Min: %d Max: %d)", val, |
| 3128 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3129 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3130 | ret = -EINVAL; |
| 3131 | goto exit; |
| 3132 | } |
| 3133 | |
| 3134 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3135 | "%s: Received Command to change scan home time = %d", __func__, val); |
| 3136 | |
| 3137 | pHddCtx->cfg_ini->nNeighborScanPeriod = val; |
| 3138 | sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val); |
| 3139 | } |
| 3140 | else if (strncmp(command, "GETSCANHOMETIME", 15) == 0) |
| 3141 | { |
| 3142 | tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3143 | char extra[32]; |
| 3144 | tANI_U8 len = 0; |
| 3145 | |
| 3146 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3147 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3148 | "GETSCANHOMETIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3149 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3150 | { |
| 3151 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3152 | "%s: failed to copy data to user buffer", __func__); |
| 3153 | ret = -EFAULT; |
| 3154 | goto exit; |
| 3155 | } |
| 3156 | } |
| 3157 | else if (strncmp(command, "SETROAMINTRABAND", 16) == 0) |
| 3158 | { |
| 3159 | tANI_U8 *value = command; |
| 3160 | tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 3161 | |
| 3162 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 3163 | value = value + 17; |
| 3164 | /* Convert the value from ascii to integer */ |
| 3165 | ret = kstrtou8(value, 10, &val); |
| 3166 | if (ret < 0) |
| 3167 | { |
| 3168 | /* If the input value is greater than max value of datatype, then also |
| 3169 | kstrtou8 fails */ |
| 3170 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3171 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3172 | CFG_ROAM_INTRA_BAND_MIN, |
| 3173 | CFG_ROAM_INTRA_BAND_MAX); |
| 3174 | ret = -EINVAL; |
| 3175 | goto exit; |
| 3176 | } |
| 3177 | |
| 3178 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 3179 | (val > CFG_ROAM_INTRA_BAND_MAX)) |
| 3180 | { |
| 3181 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3182 | "intra band mode value %d is out of range" |
| 3183 | " (Min: %d Max: %d)", val, |
| 3184 | CFG_ROAM_INTRA_BAND_MIN, |
| 3185 | CFG_ROAM_INTRA_BAND_MAX); |
| 3186 | ret = -EINVAL; |
| 3187 | goto exit; |
| 3188 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3189 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3190 | "%s: Received Command to change intra band = %d", __func__, val); |
| 3191 | |
| 3192 | pHddCtx->cfg_ini->nRoamIntraBand = val; |
| 3193 | sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val); |
| 3194 | } |
| 3195 | else if (strncmp(command, "GETROAMINTRABAND", 16) == 0) |
| 3196 | { |
| 3197 | tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal)); |
| 3198 | char extra[32]; |
| 3199 | tANI_U8 len = 0; |
| 3200 | |
| 3201 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3202 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3203 | "GETROAMINTRABAND", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3204 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3205 | { |
| 3206 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3207 | "%s: failed to copy data to user buffer", __func__); |
| 3208 | ret = -EFAULT; |
| 3209 | goto exit; |
| 3210 | } |
| 3211 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3212 | else if (strncmp(command, "SETSCANNPROBES", 14) == 0) |
| 3213 | { |
| 3214 | tANI_U8 *value = command; |
| 3215 | tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 3216 | |
| 3217 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 3218 | value = value + 15; |
| 3219 | /* Convert the value from ascii to integer */ |
| 3220 | ret = kstrtou8(value, 10, &nProbes); |
| 3221 | if (ret < 0) |
| 3222 | { |
| 3223 | /* If the input value is greater than max value of datatype, then also |
| 3224 | kstrtou8 fails */ |
| 3225 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3226 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3227 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3228 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3229 | ret = -EINVAL; |
| 3230 | goto exit; |
| 3231 | } |
| 3232 | |
| 3233 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 3234 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) |
| 3235 | { |
| 3236 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3237 | "NProbes value %d is out of range" |
| 3238 | " (Min: %d Max: %d)", nProbes, |
| 3239 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3240 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3241 | ret = -EINVAL; |
| 3242 | goto exit; |
| 3243 | } |
| 3244 | |
| 3245 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3246 | "%s: Received Command to Set nProbes = %d", __func__, nProbes); |
| 3247 | |
| 3248 | pHddCtx->cfg_ini->nProbes = nProbes; |
| 3249 | sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes); |
| 3250 | } |
| 3251 | else if (strncmp(priv_data.buf, "GETSCANNPROBES", 14) == 0) |
| 3252 | { |
| 3253 | tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal)); |
| 3254 | char extra[32]; |
| 3255 | tANI_U8 len = 0; |
| 3256 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3257 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3258 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3259 | { |
| 3260 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3261 | "%s: failed to copy data to user buffer", __func__); |
| 3262 | ret = -EFAULT; |
| 3263 | goto exit; |
| 3264 | } |
| 3265 | } |
| 3266 | else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0) |
| 3267 | { |
| 3268 | tANI_U8 *value = command; |
| 3269 | tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 3270 | |
| 3271 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 3272 | /* input value is in units of msec */ |
| 3273 | value = value + 20; |
| 3274 | /* Convert the value from ascii to integer */ |
| 3275 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 3276 | if (ret < 0) |
| 3277 | { |
| 3278 | /* If the input value is greater than max value of datatype, then also |
| 3279 | kstrtou8 fails */ |
| 3280 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3281 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3282 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3283 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3284 | ret = -EINVAL; |
| 3285 | goto exit; |
| 3286 | } |
| 3287 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3288 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 3289 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) |
| 3290 | { |
| 3291 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3292 | "homeAwayTime value %d is out of range" |
| 3293 | " (Min: %d Max: %d)", homeAwayTime, |
| 3294 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3295 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3296 | ret = -EINVAL; |
| 3297 | goto exit; |
| 3298 | } |
| 3299 | |
| 3300 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3301 | "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime); |
Srinivas Girigowda | 6cf0b82 | 2013-06-27 14:00:20 -0700 | [diff] [blame] | 3302 | if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime) |
| 3303 | { |
| 3304 | pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime; |
| 3305 | sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE); |
| 3306 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3307 | } |
| 3308 | else if (strncmp(priv_data.buf, "GETSCANHOMEAWAYTIME", 19) == 0) |
| 3309 | { |
| 3310 | tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal)); |
| 3311 | char extra[32]; |
| 3312 | tANI_U8 len = 0; |
| 3313 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3314 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3315 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3316 | { |
| 3317 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3318 | "%s: failed to copy data to user buffer", __func__); |
| 3319 | ret = -EFAULT; |
| 3320 | goto exit; |
| 3321 | } |
| 3322 | } |
| 3323 | else if (strncmp(command, "REASSOC", 7) == 0) |
| 3324 | { |
| 3325 | tANI_U8 *value = command; |
| 3326 | tANI_U8 channel = 0; |
| 3327 | tSirMacAddr targetApBssid; |
| 3328 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3329 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3330 | tCsrHandoffRequest handoffInfo; |
| 3331 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3332 | hdd_station_ctx_t *pHddStaCtx = NULL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3333 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3334 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3335 | /* if not associated, no need to proceed with reassoc */ |
| 3336 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3337 | { |
| 3338 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3339 | ret = -EINVAL; |
| 3340 | goto exit; |
| 3341 | } |
| 3342 | |
| 3343 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
| 3344 | if (eHAL_STATUS_SUCCESS != status) |
| 3345 | { |
| 3346 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3347 | "%s: Failed to parse reassoc command data", __func__); |
| 3348 | ret = -EINVAL; |
| 3349 | goto exit; |
| 3350 | } |
| 3351 | |
| 3352 | /* if the target bssid is same as currently associated AP, |
| 3353 | then no need to proceed with reassoc */ |
| 3354 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3355 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3356 | { |
| 3357 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__); |
| 3358 | ret = -EINVAL; |
| 3359 | goto exit; |
| 3360 | } |
| 3361 | |
| 3362 | /* Check channel number is a valid channel number */ |
| 3363 | if(VOS_STATUS_SUCCESS != |
| 3364 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3365 | { |
| 3366 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3367 | "%s: Invalid Channel [%d]", __func__, channel); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3368 | return -EINVAL; |
| 3369 | } |
| 3370 | |
| 3371 | /* Proceed with reassoc */ |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3372 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3373 | handoffInfo.channel = channel; |
| 3374 | vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr)); |
| 3375 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 3376 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3377 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3378 | else if (strncmp(command, "SETWESMODE", 10) == 0) |
| 3379 | { |
| 3380 | tANI_U8 *value = command; |
| 3381 | tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 3382 | |
| 3383 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 3384 | value = value + 11; |
| 3385 | /* Convert the value from ascii to integer */ |
| 3386 | ret = kstrtou8(value, 10, &wesMode); |
| 3387 | if (ret < 0) |
| 3388 | { |
| 3389 | /* If the input value is greater than max value of datatype, then also |
| 3390 | kstrtou8 fails */ |
| 3391 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3392 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3393 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3394 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3395 | ret = -EINVAL; |
| 3396 | goto exit; |
| 3397 | } |
| 3398 | |
| 3399 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 3400 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) |
| 3401 | { |
| 3402 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3403 | "WES Mode value %d is out of range" |
| 3404 | " (Min: %d Max: %d)", wesMode, |
| 3405 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3406 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3407 | ret = -EINVAL; |
| 3408 | goto exit; |
| 3409 | } |
| 3410 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3411 | "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode); |
| 3412 | |
| 3413 | pHddCtx->cfg_ini->isWESModeEnabled = wesMode; |
| 3414 | sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode); |
| 3415 | } |
| 3416 | else if (strncmp(priv_data.buf, "GETWESMODE", 10) == 0) |
| 3417 | { |
| 3418 | tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal)); |
| 3419 | char extra[32]; |
| 3420 | tANI_U8 len = 0; |
| 3421 | |
Arif Hussain | 826d941 | 2013-11-12 16:44:54 -0800 | [diff] [blame] | 3422 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3423 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3424 | { |
| 3425 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3426 | "%s: failed to copy data to user buffer", __func__); |
| 3427 | ret = -EFAULT; |
| 3428 | goto exit; |
| 3429 | } |
| 3430 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3431 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3432 | #ifdef FEATURE_WLAN_LFR |
| 3433 | else if (strncmp(command, "SETFASTROAM", 11) == 0) |
| 3434 | { |
| 3435 | tANI_U8 *value = command; |
| 3436 | tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 3437 | |
| 3438 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3439 | value = value + 12; |
| 3440 | /* Convert the value from ascii to integer */ |
| 3441 | ret = kstrtou8(value, 10, &lfrMode); |
| 3442 | if (ret < 0) |
| 3443 | { |
| 3444 | /* If the input value is greater than max value of datatype, then also |
| 3445 | kstrtou8 fails */ |
| 3446 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3447 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3448 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3449 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3450 | ret = -EINVAL; |
| 3451 | goto exit; |
| 3452 | } |
| 3453 | |
| 3454 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 3455 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 3456 | { |
| 3457 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3458 | "lfr mode value %d is out of range" |
| 3459 | " (Min: %d Max: %d)", lfrMode, |
| 3460 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3461 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3462 | ret = -EINVAL; |
| 3463 | goto exit; |
| 3464 | } |
| 3465 | |
| 3466 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3467 | "%s: Received Command to change lfr mode = %d", __func__, lfrMode); |
| 3468 | |
| 3469 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode; |
| 3470 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode); |
| 3471 | } |
| 3472 | #endif |
| 3473 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 3474 | else if (strncmp(command, "SETFASTTRANSITION", 17) == 0) |
| 3475 | { |
| 3476 | tANI_U8 *value = command; |
| 3477 | tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 3478 | |
| 3479 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3480 | value = value + 18; |
| 3481 | /* Convert the value from ascii to integer */ |
| 3482 | ret = kstrtou8(value, 10, &ft); |
| 3483 | if (ret < 0) |
| 3484 | { |
| 3485 | /* If the input value is greater than max value of datatype, then also |
| 3486 | kstrtou8 fails */ |
| 3487 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3488 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3489 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3490 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3491 | ret = -EINVAL; |
| 3492 | goto exit; |
| 3493 | } |
| 3494 | |
| 3495 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 3496 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) |
| 3497 | { |
| 3498 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3499 | "ft mode value %d is out of range" |
| 3500 | " (Min: %d Max: %d)", ft, |
| 3501 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3502 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3503 | ret = -EINVAL; |
| 3504 | goto exit; |
| 3505 | } |
| 3506 | |
| 3507 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3508 | "%s: Received Command to change ft mode = %d", __func__, ft); |
| 3509 | |
| 3510 | pHddCtx->cfg_ini->isFastTransitionEnabled = ft; |
| 3511 | sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft); |
| 3512 | } |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3513 | |
| 3514 | else if (strncmp(command, "FASTREASSOC", 11) == 0) |
| 3515 | { |
| 3516 | tANI_U8 *value = command; |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3517 | tANI_U8 channel = 0; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3518 | tSirMacAddr targetApBssid; |
| 3519 | tANI_U8 trigger = 0; |
| 3520 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3521 | tHalHandle hHal; |
| 3522 | v_U32_t roamId = 0; |
| 3523 | tCsrRoamModifyProfileFields modProfileFields; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3524 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3525 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3526 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3527 | |
| 3528 | /* if not associated, no need to proceed with reassoc */ |
| 3529 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3530 | { |
| 3531 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3532 | ret = -EINVAL; |
| 3533 | goto exit; |
| 3534 | } |
| 3535 | |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3536 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3537 | if (eHAL_STATUS_SUCCESS != status) |
| 3538 | { |
| 3539 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3540 | "%s: Failed to parse reassoc command data", __func__); |
| 3541 | ret = -EINVAL; |
| 3542 | goto exit; |
| 3543 | } |
| 3544 | |
| 3545 | /* if the target bssid is same as currently associated AP, |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3546 | issue reassoc to same AP */ |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3547 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3548 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3549 | { |
| 3550 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3551 | "%s:11r Reassoc BSSID is same as currently associated AP bssid", |
| 3552 | __func__); |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3553 | sme_GetModifyProfileFields(hHal, pAdapter->sessionId, |
| 3554 | &modProfileFields); |
| 3555 | sme_RoamReassoc(hHal, pAdapter->sessionId, |
| 3556 | NULL, modProfileFields, &roamId, 1); |
| 3557 | return 0; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3558 | } |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 3559 | |
| 3560 | /* Check channel number is a valid channel number */ |
| 3561 | if(VOS_STATUS_SUCCESS != |
| 3562 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3563 | { |
| 3564 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3565 | "%s: Invalid Channel [%d]", __func__, channel); |
| 3566 | return -EINVAL; |
| 3567 | } |
| 3568 | |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3569 | trigger = eSME_ROAM_TRIGGER_SCAN; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3570 | |
| 3571 | /* Proceed with scan/roam */ |
| 3572 | smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3573 | &targetApBssid[0], |
| 3574 | (tSmeFastRoamTrigger)(trigger)); |
| 3575 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3576 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3577 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3578 | else if (strncmp(command, "SETCCXMODE", 10) == 0) |
| 3579 | { |
| 3580 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3581 | tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3582 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3583 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3584 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3585 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3586 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3587 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3588 | { |
| 3589 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3590 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3591 | " hence this operation is not permitted!", __func__); |
| 3592 | ret = -EPERM; |
| 3593 | goto exit; |
| 3594 | } |
| 3595 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3596 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 3597 | value = value + 11; |
| 3598 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3599 | ret = kstrtou8(value, 10, &eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3600 | if (ret < 0) |
| 3601 | { |
| 3602 | /* If the input value is greater than max value of datatype, then also |
| 3603 | kstrtou8 fails */ |
| 3604 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3605 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3606 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3607 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3608 | ret = -EINVAL; |
| 3609 | goto exit; |
| 3610 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3611 | if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) || |
| 3612 | (eseMode > CFG_ESE_FEATURE_ENABLED_MAX)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3613 | { |
| 3614 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3615 | "Ese mode value %d is out of range" |
| 3616 | " (Min: %d Max: %d)", eseMode, |
| 3617 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3618 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3619 | ret = -EINVAL; |
| 3620 | goto exit; |
| 3621 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3622 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3623 | "%s: Received Command to change ese mode = %d", __func__, eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3624 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3625 | pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode; |
| 3626 | sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3627 | } |
| 3628 | #endif |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3629 | else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0) |
| 3630 | { |
| 3631 | tANI_U8 *value = command; |
| 3632 | tANI_BOOLEAN roamScanControl = 0; |
| 3633 | |
| 3634 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 3635 | value = value + 19; |
| 3636 | /* Convert the value from ascii to integer */ |
| 3637 | ret = kstrtou8(value, 10, &roamScanControl); |
| 3638 | if (ret < 0) |
| 3639 | { |
| 3640 | /* If the input value is greater than max value of datatype, then also |
| 3641 | kstrtou8 fails */ |
| 3642 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3643 | "%s: kstrtou8 failed ", __func__); |
| 3644 | ret = -EINVAL; |
| 3645 | goto exit; |
| 3646 | } |
| 3647 | |
| 3648 | if (0 != roamScanControl) |
| 3649 | { |
| 3650 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3651 | "roam scan control invalid value = %d", |
| 3652 | roamScanControl); |
| 3653 | ret = -EINVAL; |
| 3654 | goto exit; |
| 3655 | } |
| 3656 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3657 | "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl); |
| 3658 | |
| 3659 | sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl); |
| 3660 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3661 | #ifdef FEATURE_WLAN_OKC |
| 3662 | else if (strncmp(command, "SETOKCMODE", 10) == 0) |
| 3663 | { |
| 3664 | tANI_U8 *value = command; |
| 3665 | tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 3666 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3667 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3668 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3669 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3670 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3671 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3672 | { |
| 3673 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3674 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3675 | " hence this operation is not permitted!", __func__); |
| 3676 | ret = -EPERM; |
| 3677 | goto exit; |
| 3678 | } |
| 3679 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3680 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 3681 | value = value + 11; |
| 3682 | /* Convert the value from ascii to integer */ |
| 3683 | ret = kstrtou8(value, 10, &okcMode); |
| 3684 | if (ret < 0) |
| 3685 | { |
| 3686 | /* If the input value is greater than max value of datatype, then also |
| 3687 | kstrtou8 fails */ |
| 3688 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3689 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3690 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3691 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3692 | ret = -EINVAL; |
| 3693 | goto exit; |
| 3694 | } |
| 3695 | |
| 3696 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 3697 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) |
| 3698 | { |
| 3699 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3700 | "Okc mode value %d is out of range" |
| 3701 | " (Min: %d Max: %d)", okcMode, |
| 3702 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3703 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3704 | ret = -EINVAL; |
| 3705 | goto exit; |
| 3706 | } |
| 3707 | |
| 3708 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3709 | "%s: Received Command to change okc mode = %d", __func__, okcMode); |
| 3710 | |
| 3711 | pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode; |
| 3712 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3713 | #endif /* FEATURE_WLAN_OKC */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3714 | else if (strncmp(priv_data.buf, "GETROAMSCANCONTROL", 18) == 0) |
| 3715 | { |
| 3716 | tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal)); |
| 3717 | char extra[32]; |
| 3718 | tANI_U8 len = 0; |
| 3719 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3720 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3721 | command, roamScanControl); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3722 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3723 | { |
| 3724 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3725 | "%s: failed to copy data to user buffer", __func__); |
| 3726 | ret = -EFAULT; |
| 3727 | goto exit; |
| 3728 | } |
| 3729 | } |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 3730 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3731 | else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0) |
| 3732 | { |
| 3733 | tANI_U8 filterType = 0; |
| 3734 | tANI_U8 *value = command; |
| 3735 | |
| 3736 | /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */ |
| 3737 | value = value + 22; |
| 3738 | |
| 3739 | /* Convert the value from ascii to integer */ |
| 3740 | ret = kstrtou8(value, 10, &filterType); |
| 3741 | if (ret < 0) |
| 3742 | { |
| 3743 | /* If the input value is greater than max value of datatype, |
| 3744 | * then also kstrtou8 fails |
| 3745 | */ |
| 3746 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3747 | "%s: kstrtou8 failed range ", __func__); |
| 3748 | ret = -EINVAL; |
| 3749 | goto exit; |
| 3750 | } |
| 3751 | |
| 3752 | if (filterType != 0 && filterType != 1) |
| 3753 | { |
| 3754 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3755 | "%s: Accepted Values are 0 and 1 ", __func__); |
| 3756 | ret = -EINVAL; |
| 3757 | goto exit; |
| 3758 | } |
| 3759 | wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType, |
| 3760 | pAdapter->sessionId); |
| 3761 | } |
| 3762 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3763 | else if (strncmp(command, "BTCOEXMODE", 10) == 0 ) |
| 3764 | { |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3765 | char *dhcpPhase; |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 3766 | int ret; |
| 3767 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3768 | dhcpPhase = command + 11; |
| 3769 | if ('1' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3770 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 3771 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3772 | FL("send DHCP START indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3773 | |
| 3774 | pHddCtx->btCoexModeSet = TRUE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3775 | |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 3776 | ret = wlan_hdd_scan_abort(pAdapter); |
| 3777 | if (ret < 0) |
| 3778 | { |
| 3779 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3780 | FL("failed to abort existing scan %d"), ret); |
| 3781 | } |
| 3782 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3783 | sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode, |
| 3784 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3785 | } |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3786 | else if ('2' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3787 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 3788 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3789 | FL("send DHCP STOP indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3790 | |
| 3791 | pHddCtx->btCoexModeSet = FALSE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3792 | |
| 3793 | sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode, |
| 3794 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3795 | } |
| 3796 | } |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3797 | else if (strncmp(command, "SCAN-ACTIVE", 11) == 0) |
| 3798 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3799 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3800 | FL("making default scan to ACTIVE")); |
| 3801 | pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3802 | } |
| 3803 | else if (strncmp(command, "SCAN-PASSIVE", 12) == 0) |
| 3804 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3805 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3806 | FL("making default scan to PASSIVE")); |
| 3807 | pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3808 | } |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3809 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 3810 | { |
| 3811 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 3812 | char extra[32]; |
| 3813 | tANI_U8 len = 0; |
| 3814 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3815 | memset(extra, 0, sizeof(extra)); |
| 3816 | ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len); |
| 3817 | 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] | 3818 | { |
| 3819 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3820 | "%s: failed to copy data to user buffer", __func__); |
| 3821 | ret = -EFAULT; |
| 3822 | goto exit; |
| 3823 | } |
| 3824 | ret = len; |
| 3825 | } |
| 3826 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 3827 | { |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3828 | ret = hdd_set_dwell_time(pAdapter, command); |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3829 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3830 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 3831 | { |
| 3832 | tANI_U8 filterType = 0; |
| 3833 | tANI_U8 *value; |
| 3834 | value = command + 9; |
| 3835 | |
| 3836 | /* Convert the value from ascii to integer */ |
| 3837 | ret = kstrtou8(value, 10, &filterType); |
| 3838 | if (ret < 0) |
| 3839 | { |
| 3840 | /* If the input value is greater than max value of datatype, |
| 3841 | * then also kstrtou8 fails |
| 3842 | */ |
| 3843 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3844 | "%s: kstrtou8 failed range ", __func__); |
| 3845 | ret = -EINVAL; |
| 3846 | goto exit; |
| 3847 | } |
| 3848 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 3849 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 3850 | { |
| 3851 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3852 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 3853 | " 2-Sink ", __func__); |
| 3854 | ret = -EINVAL; |
| 3855 | goto exit; |
| 3856 | } |
| 3857 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 3858 | pHddCtx->drvr_miracast = filterType; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3859 | pScanInfo = &pHddCtx->scan_info; |
| 3860 | if (filterType && pScanInfo != NULL && |
| 3861 | pHddCtx->scan_info.mScanPending) |
| 3862 | { |
| 3863 | /*Miracast Session started. Abort Scan */ |
| 3864 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3865 | "%s, Aborting Scan For Miracast",__func__); |
| 3866 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 3867 | eCSR_SCAN_ABORT_DEFAULT); |
| 3868 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3869 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
Ganesh Kondabattini | 8f6e3b3 | 2014-08-25 16:07:54 +0530 | [diff] [blame] | 3870 | sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast); |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3871 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3872 | else if (strncmp(command, "SETMCRATE", 9) == 0) |
| 3873 | { |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3874 | tANI_U8 *value = command; |
| 3875 | int targetRate; |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3876 | tSirRateUpdateInd *rateUpdate; |
| 3877 | eHalStatus status; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3878 | |
| 3879 | /* Only valid for SAP mode */ |
| 3880 | if (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
| 3881 | { |
| 3882 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3883 | "%s: SAP mode is not running", __func__); |
| 3884 | ret = -EFAULT; |
| 3885 | goto exit; |
| 3886 | } |
| 3887 | |
| 3888 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 3889 | /* input value is in units of hundred kbps */ |
| 3890 | value = value + 10; |
| 3891 | /* Convert the value from ascii to integer, decimal base */ |
| 3892 | ret = kstrtouint(value, 10, &targetRate); |
| 3893 | |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3894 | rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 3895 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3896 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3897 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3898 | "%s: SETMCRATE indication alloc fail", __func__); |
| 3899 | ret = -EFAULT; |
| 3900 | goto exit; |
| 3901 | } |
| 3902 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 3903 | |
| 3904 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3905 | "MC Target rate %d", targetRate); |
| 3906 | /* Ignore unicast */ |
| 3907 | rateUpdate->ucastDataRate = -1; |
| 3908 | rateUpdate->mcastDataRate24GHz = targetRate; |
| 3909 | rateUpdate->mcastDataRate5GHz = targetRate; |
| 3910 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 3911 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 3912 | status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate); |
| 3913 | if (eHAL_STATUS_SUCCESS != status) |
| 3914 | { |
| 3915 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3916 | "%s: SET_MC_RATE failed", __func__); |
| 3917 | vos_mem_free(rateUpdate); |
| 3918 | ret = -EFAULT; |
| 3919 | goto exit; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3920 | } |
| 3921 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3922 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3923 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3924 | { |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3925 | ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3926 | } |
| 3927 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3928 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3929 | else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0) |
| 3930 | { |
| 3931 | tANI_U8 *value = command; |
| 3932 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3933 | tANI_U8 numChannels = 0; |
| 3934 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3935 | |
| 3936 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 3937 | if (eHAL_STATUS_SUCCESS != status) |
| 3938 | { |
| 3939 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3940 | "%s: Failed to parse channel list information", __func__); |
| 3941 | ret = -EINVAL; |
| 3942 | goto exit; |
| 3943 | } |
| 3944 | |
| 3945 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 3946 | { |
| 3947 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3948 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 3949 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3950 | ret = -EINVAL; |
| 3951 | goto exit; |
| 3952 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3953 | status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal), |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3954 | ChannelList, |
| 3955 | numChannels); |
| 3956 | if (eHAL_STATUS_SUCCESS != status) |
| 3957 | { |
| 3958 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3959 | "%s: Failed to update channel list information", __func__); |
| 3960 | ret = -EINVAL; |
| 3961 | goto exit; |
| 3962 | } |
| 3963 | } |
| 3964 | else if (strncmp(command, "GETTSMSTATS", 11) == 0) |
| 3965 | { |
| 3966 | tANI_U8 *value = command; |
| 3967 | char extra[128] = {0}; |
| 3968 | int len = 0; |
| 3969 | tANI_U8 tid = 0; |
| 3970 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3971 | tAniTrafStrmMetrics tsmMetrics; |
| 3972 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3973 | |
| 3974 | /* if not associated, return error */ |
| 3975 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3976 | { |
| 3977 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__); |
| 3978 | ret = -EINVAL; |
| 3979 | goto exit; |
| 3980 | } |
| 3981 | |
| 3982 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 3983 | value = value + 12; |
| 3984 | /* Convert the value from ascii to integer */ |
| 3985 | ret = kstrtou8(value, 10, &tid); |
| 3986 | if (ret < 0) |
| 3987 | { |
| 3988 | /* If the input value is greater than max value of datatype, then also |
| 3989 | kstrtou8 fails */ |
| 3990 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3991 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3992 | TID_MIN_VALUE, |
| 3993 | TID_MAX_VALUE); |
| 3994 | ret = -EINVAL; |
| 3995 | goto exit; |
| 3996 | } |
| 3997 | |
| 3998 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) |
| 3999 | { |
| 4000 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4001 | "tid value %d is out of range" |
| 4002 | " (Min: %d Max: %d)", tid, |
| 4003 | TID_MIN_VALUE, |
| 4004 | TID_MAX_VALUE); |
| 4005 | ret = -EINVAL; |
| 4006 | goto exit; |
| 4007 | } |
| 4008 | |
| 4009 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4010 | "%s: Received Command to get tsm stats tid = %d", __func__, tid); |
| 4011 | |
| 4012 | if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics)) |
| 4013 | { |
| 4014 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4015 | "%s: failed to get tsm stats", __func__); |
| 4016 | ret = -EFAULT; |
| 4017 | goto exit; |
| 4018 | } |
| 4019 | |
| 4020 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4021 | "UplinkPktQueueDly(%d)\n" |
| 4022 | "UplinkPktQueueDlyHist[0](%d)\n" |
| 4023 | "UplinkPktQueueDlyHist[1](%d)\n" |
| 4024 | "UplinkPktQueueDlyHist[2](%d)\n" |
| 4025 | "UplinkPktQueueDlyHist[3](%d)\n" |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 4026 | "UplinkPktTxDly(%u)\n" |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4027 | "UplinkPktLoss(%d)\n" |
| 4028 | "UplinkPktCount(%d)\n" |
| 4029 | "RoamingCount(%d)\n" |
| 4030 | "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly, |
| 4031 | tsmMetrics.UplinkPktQueueDlyHist[0], |
| 4032 | tsmMetrics.UplinkPktQueueDlyHist[1], |
| 4033 | tsmMetrics.UplinkPktQueueDlyHist[2], |
| 4034 | tsmMetrics.UplinkPktQueueDlyHist[3], |
| 4035 | tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss, |
| 4036 | tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly); |
| 4037 | |
| 4038 | /* Output TSM stats is of the format |
| 4039 | GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 4040 | eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */ |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4041 | 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] | 4042 | tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0], |
| 4043 | tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2], |
| 4044 | tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly, |
| 4045 | tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, |
| 4046 | tsmMetrics.RoamingDly); |
| 4047 | |
| 4048 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 4049 | { |
| 4050 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4051 | "%s: failed to copy data to user buffer", __func__); |
| 4052 | ret = -EFAULT; |
| 4053 | goto exit; |
| 4054 | } |
| 4055 | } |
| 4056 | else if (strncmp(command, "SETCCKMIE", 9) == 0) |
| 4057 | { |
| 4058 | tANI_U8 *value = command; |
| 4059 | tANI_U8 *cckmIe = NULL; |
| 4060 | tANI_U8 cckmIeLen = 0; |
| 4061 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4062 | |
| 4063 | status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 4064 | if (eHAL_STATUS_SUCCESS != status) |
| 4065 | { |
| 4066 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4067 | "%s: Failed to parse cckm ie data", __func__); |
| 4068 | ret = -EINVAL; |
| 4069 | goto exit; |
| 4070 | } |
| 4071 | |
| 4072 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) |
| 4073 | { |
| 4074 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4075 | "%s: CCKM Ie input length is more than max[%d]", __func__, |
| 4076 | DOT11F_IE_RSN_MAX_LEN); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4077 | vos_mem_free(cckmIe); |
| 4078 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4079 | ret = -EINVAL; |
| 4080 | goto exit; |
| 4081 | } |
| 4082 | sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4083 | vos_mem_free(cckmIe); |
| 4084 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4085 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4086 | else if (strncmp(command, "CCXBEACONREQ", 12) == 0) |
| 4087 | { |
| 4088 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4089 | tCsrEseBeaconReq eseBcnReq; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4090 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 4091 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4092 | status = hdd_parse_ese_beacon_req(value, &eseBcnReq); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4093 | if (eHAL_STATUS_SUCCESS != status) |
| 4094 | { |
| 4095 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4096 | "%s: Failed to parse ese beacon req", __func__); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4097 | ret = -EINVAL; |
| 4098 | goto exit; |
| 4099 | } |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 4100 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 4101 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated")); |
| 4102 | hdd_indicateEseBcnReportNoResults (pAdapter, |
| 4103 | eseBcnReq.bcnReq[0].measurementToken, |
| 4104 | 0x02, //BIT(1) set for measurement done |
| 4105 | 0); // no BSS |
| 4106 | goto exit; |
| 4107 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4108 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4109 | status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq); |
| 4110 | if (eHAL_STATUS_SUCCESS != status) |
| 4111 | { |
| 4112 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4113 | "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status); |
| 4114 | ret = -EINVAL; |
| 4115 | goto exit; |
| 4116 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4117 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4118 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 4119 | else if (strncmp(command, "GETBCNMISSRATE", 14) == 0) |
| 4120 | { |
| 4121 | eHalStatus status; |
| 4122 | char buf[32], len; |
| 4123 | long waitRet; |
| 4124 | bcnMissRateContext_t getBcnMissRateCtx; |
| 4125 | |
| 4126 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4127 | |
| 4128 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 4129 | { |
| 4130 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4131 | FL("GETBCNMISSRATE: STA is not in connected state")); |
| 4132 | ret = -1; |
| 4133 | goto exit; |
| 4134 | } |
| 4135 | |
| 4136 | init_completion(&(getBcnMissRateCtx.completion)); |
| 4137 | getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC; |
| 4138 | |
| 4139 | status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal), |
| 4140 | pAdapter->sessionId, |
| 4141 | (void *)getBcnMissRateCB, |
| 4142 | (void *)(&getBcnMissRateCtx)); |
| 4143 | if( eHAL_STATUS_SUCCESS != status) |
| 4144 | { |
| 4145 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4146 | FL("GETBCNMISSRATE: fail to post WDA cmd")); |
| 4147 | ret = -EINVAL; |
| 4148 | goto exit; |
| 4149 | } |
| 4150 | |
| 4151 | waitRet = wait_for_completion_interruptible_timeout |
| 4152 | (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME); |
| 4153 | if(waitRet <= 0) |
| 4154 | { |
| 4155 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4156 | FL("failed to wait on bcnMissRateComp %d"), ret); |
| 4157 | |
| 4158 | //Make magic number to zero so that callback is not called. |
| 4159 | spin_lock(&hdd_context_lock); |
| 4160 | getBcnMissRateCtx.magic = 0x0; |
| 4161 | spin_unlock(&hdd_context_lock); |
| 4162 | ret = -EINVAL; |
| 4163 | goto exit; |
| 4164 | } |
| 4165 | |
| 4166 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4167 | FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate); |
| 4168 | |
| 4169 | len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate); |
| 4170 | if (copy_to_user(priv_data.buf, &buf, len + 1)) |
| 4171 | { |
| 4172 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4173 | "%s: failed to copy data to user buffer", __func__); |
| 4174 | ret = -EFAULT; |
| 4175 | goto exit; |
| 4176 | } |
| 4177 | ret = len; |
| 4178 | } |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 4179 | #ifdef FEATURE_WLAN_TDLS |
| 4180 | else if (strncmp(command, "TDLSSECONDARYCHANNELOFFSET", 26) == 0) { |
| 4181 | tANI_U8 *value = command; |
| 4182 | int set_value; |
| 4183 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 4184 | value += 26; |
| 4185 | sscanf(value, "%d", &set_value); |
| 4186 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4187 | "%s: Tdls offchannel offset:%d", |
| 4188 | __func__, set_value); |
| 4189 | ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value); |
| 4190 | if (ret < 0) |
| 4191 | { |
| 4192 | ret = -EINVAL; |
| 4193 | goto exit; |
| 4194 | } |
| 4195 | |
| 4196 | } else if (strncmp(command, "TDLSOFFCHANNELMODE", 18) == 0) { |
| 4197 | tANI_U8 *value = command; |
| 4198 | int set_value; |
| 4199 | /* Move pointer to ahead of tdlsoffchnmode*/ |
| 4200 | value += 18; |
| 4201 | sscanf(value, "%d", &set_value); |
| 4202 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4203 | "%s: Tdls offchannel mode:%d", |
| 4204 | __func__, set_value); |
| 4205 | ret = iw_set_tdlsoffchannelmode(pAdapter, set_value); |
| 4206 | if (ret < 0) |
| 4207 | { |
| 4208 | ret = -EINVAL; |
| 4209 | goto exit; |
| 4210 | } |
| 4211 | } else if (strncmp(command, "TDLSOFFCHANNEL", 14) == 0) { |
| 4212 | tANI_U8 *value = command; |
| 4213 | int set_value; |
| 4214 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 4215 | value += 14; |
| 4216 | sscanf(value, "%d", &set_value); |
| 4217 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4218 | "%s: Tdls offchannel num: %d", |
| 4219 | __func__, set_value); |
| 4220 | ret = iw_set_tdlsoffchannel(pHddCtx, set_value); |
| 4221 | if (ret < 0) |
| 4222 | { |
| 4223 | ret = -EINVAL; |
| 4224 | goto exit; |
| 4225 | } |
| 4226 | } |
| 4227 | #endif |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4228 | else if (strncmp(command, "GETFWSTATS", 10) == 0) |
| 4229 | { |
| 4230 | eHalStatus status; |
| 4231 | char *buf = NULL; |
| 4232 | char len; |
| 4233 | long waitRet; |
| 4234 | fwStatsContext_t fwStatsCtx; |
| 4235 | fwStatsResult_t *fwStatsRsp = &(pAdapter->fwStatsRsp); |
| 4236 | tANI_U8 *ptr = command; |
| 4237 | int stats = *(ptr + 11) - '0'; |
| 4238 | |
| 4239 | hddLog(VOS_TRACE_LEVEL_INFO, FL("stats = %d "),stats); |
| 4240 | if (!IS_FEATURE_FW_STATS_ENABLE) |
| 4241 | { |
| 4242 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4243 | FL("Get Firmware stats feature not supported")); |
| 4244 | ret = -EINVAL; |
| 4245 | goto exit; |
| 4246 | } |
| 4247 | |
| 4248 | if (FW_STATS_MAX <= stats || 0 >= stats) |
| 4249 | { |
| 4250 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4251 | FL(" stats %d not supported"),stats); |
| 4252 | ret = -EINVAL; |
| 4253 | goto exit; |
| 4254 | } |
| 4255 | |
| 4256 | init_completion(&(fwStatsCtx.completion)); |
| 4257 | fwStatsCtx.magic = FW_STATS_CONTEXT_MAGIC; |
| 4258 | fwStatsCtx.pAdapter = pAdapter; |
| 4259 | fwStatsRsp->type = 0; |
| 4260 | status = sme_GetFwStats( (tHalHandle)pHddCtx->hHal, stats, |
| 4261 | (&fwStatsCtx), hdd_FWStatisCB); |
| 4262 | if (eHAL_STATUS_SUCCESS != status) |
| 4263 | { |
| 4264 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4265 | FL(" fail to post WDA cmd status = %d"), status); |
| 4266 | ret = -EINVAL; |
| 4267 | goto exit; |
| 4268 | } |
| 4269 | waitRet = wait_for_completion_timeout |
| 4270 | (&(fwStatsCtx.completion), FW_STATE_WAIT_TIME); |
| 4271 | if (waitRet <= 0) |
| 4272 | { |
| 4273 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4274 | FL("failed to wait on GwtFwstats")); |
| 4275 | //Make magic number to zero so that callback is not executed. |
| 4276 | spin_lock(&hdd_context_lock); |
| 4277 | fwStatsCtx.magic = 0x0; |
| 4278 | spin_unlock(&hdd_context_lock); |
| 4279 | ret = -EINVAL; |
| 4280 | goto exit; |
| 4281 | } |
| 4282 | if (fwStatsRsp->type) |
| 4283 | { |
| 4284 | buf = kmalloc(FW_STATE_RSP_LEN, GFP_KERNEL); |
| 4285 | if (!buf) |
| 4286 | { |
| 4287 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4288 | FL(" failed to allocate memory")); |
| 4289 | ret = -ENOMEM; |
| 4290 | goto exit; |
| 4291 | } |
| 4292 | switch( fwStatsRsp->type ) |
| 4293 | { |
| 4294 | case FW_UBSP_STATS: |
| 4295 | { |
| 4296 | len = snprintf(buf, FW_STATE_RSP_LEN, |
| 4297 | "GETFWSTATS: ubsp_enter_cnt %d ubsp_jump_ddr_cnt %d", |
| 4298 | fwStatsRsp->hddFwStatsData.ubspStats.ubsp_enter_cnt, |
| 4299 | fwStatsRsp->hddFwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
| 4300 | } |
| 4301 | break; |
| 4302 | default: |
| 4303 | { |
| 4304 | hddLog(VOS_TRACE_LEVEL_ERROR, FL( "No handling for stats type %d"),fwStatsRsp->type); |
| 4305 | ret = -EFAULT; |
| 4306 | kfree(buf); |
| 4307 | goto exit; |
| 4308 | } |
| 4309 | } |
| 4310 | if (copy_to_user(priv_data.buf, buf, len + 1)) |
| 4311 | { |
| 4312 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4313 | FL(" failed to copy data to user buffer")); |
| 4314 | ret = -EFAULT; |
| 4315 | kfree(buf); |
| 4316 | goto exit; |
| 4317 | } |
| 4318 | ret = len; |
| 4319 | kfree(buf); |
| 4320 | } |
| 4321 | else |
| 4322 | { |
| 4323 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4324 | FL("failed to fetch the stats")); |
| 4325 | ret = -EFAULT; |
| 4326 | goto exit; |
| 4327 | } |
| 4328 | |
| 4329 | } |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4330 | else { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4331 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4332 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 4333 | pAdapter->sessionId, 0)); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4334 | hddLog( VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"), |
| 4335 | command); |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4336 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4337 | } |
| 4338 | exit: |
| 4339 | if (command) |
| 4340 | { |
| 4341 | kfree(command); |
| 4342 | } |
| 4343 | return ret; |
| 4344 | } |
| 4345 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4346 | #ifdef CONFIG_COMPAT |
| 4347 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4348 | { |
| 4349 | struct { |
| 4350 | compat_uptr_t buf; |
| 4351 | int used_len; |
| 4352 | int total_len; |
| 4353 | } compat_priv_data; |
| 4354 | hdd_priv_data_t priv_data; |
| 4355 | int ret = 0; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4356 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4357 | /* |
| 4358 | * Note that pAdapter and ifr have already been verified by caller, |
| 4359 | * and HDD context has also been validated |
| 4360 | */ |
| 4361 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 4362 | sizeof(compat_priv_data))) { |
| 4363 | ret = -EFAULT; |
| 4364 | goto exit; |
| 4365 | } |
| 4366 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 4367 | priv_data.used_len = compat_priv_data.used_len; |
| 4368 | priv_data.total_len = compat_priv_data.total_len; |
| 4369 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4370 | exit: |
| 4371 | return ret; |
| 4372 | } |
| 4373 | #else /* CONFIG_COMPAT */ |
| 4374 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4375 | { |
| 4376 | /* will never be invoked */ |
| 4377 | return 0; |
| 4378 | } |
| 4379 | #endif /* CONFIG_COMPAT */ |
| 4380 | |
| 4381 | static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4382 | { |
| 4383 | hdd_priv_data_t priv_data; |
| 4384 | int ret = 0; |
| 4385 | |
| 4386 | /* |
| 4387 | * Note that pAdapter and ifr have already been verified by caller, |
| 4388 | * and HDD context has also been validated |
| 4389 | */ |
| 4390 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) { |
| 4391 | ret = -EFAULT; |
| 4392 | } else { |
| 4393 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4394 | } |
| 4395 | return ret; |
| 4396 | } |
| 4397 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 4398 | int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4399 | { |
| 4400 | hdd_adapter_t *pAdapter; |
| 4401 | hdd_context_t *pHddCtx; |
| 4402 | int ret; |
| 4403 | |
| 4404 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4405 | if (NULL == pAdapter) { |
| 4406 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4407 | "%s: HDD adapter context is Null", __func__); |
| 4408 | ret = -ENODEV; |
| 4409 | goto exit; |
| 4410 | } |
| 4411 | if (dev != pAdapter->dev) { |
| 4412 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4413 | "%s: HDD adapter/dev inconsistency", __func__); |
| 4414 | ret = -ENODEV; |
| 4415 | goto exit; |
| 4416 | } |
| 4417 | |
| 4418 | if ((!ifr) || (!ifr->ifr_data)) { |
| 4419 | ret = -EINVAL; |
| 4420 | goto exit; |
| 4421 | } |
| 4422 | |
| 4423 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4424 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4425 | if (ret) { |
Mahesh A Saptasagar | 5b16d0a | 2014-11-03 17:55:29 +0530 | [diff] [blame] | 4426 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4427 | "%s: invalid context", __func__); |
| 4428 | ret = -EBUSY; |
| 4429 | goto exit; |
| 4430 | } |
| 4431 | |
| 4432 | switch (cmd) { |
| 4433 | case (SIOCDEVPRIVATE + 1): |
| 4434 | if (is_compat_task()) |
| 4435 | ret = hdd_driver_compat_ioctl(pAdapter, ifr); |
| 4436 | else |
| 4437 | ret = hdd_driver_ioctl(pAdapter, ifr); |
| 4438 | break; |
| 4439 | default: |
| 4440 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d", |
| 4441 | __func__, cmd); |
| 4442 | ret = -EINVAL; |
| 4443 | break; |
| 4444 | } |
| 4445 | exit: |
| 4446 | return ret; |
| 4447 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4448 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 4449 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 4450 | { |
| 4451 | int ret; |
| 4452 | |
| 4453 | vos_ssr_protect(__func__); |
| 4454 | ret = __hdd_ioctl(dev, ifr, cmd); |
| 4455 | vos_ssr_unprotect(__func__); |
| 4456 | |
| 4457 | return ret; |
| 4458 | } |
| 4459 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4460 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4461 | /**--------------------------------------------------------------------------- |
| 4462 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4463 | \brief hdd_parse_ese_beacon_req() - Parse ese beacon request |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4464 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4465 | This function parses the ese beacon request passed in the format |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4466 | CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 4467 | <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 4468 | <space>Scan Mode N<space>Meas Duration N |
| 4469 | if the Number of bcn req fields (N) does not match with the actual number of fields passed |
| 4470 | then take N. |
| 4471 | <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair |
| 4472 | For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 4473 | This function does not take care of removing duplicate channels from the list |
| 4474 | |
| 4475 | \param - pValue Pointer to data |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4476 | \param - pEseBcnReq output pointer to store parsed ie information |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4477 | |
| 4478 | \return - 0 for success non-zero for failure |
| 4479 | |
| 4480 | --------------------------------------------------------------------------*/ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4481 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 4482 | tCsrEseBeaconReq *pEseBcnReq) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4483 | { |
| 4484 | tANI_U8 *inPtr = pValue; |
| 4485 | int tempInt = 0; |
| 4486 | int j = 0, i = 0, v = 0; |
| 4487 | char buf[32]; |
| 4488 | |
| 4489 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4490 | /*no argument after the command*/ |
| 4491 | if (NULL == inPtr) |
| 4492 | { |
| 4493 | return -EINVAL; |
| 4494 | } |
| 4495 | /*no space after the command*/ |
| 4496 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4497 | { |
| 4498 | return -EINVAL; |
| 4499 | } |
| 4500 | |
| 4501 | /*removing empty spaces*/ |
| 4502 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4503 | |
| 4504 | /*no argument followed by spaces*/ |
| 4505 | if ('\0' == *inPtr) return -EINVAL; |
| 4506 | |
| 4507 | /*getting the first argument ie measurement token*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4508 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4509 | if (1 != v) return -EINVAL; |
| 4510 | |
| 4511 | v = kstrtos32(buf, 10, &tempInt); |
| 4512 | if ( v < 0) return -EINVAL; |
| 4513 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4514 | pEseBcnReq->numBcnReqIe = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4515 | |
| 4516 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4517 | "Number of Bcn Req Ie fields(%d)", pEseBcnReq->numBcnReqIe); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4518 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4519 | for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4520 | { |
| 4521 | for (i = 0; i < 4; i++) |
| 4522 | { |
| 4523 | /*inPtr pointing to the beginning of first space after number of ie fields*/ |
| 4524 | inPtr = strpbrk( inPtr, " " ); |
| 4525 | /*no ie data after the number of ie fields argument*/ |
| 4526 | if (NULL == inPtr) return -EINVAL; |
| 4527 | |
| 4528 | /*removing empty space*/ |
| 4529 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4530 | |
| 4531 | /*no ie data after the number of ie fields argument and spaces*/ |
| 4532 | if ( '\0' == *inPtr ) return -EINVAL; |
| 4533 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4534 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4535 | if (1 != v) return -EINVAL; |
| 4536 | |
| 4537 | v = kstrtos32(buf, 10, &tempInt); |
| 4538 | if (v < 0) return -EINVAL; |
| 4539 | |
| 4540 | switch (i) |
| 4541 | { |
| 4542 | case 0: /* Measurement token */ |
| 4543 | if (tempInt <= 0) |
| 4544 | { |
| 4545 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4546 | "Invalid Measurement Token(%d)", tempInt); |
| 4547 | return -EINVAL; |
| 4548 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4549 | pEseBcnReq->bcnReq[j].measurementToken = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4550 | break; |
| 4551 | |
| 4552 | case 1: /* Channel number */ |
| 4553 | if ((tempInt <= 0) || |
| 4554 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4555 | { |
| 4556 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4557 | "Invalid Channel Number(%d)", tempInt); |
| 4558 | return -EINVAL; |
| 4559 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4560 | pEseBcnReq->bcnReq[j].channel = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4561 | break; |
| 4562 | |
| 4563 | case 2: /* Scan mode */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 4564 | if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE)) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4565 | { |
| 4566 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4567 | "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt); |
| 4568 | return -EINVAL; |
| 4569 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4570 | pEseBcnReq->bcnReq[j].scanMode= tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4571 | break; |
| 4572 | |
| 4573 | case 3: /* Measurement duration */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4574 | if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) || |
| 4575 | ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE))) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4576 | { |
| 4577 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4578 | "Invalid Measurement Duration(%d)", tempInt); |
| 4579 | return -EINVAL; |
| 4580 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4581 | pEseBcnReq->bcnReq[j].measurementDuration = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4582 | break; |
| 4583 | } |
| 4584 | } |
| 4585 | } |
| 4586 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4587 | for (j = 0; j < pEseBcnReq->numBcnReqIe; j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4588 | { |
| 4589 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 4590 | "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] | 4591 | j, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4592 | pEseBcnReq->bcnReq[j].measurementToken, |
| 4593 | pEseBcnReq->bcnReq[j].channel, |
| 4594 | pEseBcnReq->bcnReq[j].scanMode, |
| 4595 | pEseBcnReq->bcnReq[j].measurementDuration); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4596 | } |
| 4597 | |
| 4598 | return VOS_STATUS_SUCCESS; |
| 4599 | } |
| 4600 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4601 | static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext ) |
| 4602 | { |
| 4603 | struct statsContext *pStatsContext = NULL; |
| 4604 | hdd_adapter_t *pAdapter = NULL; |
| 4605 | |
| 4606 | if (NULL == pContext) |
| 4607 | { |
| 4608 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4609 | "%s: Bad param, pContext [%p]", |
| 4610 | __func__, pContext); |
| 4611 | return; |
| 4612 | } |
| 4613 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4614 | /* there is a race condition that exists between this callback |
| 4615 | function and the caller since the caller could time out either |
| 4616 | before or while this code is executing. we use a spinlock to |
| 4617 | serialize these actions */ |
| 4618 | spin_lock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4619 | |
| 4620 | pStatsContext = pContext; |
| 4621 | pAdapter = pStatsContext->pAdapter; |
| 4622 | if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic)) |
| 4623 | { |
| 4624 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4625 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4626 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4627 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 4628 | __func__, pAdapter, pStatsContext->magic); |
| 4629 | return; |
| 4630 | } |
| 4631 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4632 | /* context is valid so caller is still waiting */ |
| 4633 | |
| 4634 | /* paranoia: invalidate the magic */ |
| 4635 | pStatsContext->magic = 0; |
| 4636 | |
| 4637 | /* copy over the tsm stats */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4638 | pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly; |
| 4639 | vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4640 | tsmMetrics.UplinkPktQueueDlyHist, |
| 4641 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4642 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4643 | pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly; |
| 4644 | pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss; |
| 4645 | pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount; |
| 4646 | pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount; |
| 4647 | pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly; |
| 4648 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4649 | /* notify the caller */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4650 | complete(&pStatsContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4651 | |
| 4652 | /* serialization is complete */ |
| 4653 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4654 | } |
| 4655 | |
| 4656 | |
| 4657 | |
| 4658 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 4659 | tAniTrafStrmMetrics* pTsmMetrics) |
| 4660 | { |
| 4661 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4662 | eHalStatus hstatus; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4663 | VOS_STATUS vstatus = VOS_STATUS_SUCCESS; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4664 | long lrc; |
| 4665 | struct statsContext context; |
| 4666 | hdd_context_t *pHddCtx = NULL; |
| 4667 | |
| 4668 | if (NULL == pAdapter) |
| 4669 | { |
| 4670 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__); |
| 4671 | return VOS_STATUS_E_FAULT; |
| 4672 | } |
| 4673 | |
| 4674 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4675 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4676 | |
| 4677 | /* we are connected prepare our callback context */ |
| 4678 | init_completion(&context.completion); |
| 4679 | context.pAdapter = pAdapter; |
| 4680 | context.magic = STATS_CONTEXT_MAGIC; |
| 4681 | |
| 4682 | /* query tsm stats */ |
| 4683 | hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB, |
| 4684 | pHddStaCtx->conn_info.staId[ 0 ], |
| 4685 | pHddStaCtx->conn_info.bssId, |
| 4686 | &context, pHddCtx->pvosContext, tid); |
| 4687 | |
| 4688 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 4689 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4690 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics", |
| 4691 | __func__); |
| 4692 | vstatus = VOS_STATUS_E_FAULT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4693 | } |
| 4694 | else |
| 4695 | { |
| 4696 | /* request was sent -- wait for the response */ |
| 4697 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 4698 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4699 | if (lrc <= 0) |
| 4700 | { |
| 4701 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4702 | "%s: SME %s while retrieving statistics", |
| 4703 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4704 | vstatus = VOS_STATUS_E_TIMEOUT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4705 | } |
| 4706 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4707 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4708 | /* either we never sent a request, we sent a request and received a |
| 4709 | response or we sent a request and timed out. if we never sent a |
| 4710 | request or if we sent a request and got a response, we want to |
| 4711 | clear the magic out of paranoia. if we timed out there is a |
| 4712 | race condition such that the callback function could be |
| 4713 | executing at the same time we are. of primary concern is if the |
| 4714 | callback function had already verified the "magic" but had not |
| 4715 | yet set the completion variable when a timeout occurred. we |
| 4716 | serialize these activities by invalidating the magic while |
| 4717 | holding a shared spinlock which will cause us to block if the |
| 4718 | callback is currently executing */ |
| 4719 | spin_lock(&hdd_context_lock); |
| 4720 | context.magic = 0; |
| 4721 | spin_unlock(&hdd_context_lock); |
| 4722 | |
| 4723 | if (VOS_STATUS_SUCCESS == vstatus) |
| 4724 | { |
| 4725 | pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly; |
| 4726 | vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist, |
| 4727 | pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4728 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4729 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4730 | pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly; |
| 4731 | pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss; |
| 4732 | pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount; |
| 4733 | pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount; |
| 4734 | pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly; |
| 4735 | } |
| 4736 | return vstatus; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4737 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4738 | #endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4739 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4740 | #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] | 4741 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand) |
| 4742 | { |
| 4743 | eCsrBand band = -1; |
| 4744 | sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band); |
| 4745 | switch (band) |
| 4746 | { |
| 4747 | case eCSR_BAND_ALL: |
| 4748 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 4749 | break; |
| 4750 | |
| 4751 | case eCSR_BAND_24: |
| 4752 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 4753 | break; |
| 4754 | |
| 4755 | case eCSR_BAND_5G: |
| 4756 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 4757 | break; |
| 4758 | |
| 4759 | default: |
| 4760 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band); |
| 4761 | *pBand = -1; |
| 4762 | break; |
| 4763 | } |
| 4764 | } |
| 4765 | |
| 4766 | /**--------------------------------------------------------------------------- |
| 4767 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4768 | \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 4769 | |
| 4770 | This function parses the send action frame data passed in the format |
| 4771 | SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 4772 | |
Srinivas Girigowda | 5607685 | 2013-08-20 14:00:50 -0700 | [diff] [blame] | 4773 | \param - pValue Pointer to input data |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4774 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4775 | \param - pChannel Pointer to the Target AP channel |
| 4776 | \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame |
| 4777 | \param - pBuf Pointer to data |
| 4778 | \param - pBufLen Pointer to data length |
| 4779 | |
| 4780 | \return - 0 for success non-zero for failure |
| 4781 | |
| 4782 | --------------------------------------------------------------------------*/ |
| 4783 | VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel, |
| 4784 | tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen) |
| 4785 | { |
| 4786 | tANI_U8 *inPtr = pValue; |
| 4787 | tANI_U8 *dataEnd; |
| 4788 | int tempInt; |
| 4789 | int j = 0; |
| 4790 | int i = 0; |
| 4791 | int v = 0; |
| 4792 | tANI_U8 tempBuf[32]; |
| 4793 | tANI_U8 tempByte = 0; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4794 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 4795 | tANI_U8 macAddress[18]; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4796 | |
| 4797 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4798 | /*no argument after the command*/ |
| 4799 | if (NULL == inPtr) |
| 4800 | { |
| 4801 | return -EINVAL; |
| 4802 | } |
| 4803 | |
| 4804 | /*no space after the command*/ |
| 4805 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4806 | { |
| 4807 | return -EINVAL; |
| 4808 | } |
| 4809 | |
| 4810 | /*removing empty spaces*/ |
| 4811 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4812 | |
| 4813 | /*no argument followed by spaces*/ |
| 4814 | if ('\0' == *inPtr) |
| 4815 | { |
| 4816 | return -EINVAL; |
| 4817 | } |
| 4818 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4819 | v = sscanf(inPtr, "%17s", macAddress); |
| 4820 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4821 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4822 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4823 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4824 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4825 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4826 | |
| 4827 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4828 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4829 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4830 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4831 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4832 | 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] | 4833 | |
| 4834 | /* point to the next argument */ |
| 4835 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4836 | /*no argument after the command*/ |
| 4837 | if (NULL == inPtr) return -EINVAL; |
| 4838 | |
| 4839 | /*removing empty spaces*/ |
| 4840 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4841 | |
| 4842 | /*no argument followed by spaces*/ |
| 4843 | if ('\0' == *inPtr) |
| 4844 | { |
| 4845 | return -EINVAL; |
| 4846 | } |
| 4847 | |
| 4848 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4849 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4850 | if (1 != v) return -EINVAL; |
| 4851 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4852 | v = kstrtos32(tempBuf, 10, &tempInt); |
Agarwal Ashish | 353b3a8 | 2014-04-08 14:55:11 +0530 | [diff] [blame] | 4853 | if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX ) |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4854 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4855 | |
| 4856 | *pChannel = tempInt; |
| 4857 | |
| 4858 | /* point to the next argument */ |
| 4859 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4860 | /*no argument after the command*/ |
| 4861 | if (NULL == inPtr) return -EINVAL; |
| 4862 | /*removing empty spaces*/ |
| 4863 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4864 | |
| 4865 | /*no argument followed by spaces*/ |
| 4866 | if ('\0' == *inPtr) |
| 4867 | { |
| 4868 | return -EINVAL; |
| 4869 | } |
| 4870 | |
| 4871 | /*getting the next argument ie the dwell time */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4872 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4873 | if (1 != v) return -EINVAL; |
| 4874 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4875 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 5a6e067 | 2014-01-09 14:42:57 -0800 | [diff] [blame] | 4876 | if ( v < 0 || tempInt < 0) return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4877 | |
| 4878 | *pDwellTime = tempInt; |
| 4879 | |
| 4880 | /* point to the next argument */ |
| 4881 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4882 | /*no argument after the command*/ |
| 4883 | if (NULL == inPtr) return -EINVAL; |
| 4884 | /*removing empty spaces*/ |
| 4885 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4886 | |
| 4887 | /*no argument followed by spaces*/ |
| 4888 | if ('\0' == *inPtr) |
| 4889 | { |
| 4890 | return -EINVAL; |
| 4891 | } |
| 4892 | |
| 4893 | /* find the length of data */ |
| 4894 | dataEnd = inPtr; |
| 4895 | while(('\0' != *dataEnd) ) |
| 4896 | { |
| 4897 | dataEnd++; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4898 | } |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4899 | *pBufLen = dataEnd - inPtr ; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4900 | if ( *pBufLen <= 0) return -EINVAL; |
| 4901 | |
Srinivas Girigowda | b5ae85d | 2013-06-03 10:51:45 -0700 | [diff] [blame] | 4902 | /* Allocate the number of bytes based on the number of input characters |
| 4903 | whether it is even or odd. |
| 4904 | if the number of input characters are even, then we need N/2 byte. |
| 4905 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 4906 | compensate rounding off. |
| 4907 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 4908 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 4909 | *pBuf = vos_mem_malloc((*pBufLen + 1)/2); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4910 | if (NULL == *pBuf) |
| 4911 | { |
| 4912 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4913 | "%s: vos_mem_alloc failed ", __func__); |
| 4914 | return -EINVAL; |
| 4915 | } |
| 4916 | |
| 4917 | /* the buffer received from the upper layer is character buffer, |
| 4918 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 4919 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 4920 | and f0 in 3rd location */ |
| 4921 | for (i = 0, j = 0; j < *pBufLen; j += 2) |
| 4922 | { |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4923 | if( j+1 == *pBufLen) |
| 4924 | { |
| 4925 | tempByte = hdd_parse_hex(inPtr[j]); |
| 4926 | } |
| 4927 | else |
| 4928 | { |
| 4929 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 4930 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4931 | (*pBuf)[i++] = tempByte; |
| 4932 | } |
| 4933 | *pBufLen = i; |
| 4934 | return VOS_STATUS_SUCCESS; |
| 4935 | } |
| 4936 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4937 | /**--------------------------------------------------------------------------- |
| 4938 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4939 | \brief hdd_parse_channellist() - HDD Parse channel list |
| 4940 | |
| 4941 | This function parses the channel list passed in the format |
| 4942 | 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] | 4943 | if the Number of channels (N) does not match with the actual number of channels passed |
| 4944 | then take the minimum of N and count of (Ch1, Ch2, ...Ch M) |
| 4945 | For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken. |
| 4946 | If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48. |
| 4947 | 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] | 4948 | |
| 4949 | \param - pValue Pointer to input channel list |
| 4950 | \param - ChannelList Pointer to local output array to record channel list |
| 4951 | \param - pNumChannels Pointer to number of roam scan channels |
| 4952 | |
| 4953 | \return - 0 for success non-zero for failure |
| 4954 | |
| 4955 | --------------------------------------------------------------------------*/ |
| 4956 | VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels) |
| 4957 | { |
| 4958 | tANI_U8 *inPtr = pValue; |
| 4959 | int tempInt; |
| 4960 | int j = 0; |
| 4961 | int v = 0; |
| 4962 | char buf[32]; |
| 4963 | |
| 4964 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4965 | /*no argument after the command*/ |
| 4966 | if (NULL == inPtr) |
| 4967 | { |
| 4968 | return -EINVAL; |
| 4969 | } |
| 4970 | |
| 4971 | /*no space after the command*/ |
| 4972 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4973 | { |
| 4974 | return -EINVAL; |
| 4975 | } |
| 4976 | |
| 4977 | /*removing empty spaces*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4978 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4979 | |
| 4980 | /*no argument followed by spaces*/ |
| 4981 | if ('\0' == *inPtr) |
| 4982 | { |
| 4983 | return -EINVAL; |
| 4984 | } |
| 4985 | |
| 4986 | /*getting the first argument ie the number of channels*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4987 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4988 | if (1 != v) return -EINVAL; |
| 4989 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4990 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4991 | if ((v < 0) || |
| 4992 | (tempInt <= 0) || |
| 4993 | (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 4994 | { |
| 4995 | return -EINVAL; |
| 4996 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4997 | |
| 4998 | *pNumChannels = tempInt; |
| 4999 | |
| 5000 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 5001 | "Number of channels are: %d", *pNumChannels); |
| 5002 | |
| 5003 | for (j = 0; j < (*pNumChannels); j++) |
| 5004 | { |
| 5005 | /*inPtr pointing to the beginning of first space after number of channels*/ |
| 5006 | inPtr = strpbrk( inPtr, " " ); |
| 5007 | /*no channel list after the number of channels argument*/ |
| 5008 | if (NULL == inPtr) |
| 5009 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 5010 | if (0 != j) |
| 5011 | { |
| 5012 | *pNumChannels = j; |
| 5013 | return VOS_STATUS_SUCCESS; |
| 5014 | } |
| 5015 | else |
| 5016 | { |
| 5017 | return -EINVAL; |
| 5018 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5019 | } |
| 5020 | |
| 5021 | /*removing empty space*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 5022 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5023 | |
| 5024 | /*no channel list after the number of channels argument and spaces*/ |
| 5025 | if ( '\0' == *inPtr ) |
| 5026 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 5027 | if (0 != j) |
| 5028 | { |
| 5029 | *pNumChannels = j; |
| 5030 | return VOS_STATUS_SUCCESS; |
| 5031 | } |
| 5032 | else |
| 5033 | { |
| 5034 | return -EINVAL; |
| 5035 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5036 | } |
| 5037 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5038 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5039 | if (1 != v) return -EINVAL; |
| 5040 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5041 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 5042 | if ((v < 0) || |
| 5043 | (tempInt <= 0) || |
| 5044 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 5045 | { |
| 5046 | return -EINVAL; |
| 5047 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5048 | pChannelList[j] = tempInt; |
| 5049 | |
| 5050 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 5051 | "Channel %d added to preferred channel list", |
| 5052 | pChannelList[j] ); |
| 5053 | } |
| 5054 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5055 | return VOS_STATUS_SUCCESS; |
| 5056 | } |
| 5057 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5058 | |
| 5059 | /**--------------------------------------------------------------------------- |
| 5060 | |
| 5061 | \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
| 5062 | |
| 5063 | This function parses the reasoc command data passed in the format |
| 5064 | REASSOC<space><bssid><space><channel> |
| 5065 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5066 | \param - pValue Pointer to input data (its a NUL terminated string) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5067 | \param - pTargetApBssid Pointer to target Ap bssid |
| 5068 | \param - pChannel Pointer to the Target AP channel |
| 5069 | |
| 5070 | \return - 0 for success non-zero for failure |
| 5071 | |
| 5072 | --------------------------------------------------------------------------*/ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5073 | VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 5074 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5075 | { |
| 5076 | tANI_U8 *inPtr = pValue; |
| 5077 | int tempInt; |
| 5078 | int v = 0; |
| 5079 | tANI_U8 tempBuf[32]; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 5080 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5081 | tANI_U8 macAddress[18]; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5082 | |
| 5083 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 5084 | /*no argument after the command*/ |
| 5085 | if (NULL == inPtr) |
| 5086 | { |
| 5087 | return -EINVAL; |
| 5088 | } |
| 5089 | |
| 5090 | /*no space after the command*/ |
| 5091 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 5092 | { |
| 5093 | return -EINVAL; |
| 5094 | } |
| 5095 | |
| 5096 | /*removing empty spaces*/ |
| 5097 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 5098 | |
| 5099 | /*no argument followed by spaces*/ |
| 5100 | if ('\0' == *inPtr) |
| 5101 | { |
| 5102 | return -EINVAL; |
| 5103 | } |
| 5104 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5105 | v = sscanf(inPtr, "%17s", macAddress); |
| 5106 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5107 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5108 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5109 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 5110 | return -EINVAL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5111 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5112 | |
| 5113 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 5114 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 5115 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 5116 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 5117 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 5118 | 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] | 5119 | |
| 5120 | /* point to the next argument */ |
| 5121 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 5122 | /*no argument after the command*/ |
| 5123 | if (NULL == inPtr) return -EINVAL; |
| 5124 | |
| 5125 | /*removing empty spaces*/ |
| 5126 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 5127 | |
| 5128 | /*no argument followed by spaces*/ |
| 5129 | if ('\0' == *inPtr) |
| 5130 | { |
| 5131 | return -EINVAL; |
| 5132 | } |
| 5133 | |
| 5134 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5135 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5136 | if (1 != v) return -EINVAL; |
| 5137 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5138 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5139 | if ((v < 0) || |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 5140 | (tempInt < 0) || |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5141 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 5142 | { |
| 5143 | return -EINVAL; |
| 5144 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5145 | |
| 5146 | *pChannel = tempInt; |
| 5147 | return VOS_STATUS_SUCCESS; |
| 5148 | } |
| 5149 | |
| 5150 | #endif |
| 5151 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5152 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5153 | /**--------------------------------------------------------------------------- |
| 5154 | |
| 5155 | \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 5156 | |
| 5157 | This function parses the SETCCKM IE command |
| 5158 | SETCCKMIE<space><ie data> |
| 5159 | |
| 5160 | \param - pValue Pointer to input data |
| 5161 | \param - pCckmIe Pointer to output cckm Ie |
| 5162 | \param - pCckmIeLen Pointer to output cckm ie length |
| 5163 | |
| 5164 | \return - 0 for success non-zero for failure |
| 5165 | |
| 5166 | --------------------------------------------------------------------------*/ |
| 5167 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, |
| 5168 | tANI_U8 *pCckmIeLen) |
| 5169 | { |
| 5170 | tANI_U8 *inPtr = pValue; |
| 5171 | tANI_U8 *dataEnd; |
| 5172 | int j = 0; |
| 5173 | int i = 0; |
| 5174 | tANI_U8 tempByte = 0; |
| 5175 | |
| 5176 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 5177 | /*no argument after the command*/ |
| 5178 | if (NULL == inPtr) |
| 5179 | { |
| 5180 | return -EINVAL; |
| 5181 | } |
| 5182 | |
| 5183 | /*no space after the command*/ |
| 5184 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 5185 | { |
| 5186 | return -EINVAL; |
| 5187 | } |
| 5188 | |
| 5189 | /*removing empty spaces*/ |
| 5190 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 5191 | |
| 5192 | /*no argument followed by spaces*/ |
| 5193 | if ('\0' == *inPtr) |
| 5194 | { |
| 5195 | return -EINVAL; |
| 5196 | } |
| 5197 | |
| 5198 | /* find the length of data */ |
| 5199 | dataEnd = inPtr; |
| 5200 | while(('\0' != *dataEnd) ) |
| 5201 | { |
| 5202 | dataEnd++; |
| 5203 | ++(*pCckmIeLen); |
| 5204 | } |
| 5205 | if ( *pCckmIeLen <= 0) return -EINVAL; |
| 5206 | |
| 5207 | /* Allocate the number of bytes based on the number of input characters |
| 5208 | whether it is even or odd. |
| 5209 | if the number of input characters are even, then we need N/2 byte. |
| 5210 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 5211 | compensate rounding off. |
| 5212 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 5213 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 5214 | *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2); |
| 5215 | if (NULL == *pCckmIe) |
| 5216 | { |
| 5217 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5218 | "%s: vos_mem_alloc failed ", __func__); |
| 5219 | return -EINVAL; |
| 5220 | } |
| 5221 | vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2); |
| 5222 | /* the buffer received from the upper layer is character buffer, |
| 5223 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 5224 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 5225 | and f0 in 3rd location */ |
| 5226 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) |
| 5227 | { |
| 5228 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 5229 | (*pCckmIe)[i++] = tempByte; |
| 5230 | } |
| 5231 | *pCckmIeLen = i; |
| 5232 | |
| 5233 | return VOS_STATUS_SUCCESS; |
| 5234 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5235 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5236 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5237 | /**--------------------------------------------------------------------------- |
| 5238 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5239 | \brief hdd_is_valid_mac_address() - Validate MAC address |
| 5240 | |
| 5241 | This function validates whether the given MAC address is valid or not |
| 5242 | Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 5243 | where X is the hexa decimal digit character and separated by ':' |
| 5244 | This algorithm works even if MAC address is not separated by ':' |
| 5245 | |
| 5246 | This code checks given input string mac contains exactly 12 hexadecimal digits. |
| 5247 | and a separator colon : appears in the input string only after |
| 5248 | an even number of hex digits. |
| 5249 | |
| 5250 | \param - pMacAddr pointer to the input MAC address |
| 5251 | \return - 1 for valid and 0 for invalid |
| 5252 | |
| 5253 | --------------------------------------------------------------------------*/ |
| 5254 | |
| 5255 | v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr) |
| 5256 | { |
| 5257 | int xdigit = 0; |
| 5258 | int separator = 0; |
| 5259 | while (*pMacAddr) |
| 5260 | { |
| 5261 | if (isxdigit(*pMacAddr)) |
| 5262 | { |
| 5263 | xdigit++; |
| 5264 | } |
| 5265 | else if (':' == *pMacAddr) |
| 5266 | { |
| 5267 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 5268 | break; |
| 5269 | |
| 5270 | ++separator; |
| 5271 | } |
| 5272 | else |
| 5273 | { |
| 5274 | separator = -1; |
| 5275 | /* Invalid MAC found */ |
| 5276 | return 0; |
| 5277 | } |
| 5278 | ++pMacAddr; |
| 5279 | } |
| 5280 | return (xdigit == 12 && (separator == 5 || separator == 0)); |
| 5281 | } |
| 5282 | |
| 5283 | /**--------------------------------------------------------------------------- |
| 5284 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5285 | \brief __hdd_open() - HDD Open function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5286 | |
| 5287 | \param - dev Pointer to net_device structure |
| 5288 | |
| 5289 | \return - 0 for success non-zero for failure |
| 5290 | |
| 5291 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5292 | int __hdd_open(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5293 | { |
| 5294 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5295 | hdd_context_t *pHddCtx; |
| 5296 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 5297 | VOS_STATUS status; |
| 5298 | v_BOOL_t in_standby = TRUE; |
| 5299 | |
| 5300 | if (NULL == pAdapter) |
| 5301 | { |
| 5302 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5303 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5304 | return -ENODEV; |
| 5305 | } |
| 5306 | |
| 5307 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5308 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 5309 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5310 | if (NULL == pHddCtx) |
| 5311 | { |
| 5312 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5313 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5314 | return -ENODEV; |
| 5315 | } |
| 5316 | |
| 5317 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5318 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5319 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5320 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5321 | { |
| 5322 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5323 | __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5324 | in_standby = FALSE; |
| 5325 | break; |
| 5326 | } |
| 5327 | else |
| 5328 | { |
| 5329 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5330 | pAdapterNode = pNext; |
| 5331 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5332 | } |
| 5333 | |
| 5334 | if (TRUE == in_standby) |
| 5335 | { |
| 5336 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 5337 | { |
| 5338 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 5339 | "wlan out of power save", __func__); |
| 5340 | return -EINVAL; |
| 5341 | } |
| 5342 | } |
| 5343 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5344 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5345 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 5346 | { |
| 5347 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5348 | "%s: Enabling Tx Queues", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5349 | /* Enable TX queues only when we are connected */ |
| 5350 | netif_tx_start_all_queues(dev); |
| 5351 | } |
| 5352 | |
| 5353 | return 0; |
| 5354 | } |
| 5355 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5356 | /**--------------------------------------------------------------------------- |
| 5357 | |
| 5358 | \brief hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 5359 | |
| 5360 | This is called in response to ifconfig up |
| 5361 | |
| 5362 | \param - dev Pointer to net_device structure |
| 5363 | |
| 5364 | \return - 0 for success non-zero for failure |
| 5365 | |
| 5366 | --------------------------------------------------------------------------*/ |
| 5367 | int hdd_open(struct net_device *dev) |
| 5368 | { |
| 5369 | int ret; |
| 5370 | |
| 5371 | vos_ssr_protect(__func__); |
| 5372 | ret = __hdd_open(dev); |
| 5373 | vos_ssr_unprotect(__func__); |
| 5374 | |
| 5375 | return ret; |
| 5376 | } |
| 5377 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5378 | int hdd_mon_open (struct net_device *dev) |
| 5379 | { |
| 5380 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5381 | |
| 5382 | if(pAdapter == NULL) { |
| 5383 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5384 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5385 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5386 | } |
| 5387 | |
| 5388 | netif_start_queue(dev); |
| 5389 | |
| 5390 | return 0; |
| 5391 | } |
| 5392 | /**--------------------------------------------------------------------------- |
| 5393 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5394 | \brief __hdd_stop() - HDD stop function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5395 | |
| 5396 | \param - dev Pointer to net_device structure |
| 5397 | |
| 5398 | \return - 0 for success non-zero for failure |
| 5399 | |
| 5400 | --------------------------------------------------------------------------*/ |
| 5401 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5402 | int __hdd_stop (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5403 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5404 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5405 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5406 | hdd_context_t *pHddCtx; |
| 5407 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 5408 | VOS_STATUS status; |
| 5409 | v_BOOL_t enter_standby = TRUE; |
| 5410 | |
| 5411 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5412 | if (NULL == pAdapter) |
| 5413 | { |
| 5414 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5415 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5416 | return -ENODEV; |
| 5417 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5418 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 5419 | pAdapter->sessionId, pAdapter->device_mode)); |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5420 | |
| 5421 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5422 | ret = wlan_hdd_validate_context(pHddCtx); |
| 5423 | if (ret) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5424 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5425 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5426 | "%s: HDD context is not valid!", __func__); |
| 5427 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5428 | } |
| 5429 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5430 | /* Nothing to be done if the interface is not opened */ |
| 5431 | if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) |
| 5432 | { |
| 5433 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5434 | "%s: NETDEV Interface is not OPENED", __func__); |
| 5435 | return -ENODEV; |
| 5436 | } |
| 5437 | |
| 5438 | /* Make sure the interface is marked as closed */ |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5439 | clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5440 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5441 | |
| 5442 | /* Disable TX on the interface, after this hard_start_xmit() will not |
| 5443 | * be called on that interface |
| 5444 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5445 | netif_tx_disable(pAdapter->dev); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5446 | |
| 5447 | /* Mark the interface status as "down" for outside world */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5448 | netif_carrier_off(pAdapter->dev); |
| 5449 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5450 | /* The interface is marked as down for outside world (aka kernel) |
| 5451 | * But the driver is pretty much alive inside. The driver needs to |
| 5452 | * tear down the existing connection on the netdev (session) |
| 5453 | * cleanup the data pipes and wait until the control plane is stabilized |
| 5454 | * for this interface. The call also needs to wait until the above |
| 5455 | * mentioned actions are completed before returning to the caller. |
| 5456 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 5457 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 5458 | */ |
| 5459 | hdd_stop_adapter(pHddCtx, pAdapter, VOS_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5460 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5461 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 5462 | hdd_deinit_adapter(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5463 | /* SoftAP ifaces should never go in power save mode |
| 5464 | making sure same here. */ |
| 5465 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 5466 | || (WLAN_HDD_MONITOR == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5467 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5468 | ) |
| 5469 | { |
| 5470 | /* SoftAP mode, so return from here */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5471 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5472 | "%s: In SAP MODE", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5473 | EXIT(); |
| 5474 | return 0; |
| 5475 | } |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5476 | /* Find if any iface is up. If any iface is up then can't put device to |
| 5477 | * sleep/power save mode |
| 5478 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5479 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5480 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5481 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5482 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5483 | { |
| 5484 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot " |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5485 | "put device to sleep", __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5486 | enter_standby = FALSE; |
| 5487 | break; |
| 5488 | } |
| 5489 | else |
| 5490 | { |
| 5491 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5492 | pAdapterNode = pNext; |
| 5493 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5494 | } |
| 5495 | |
| 5496 | if (TRUE == enter_standby) |
| 5497 | { |
| 5498 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down " |
| 5499 | "entering standby", __func__); |
| 5500 | if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx)) |
| 5501 | { |
| 5502 | /*log and return success*/ |
| 5503 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put " |
| 5504 | "wlan in power save", __func__); |
| 5505 | } |
| 5506 | } |
| 5507 | |
| 5508 | EXIT(); |
| 5509 | return 0; |
| 5510 | } |
| 5511 | |
| 5512 | /**--------------------------------------------------------------------------- |
| 5513 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5514 | \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] | 5515 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5516 | This is called in response to ifconfig down |
| 5517 | |
| 5518 | \param - dev Pointer to net_device structure |
| 5519 | |
| 5520 | \return - 0 for success non-zero for failure |
| 5521 | -----------------------------------------------------------------------------*/ |
| 5522 | int hdd_stop (struct net_device *dev) |
| 5523 | { |
| 5524 | int ret; |
| 5525 | |
| 5526 | vos_ssr_protect(__func__); |
| 5527 | ret = __hdd_stop(dev); |
| 5528 | vos_ssr_unprotect(__func__); |
| 5529 | |
| 5530 | return ret; |
| 5531 | } |
| 5532 | |
| 5533 | /**--------------------------------------------------------------------------- |
| 5534 | |
| 5535 | \brief __hdd_uninit() - HDD uninit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5536 | |
| 5537 | \param - dev Pointer to net_device structure |
| 5538 | |
| 5539 | \return - void |
| 5540 | |
| 5541 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5542 | static void __hdd_uninit (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5543 | { |
| 5544 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5545 | |
| 5546 | ENTER(); |
| 5547 | |
| 5548 | do |
| 5549 | { |
| 5550 | if (NULL == pAdapter) |
| 5551 | { |
| 5552 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5553 | "%s: NULL pAdapter", __func__); |
| 5554 | break; |
| 5555 | } |
| 5556 | |
| 5557 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 5558 | { |
| 5559 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5560 | "%s: Invalid magic", __func__); |
| 5561 | break; |
| 5562 | } |
| 5563 | |
| 5564 | if (NULL == pAdapter->pHddCtx) |
| 5565 | { |
| 5566 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5567 | "%s: NULL pHddCtx", __func__); |
| 5568 | break; |
| 5569 | } |
| 5570 | |
| 5571 | if (dev != pAdapter->dev) |
| 5572 | { |
| 5573 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5574 | "%s: Invalid device reference", __func__); |
| 5575 | /* we haven't validated all cases so let this go for now */ |
| 5576 | } |
| 5577 | |
| 5578 | hdd_deinit_adapter(pAdapter->pHddCtx, pAdapter); |
| 5579 | |
| 5580 | /* after uninit our adapter structure will no longer be valid */ |
| 5581 | pAdapter->dev = NULL; |
| 5582 | pAdapter->magic = 0; |
| 5583 | } while (0); |
| 5584 | |
| 5585 | EXIT(); |
| 5586 | } |
| 5587 | |
| 5588 | /**--------------------------------------------------------------------------- |
| 5589 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5590 | \brief hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 5591 | |
| 5592 | This is called during the netdev unregister to uninitialize all data |
| 5593 | associated with the device |
| 5594 | |
| 5595 | \param - dev Pointer to net_device structure |
| 5596 | |
| 5597 | \return - void |
| 5598 | |
| 5599 | --------------------------------------------------------------------------*/ |
| 5600 | static void hdd_uninit (struct net_device *dev) |
| 5601 | { |
| 5602 | vos_ssr_protect(__func__); |
| 5603 | __hdd_uninit(dev); |
| 5604 | vos_ssr_unprotect(__func__); |
| 5605 | } |
| 5606 | |
| 5607 | /**--------------------------------------------------------------------------- |
| 5608 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5609 | \brief hdd_release_firmware() - |
| 5610 | |
| 5611 | This function calls the release firmware API to free the firmware buffer. |
| 5612 | |
| 5613 | \param - pFileName Pointer to the File Name. |
| 5614 | pCtx - Pointer to the adapter . |
| 5615 | |
| 5616 | |
| 5617 | \return - 0 for success, non zero for failure |
| 5618 | |
| 5619 | --------------------------------------------------------------------------*/ |
| 5620 | |
| 5621 | VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx) |
| 5622 | { |
| 5623 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 5624 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5625 | ENTER(); |
| 5626 | |
| 5627 | |
| 5628 | if (!strcmp(WLAN_FW_FILE, pFileName)) { |
| 5629 | |
| 5630 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName); |
| 5631 | |
| 5632 | if(pHddCtx->fw) { |
| 5633 | release_firmware(pHddCtx->fw); |
| 5634 | pHddCtx->fw = NULL; |
| 5635 | } |
| 5636 | else |
| 5637 | status = VOS_STATUS_E_FAILURE; |
| 5638 | } |
| 5639 | else if (!strcmp(WLAN_NV_FILE,pFileName)) { |
| 5640 | if(pHddCtx->nv) { |
| 5641 | release_firmware(pHddCtx->nv); |
| 5642 | pHddCtx->nv = NULL; |
| 5643 | } |
| 5644 | else |
| 5645 | status = VOS_STATUS_E_FAILURE; |
| 5646 | |
| 5647 | } |
| 5648 | |
| 5649 | EXIT(); |
| 5650 | return status; |
| 5651 | } |
| 5652 | |
| 5653 | /**--------------------------------------------------------------------------- |
| 5654 | |
| 5655 | \brief hdd_request_firmware() - |
| 5656 | |
| 5657 | This function reads the firmware file using the request firmware |
| 5658 | API and returns the the firmware data and the firmware file size. |
| 5659 | |
| 5660 | \param - pfileName - Pointer to the file name. |
| 5661 | - pCtx - Pointer to the adapter . |
| 5662 | - ppfw_data - Pointer to the pointer of the firmware data. |
| 5663 | - pSize - Pointer to the file size. |
| 5664 | |
| 5665 | \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure |
| 5666 | |
| 5667 | --------------------------------------------------------------------------*/ |
| 5668 | |
| 5669 | |
| 5670 | VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize) |
| 5671 | { |
| 5672 | int status; |
| 5673 | VOS_STATUS retval = VOS_STATUS_SUCCESS; |
| 5674 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5675 | ENTER(); |
| 5676 | |
| 5677 | if( (!strcmp(WLAN_FW_FILE, pfileName)) ) { |
| 5678 | |
| 5679 | status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev); |
| 5680 | |
| 5681 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5682 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed", |
| 5683 | __func__, pfileName); |
| 5684 | retval = VOS_STATUS_E_FAILURE; |
| 5685 | } |
| 5686 | |
| 5687 | else { |
| 5688 | *ppfw_data = (v_VOID_t *)pHddCtx->fw->data; |
| 5689 | *pSize = pHddCtx->fw->size; |
| 5690 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d", |
| 5691 | __func__, *pSize); |
| 5692 | } |
| 5693 | } |
| 5694 | else if(!strcmp(WLAN_NV_FILE, pfileName)) { |
| 5695 | |
| 5696 | status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev); |
| 5697 | |
| 5698 | if(status || !pHddCtx->nv || !pHddCtx->nv->data) { |
| 5699 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed", |
| 5700 | __func__, pfileName); |
| 5701 | retval = VOS_STATUS_E_FAILURE; |
| 5702 | } |
| 5703 | |
| 5704 | else { |
| 5705 | *ppfw_data = (v_VOID_t *)pHddCtx->nv->data; |
| 5706 | *pSize = pHddCtx->nv->size; |
| 5707 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d", |
| 5708 | __func__, *pSize); |
| 5709 | } |
| 5710 | } |
| 5711 | |
| 5712 | EXIT(); |
| 5713 | return retval; |
| 5714 | } |
| 5715 | /**--------------------------------------------------------------------------- |
| 5716 | \brief hdd_full_pwr_cbk() - HDD full power callbackfunction |
| 5717 | |
| 5718 | This is the function invoked by SME to inform the result of a full power |
| 5719 | request issued by HDD |
| 5720 | |
| 5721 | \param - callbackcontext - Pointer to cookie |
| 5722 | status - result of request |
| 5723 | |
| 5724 | \return - None |
| 5725 | |
| 5726 | --------------------------------------------------------------------------*/ |
| 5727 | void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status) |
| 5728 | { |
| 5729 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 5730 | |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 5731 | 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] | 5732 | if(&pHddCtx->full_pwr_comp_var) |
| 5733 | { |
| 5734 | complete(&pHddCtx->full_pwr_comp_var); |
| 5735 | } |
| 5736 | } |
| 5737 | |
| 5738 | /**--------------------------------------------------------------------------- |
| 5739 | |
| 5740 | \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function |
| 5741 | |
| 5742 | This is the function invoked by SME to inform the result of BMPS |
| 5743 | request issued by HDD |
| 5744 | |
| 5745 | \param - callbackcontext - Pointer to cookie |
| 5746 | status - result of request |
| 5747 | |
| 5748 | \return - None |
| 5749 | |
| 5750 | --------------------------------------------------------------------------*/ |
| 5751 | void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status) |
| 5752 | { |
| 5753 | |
| 5754 | struct completion *completion_var = (struct completion*) callbackContext; |
| 5755 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5756 | hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5757 | if(completion_var != NULL) |
| 5758 | { |
| 5759 | complete(completion_var); |
| 5760 | } |
| 5761 | } |
| 5762 | |
| 5763 | /**--------------------------------------------------------------------------- |
| 5764 | |
| 5765 | \brief hdd_get_cfg_file_size() - |
| 5766 | |
| 5767 | This function reads the configuration file using the request firmware |
| 5768 | API and returns the configuration file size. |
| 5769 | |
| 5770 | \param - pCtx - Pointer to the adapter . |
| 5771 | - pFileName - Pointer to the file name. |
| 5772 | - pBufSize - Pointer to the buffer size. |
| 5773 | |
| 5774 | \return - 0 for success, non zero for failure |
| 5775 | |
| 5776 | --------------------------------------------------------------------------*/ |
| 5777 | |
| 5778 | VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize) |
| 5779 | { |
| 5780 | int status; |
| 5781 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5782 | |
| 5783 | ENTER(); |
| 5784 | |
| 5785 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5786 | |
| 5787 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5788 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5789 | status = VOS_STATUS_E_FAILURE; |
| 5790 | } |
| 5791 | else { |
| 5792 | *pBufSize = pHddCtx->fw->size; |
| 5793 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize); |
| 5794 | release_firmware(pHddCtx->fw); |
| 5795 | pHddCtx->fw = NULL; |
| 5796 | } |
| 5797 | |
| 5798 | EXIT(); |
| 5799 | return VOS_STATUS_SUCCESS; |
| 5800 | } |
| 5801 | |
| 5802 | /**--------------------------------------------------------------------------- |
| 5803 | |
| 5804 | \brief hdd_read_cfg_file() - |
| 5805 | |
| 5806 | This function reads the configuration file using the request firmware |
| 5807 | API and returns the cfg data and the buffer size of the configuration file. |
| 5808 | |
| 5809 | \param - pCtx - Pointer to the adapter . |
| 5810 | - pFileName - Pointer to the file name. |
| 5811 | - pBuffer - Pointer to the data buffer. |
| 5812 | - pBufSize - Pointer to the buffer size. |
| 5813 | |
| 5814 | \return - 0 for success, non zero for failure |
| 5815 | |
| 5816 | --------------------------------------------------------------------------*/ |
| 5817 | |
| 5818 | VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName, |
| 5819 | v_VOID_t *pBuffer, v_SIZE_t *pBufSize) |
| 5820 | { |
| 5821 | int status; |
| 5822 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5823 | |
| 5824 | ENTER(); |
| 5825 | |
| 5826 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5827 | |
| 5828 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5829 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5830 | return VOS_STATUS_E_FAILURE; |
| 5831 | } |
| 5832 | else { |
| 5833 | if(*pBufSize != pHddCtx->fw->size) { |
| 5834 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG " |
| 5835 | "file size", __func__); |
| 5836 | release_firmware(pHddCtx->fw); |
| 5837 | pHddCtx->fw = NULL; |
| 5838 | return VOS_STATUS_E_FAILURE; |
| 5839 | } |
| 5840 | else { |
| 5841 | if(pBuffer) { |
| 5842 | vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize); |
| 5843 | } |
| 5844 | release_firmware(pHddCtx->fw); |
| 5845 | pHddCtx->fw = NULL; |
| 5846 | } |
| 5847 | } |
| 5848 | |
| 5849 | EXIT(); |
| 5850 | |
| 5851 | return VOS_STATUS_SUCCESS; |
| 5852 | } |
| 5853 | |
| 5854 | /**--------------------------------------------------------------------------- |
| 5855 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5856 | \brief __hdd_set_mac_address() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5857 | |
| 5858 | This function sets the user specified mac address using |
| 5859 | the command ifconfig wlanX hw ether <mac adress>. |
| 5860 | |
| 5861 | \param - dev - Pointer to the net device. |
| 5862 | - addr - Pointer to the sockaddr. |
| 5863 | \return - 0 for success, non zero for failure |
| 5864 | |
| 5865 | --------------------------------------------------------------------------*/ |
| 5866 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5867 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5868 | { |
| 5869 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5870 | struct sockaddr *psta_mac_addr = addr; |
| 5871 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5872 | |
| 5873 | ENTER(); |
| 5874 | |
| 5875 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5876 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 5877 | |
| 5878 | EXIT(); |
| 5879 | return halStatus; |
| 5880 | } |
| 5881 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5882 | /**--------------------------------------------------------------------------- |
| 5883 | |
| 5884 | \brief hdd_set_mac_address() - |
| 5885 | |
| 5886 | Wrapper function to protect __hdd_set_mac_address() function from ssr |
| 5887 | |
| 5888 | \param - dev - Pointer to the net device. |
| 5889 | - addr - Pointer to the sockaddr. |
| 5890 | \return - 0 for success, non zero for failure |
| 5891 | |
| 5892 | --------------------------------------------------------------------------*/ |
| 5893 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 5894 | { |
| 5895 | int ret; |
| 5896 | |
| 5897 | vos_ssr_protect(__func__); |
| 5898 | ret = __hdd_set_mac_address(dev, addr); |
| 5899 | vos_ssr_unprotect(__func__); |
| 5900 | |
| 5901 | return ret; |
| 5902 | } |
| 5903 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5904 | tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx) |
| 5905 | { |
| 5906 | int i; |
| 5907 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5908 | { |
Abhishek Singh | eb18378 | 2014-02-06 13:37:21 +0530 | [diff] [blame] | 5909 | if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5910 | break; |
| 5911 | } |
| 5912 | |
| 5913 | if( VOS_MAX_CONCURRENCY_PERSONA == i) |
| 5914 | return NULL; |
| 5915 | |
| 5916 | pHddCtx->cfg_ini->intfAddrMask |= (1 << i); |
| 5917 | return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0]; |
| 5918 | } |
| 5919 | |
| 5920 | void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr) |
| 5921 | { |
| 5922 | int i; |
| 5923 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5924 | { |
| 5925 | if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) ) |
| 5926 | { |
| 5927 | pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i); |
| 5928 | break; |
| 5929 | } |
| 5930 | } |
| 5931 | return; |
| 5932 | } |
| 5933 | |
| 5934 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 5935 | static struct net_device_ops wlan_drv_ops = { |
| 5936 | .ndo_open = hdd_open, |
| 5937 | .ndo_stop = hdd_stop, |
| 5938 | .ndo_uninit = hdd_uninit, |
| 5939 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 5940 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5941 | .ndo_get_stats = hdd_stats, |
| 5942 | .ndo_do_ioctl = hdd_ioctl, |
| 5943 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5944 | .ndo_select_queue = hdd_select_queue, |
| 5945 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 5946 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) |
| 5947 | .ndo_set_rx_mode = hdd_set_multicast_list, |
| 5948 | #else |
| 5949 | .ndo_set_multicast_list = hdd_set_multicast_list, |
| 5950 | #endif //LINUX_VERSION_CODE |
| 5951 | #endif |
| 5952 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5953 | static struct net_device_ops wlan_mon_drv_ops = { |
| 5954 | .ndo_open = hdd_mon_open, |
| 5955 | .ndo_stop = hdd_stop, |
| 5956 | .ndo_uninit = hdd_uninit, |
| 5957 | .ndo_start_xmit = hdd_mon_hard_start_xmit, |
| 5958 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5959 | .ndo_get_stats = hdd_stats, |
| 5960 | .ndo_do_ioctl = hdd_ioctl, |
| 5961 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5962 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5963 | |
| 5964 | #endif |
| 5965 | |
| 5966 | void hdd_set_station_ops( struct net_device *pWlanDev ) |
| 5967 | { |
| 5968 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5969 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 5970 | #else |
| 5971 | pWlanDev->open = hdd_open; |
| 5972 | pWlanDev->stop = hdd_stop; |
| 5973 | pWlanDev->uninit = hdd_uninit; |
| 5974 | pWlanDev->hard_start_xmit = NULL; |
| 5975 | pWlanDev->tx_timeout = hdd_tx_timeout; |
| 5976 | pWlanDev->get_stats = hdd_stats; |
| 5977 | pWlanDev->do_ioctl = hdd_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5978 | pWlanDev->set_mac_address = hdd_set_mac_address; |
| 5979 | #endif |
| 5980 | } |
| 5981 | |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 5982 | 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] | 5983 | { |
| 5984 | struct net_device *pWlanDev = NULL; |
| 5985 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5986 | /* |
| 5987 | * cfg80211 initialization and registration.... |
| 5988 | */ |
| 5989 | pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, ether_setup, NUM_TX_QUEUES); |
| 5990 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5991 | if(pWlanDev != NULL) |
| 5992 | { |
| 5993 | |
| 5994 | //Save the pointer to the net_device in the HDD adapter |
| 5995 | pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev ); |
| 5996 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5997 | vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) ); |
| 5998 | |
| 5999 | pAdapter->dev = pWlanDev; |
| 6000 | pAdapter->pHddCtx = pHddCtx; |
| 6001 | pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 6002 | spin_lock_init(&pAdapter->lock_for_active_session); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6003 | |
| 6004 | init_completion(&pAdapter->session_open_comp_var); |
| 6005 | init_completion(&pAdapter->session_close_comp_var); |
| 6006 | init_completion(&pAdapter->disconnect_comp_var); |
| 6007 | init_completion(&pAdapter->linkup_event_var); |
| 6008 | init_completion(&pAdapter->cancel_rem_on_chan_var); |
| 6009 | init_completion(&pAdapter->rem_on_chan_ready_event); |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 6010 | init_completion(&pAdapter->pno_comp_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6011 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6012 | init_completion(&pAdapter->offchannel_tx_event); |
| 6013 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6014 | init_completion(&pAdapter->tx_action_cnf_event); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6015 | #ifdef FEATURE_WLAN_TDLS |
| 6016 | init_completion(&pAdapter->tdls_add_station_comp); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 6017 | init_completion(&pAdapter->tdls_del_station_comp); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6018 | init_completion(&pAdapter->tdls_mgmt_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 6019 | init_completion(&pAdapter->tdls_link_establish_req_comp); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6020 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6021 | init_completion(&pHddCtx->mc_sus_event_var); |
| 6022 | init_completion(&pHddCtx->tx_sus_event_var); |
Gopichand Nakkala | 0562141 | 2013-06-19 19:37:38 +0530 | [diff] [blame] | 6023 | init_completion(&pHddCtx->rx_sus_event_var); |
Jeff Johnson | 9efb9aa | 2013-03-15 13:59:27 -0700 | [diff] [blame] | 6024 | init_completion(&pAdapter->ula_complete); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 6025 | init_completion(&pAdapter->change_country_code); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6026 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6027 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 6028 | init_completion(&pAdapter->hdd_set_batch_scan_req_var); |
| 6029 | init_completion(&pAdapter->hdd_get_batch_scan_req_var); |
| 6030 | pAdapter->pBatchScanRsp = NULL; |
| 6031 | pAdapter->numScanList = 0; |
Rajeev Kumar | 20140c1 | 2013-10-21 19:39:02 -0700 | [diff] [blame] | 6032 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 6033 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6034 | mutex_init(&pAdapter->hdd_batch_scan_lock); |
| 6035 | #endif |
| 6036 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6037 | pAdapter->isLinkUpSvcNeeded = FALSE; |
| 6038 | pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE; |
| 6039 | //Init the net_device structure |
| 6040 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 6041 | |
| 6042 | vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr)); |
| 6043 | vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr)); |
| 6044 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 6045 | pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM; |
| 6046 | |
| 6047 | hdd_set_station_ops( pAdapter->dev ); |
| 6048 | |
| 6049 | pWlanDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6050 | pWlanDev->ieee80211_ptr = &pAdapter->wdev ; |
| 6051 | pAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 6052 | pAdapter->wdev.netdev = pWlanDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6053 | /* set pWlanDev's parent to underlying device */ |
| 6054 | SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev); |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 6055 | |
| 6056 | hdd_wmm_init( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6057 | } |
| 6058 | |
| 6059 | return pAdapter; |
| 6060 | } |
| 6061 | |
| 6062 | VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 6063 | { |
| 6064 | struct net_device *pWlanDev = pAdapter->dev; |
| 6065 | //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 6066 | //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 6067 | //eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 6068 | |
| 6069 | if( rtnl_lock_held ) |
| 6070 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 6071 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6072 | if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 ) |
| 6073 | { |
| 6074 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__); |
| 6075 | return VOS_STATUS_E_FAILURE; |
| 6076 | } |
| 6077 | } |
| 6078 | if (register_netdevice(pWlanDev)) |
| 6079 | { |
| 6080 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__); |
| 6081 | return VOS_STATUS_E_FAILURE; |
| 6082 | } |
| 6083 | } |
| 6084 | else |
| 6085 | { |
| 6086 | if(register_netdev(pWlanDev)) |
| 6087 | { |
| 6088 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__); |
| 6089 | return VOS_STATUS_E_FAILURE; |
| 6090 | } |
| 6091 | } |
| 6092 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 6093 | |
| 6094 | return VOS_STATUS_SUCCESS; |
| 6095 | } |
| 6096 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6097 | static eHalStatus hdd_smeCloseSessionCallback(void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6098 | { |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6099 | hdd_adapter_t *pAdapter = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6100 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6101 | if (NULL == pAdapter) |
| 6102 | { |
| 6103 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__); |
| 6104 | return eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6105 | } |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6106 | |
| 6107 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 6108 | { |
| 6109 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__); |
| 6110 | return eHAL_STATUS_NOT_INITIALIZED; |
| 6111 | } |
| 6112 | |
| 6113 | clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags); |
| 6114 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6115 | #ifndef WLAN_OPEN_SOURCE |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6116 | /* need to make sure all of our scheduled work has completed. |
| 6117 | * This callback is called from MC thread context, so it is safe to |
| 6118 | * to call below flush workqueue API from here. |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6119 | * |
| 6120 | * Even though this is called from MC thread context, if there is a faulty |
| 6121 | * work item in the system, that can hang this call forever. So flushing |
| 6122 | * this global work queue is not safe; and now we make sure that |
| 6123 | * individual work queues are stopped correctly. But the cancel work queue |
| 6124 | * is a GPL only API, so the proprietary version of the driver would still |
| 6125 | * rely on the global work queue flush. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6126 | */ |
| 6127 | flush_scheduled_work(); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6128 | #endif |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6129 | |
| 6130 | /* We can be blocked while waiting for scheduled work to be |
| 6131 | * flushed, and the adapter structure can potentially be freed, in |
| 6132 | * which case the magic will have been reset. So make sure the |
| 6133 | * magic is still good, and hence the adapter structure is still |
| 6134 | * valid, before signaling completion */ |
| 6135 | if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic) |
| 6136 | { |
| 6137 | complete(&pAdapter->session_close_comp_var); |
| 6138 | } |
| 6139 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6140 | return eHAL_STATUS_SUCCESS; |
| 6141 | } |
| 6142 | |
| 6143 | VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter ) |
| 6144 | { |
| 6145 | struct net_device *pWlanDev = pAdapter->dev; |
| 6146 | hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 6147 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 6148 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 6149 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6150 | long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6151 | |
| 6152 | INIT_COMPLETION(pAdapter->session_open_comp_var); |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 6153 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6154 | //Open a SME session for future operation |
| 6155 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 6156 | (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6157 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 6158 | { |
| 6159 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6160 | "sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6161 | halStatus, halStatus ); |
| 6162 | status = VOS_STATUS_E_FAILURE; |
| 6163 | goto error_sme_open; |
| 6164 | } |
| 6165 | |
| 6166 | //Block on a completion variable. Can't wait forever though. |
Vinay Krishna Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 6167 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6168 | &pAdapter->session_open_comp_var, |
| 6169 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6170 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6171 | { |
| 6172 | hddLog(VOS_TRACE_LEVEL_FATAL, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6173 | "Session is not opened within timeout period code %ld", rc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6174 | status = VOS_STATUS_E_FAILURE; |
| 6175 | goto error_sme_open; |
| 6176 | } |
| 6177 | |
| 6178 | // Register wireless extensions |
| 6179 | if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev))) |
| 6180 | { |
| 6181 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6182 | "hdd_register_wext() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6183 | halStatus, halStatus ); |
| 6184 | status = VOS_STATUS_E_FAILURE; |
| 6185 | goto error_register_wext; |
| 6186 | } |
| 6187 | //Safe to register the hard_start_xmit function again |
| 6188 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 6189 | wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit; |
| 6190 | #else |
| 6191 | pWlanDev->hard_start_xmit = hdd_hard_start_xmit; |
| 6192 | #endif |
| 6193 | |
| 6194 | //Set the Connection State to Not Connected |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 6195 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6196 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 6197 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6198 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 6199 | |
| 6200 | //Set the default operation channel |
| 6201 | pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel; |
| 6202 | |
| 6203 | /* Make the default Auth Type as OPEN*/ |
| 6204 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6205 | |
| 6206 | if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) ) |
| 6207 | { |
| 6208 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6209 | "hdd_init_tx_rx() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6210 | status, status ); |
| 6211 | goto error_init_txrx; |
| 6212 | } |
| 6213 | |
| 6214 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6215 | |
| 6216 | if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) ) |
| 6217 | { |
| 6218 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6219 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6220 | status, status ); |
| 6221 | goto error_wmm_init; |
| 6222 | } |
| 6223 | |
| 6224 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6225 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6226 | #ifdef FEATURE_WLAN_TDLS |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 6227 | if(0 != wlan_hdd_sta_tdls_init(pAdapter)) |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6228 | { |
| 6229 | status = VOS_STATUS_E_FAILURE; |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 6230 | 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] | 6231 | goto error_tdls_init; |
| 6232 | } |
| 6233 | set_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 6234 | #endif |
| 6235 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6236 | return VOS_STATUS_SUCCESS; |
| 6237 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6238 | #ifdef FEATURE_WLAN_TDLS |
| 6239 | error_tdls_init: |
| 6240 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6241 | hdd_wmm_adapter_close(pAdapter); |
| 6242 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6243 | error_wmm_init: |
| 6244 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6245 | hdd_deinit_tx_rx(pAdapter); |
| 6246 | error_init_txrx: |
| 6247 | hdd_UnregisterWext(pWlanDev); |
| 6248 | error_register_wext: |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6249 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6250 | { |
| 6251 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6252 | if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6253 | pAdapter->sessionId, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6254 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6255 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6256 | unsigned long rc; |
| 6257 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6258 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6259 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6260 | &pAdapter->session_close_comp_var, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6261 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6262 | if (rc <= 0) |
| 6263 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6264 | FL("Session is not opened within timeout period code %ld"), rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6265 | } |
| 6266 | } |
| 6267 | error_sme_open: |
| 6268 | return status; |
| 6269 | } |
| 6270 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6271 | void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 6272 | { |
| 6273 | hdd_cfg80211_state_t *cfgState; |
| 6274 | |
| 6275 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 6276 | |
| 6277 | if( NULL != cfgState->buf ) |
| 6278 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6279 | long rc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6280 | INIT_COMPLETION(pAdapter->tx_action_cnf_event); |
| 6281 | rc = wait_for_completion_interruptible_timeout( |
| 6282 | &pAdapter->tx_action_cnf_event, |
| 6283 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6284 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6285 | { |
Sudhir Sattayappa Kohalli | 8ee532d | 2013-02-15 13:16:26 -0800 | [diff] [blame] | 6286 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6287 | "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld" |
| 6288 | , __func__, rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6289 | } |
| 6290 | } |
| 6291 | return; |
| 6292 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6293 | |
| 6294 | void hdd_deinit_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 6295 | { |
| 6296 | ENTER(); |
| 6297 | switch ( pAdapter->device_mode ) |
| 6298 | { |
| 6299 | case WLAN_HDD_INFRA_STATION: |
| 6300 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6301 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6302 | { |
| 6303 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 6304 | { |
| 6305 | hdd_deinit_tx_rx( pAdapter ); |
| 6306 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6307 | } |
| 6308 | |
| 6309 | if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6310 | { |
| 6311 | hdd_wmm_adapter_close( pAdapter ); |
| 6312 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6313 | } |
| 6314 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6315 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6316 | #ifdef FEATURE_WLAN_TDLS |
| 6317 | if(test_bit(TDLS_INIT_DONE, &pAdapter->event_flags)) |
| 6318 | { |
| 6319 | wlan_hdd_tdls_exit(pAdapter); |
| 6320 | clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 6321 | } |
| 6322 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6323 | |
| 6324 | break; |
| 6325 | } |
| 6326 | |
| 6327 | case WLAN_HDD_SOFTAP: |
| 6328 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6329 | { |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 6330 | |
| 6331 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6332 | { |
| 6333 | hdd_wmm_adapter_close( pAdapter ); |
| 6334 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6335 | } |
| 6336 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6337 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6338 | |
| 6339 | hdd_unregister_hostapd(pAdapter); |
| 6340 | hdd_set_conparam( 0 ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6341 | wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), NULL ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6342 | break; |
| 6343 | } |
| 6344 | |
| 6345 | case WLAN_HDD_MONITOR: |
| 6346 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6347 | hdd_adapter_t* pAdapterforTx = pAdapter->sessionCtx.monitor.pAdapterForTx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6348 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 6349 | { |
| 6350 | hdd_deinit_tx_rx( pAdapter ); |
| 6351 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6352 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6353 | if(NULL != pAdapterforTx) |
| 6354 | { |
| 6355 | hdd_cleanup_actionframe(pHddCtx, pAdapterforTx); |
| 6356 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6357 | break; |
| 6358 | } |
| 6359 | |
| 6360 | |
| 6361 | default: |
| 6362 | break; |
| 6363 | } |
| 6364 | |
| 6365 | EXIT(); |
| 6366 | } |
| 6367 | |
| 6368 | void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
| 6369 | { |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 6370 | struct net_device *pWlanDev = NULL; |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6371 | |
| 6372 | ENTER(); |
| 6373 | if (NULL == pAdapter) |
| 6374 | { |
| 6375 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6376 | "%s: HDD adapter is Null", __func__); |
| 6377 | return; |
| 6378 | } |
| 6379 | |
| 6380 | pWlanDev = pAdapter->dev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6381 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6382 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6383 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 6384 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6385 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6386 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
| 6387 | ) |
| 6388 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6389 | if (pAdapter) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6390 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6391 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 6392 | { |
| 6393 | hdd_deinit_batch_scan(pAdapter); |
| 6394 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6395 | } |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6396 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6397 | #endif |
| 6398 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6399 | if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) { |
| 6400 | if( rtnl_held ) |
| 6401 | { |
| 6402 | unregister_netdevice(pWlanDev); |
| 6403 | } |
| 6404 | else |
| 6405 | { |
| 6406 | unregister_netdev(pWlanDev); |
| 6407 | } |
| 6408 | // note that the pAdapter is no longer valid at this point |
| 6409 | // since the memory has been reclaimed |
| 6410 | } |
| 6411 | |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6412 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6413 | } |
| 6414 | |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6415 | void hdd_set_pwrparams(hdd_context_t *pHddCtx) |
| 6416 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6417 | VOS_STATUS status; |
| 6418 | hdd_adapter_t *pAdapter = NULL; |
| 6419 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6420 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6421 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6422 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6423 | /*loop through all adapters.*/ |
| 6424 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6425 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6426 | pAdapter = pAdapterNode->pAdapter; |
| 6427 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 6428 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6429 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6430 | { // we skip this registration for modes other than STA and P2P client modes. |
| 6431 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6432 | pAdapterNode = pNext; |
| 6433 | continue; |
| 6434 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6435 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6436 | //Apply Dynamic DTIM For P2P |
| 6437 | //Only if ignoreDynamicDtimInP2pMode is not set in ini |
| 6438 | if ((pHddCtx->cfg_ini->enableDynamicDTIM || |
| 6439 | pHddCtx->cfg_ini->enableModulatedDTIM) && |
| 6440 | ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 6441 | ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) && |
| 6442 | !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) && |
| 6443 | (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) && |
| 6444 | (eConnectionState_Associated == |
| 6445 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) && |
| 6446 | (pHddCtx->cfg_ini->fIsBmpsEnabled)) |
| 6447 | { |
| 6448 | tSirSetPowerParamsReq powerRequest = { 0 }; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6449 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6450 | powerRequest.uIgnoreDTIM = 1; |
| 6451 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
| 6452 | |
| 6453 | if (pHddCtx->cfg_ini->enableModulatedDTIM) |
| 6454 | { |
| 6455 | powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM; |
| 6456 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
| 6457 | } |
| 6458 | else |
| 6459 | { |
| 6460 | powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM; |
| 6461 | } |
| 6462 | |
| 6463 | /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM |
| 6464 | * specified during Enter/Exit BMPS when LCD off*/ |
| 6465 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6466 | NULL, eANI_BOOLEAN_FALSE); |
| 6467 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6468 | NULL, eANI_BOOLEAN_FALSE); |
| 6469 | |
| 6470 | /* switch to the DTIM specified in cfg.ini */ |
| 6471 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6472 | "Switch to DTIM %d", powerRequest.uListenInterval); |
| 6473 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6474 | break; |
| 6475 | |
| 6476 | } |
| 6477 | |
| 6478 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6479 | pAdapterNode = pNext; |
| 6480 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6481 | } |
| 6482 | |
| 6483 | void hdd_reset_pwrparams(hdd_context_t *pHddCtx) |
| 6484 | { |
| 6485 | /*Switch back to DTIM 1*/ |
| 6486 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 6487 | |
| 6488 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 6489 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 6490 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6491 | |
| 6492 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 6493 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6494 | NULL, eANI_BOOLEAN_FALSE); |
| 6495 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6496 | NULL, eANI_BOOLEAN_FALSE); |
| 6497 | |
| 6498 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6499 | "Switch to DTIM%d",powerRequest.uListenInterval); |
| 6500 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6501 | |
| 6502 | } |
| 6503 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6504 | VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx) |
| 6505 | { |
| 6506 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 6507 | |
| 6508 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6509 | { |
| 6510 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6511 | } |
| 6512 | |
| 6513 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6514 | { |
| 6515 | sme_StartAutoBmpsTimer(pHddCtx->hHal); |
| 6516 | } |
| 6517 | |
| 6518 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6519 | { |
| 6520 | sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6521 | } |
| 6522 | |
| 6523 | return status; |
| 6524 | } |
| 6525 | |
| 6526 | VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type) |
| 6527 | { |
| 6528 | hdd_adapter_t *pAdapter = NULL; |
| 6529 | eHalStatus halStatus; |
| 6530 | VOS_STATUS status = VOS_STATUS_E_INVAL; |
| 6531 | v_BOOL_t disableBmps = FALSE; |
| 6532 | v_BOOL_t disableImps = FALSE; |
| 6533 | |
| 6534 | switch(session_type) |
| 6535 | { |
| 6536 | case WLAN_HDD_INFRA_STATION: |
| 6537 | case WLAN_HDD_SOFTAP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6538 | case WLAN_HDD_P2P_CLIENT: |
| 6539 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6540 | //Exit BMPS -> Is Sta/P2P Client is already connected |
| 6541 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6542 | if((NULL != pAdapter)&& |
| 6543 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6544 | { |
| 6545 | disableBmps = TRUE; |
| 6546 | } |
| 6547 | |
| 6548 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 6549 | if((NULL != pAdapter)&& |
| 6550 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6551 | { |
| 6552 | disableBmps = TRUE; |
| 6553 | } |
| 6554 | |
| 6555 | //Exit both Bmps and Imps incase of Go/SAP Mode |
| 6556 | if((WLAN_HDD_SOFTAP == session_type) || |
| 6557 | (WLAN_HDD_P2P_GO == session_type)) |
| 6558 | { |
| 6559 | disableBmps = TRUE; |
| 6560 | disableImps = TRUE; |
| 6561 | } |
| 6562 | |
| 6563 | if(TRUE == disableImps) |
| 6564 | { |
| 6565 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6566 | { |
| 6567 | sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6568 | } |
| 6569 | } |
| 6570 | |
| 6571 | if(TRUE == disableBmps) |
| 6572 | { |
| 6573 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6574 | { |
| 6575 | halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6576 | |
| 6577 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6578 | { |
| 6579 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6580 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6581 | VOS_ASSERT(0); |
| 6582 | return status; |
| 6583 | } |
| 6584 | } |
| 6585 | |
| 6586 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6587 | { |
| 6588 | halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal); |
| 6589 | |
| 6590 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6591 | { |
| 6592 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6593 | 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] | 6594 | VOS_ASSERT(0); |
| 6595 | return status; |
| 6596 | } |
| 6597 | } |
| 6598 | } |
| 6599 | |
| 6600 | if((TRUE == disableBmps) || |
| 6601 | (TRUE == disableImps)) |
| 6602 | { |
| 6603 | /* Now, get the chip into Full Power now */ |
| 6604 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 6605 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk, |
| 6606 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 6607 | |
| 6608 | if(halStatus != eHAL_STATUS_SUCCESS) |
| 6609 | { |
| 6610 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 6611 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6612 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6613 | //Block on a completion variable. Can't wait forever though |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6614 | ret = wait_for_completion_interruptible_timeout( |
| 6615 | &pHddCtx->full_pwr_comp_var, |
| 6616 | msecs_to_jiffies(1000)); |
| 6617 | if (ret <= 0) |
| 6618 | { |
| 6619 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6620 | "%s: wait on full_pwr_comp_var failed %ld", |
| 6621 | __func__, ret); |
| 6622 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6623 | } |
| 6624 | else |
| 6625 | { |
| 6626 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6627 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6628 | VOS_ASSERT(0); |
| 6629 | return status; |
| 6630 | } |
| 6631 | } |
| 6632 | |
| 6633 | status = VOS_STATUS_SUCCESS; |
| 6634 | } |
| 6635 | |
| 6636 | break; |
| 6637 | } |
| 6638 | return status; |
| 6639 | } |
| 6640 | |
| 6641 | 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] | 6642 | const char *iface_name, tSirMacAddr macAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6643 | tANI_U8 rtnl_held ) |
| 6644 | { |
Vinay Krishna Eranna | 83b0ef7 | 2014-11-19 16:56:20 +0530 | [diff] [blame] | 6645 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6646 | hdd_adapter_t *pAdapter = NULL; |
| 6647 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
| 6648 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 6649 | VOS_STATUS exitbmpsStatus; |
| 6650 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6651 | 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] | 6652 | |
Nirav Shah | 436658f | 2014-02-28 17:05:45 +0530 | [diff] [blame] | 6653 | if(macAddr == NULL) |
| 6654 | { |
| 6655 | /* Not received valid macAddr */ |
| 6656 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6657 | "%s:Unable to add virtual intf: Not able to get" |
| 6658 | "valid mac address",__func__); |
| 6659 | return NULL; |
| 6660 | } |
| 6661 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6662 | //Disable BMPS incase of Concurrency |
| 6663 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type); |
| 6664 | |
| 6665 | if(VOS_STATUS_E_FAILURE == exitbmpsStatus) |
| 6666 | { |
| 6667 | //Fail to Exit BMPS |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6668 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6669 | VOS_ASSERT(0); |
| 6670 | return NULL; |
| 6671 | } |
| 6672 | |
| 6673 | switch(session_type) |
| 6674 | { |
| 6675 | case WLAN_HDD_INFRA_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6676 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6677 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6678 | { |
| 6679 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6680 | |
| 6681 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6682 | { |
| 6683 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6684 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6685 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6686 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6687 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6688 | #ifdef FEATURE_WLAN_TDLS |
| 6689 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6690 | * protect the concurrent access for the Adapters by TDLS module. |
| 6691 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6692 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6693 | #endif |
| 6694 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6695 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ? |
| 6696 | NL80211_IFTYPE_P2P_CLIENT: |
| 6697 | NL80211_IFTYPE_STATION; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6698 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6699 | pAdapter->device_mode = session_type; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6700 | #ifdef FEATURE_WLAN_TDLS |
| 6701 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6702 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 6703 | |
| 6704 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6705 | if( VOS_STATUS_SUCCESS != status ) |
| 6706 | goto err_free_netdev; |
| 6707 | |
| 6708 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6709 | if( VOS_STATUS_SUCCESS != status ) |
| 6710 | { |
| 6711 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 6712 | goto err_free_netdev; |
| 6713 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6714 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6715 | // Workqueue which gets scheduled in IPv4 notification callback. |
| 6716 | INIT_WORK(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue); |
Vinay Krishna Eranna | 83b0ef7 | 2014-11-19 16:56:20 +0530 | [diff] [blame] | 6717 | // Register IPv4 notifier to notify if any change in IP |
| 6718 | // So that we can reconfigure the offload parameters |
| 6719 | pAdapter->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6720 | ret = register_inetaddr_notifier(&pAdapter->ipv4_notifier); |
| 6721 | if (ret) |
| 6722 | { |
| 6723 | hddLog(LOGE, FL("Failed to register IPv4 notifier")); |
| 6724 | } |
| 6725 | else |
| 6726 | { |
| 6727 | hddLog(LOG1, FL("Registered IPv4 notifier")); |
| 6728 | pAdapter->ipv4_notifier_registered = true; |
| 6729 | } |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6730 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6731 | #ifdef WLAN_NS_OFFLOAD |
| 6732 | // Workqueue which gets scheduled in IPv6 notification callback. |
| 6733 | INIT_WORK(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue); |
Vinay Krishna Eranna | 83b0ef7 | 2014-11-19 16:56:20 +0530 | [diff] [blame] | 6734 | // Register IPv6 notifier to notify if any change in IP |
| 6735 | // So that we can reconfigure the offload parameters |
| 6736 | pAdapter->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6737 | ret = register_inet6addr_notifier(&pAdapter->ipv6_notifier); |
| 6738 | if (ret) |
| 6739 | { |
| 6740 | hddLog(LOGE, FL("Failed to register IPv6 notifier")); |
| 6741 | } |
| 6742 | else |
| 6743 | { |
| 6744 | hddLog(LOG1, FL("Registered IPv6 notifier")); |
| 6745 | pAdapter->ipv6_notifier_registered = true; |
| 6746 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6747 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6748 | //Stop the Interface TX queue. |
| 6749 | netif_tx_disable(pAdapter->dev); |
| 6750 | //netif_tx_disable(pWlanDev); |
| 6751 | netif_carrier_off(pAdapter->dev); |
| 6752 | |
| 6753 | break; |
| 6754 | } |
| 6755 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6756 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6757 | case WLAN_HDD_SOFTAP: |
| 6758 | { |
| 6759 | pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name ); |
| 6760 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6761 | { |
| 6762 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6763 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6764 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6765 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6766 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6767 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ? |
| 6768 | NL80211_IFTYPE_AP: |
| 6769 | NL80211_IFTYPE_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6770 | pAdapter->device_mode = session_type; |
| 6771 | |
| 6772 | status = hdd_init_ap_mode(pAdapter); |
| 6773 | if( VOS_STATUS_SUCCESS != status ) |
| 6774 | goto err_free_netdev; |
| 6775 | |
| 6776 | status = hdd_register_hostapd( pAdapter, rtnl_held ); |
| 6777 | if( VOS_STATUS_SUCCESS != status ) |
| 6778 | { |
| 6779 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 6780 | goto err_free_netdev; |
| 6781 | } |
| 6782 | |
| 6783 | netif_tx_disable(pAdapter->dev); |
| 6784 | netif_carrier_off(pAdapter->dev); |
| 6785 | |
| 6786 | hdd_set_conparam( 1 ); |
| 6787 | break; |
| 6788 | } |
| 6789 | case WLAN_HDD_MONITOR: |
| 6790 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6791 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6792 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6793 | { |
| 6794 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6795 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6796 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6797 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6798 | |
| 6799 | pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
| 6800 | pAdapter->device_mode = session_type; |
| 6801 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6802 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 6803 | pAdapter->dev->netdev_ops = &wlan_mon_drv_ops; |
| 6804 | #else |
| 6805 | pAdapter->dev->open = hdd_mon_open; |
| 6806 | pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit; |
| 6807 | #endif |
| 6808 | hdd_init_tx_rx( pAdapter ); |
| 6809 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6810 | //Set adapter to be used for data tx. It will use either GO or softap. |
| 6811 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6812 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_SOFTAP); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6813 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) |
| 6814 | { |
| 6815 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6816 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_GO); |
| 6817 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6818 | /* This workqueue will be used to transmit management packet over |
| 6819 | * monitor interface. */ |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6820 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) { |
| 6821 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:hdd_get_adapter",__func__); |
| 6822 | return NULL; |
| 6823 | } |
Madan Mohan Koyyalamudi | 9f40ceb | 2012-10-18 19:22:56 -0700 | [diff] [blame] | 6824 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6825 | INIT_WORK(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue, |
| 6826 | hdd_mon_tx_work_queue); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6827 | } |
| 6828 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6829 | case WLAN_HDD_FTM: |
| 6830 | { |
| 6831 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6832 | |
| 6833 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6834 | { |
| 6835 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6836 | FL("failed to allocate adapter for session %d"), session_type); |
| 6837 | return NULL; |
| 6838 | } |
| 6839 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6840 | /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning |
| 6841 | * message while loading driver in FTM mode. */ |
| 6842 | pAdapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 6843 | pAdapter->device_mode = session_type; |
| 6844 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 6845 | |
| 6846 | hdd_init_tx_rx( pAdapter ); |
| 6847 | |
| 6848 | //Stop the Interface TX queue. |
| 6849 | netif_tx_disable(pAdapter->dev); |
| 6850 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6851 | } |
| 6852 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6853 | default: |
| 6854 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6855 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d", |
| 6856 | __func__, session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6857 | VOS_ASSERT(0); |
| 6858 | return NULL; |
| 6859 | } |
| 6860 | } |
| 6861 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6862 | if( VOS_STATUS_SUCCESS == status ) |
| 6863 | { |
| 6864 | //Add it to the hdd's session list. |
| 6865 | pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) ); |
| 6866 | if( NULL == pHddAdapterNode ) |
| 6867 | { |
| 6868 | status = VOS_STATUS_E_NOMEM; |
| 6869 | } |
| 6870 | else |
| 6871 | { |
| 6872 | pHddAdapterNode->pAdapter = pAdapter; |
| 6873 | status = hdd_add_adapter_back ( pHddCtx, |
| 6874 | pHddAdapterNode ); |
| 6875 | } |
| 6876 | } |
| 6877 | |
| 6878 | if( VOS_STATUS_SUCCESS != status ) |
| 6879 | { |
| 6880 | if( NULL != pAdapter ) |
| 6881 | { |
| 6882 | hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held ); |
| 6883 | pAdapter = NULL; |
| 6884 | } |
| 6885 | if( NULL != pHddAdapterNode ) |
| 6886 | { |
| 6887 | vos_mem_free( pHddAdapterNode ); |
| 6888 | } |
| 6889 | |
| 6890 | goto resume_bmps; |
| 6891 | } |
| 6892 | |
| 6893 | if(VOS_STATUS_SUCCESS == status) |
| 6894 | { |
| 6895 | wlan_hdd_set_concurrency_mode(pHddCtx, session_type); |
| 6896 | |
Madan Mohan Koyyalamudi | 96dd30d | 2012-10-05 17:24:51 -0700 | [diff] [blame] | 6897 | //Initialize the WoWL service |
| 6898 | if(!hdd_init_wowl(pAdapter)) |
| 6899 | { |
| 6900 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__); |
| 6901 | goto err_free_netdev; |
| 6902 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6903 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6904 | return pAdapter; |
| 6905 | |
| 6906 | err_free_netdev: |
| 6907 | free_netdev(pAdapter->dev); |
| 6908 | wlan_hdd_release_intf_addr( pHddCtx, |
| 6909 | pAdapter->macAddressCurrent.bytes ); |
| 6910 | |
| 6911 | resume_bmps: |
| 6912 | //If bmps disabled enable it |
| 6913 | if(VOS_STATUS_SUCCESS == exitbmpsStatus) |
| 6914 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6915 | if (pHddCtx->hdd_wlan_suspended) |
| 6916 | { |
| 6917 | hdd_set_pwrparams(pHddCtx); |
| 6918 | } |
| 6919 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6920 | } |
| 6921 | return NULL; |
| 6922 | } |
| 6923 | |
| 6924 | VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 6925 | tANI_U8 rtnl_held ) |
| 6926 | { |
| 6927 | hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext; |
| 6928 | VOS_STATUS status; |
| 6929 | |
| 6930 | status = hdd_get_front_adapter ( pHddCtx, &pCurrent ); |
| 6931 | if( VOS_STATUS_SUCCESS != status ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6932 | { |
| 6933 | hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d", |
| 6934 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6935 | return status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6936 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6937 | |
| 6938 | while ( pCurrent->pAdapter != pAdapter ) |
| 6939 | { |
| 6940 | status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext ); |
| 6941 | if( VOS_STATUS_SUCCESS != status ) |
| 6942 | break; |
| 6943 | |
| 6944 | pCurrent = pNext; |
| 6945 | } |
| 6946 | pAdapterNode = pCurrent; |
| 6947 | if( VOS_STATUS_SUCCESS == status ) |
| 6948 | { |
| 6949 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 6950 | hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6951 | |
| 6952 | #ifdef FEATURE_WLAN_TDLS |
| 6953 | |
| 6954 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6955 | * protect the concurrent access for the Adapters by TDLS module. |
| 6956 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6957 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6958 | #endif |
| 6959 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6960 | hdd_remove_adapter( pHddCtx, pAdapterNode ); |
| 6961 | vos_mem_free( pAdapterNode ); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6962 | pAdapterNode = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6963 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6964 | #ifdef FEATURE_WLAN_TDLS |
| 6965 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6966 | #endif |
| 6967 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6968 | |
| 6969 | /* 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] | 6970 | if ((!vos_concurrent_open_sessions_running()) && |
| 6971 | ((pHddCtx->no_of_open_sessions[VOS_STA_MODE] >= 1) || |
| 6972 | (pHddCtx->no_of_open_sessions[VOS_P2P_CLIENT_MODE] >= 1))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6973 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6974 | if (pHddCtx->hdd_wlan_suspended) |
| 6975 | { |
| 6976 | hdd_set_pwrparams(pHddCtx); |
| 6977 | } |
| 6978 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6979 | } |
| 6980 | |
| 6981 | return VOS_STATUS_SUCCESS; |
| 6982 | } |
| 6983 | |
| 6984 | return VOS_STATUS_E_FAILURE; |
| 6985 | } |
| 6986 | |
| 6987 | VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx ) |
| 6988 | { |
| 6989 | hdd_adapter_list_node_t *pHddAdapterNode; |
| 6990 | VOS_STATUS status; |
| 6991 | |
| 6992 | ENTER(); |
| 6993 | |
| 6994 | do |
| 6995 | { |
| 6996 | status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode ); |
| 6997 | if( pHddAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6998 | { |
| 6999 | hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE ); |
| 7000 | vos_mem_free( pHddAdapterNode ); |
| 7001 | } |
| 7002 | }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status ); |
| 7003 | |
| 7004 | EXIT(); |
| 7005 | |
| 7006 | return VOS_STATUS_SUCCESS; |
| 7007 | } |
| 7008 | |
| 7009 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter) |
| 7010 | { |
| 7011 | v_U8_t addIE[1] = {0}; |
| 7012 | |
| 7013 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 7014 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL, |
| 7015 | eANI_BOOLEAN_FALSE) ) |
| 7016 | { |
| 7017 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7018 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7019 | } |
| 7020 | |
| 7021 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 7022 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 7023 | eANI_BOOLEAN_FALSE) ) |
| 7024 | { |
| 7025 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7026 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7027 | } |
| 7028 | |
| 7029 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 7030 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 7031 | eANI_BOOLEAN_FALSE) ) |
| 7032 | { |
| 7033 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7034 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7035 | } |
| 7036 | } |
| 7037 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7038 | VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 7039 | const v_BOOL_t bCloseSession ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7040 | { |
| 7041 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 7042 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7043 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7044 | union iwreq_data wrqu; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7045 | v_U8_t retry = 0; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7046 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7047 | |
| 7048 | ENTER(); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7049 | pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7050 | switch(pAdapter->device_mode) |
| 7051 | { |
| 7052 | case WLAN_HDD_INFRA_STATION: |
| 7053 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7054 | case WLAN_HDD_P2P_DEVICE: |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 7055 | { |
| 7056 | hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7057 | if( hdd_connIsConnected(pstation) || |
| 7058 | (pstation->conn_info.connState == eConnectionState_Connecting) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7059 | { |
| 7060 | if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 7061 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 7062 | pAdapter->sessionId, |
| 7063 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 7064 | else |
| 7065 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 7066 | pAdapter->sessionId, |
| 7067 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7068 | //success implies disconnect command got queued up successfully |
| 7069 | if(halStatus == eHAL_STATUS_SUCCESS) |
| 7070 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7071 | ret = wait_for_completion_interruptible_timeout( |
| 7072 | &pAdapter->disconnect_comp_var, |
| 7073 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 7074 | if (ret <= 0) |
| 7075 | { |
| 7076 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7077 | "%s: wait on disconnect_comp_var failed %ld", |
| 7078 | __func__, ret); |
| 7079 | } |
| 7080 | } |
| 7081 | else |
| 7082 | { |
| 7083 | hddLog(LOGE, "%s: failed to post disconnect event to SME", |
| 7084 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7085 | } |
| 7086 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 7087 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 7088 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 7089 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
| 7090 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 7091 | else if(pstation->conn_info.connState == |
| 7092 | eConnectionState_Disconnecting) |
| 7093 | { |
| 7094 | ret = wait_for_completion_interruptible_timeout( |
| 7095 | &pAdapter->disconnect_comp_var, |
| 7096 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 7097 | if (ret <= 0) |
| 7098 | { |
| 7099 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7100 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 7101 | } |
| 7102 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7103 | else if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7104 | { |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7105 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 7106 | eCSR_SCAN_ABORT_DEFAULT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7107 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7108 | if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION) |
| 7109 | { |
| 7110 | while (pAdapter->is_roc_inprogress) |
| 7111 | { |
| 7112 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7113 | "%s: ROC in progress for session %d!!!", |
| 7114 | __func__, pAdapter->sessionId); |
| 7115 | // waiting for ROC to expire |
| 7116 | msleep(500); |
| 7117 | /* In GO present case , if retry exceeds 3, |
| 7118 | it means something went wrong. */ |
| 7119 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) |
| 7120 | { |
| 7121 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7122 | "%s: ROC completion is not received.!!!", __func__); |
| 7123 | sme_CancelRemainOnChannel(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7124 | pAdapter->sessionId); |
| 7125 | wait_for_completion_interruptible_timeout( |
| 7126 | &pAdapter->cancel_rem_on_chan_var, |
| 7127 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 7128 | break; |
| 7129 | } |
| 7130 | } |
| 7131 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 7132 | #ifdef WLAN_NS_OFFLOAD |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 7133 | #ifdef WLAN_OPEN_SOURCE |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 7134 | cancel_work_sync(&pAdapter->ipv6NotifierWorkQueue); |
| 7135 | #endif |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 7136 | if (pAdapter->ipv6_notifier_registered) |
| 7137 | { |
| 7138 | hddLog(LOG1, FL("Unregistered IPv6 notifier")); |
| 7139 | unregister_inet6addr_notifier(&pAdapter->ipv6_notifier); |
| 7140 | pAdapter->ipv6_notifier_registered = false; |
| 7141 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 7142 | #endif |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 7143 | if (pAdapter->ipv4_notifier_registered) |
| 7144 | { |
| 7145 | hddLog(LOG1, FL("Unregistered IPv4 notifier")); |
| 7146 | unregister_inetaddr_notifier(&pAdapter->ipv4_notifier); |
| 7147 | pAdapter->ipv4_notifier_registered = false; |
| 7148 | } |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 7149 | #ifdef WLAN_OPEN_SOURCE |
| 7150 | cancel_work_sync(&pAdapter->ipv4NotifierWorkQueue); |
| 7151 | #endif |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7152 | /* It is possible that the caller of this function does not |
| 7153 | * wish to close the session |
| 7154 | */ |
| 7155 | if (VOS_TRUE == bCloseSession && |
| 7156 | test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7157 | { |
| 7158 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
| 7159 | if (eHAL_STATUS_SUCCESS == |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7160 | sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, |
| 7161 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7162 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7163 | unsigned long ret; |
| 7164 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7165 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7166 | ret = wait_for_completion_timeout( |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7167 | &pAdapter->session_close_comp_var, |
| 7168 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7169 | if ( 0 >= ret) |
| 7170 | { |
| 7171 | hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld", |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7172 | __func__, ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7173 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7174 | } |
| 7175 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 7176 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7177 | break; |
| 7178 | |
| 7179 | case WLAN_HDD_SOFTAP: |
| 7180 | case WLAN_HDD_P2P_GO: |
| 7181 | //Any softap specific cleanup here... |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7182 | if (pAdapter->device_mode == WLAN_HDD_P2P_GO) { |
| 7183 | while (pAdapter->is_roc_inprogress) { |
| 7184 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7185 | "%s: ROC in progress for session %d!!!", |
| 7186 | __func__, pAdapter->sessionId); |
| 7187 | msleep(500); |
| 7188 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) { |
| 7189 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7190 | "%s: ROC completion is not received.!!!", __func__); |
| 7191 | WLANSAP_CancelRemainOnChannel( |
| 7192 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
| 7193 | wait_for_completion_interruptible_timeout( |
| 7194 | &pAdapter->cancel_rem_on_chan_var, |
| 7195 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 7196 | break; |
| 7197 | } |
| 7198 | } |
| 7199 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7200 | mutex_lock(&pHddCtx->sap_lock); |
| 7201 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7202 | { |
| 7203 | VOS_STATUS status; |
| 7204 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7205 | |
| 7206 | //Stop Bss. |
| 7207 | status = WLANSAP_StopBss(pHddCtx->pvosContext); |
| 7208 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 7209 | { |
| 7210 | hdd_hostapd_state_t *pHostapdState = |
| 7211 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7212 | |
| 7213 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 7214 | |
| 7215 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 7216 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7217 | hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d", |
| 7218 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7219 | } |
| 7220 | } |
| 7221 | else |
| 7222 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7223 | hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7224 | } |
| 7225 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 7226 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7227 | |
| 7228 | if (eHAL_STATUS_FAILURE == |
| 7229 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 7230 | 0, NULL, eANI_BOOLEAN_FALSE)) |
| 7231 | { |
| 7232 | hddLog(LOGE, |
| 7233 | "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7234 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7235 | } |
| 7236 | |
| 7237 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 7238 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 7239 | eANI_BOOLEAN_FALSE) ) |
| 7240 | { |
| 7241 | hddLog(LOGE, |
| 7242 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
| 7243 | } |
| 7244 | |
| 7245 | // Reset WNI_CFG_PROBE_RSP Flags |
| 7246 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 7247 | kfree(pAdapter->sessionCtx.ap.beacon); |
| 7248 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 7249 | } |
| 7250 | mutex_unlock(&pHddCtx->sap_lock); |
| 7251 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7252 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7253 | case WLAN_HDD_MONITOR: |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7254 | #ifdef WLAN_OPEN_SOURCE |
| 7255 | cancel_work_sync(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue); |
| 7256 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7257 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7258 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7259 | default: |
| 7260 | break; |
| 7261 | } |
| 7262 | |
| 7263 | EXIT(); |
| 7264 | return VOS_STATUS_SUCCESS; |
| 7265 | } |
| 7266 | |
| 7267 | VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx ) |
| 7268 | { |
| 7269 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7270 | VOS_STATUS status; |
| 7271 | hdd_adapter_t *pAdapter; |
| 7272 | |
| 7273 | ENTER(); |
| 7274 | |
| 7275 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7276 | |
| 7277 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7278 | { |
| 7279 | pAdapter = pAdapterNode->pAdapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7280 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7281 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7282 | |
| 7283 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7284 | pAdapterNode = pNext; |
| 7285 | } |
| 7286 | |
| 7287 | EXIT(); |
| 7288 | |
| 7289 | return VOS_STATUS_SUCCESS; |
| 7290 | } |
| 7291 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7292 | |
| 7293 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 7294 | /**--------------------------------------------------------------------------- |
| 7295 | |
| 7296 | \brief hdd_deinit_batch_scan () - This function cleans up batch scan data |
| 7297 | structures |
| 7298 | |
| 7299 | \param - pAdapter Pointer to HDD adapter |
| 7300 | |
| 7301 | \return - None |
| 7302 | |
| 7303 | --------------------------------------------------------------------------*/ |
| 7304 | void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter) |
| 7305 | { |
| 7306 | tHddBatchScanRsp *pNode; |
| 7307 | tHddBatchScanRsp *pPrev; |
| 7308 | |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 7309 | if (NULL == pAdapter) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7310 | { |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 7311 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7312 | "%s: Adapter context is Null", __func__); |
| 7313 | return; |
| 7314 | } |
| 7315 | |
| 7316 | pNode = pAdapter->pBatchScanRsp; |
| 7317 | while (pNode) |
| 7318 | { |
| 7319 | pPrev = pNode; |
| 7320 | pNode = pNode->pNext; |
| 7321 | vos_mem_free((v_VOID_t * )pPrev); |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7322 | } |
| 7323 | |
| 7324 | pAdapter->pBatchScanRsp = NULL; |
| 7325 | pAdapter->numScanList = 0; |
| 7326 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 7327 | pAdapter->prev_batch_id = 0; |
| 7328 | |
| 7329 | return; |
| 7330 | } |
| 7331 | #endif |
| 7332 | |
| 7333 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7334 | VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx ) |
| 7335 | { |
| 7336 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7337 | VOS_STATUS status; |
| 7338 | hdd_adapter_t *pAdapter; |
| 7339 | |
| 7340 | ENTER(); |
| 7341 | |
| 7342 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7343 | |
| 7344 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7345 | { |
| 7346 | pAdapter = pAdapterNode->pAdapter; |
| 7347 | netif_tx_disable(pAdapter->dev); |
| 7348 | netif_carrier_off(pAdapter->dev); |
| 7349 | |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 7350 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
| 7351 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7352 | hdd_deinit_tx_rx(pAdapter); |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 7353 | |
| 7354 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 7355 | |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 7356 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 7357 | { |
| 7358 | hdd_wmm_adapter_close( pAdapter ); |
| 7359 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 7360 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7361 | |
Siddharth Bhal | 2db319d | 2014-12-03 12:37:18 +0530 | [diff] [blame] | 7362 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7363 | { |
| 7364 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 7365 | } |
| 7366 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7367 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 7368 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 7369 | { |
| 7370 | hdd_deinit_batch_scan(pAdapter); |
| 7371 | } |
| 7372 | #endif |
| 7373 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7374 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7375 | pAdapterNode = pNext; |
| 7376 | } |
| 7377 | |
| 7378 | EXIT(); |
| 7379 | |
| 7380 | return VOS_STATUS_SUCCESS; |
| 7381 | } |
| 7382 | |
| 7383 | VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx ) |
| 7384 | { |
| 7385 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7386 | VOS_STATUS status; |
| 7387 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7388 | eConnectionState connState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7389 | |
| 7390 | ENTER(); |
| 7391 | |
| 7392 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7393 | |
| 7394 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7395 | { |
| 7396 | pAdapter = pAdapterNode->pAdapter; |
| 7397 | |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 7398 | hdd_wmm_init( pAdapter ); |
| 7399 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7400 | switch(pAdapter->device_mode) |
| 7401 | { |
| 7402 | case WLAN_HDD_INFRA_STATION: |
| 7403 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7404 | case WLAN_HDD_P2P_DEVICE: |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7405 | |
| 7406 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState; |
| 7407 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7408 | hdd_init_station_mode(pAdapter); |
| 7409 | /* Open the gates for HDD to receive Wext commands */ |
| 7410 | pAdapter->isLinkUpSvcNeeded = FALSE; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 7411 | pHddCtx->scan_info.mScanPending = FALSE; |
| 7412 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7413 | |
| 7414 | //Trigger the initial scan |
| 7415 | hdd_wlan_initial_scan(pAdapter); |
| 7416 | |
| 7417 | //Indicate disconnect event to supplicant if associated previously |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7418 | if (eConnectionState_Associated == connState || |
| 7419 | eConnectionState_IbssConnected == connState ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7420 | { |
| 7421 | union iwreq_data wrqu; |
| 7422 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 7423 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 7424 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 7425 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 7426 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7427 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7428 | /* indicate disconnected event to nl80211 */ |
| 7429 | cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED, |
| 7430 | NULL, 0, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7431 | } |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7432 | else if (eConnectionState_Connecting == connState) |
| 7433 | { |
| 7434 | /* |
| 7435 | * Indicate connect failure to supplicant if we were in the |
| 7436 | * process of connecting |
| 7437 | */ |
| 7438 | cfg80211_connect_result(pAdapter->dev, NULL, |
| 7439 | NULL, 0, NULL, 0, |
| 7440 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 7441 | GFP_KERNEL); |
| 7442 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7443 | break; |
| 7444 | |
| 7445 | case WLAN_HDD_SOFTAP: |
| 7446 | /* softAP can handle SSR */ |
| 7447 | break; |
| 7448 | |
| 7449 | case WLAN_HDD_P2P_GO: |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 7450 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7451 | __func__); |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 7452 | cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7453 | break; |
| 7454 | |
| 7455 | case WLAN_HDD_MONITOR: |
| 7456 | /* monitor interface start */ |
| 7457 | break; |
| 7458 | default: |
| 7459 | break; |
| 7460 | } |
| 7461 | |
| 7462 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7463 | pAdapterNode = pNext; |
| 7464 | } |
| 7465 | |
| 7466 | EXIT(); |
| 7467 | |
| 7468 | return VOS_STATUS_SUCCESS; |
| 7469 | } |
| 7470 | |
| 7471 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ) |
| 7472 | { |
| 7473 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7474 | hdd_adapter_t *pAdapter; |
| 7475 | VOS_STATUS status; |
| 7476 | v_U32_t roamId; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7477 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7478 | |
| 7479 | ENTER(); |
| 7480 | |
| 7481 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7482 | |
| 7483 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7484 | { |
| 7485 | pAdapter = pAdapterNode->pAdapter; |
| 7486 | |
| 7487 | if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 7488 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 7489 | { |
| 7490 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7491 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 7492 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 7493 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7494 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 7495 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7496 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 7497 | init_completion(&pAdapter->disconnect_comp_var); |
| 7498 | sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, |
| 7499 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7500 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7501 | ret = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7502 | &pAdapter->disconnect_comp_var, |
| 7503 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7504 | if (0 >= ret) |
| 7505 | hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld", |
| 7506 | __func__, ret); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7507 | |
| 7508 | pWextState->roamProfile.csrPersona = pAdapter->device_mode; |
| 7509 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 7510 | sme_RoamConnect(pHddCtx->hHal, |
| 7511 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 7512 | &roamId); |
| 7513 | } |
| 7514 | |
| 7515 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7516 | pAdapterNode = pNext; |
| 7517 | } |
| 7518 | |
| 7519 | EXIT(); |
| 7520 | |
| 7521 | return VOS_STATUS_SUCCESS; |
| 7522 | } |
| 7523 | |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 7524 | void hdd_dump_concurrency_info(hdd_context_t *pHddCtx) |
| 7525 | { |
| 7526 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7527 | VOS_STATUS status; |
| 7528 | hdd_adapter_t *pAdapter; |
| 7529 | hdd_station_ctx_t *pHddStaCtx; |
| 7530 | hdd_ap_ctx_t *pHddApCtx; |
| 7531 | hdd_hostapd_state_t * pHostapdState; |
| 7532 | tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 }; |
| 7533 | v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 7534 | const char *p2pMode = "DEV"; |
| 7535 | const char *ccMode = "Standalone"; |
| 7536 | int n; |
| 7537 | |
| 7538 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7539 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7540 | { |
| 7541 | pAdapter = pAdapterNode->pAdapter; |
| 7542 | switch (pAdapter->device_mode) { |
| 7543 | case WLAN_HDD_INFRA_STATION: |
| 7544 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7545 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7546 | staChannel = pHddStaCtx->conn_info.operationChannel; |
| 7547 | memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid)); |
| 7548 | } |
| 7549 | break; |
| 7550 | case WLAN_HDD_P2P_CLIENT: |
| 7551 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7552 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7553 | p2pChannel = pHddStaCtx->conn_info.operationChannel; |
| 7554 | memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid)); |
| 7555 | p2pMode = "CLI"; |
| 7556 | } |
| 7557 | break; |
| 7558 | case WLAN_HDD_P2P_GO: |
| 7559 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7560 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7561 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7562 | p2pChannel = pHddApCtx->operatingChannel; |
| 7563 | memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid)); |
| 7564 | } |
| 7565 | p2pMode = "GO"; |
| 7566 | break; |
| 7567 | case WLAN_HDD_SOFTAP: |
| 7568 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7569 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7570 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7571 | apChannel = pHddApCtx->operatingChannel; |
| 7572 | memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid)); |
| 7573 | } |
| 7574 | break; |
| 7575 | default: |
| 7576 | break; |
| 7577 | } |
| 7578 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7579 | pAdapterNode = pNext; |
| 7580 | } |
| 7581 | if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) { |
| 7582 | ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC"; |
| 7583 | } |
| 7584 | n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s", |
| 7585 | staChannel, MAC_ADDR_ARRAY(staBssid), ccMode); |
| 7586 | if (p2pChannel > 0) { |
| 7587 | n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR, |
| 7588 | p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid)); |
| 7589 | } |
| 7590 | if (apChannel > 0) { |
| 7591 | n += pr_info("AP(%d) " MAC_ADDRESS_STR, |
| 7592 | apChannel, MAC_ADDR_ARRAY(apBssid)); |
| 7593 | } |
| 7594 | |
| 7595 | if (p2pChannel > 0 && apChannel > 0) { |
| 7596 | hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel); |
| 7597 | } |
| 7598 | } |
| 7599 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7600 | bool hdd_is_ssr_required( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7601 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7602 | return (isSsrRequired == HDD_SSR_REQUIRED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7603 | } |
| 7604 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7605 | /* Once SSR is disabled then it cannot be set. */ |
| 7606 | void hdd_set_ssr_required( e_hdd_ssr_required value) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7607 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7608 | if (HDD_SSR_DISABLED == isSsrRequired) |
| 7609 | return; |
| 7610 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7611 | isSsrRequired = value; |
| 7612 | } |
| 7613 | |
| 7614 | VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx, |
| 7615 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7616 | { |
| 7617 | VOS_STATUS status; |
| 7618 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7619 | status = hdd_list_peek_front ( &pHddCtx->hddAdapters, |
| 7620 | (hdd_list_node_t**) ppAdapterNode ); |
| 7621 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7622 | return status; |
| 7623 | } |
| 7624 | |
| 7625 | VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx, |
| 7626 | hdd_adapter_list_node_t* pAdapterNode, |
| 7627 | hdd_adapter_list_node_t** pNextAdapterNode) |
| 7628 | { |
| 7629 | VOS_STATUS status; |
| 7630 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7631 | status = hdd_list_peek_next ( &pHddCtx->hddAdapters, |
| 7632 | (hdd_list_node_t*) pAdapterNode, |
| 7633 | (hdd_list_node_t**)pNextAdapterNode ); |
| 7634 | |
| 7635 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7636 | return status; |
| 7637 | } |
| 7638 | |
| 7639 | VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx, |
| 7640 | hdd_adapter_list_node_t* pAdapterNode) |
| 7641 | { |
| 7642 | VOS_STATUS status; |
| 7643 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7644 | status = hdd_list_remove_node ( &pHddCtx->hddAdapters, |
| 7645 | &pAdapterNode->node ); |
| 7646 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7647 | return status; |
| 7648 | } |
| 7649 | |
| 7650 | VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx, |
| 7651 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7652 | { |
| 7653 | VOS_STATUS status; |
| 7654 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7655 | status = hdd_list_remove_front( &pHddCtx->hddAdapters, |
| 7656 | (hdd_list_node_t**) ppAdapterNode ); |
| 7657 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7658 | return status; |
| 7659 | } |
| 7660 | |
| 7661 | VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx, |
| 7662 | hdd_adapter_list_node_t* pAdapterNode) |
| 7663 | { |
| 7664 | VOS_STATUS status; |
| 7665 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7666 | status = hdd_list_insert_back ( &pHddCtx->hddAdapters, |
| 7667 | (hdd_list_node_t*) pAdapterNode ); |
| 7668 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7669 | return status; |
| 7670 | } |
| 7671 | |
| 7672 | VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx, |
| 7673 | hdd_adapter_list_node_t* pAdapterNode) |
| 7674 | { |
| 7675 | VOS_STATUS status; |
| 7676 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7677 | status = hdd_list_insert_front ( &pHddCtx->hddAdapters, |
| 7678 | (hdd_list_node_t*) pAdapterNode ); |
| 7679 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7680 | return status; |
| 7681 | } |
| 7682 | |
| 7683 | hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx, |
| 7684 | tSirMacAddr macAddr ) |
| 7685 | { |
| 7686 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7687 | hdd_adapter_t *pAdapter; |
| 7688 | VOS_STATUS status; |
| 7689 | |
| 7690 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7691 | |
| 7692 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7693 | { |
| 7694 | pAdapter = pAdapterNode->pAdapter; |
| 7695 | |
| 7696 | if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes, |
| 7697 | macAddr, sizeof(tSirMacAddr) ) ) |
| 7698 | { |
| 7699 | return pAdapter; |
| 7700 | } |
| 7701 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7702 | pAdapterNode = pNext; |
| 7703 | } |
| 7704 | |
| 7705 | return NULL; |
| 7706 | |
| 7707 | } |
| 7708 | |
| 7709 | hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name ) |
| 7710 | { |
| 7711 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7712 | hdd_adapter_t *pAdapter; |
| 7713 | VOS_STATUS status; |
| 7714 | |
| 7715 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7716 | |
| 7717 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7718 | { |
| 7719 | pAdapter = pAdapterNode->pAdapter; |
| 7720 | |
| 7721 | if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name, |
| 7722 | IFNAMSIZ ) ) |
| 7723 | { |
| 7724 | return pAdapter; |
| 7725 | } |
| 7726 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7727 | pAdapterNode = pNext; |
| 7728 | } |
| 7729 | |
| 7730 | return NULL; |
| 7731 | |
| 7732 | } |
| 7733 | |
| 7734 | hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7735 | { |
| 7736 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7737 | hdd_adapter_t *pAdapter; |
| 7738 | VOS_STATUS status; |
| 7739 | |
| 7740 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7741 | |
| 7742 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7743 | { |
| 7744 | pAdapter = pAdapterNode->pAdapter; |
| 7745 | |
| 7746 | if( pAdapter && (mode == pAdapter->device_mode) ) |
| 7747 | { |
| 7748 | return pAdapter; |
| 7749 | } |
| 7750 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7751 | pAdapterNode = pNext; |
| 7752 | } |
| 7753 | |
| 7754 | return NULL; |
| 7755 | |
| 7756 | } |
| 7757 | |
| 7758 | //Remove this function later |
| 7759 | hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx ) |
| 7760 | { |
| 7761 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7762 | hdd_adapter_t *pAdapter; |
| 7763 | VOS_STATUS status; |
| 7764 | |
| 7765 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7766 | |
| 7767 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7768 | { |
| 7769 | pAdapter = pAdapterNode->pAdapter; |
| 7770 | |
| 7771 | if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode ) |
| 7772 | { |
| 7773 | return pAdapter; |
| 7774 | } |
| 7775 | |
| 7776 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7777 | pAdapterNode = pNext; |
| 7778 | } |
| 7779 | |
| 7780 | return NULL; |
| 7781 | |
| 7782 | } |
| 7783 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7784 | /**--------------------------------------------------------------------------- |
| 7785 | |
| 7786 | \brief hdd_set_monitor_tx_adapter() - |
| 7787 | |
| 7788 | This API initializes the adapter to be used while transmitting on monitor |
| 7789 | adapter. |
| 7790 | |
| 7791 | \param - pHddCtx - Pointer to the HDD context. |
| 7792 | pAdapter - Adapter that will used for TX. This can be NULL. |
| 7793 | \return - None. |
| 7794 | --------------------------------------------------------------------------*/ |
| 7795 | void wlan_hdd_set_monitor_tx_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 7796 | { |
| 7797 | hdd_adapter_t *pMonAdapter; |
| 7798 | |
| 7799 | pMonAdapter = hdd_get_adapter( pHddCtx, WLAN_HDD_MONITOR ); |
| 7800 | |
| 7801 | if( NULL != pMonAdapter ) |
| 7802 | { |
| 7803 | pMonAdapter->sessionCtx.monitor.pAdapterForTx = pAdapter; |
| 7804 | } |
| 7805 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7806 | /**--------------------------------------------------------------------------- |
| 7807 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7808 | \brief hdd_get_operating_channel() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7809 | |
| 7810 | This API returns the operating channel of the requested device mode |
| 7811 | |
| 7812 | \param - pHddCtx - Pointer to the HDD context. |
| 7813 | - mode - Device mode for which operating channel is required |
| 7814 | suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT |
| 7815 | WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO. |
| 7816 | \return - channel number. "0" id the requested device is not found OR it is not connected. |
| 7817 | --------------------------------------------------------------------------*/ |
| 7818 | v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7819 | { |
| 7820 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7821 | VOS_STATUS status; |
| 7822 | hdd_adapter_t *pAdapter; |
| 7823 | v_U8_t operatingChannel = 0; |
| 7824 | |
| 7825 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7826 | |
| 7827 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7828 | { |
| 7829 | pAdapter = pAdapterNode->pAdapter; |
| 7830 | |
| 7831 | if( mode == pAdapter->device_mode ) |
| 7832 | { |
| 7833 | switch(pAdapter->device_mode) |
| 7834 | { |
| 7835 | case WLAN_HDD_INFRA_STATION: |
| 7836 | case WLAN_HDD_P2P_CLIENT: |
| 7837 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 7838 | operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel; |
| 7839 | break; |
| 7840 | case WLAN_HDD_SOFTAP: |
| 7841 | case WLAN_HDD_P2P_GO: |
| 7842 | /*softap connection info */ |
| 7843 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7844 | operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel; |
| 7845 | break; |
| 7846 | default: |
| 7847 | break; |
| 7848 | } |
| 7849 | |
| 7850 | break; //Found the device of interest. break the loop |
| 7851 | } |
| 7852 | |
| 7853 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7854 | pAdapterNode = pNext; |
| 7855 | } |
| 7856 | return operatingChannel; |
| 7857 | } |
| 7858 | |
| 7859 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 7860 | /**--------------------------------------------------------------------------- |
| 7861 | |
| 7862 | \brief hdd_set_multicast_list() - |
| 7863 | |
| 7864 | This used to set the multicast address list. |
| 7865 | |
| 7866 | \param - dev - Pointer to the WLAN device. |
| 7867 | - skb - Pointer to OS packet (sk_buff). |
| 7868 | \return - success/fail |
| 7869 | |
| 7870 | --------------------------------------------------------------------------*/ |
| 7871 | static void hdd_set_multicast_list(struct net_device *dev) |
| 7872 | { |
| 7873 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7874 | int mc_count; |
| 7875 | int i = 0; |
| 7876 | struct netdev_hw_addr *ha; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7877 | |
| 7878 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7879 | { |
| 7880 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7881 | "%s: Adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7882 | return; |
| 7883 | } |
| 7884 | |
| 7885 | if (dev->flags & IFF_ALLMULTI) |
| 7886 | { |
| 7887 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7888 | "%s: allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7889 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7890 | } |
| 7891 | else |
| 7892 | { |
| 7893 | mc_count = netdev_mc_count(dev); |
| 7894 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7895 | "%s: mc_count = %u", __func__, mc_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7896 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) |
| 7897 | { |
| 7898 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7899 | "%s: No free filter available; allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7900 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7901 | return; |
| 7902 | } |
| 7903 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7904 | pAdapter->mc_addr_list.mc_cnt = mc_count; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7905 | |
| 7906 | netdev_for_each_mc_addr(ha, dev) { |
| 7907 | if (i == mc_count) |
| 7908 | break; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7909 | memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN); |
| 7910 | memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7911 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7912 | __func__, i, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7913 | MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i])); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7914 | i++; |
| 7915 | } |
| 7916 | } |
| 7917 | return; |
| 7918 | } |
| 7919 | #endif |
| 7920 | |
| 7921 | /**--------------------------------------------------------------------------- |
| 7922 | |
| 7923 | \brief hdd_select_queue() - |
| 7924 | |
| 7925 | This function is registered with the Linux OS for network |
| 7926 | core to decide which queue to use first. |
| 7927 | |
| 7928 | \param - dev - Pointer to the WLAN device. |
| 7929 | - skb - Pointer to OS packet (sk_buff). |
| 7930 | \return - ac, Queue Index/access category corresponding to UP in IP header |
| 7931 | |
| 7932 | --------------------------------------------------------------------------*/ |
| 7933 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 7934 | struct sk_buff *skb) |
| 7935 | { |
| 7936 | return hdd_wmm_select_queue(dev, skb); |
| 7937 | } |
| 7938 | |
| 7939 | |
| 7940 | /**--------------------------------------------------------------------------- |
| 7941 | |
| 7942 | \brief hdd_wlan_initial_scan() - |
| 7943 | |
| 7944 | This function triggers the initial scan |
| 7945 | |
| 7946 | \param - pAdapter - Pointer to the HDD adapter. |
| 7947 | |
| 7948 | --------------------------------------------------------------------------*/ |
| 7949 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter) |
| 7950 | { |
| 7951 | tCsrScanRequest scanReq; |
| 7952 | tCsrChannelInfo channelInfo; |
| 7953 | eHalStatus halStatus; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 7954 | tANI_U32 scanId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7955 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7956 | |
| 7957 | vos_mem_zero(&scanReq, sizeof(tCsrScanRequest)); |
| 7958 | vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff); |
| 7959 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 7960 | |
| 7961 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 7962 | { |
| 7963 | halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo ); |
| 7964 | if ( HAL_STATUS_SUCCESS( halStatus ) ) |
| 7965 | { |
| 7966 | scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels); |
| 7967 | if( !scanReq.ChannelInfo.ChannelList ) |
| 7968 | { |
| 7969 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__); |
| 7970 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 7971 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7972 | return; |
| 7973 | } |
| 7974 | vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList, |
| 7975 | channelInfo.numOfChannels); |
| 7976 | scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels; |
| 7977 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 7978 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7979 | } |
| 7980 | |
| 7981 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 7982 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 7983 | scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime; |
| 7984 | scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime; |
| 7985 | } |
| 7986 | else |
| 7987 | { |
| 7988 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 7989 | scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 7990 | scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime; |
| 7991 | scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime; |
| 7992 | } |
| 7993 | |
| 7994 | halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL); |
| 7995 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 7996 | { |
| 7997 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d", |
| 7998 | __func__, halStatus ); |
| 7999 | } |
| 8000 | |
| 8001 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 8002 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
| 8003 | } |
| 8004 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8005 | /**--------------------------------------------------------------------------- |
| 8006 | |
| 8007 | \brief hdd_full_power_callback() - HDD full power callback function |
| 8008 | |
| 8009 | This is the function invoked by SME to inform the result of a full power |
| 8010 | request issued by HDD |
| 8011 | |
| 8012 | \param - callbackcontext - Pointer to cookie |
| 8013 | \param - status - result of request |
| 8014 | |
| 8015 | \return - None |
| 8016 | |
| 8017 | --------------------------------------------------------------------------*/ |
| 8018 | static void hdd_full_power_callback(void *callbackContext, eHalStatus status) |
| 8019 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8020 | struct statsContext *pContext = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8021 | |
| 8022 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8023 | "%s: context = %p, status = %d", __func__, pContext, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8024 | |
| 8025 | if (NULL == callbackContext) |
| 8026 | { |
| 8027 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8028 | "%s: Bad param, context [%p]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8029 | __func__, callbackContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8030 | return; |
| 8031 | } |
| 8032 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8033 | /* there is a race condition that exists between this callback |
| 8034 | function and the caller since the caller could time out either |
| 8035 | before or while this code is executing. we use a spinlock to |
| 8036 | serialize these actions */ |
| 8037 | spin_lock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8038 | |
| 8039 | if (POWER_CONTEXT_MAGIC != pContext->magic) |
| 8040 | { |
| 8041 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8042 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8043 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 8044 | "%s: Invalid context, magic [%08x]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8045 | __func__, pContext->magic); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8046 | return; |
| 8047 | } |
| 8048 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8049 | /* context is valid so caller is still waiting */ |
| 8050 | |
| 8051 | /* paranoia: invalidate the magic */ |
| 8052 | pContext->magic = 0; |
| 8053 | |
| 8054 | /* notify the caller */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8055 | complete(&pContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8056 | |
| 8057 | /* serialization is complete */ |
| 8058 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8059 | } |
| 8060 | |
| 8061 | /**--------------------------------------------------------------------------- |
| 8062 | |
| 8063 | \brief hdd_wlan_exit() - HDD WLAN exit function |
| 8064 | |
| 8065 | This is the driver exit point (invoked during rmmod) |
| 8066 | |
| 8067 | \param - pHddCtx - Pointer to the HDD Context |
| 8068 | |
| 8069 | \return - None |
| 8070 | |
| 8071 | --------------------------------------------------------------------------*/ |
| 8072 | void hdd_wlan_exit(hdd_context_t *pHddCtx) |
| 8073 | { |
| 8074 | eHalStatus halStatus; |
| 8075 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
| 8076 | VOS_STATUS vosStatus; |
Gopichand Nakkala | 66923aa | 2013-03-06 23:17:24 +0530 | [diff] [blame] | 8077 | struct wiphy *wiphy = pHddCtx->wiphy; |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8078 | hdd_adapter_t* pAdapter = NULL; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8079 | struct statsContext powerContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8080 | long lrc; |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8081 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8082 | |
| 8083 | ENTER(); |
| 8084 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8085 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 8086 | { |
| 8087 | // Unloading, restart logic is no more required. |
| 8088 | wlan_hdd_restart_deinit(pHddCtx); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8089 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8090 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 8091 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8092 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8093 | pAdapter = pAdapterNode->pAdapter; |
| 8094 | if (NULL != pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8095 | { |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 8096 | /* Disable TX on the interface, after this hard_start_xmit() will |
| 8097 | * not be called on that interface |
| 8098 | */ |
| 8099 | netif_tx_disable(pAdapter->dev); |
| 8100 | |
| 8101 | /* Mark the interface status as "down" for outside world */ |
| 8102 | netif_carrier_off(pAdapter->dev); |
| 8103 | |
| 8104 | /* DeInit the adapter. This ensures that all data packets |
| 8105 | * are freed. |
| 8106 | */ |
| 8107 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 8108 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8109 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 8110 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
| 8111 | { |
| 8112 | wlan_hdd_cfg80211_deregister_frames(pAdapter); |
| 8113 | hdd_UnregisterWext(pAdapter->dev); |
| 8114 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8115 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8116 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8117 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8118 | pAdapterNode = pNext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8119 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8120 | // Cancel any outstanding scan requests. We are about to close all |
| 8121 | // of our adapters, but an adapter structure is what SME passes back |
| 8122 | // to our callback function. Hence if there are any outstanding scan |
| 8123 | // requests then there is a race condition between when the adapter |
| 8124 | // is closed and when the callback is invoked.We try to resolve that |
| 8125 | // race condition here by canceling any outstanding scans before we |
| 8126 | // close the adapters. |
| 8127 | // Note that the scans may be cancelled in an asynchronous manner, |
| 8128 | // so ideally there needs to be some kind of synchronization. Rather |
| 8129 | // than introduce a new synchronization here, we will utilize the |
| 8130 | // fact that we are about to Request Full Power, and since that is |
| 8131 | // synchronized, the expectation is that by the time Request Full |
| 8132 | // Power has completed all scans will be cancelled. |
| 8133 | if (pHddCtx->scan_info.mScanPending) |
| 8134 | { |
| 8135 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8136 | FL("abort scan mode: %d sessionId: %d"), |
| 8137 | pAdapter->device_mode, |
| 8138 | pAdapter->sessionId); |
| 8139 | hdd_abort_mac_scan(pHddCtx, |
| 8140 | pHddCtx->scan_info.sessionId, |
| 8141 | eCSR_SCAN_ABORT_DEFAULT); |
| 8142 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8143 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8144 | else |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8145 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8146 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__); |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8147 | wlan_hdd_ftm_close(pHddCtx); |
| 8148 | goto free_hdd_ctx; |
| 8149 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8150 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8151 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 8152 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 8153 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 8154 | { |
| 8155 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 8156 | VOS_ASSERT(0); |
| 8157 | } |
| 8158 | |
| 8159 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 8160 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 8161 | { |
| 8162 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 8163 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8164 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 8165 | //Stop the traffic monitor timer |
| 8166 | if ( VOS_TIMER_STATE_RUNNING == |
| 8167 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) |
| 8168 | { |
| 8169 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 8170 | } |
| 8171 | |
| 8172 | // Destroy the traffic monitor timer |
| 8173 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 8174 | &pHddCtx->tx_rx_trafficTmr))) |
| 8175 | { |
| 8176 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8177 | "%s: Cannot deallocate Traffic monitor timer", __func__); |
| 8178 | } |
| 8179 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8180 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 8181 | //save mode during shutdown |
| 8182 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 8183 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 8184 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 8185 | |
| 8186 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 8187 | init_completion(&powerContext.completion); |
| 8188 | powerContext.magic = POWER_CONTEXT_MAGIC; |
| 8189 | |
| 8190 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback, |
| 8191 | &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 8192 | |
| 8193 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 8194 | { |
| 8195 | if (eHAL_STATUS_PMC_PENDING == halStatus) |
| 8196 | { |
| 8197 | /* request was sent -- wait for the response */ |
| 8198 | lrc = wait_for_completion_interruptible_timeout( |
| 8199 | &powerContext.completion, |
| 8200 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8201 | if (lrc <= 0) |
| 8202 | { |
| 8203 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8204 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8205 | } |
| 8206 | } |
| 8207 | else |
| 8208 | { |
| 8209 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8210 | "%s: Request for Full Power failed, status %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8211 | __func__, halStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8212 | /* continue -- need to clean up as much as possible */ |
| 8213 | } |
| 8214 | } |
| 8215 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8216 | /* either we never sent a request, we sent a request and received a |
| 8217 | response or we sent a request and timed out. if we never sent a |
| 8218 | request or if we sent a request and got a response, we want to |
| 8219 | clear the magic out of paranoia. if we timed out there is a |
| 8220 | race condition such that the callback function could be |
| 8221 | executing at the same time we are. of primary concern is if the |
| 8222 | callback function had already verified the "magic" but had not |
| 8223 | yet set the completion variable when a timeout occurred. we |
| 8224 | serialize these activities by invalidating the magic while |
| 8225 | holding a shared spinlock which will cause us to block if the |
| 8226 | callback is currently executing */ |
| 8227 | spin_lock(&hdd_context_lock); |
| 8228 | powerContext.magic = 0; |
| 8229 | spin_unlock(&hdd_context_lock); |
| 8230 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8231 | hdd_debugfs_exit(pHddCtx); |
| 8232 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8233 | // Unregister the Net Device Notifier |
| 8234 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 8235 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8236 | hdd_stop_all_adapters( pHddCtx ); |
| 8237 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8238 | #ifdef WLAN_BTAMP_FEATURE |
| 8239 | vosStatus = WLANBAP_Stop(pVosContext); |
| 8240 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8241 | { |
| 8242 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8243 | "%s: Failed to stop BAP",__func__); |
| 8244 | } |
| 8245 | #endif //WLAN_BTAMP_FEATURE |
| 8246 | |
| 8247 | //Stop all the modules |
| 8248 | vosStatus = vos_stop( pVosContext ); |
| 8249 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8250 | { |
| 8251 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8252 | "%s: Failed to stop VOSS",__func__); |
| 8253 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8254 | } |
| 8255 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8256 | //This requires pMac access, Call this before vos_close(). |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8257 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8258 | |
| 8259 | //Close the scheduler before calling vos_close to make sure no thread is |
| 8260 | // scheduled after the each module close is called i.e after all the data |
| 8261 | // structures are freed. |
| 8262 | vosStatus = vos_sched_close( pVosContext ); |
| 8263 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 8264 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 8265 | "%s: Failed to close VOSS Scheduler",__func__); |
| 8266 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8267 | } |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8268 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8269 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 8270 | /* Destroy the wake lock */ |
| 8271 | wake_lock_destroy(&pHddCtx->rx_wake_lock); |
| 8272 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 8273 | /* Destroy the wake lock */ |
| 8274 | wake_lock_destroy(&pHddCtx->sap_wake_lock); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8275 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8276 | |
Mihir Shete | 7a24b5f | 2013-12-21 12:18:31 +0530 | [diff] [blame] | 8277 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 8278 | vosStatus = vos_nv_close(); |
| 8279 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8280 | { |
| 8281 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8282 | "%s: Failed to close NV", __func__); |
| 8283 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8284 | } |
| 8285 | #endif |
| 8286 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8287 | //Close VOSS |
| 8288 | //This frees pMac(HAL) context. There should not be any call that requires pMac access after this. |
| 8289 | vos_close(pVosContext); |
| 8290 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8291 | //Close Watchdog |
| 8292 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 8293 | vos_watchdog_close(pVosContext); |
| 8294 | |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 8295 | //Clean up HDD Nlink Service |
| 8296 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 8297 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 8298 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 8299 | if (pHddCtx->cfg_ini->wlanLoggingEnable) |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 8300 | { |
| 8301 | wlan_logging_sock_deactivate_svc(); |
| 8302 | } |
| 8303 | #endif |
| 8304 | |
Vinay Krishna Eranna | ef30b52 | 2014-08-26 17:48:16 +0530 | [diff] [blame] | 8305 | #ifdef WLAN_KD_READY_NOTIFIER |
| 8306 | nl_srv_exit(pHddCtx->ptt_pid); |
| 8307 | #else |
| 8308 | nl_srv_exit(); |
| 8309 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 8310 | |
| 8311 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8312 | hdd_close_all_adapters( pHddCtx ); |
| 8313 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8314 | /* free the power on lock from platform driver */ |
| 8315 | if (free_riva_power_on_lock("wlan")) |
| 8316 | { |
| 8317 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 8318 | __func__); |
| 8319 | } |
| 8320 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8321 | free_hdd_ctx: |
c_hpothu | 78c7b60 | 2014-05-17 17:35:49 +0530 | [diff] [blame] | 8322 | |
| 8323 | //Free up dynamically allocated members inside HDD Adapter |
| 8324 | if (pHddCtx->cfg_ini) |
| 8325 | { |
| 8326 | kfree(pHddCtx->cfg_ini); |
| 8327 | pHddCtx->cfg_ini= NULL; |
| 8328 | } |
| 8329 | |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 8330 | /* FTM mode, WIPHY did not registered |
| 8331 | If un-register here, system crash will happen */ |
| 8332 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 8333 | { |
| 8334 | wiphy_unregister(wiphy) ; |
| 8335 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8336 | wiphy_free(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8337 | if (hdd_is_ssr_required()) |
| 8338 | { |
| 8339 | /* WDI timeout had happened during unload, so SSR is needed here */ |
Madan Mohan Koyyalamudi | 3246f5b | 2012-10-15 15:40:02 -0700 | [diff] [blame] | 8340 | subsystem_restart("wcnss"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8341 | msleep(5000); |
| 8342 | } |
| 8343 | hdd_set_ssr_required (VOS_FALSE); |
| 8344 | } |
| 8345 | |
| 8346 | |
| 8347 | /**--------------------------------------------------------------------------- |
| 8348 | |
| 8349 | \brief hdd_update_config_from_nv() - Function to update the contents of |
| 8350 | the running configuration with parameters taken from NV storage |
| 8351 | |
| 8352 | \param - pHddCtx - Pointer to the HDD global context |
| 8353 | |
| 8354 | \return - VOS_STATUS_SUCCESS if successful |
| 8355 | |
| 8356 | --------------------------------------------------------------------------*/ |
| 8357 | static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx) |
| 8358 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8359 | v_BOOL_t itemIsValid = VOS_FALSE; |
| 8360 | VOS_STATUS status; |
| 8361 | v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA]; |
| 8362 | v_U8_t macLoop; |
| 8363 | |
| 8364 | /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/ |
| 8365 | status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid); |
| 8366 | if(status != VOS_STATUS_SUCCESS) |
| 8367 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8368 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8369 | return VOS_STATUS_E_FAILURE; |
| 8370 | } |
| 8371 | |
| 8372 | if (itemIsValid == VOS_TRUE) |
| 8373 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8374 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8375 | status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0], |
| 8376 | VOS_MAX_CONCURRENCY_PERSONA); |
| 8377 | if(status != VOS_STATUS_SUCCESS) |
| 8378 | { |
| 8379 | /* Get MAC from NV fail, not update CFG info |
| 8380 | * INI MAC value will be used for MAC setting */ |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8381 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8382 | return VOS_STATUS_E_FAILURE; |
| 8383 | } |
| 8384 | |
| 8385 | /* If first MAC is not valid, treat all others are not valid |
| 8386 | * Then all MACs will be got from ini file */ |
| 8387 | if(vos_is_macaddr_zero(&macFromNV[0])) |
| 8388 | { |
| 8389 | /* MAC address in NV file is not configured yet */ |
| 8390 | hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file"); |
| 8391 | return VOS_STATUS_E_INVAL; |
| 8392 | } |
| 8393 | |
| 8394 | /* Get MAC address from NV, update CFG info */ |
| 8395 | for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++) |
| 8396 | { |
| 8397 | if(vos_is_macaddr_zero(&macFromNV[macLoop])) |
| 8398 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8399 | 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] | 8400 | /* This MAC is not valid, skip it |
| 8401 | * This MAC will be got from ini file */ |
| 8402 | } |
| 8403 | else |
| 8404 | { |
| 8405 | vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0], |
| 8406 | (v_U8_t *)&macFromNV[macLoop].bytes[0], |
| 8407 | VOS_MAC_ADDR_SIZE); |
| 8408 | } |
| 8409 | } |
| 8410 | } |
| 8411 | else |
| 8412 | { |
| 8413 | hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid"); |
| 8414 | return VOS_STATUS_E_FAILURE; |
| 8415 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8416 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8417 | |
| 8418 | return VOS_STATUS_SUCCESS; |
| 8419 | } |
| 8420 | |
| 8421 | /**--------------------------------------------------------------------------- |
| 8422 | |
| 8423 | \brief hdd_post_voss_start_config() - HDD post voss start config helper |
| 8424 | |
| 8425 | \param - pAdapter - Pointer to the HDD |
| 8426 | |
| 8427 | \return - None |
| 8428 | |
| 8429 | --------------------------------------------------------------------------*/ |
| 8430 | VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx) |
| 8431 | { |
| 8432 | eHalStatus halStatus; |
| 8433 | v_U32_t listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8434 | tANI_U32 ignoreDtim; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8435 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8436 | |
| 8437 | // Send ready indication to the HDD. This will kick off the MAC |
| 8438 | // into a 'running' state and should kick off an initial scan. |
| 8439 | halStatus = sme_HDDReadyInd( pHddCtx->hHal ); |
| 8440 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 8441 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8442 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8443 | "code %08d [x%08x]",__func__, halStatus, halStatus ); |
| 8444 | return VOS_STATUS_E_FAILURE; |
| 8445 | } |
| 8446 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8447 | // Set default LI and ignoreDtim into HDD context, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8448 | // otherwise under some race condition, HDD will set 0 LI value into RIVA, |
| 8449 | // And RIVA will crash |
| 8450 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval); |
| 8451 | pHddCtx->hdd_actual_LI_value = listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8452 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim); |
| 8453 | pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim; |
| 8454 | |
| 8455 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8456 | return VOS_STATUS_SUCCESS; |
| 8457 | } |
| 8458 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8459 | /* wake lock APIs for HDD */ |
| 8460 | void hdd_prevent_suspend(void) |
| 8461 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8462 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8463 | wake_lock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8464 | #else |
| 8465 | wcnss_prevent_suspend(); |
| 8466 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8467 | } |
| 8468 | |
| 8469 | void hdd_allow_suspend(void) |
| 8470 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8471 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8472 | wake_unlock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8473 | #else |
| 8474 | wcnss_allow_suspend(); |
| 8475 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8476 | } |
| 8477 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 8478 | void hdd_prevent_suspend_timeout(v_U32_t timeout) |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8479 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8480 | #ifdef WLAN_OPEN_SOURCE |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 8481 | wake_lock_timeout(&wlan_wake_lock, msecs_to_jiffies(timeout)); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8482 | #else |
| 8483 | /* Do nothing as there is no API in wcnss for timeout*/ |
| 8484 | #endif |
| 8485 | } |
| 8486 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8487 | /**--------------------------------------------------------------------------- |
| 8488 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8489 | \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability |
| 8490 | information between Host and Riva |
| 8491 | |
| 8492 | This function gets reported version of FW |
| 8493 | It also finds the version of Riva headers used to compile the host |
| 8494 | It compares the above two and prints a warning if they are different |
| 8495 | It gets the SW and HW version string |
| 8496 | Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg |
| 8497 | indicating the features they support through a bitmap |
| 8498 | |
| 8499 | \param - pHddCtx - Pointer to HDD context |
| 8500 | |
| 8501 | \return - void |
| 8502 | |
| 8503 | --------------------------------------------------------------------------*/ |
| 8504 | |
| 8505 | void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx) |
| 8506 | { |
| 8507 | |
| 8508 | tSirVersionType versionCompiled; |
| 8509 | tSirVersionType versionReported; |
| 8510 | tSirVersionString versionString; |
| 8511 | tANI_U8 fwFeatCapsMsgSupported = 0; |
| 8512 | VOS_STATUS vstatus; |
| 8513 | |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8514 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 8515 | memset(&versionReported, 0, sizeof(versionReported)); |
| 8516 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8517 | /* retrieve and display WCNSS version information */ |
| 8518 | do { |
| 8519 | |
| 8520 | vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal, |
| 8521 | &versionCompiled); |
| 8522 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8523 | { |
| 8524 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8525 | "%s: unable to retrieve WCNSS WLAN compiled version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8526 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8527 | break; |
| 8528 | } |
| 8529 | |
| 8530 | vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal, |
| 8531 | &versionReported); |
| 8532 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8533 | { |
| 8534 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8535 | "%s: unable to retrieve WCNSS WLAN reported version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8536 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8537 | break; |
| 8538 | } |
| 8539 | |
| 8540 | if ((versionCompiled.major != versionReported.major) || |
| 8541 | (versionCompiled.minor != versionReported.minor) || |
| 8542 | (versionCompiled.version != versionReported.version) || |
| 8543 | (versionCompiled.revision != versionReported.revision)) |
| 8544 | { |
| 8545 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 8546 | "Host expected %u.%u.%u.%u\n", |
| 8547 | WLAN_MODULE_NAME, |
| 8548 | (int)versionReported.major, |
| 8549 | (int)versionReported.minor, |
| 8550 | (int)versionReported.version, |
| 8551 | (int)versionReported.revision, |
| 8552 | (int)versionCompiled.major, |
| 8553 | (int)versionCompiled.minor, |
| 8554 | (int)versionCompiled.version, |
| 8555 | (int)versionCompiled.revision); |
| 8556 | } |
| 8557 | else |
| 8558 | { |
| 8559 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 8560 | WLAN_MODULE_NAME, |
| 8561 | (int)versionReported.major, |
| 8562 | (int)versionReported.minor, |
| 8563 | (int)versionReported.version, |
| 8564 | (int)versionReported.revision); |
| 8565 | } |
| 8566 | |
| 8567 | vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal, |
| 8568 | versionString, |
| 8569 | sizeof(versionString)); |
| 8570 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8571 | { |
| 8572 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8573 | "%s: unable to retrieve WCNSS software version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8574 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8575 | break; |
| 8576 | } |
| 8577 | |
| 8578 | pr_info("%s: WCNSS software version %s\n", |
| 8579 | WLAN_MODULE_NAME, versionString); |
| 8580 | |
| 8581 | vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal, |
| 8582 | versionString, |
| 8583 | sizeof(versionString)); |
| 8584 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8585 | { |
| 8586 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8587 | "%s: unable to retrieve WCNSS hardware version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8588 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8589 | break; |
| 8590 | } |
| 8591 | |
| 8592 | pr_info("%s: WCNSS hardware version %s\n", |
| 8593 | WLAN_MODULE_NAME, versionString); |
| 8594 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8595 | /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message |
| 8596 | 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] | 8597 | send the message only if it the riva is 1.1 |
| 8598 | minor numbers for different riva branches: |
| 8599 | 0 -> (1.0)Mainline Build |
| 8600 | 1 -> (1.1)Mainline Build |
| 8601 | 2->(1.04) Stability Build |
| 8602 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8603 | if (((versionReported.major>0) || (versionReported.minor>1) || |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8604 | ((versionReported.minor>=1) && (versionReported.version>=1))) |
| 8605 | && ((versionReported.major == 1) && (versionReported.minor >= 1))) |
| 8606 | fwFeatCapsMsgSupported = 1; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8607 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8608 | if (fwFeatCapsMsgSupported) |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8609 | { |
| 8610 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 8611 | if(!pHddCtx->cfg_ini->fEnableActiveModeOffload) |
| 8612 | sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD); |
| 8613 | #endif |
Ravi Joshi | d2ca7c4 | 2013-07-23 08:37:49 -0700 | [diff] [blame] | 8614 | /* Indicate if IBSS heartbeat monitoring needs to be offloaded */ |
| 8615 | if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload) |
| 8616 | { |
| 8617 | sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD); |
| 8618 | } |
| 8619 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8620 | sme_featureCapsExchange(pHddCtx->hHal); |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8621 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8622 | |
| 8623 | } while (0); |
| 8624 | |
| 8625 | } |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 8626 | void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len) |
| 8627 | { |
| 8628 | struct sk_buff *skb; |
| 8629 | struct nlmsghdr *nlh; |
| 8630 | tAniMsgHdr *ani_hdr; |
| 8631 | |
| 8632 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), GFP_KERNEL); |
| 8633 | |
| 8634 | if(skb == NULL) { |
| 8635 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8636 | "%s: alloc_skb failed", __func__); |
| 8637 | return; |
| 8638 | } |
| 8639 | |
| 8640 | nlh = (struct nlmsghdr *)skb->data; |
| 8641 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 8642 | nlh->nlmsg_flags = 0; |
| 8643 | nlh->nlmsg_seq = 0; |
| 8644 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 8645 | |
| 8646 | ani_hdr = NLMSG_DATA(nlh); |
| 8647 | ani_hdr->type = type; |
| 8648 | |
| 8649 | switch(type) { |
| 8650 | case WLAN_SVC_SAP_RESTART_IND: |
| 8651 | ani_hdr->length = 0; |
| 8652 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
| 8653 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr))); |
| 8654 | break; |
| 8655 | default: |
| 8656 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8657 | "Attempt to send unknown nlink message %d", type); |
| 8658 | kfree_skb(skb); |
| 8659 | return; |
| 8660 | } |
| 8661 | |
| 8662 | nl_srv_bcast(skb); |
| 8663 | |
| 8664 | return; |
| 8665 | } |
| 8666 | |
| 8667 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8668 | |
| 8669 | /**--------------------------------------------------------------------------- |
| 8670 | |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8671 | \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz |
| 8672 | |
| 8673 | \param - pHddCtx - Pointer to the hdd context |
| 8674 | |
| 8675 | \return - true if hardware supports 5GHz |
| 8676 | |
| 8677 | --------------------------------------------------------------------------*/ |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 8678 | boolean hdd_is_5g_supported(hdd_context_t * pHddCtx) |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8679 | { |
| 8680 | /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1); |
| 8681 | * then hardware support 5Ghz. |
| 8682 | */ |
| 8683 | if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode()) |
| 8684 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8685 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8686 | return true; |
| 8687 | } |
| 8688 | else |
| 8689 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8690 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz", |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8691 | __func__); |
| 8692 | return false; |
| 8693 | } |
| 8694 | } |
| 8695 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8696 | /**--------------------------------------------------------------------------- |
| 8697 | |
| 8698 | \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto |
| 8699 | generate function |
| 8700 | |
| 8701 | This is generate the random mac address for WLAN interface |
| 8702 | |
| 8703 | \param - pHddCtx - Pointer to HDD context |
| 8704 | idx - Start interface index to get auto |
| 8705 | generated mac addr. |
| 8706 | mac_addr - Mac address |
| 8707 | |
| 8708 | \return - 0 for success, < 0 for failure |
| 8709 | |
| 8710 | --------------------------------------------------------------------------*/ |
| 8711 | |
| 8712 | static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx, |
| 8713 | int idx, v_MACADDR_t mac_addr) |
| 8714 | { |
| 8715 | int i; |
| 8716 | unsigned int serialno; |
| 8717 | serialno = wcnss_get_serial_number(); |
| 8718 | |
| 8719 | if (0 != serialno) |
| 8720 | { |
| 8721 | /* MAC address has 3 bytes of OUI so we have a maximum of 3 |
| 8722 | bytes of the serial number that can be used to generate |
| 8723 | the other 3 bytes of the MAC address. Mask off all but |
| 8724 | the lower 3 bytes (this will also make sure we don't |
| 8725 | overflow in the next step) */ |
| 8726 | serialno &= 0x00FFFFFF; |
| 8727 | |
| 8728 | /* we need a unique address for each session */ |
| 8729 | serialno *= VOS_MAX_CONCURRENCY_PERSONA; |
| 8730 | |
| 8731 | /* autogen other Mac addresses */ |
| 8732 | for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 8733 | { |
| 8734 | /* start with the entire default address */ |
| 8735 | pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr; |
| 8736 | /* then replace the lower 3 bytes */ |
| 8737 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF; |
| 8738 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF; |
| 8739 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF; |
| 8740 | |
| 8741 | serialno++; |
| 8742 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8743 | "%s: Derived Mac Addr: " |
| 8744 | MAC_ADDRESS_STR, __func__, |
| 8745 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes)); |
| 8746 | } |
| 8747 | |
| 8748 | } |
| 8749 | else |
| 8750 | { |
| 8751 | hddLog(LOGE, FL("Failed to Get Serial NO")); |
| 8752 | return -1; |
| 8753 | } |
| 8754 | return 0; |
| 8755 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8756 | |
| 8757 | /**--------------------------------------------------------------------------- |
| 8758 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 8759 | \brief hdd_11d_scan_done - callback to be executed when 11d scan is |
| 8760 | completed to flush out the scan results |
| 8761 | |
| 8762 | 11d scan is done during driver load and is a passive scan on all |
| 8763 | channels supported by the device, 11d scans may find some APs on |
| 8764 | frequencies which are forbidden to be used in the regulatory domain |
| 8765 | the device is operating in. If these APs are notified to the supplicant |
| 8766 | it may try to connect to these APs, thus flush out all the scan results |
| 8767 | which are present in SME after 11d scan is done. |
| 8768 | |
| 8769 | \return - eHalStatus |
| 8770 | |
| 8771 | --------------------------------------------------------------------------*/ |
| 8772 | static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
| 8773 | tANI_U32 scanId, eCsrScanStatus status) |
| 8774 | { |
| 8775 | ENTER(); |
| 8776 | |
| 8777 | sme_ScanFlushResult(halHandle, 0); |
| 8778 | |
| 8779 | EXIT(); |
| 8780 | |
| 8781 | return eHAL_STATUS_SUCCESS; |
| 8782 | } |
| 8783 | |
| 8784 | /**--------------------------------------------------------------------------- |
| 8785 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8786 | \brief hdd_wlan_startup() - HDD init function |
| 8787 | |
| 8788 | This is the driver startup code executed once a WLAN device has been detected |
| 8789 | |
| 8790 | \param - dev - Pointer to the underlying device |
| 8791 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8792 | \return - 0 for success, < 0 for failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8793 | |
| 8794 | --------------------------------------------------------------------------*/ |
| 8795 | |
| 8796 | int hdd_wlan_startup(struct device *dev ) |
| 8797 | { |
| 8798 | VOS_STATUS status; |
| 8799 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8800 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8801 | hdd_context_t *pHddCtx = NULL; |
| 8802 | v_CONTEXT_t pVosContext= NULL; |
| 8803 | #ifdef WLAN_BTAMP_FEATURE |
| 8804 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 8805 | WLANBAP_ConfigType btAmpConfig; |
| 8806 | hdd_config_t *pConfig; |
| 8807 | #endif |
| 8808 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8809 | struct wiphy *wiphy; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8810 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8811 | |
| 8812 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8813 | /* |
| 8814 | * cfg80211: wiphy allocation |
| 8815 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8816 | wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8817 | |
| 8818 | if(wiphy == NULL) |
| 8819 | { |
| 8820 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8821 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8822 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8823 | pHddCtx = wiphy_priv(wiphy); |
| 8824 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8825 | //Initialize the adapter context to zeros. |
| 8826 | vos_mem_zero(pHddCtx, sizeof( hdd_context_t )); |
| 8827 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8828 | pHddCtx->wiphy = wiphy; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8829 | hdd_prevent_suspend(); |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 8830 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8831 | |
| 8832 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 8833 | |
| 8834 | /*Get vos context here bcoz vos_open requires it*/ |
| 8835 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 8836 | |
Madan Mohan Koyyalamudi | 0b78e15 | 2012-11-28 15:46:51 -0800 | [diff] [blame] | 8837 | if(pVosContext == NULL) |
| 8838 | { |
| 8839 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__); |
| 8840 | goto err_free_hdd_context; |
| 8841 | } |
| 8842 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8843 | //Save the Global VOSS context in adapter context for future. |
| 8844 | pHddCtx->pvosContext = pVosContext; |
| 8845 | |
| 8846 | //Save the adapter context in global context for future. |
| 8847 | ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx; |
| 8848 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8849 | pHddCtx->parent_dev = dev; |
| 8850 | |
| 8851 | init_completion(&pHddCtx->full_pwr_comp_var); |
| 8852 | init_completion(&pHddCtx->standby_comp_var); |
| 8853 | init_completion(&pHddCtx->req_bmps_comp_var); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8854 | init_completion(&pHddCtx->scan_info.scan_req_completion_event); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 8855 | init_completion(&pHddCtx->scan_info.abortscan_event_var); |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 8856 | init_completion(&pHddCtx->wiphy_channel_update_event); |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 8857 | init_completion(&pHddCtx->ssr_comp_var); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8858 | |
| 8859 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 8860 | init_completion(&pHddCtx->linux_reg_req); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8861 | #else |
| 8862 | init_completion(&pHddCtx->driver_crda_req); |
| 8863 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8864 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8865 | spin_lock_init(&pHddCtx->schedScan_lock); |
| 8866 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8867 | hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS ); |
| 8868 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8869 | #ifdef FEATURE_WLAN_TDLS |
| 8870 | /* tdls_lock is initialized before an hdd_open_adapter ( which is |
| 8871 | * invoked by other instances also) to protect the concurrent |
| 8872 | * access for the Adapters by TDLS module. |
| 8873 | */ |
| 8874 | mutex_init(&pHddCtx->tdls_lock); |
| 8875 | #endif |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 8876 | mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock); |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 8877 | /* By default Strict Regulatory For FCC should be false */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8878 | |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 8879 | pHddCtx->nEnableStrictRegulatoryForFCC = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8880 | // Load all config first as TL config is needed during vos_open |
| 8881 | pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL); |
| 8882 | if(pHddCtx->cfg_ini == NULL) |
| 8883 | { |
| 8884 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__); |
| 8885 | goto err_free_hdd_context; |
| 8886 | } |
| 8887 | |
| 8888 | vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t )); |
| 8889 | |
| 8890 | // Read and parse the qcom_cfg.ini file |
| 8891 | status = hdd_parse_config_ini( pHddCtx ); |
| 8892 | if ( VOS_STATUS_SUCCESS != status ) |
| 8893 | { |
| 8894 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s", |
| 8895 | __func__, WLAN_INI_FILE); |
| 8896 | goto err_config; |
| 8897 | } |
Arif Hussain | d521891 | 2013-12-05 01:10:55 -0800 | [diff] [blame] | 8898 | #ifdef MEMORY_DEBUG |
| 8899 | if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled) |
| 8900 | vos_mem_init(); |
| 8901 | |
| 8902 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d", |
| 8903 | __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled); |
| 8904 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8905 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 8906 | /* INI has been read, initialise the configuredMcastBcastFilter with |
| 8907 | * INI value as this will serve as the default value |
| 8908 | */ |
| 8909 | pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting; |
| 8910 | hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d", |
| 8911 | pHddCtx->cfg_ini->mcastBcastFilterSetting); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8912 | |
| 8913 | if (false == hdd_is_5g_supported(pHddCtx)) |
| 8914 | { |
| 8915 | //5Ghz is not supported. |
| 8916 | if (1 != pHddCtx->cfg_ini->nBandCapability) |
| 8917 | { |
| 8918 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8919 | "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__); |
| 8920 | pHddCtx->cfg_ini->nBandCapability = 1; |
| 8921 | } |
| 8922 | } |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8923 | |
| 8924 | /* If SNR Monitoring is enabled, FW has to parse all beacons |
| 8925 | * for calcaluting and storing the average SNR, so set Nth beacon |
| 8926 | * filter to 1 to enable FW to parse all the beaocons |
| 8927 | */ |
| 8928 | if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring) |
| 8929 | { |
| 8930 | /* The log level is deliberately set to WARN as overriding |
| 8931 | * nthBeaconFilter to 1 will increase power cosumption and this |
| 8932 | * might just prove helpful to detect the power issue. |
| 8933 | */ |
| 8934 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 8935 | "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__); |
| 8936 | pHddCtx->cfg_ini->nthBeaconFilter = 1; |
| 8937 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8938 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8939 | * cfg80211: Initialization ... |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8940 | */ |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 8941 | if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8942 | { |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 8943 | if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini)) |
| 8944 | { |
| 8945 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8946 | "%s: wlan_hdd_cfg80211_init return failure", __func__); |
| 8947 | goto err_config; |
| 8948 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8949 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8950 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8951 | // Update VOS trace levels based upon the cfg.ini |
| 8952 | hdd_vos_trace_enable(VOS_MODULE_ID_BAP, |
| 8953 | pHddCtx->cfg_ini->vosTraceEnableBAP); |
| 8954 | hdd_vos_trace_enable(VOS_MODULE_ID_TL, |
| 8955 | pHddCtx->cfg_ini->vosTraceEnableTL); |
| 8956 | hdd_vos_trace_enable(VOS_MODULE_ID_WDI, |
| 8957 | pHddCtx->cfg_ini->vosTraceEnableWDI); |
| 8958 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD, |
| 8959 | pHddCtx->cfg_ini->vosTraceEnableHDD); |
| 8960 | hdd_vos_trace_enable(VOS_MODULE_ID_SME, |
| 8961 | pHddCtx->cfg_ini->vosTraceEnableSME); |
| 8962 | hdd_vos_trace_enable(VOS_MODULE_ID_PE, |
| 8963 | pHddCtx->cfg_ini->vosTraceEnablePE); |
Katya Nigam | 70d6833 | 2013-09-16 16:49:45 +0530 | [diff] [blame] | 8964 | hdd_vos_trace_enable(VOS_MODULE_ID_PMC, |
| 8965 | pHddCtx->cfg_ini->vosTraceEnablePMC); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8966 | hdd_vos_trace_enable(VOS_MODULE_ID_WDA, |
| 8967 | pHddCtx->cfg_ini->vosTraceEnableWDA); |
| 8968 | hdd_vos_trace_enable(VOS_MODULE_ID_SYS, |
| 8969 | pHddCtx->cfg_ini->vosTraceEnableSYS); |
| 8970 | hdd_vos_trace_enable(VOS_MODULE_ID_VOSS, |
| 8971 | pHddCtx->cfg_ini->vosTraceEnableVOSS); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8972 | hdd_vos_trace_enable(VOS_MODULE_ID_SAP, |
| 8973 | pHddCtx->cfg_ini->vosTraceEnableSAP); |
| 8974 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP, |
| 8975 | pHddCtx->cfg_ini->vosTraceEnableHDDSAP); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8976 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8977 | // Update WDI trace levels based upon the cfg.ini |
| 8978 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL, |
| 8979 | pHddCtx->cfg_ini->wdiTraceEnableDAL); |
| 8980 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL, |
| 8981 | pHddCtx->cfg_ini->wdiTraceEnableCTL); |
| 8982 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA, |
| 8983 | pHddCtx->cfg_ini->wdiTraceEnableDAT); |
| 8984 | hdd_wdi_trace_enable(eWLAN_MODULE_PAL, |
| 8985 | pHddCtx->cfg_ini->wdiTraceEnablePAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8986 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8987 | if (VOS_FTM_MODE == hdd_get_conparam()) |
| 8988 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8989 | if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) ) |
| 8990 | { |
| 8991 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__); |
| 8992 | goto err_free_hdd_context; |
| 8993 | } |
| 8994 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__); |
c_hpothu | 2de0ef6 | 2014-04-15 16:16:15 +0530 | [diff] [blame] | 8995 | |
| 8996 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8997 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8998 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8999 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 9000 | //Open watchdog module |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9001 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 9002 | { |
| 9003 | status = vos_watchdog_open(pVosContext, |
| 9004 | &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext)); |
| 9005 | |
| 9006 | if(!VOS_IS_STATUS_SUCCESS( status )) |
| 9007 | { |
| 9008 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9009 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9010 | } |
| 9011 | } |
| 9012 | |
| 9013 | pHddCtx->isLogpInProgress = FALSE; |
| 9014 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 9015 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9016 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9017 | /* initialize the NV module. This is required so that |
| 9018 | we can initialize the channel information in wiphy |
| 9019 | from the NV.bin data. The channel information in |
| 9020 | wiphy needs to be initialized before wiphy registration */ |
| 9021 | |
| 9022 | status = vos_nv_open(); |
| 9023 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9024 | { |
| 9025 | /* NV module cannot be initialized */ |
| 9026 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 9027 | "%s: vos_nv_open failed", __func__); |
Vinay Krishna Eranna | 2025d89 | 2014-09-18 16:51:42 +0530 | [diff] [blame] | 9028 | goto err_wdclose; |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9029 | } |
| 9030 | |
| 9031 | status = vos_init_wiphy_from_nv_bin(); |
| 9032 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9033 | { |
| 9034 | /* NV module cannot be initialized */ |
| 9035 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 9036 | "%s: vos_init_wiphy failed", __func__); |
| 9037 | goto err_vos_nv_close; |
| 9038 | } |
| 9039 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9040 | #endif |
| 9041 | |
Arun Kumar Khandavalli | ebb1948 | 2014-03-25 13:56:53 +0530 | [diff] [blame] | 9042 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9043 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 9044 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9045 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 9046 | goto err_vos_nv_close; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9047 | } |
| 9048 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9049 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 9050 | |
| 9051 | if ( NULL == pHddCtx->hHal ) |
| 9052 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9053 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9054 | goto err_vosclose; |
| 9055 | } |
| 9056 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9057 | status = vos_preStart( pHddCtx->pvosContext ); |
| 9058 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9059 | { |
| 9060 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9061 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9062 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9063 | |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 9064 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) |
| 9065 | { |
| 9066 | pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan; |
| 9067 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d", |
| 9068 | __func__, enable_dfs_chan_scan); |
| 9069 | } |
| 9070 | if (0 == enable_11d || 1 == enable_11d) |
| 9071 | { |
| 9072 | pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d; |
| 9073 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d", |
| 9074 | __func__, enable_11d); |
| 9075 | } |
| 9076 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9077 | /* Note that the vos_preStart() sequence triggers the cfg download. |
| 9078 | The cfg download must occur before we update the SME config |
| 9079 | since the SME config operation must access the cfg database */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9080 | status = hdd_set_sme_config( pHddCtx ); |
| 9081 | |
| 9082 | if ( VOS_STATUS_SUCCESS != status ) |
| 9083 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9084 | 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] | 9085 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9086 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9087 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9088 | /* In the integrated architecture we update the configuration from |
| 9089 | the INI file and from NV before vOSS has been started so that |
| 9090 | the final contents are available to send down to the cCPU */ |
| 9091 | |
| 9092 | // Apply the cfg.ini to cfg.dat |
| 9093 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 9094 | { |
| 9095 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9096 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9097 | } |
| 9098 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9099 | // Get mac addr from platform driver |
| 9100 | ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes); |
| 9101 | |
| 9102 | if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9103 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9104 | /* Store the mac addr for first interface */ |
| 9105 | pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr; |
| 9106 | |
| 9107 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9108 | "%s: WLAN Mac Addr: " |
| 9109 | MAC_ADDRESS_STR, __func__, |
| 9110 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 9111 | |
| 9112 | /* Here, passing Arg2 as 1 because we do not want to change the |
| 9113 | last 3 bytes (means non OUI bytes) of first interface mac |
| 9114 | addr. |
| 9115 | */ |
| 9116 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr)) |
| 9117 | { |
| 9118 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9119 | "%s: Failed to generate wlan interface mac addr " |
| 9120 | "using MAC from ini file ", __func__); |
| 9121 | } |
| 9122 | } |
| 9123 | else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx)) |
| 9124 | { |
| 9125 | // Apply the NV to cfg.dat |
| 9126 | /* Prima Update MAC address only at here */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9127 | #ifdef WLAN_AUTOGEN_MACADDR_FEATURE |
| 9128 | /* There was not a valid set of MAC Addresses in NV. See if the |
| 9129 | default addresses were modified by the cfg.ini settings. If so, |
| 9130 | we'll use them, but if not, we'll autogenerate a set of MAC |
| 9131 | addresses based upon the device serial number */ |
| 9132 | |
| 9133 | static const v_MACADDR_t default_address = |
| 9134 | {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9135 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9136 | if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0], |
| 9137 | sizeof(default_address))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9138 | { |
| 9139 | /* cfg.ini has the default address, invoke autogen logic */ |
| 9140 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9141 | /* Here, passing Arg2 as 0 because we want to change the |
| 9142 | last 3 bytes (means non OUI bytes) of all the interfaces |
| 9143 | mac addr. |
| 9144 | */ |
| 9145 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0, |
| 9146 | default_address)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9147 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9148 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9149 | "%s: Failed to generate wlan interface mac addr " |
| 9150 | "using MAC from ini file " MAC_ADDRESS_STR, __func__, |
| 9151 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9152 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9153 | } |
| 9154 | else |
| 9155 | #endif //WLAN_AUTOGEN_MACADDR_FEATURE |
| 9156 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9157 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9158 | "%s: Invalid MAC address in NV, using MAC from ini file " |
| 9159 | MAC_ADDRESS_STR, __func__, |
| 9160 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 9161 | } |
| 9162 | } |
| 9163 | { |
| 9164 | eHalStatus halStatus; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9165 | |
| 9166 | /* Set the MAC Address Currently this is used by HAL to |
| 9167 | * add self sta. Remove this once self sta is added as |
| 9168 | * part of session open. |
| 9169 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9170 | halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID, |
| 9171 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 9172 | sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) ); |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9173 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9174 | if (!HAL_STATUS_SUCCESS( halStatus )) |
| 9175 | { |
| 9176 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 9177 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9178 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9179 | } |
| 9180 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9181 | |
| 9182 | /*Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 9183 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 9184 | status = vos_start( pHddCtx->pvosContext ); |
| 9185 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9186 | { |
| 9187 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9188 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9189 | } |
| 9190 | |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 9191 | #ifdef FEATURE_WLAN_CH_AVOID |
| 9192 | /* Plug in avoid channel notification callback |
| 9193 | * This should happen before ADD_SELF_STA |
| 9194 | * 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] | 9195 | |
| 9196 | /* check the Channel Avoidance is enabled */ |
| 9197 | if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance) |
| 9198 | { |
| 9199 | sme_AddChAvoidCallback(pHddCtx->hHal, |
| 9200 | hdd_hostapd_ch_avoid_cb); |
| 9201 | } |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 9202 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 9203 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 9204 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 9205 | hdd_exchange_version_and_caps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9206 | |
Agarwal Ashish | ad9281b | 2014-06-10 14:57:30 +0530 | [diff] [blame] | 9207 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 9208 | status = wlan_hdd_init_channels(pHddCtx); |
| 9209 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9210 | { |
| 9211 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed", |
| 9212 | __func__); |
| 9213 | goto err_vosstop; |
| 9214 | } |
| 9215 | #endif |
| 9216 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9217 | status = hdd_post_voss_start_config( pHddCtx ); |
| 9218 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9219 | { |
| 9220 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 9221 | __func__); |
| 9222 | goto err_vosstop; |
| 9223 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9224 | |
| 9225 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9226 | wlan_hdd_cfg80211_update_reg_info( wiphy ); |
| 9227 | |
| 9228 | /* registration of wiphy dev with cfg80211 */ |
| 9229 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 9230 | { |
| 9231 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 9232 | goto err_vosstop; |
| 9233 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9234 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9235 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9236 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9237 | /* registration of wiphy dev with cfg80211 */ |
| 9238 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 9239 | { |
| 9240 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 9241 | goto err_vosstop; |
| 9242 | } |
| 9243 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 9244 | status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9245 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9246 | { |
| 9247 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed", |
| 9248 | __func__); |
| 9249 | goto err_unregister_wiphy; |
| 9250 | } |
| 9251 | #endif |
| 9252 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9253 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 9254 | { |
| 9255 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d", |
| 9256 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 9257 | } |
| 9258 | else |
| 9259 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9260 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d", |
| 9261 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 9262 | if (pAdapter != NULL) |
| 9263 | { |
Katya Nigam | a7d81d7 | 2014-11-12 12:44:34 +0530 | [diff] [blame] | 9264 | 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] | 9265 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9266 | vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes, |
| 9267 | pHddCtx->cfg_ini->intfMacAddr[0].bytes, |
| 9268 | sizeof(tSirMacAddr)); |
Madan Mohan Koyyalamudi | edfc1b7 | 2012-10-18 20:25:55 -0700 | [diff] [blame] | 9269 | |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9270 | /* Generate the P2P Device Address. This consists of the device's |
| 9271 | * primary MAC address with the locally administered bit set. |
| 9272 | */ |
| 9273 | pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9274 | } |
| 9275 | else |
| 9276 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9277 | tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx); |
| 9278 | if (p2p_dev_addr != NULL) |
| 9279 | { |
| 9280 | vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0], |
| 9281 | p2p_dev_addr, VOS_MAC_ADDR_SIZE); |
| 9282 | } |
| 9283 | else |
| 9284 | { |
| 9285 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9286 | "%s: Failed to allocate mac_address for p2p_device", |
| 9287 | __func__); |
| 9288 | goto err_close_adapter; |
| 9289 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9290 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9291 | |
| 9292 | pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 9293 | &pHddCtx->p2pDeviceAddress.bytes[0], FALSE ); |
| 9294 | if ( NULL == pP2pAdapter ) |
| 9295 | { |
| 9296 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9297 | "%s: Failed to do hdd_open_adapter for P2P Device Interface", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9298 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9299 | goto err_close_adapter; |
| 9300 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9301 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9302 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9303 | |
| 9304 | if( pAdapter == NULL ) |
| 9305 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9306 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 9307 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9308 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9309 | |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9310 | if (country_code) |
| 9311 | { |
| 9312 | eHalStatus ret; |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9313 | INIT_COMPLETION(pAdapter->change_country_code); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9314 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
| 9315 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 9316 | hdd_checkandupdate_phymode(pAdapter, country_code); |
| 9317 | #endif |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 9318 | ret = sme_ChangeCountryCode(pHddCtx->hHal, |
| 9319 | (void *)(tSmeChangeCountryCallback) |
| 9320 | wlan_hdd_change_country_code_callback, |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9321 | country_code, |
| 9322 | pAdapter, pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 9323 | eSIR_TRUE, eSIR_TRUE); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9324 | if (eHAL_STATUS_SUCCESS == ret) |
| 9325 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9326 | ret = wait_for_completion_interruptible_timeout( |
| 9327 | &pAdapter->change_country_code, |
| 9328 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 9329 | |
| 9330 | if (0 >= ret) |
| 9331 | { |
| 9332 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9333 | "%s: SME while setting country code timed out", __func__); |
| 9334 | } |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9335 | } |
| 9336 | else |
| 9337 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9338 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9339 | "%s: SME Change Country code from module param fail ret=%d", |
| 9340 | __func__, ret); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9341 | } |
| 9342 | } |
| 9343 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9344 | #ifdef WLAN_BTAMP_FEATURE |
| 9345 | vStatus = WLANBAP_Open(pVosContext); |
| 9346 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9347 | { |
| 9348 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9349 | "%s: Failed to open BAP",__func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9350 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9351 | } |
| 9352 | |
| 9353 | vStatus = BSL_Init(pVosContext); |
| 9354 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9355 | { |
| 9356 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9357 | "%s: Failed to Init BSL",__func__); |
| 9358 | goto err_bap_close; |
| 9359 | } |
| 9360 | vStatus = WLANBAP_Start(pVosContext); |
| 9361 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9362 | { |
| 9363 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9364 | "%s: Failed to start TL",__func__); |
| 9365 | goto err_bap_close; |
| 9366 | } |
| 9367 | |
| 9368 | pConfig = pHddCtx->cfg_ini; |
| 9369 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 9370 | status = WLANBAP_SetConfig(&btAmpConfig); |
| 9371 | |
| 9372 | #endif //WLAN_BTAMP_FEATURE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9373 | |
Mihir Shete | 9c23877 | 2014-10-15 14:35:16 +0530 | [diff] [blame] | 9374 | /* |
| 9375 | * UapsdMask is 0xf if U-APSD is enbaled for all AC's... |
| 9376 | * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value) |
| 9377 | * which is greater than 0xf. So the below check is safe to make |
| 9378 | * sure that there is no entry for UapsdMask in the ini |
| 9379 | */ |
| 9380 | if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask) |
| 9381 | { |
| 9382 | if(IS_DYNAMIC_WMM_PS_ENABLED) |
| 9383 | { |
| 9384 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO", |
| 9385 | __func__); |
| 9386 | pHddCtx->cfg_ini->UapsdMask = |
| 9387 | CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT; |
| 9388 | } |
| 9389 | else |
| 9390 | { |
| 9391 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD", |
| 9392 | __func__); |
| 9393 | pHddCtx->cfg_ini->UapsdMask = |
| 9394 | CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT; |
| 9395 | } |
| 9396 | } |
| 9397 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 9398 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 9399 | if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE)) |
| 9400 | { |
| 9401 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__); |
| 9402 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0; |
| 9403 | sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal), |
| 9404 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled); |
| 9405 | } |
| 9406 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9407 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 9408 | wlan_hdd_tdls_init(pHddCtx); |
| 9409 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 9410 | sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done); |
| 9411 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9412 | /* Register with platform driver as client for Suspend/Resume */ |
| 9413 | status = hddRegisterPmOps(pHddCtx); |
| 9414 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9415 | { |
| 9416 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 9417 | #ifdef WLAN_BTAMP_FEATURE |
| 9418 | goto err_bap_stop; |
| 9419 | #else |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9420 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9421 | #endif //WLAN_BTAMP_FEATURE |
| 9422 | } |
| 9423 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9424 | /* Open debugfs interface */ |
| 9425 | if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter)) |
| 9426 | { |
| 9427 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9428 | "%s: hdd_debugfs_init failed!", __func__); |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9429 | } |
| 9430 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9431 | /* Register TM level change handler function to the platform */ |
| 9432 | status = hddDevTmRegisterNotifyCallback(pHddCtx); |
| 9433 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9434 | { |
| 9435 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__); |
| 9436 | goto err_unregister_pmops; |
| 9437 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9438 | |
| 9439 | /* register for riva power on lock to platform driver */ |
| 9440 | if (req_riva_power_on_lock("wlan")) |
| 9441 | { |
| 9442 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 9443 | __func__); |
| 9444 | goto err_unregister_pmops; |
| 9445 | } |
| 9446 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9447 | // register net device notifier for device change notification |
| 9448 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 9449 | |
| 9450 | if(ret < 0) |
| 9451 | { |
| 9452 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__); |
| 9453 | goto err_free_power_on_lock; |
| 9454 | } |
| 9455 | |
| 9456 | //Initialize the nlink service |
| 9457 | if(nl_srv_init() != 0) |
| 9458 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9459 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9460 | goto err_reg_netdev; |
| 9461 | } |
| 9462 | |
Leo Chang | 4ce1cc5 | 2013-10-21 18:27:15 -0700 | [diff] [blame] | 9463 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9464 | pHddCtx->kd_nl_init = 1; |
| 9465 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 9466 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9467 | //Initialize the BTC service |
| 9468 | if(btc_activate_service(pHddCtx) != 0) |
| 9469 | { |
| 9470 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__); |
| 9471 | goto err_nl_srv; |
| 9472 | } |
| 9473 | |
| 9474 | #ifdef PTT_SOCK_SVC_ENABLE |
| 9475 | //Initialize the PTT service |
| 9476 | if(ptt_sock_activate_svc(pHddCtx) != 0) |
| 9477 | { |
| 9478 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__); |
| 9479 | goto err_nl_srv; |
| 9480 | } |
| 9481 | #endif |
| 9482 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 9483 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9484 | if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable) |
| 9485 | { |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 9486 | if(wlan_logging_sock_activate_svc( |
| 9487 | pHddCtx->cfg_ini->wlanLoggingFEToConsole, |
| 9488 | pHddCtx->cfg_ini->wlanLoggingNumBuf)) |
| 9489 | { |
| 9490 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc" |
| 9491 | " failed", __func__); |
| 9492 | goto err_nl_srv; |
| 9493 | } |
| 9494 | //TODO: To Remove enableDhcpDebug and use gEnableDebugLog for |
| 9495 | //EAPOL and DHCP |
Sachin Ahuja | 8c65f38 | 2014-12-12 15:34:21 +0530 | [diff] [blame] | 9496 | if (!pHddCtx->cfg_ini->gEnableDebugLog) |
| 9497 | pHddCtx->cfg_ini->gEnableDebugLog = |
| 9498 | VOS_PKT_PROTO_TYPE_EAPOL | VOS_PKT_PROTO_TYPE_DHCP; |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 9499 | } |
| 9500 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9501 | hdd_register_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9502 | if (VOS_STA_SAP_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9503 | { |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 9504 | /* Action frame registered in one adapter which will |
| 9505 | * applicable to all interfaces |
| 9506 | */ |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 9507 | wlan_hdd_cfg80211_register_frames(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9508 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9509 | |
| 9510 | mutex_init(&pHddCtx->sap_lock); |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 9511 | mutex_init(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9512 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9513 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9514 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9515 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 9516 | /* Initialize the wake lcok */ |
| 9517 | wake_lock_init(&pHddCtx->rx_wake_lock, |
| 9518 | WAKE_LOCK_SUSPEND, |
| 9519 | "qcom_rx_wakelock"); |
| 9520 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 9521 | /* Initialize the wake lcok */ |
| 9522 | wake_lock_init(&pHddCtx->sap_wake_lock, |
| 9523 | WAKE_LOCK_SUSPEND, |
| 9524 | "qcom_sap_wakelock"); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9525 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9526 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 9527 | vos_event_init(&pHddCtx->scan_info.scan_finished_event); |
| 9528 | pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9529 | |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 9530 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9531 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 9532 | hdd_allow_suspend(); |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 9533 | |
| 9534 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9535 | /*SME must send channel update configuration to RIVA*/ |
| 9536 | sme_UpdateChannelConfig(pHddCtx->hHal); |
| 9537 | #endif |
Abhishek Singh | f644b27 | 2014-08-21 02:59:39 +0530 | [diff] [blame] | 9538 | /* Send the update default channel list to the FW*/ |
| 9539 | sme_UpdateChannelList(pHddCtx->hHal); |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 9540 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 9541 | /*updating wiphy so that regulatory user hints can be processed*/ |
| 9542 | if (wiphy) |
| 9543 | { |
| 9544 | regulatory_hint(wiphy, "00"); |
| 9545 | } |
| 9546 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9547 | // Initialize the restart logic |
| 9548 | wlan_hdd_restart_init(pHddCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 9549 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 9550 | //Register the traffic monitor timer now |
| 9551 | if ( pHddCtx->cfg_ini->dynSplitscan) |
| 9552 | { |
| 9553 | vos_timer_init(&pHddCtx->tx_rx_trafficTmr, |
| 9554 | VOS_TIMER_TYPE_SW, |
| 9555 | hdd_tx_rx_pkt_cnt_stat_timer_handler, |
| 9556 | (void *)pHddCtx); |
| 9557 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 9558 | #ifdef WLAN_FEATURE_EXTSCAN |
| 9559 | sme_EXTScanRegisterCallback(pHddCtx->hHal, |
| 9560 | wlan_hdd_cfg80211_extscan_callback, |
| 9561 | pHddCtx); |
| 9562 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9563 | goto success; |
| 9564 | |
| 9565 | err_nl_srv: |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9566 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9567 | nl_srv_exit(pHddCtx->ptt_pid); |
| 9568 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9569 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9570 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9571 | err_reg_netdev: |
| 9572 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 9573 | |
| 9574 | err_free_power_on_lock: |
| 9575 | free_riva_power_on_lock("wlan"); |
| 9576 | |
| 9577 | err_unregister_pmops: |
| 9578 | hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 9579 | hddDeregisterPmOps(pHddCtx); |
| 9580 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9581 | hdd_debugfs_exit(pHddCtx); |
| 9582 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9583 | #ifdef WLAN_BTAMP_FEATURE |
| 9584 | err_bap_stop: |
| 9585 | WLANBAP_Stop(pVosContext); |
| 9586 | #endif |
| 9587 | |
| 9588 | #ifdef WLAN_BTAMP_FEATURE |
| 9589 | err_bap_close: |
| 9590 | WLANBAP_Close(pVosContext); |
| 9591 | #endif |
| 9592 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9593 | err_close_adapter: |
| 9594 | hdd_close_all_adapters( pHddCtx ); |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 9595 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9596 | err_unregister_wiphy: |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 9597 | #endif |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9598 | wiphy_unregister(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9599 | err_vosstop: |
| 9600 | vos_stop(pVosContext); |
| 9601 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9602 | err_vosclose: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9603 | status = vos_sched_close( pVosContext ); |
| 9604 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 9605 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 9606 | "%s: Failed to close VOSS Scheduler", __func__); |
| 9607 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 9608 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9609 | vos_close(pVosContext ); |
| 9610 | |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9611 | err_vos_nv_close: |
| 9612 | |
c_hpothu | e6a3628 | 2014-03-19 12:27:38 +0530 | [diff] [blame] | 9613 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9614 | vos_nv_close(); |
| 9615 | |
c_hpothu | 70f8d81 | 2014-03-22 22:59:23 +0530 | [diff] [blame] | 9616 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9617 | |
| 9618 | err_wdclose: |
| 9619 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 9620 | vos_watchdog_close(pVosContext); |
| 9621 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9622 | err_config: |
| 9623 | kfree(pHddCtx->cfg_ini); |
| 9624 | pHddCtx->cfg_ini= NULL; |
| 9625 | |
| 9626 | err_free_hdd_context: |
| 9627 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9628 | wiphy_free(wiphy) ; |
| 9629 | //kfree(wdev) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9630 | VOS_BUG(1); |
| 9631 | |
Madan Mohan Koyyalamudi | d57ae63 | 2012-11-06 18:42:48 -0800 | [diff] [blame] | 9632 | if (hdd_is_ssr_required()) |
| 9633 | { |
| 9634 | /* WDI timeout had happened during load, so SSR is needed here */ |
| 9635 | subsystem_restart("wcnss"); |
| 9636 | msleep(5000); |
| 9637 | } |
| 9638 | hdd_set_ssr_required (VOS_FALSE); |
| 9639 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 9640 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9641 | |
| 9642 | success: |
| 9643 | EXIT(); |
| 9644 | return 0; |
| 9645 | } |
| 9646 | |
| 9647 | /**--------------------------------------------------------------------------- |
| 9648 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9649 | \brief hdd_driver_init() - Core Driver Init Function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9650 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9651 | This is the driver entry point - called in different timeline depending |
| 9652 | on whether the driver is statically or dynamically linked |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9653 | |
| 9654 | \param - None |
| 9655 | |
| 9656 | \return - 0 for success, non zero for failure |
| 9657 | |
| 9658 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9659 | static int hdd_driver_init( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9660 | { |
| 9661 | VOS_STATUS status; |
| 9662 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9663 | struct device *dev = NULL; |
| 9664 | int ret_status = 0; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9665 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 9666 | int max_retries = 0; |
| 9667 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9668 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9669 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9670 | wlan_logging_sock_init_svc(); |
| 9671 | #endif |
| 9672 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9673 | ENTER(); |
| 9674 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9675 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9676 | wake_lock_init(&wlan_wake_lock, WAKE_LOCK_SUSPEND, "wlan"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9677 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9678 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9679 | hddTraceInit(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9680 | pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME, |
| 9681 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 9682 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9683 | #ifdef ANI_BUS_TYPE_PCI |
| 9684 | |
| 9685 | dev = wcnss_wlan_get_device(); |
| 9686 | |
| 9687 | #endif // ANI_BUS_TYPE_PCI |
| 9688 | |
| 9689 | #ifdef ANI_BUS_TYPE_PLATFORM |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9690 | |
| 9691 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 9692 | /* wait until WCNSS driver downloads NV */ |
| 9693 | while (!wcnss_device_ready() && 5 >= ++max_retries) { |
| 9694 | msleep(1000); |
| 9695 | } |
| 9696 | if (max_retries >= 5) { |
| 9697 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
madan mohan koyyalamudi | 8c96ce1 | 2013-07-10 19:14:39 +0530 | [diff] [blame] | 9698 | #ifdef WLAN_OPEN_SOURCE |
| 9699 | wake_lock_destroy(&wlan_wake_lock); |
| 9700 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9701 | |
| 9702 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9703 | wlan_logging_sock_deinit_svc(); |
| 9704 | #endif |
| 9705 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9706 | return -ENODEV; |
| 9707 | } |
| 9708 | #endif |
| 9709 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9710 | dev = wcnss_wlan_get_device(); |
| 9711 | #endif // ANI_BUS_TYPE_PLATFORM |
| 9712 | |
| 9713 | |
| 9714 | do { |
| 9715 | if (NULL == dev) { |
| 9716 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__); |
| 9717 | ret_status = -1; |
| 9718 | break; |
| 9719 | } |
| 9720 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9721 | #ifdef TIMER_MANAGER |
| 9722 | vos_timer_manager_init(); |
| 9723 | #endif |
| 9724 | |
| 9725 | /* Preopen VOSS so that it is ready to start at least SAL */ |
| 9726 | status = vos_preOpen(&pVosContext); |
| 9727 | |
| 9728 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9729 | { |
| 9730 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__); |
| 9731 | ret_status = -1; |
| 9732 | break; |
| 9733 | } |
| 9734 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9735 | #ifndef MODULE |
| 9736 | /* For statically linked driver, call hdd_set_conparam to update curr_con_mode |
| 9737 | */ |
| 9738 | hdd_set_conparam((v_UINT_t)con_mode); |
| 9739 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9740 | |
| 9741 | // Call our main init function |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9742 | if (hdd_wlan_startup(dev)) |
| 9743 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9744 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed", |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9745 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9746 | vos_preClose( &pVosContext ); |
| 9747 | ret_status = -1; |
| 9748 | break; |
| 9749 | } |
| 9750 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9751 | } while (0); |
| 9752 | |
| 9753 | if (0 != ret_status) |
| 9754 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9755 | #ifdef TIMER_MANAGER |
| 9756 | vos_timer_exit(); |
| 9757 | #endif |
| 9758 | #ifdef MEMORY_DEBUG |
| 9759 | vos_mem_exit(); |
| 9760 | #endif |
| 9761 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9762 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9763 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9764 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9765 | |
| 9766 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9767 | wlan_logging_sock_deinit_svc(); |
| 9768 | #endif |
| 9769 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9770 | pr_err("%s: driver load failure\n", WLAN_MODULE_NAME); |
| 9771 | } |
| 9772 | else |
| 9773 | { |
| 9774 | //Send WLAN UP indication to Nlink Service |
| 9775 | send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); |
| 9776 | |
| 9777 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9778 | } |
| 9779 | |
| 9780 | EXIT(); |
| 9781 | |
| 9782 | return ret_status; |
| 9783 | } |
| 9784 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9785 | /**--------------------------------------------------------------------------- |
| 9786 | |
| 9787 | \brief hdd_module_init() - Init Function |
| 9788 | |
| 9789 | This is the driver entry point (invoked when module is loaded using insmod) |
| 9790 | |
| 9791 | \param - None |
| 9792 | |
| 9793 | \return - 0 for success, non zero for failure |
| 9794 | |
| 9795 | --------------------------------------------------------------------------*/ |
| 9796 | #ifdef MODULE |
| 9797 | static int __init hdd_module_init ( void) |
| 9798 | { |
| 9799 | return hdd_driver_init(); |
| 9800 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9801 | #else /* #ifdef MODULE */ |
| 9802 | static int __init hdd_module_init ( void) |
| 9803 | { |
| 9804 | /* Driver initialization is delayed to fwpath_changed_handler */ |
| 9805 | return 0; |
| 9806 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9807 | #endif /* #ifdef MODULE */ |
| 9808 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9809 | |
| 9810 | /**--------------------------------------------------------------------------- |
| 9811 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9812 | \brief hdd_driver_exit() - Exit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9813 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9814 | This is the driver exit point (invoked when module is unloaded using rmmod |
| 9815 | or con_mode was changed by userspace) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9816 | |
| 9817 | \param - None |
| 9818 | |
| 9819 | \return - None |
| 9820 | |
| 9821 | --------------------------------------------------------------------------*/ |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9822 | static void hdd_driver_exit(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9823 | { |
| 9824 | hdd_context_t *pHddCtx = NULL; |
| 9825 | v_CONTEXT_t pVosContext = NULL; |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 9826 | v_REGDOMAIN_t regId; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9827 | unsigned long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9828 | |
| 9829 | pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR); |
| 9830 | |
| 9831 | //Get the global vos context |
| 9832 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 9833 | |
| 9834 | if(!pVosContext) |
| 9835 | { |
| 9836 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 9837 | goto done; |
| 9838 | } |
| 9839 | |
| 9840 | //Get the HDD context. |
| 9841 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 9842 | |
| 9843 | if(!pHddCtx) |
| 9844 | { |
| 9845 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__); |
| 9846 | } |
| 9847 | else |
| 9848 | { |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9849 | INIT_COMPLETION(pHddCtx->ssr_comp_var); |
| 9850 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 9851 | if ((pHddCtx->isLogpInProgress) && |
| 9852 | (FALSE == vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL))) |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9853 | { |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 9854 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9855 | "%s:SSR in Progress; block rmmod !!!", __func__); |
| 9856 | rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var, |
| 9857 | msecs_to_jiffies(30000)); |
| 9858 | if(!rc) |
| 9859 | { |
| 9860 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9861 | "%s:SSR timedout, fatal error", __func__); |
| 9862 | VOS_BUG(0); |
| 9863 | } |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9864 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9865 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 9866 | rtnl_lock(); |
| 9867 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
| 9868 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 9869 | rtnl_unlock(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9870 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 9871 | /* Driver Need to send country code 00 in below condition |
| 9872 | * 1) If gCountryCodePriority is set to 1; and last country |
| 9873 | * code set is through 11d. This needs to be done in case |
| 9874 | * when NV country code is 00. |
| 9875 | * This Needs to be done as when kernel store last country |
| 9876 | * code and if stored country code is not through 11d, |
| 9877 | * in sme_HandleChangeCountryCodeByUser we will disable 11d |
| 9878 | * in next load/unload as soon as we get any country through |
| 9879 | * 11d. In sme_HandleChangeCountryCodeByUser |
| 9880 | * pMsg->countryCode will be last countryCode and |
| 9881 | * pMac->scan.countryCode11d will be country through 11d so |
| 9882 | * due to mismatch driver will disable 11d. |
| 9883 | * |
| 9884 | */ |
Agarwal Ashish | 8db3988 | 2014-07-30 21:56:07 +0530 | [diff] [blame] | 9885 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 9886 | if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) && |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 9887 | pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority && |
Abhishek Singh | 2a70596 | 2014-10-30 14:47:28 +0530 | [diff] [blame] | 9888 | sme_Is11dSupported(pHddCtx->hHal))) |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 9889 | { |
| 9890 | hddLog(VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 9891 | FL("CountryCode 00 is being set while unloading driver")); |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 9892 | vos_nv_getRegDomainFromCountryCode(®Id , "00", COUNTRY_USER); |
| 9893 | } |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 9894 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 9895 | //Do all the cleanup before deregistering the driver |
| 9896 | hdd_wlan_exit(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9897 | } |
| 9898 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9899 | vos_preClose( &pVosContext ); |
| 9900 | |
| 9901 | #ifdef TIMER_MANAGER |
| 9902 | vos_timer_exit(); |
| 9903 | #endif |
| 9904 | #ifdef MEMORY_DEBUG |
| 9905 | vos_mem_exit(); |
| 9906 | #endif |
| 9907 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9908 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9909 | wlan_logging_sock_deinit_svc(); |
| 9910 | #endif |
| 9911 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9912 | done: |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9913 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9914 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9915 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9916 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9917 | pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME); |
| 9918 | } |
| 9919 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9920 | /**--------------------------------------------------------------------------- |
| 9921 | |
| 9922 | \brief hdd_module_exit() - Exit function |
| 9923 | |
| 9924 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9925 | |
| 9926 | \param - None |
| 9927 | |
| 9928 | \return - None |
| 9929 | |
| 9930 | --------------------------------------------------------------------------*/ |
| 9931 | static void __exit hdd_module_exit(void) |
| 9932 | { |
| 9933 | hdd_driver_exit(); |
| 9934 | } |
| 9935 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9936 | #ifdef MODULE |
| 9937 | static int fwpath_changed_handler(const char *kmessage, |
| 9938 | struct kernel_param *kp) |
| 9939 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9940 | return param_set_copystring(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9941 | } |
| 9942 | |
| 9943 | static int con_mode_handler(const char *kmessage, |
| 9944 | struct kernel_param *kp) |
| 9945 | { |
Madan Mohan Koyyalamudi | f2f8d8b | 2012-10-11 17:06:59 -0700 | [diff] [blame] | 9946 | return param_set_int(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9947 | } |
| 9948 | #else /* #ifdef MODULE */ |
| 9949 | /**--------------------------------------------------------------------------- |
| 9950 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9951 | \brief kickstart_driver |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9952 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9953 | This is the driver entry point |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9954 | - delayed driver initialization when driver is statically linked |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9955 | - invoked when module parameter fwpath is modified from userspace to signal |
| 9956 | initializing the WLAN driver or when con_mode is modified from userspace |
| 9957 | to signal a switch in operating mode |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9958 | |
| 9959 | \return - 0 for success, non zero for failure |
| 9960 | |
| 9961 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9962 | static int kickstart_driver(void) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9963 | { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9964 | int ret_status; |
| 9965 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9966 | if (!wlan_hdd_inited) { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9967 | ret_status = hdd_driver_init(); |
| 9968 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 9969 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9970 | } |
| 9971 | |
| 9972 | hdd_driver_exit(); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9973 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9974 | msleep(200); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9975 | |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9976 | ret_status = hdd_driver_init(); |
| 9977 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 9978 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9979 | } |
| 9980 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9981 | /**--------------------------------------------------------------------------- |
| 9982 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9983 | \brief fwpath_changed_handler() - Handler Function |
| 9984 | |
| 9985 | Handle changes to the fwpath parameter |
| 9986 | |
| 9987 | \return - 0 for success, non zero for failure |
| 9988 | |
| 9989 | --------------------------------------------------------------------------*/ |
| 9990 | static int fwpath_changed_handler(const char *kmessage, |
| 9991 | struct kernel_param *kp) |
| 9992 | { |
| 9993 | int ret; |
| 9994 | |
| 9995 | ret = param_set_copystring(kmessage, kp); |
| 9996 | if (0 == ret) |
| 9997 | ret = kickstart_driver(); |
| 9998 | return ret; |
| 9999 | } |
| 10000 | |
| 10001 | /**--------------------------------------------------------------------------- |
| 10002 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10003 | \brief con_mode_handler() - |
| 10004 | |
| 10005 | Handler function for module param con_mode when it is changed by userspace |
| 10006 | Dynamically linked - do nothing |
| 10007 | Statically linked - exit and init driver, as in rmmod and insmod |
| 10008 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10009 | \param - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10010 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10011 | \return - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10012 | |
| 10013 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10014 | 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] | 10015 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10016 | int ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10017 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10018 | ret = param_set_int(kmessage, kp); |
| 10019 | if (0 == ret) |
| 10020 | ret = kickstart_driver(); |
| 10021 | return ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10022 | } |
| 10023 | #endif /* #ifdef MODULE */ |
| 10024 | |
| 10025 | /**--------------------------------------------------------------------------- |
| 10026 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10027 | \brief hdd_get_conparam() - |
| 10028 | |
| 10029 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 10030 | |
| 10031 | \param - None |
| 10032 | |
| 10033 | \return - tVOS_CON_MODE |
| 10034 | |
| 10035 | --------------------------------------------------------------------------*/ |
| 10036 | tVOS_CON_MODE hdd_get_conparam ( void ) |
| 10037 | { |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10038 | #ifdef MODULE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10039 | return (tVOS_CON_MODE)con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10040 | #else |
| 10041 | return (tVOS_CON_MODE)curr_con_mode; |
| 10042 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10043 | } |
| 10044 | void hdd_set_conparam ( v_UINT_t newParam ) |
| 10045 | { |
| 10046 | con_mode = newParam; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10047 | #ifndef MODULE |
| 10048 | curr_con_mode = con_mode; |
| 10049 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10050 | } |
| 10051 | /**--------------------------------------------------------------------------- |
| 10052 | |
| 10053 | \brief hdd_softap_sta_deauth() - function |
| 10054 | |
| 10055 | This to take counter measure to handle deauth req from HDD |
| 10056 | |
| 10057 | \param - pAdapter - Pointer to the HDD |
| 10058 | |
| 10059 | \param - enable - boolean value |
| 10060 | |
| 10061 | \return - None |
| 10062 | |
| 10063 | --------------------------------------------------------------------------*/ |
| 10064 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10065 | VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, |
| 10066 | struct tagCsrDelStaParams *pDelStaParams) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10067 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10068 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 10069 | VOS_STATUS vosStatus = VOS_STATUS_E_FAULT; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10070 | |
| 10071 | ENTER(); |
| 10072 | |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 10073 | hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)", |
| 10074 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10075 | |
| 10076 | //Ignore request to deauth bcmc station |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10077 | if (pDelStaParams->peerMacAddr[0] & 0x1) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 10078 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10079 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10080 | vosStatus = WLANSAP_DeauthSta(pVosContext, pDelStaParams); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10081 | |
| 10082 | EXIT(); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 10083 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10084 | } |
| 10085 | |
| 10086 | /**--------------------------------------------------------------------------- |
| 10087 | |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10088 | \brief hdd_del_all_sta() - function |
| 10089 | |
| 10090 | This function removes all the stations associated on stopping AP/P2P GO. |
| 10091 | |
| 10092 | \param - pAdapter - Pointer to the HDD |
| 10093 | |
| 10094 | \return - None |
| 10095 | |
| 10096 | --------------------------------------------------------------------------*/ |
| 10097 | |
| 10098 | int hdd_del_all_sta(hdd_adapter_t *pAdapter) |
| 10099 | { |
| 10100 | v_U16_t i; |
| 10101 | VOS_STATUS vos_status; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10102 | v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 10103 | ptSapContext pSapCtx = NULL; |
| 10104 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 10105 | if(pSapCtx == NULL){ |
| 10106 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10107 | FL("psapCtx is NULL")); |
| 10108 | return 1; |
| 10109 | } |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10110 | ENTER(); |
| 10111 | |
| 10112 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10113 | "%s: Delete all STAs associated.",__func__); |
| 10114 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 10115 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 10116 | ) |
| 10117 | { |
| 10118 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 10119 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10120 | if ((pSapCtx->aStaInfo[i].isUsed) && |
| 10121 | (!pSapCtx->aStaInfo[i].isDeauthInProgress)) |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10122 | { |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10123 | struct tagCsrDelStaParams delStaParams; |
| 10124 | |
| 10125 | WLANSAP_PopulateDelStaParams( |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10126 | pSapCtx->aStaInfo[i].macAddrSTA.bytes, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10127 | eCsrForcedDeauthSta, SIR_MAC_MGMT_DEAUTH >> 4, |
| 10128 | &delStaParams); |
| 10129 | vos_status = hdd_softap_sta_deauth(pAdapter, &delStaParams); |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10130 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10131 | pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE; |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10132 | } |
| 10133 | } |
| 10134 | } |
| 10135 | |
| 10136 | EXIT(); |
| 10137 | return 0; |
| 10138 | } |
| 10139 | |
| 10140 | /**--------------------------------------------------------------------------- |
| 10141 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10142 | \brief hdd_softap_sta_disassoc() - function |
| 10143 | |
| 10144 | This to take counter measure to handle deauth req from HDD |
| 10145 | |
| 10146 | \param - pAdapter - Pointer to the HDD |
| 10147 | |
| 10148 | \param - enable - boolean value |
| 10149 | |
| 10150 | \return - None |
| 10151 | |
| 10152 | --------------------------------------------------------------------------*/ |
| 10153 | |
| 10154 | void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress) |
| 10155 | { |
| 10156 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 10157 | |
| 10158 | ENTER(); |
| 10159 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 10160 | 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] | 10161 | |
| 10162 | //Ignore request to disassoc bcmc station |
| 10163 | if( pDestMacAddress[0] & 0x1 ) |
| 10164 | return; |
| 10165 | |
| 10166 | WLANSAP_DisassocSta(pVosContext,pDestMacAddress); |
| 10167 | } |
| 10168 | |
| 10169 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable) |
| 10170 | { |
| 10171 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 10172 | |
| 10173 | ENTER(); |
| 10174 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 10175 | 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] | 10176 | |
| 10177 | WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable); |
| 10178 | } |
| 10179 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10180 | /**--------------------------------------------------------------------------- |
| 10181 | * |
| 10182 | * \brief hdd_get__concurrency_mode() - |
| 10183 | * |
| 10184 | * |
| 10185 | * \param - None |
| 10186 | * |
| 10187 | * \return - CONCURRENCY MODE |
| 10188 | * |
| 10189 | * --------------------------------------------------------------------------*/ |
| 10190 | tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void ) |
| 10191 | { |
| 10192 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 10193 | hdd_context_t *pHddCtx; |
| 10194 | |
| 10195 | if (NULL != pVosContext) |
| 10196 | { |
| 10197 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 10198 | if (NULL != pHddCtx) |
| 10199 | { |
| 10200 | return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode; |
| 10201 | } |
| 10202 | } |
| 10203 | |
| 10204 | /* we are in an invalid state :( */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10205 | hddLog(LOGE, "%s: Invalid context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10206 | return VOS_STA; |
| 10207 | } |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10208 | v_BOOL_t |
| 10209 | wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx) |
| 10210 | { |
| 10211 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10212 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10213 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO); |
| 10214 | if (pAdapter == NULL) |
| 10215 | { |
| 10216 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10217 | FL("GO doesn't exist")); |
| 10218 | return TRUE; |
| 10219 | } |
| 10220 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 10221 | { |
| 10222 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10223 | FL("GO started")); |
| 10224 | return TRUE; |
| 10225 | } |
| 10226 | else |
| 10227 | /* wait till GO changes its interface to p2p device */ |
| 10228 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10229 | FL("Del_bss called, avoid apps suspend")); |
| 10230 | return FALSE; |
| 10231 | |
| 10232 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10233 | /* Decide whether to allow/not the apps power collapse. |
| 10234 | * Allow apps power collapse if we are in connected state. |
| 10235 | * if not, allow only if we are in IMPS */ |
| 10236 | v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx) |
| 10237 | { |
| 10238 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10239 | tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal); |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10240 | tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10241 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 10242 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10243 | hdd_adapter_t *pAdapter = NULL; |
| 10244 | VOS_STATUS status; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10245 | tVOS_CONCURRENCY_MODE concurrent_state = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10246 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10247 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 10248 | return TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10249 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10250 | concurrent_state = hdd_get_concurrency_mode(); |
| 10251 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10252 | if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) && |
| 10253 | !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx))) |
| 10254 | return FALSE; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10255 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10256 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10257 | if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) || |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10258 | (concurrent_state == (VOS_STA | VOS_P2P_GO)))&& |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10259 | (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)) |
| 10260 | return TRUE; |
| 10261 | #endif |
| 10262 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10263 | /*loop through all adapters. TBD fix for Concurrency */ |
| 10264 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10265 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10266 | { |
| 10267 | pAdapter = pAdapterNode->pAdapter; |
| 10268 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 10269 | || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 10270 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10271 | if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled) |
c_hpothu | 4e8faac | 2014-05-16 17:38:44 +0530 | [diff] [blame] | 10272 | && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10273 | && pmcState != STOPPED && pmcState != STANDBY)) || |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10274 | (eANI_BOOLEAN_TRUE == scanRspPending) || |
| 10275 | (eANI_BOOLEAN_TRUE == inMiddleOfRoaming)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10276 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10277 | hddLog( LOGE, "%s: do not allow APPS power collapse-" |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10278 | "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d", |
| 10279 | __func__, pmcState, scanRspPending, inMiddleOfRoaming ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10280 | return FALSE; |
| 10281 | } |
| 10282 | } |
| 10283 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10284 | pAdapterNode = pNext; |
| 10285 | } |
| 10286 | return TRUE; |
| 10287 | } |
| 10288 | |
Madan Mohan Koyyalamudi | c72a4d6 | 2012-11-08 14:59:34 -0800 | [diff] [blame] | 10289 | /* Decides whether to send suspend notification to Riva |
| 10290 | * if any adapter is in BMPS; then it is required */ |
| 10291 | v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx) |
| 10292 | { |
| 10293 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
| 10294 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 10295 | |
| 10296 | if (pConfig->fIsBmpsEnabled && (pmcState == BMPS)) |
| 10297 | { |
| 10298 | return TRUE; |
| 10299 | } |
| 10300 | return FALSE; |
| 10301 | } |
| 10302 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10303 | void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10304 | { |
| 10305 | switch(mode) |
| 10306 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 10307 | case VOS_STA_MODE: |
| 10308 | case VOS_P2P_CLIENT_MODE: |
| 10309 | case VOS_P2P_GO_MODE: |
| 10310 | case VOS_STA_SAP_MODE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10311 | pHddCtx->concurrency_mode |= (1 << mode); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10312 | pHddCtx->no_of_open_sessions[mode]++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10313 | break; |
| 10314 | default: |
| 10315 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10316 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10317 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 10318 | "Number of open sessions for mode %d = %d"), |
| 10319 | pHddCtx->concurrency_mode, mode, |
| 10320 | pHddCtx->no_of_open_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10321 | } |
| 10322 | |
| 10323 | |
| 10324 | void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10325 | { |
| 10326 | switch(mode) |
| 10327 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 10328 | case VOS_STA_MODE: |
| 10329 | case VOS_P2P_CLIENT_MODE: |
| 10330 | case VOS_P2P_GO_MODE: |
| 10331 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10332 | pHddCtx->no_of_open_sessions[mode]--; |
| 10333 | if (!(pHddCtx->no_of_open_sessions[mode])) |
| 10334 | pHddCtx->concurrency_mode &= (~(1 << mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10335 | break; |
| 10336 | default: |
| 10337 | break; |
| 10338 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10339 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 10340 | "Number of open sessions for mode %d = %d"), |
| 10341 | pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]); |
| 10342 | |
| 10343 | } |
| 10344 | /**--------------------------------------------------------------------------- |
| 10345 | * |
| 10346 | * \brief wlan_hdd_incr_active_session() |
| 10347 | * |
| 10348 | * This function increments the number of active sessions |
| 10349 | * maintained per device mode |
| 10350 | * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented |
| 10351 | * Incase of SAP/P2P GO upon bss start it is incremented |
| 10352 | * |
| 10353 | * \param pHddCtx - HDD Context |
| 10354 | * \param mode - device mode |
| 10355 | * |
| 10356 | * \return - None |
| 10357 | * |
| 10358 | * --------------------------------------------------------------------------*/ |
| 10359 | void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10360 | { |
| 10361 | switch (mode) { |
| 10362 | case VOS_STA_MODE: |
| 10363 | case VOS_P2P_CLIENT_MODE: |
| 10364 | case VOS_P2P_GO_MODE: |
| 10365 | case VOS_STA_SAP_MODE: |
| 10366 | pHddCtx->no_of_active_sessions[mode]++; |
| 10367 | break; |
| 10368 | default: |
| 10369 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 10370 | break; |
| 10371 | } |
| 10372 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 10373 | mode, |
| 10374 | pHddCtx->no_of_active_sessions[mode]); |
| 10375 | } |
| 10376 | |
| 10377 | /**--------------------------------------------------------------------------- |
| 10378 | * |
| 10379 | * \brief wlan_hdd_decr_active_session() |
| 10380 | * |
| 10381 | * This function decrements the number of active sessions |
| 10382 | * maintained per device mode |
| 10383 | * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented |
| 10384 | * Incase of SAP/P2P GO upon bss stop it is decremented |
| 10385 | * |
| 10386 | * \param pHddCtx - HDD Context |
| 10387 | * \param mode - device mode |
| 10388 | * |
| 10389 | * \return - None |
| 10390 | * |
| 10391 | * --------------------------------------------------------------------------*/ |
| 10392 | void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10393 | { |
| 10394 | switch (mode) { |
| 10395 | case VOS_STA_MODE: |
| 10396 | case VOS_P2P_CLIENT_MODE: |
| 10397 | case VOS_P2P_GO_MODE: |
| 10398 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 5325f52 | 2014-08-06 00:58:44 +0530 | [diff] [blame] | 10399 | if (pHddCtx->no_of_active_sessions[mode] > 0) |
| 10400 | pHddCtx->no_of_active_sessions[mode]--; |
| 10401 | else |
| 10402 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions" |
| 10403 | "is already Zero")); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10404 | break; |
| 10405 | default: |
| 10406 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 10407 | break; |
| 10408 | } |
| 10409 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 10410 | mode, |
| 10411 | pHddCtx->no_of_active_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10412 | } |
| 10413 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10414 | /**--------------------------------------------------------------------------- |
| 10415 | * |
| 10416 | * \brief wlan_hdd_restart_init |
| 10417 | * |
| 10418 | * This function initalizes restart timer/flag. An internal function. |
| 10419 | * |
| 10420 | * \param - pHddCtx |
| 10421 | * |
| 10422 | * \return - None |
| 10423 | * |
| 10424 | * --------------------------------------------------------------------------*/ |
| 10425 | |
| 10426 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx) |
| 10427 | { |
| 10428 | /* Initialize */ |
| 10429 | pHddCtx->hdd_restart_retries = 0; |
| 10430 | atomic_set(&pHddCtx->isRestartInProgress, 0); |
| 10431 | vos_timer_init(&pHddCtx->hdd_restart_timer, |
| 10432 | VOS_TIMER_TYPE_SW, |
| 10433 | wlan_hdd_restart_timer_cb, |
| 10434 | pHddCtx); |
| 10435 | } |
| 10436 | /**--------------------------------------------------------------------------- |
| 10437 | * |
| 10438 | * \brief wlan_hdd_restart_deinit |
| 10439 | * |
| 10440 | * This function cleans up the resources used. An internal function. |
| 10441 | * |
| 10442 | * \param - pHddCtx |
| 10443 | * |
| 10444 | * \return - None |
| 10445 | * |
| 10446 | * --------------------------------------------------------------------------*/ |
| 10447 | |
| 10448 | static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx) |
| 10449 | { |
| 10450 | |
| 10451 | VOS_STATUS vos_status; |
| 10452 | /* Block any further calls */ |
| 10453 | atomic_set(&pHddCtx->isRestartInProgress, 1); |
| 10454 | /* Cleanup */ |
| 10455 | vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer ); |
| 10456 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10457 | hddLog(LOGE, FL("Failed to stop HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10458 | vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer); |
| 10459 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10460 | hddLog(LOGE, FL("Failed to destroy HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10461 | |
| 10462 | } |
| 10463 | |
| 10464 | /**--------------------------------------------------------------------------- |
| 10465 | * |
| 10466 | * \brief wlan_hdd_framework_restart |
| 10467 | * |
| 10468 | * This function uses a cfg80211 API to start a framework initiated WLAN |
| 10469 | * driver module unload/load. |
| 10470 | * |
| 10471 | * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT). |
| 10472 | * |
| 10473 | * |
| 10474 | * \param - pHddCtx |
| 10475 | * |
| 10476 | * \return - VOS_STATUS_SUCCESS: Success |
| 10477 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 10478 | * VOS_STATUS_E_NOMEM: No memory |
| 10479 | |
| 10480 | * --------------------------------------------------------------------------*/ |
| 10481 | |
| 10482 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx) |
| 10483 | { |
| 10484 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 10485 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10486 | int len = (sizeof (struct ieee80211_mgmt)); |
| 10487 | struct ieee80211_mgmt *mgmt = NULL; |
| 10488 | |
| 10489 | /* Prepare the DEAUTH managment frame with reason code */ |
| 10490 | mgmt = kzalloc(len, GFP_KERNEL); |
| 10491 | if(mgmt == NULL) |
| 10492 | { |
| 10493 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10494 | "%s: memory allocation failed (%d bytes)", __func__, len); |
| 10495 | return VOS_STATUS_E_NOMEM; |
| 10496 | } |
| 10497 | mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10498 | |
| 10499 | /* Iterate over all adapters/devices */ |
| 10500 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10501 | do |
| 10502 | { |
| 10503 | if( (status == VOS_STATUS_SUCCESS) && |
| 10504 | pAdapterNode && |
| 10505 | pAdapterNode->pAdapter) |
| 10506 | { |
| 10507 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10508 | "restarting the driver(intf:\'%s\' mode:%d :try %d)", |
| 10509 | pAdapterNode->pAdapter->dev->name, |
| 10510 | pAdapterNode->pAdapter->device_mode, |
| 10511 | pHddCtx->hdd_restart_retries + 1); |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10512 | /* |
| 10513 | * CFG80211 event to restart the driver |
| 10514 | * |
| 10515 | * 'cfg80211_send_unprot_deauth' sends a |
| 10516 | * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state |
| 10517 | * of SME(Linux Kernel) state machine. |
| 10518 | * |
| 10519 | * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart |
| 10520 | * the driver. |
| 10521 | * |
| 10522 | */ |
| 10523 | |
| 10524 | cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10525 | } |
| 10526 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10527 | pAdapterNode = pNext; |
| 10528 | } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)); |
| 10529 | |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10530 | |
| 10531 | /* Free the allocated management frame */ |
| 10532 | kfree(mgmt); |
| 10533 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10534 | /* Retry until we unload or reach max count */ |
| 10535 | if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT) |
| 10536 | vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS); |
| 10537 | |
| 10538 | return status; |
| 10539 | |
| 10540 | } |
| 10541 | /**--------------------------------------------------------------------------- |
| 10542 | * |
| 10543 | * \brief wlan_hdd_restart_timer_cb |
| 10544 | * |
| 10545 | * Restart timer callback. An internal function. |
| 10546 | * |
| 10547 | * \param - User data: |
| 10548 | * |
| 10549 | * \return - None |
| 10550 | * |
| 10551 | * --------------------------------------------------------------------------*/ |
| 10552 | |
| 10553 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback) |
| 10554 | { |
| 10555 | hdd_context_t *pHddCtx = usrDataForCallback; |
| 10556 | wlan_hdd_framework_restart(pHddCtx); |
| 10557 | return; |
| 10558 | |
| 10559 | } |
| 10560 | |
| 10561 | |
| 10562 | /**--------------------------------------------------------------------------- |
| 10563 | * |
| 10564 | * \brief wlan_hdd_restart_driver |
| 10565 | * |
| 10566 | * This function sends an event to supplicant to restart the WLAN driver. |
| 10567 | * |
| 10568 | * This function is called from vos_wlanRestart. |
| 10569 | * |
| 10570 | * \param - pHddCtx |
| 10571 | * |
| 10572 | * \return - VOS_STATUS_SUCCESS: Success |
| 10573 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 10574 | * VOS_STATUS_E_ALREADY: Request already in progress |
| 10575 | |
| 10576 | * --------------------------------------------------------------------------*/ |
| 10577 | VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx) |
| 10578 | { |
| 10579 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 10580 | |
| 10581 | /* A tight check to make sure reentrancy */ |
| 10582 | if(atomic_xchg(&pHddCtx->isRestartInProgress, 1)) |
| 10583 | { |
Mihir Shete | fd52865 | 2014-06-23 19:07:50 +0530 | [diff] [blame] | 10584 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10585 | "%s: WLAN restart is already in progress", __func__); |
| 10586 | |
| 10587 | return VOS_STATUS_E_ALREADY; |
| 10588 | } |
Sameer Thalappil | 0c164f5 | 2013-03-28 15:27:56 -0700 | [diff] [blame] | 10589 | /* Send reset FIQ to WCNSS to invoke SSR. */ |
Madan Mohan Koyyalamudi | e388b34 | 2012-11-08 15:03:16 -0800 | [diff] [blame] | 10590 | #ifdef HAVE_WCNSS_RESET_INTR |
Madan Mohan Koyyalamudi | bb8f017 | 2012-09-28 15:36:06 -0700 | [diff] [blame] | 10591 | wcnss_reset_intr(); |
| 10592 | #endif |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 10593 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10594 | return status; |
| 10595 | } |
| 10596 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 10597 | /**--------------------------------------------------------------------------- |
| 10598 | * |
| 10599 | * \brief wlan_hdd_init_channels |
| 10600 | * |
| 10601 | * This function is used to initialize the channel list in CSR |
| 10602 | * |
| 10603 | * This function is called from hdd_wlan_startup |
| 10604 | * |
| 10605 | * \param - pHddCtx: HDD context |
| 10606 | * |
| 10607 | * \return - VOS_STATUS_SUCCESS: Success |
| 10608 | * VOS_STATUS_E_FAULT: Failure reported by SME |
| 10609 | |
| 10610 | * --------------------------------------------------------------------------*/ |
| 10611 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx) |
| 10612 | { |
| 10613 | eHalStatus status; |
| 10614 | |
| 10615 | status = sme_InitChannels(pHddCtx->hHal); |
| 10616 | if (HAL_STATUS_SUCCESS(status)) |
| 10617 | { |
| 10618 | return VOS_STATUS_SUCCESS; |
| 10619 | } |
| 10620 | else |
| 10621 | { |
| 10622 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)", |
| 10623 | __func__, status); |
| 10624 | return VOS_STATUS_E_FAULT; |
| 10625 | } |
| 10626 | } |
| 10627 | |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 10628 | #ifdef CONFIG_ENABLE_LINUX_REG |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 10629 | 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] | 10630 | { |
| 10631 | eHalStatus status; |
| 10632 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 10633 | status = sme_InitChannelsForCC(pHddCtx->hHal, init); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 10634 | if (HAL_STATUS_SUCCESS(status)) |
| 10635 | { |
| 10636 | return VOS_STATUS_SUCCESS; |
| 10637 | } |
| 10638 | else |
| 10639 | { |
| 10640 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)", |
| 10641 | __func__, status); |
| 10642 | return VOS_STATUS_E_FAULT; |
| 10643 | } |
| 10644 | } |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 10645 | #endif |
Sudhir Sattayappa Kohalli | b1d8c3a | 2013-06-18 14:47:20 -0700 | [diff] [blame] | 10646 | /* |
| 10647 | * API to find if there is any STA or P2P-Client is connected |
| 10648 | */ |
| 10649 | VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx) |
| 10650 | { |
| 10651 | return sme_isSta_p2p_clientConnected(pHddCtx->hHal); |
| 10652 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10653 | |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 10654 | /* |
| 10655 | * API to find if there is any session connected |
| 10656 | */ |
| 10657 | VOS_STATUS hdd_is_any_session_connected(hdd_context_t *pHddCtx) |
| 10658 | { |
| 10659 | return sme_is_any_session_connected(pHddCtx->hHal); |
| 10660 | } |
| 10661 | |
| 10662 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10663 | int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter) |
| 10664 | { |
| 10665 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10666 | hdd_scaninfo_t *pScanInfo = NULL; |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10667 | long status = 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10668 | |
| 10669 | pScanInfo = &pHddCtx->scan_info; |
| 10670 | if (pScanInfo->mScanPending) |
| 10671 | { |
| 10672 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 10673 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10674 | eCSR_SCAN_ABORT_DEFAULT); |
| 10675 | |
| 10676 | status = wait_for_completion_interruptible_timeout( |
| 10677 | &pScanInfo->abortscan_event_var, |
| 10678 | msecs_to_jiffies(5000)); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10679 | if (0 >= status) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10680 | { |
| 10681 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10682 | "%s: Timeout or Interrupt occurred while waiting for abort" |
| 10683 | "scan, status- %ld", __func__, status); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10684 | return -ETIMEDOUT; |
| 10685 | } |
| 10686 | } |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10687 | return 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10688 | } |
| 10689 | |
c_hpothu | 225aa7c | 2014-10-22 17:45:13 +0530 | [diff] [blame] | 10690 | VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx) |
| 10691 | { |
| 10692 | hdd_adapter_t *pAdapter; |
| 10693 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10694 | VOS_STATUS vosStatus; |
| 10695 | |
| 10696 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10697 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 10698 | { |
| 10699 | pAdapter = pAdapterNode->pAdapter; |
| 10700 | if (NULL != pAdapter) |
| 10701 | { |
| 10702 | if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode || |
| 10703 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode || |
| 10704 | WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 10705 | { |
| 10706 | hddLog(LOG1, FL("abort ROC deviceMode: %d"), |
| 10707 | pAdapter->device_mode); |
| 10708 | if (VOS_STATUS_SUCCESS != |
| 10709 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter)) |
| 10710 | { |
| 10711 | hddLog(LOGE, FL("failed to abort ROC")); |
| 10712 | return VOS_STATUS_E_FAILURE; |
| 10713 | } |
| 10714 | } |
| 10715 | } |
| 10716 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10717 | pAdapterNode = pNext; |
| 10718 | } |
| 10719 | return VOS_STATUS_SUCCESS; |
| 10720 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10721 | //Register the module init/exit functions |
| 10722 | module_init(hdd_module_init); |
| 10723 | module_exit(hdd_module_exit); |
| 10724 | |
| 10725 | MODULE_LICENSE("Dual BSD/GPL"); |
| 10726 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 10727 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 10728 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10729 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 10730 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10731 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10732 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10733 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 10734 | |
| 10735 | module_param(enable_dfs_chan_scan, int, |
| 10736 | S_IRUSR | S_IRGRP | S_IROTH); |
| 10737 | |
| 10738 | module_param(enable_11d, int, |
| 10739 | S_IRUSR | S_IRGRP | S_IROTH); |
| 10740 | |
| 10741 | module_param(country_code, charp, |
| 10742 | S_IRUSR | S_IRGRP | S_IROTH); |