blob: 591f463195debc4d77e5bf7cc6b87fa8145d841e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * 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 Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/** ------------------------------------------------------------------------ *
31 ------------------------------------------------------------------------ *
32
33
34 \file wlan_hdd_wext.c
35
36 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
37 interfaces.
38
39 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041 This file defines all of the types that are utilized by the CCP module
42 of the "Portable" HDD. This file also includes the underlying Linux
43 Wireless Extensions Data types referred to by CCP.
44
45 ======================================================================== */
46
47#include <linux/version.h>
48#include <linux/module.h>
49#include <linux/kernel.h>
50#include <linux/init.h>
51#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053052#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include <wlan_hdd_includes.h>
54#include <wlan_btc_svc.h>
55#include <wlan_nlink_common.h>
56#ifdef WLAN_BTAMP_FEATURE
57#include <bap_hdd_main.h>
58#endif
59#include <vos_api.h>
60#include <net/arp.h>
61#include "ccmApi.h"
62#include "sirParams.h"
63#include "csrApi.h"
64#include "csrInsideApi.h"
65#if defined WLAN_FEATURE_VOWIFI
66#include "smeRrmInternal.h"
67#endif
68#include <aniGlobal.h>
69#include "dot11f.h"
70#include <wlan_hdd_wowl.h>
71#include <wlan_hdd_cfg.h>
72#include <wlan_hdd_wmm.h>
73#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070074#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053075#ifdef FEATURE_WLAN_TDLS
76#include "wlan_hdd_tdls.h"
77#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070078
79#ifdef CONFIG_HAS_EARLYSUSPEND
80#include <linux/earlysuspend.h>
81#endif
82#include "wlan_hdd_power.h"
83#include "qwlan_version.h"
84#include <vos_power.h>
85#include "wlan_hdd_host_offload.h"
86#include "wlan_hdd_keep_alive.h"
87#ifdef WLAN_FEATURE_PACKET_FILTERING
88#include "wlan_hdd_packet_filtering.h"
89#endif
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091#include <linux/wireless.h>
92#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053094#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96#include "wlan_hdd_misc.h"
97#include "bap_hdd_misc.h"
98
99#include "wlan_hdd_dev_pwr.h"
100#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530101#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700102#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530103#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
105#ifdef CONFIG_HAS_EARLYSUSPEND
106extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
107extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
108#endif
109
Jeff Johnsone7245742012-09-05 17:12:55 -0700110#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800111#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700112#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700113
114#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530115#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700119static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700120module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122/* To Validate Channel against the Frequency and Vice-Versa */
123static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
124 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
125 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
126 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
127 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
128 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
129 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
130 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800131 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
132 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700133
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800134#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700135
136/* Private ioctls and their sub-ioctls */
137#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
138#define WE_SET_11D_STATE 1
139#define WE_WOWL 2
140#define WE_SET_POWER 3
141#define WE_SET_MAX_ASSOC 4
142#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
143#define WE_SET_DATA_INACTIVITY_TO 6
144#define WE_SET_MAX_TX_POWER 7
145#define WE_SET_HIGHER_DTIM_TRANSITION 8
146#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530147#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700148#define WE_SET_MAX_TX_POWER_2_4 11
149#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800150/* Private IOCTL for debug connection issues */
151#define WE_SET_DEBUG_LOG 13
Jeff Johnson295189b2012-06-20 16:38:30 -0700152
153/* Private ioctls and their sub-ioctls */
154#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
155#define WE_GET_11D_STATE 1
156#define WE_IBSS_STATUS 2
157#define WE_PMC_STATE 3
158#define WE_GET_WLAN_DBG 4
159#define WE_MODULE_DOWN_IND 5
160#define WE_GET_MAX_ASSOC 6
161#define WE_GET_WDI_DBG 7
162#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
163#define WE_GET_CONCURRENCY_MODE 9
164/* Private ioctls and their sub-ioctls */
165#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
166
167/* Private ioctls and their sub-ioctls */
168#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
169#define WE_WOWL_ADD_PTRN 1
170#define WE_WOWL_DEL_PTRN 2
171#if defined WLAN_FEATURE_VOWIFI
172#define WE_NEIGHBOR_REPORT_REQUEST 3
173#endif
174#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
175#define WE_SET_CONFIG 5
176
177/* Private ioctls and their sub-ioctls */
178#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
179#define WE_SET_WLAN_DBG 1
180#define WE_SET_WDI_DBG 2
181#define WE_SET_SAP_CHANNELS 3
182
183/* Private ioctls and their sub-ioctls */
184#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
185#define WE_WLAN_VERSION 1
186#define WE_GET_STATS 2
187#define WE_GET_CFG 3
188#define WE_GET_WMM_STATUS 4
189#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700190#ifdef WLAN_FEATURE_11AC
191#define WE_GET_RSSI 6
192#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800193#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800194#ifdef FEATURE_WLAN_TDLS
195#define WE_GET_TDLS_PEERS 8
196#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700197#ifdef WLAN_FEATURE_11W
198#define WE_GET_11W_INFO 9
199#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530200#define WE_GET_STATES 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
202/* Private ioctls and their sub-ioctls */
203#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
204#define WE_CLEAR_STATS 1
205#define WE_INIT_AP 2
206#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530207#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700208#define WE_ENABLE_AMP 4
209#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530210#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700211#define WE_ENABLE_DXE_STALL_DETECT 6
212#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700213#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530214#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530215#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700216
217/* Private ioctls and their sub-ioctls */
218#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
219#define WE_LOG_DUMP_CMD 1
220
Jeff Johnson295189b2012-06-20 16:38:30 -0700221#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800222//IOCTL to configure MCC params
223#define WE_MCC_CONFIG_CREDENTIAL 3
224#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700225
Chilam NG571c65a2013-01-19 12:27:36 +0530226#ifdef FEATURE_WLAN_TDLS
227#define WE_TDLS_CONFIG_PARAMS 5
228#endif
229
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700230#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530231#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700232
Chilam Ng01120412013-02-19 18:32:21 -0800233#ifdef FEATURE_WLAN_TDLS
234#undef MAX_VAR_ARGS
235#define MAX_VAR_ARGS 10
236#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700237#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800238#endif
239
Jeff Johnson295189b2012-06-20 16:38:30 -0700240
241/* Private ioctls (with no sub-ioctls) */
242/* note that they must be odd so that they have "get" semantics */
243#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
244#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
245#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
246
247#ifdef FEATURE_WLAN_WAPI
248/* Private ioctls EVEN NO: SET, ODD NO:GET */
249#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
250#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
251#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
252#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
253#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
254#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
255#define WAPI_PSK_AKM_SUITE 0x02721400
256#define WAPI_CERT_AKM_SUITE 0x01721400
257#endif
258
Jeff Johnsone7245742012-09-05 17:12:55 -0700259#ifdef FEATURE_OEM_DATA_SUPPORT
260/* Private ioctls for setting the measurement configuration */
261#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
262#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
263#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700264
265#ifdef WLAN_FEATURE_VOWIFI_11R
266#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
267#endif
268
269/* Private ioctl for setting the host offload feature */
270#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
271
272/* Private ioctl to get the statistics */
273#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
274
275/* Private ioctl to set the Keep Alive Params */
276#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
277#ifdef WLAN_FEATURE_PACKET_FILTERING
278/* Private ioctl to set the Packet Filtering Params */
279#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
280#endif
281
282#ifdef FEATURE_WLAN_SCAN_PNO
283/* Private ioctl to get the statistics */
284#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
285#endif
286
287#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
288
289#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
290#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700291/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700292
Jeff Johnson295189b2012-06-20 16:38:30 -0700293#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
294#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
295
296#define WLAN_STATS_INVALID 0
297#define WLAN_STATS_RETRY_CNT 1
298#define WLAN_STATS_MUL_RETRY_CNT 2
299#define WLAN_STATS_TX_FRM_CNT 3
300#define WLAN_STATS_RX_FRM_CNT 4
301#define WLAN_STATS_FRM_DUP_CNT 5
302#define WLAN_STATS_FAIL_CNT 6
303#define WLAN_STATS_RTS_FAIL_CNT 7
304#define WLAN_STATS_ACK_FAIL_CNT 8
305#define WLAN_STATS_RTS_SUC_CNT 9
306#define WLAN_STATS_RX_DISCARD_CNT 10
307#define WLAN_STATS_RX_ERROR_CNT 11
308#define WLAN_STATS_TX_BYTE_CNT 12
309
310#define WLAN_STATS_RX_BYTE_CNT 13
311#define WLAN_STATS_RX_RATE 14
312#define WLAN_STATS_TX_RATE 15
313
Jeff Johnsone7245742012-09-05 17:12:55 -0700314#define WLAN_STATS_RX_UC_BYTE_CNT 16
315#define WLAN_STATS_RX_MC_BYTE_CNT 17
316#define WLAN_STATS_RX_BC_BYTE_CNT 18
317#define WLAN_STATS_TX_UC_BYTE_CNT 19
318#define WLAN_STATS_TX_MC_BYTE_CNT 20
319#define WLAN_STATS_TX_BC_BYTE_CNT 21
320
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800321#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
322 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
323 { \
324 *__p++ = __type; \
325 *__p++ = __size; \
326 memcpy(__p, __val, __size); \
327 __p += __size; \
328 __tlen += __size + 2; \
329 } \
330 else \
331 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800332 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800333 } \
334 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700335
336#define VERSION_VALUE_MAX_LEN 32
337
338#define TX_PER_TRACKING_DEFAULT_RATIO 5
339#define TX_PER_TRACKING_MAX_RATIO 10
340#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
341
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530342#define WLAN_ADAPTER 0
343#define P2P_ADAPTER 1
344
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800345/*MCC Configuration parameters */
346enum {
347 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
348 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
349 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
350 MCC_RX_DRAIN_TIME_CFG_PARAM,
351 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
352 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
353 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
354 MCC_MIN_AFTER_DTIM_CFG_PARAM,
355 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
356};
357
358int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
359 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
360
Jeff Johnson295189b2012-06-20 16:38:30 -0700361#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800362int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700363 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700364#endif
365
Jeff Johnson295189b2012-06-20 16:38:30 -0700366/**---------------------------------------------------------------------------
367
Arif Hussain0273cba2014-01-07 20:58:29 -0800368 \brief mem_alloc_copy_from_user_helper -
369
370 Helper function to allocate buffer and copy user data.
371
372 \param - wrqu - Pointer to IOCTL Data.
373 len - size
374
375 \return - On Success pointer to buffer, On failure NULL
376
377 --------------------------------------------------------------------------*/
378static void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
379{
380 u8 *ptr = NULL;
381
382 /* in order to protect the code, an extra byte is post appended to the buffer
383 * and the null termination is added. However, when allocating (len+1) byte
384 * of memory, we need to make sure that there is no uint overflow when doing
385 * addition. In theory check len < UINT_MAX protects the uint overflow. For
386 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
387 * guess, now, it is assumed that the private command buffer size is no
388 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
389 */
390 if (len > MAX_USER_COMMAND_SIZE)
391 {
392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
393 "Invalid length");
394 return NULL;
395 }
396
397 ptr = kmalloc(len + 1, GFP_KERNEL);
398 if (NULL == ptr)
399 {
400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
401 "unable to allocate memory");
402 return NULL;
403 }
404
405 if (copy_from_user(ptr, wrqu_data, len))
406 {
407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
408 "%s: failed to copy data to user buffer", __func__);
409 kfree(ptr);
410 return NULL;
411 }
412 ptr[len] = '\0';
413 return ptr;
414}
415
Girish Gowli488ef492014-06-12 18:44:33 +0530416// Function to handle and get compatible struct iw_point passed to ioctl.
417int hdd_priv_get_data(struct iw_point *p_priv_data,
418 union iwreq_data *wrqu)
419{
420 if ((NULL == p_priv_data) || (NULL == wrqu))
421 {
422 return -EINVAL;
423 }
424
425#ifdef CONFIG_COMPAT
426 if (is_compat_task())
427 {
428 struct compat_iw_point *p_compat_priv_data;
429
430 // Compat task: typecast to campat structure and copy the members.
431 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
432
433 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
434 p_priv_data->length = p_compat_priv_data->length;
435 p_priv_data->flags = p_compat_priv_data->flags;
436 }//if(is_compat_task())
437 else
438 {
439#endif //#ifdef CONFIG_COMPAT
440
441 // Non compat task: directly copy the structure.
442 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
443
444#ifdef CONFIG_COMPAT
445 }//else of - if(is_compat_task())
446#endif //#ifdef CONFIG_COMPAT
447
448 return 0;
449}
450
Arif Hussain0273cba2014-01-07 20:58:29 -0800451/**---------------------------------------------------------------------------
452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 \brief hdd_wlan_get_version() -
454
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800455 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700456
457 \param - pAdapter Pointer to the adapter.
458 wrqu - Pointer to IOCTL REQUEST Data.
459 extra - Pointer to char
460
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800461 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700462
463 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800464void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
465 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700466{
467 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800468 tSirVersionString wcnss_SW_version;
469 tSirVersionString wcnss_HW_version;
470 char *pSWversion;
471 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700473
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800474 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
475 sizeof(wcnss_SW_version));
476 if (VOS_IS_STATUS_SUCCESS(status))
477 {
478 pSWversion = wcnss_SW_version;
479 }
480 else
481 {
482 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700483 }
484
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800485 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
486 sizeof(wcnss_HW_version));
487 if (VOS_IS_STATUS_SUCCESS(status))
488 {
489 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800491 else
492 {
493 pHWversion = "Unknown";
494 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700495
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700496 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800497 "Host SW:%s, FW:%s, HW:%s",
498 QWLAN_VERSIONSTR,
499 pSWversion,
500 pHWversion);
501
502 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700503}
504
Jeff Johnson295189b2012-06-20 16:38:30 -0700505int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
506{
507 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
508 v_U32_t threshold = 0,status = 0;
509
510 ENTER();
511
Agarwal Ashish971c2882013-10-30 20:11:12 +0530512 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
513 {
514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 "%s:LOGP in Progress. Ignore!!!",__func__);
516 return status;
517 }
518
519 if ( eHAL_STATUS_SUCCESS !=
520 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
521 {
c_hpothub8245442013-11-20 23:41:09 +0530522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
523 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 return -EIO;
525 }
526 wrqu->rts.value = threshold;
527
528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800529 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700530
531 EXIT();
532
533 return 0;
534}
535
536int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
537{
538 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
539 v_U32_t threshold = 0,status = 0;
540
541 ENTER();
542
Agarwal Ashish971c2882013-10-30 20:11:12 +0530543 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
544 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
546 "%s:LOGP in Progress. Ignore!!!",__func__);
547 return status;
548 }
549
550 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
551 != eHAL_STATUS_SUCCESS )
552 {
c_hpothub8245442013-11-20 23:41:09 +0530553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
554 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 return -EIO;
556 }
557 wrqu->frag.value = threshold;
558
559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800560 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700561
562 EXIT();
563
564 return 0;
565}
566
567int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
568{
Jeff Johnsone7245742012-09-05 17:12:55 -0700569 int i;
570 if (channel > 0)
571 {
572 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
573 {
574 if (channel == freq_chan_map[i].chan)
575 {
576 *pfreq = freq_chan_map[i].freq;
577 return 1;
578 }
579 }
580 }
581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800582 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700583 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700584}
585
586static v_BOOL_t
587hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
588{
589 v_BOOL_t rsnType = VOS_FALSE;
590 // is the authType supported?
591 switch (authType)
592 {
593 case eCSR_AUTH_TYPE_NONE: //never used
594 rsnType = eANI_BOOLEAN_FALSE;
595 break;
596 // MAC layer authentication types
597 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
598 rsnType = eANI_BOOLEAN_FALSE;
599 break;
600 case eCSR_AUTH_TYPE_SHARED_KEY:
601 rsnType = eANI_BOOLEAN_FALSE;
602 break;
603 case eCSR_AUTH_TYPE_AUTOSWITCH:
604 rsnType = eANI_BOOLEAN_FALSE;
605 break;
606
607 // Upper layer authentication types
608 case eCSR_AUTH_TYPE_WPA:
609 rsnType = eANI_BOOLEAN_TRUE;
610 break;
611 case eCSR_AUTH_TYPE_WPA_PSK:
612 rsnType = eANI_BOOLEAN_TRUE;
613 break;
614 case eCSR_AUTH_TYPE_WPA_NONE:
615 rsnType = eANI_BOOLEAN_TRUE;
616 break;
617#ifdef WLAN_FEATURE_VOWIFI_11R
618 case eCSR_AUTH_TYPE_FT_RSN:
619#endif
620 case eCSR_AUTH_TYPE_RSN:
621 rsnType = eANI_BOOLEAN_TRUE;
622 break;
623#ifdef WLAN_FEATURE_VOWIFI_11R
624 case eCSR_AUTH_TYPE_FT_RSN_PSK:
625#endif
626 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700627#ifdef WLAN_FEATURE_11W
628 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
629#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 rsnType = eANI_BOOLEAN_TRUE;
631 break;
632 //case eCSR_AUTH_TYPE_FAILED:
633 case eCSR_AUTH_TYPE_UNKNOWN:
634 rsnType = eANI_BOOLEAN_FALSE;
635 break;
636 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800637 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
638 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 rsnType = eANI_BOOLEAN_FALSE;
640 break;
641 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800642 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700643 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 return rsnType;
645}
646
647static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
648{
649 struct statsContext *pStatsContext;
650 hdd_adapter_t *pAdapter;
651
652 if (ioctl_debug)
653 {
654 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700655 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 }
657
658 if (NULL == pContext)
659 {
660 hddLog(VOS_TRACE_LEVEL_ERROR,
661 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700662 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 return;
664 }
665
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 pStatsContext = pContext;
667 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800668
669 /* there is a race condition that exists between this callback
670 function and the caller since the caller could time out either
671 before or while this code is executing. we use a spinlock to
672 serialize these actions */
673 spin_lock(&hdd_context_lock);
674
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
676 {
677 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800678 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700679 hddLog(VOS_TRACE_LEVEL_WARN,
680 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700681 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 if (ioctl_debug)
683 {
684 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700685 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700686 }
687 return;
688 }
689
Jeff Johnson72a40512013-12-19 10:14:15 -0800690 /* context is valid so caller is still waiting */
691
692 /* paranoia: invalidate the magic */
693 pStatsContext->magic = 0;
694
695 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 pAdapter->rssi = rssi;
697
Jeff Johnson72a40512013-12-19 10:14:15 -0800698 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800700
701 /* serialization is complete */
702 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700703}
704
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530705static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
706{
707 struct statsContext *pStatsContext;
708 hdd_adapter_t *pAdapter;
709
710 if (ioctl_debug)
711 {
712 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
713 __func__, (int)snr, (int)staId, pContext);
714 }
715
716 if (NULL == pContext)
717 {
718 hddLog(VOS_TRACE_LEVEL_ERROR,
719 "%s: Bad param, pContext [%p]",
720 __func__, pContext);
721 return;
722 }
723
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530724 pStatsContext = pContext;
725 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800726
727 /* there is a race condition that exists between this callback
728 function and the caller since the caller could time out either
729 before or while this code is executing. we use a spinlock to
730 serialize these actions */
731 spin_lock(&hdd_context_lock);
732
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530733 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
734 {
735 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800736 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530737 hddLog(VOS_TRACE_LEVEL_WARN,
738 "%s: Invalid context, pAdapter [%p] magic [%08x]",
739 __func__, pAdapter, pStatsContext->magic);
740 if (ioctl_debug)
741 {
742 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
743 __func__, pAdapter, pStatsContext->magic);
744 }
745 return;
746 }
747
Jeff Johnson72a40512013-12-19 10:14:15 -0800748 /* context is valid so caller is still waiting */
749
750 /* paranoia: invalidate the magic */
751 pStatsContext->magic = 0;
752
753 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530754 pAdapter->snr = snr;
755
Jeff Johnson72a40512013-12-19 10:14:15 -0800756 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530757 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800758
759 /* serialization is complete */
760 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530761}
762
Jeff Johnson295189b2012-06-20 16:38:30 -0700763VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
764{
765 struct statsContext context;
766 hdd_context_t *pHddCtx;
767 hdd_station_ctx_t *pHddStaCtx;
768 eHalStatus hstatus;
769 long lrc;
770
771 if (NULL == pAdapter)
772 {
773 hddLog(VOS_TRACE_LEVEL_WARN,
774 "%s: Invalid context, pAdapter", __func__);
775 return VOS_STATUS_E_FAULT;
776 }
777 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
778 {
779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
780 /* return a cached value */
781 *rssi_value = pAdapter->rssi;
782 return VOS_STATUS_SUCCESS;
783 }
784
785 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
786 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
787
788 init_completion(&context.completion);
789 context.pAdapter = pAdapter;
790 context.magic = RSSI_CONTEXT_MAGIC;
791
792 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
793 pHddStaCtx->conn_info.staId[ 0 ],
794 pHddStaCtx->conn_info.bssId,
795 &context, pHddCtx->pvosContext);
796 if (eHAL_STATUS_SUCCESS != hstatus)
797 {
798 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700799 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700800 /* we'll returned a cached value below */
801 }
802 else
803 {
804 /* request was sent -- wait for the response */
805 lrc = wait_for_completion_interruptible_timeout(&context.completion,
806 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700807 if (lrc <= 0)
808 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800809 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700810 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 /* we'll now returned a cached value below */
812 }
813 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800814
815 /* either we never sent a request, we sent a request and received a
816 response or we sent a request and timed out. if we never sent a
817 request or if we sent a request and got a response, we want to
818 clear the magic out of paranoia. if we timed out there is a
819 race condition such that the callback function could be
820 executing at the same time we are. of primary concern is if the
821 callback function had already verified the "magic" but had not
822 yet set the completion variable when a timeout occurred. we
823 serialize these activities by invalidating the magic while
824 holding a shared spinlock which will cause us to block if the
825 callback is currently executing */
826 spin_lock(&hdd_context_lock);
827 context.magic = 0;
828 spin_unlock(&hdd_context_lock);
829
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 *rssi_value = pAdapter->rssi;
831
832 return VOS_STATUS_SUCCESS;
833}
834
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530835VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
836{
837 struct statsContext context;
838 hdd_context_t *pHddCtx;
839 hdd_station_ctx_t *pHddStaCtx;
840 eHalStatus hstatus;
841 long lrc;
842 int valid;
843
844 if (NULL == pAdapter)
845 {
846 hddLog(VOS_TRACE_LEVEL_ERROR,
847 "%s: Invalid context, pAdapter", __func__);
848 return VOS_STATUS_E_FAULT;
849 }
850
851 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
852
853 valid = wlan_hdd_validate_context(pHddCtx);
854 if (0 != valid)
855 {
856 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
857 return VOS_STATUS_E_FAULT;
858 }
859
860 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
861 if (NULL == pHddStaCtx)
862 {
863 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
864 return VOS_STATUS_E_FAULT;
865 }
866
867 init_completion(&context.completion);
868 context.pAdapter = pAdapter;
869 context.magic = SNR_CONTEXT_MAGIC;
870
871 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
872 pHddStaCtx->conn_info.staId[ 0 ],
873 pHddStaCtx->conn_info.bssId,
874 &context);
875 if (eHAL_STATUS_SUCCESS != hstatus)
876 {
877 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
878 __func__);
879 /* we'll returned a cached value below */
880 }
881 else
882 {
883 /* request was sent -- wait for the response */
884 lrc = wait_for_completion_interruptible_timeout(&context.completion,
885 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530886 if (lrc <= 0)
887 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800888 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530889 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530890 /* we'll now returned a cached value below */
891 }
892 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800893
894 /* either we never sent a request, we sent a request and received a
895 response or we sent a request and timed out. if we never sent a
896 request or if we sent a request and got a response, we want to
897 clear the magic out of paranoia. if we timed out there is a
898 race condition such that the callback function could be
899 executing at the same time we are. of primary concern is if the
900 callback function had already verified the "magic" but had not
901 yet set the completion variable when a timeout occurred. we
902 serialize these activities by invalidating the magic while
903 holding a shared spinlock which will cause us to block if the
904 callback is currently executing */
905 spin_lock(&hdd_context_lock);
906 context.magic = 0;
907 spin_unlock(&hdd_context_lock);
908
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530909 *snr = pAdapter->snr;
910
911 return VOS_STATUS_SUCCESS;
912}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800913#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800914
915static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
916{
917 struct statsContext *pStatsContext;
918 hdd_adapter_t *pAdapter;
919 if (ioctl_debug)
920 {
921 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
922 __func__, (int)rssi, (int)staId, pContext);
923 }
924
925 if (NULL == pContext)
926 {
927 hddLog(VOS_TRACE_LEVEL_ERROR,
928 "%s: Bad param, pContext [%p]",
929 __func__, pContext);
930 return;
931 }
932
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800933 pStatsContext = pContext;
934 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800935
936 /* there is a race condition that exists between this callback
937 function and the caller since the caller could time out either
938 before or while this code is executing. we use a spinlock to
939 serialize these actions */
940 spin_lock(&hdd_context_lock);
941
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800942 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
943 {
944 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800945 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800946 hddLog(VOS_TRACE_LEVEL_WARN,
947 "%s: Invalid context, pAdapter [%p] magic [%08x]",
948 __func__, pAdapter, pStatsContext->magic);
949 if (ioctl_debug)
950 {
951 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
952 __func__, pAdapter, pStatsContext->magic);
953 }
954 return;
955 }
956
Jeff Johnson72a40512013-12-19 10:14:15 -0800957 /* context is valid so caller is still waiting */
958
959 /* paranoia: invalidate the magic */
960 pStatsContext->magic = 0;
961
962 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800963 pAdapter->rssi = rssi;
964
Jeff Johnson72a40512013-12-19 10:14:15 -0800965 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800966 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800967
968 /* serialization is complete */
969 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800970}
971
972
973
974VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
975{
976 struct statsContext context;
977 hdd_context_t *pHddCtx = NULL;
978 hdd_station_ctx_t *pHddStaCtx = NULL;
979 eHalStatus hstatus;
980 long lrc;
981
982 if (NULL == pAdapter)
983 {
984 hddLog(VOS_TRACE_LEVEL_WARN,
985 "%s: Invalid context, pAdapter", __func__);
986 return VOS_STATUS_E_FAULT;
987 }
988 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
989 {
990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
991 /* return a cached value */
992 *rssi_value = pAdapter->rssi;
993 return VOS_STATUS_SUCCESS;
994 }
995
996 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
997 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
998
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +0530999 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001000 {
1001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1002 /* return a cached value */
1003 *rssi_value = 0;
1004 return VOS_STATUS_SUCCESS;
1005 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301006
1007 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1008 {
1009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1010 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1011 *rssi_value = pAdapter->rssi;
1012 return VOS_STATUS_SUCCESS;
1013 }
1014
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001015 init_completion(&context.completion);
1016 context.pAdapter = pAdapter;
1017 context.magic = RSSI_CONTEXT_MAGIC;
1018
1019 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1020 pHddStaCtx->conn_info.staId[ 0 ],
1021 pHddStaCtx->conn_info.bssId,
1022 &context, pHddCtx->pvosContext);
1023 if (eHAL_STATUS_SUCCESS != hstatus)
1024 {
1025 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1026 __func__);
1027 /* we'll returned a cached value below */
1028 }
1029 else
1030 {
1031 /* request was sent -- wait for the response */
1032 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1033 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001034 if (lrc <= 0)
1035 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001036 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001037 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001038 /* we'll now returned a cached value below */
1039 }
1040 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001041
1042 /* either we never sent a request, we sent a request and received a
1043 response or we sent a request and timed out. if we never sent a
1044 request or if we sent a request and got a response, we want to
1045 clear the magic out of paranoia. if we timed out there is a
1046 race condition such that the callback function could be
1047 executing at the same time we are. of primary concern is if the
1048 callback function had already verified the "magic" but had not
1049 yet set the completion variable when a timeout occurred. we
1050 serialize these activities by invalidating the magic while
1051 holding a shared spinlock which will cause us to block if the
1052 callback is currently executing */
1053 spin_lock(&hdd_context_lock);
1054 context.magic = 0;
1055 spin_unlock(&hdd_context_lock);
1056
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001057 *rssi_value = pAdapter->rssi;
1058
1059 return VOS_STATUS_SUCCESS;
1060}
1061#endif
1062
1063
Jeff Johnson295189b2012-06-20 16:38:30 -07001064void hdd_StatisticsCB( void *pStats, void *pContext )
1065{
1066 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1067 hdd_stats_t *pStatsCache = NULL;
1068 hdd_wext_state_t *pWextState;
1069 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1070
1071 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1072 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1073 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1074 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1075 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1076 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1077
1078 if (pAdapter!= NULL)
1079 pStatsCache = &pAdapter->hdd_stats;
1080
1081
1082 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1083 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1084 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1085 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1086 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1087 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1088
1089 if (pStatsCache!=NULL)
1090 {
1091 // and copy the stats into the cache we keep in the adapter instance structure
1092 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1093 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1094 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1095 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1096 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1097 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1098 }
1099
1100 if(pAdapter)
1101 {
1102 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1103 if(pWextState)
1104 {
1105 vos_status = vos_event_set(&pWextState->vosevent);
1106 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1107 {
1108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001109 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 return;
1111 }
1112 }
1113 }
1114}
1115
1116void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1117{
1118 v_CONTEXT_t pVosContext;
1119 hdd_context_t *pHddCtx;
1120 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1121#if 0
1122 hdd_wext_state_t *pWextState;
1123 v_U32_t roamId;
1124#endif
1125
1126 ENTER();
1127
1128 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1129
1130 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1131 if (NULL == pHddCtx)
1132 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001133 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 return;
1135 }
1136#if 0
1137 pWextState = pAdapter->pWextState;
1138#endif
1139
1140 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1141 {
1142 //TODO Verify is this is really used. If yes need to fix it.
1143 hdd_reconnect_all_adapters( pHddCtx );
1144#if 0
1145 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1146 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1147 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1148
1149 if(VOS_STATUS_SUCCESS == vosStatus)
1150 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1151 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1152
1153 sme_RoamConnect(halHandle,
1154 pAdapter->sessionId, &(pWextState->roamProfile),
1155 &roamId);
1156#endif
1157 }
1158
1159 EXIT();
1160
1161}
1162
1163void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1164{
1165 int i = 0;
1166 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1167
1168 /* clear WPA/RSN/WSC IE information in the profile */
1169 pWextState->roamProfile.nWPAReqIELength = 0;
1170 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1171 pWextState->roamProfile.nRSNReqIELength = 0;
1172 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1173
Chet Lanctot186b5732013-03-18 10:26:30 -07001174#ifdef FEATURE_WLAN_WAPI
1175 pWextState->roamProfile.nWAPIReqIELength = 0;
1176 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1177#endif
1178
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001180 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301182 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001183 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1184 pWextState->roamProfile.nAddIEAssocLength = 0;
1185
1186 pWextState->roamProfile.EncryptionType.numEntries = 1;
1187 pWextState->roamProfile.EncryptionType.encryptionType[0]
1188 = eCSR_ENCRYPT_TYPE_NONE;
1189
1190 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1191 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1192 = eCSR_ENCRYPT_TYPE_NONE;
1193
1194 pWextState->roamProfile.AuthType.numEntries = 1;
1195 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1196
Chet Lanctot186b5732013-03-18 10:26:30 -07001197#ifdef WLAN_FEATURE_11W
1198 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1199 pWextState->roamProfile.MFPRequired = 0;
1200 pWextState->roamProfile.MFPCapable = 0;
1201#endif
1202
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 pWextState->authKeyMgmt = 0;
1204
1205 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1206 {
1207 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1208 {
1209 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1210 }
1211 }
1212#ifdef FEATURE_WLAN_WAPI
1213 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1214 pAdapter->wapi_info.nWapiMode = 0;
1215#endif
1216
1217 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1218
1219}
1220
1221void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1222{
1223 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001224
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001225 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1226 {
1227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1228 "%s: Invalid pAdapter magic", __func__);
1229 }
1230 else
1231 {
1232 complete(&pAdapter->ula_complete);
1233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001234}
1235
1236VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1237{
1238 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001240 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001241
1242 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1243 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001244 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001245
1246 /*To avoid race condition between the set key and the last EAPOL
1247 packet, notify TL to finish upper layer authentication incase if the
1248 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001249 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001250
1251 if ( vos_status != VOS_STATUS_SUCCESS )
1252 {
1253 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1254 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1255 __LINE__, vos_status );
1256 return vos_status;
1257
1258 }
1259
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001260 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301262 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001263 {
1264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301265 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001266 /* we'll still fall through and return success since the
1267 * connection may still get established but is just taking
1268 * too long for us to wait */
1269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 }
1271 return VOS_STATUS_SUCCESS;
1272}
1273
1274v_U8_t* wlan_hdd_get_vendor_oui_ie_ptr(v_U8_t *oui, v_U8_t oui_size, v_U8_t *ie, int ie_len)
1275{
1276
1277 int left = ie_len;
1278 v_U8_t *ptr = ie;
1279 v_U8_t elem_id,elem_len;
1280 v_U8_t eid = 0xDD;
1281
1282 if ( NULL == ie || 0 == ie_len )
1283 return NULL;
1284
1285 while(left >= 2)
1286 {
1287 elem_id = ptr[0];
1288 elem_len = ptr[1];
1289 left -= 2;
1290 if(elem_len > left)
1291 {
1292 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001293 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 eid,elem_len,left);
1295 return NULL;
1296 }
1297 if (elem_id == eid)
1298 {
1299 if(memcmp( &ptr[2], oui, oui_size)==0)
1300 return ptr;
1301 }
1302
1303 left -= elem_len;
1304 ptr += (elem_len + 2);
1305 }
1306 return NULL;
1307}
1308
1309static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1310 union iwreq_data *wrqu, char *extra)
1311{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001312 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 /* Do nothing for now */
1314 return 0;
1315}
1316
1317static int iw_get_name(struct net_device *dev,
1318 struct iw_request_info *info,
1319 char *wrqu, char *extra)
1320{
1321
1322 ENTER();
1323 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1324 EXIT();
1325 return 0;
1326}
1327
1328static int iw_set_mode(struct net_device *dev,
1329 struct iw_request_info *info,
1330 union iwreq_data *wrqu, char *extra)
1331{
1332 hdd_wext_state_t *pWextState;
1333 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1334 tCsrRoamProfile *pRoamProfile;
1335 eCsrRoamBssType LastBSSType;
1336 eMib_dot11DesiredBssType connectedBssType;
1337 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001339
1340 ENTER();
1341
1342 if (NULL == pAdapter)
1343 {
1344 hddLog(VOS_TRACE_LEVEL_WARN,
1345 "%s: Invalid context, pAdapter", __func__);
1346 return 0;
1347 }
1348
1349 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1351 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 return 0;
1353 }
1354
1355 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1356 if (pWextState == NULL)
1357 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301358 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 return -EINVAL;
1360 }
1361
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 pRoamProfile = &pWextState->roamProfile;
1364 LastBSSType = pRoamProfile->BSSType;
1365
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301366 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001367
1368 switch (wrqu->mode)
1369 {
1370 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301371 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1373 // Set the phymode correctly for IBSS.
1374 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1375 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001376 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 break;
1379 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301380 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 break;
1384 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301385 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1387 break;
1388 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301389 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 return -EOPNOTSUPP;
1391 }
1392
1393 if ( LastBSSType != pRoamProfile->BSSType )
1394 {
1395 //the BSS mode changed
1396 // We need to issue disconnect if connected or in IBSS disconnect state
1397 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1398 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1399 {
1400 VOS_STATUS vosStatus;
1401 // need to issue a disconnect to CSR.
1402 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1403 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1404 pAdapter->sessionId,
1405 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1406 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301407 {
1408 long ret;
1409 ret = wait_for_completion_interruptible_timeout(
1410 &pAdapter->disconnect_comp_var,
1411 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1412 if (ret <= 0)
1413 hddLog(VOS_TRACE_LEVEL_ERROR,
1414 FL("failed wait on disconnect_comp_var %ld"), ret);
1415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 }
1417 }
1418
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 EXIT();
1420 return 0;
1421}
1422
1423
1424static int iw_get_mode(struct net_device *dev,
1425 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301426 union iwreq_data *wrqu,
1427 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001428{
1429
1430 hdd_wext_state_t *pWextState;
1431 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1432
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301433 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001434
1435 if (NULL == pAdapter)
1436 {
1437 hddLog(VOS_TRACE_LEVEL_WARN,
1438 "%s: Invalid context, pAdapter", __func__);
1439 return 0;
1440 }
1441
1442 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1444 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001445 return 0;
1446 }
1447
1448 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1449 if (pWextState == NULL)
1450 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301451 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 return -EINVAL;
1453 }
1454
1455 switch (pWextState->roamProfile.BSSType)
1456 {
1457 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001458 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301459 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 break;
1461 case eCSR_BSS_TYPE_IBSS:
1462 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001463 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301464 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 break;
1466 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001467 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301468 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 break;
1470 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001471 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 break;
1473 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301474
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 return 0;
1476}
1477
1478static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1479 union iwreq_data *wrqu, char *extra)
1480{
1481 v_U32_t numChans = 0;
1482 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1483 v_U32_t indx = 0;
1484 v_U32_t status = 0;
1485
1486 hdd_wext_state_t *pWextState;
1487 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1488 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1489 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1490 tCsrRoamProfile * pRoamProfile;
1491 ENTER();
1492
1493 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1495 return status;
1496 }
1497
1498 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1499
1500 pRoamProfile = &pWextState->roamProfile;
1501
Arif Hussain6d2a3322013-11-17 19:50:10 -08001502 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001503
1504 /* Link is up then return cant set channel*/
1505 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1506 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1507 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001508 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 return -EOPNOTSUPP;
1510 }
1511
1512 /* Settings by Frequency as input */
1513 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1514 (wrqu->freq.m <= (tANI_U32)5.825e8))
1515 {
1516 tANI_U32 freq = wrqu->freq.m / 100000;
1517
1518 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1519 indx++;
1520 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1521 {
1522 return -EINVAL;
1523 }
1524 wrqu->freq.e = 0;
1525 wrqu->freq.m = freq_chan_map[indx].chan;
1526
1527 }
1528
1529 if (wrqu->freq.e == 0)
1530 {
1531 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1532 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1533 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001534 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001535 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1537 return -EINVAL;
1538 }
1539
1540 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1541
1542 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1543 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1545 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 return -EIO;
1547 }
1548
1549 for (indx = 0; indx < numChans; indx++) {
1550 if (wrqu->freq.m == validChan[indx]){
1551 break;
1552 }
1553 }
1554 }
1555 else{
1556
1557 return -EINVAL;
1558 }
1559
1560 if(indx >= numChans)
1561 {
1562 return -EINVAL;
1563 }
1564
1565 /* Set the Operational Channel */
1566 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1567 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1568 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1569
Arif Hussain6d2a3322013-11-17 19:50:10 -08001570 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001571
1572 EXIT();
1573
1574 return status;
1575}
1576
1577static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1578 struct iw_freq *fwrq, char *extra)
1579{
Jeff Johnsone7245742012-09-05 17:12:55 -07001580 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1582 tHalHandle hHal;
1583 hdd_wext_state_t *pWextState;
1584 tCsrRoamProfile * pRoamProfile;
1585 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1586
1587 ENTER();
1588
1589 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1591 return status;
1592 }
1593
1594 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1595 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1596
1597 pRoamProfile = &pWextState->roamProfile;
1598
1599 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1600 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001601 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 {
c_hpothub8245442013-11-20 23:41:09 +05301603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1604 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 return -EIO;
1606 }
1607 else
1608 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001609 status = hdd_wlan_get_freq(channel, &freq);
1610 if( TRUE == status )
1611 {
1612 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1613 * iwlist & iwconfig command shows frequency into proper
1614 * format (2.412 GHz instead of 246.2 MHz)*/
1615 fwrq->m = freq;
1616 fwrq->e = MHZ;
1617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 }
1619 }
1620 else
1621 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001622 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1623 * iwlist & iwconfig command shows frequency into proper
1624 * format (2.412 GHz instead of 246.2 MHz)*/
1625 fwrq->m = 0;
1626 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001628 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001629}
1630
1631static int iw_get_tx_power(struct net_device *dev,
1632 struct iw_request_info *info,
1633 union iwreq_data *wrqu, char *extra)
1634{
1635
1636 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1637 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1638 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1639
1640 if (pHddCtx->isLogpInProgress)
1641 {
1642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1643 "%s:LOGP in Progress. Ignore!!!",__func__);
1644 return -EBUSY;
1645 }
1646
1647 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1648 {
1649 wrqu->txpower.value = 0;
1650 return 0;
1651 }
1652 wlan_hdd_get_classAstats(pAdapter);
1653 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1654
1655 return 0;
1656}
1657
1658static int iw_set_tx_power(struct net_device *dev,
1659 struct iw_request_info *info,
1660 union iwreq_data *wrqu, char *extra)
1661{
1662 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1663 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1664
1665 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1666 {
1667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1668 return 0;
1669 }
1670
1671 ENTER();
1672
1673 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1674 {
c_hpothub8245442013-11-20 23:41:09 +05301675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1676 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 return -EIO;
1678 }
1679
1680 EXIT();
1681
1682 return 0;
1683}
1684
1685static int iw_get_bitrate(struct net_device *dev,
1686 struct iw_request_info *info,
1687 union iwreq_data *wrqu, char *extra)
1688{
1689 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1690 eHalStatus status = eHAL_STATUS_SUCCESS;
1691 hdd_wext_state_t *pWextState;
1692 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1693 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1694
1695 ENTER();
1696
1697 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1699 return status;
1700 }
1701
1702 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1703 wrqu->bitrate.value = 0;
1704 }
1705 else {
1706 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1707 SME_SUMMARY_STATS |
1708 SME_GLOBAL_CLASSA_STATS |
1709 SME_GLOBAL_CLASSB_STATS |
1710 SME_GLOBAL_CLASSC_STATS |
1711 SME_GLOBAL_CLASSD_STATS |
1712 SME_PER_STA_STATS,
1713 hdd_StatisticsCB, 0, FALSE,
1714 pHddStaCtx->conn_info.staId[0], pAdapter );
1715
1716 if(eHAL_STATUS_SUCCESS != status)
1717 {
1718 hddLog(VOS_TRACE_LEVEL_ERROR,
1719 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001720 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 return status;
1722 }
1723
1724 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1725
1726 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1727
1728 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1729 {
1730 hddLog(VOS_TRACE_LEVEL_ERROR,
1731 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001732 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 return VOS_STATUS_E_FAILURE;
1734 }
1735
1736 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1737 }
1738
1739 EXIT();
1740
1741 return vos_status;
1742}
1743/* ccm call back function */
1744
1745static int iw_set_bitrate(struct net_device *dev,
1746 struct iw_request_info *info,
1747 union iwreq_data *wrqu,
1748 char *extra)
1749{
1750 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1751 hdd_wext_state_t *pWextState;
1752 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1753 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1754 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1755 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1756 v_U32_t i, rate;
1757 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1758
1759 ENTER();
1760
1761 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1763 return 0;
1764 }
1765
1766 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1767
1768 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1769 {
1770 return -ENXIO ;
1771 }
1772
1773 rate = wrqu->bitrate.value;
1774
1775 if (rate == -1)
1776 {
1777 rate = WNI_CFG_FIXED_RATE_AUTO;
1778 valid_rate = TRUE;
1779 }
1780 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1781 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1782 {
1783 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1784 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1785 {
1786 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1787 WNI_CFG_SUPPORTED_RATES_11A,
1788 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1789 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1790 WNI_CFG_SUPPORTED_RATES_11B,
1791 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1792 {
1793 for (i = 0; i < (b_len + a_len); ++i)
1794 {
1795 /* supported rates returned is double the actual rate so we divide it by 2 */
1796 if ((supp_rates[i]&0x7F)/2 == rate)
1797 {
1798 valid_rate = TRUE;
1799 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1800 break;
1801 }
1802 }
1803 }
1804 }
1805 }
1806 if (valid_rate != TRUE)
1807 {
1808 return -EINVAL;
1809 }
1810 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1811 WNI_CFG_FIXED_RATE, rate,
1812 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1813 {
c_hpothub8245442013-11-20 23:41:09 +05301814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1815 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 return -EIO;
1817 }
1818 return 0;
1819}
1820
1821
1822static int iw_set_genie(struct net_device *dev,
1823 struct iw_request_info *info,
1824 union iwreq_data *wrqu,
1825 char *extra)
1826{
1827 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1828 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001829 u_int8_t *genie = NULL;
1830 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 v_U16_t remLen;
1832
1833 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001834
1835 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1837 "%s:LOGP in Progress. Ignore!!!", __func__);
1838 return 0;
1839 }
1840
1841 if (!wrqu->data.length) {
1842 hdd_clearRoamProfileIe(pAdapter);
1843 EXIT();
1844 return 0;
1845 }
1846
1847 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1848 wrqu->data.length);
1849 if (NULL == base_genie)
1850 {
1851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1852 "mem_alloc_copy_from_user_helper fail");
1853 return -ENOMEM;
1854 }
1855
1856 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001857
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 remLen = wrqu->data.length;
1859
Arif Hussain6d2a3322013-11-17 19:50:10 -08001860 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001861
1862 /* clear any previous genIE before this call */
1863 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1864
1865 while (remLen >= 2)
1866 {
1867 v_U16_t eLen = 0;
1868 v_U8_t elementId;
1869 elementId = *genie++;
1870 eLen = *genie++;
1871 remLen -= 2;
1872
Arif Hussain6d2a3322013-11-17 19:50:10 -08001873 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 __func__, elementId, eLen);
1875
1876 switch ( elementId )
1877 {
1878 case IE_EID_VENDOR:
1879 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001880 {
1881 kfree(base_genie);
1882 return -EINVAL;
1883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001884
1885 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1886 {
1887 v_U16_t curGenIELen = pWextState->genIE.length;
1888 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1889 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1890
1891 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1892 {
1893 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001894 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001896 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001897 return -ENOMEM;
1898 }
1899 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1900 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1901 pWextState->genIE.length += eLen + 2;
1902 }
1903 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1904 {
1905 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1906 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1907 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1908 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1909 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1910 }
1911 else /* any vendorId except WPA IE should be accumulated to genIE */
1912 {
1913 v_U16_t curGenIELen = pWextState->genIE.length;
1914 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1915 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1916
1917 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1918 {
1919 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001920 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001922 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 return -ENOMEM;
1924 }
1925 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1926 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1927 pWextState->genIE.length += eLen + 2;
1928 }
1929 break;
1930 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001931 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1933 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1934 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1935 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1936 break;
1937
1938 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001939 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001940 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001941 return 0;
1942 }
1943 genie += eLen;
1944 remLen -= eLen;
1945 }
1946 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001947 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 return 0;
1949}
1950
1951static int iw_get_genie(struct net_device *dev,
1952 struct iw_request_info *info,
1953 union iwreq_data *wrqu,
1954 char *extra)
1955{
1956 hdd_wext_state_t *pWextState;
1957 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1958 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1959 eHalStatus status;
1960 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1961 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1962
1963 ENTER();
1964
1965 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1967 return 0;
1968 }
1969
1970
Arif Hussain6d2a3322013-11-17 19:50:10 -08001971 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001972
1973 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1974
1975 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1976 {
1977 return -ENXIO;
1978 }
1979
1980 // Return something ONLY if we are associated with an RSN or WPA network
1981 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1982 pWextState->roamProfile.negotiatedAuthType))
1983 {
1984 return -ENXIO;
1985 }
1986
1987 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1988 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1989 pAdapter->sessionId,
1990 &length,
1991 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001992 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1993 if (wrqu->data.length < length)
1994 {
1995 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1996 return -EFAULT;
1997 }
Arif Hussain9f05be02014-02-05 12:06:53 -08001998 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001999 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002000
Arif Hussain6d2a3322013-11-17 19:50:10 -08002001 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002002
2003 EXIT();
2004
2005 return 0;
2006}
2007
2008static int iw_get_encode(struct net_device *dev,
2009 struct iw_request_info *info,
2010 struct iw_point *dwrq, char *extra)
2011{
2012 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2013 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2014 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2015 int keyId;
2016 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
2017 int i;
2018
2019 ENTER();
2020
2021 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2023 return 0;
2024 }
2025
2026 keyId = pRoamProfile->Keys.defaultIndex;
2027
2028 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2029 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002030 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 return -EINVAL;
2032 }
2033
2034 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2035 {
2036 dwrq->flags |= IW_ENCODE_ENABLED;
2037 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2038 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2039
2040 dwrq->flags |= (keyId + 1);
2041
2042 }
2043 else
2044 {
2045 dwrq->flags |= IW_ENCODE_DISABLED;
2046 }
2047
2048 for(i=0; i < MAX_WEP_KEYS; i++)
2049 {
2050 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2051 {
2052 continue;
2053 }
2054 else
2055 {
2056 break;
2057 }
2058 }
2059
2060 if(MAX_WEP_KEYS == i)
2061 {
2062 dwrq->flags |= IW_ENCODE_NOKEY;
2063 }
2064
2065 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2066
2067 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2068 {
2069 dwrq->flags |= IW_ENCODE_OPEN;
2070 }
2071 else
2072 {
2073 dwrq->flags |= IW_ENCODE_RESTRICTED;
2074 }
2075 EXIT();
2076 return 0;
2077}
2078
2079#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2080#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2081
2082
2083/*
2084 * This function sends a single 'key' to LIM at all time.
2085 */
2086
2087static int iw_get_rts_threshold(struct net_device *dev,
2088 struct iw_request_info *info,
2089 union iwreq_data *wrqu, char *extra)
2090{
2091 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2092 v_U32_t status = 0;
2093
2094 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2095
2096 return status;
2097}
2098
2099static int iw_set_rts_threshold(struct net_device *dev,
2100 struct iw_request_info *info,
2101 union iwreq_data *wrqu, char *extra)
2102{
2103 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2104 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2105
2106 ENTER();
2107
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002108 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2109 {
2110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2111 "%s:LOGP in Progress. Ignore!!!", __func__);
2112 return -EAGAIN;
2113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2115 {
2116 return -EINVAL;
2117 }
2118
2119 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2120 {
c_hpothub8245442013-11-20 23:41:09 +05302121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2122 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 return -EIO;
2124 }
2125
2126 EXIT();
2127
2128 return 0;
2129}
2130
2131static int iw_get_frag_threshold(struct net_device *dev,
2132 struct iw_request_info *info,
2133 union iwreq_data *wrqu, char *extra)
2134{
2135 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2136 v_U32_t status = 0;
2137
2138 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2139
2140 return status;
2141}
2142
2143static int iw_set_frag_threshold(struct net_device *dev,
2144 struct iw_request_info *info,
2145 union iwreq_data *wrqu, char *extra)
2146{
2147 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2148 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2149
2150 ENTER();
2151
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002152 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2153 {
2154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2155 "%s:LOGP in Progress. Ignore!!!", __func__);
2156 return -EBUSY;
2157 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2159 {
2160 return -EINVAL;
2161 }
2162
2163 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2164 {
c_hpothub8245442013-11-20 23:41:09 +05302165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2166 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 return -EIO;
2168 }
2169
2170 EXIT();
2171
2172 return 0;
2173}
2174
2175static int iw_get_power_mode(struct net_device *dev,
2176 struct iw_request_info *info,
2177 union iwreq_data *wrqu, char *extra)
2178{
2179 ENTER();
2180 return -EOPNOTSUPP;
2181}
2182
2183static int iw_set_power_mode(struct net_device *dev,
2184 struct iw_request_info *info,
2185 union iwreq_data *wrqu, char *extra)
2186{
2187 ENTER();
2188 return -EOPNOTSUPP;
2189}
2190
2191static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2192 union iwreq_data *wrqu, char *extra)
2193{
2194 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2195 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2196 struct iw_range *range = (struct iw_range *) extra;
2197
2198 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2199
2200 v_U32_t num_channels = sizeof(channels);
2201 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2202 v_U32_t a_len;
2203 v_U32_t b_len;
2204 v_U32_t active_phy_mode = 0;
2205 v_U8_t index = 0, i;
2206
2207 ENTER();
2208
2209 wrqu->data.length = sizeof(struct iw_range);
2210 memset(range, 0, sizeof(struct iw_range));
2211
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002212 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2213 {
2214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2215 "%s:LOGP in Progress. Ignore!!!", __func__);
2216 return -EBUSY;
2217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002218
2219 /*Get the phy mode*/
2220 if (ccmCfgGetInt(hHal,
2221 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2222 {
2223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002224 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
2226 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2227 {
2228 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002229 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 if (ccmCfgGetStr(hHal,
2231 WNI_CFG_SUPPORTED_RATES_11A,
2232 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2233 {
2234 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2235 {
2236 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2237 }
2238 for (i = 0; i < a_len; i++)
2239 {
2240 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2241 }
2242 range->num_bitrates = a_len;
2243 }
2244 else
2245 {
2246 return -EIO;
2247 }
2248 }
2249 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2250 {
2251 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002252 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 if (ccmCfgGetStr(hHal,
2254 WNI_CFG_SUPPORTED_RATES_11B,
2255 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2256 {
2257 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2258 {
2259 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2260 }
2261 for (i = 0; i < b_len; i++)
2262 {
2263 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2264 }
2265 range->num_bitrates = b_len;
2266 }
2267 else
2268 {
2269 return -EIO;
2270 }
2271 }
2272 }
2273
2274 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2275 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2276 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2277
2278 range->encoding_size[0] = 5;
2279 range->encoding_size[1] = 13;
2280 range->num_encoding_sizes = 2;
2281 range->max_encoding_tokens = MAX_WEP_KEYS;
2282
2283 // we support through Wireless Extensions 22
2284 range->we_version_compiled = WIRELESS_EXT;
2285 range->we_version_source = 22;
2286
2287 /*Supported Channels and Frequencies*/
2288 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2289 {
c_hpothub8245442013-11-20 23:41:09 +05302290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2291 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 return -EIO;
2293 }
2294 if (num_channels > IW_MAX_FREQUENCIES)
2295 {
2296 num_channels = IW_MAX_FREQUENCIES;
2297 }
2298
2299 range->num_channels = num_channels;
2300 range->num_frequency = num_channels;
2301
2302 for (index=0; index < num_channels; index++)
2303 {
2304 v_U32_t frq_indx = 0;
2305
2306 range->freq[index].i = channels[index];
2307 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2308 {
2309 if(channels[index] == freq_chan_map[frq_indx].chan)
2310 {
2311 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2312 range->freq[index].e = 1;
2313 break;
2314 }
2315 frq_indx++;
2316 }
2317 }
2318
2319 /* Event capability (kernel + driver) */
2320 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2321 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2322 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2323 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2324
2325 /*Encryption capability*/
2326 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2327 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2328
2329 /* Txpower capability */
2330 range->txpower_capa = IW_TXPOW_MWATT;
2331
2332 /*Scanning capability*/
2333 #if WIRELESS_EXT >= 22
2334 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2335 #endif
2336
2337 EXIT();
2338 return 0;
2339}
2340
2341/* Callback function registered with PMC to know status of PMC request */
2342static void iw_power_callback_fn (void *pContext, eHalStatus status)
2343{
2344 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002345
2346 if (NULL == pContext)
2347 {
2348 hddLog(VOS_TRACE_LEVEL_ERROR,
2349 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002350 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 return;
2352 }
2353
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002355
Jeff Johnson72a40512013-12-19 10:14:15 -08002356 /* there is a race condition that exists between this callback
2357 function and the caller since the caller could time out either
2358 before or while this code is executing. we use a spinlock to
2359 serialize these actions */
2360 spin_lock(&hdd_context_lock);
2361
2362 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 {
2364 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002365 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002367 "%s: Invalid context, magic [%08x]",
2368 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002369
2370 if (ioctl_debug)
2371 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002372 pr_info("%s: Invalid context, magic [%08x]\n",
2373 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 }
2375 return;
2376 }
2377
Jeff Johnson72a40512013-12-19 10:14:15 -08002378 /* context is valid so caller is still waiting */
2379
2380 /* paranoia: invalidate the magic */
2381 pStatsContext->magic = 0;
2382
2383 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002385
2386 /* serialization is complete */
2387 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002388}
2389
2390/* Callback function for tx per hit */
2391void hdd_tx_per_hit_cb (void *pCallbackContext)
2392{
2393 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2394 unsigned char tx_fail[16];
2395 union iwreq_data wrqu;
2396
2397 if (NULL == pAdapter)
2398 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002399 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 return;
2401 }
2402 memset(&wrqu, 0, sizeof(wrqu));
2403 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2404 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2405}
2406
2407void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2408{
2409 struct statsContext *pStatsContext;
2410 tCsrGlobalClassAStatsInfo *pClassAStats;
2411 hdd_adapter_t *pAdapter;
2412
2413 if (ioctl_debug)
2414 {
2415 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002416 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 }
2418
2419 if ((NULL == pStats) || (NULL == pContext))
2420 {
2421 hddLog(VOS_TRACE_LEVEL_ERROR,
2422 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002423 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 return;
2425 }
2426
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 pClassAStats = pStats;
2428 pStatsContext = pContext;
2429 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002430
2431 /* there is a race condition that exists between this callback
2432 function and the caller since the caller could time out either
2433 before or while this code is executing. we use a spinlock to
2434 serialize these actions */
2435 spin_lock(&hdd_context_lock);
2436
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2438 {
2439 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002440 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 hddLog(VOS_TRACE_LEVEL_WARN,
2442 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002443 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 if (ioctl_debug)
2445 {
2446 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002447 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 }
2449 return;
2450 }
2451
Jeff Johnson72a40512013-12-19 10:14:15 -08002452 /* context is valid so caller is still waiting */
2453
2454 /* paranoia: invalidate the magic */
2455 pStatsContext->magic = 0;
2456
2457 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2459
Jeff Johnson72a40512013-12-19 10:14:15 -08002460 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002462
2463 /* serialization is complete */
2464 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002465}
2466
2467VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2468{
2469 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2470 eHalStatus hstatus;
2471 long lrc;
2472 struct statsContext context;
2473
2474 if (NULL == pAdapter)
2475 {
2476 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2477 return VOS_STATUS_E_FAULT;
2478 }
2479 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2480 {
2481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2482 return VOS_STATUS_SUCCESS;
2483 }
2484
2485 /* we are connected
2486 prepare our callback context */
2487 init_completion(&context.completion);
2488 context.pAdapter = pAdapter;
2489 context.magic = STATS_CONTEXT_MAGIC;
2490 /* query only for Class A statistics (which include link speed) */
2491 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2492 eCSR_HDD,
2493 SME_GLOBAL_CLASSA_STATS,
2494 hdd_GetClassA_statisticsCB,
2495 0, // not periodic
2496 FALSE, //non-cached results
2497 pHddStaCtx->conn_info.staId[0],
2498 &context);
2499 if (eHAL_STATUS_SUCCESS != hstatus)
2500 {
2501 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002502 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002503 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002504 /* we'll returned a cached value below */
2505 }
2506 else
2507 {
2508 /* request was sent -- wait for the response */
2509 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2510 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 if (lrc <= 0)
2512 {
2513 hddLog(VOS_TRACE_LEVEL_ERROR,
2514 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002515 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 }
2517 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002518
2519 /* either we never sent a request, we sent a request and received a
2520 response or we sent a request and timed out. if we never sent a
2521 request or if we sent a request and got a response, we want to
2522 clear the magic out of paranoia. if we timed out there is a
2523 race condition such that the callback function could be
2524 executing at the same time we are. of primary concern is if the
2525 callback function had already verified the "magic" but had not
2526 yet set the completion variable when a timeout occurred. we
2527 serialize these activities by invalidating the magic while
2528 holding a shared spinlock which will cause us to block if the
2529 callback is currently executing */
2530 spin_lock(&hdd_context_lock);
2531 context.magic = 0;
2532 spin_unlock(&hdd_context_lock);
2533
2534 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 return VOS_STATUS_SUCCESS;
2536}
2537
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002538static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2539{
2540 struct statsContext *pStatsContext;
2541 tCsrSummaryStatsInfo *pSummaryStats;
2542 tCsrGlobalClassAStatsInfo *pClassAStats;
2543 hdd_adapter_t *pAdapter;
2544
2545 if (ioctl_debug)
2546 {
2547 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002548 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002549 }
2550
2551 if ((NULL == pStats) || (NULL == pContext))
2552 {
2553 hddLog(VOS_TRACE_LEVEL_ERROR,
2554 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002555 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002556 return;
2557 }
2558
Jeff Johnson72a40512013-12-19 10:14:15 -08002559 /* there is a race condition that exists between this callback
2560 function and the caller since the caller could time out either
2561 before or while this code is executing. we use a spinlock to
2562 serialize these actions */
2563 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002564
2565 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2566 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2567 pStatsContext = pContext;
2568 pAdapter = pStatsContext->pAdapter;
2569 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2570 {
2571 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002572 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002573 hddLog(VOS_TRACE_LEVEL_WARN,
2574 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002575 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002576 if (ioctl_debug)
2577 {
2578 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002579 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002580 }
2581 return;
2582 }
2583
Jeff Johnson72a40512013-12-19 10:14:15 -08002584 /* context is valid so caller is still waiting */
2585
2586 /* paranoia: invalidate the magic */
2587 pStatsContext->magic = 0;
2588
2589 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002590 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2591 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2592
Jeff Johnson72a40512013-12-19 10:14:15 -08002593 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002594 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002595
2596 /* serialization is complete */
2597 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002598}
2599
2600VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2601{
2602 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2603 eHalStatus hstatus;
2604 long lrc;
2605 struct statsContext context;
2606
2607 if (NULL == pAdapter)
2608 {
2609 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2610 return VOS_STATUS_SUCCESS;
2611 }
2612
2613 /* we are connected
2614 prepare our callback context */
2615 init_completion(&context.completion);
2616 context.pAdapter = pAdapter;
2617 context.magic = STATS_CONTEXT_MAGIC;
2618
2619 /* query only for Summary & Class A statistics */
2620 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2621 eCSR_HDD,
2622 SME_SUMMARY_STATS |
2623 SME_GLOBAL_CLASSA_STATS,
2624 hdd_get_station_statisticsCB,
2625 0, // not periodic
2626 FALSE, //non-cached results
2627 pHddStaCtx->conn_info.staId[0],
2628 &context);
2629 if (eHAL_STATUS_SUCCESS != hstatus)
2630 {
2631 hddLog(VOS_TRACE_LEVEL_ERROR,
2632 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002633 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002634 /* we'll return with cached values */
2635 }
2636 else
2637 {
2638 /* request was sent -- wait for the response */
2639 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2640 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002641
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002642 if (lrc <= 0)
2643 {
2644 hddLog(VOS_TRACE_LEVEL_ERROR,
2645 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002646 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002647 }
2648 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002649
2650 /* either we never sent a request, we sent a request and received a
2651 response or we sent a request and timed out. if we never sent a
2652 request or if we sent a request and got a response, we want to
2653 clear the magic out of paranoia. if we timed out there is a
2654 race condition such that the callback function could be
2655 executing at the same time we are. of primary concern is if the
2656 callback function had already verified the "magic" but had not
2657 yet set the completion variable when a timeout occurred. we
2658 serialize these activities by invalidating the magic while
2659 holding a shared spinlock which will cause us to block if the
2660 callback is currently executing */
2661 spin_lock(&hdd_context_lock);
2662 context.magic = 0;
2663 spin_unlock(&hdd_context_lock);
2664
2665 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002666 return VOS_STATUS_SUCCESS;
2667}
2668
2669
Jeff Johnson295189b2012-06-20 16:38:30 -07002670/*
2671 * Support for the LINKSPEED private command
2672 * Per the WiFi framework the response must be of the form
2673 * "LinkSpeed xx"
2674 */
2675static int iw_get_linkspeed(struct net_device *dev,
2676 struct iw_request_info *info,
2677 union iwreq_data *wrqu, char *extra)
2678{
2679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302680 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302682 int len = sizeof(v_U32_t) + 1;
2683 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302685 VOS_STATUS status;
2686 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002687
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302688 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2689
2690 valid = wlan_hdd_validate_context(pHddCtx);
2691
2692 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002693 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302694 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2695 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002696 }
2697
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2699 {
2700 /* we are not connected so we don't have a classAstats */
2701 link_speed = 0;
2702 }
2703 else
2704 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302705 status = wlan_hdd_get_classAstats(pAdapter);
2706
2707 if (!VOS_IS_STATUS_SUCCESS(status ))
2708 {
2709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2710 return -EINVAL;
2711 }
2712
2713 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2714 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2715 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2716 &link_speed);
2717
2718 link_speed = link_speed / 10;
2719
2720 if (0 == link_speed)
2721 {
2722 /* The linkspeed returned by HAL is in units of 500kbps.
2723 * converting it to mbps.
2724 * This is required to support legacy firmware which does
2725 * not return link capacity.
2726 */
2727 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2728 }
2729
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 }
2731
2732 wrqu->data.length = len;
2733 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002734 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 if ((rc < 0) || (rc >= len))
2736 {
2737 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302738 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 return -EIO;
2740 }
2741
2742 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002743 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002744}
2745
Arif Hussain695279c2014-03-24 14:06:07 -07002746/*
2747 * Helper function to return correct value for WLAN_GET_LINK_SPEED
2748 *
2749 */
2750static int iw_get_linkspeed_priv(struct net_device *dev,
2751 struct iw_request_info *info,
2752 union iwreq_data *wrqu, char *extra)
2753{
2754 int rc;
2755
2756 rc = iw_get_linkspeed(dev, info, wrqu, extra);
2757
2758 if (rc < 0)
2759 return rc;
2760
2761 /* a value is being successfully returned */
2762 return 0;
2763}
Jeff Johnson295189b2012-06-20 16:38:30 -07002764
2765/*
2766 * Support for the RSSI & RSSI-APPROX private commands
2767 * Per the WiFi framework the response must be of the form
2768 * "<ssid> rssi <xx>"
2769 * unless we are not associated, in which case the response is
2770 * "OK"
2771 */
2772static int iw_get_rssi(struct net_device *dev,
2773 struct iw_request_info *info,
2774 union iwreq_data *wrqu, char *extra)
2775{
2776 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002777 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 int len = wrqu->data.length;
2779 v_S7_t s7Rssi = 0;
2780 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2781 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2782 VOS_STATUS vosStatus;
2783 int rc;
2784
2785 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2786 (0 == ssidlen) || (ssidlen >= len))
2787 {
2788 /* we are not connected or our SSID is too long
2789 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002790 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 }
2792 else
2793 {
2794 /* we are connected with a valid SSID
2795 so we can write the SSID into the return buffer
2796 (note that it is not NUL-terminated) */
2797 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2798
2799 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2800
2801 if (VOS_STATUS_SUCCESS == vosStatus)
2802 {
2803 /* append the rssi to the ssid in the format required by
2804 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002805 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05302806 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 }
2808 else
2809 {
2810 rc = -1;
2811 }
2812 }
2813
2814 /* verify that we wrote a valid response */
2815 if ((rc < 0) || (rc >= len))
2816 {
2817 // encoding or length error?
2818 hddLog(VOS_TRACE_LEVEL_ERROR,
2819 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002820 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 return -EIO;
2822 }
2823
2824 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002825 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002826}
2827
2828/*
2829 * Support for SoftAP channel range private command
2830 */
2831static int iw_softap_set_channel_range( struct net_device *dev,
2832 int startChannel,
2833 int endChannel,
2834 int band)
2835{
Jeff Johnson43971f52012-07-17 12:26:56 -07002836 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 int ret = 0;
2838 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2839 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002840 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2841
Jeff Johnson295189b2012-06-20 16:38:30 -07002842
2843 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2844 if (VOS_STATUS_SUCCESS != status)
2845 {
2846 ret = -EINVAL;
2847 }
Yathish9f22e662012-12-10 14:21:35 -08002848 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 return ret;
2850}
2851
2852VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2853{
2854 struct statsContext context;
2855 eHalStatus status;
2856 hdd_context_t *pHddCtx;
2857
2858 if (NULL == pAdapter)
2859 {
2860 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2861 return VOS_STATUS_E_FAULT;
2862 }
2863
2864 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2865 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05302866 if (pHddCtx->isLogpInProgress) {
2867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2868 "%s:LOGP in Progress. Ignore!!!", __func__);
2869 return VOS_STATUS_E_FAILURE;
2870 }
2871
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 init_completion(&context.completion);
2873
2874 context.pAdapter = pAdapter;
2875 context.magic = POWER_CONTEXT_MAGIC;
2876
2877 if (DRIVER_POWER_MODE_ACTIVE == mode)
2878 {
2879 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2880 "Full Power", __func__);
2881 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2882 iw_power_callback_fn, &context,
2883 eSME_FULL_PWR_NEEDED_BY_HDD);
2884 // Enter Full power command received from GUI this means we are disconnected
2885 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2886 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2887 if (eHAL_STATUS_PMC_PENDING == status)
2888 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002889 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 int lrc = wait_for_completion_interruptible_timeout(
2891 &context.completion,
2892 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002893
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 if (lrc <= 0)
2895 {
2896 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002897 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 }
2899 }
2900 }
2901 else if (DRIVER_POWER_MODE_AUTO == mode)
2902 {
2903 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2904 {
2905 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2906 __func__);
2907 // Enter BMPS command received from GUI this means DHCP is completed
2908 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2909 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2910 FALSE);
2911 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2912 iw_power_callback_fn, &context);
2913 if (eHAL_STATUS_PMC_PENDING == status)
2914 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002915 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 int lrc = wait_for_completion_interruptible_timeout(
2917 &context.completion,
2918 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 if (lrc <= 0)
2920 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002921 hddLog(VOS_TRACE_LEVEL_ERROR,
2922 "%s: SME %s while requesting BMPS",
2923 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 }
2925 }
2926 }
2927 else
2928 {
2929 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2930 "enabled in the cfg");
2931 }
2932 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002933
2934 /* either we never sent a request, we sent a request and received a
2935 response or we sent a request and timed out. if we never sent a
2936 request or if we sent a request and got a response, we want to
2937 clear the magic out of paranoia. if we timed out there is a
2938 race condition such that the callback function could be
2939 executing at the same time we are. of primary concern is if the
2940 callback function had already verified the "magic" but had not
2941 yet set the completion variable when a timeout occurred. we
2942 serialize these activities by invalidating the magic while
2943 holding a shared spinlock which will cause us to block if the
2944 callback is currently executing */
2945 spin_lock(&hdd_context_lock);
2946 context.magic = 0;
2947 spin_unlock(&hdd_context_lock);
2948
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 return VOS_STATUS_SUCCESS;
2950}
2951
2952VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2953 hdd_adapter_t *pAdapter)
2954{
2955 VOS_STATUS vos_Status;
2956
2957 if ((NULL == pAdapter) || (NULL == pHddCtx))
2958 {
2959 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2960 return VOS_STATUS_E_FAULT;
2961 }
2962
2963 /**Exit from Deep sleep or standby if we get the driver
2964 START cmd from android GUI
2965 */
2966 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2967 {
2968 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2969 "from Stand by",__func__);
2970 vos_Status = hdd_exit_standby(pHddCtx);
2971 }
2972 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2973 {
2974 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2975 "from deep sleep",__func__);
2976 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2977 }
2978 else
2979 {
2980 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2981 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2982 vos_Status = VOS_STATUS_SUCCESS;
2983 }
2984
2985 return vos_Status;
2986}
2987
2988VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2989{
2990 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2991
2992 if (NULL == pHddCtx)
2993 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302994 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 return VOS_STATUS_E_FAULT;
2996 }
2997
2998 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2999 {
3000 //Execute standby procedure.
3001 //Executing standby procedure will cause the STA to
3002 //disassociate first and then the chip will be put into standby.
3003 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3004 vos_Status = hdd_enter_standby(pHddCtx);
3005 }
3006 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3007 pHddCtx->cfg_ini->nEnableDriverStop)
3008 {
3009 //Execute deep sleep procedure
3010 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003011 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 //Deep sleep not supported
3013 vos_Status = hdd_enter_standby(pHddCtx);
3014 }
3015 else
3016 {
3017 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3018 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3019 vos_Status = VOS_STATUS_SUCCESS;
3020 }
3021
3022 return vos_Status;
3023}
3024
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003025
3026void* wlan_hdd_change_country_code_callback(void *pAdapter)
3027{
3028
3029 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003030 complete(&call_back_pAdapter->change_country_code);
3031
3032 return NULL;
3033}
3034
Jeff Johnson295189b2012-06-20 16:38:30 -07003035static int iw_set_priv(struct net_device *dev,
3036 struct iw_request_info *info,
3037 union iwreq_data *wrqu, char *extra)
3038{
3039 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08003040 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 int cmd_len = wrqu->data.length;
3042 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003043 int rc = 0;
3044 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3045
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3047
3048 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08003049 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3050 wrqu->data.length);
3051 if (NULL == cmd)
3052 {
3053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3054 "mem_alloc_copy_from_user_helper fail");
3055 return -ENOMEM;
3056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003057
3058 if (ioctl_debug)
3059 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003060 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 }
3062
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003063 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3064 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003065
3066 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003067 if (ioctl_debug)
3068 {
3069 pr_info("%s: RESTART in progress\n", __func__);
3070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003071
Arif Hussain24bfa702014-01-22 13:51:30 -08003072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003074 kfree(cmd);
3075 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 }
3077
Arif Hussain24bfa702014-01-22 13:51:30 -08003078 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003080 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3082 "%s: Error in iw_set_scan!", __func__);
3083 rc = -EINVAL;
3084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 }
3086 else if( strcasecmp(cmd, "start") == 0 ) {
3087
Arif Hussain6d2a3322013-11-17 19:50:10 -08003088 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003090
Arif Hussain24bfa702014-01-22 13:51:30 -08003091 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3092 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 {
3094 union iwreq_data wrqu;
3095 char buf[10];
3096
3097 memset(&wrqu, 0, sizeof(wrqu));
3098 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3099 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3100 }
3101 else
3102 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3104 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 }
3106 goto done;
3107 }
3108 else if( strcasecmp(cmd, "stop") == 0 )
3109 {
3110 union iwreq_data wrqu;
3111 char buf[10];
3112
Arif Hussain6d2a3322013-11-17 19:50:10 -08003113 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003114
3115 wlan_hdd_enter_lowpower(pHddCtx);
3116 memset(&wrqu, 0, sizeof(wrqu));
3117 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3118 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 goto done;
3120 }
3121 else if (strcasecmp(cmd, "macaddr") == 0)
3122 {
3123 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3124 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3125 }
3126 else if (strcasecmp(cmd, "scan-active") == 0)
3127 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303128 hddLog(VOS_TRACE_LEVEL_ERROR,
3129 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003130 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 ret = snprintf(cmd, cmd_len, "OK");
3132 }
3133 else if (strcasecmp(cmd, "scan-passive") == 0)
3134 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303135 hddLog(VOS_TRACE_LEVEL_ERROR,
3136 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003137 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 ret = snprintf(cmd, cmd_len, "OK");
3139 }
3140 else if( strcasecmp(cmd, "scan-mode") == 0 )
3141 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003142 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 }
3144 else if( strcasecmp(cmd, "linkspeed") == 0 )
3145 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003146 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 }
3148 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3149 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003150 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003151 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003152
3153 country_code = cmd + 8;
3154
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003155 init_completion(&pAdapter->change_country_code);
3156
Arif Hussain24bfa702014-01-22 13:51:30 -08003157 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003158 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 country_code,
3160 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303161 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303162 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303163 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003164
3165 /* Wait for completion */
3166 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3167 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3168
3169 if (lrc <= 0)
3170 {
3171 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003172 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003173 }
3174
Arif Hussain24bfa702014-01-22 13:51:30 -08003175 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003177 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003178 "%s: SME Change Country code fail", __func__);
3179 kfree(cmd);
3180 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003181 }
3182 }
3183 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3184 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003185 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 }
3187 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3188 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003189 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003190
Wilson Yang1be3e652013-10-09 15:18:31 -07003191 if (9 < cmd_len)
3192 {
3193 ptr = (char*)(cmd + 9);
3194
3195 }else{
3196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3197 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003198 kfree(cmd);
3199 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003200 }
3201
3202 if (1 != sscanf(ptr,"%d",&mode))
3203 {
3204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3205 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003206 kfree(cmd);
3207 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003208 }
3209
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 wlan_hdd_enter_bmps(pAdapter, mode);
3211 /*TODO:Set the power mode*/
3212 }
3213 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3214 v_U32_t pmc_state;
3215 v_U16_t value;
3216
3217 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3218 if(pmc_state == BMPS) {
3219 value = DRIVER_POWER_MODE_AUTO;
3220 }
3221 else {
3222 value = DRIVER_POWER_MODE_ACTIVE;
3223 }
3224 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3225 }
3226 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003227 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 /*TODO: set the btcoexmode*/
3229 }
3230 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3231
Arif Hussain6d2a3322013-11-17 19:50:10 -08003232 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 /*TODO: Return the btcoex status*/
3234 }
3235 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3236
Arif Hussain6d2a3322013-11-17 19:50:10 -08003237 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003238
3239 /*TODO: Enable Rx data Filter*/
3240 }
3241 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3242
Arif Hussain6d2a3322013-11-17 19:50:10 -08003243 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003244
3245 /*TODO: Disable Rx data Filter*/
3246 }
3247 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3248
Arif Hussain6d2a3322013-11-17 19:50:10 -08003249 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 /*TODO: rxfilter-statistics*/
3251 }
3252 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3253
Arif Hussain6d2a3322013-11-17 19:50:10 -08003254 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 /*TODO: rxfilter-add*/
3256 }
3257 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3258
Arif Hussain6d2a3322013-11-17 19:50:10 -08003259 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 /*TODO: rxfilter-remove*/
3261 }
3262#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003263 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3264 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3265 /*TODO: support pnosetup*/
3266 }
3267 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3268 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3269 /*TODO: support pnoforce*/
3270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3272
Arif Hussain6d2a3322013-11-17 19:50:10 -08003273 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003274 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3275 kfree(cmd);
3276 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 }
3278 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003279 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003280 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3281 kfree(cmd);
3282 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 }
3284#endif /*FEATURE_WLAN_SCAN_PNO*/
3285 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003286 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003287 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3288 kfree(cmd);
3289 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 }
3291 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3292 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003293 char *ptr;
3294
3295 if (18 < cmd_len)
3296 {
3297 ptr = (char*)(cmd + 18);
3298 }else{
3299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3300 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003301 kfree(cmd);
3302 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003303 }
3304
Jeff Johnson02797792013-10-26 19:17:13 -07003305 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003306 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3307 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3308 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3309 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3310 {
3311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3312 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003313 kfree(cmd);
3314 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003315 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003316
3317 // parameters checking
3318 // period has to be larger than 0
3319 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3320 {
3321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003322 kfree(cmd);
3323 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 }
3325
3326 // use default value 5 is the input is not reasonable. in unit of 10%
3327 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3328 {
3329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3330 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3331 }
3332
3333 // default is 5
3334 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3335 {
3336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3337 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3338 }
3339
Arif Hussain24bfa702014-01-22 13:51:30 -08003340 if (eHAL_STATUS_SUCCESS !=
3341 sme_SetTxPerTracking(pHddCtx->hHal,
3342 hdd_tx_per_hit_cb,
3343 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003345 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 }
3347 }
3348 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003349 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3350 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 }
3352done:
3353 /* many of the commands write information back into the command
3354 string using snprintf(). check the return value here in one
3355 place */
3356 if ((ret < 0) || (ret >= cmd_len))
3357 {
3358 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003359 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003361 else if (ret > 0)
3362 {
3363 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3364 {
3365 hddLog(VOS_TRACE_LEVEL_ERROR,
3366 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003367 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003368 return -EFAULT;
3369 }
3370 wrqu->data.length = ret;
3371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003372
3373 if (ioctl_debug)
3374 {
3375 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003376 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003378 kfree(cmd);
3379 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003380}
3381
3382static int iw_set_nick(struct net_device *dev,
3383 struct iw_request_info *info,
3384 union iwreq_data *wrqu, char *extra)
3385{
3386 ENTER();
3387 return 0;
3388}
3389
3390static int iw_get_nick(struct net_device *dev,
3391 struct iw_request_info *info,
3392 union iwreq_data *wrqu, char *extra)
3393{
3394 ENTER();
3395 return 0;
3396}
3397
3398static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3399{
3400 ENTER();
3401 return NULL;
3402}
3403
3404static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3405 union iwreq_data *wrqu,char *extra)
3406
3407{
3408 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3409 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3410 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3411 struct iw_point *encoderq = &(wrqu->encoding);
3412 v_U32_t keyId;
3413 v_U8_t key_length;
3414 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3415 v_BOOL_t fKeyPresent = 0;
3416 int i;
3417 eHalStatus status = eHAL_STATUS_SUCCESS;
3418
3419
3420 ENTER();
3421
3422 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3423 {
3424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3425 "%s:LOGP in Progress. Ignore!!!",__func__);
3426 return 0;
3427 }
3428
3429
3430 keyId = encoderq->flags & IW_ENCODE_INDEX;
3431
3432 if(keyId)
3433 {
3434 if(keyId > MAX_WEP_KEYS)
3435 {
3436 return -EINVAL;
3437 }
3438
3439 fKeyPresent = 1;
3440 keyId--;
3441 }
3442 else
3443 {
3444 fKeyPresent = 0;
3445 }
3446
3447
3448 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3449 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 if(!fKeyPresent) {
3452
3453 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3454
3455 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3456 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3457 }
3458 }
3459 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3460 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3461 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3462 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3463
3464 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3465 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3466
3467 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3468 {
3469 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3470 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003471 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303472 {
3473 long ret;
3474 ret = wait_for_completion_interruptible_timeout(
3475 &pAdapter->disconnect_comp_var,
3476 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3477 if (ret <= 0)
3478 hddLog(VOS_TRACE_LEVEL_ERROR,
3479 FL("failed wait on disconnect_comp_var %ld"), ret);
3480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 }
3482
3483 return status;
3484
3485 }
3486
3487 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3488 {
3489 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3490
3491 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3492
3493 }
3494
3495
3496 if(wrqu->data.length > 0)
3497 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003498 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003499
3500 key_length = wrqu->data.length;
3501
3502 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3503
3504 if(5 == key_length)
3505 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003506 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003507
3508 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3509 {
3510 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3511 }
3512 else
3513 {
3514 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3515 }
3516 }
3517 else if(13 == key_length)
3518 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003519 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003520
3521 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3522 {
3523 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3524 }
3525 else
3526 {
3527 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3528 }
3529 }
3530 else
3531 {
3532 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003533 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 return -EINVAL;
3535 }
3536
3537 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3538 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3539 pWextState->roamProfile.EncryptionType.numEntries = 1;
3540 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3541 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3542 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3543
3544 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3545 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3546 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3547 {
3548
3549 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3550
3551 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3552 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3553
3554 return status;
3555 }
3556 }
3557
3558 return 0;
3559}
3560
3561static int iw_get_encodeext(struct net_device *dev,
3562 struct iw_request_info *info,
3563 struct iw_point *dwrq,
3564 char *extra)
3565{
3566 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3567 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3568 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3569 int keyId;
3570 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3571 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3572 int i;
3573
3574 ENTER();
3575
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003576 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3577 {
3578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3579 "%s:LOGP in Progress. Ignore!!!", __func__);
3580 return -EBUSY;
3581 }
3582
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 keyId = pRoamProfile->Keys.defaultIndex;
3584
3585 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3586 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003587 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 return -EINVAL;
3589 }
3590
3591 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3592 {
3593 dwrq->flags |= IW_ENCODE_ENABLED;
3594 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303595 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3596 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003597 }
3598 else
3599 {
3600 dwrq->flags |= IW_ENCODE_DISABLED;
3601 }
3602
3603 for(i=0; i < MAX_WEP_KEYS; i++)
3604 {
3605 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3606 {
3607 continue;
3608 }
3609 else
3610 {
3611 break;
3612 }
3613 }
3614
3615 if(MAX_WEP_KEYS == i)
3616 {
3617 dwrq->flags |= IW_ENCODE_NOKEY;
3618 }
3619 else
3620 {
3621 dwrq->flags |= IW_ENCODE_ENABLED;
3622 }
3623
3624 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3625
3626 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3627 {
3628 dwrq->flags |= IW_ENCODE_DISABLED;
3629 }
3630
3631 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3632
3633 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3634 {
3635 dwrq->flags |= IW_ENCODE_OPEN;
3636 }
3637 else
3638 {
3639 dwrq->flags |= IW_ENCODE_RESTRICTED;
3640 }
3641 EXIT();
3642 return 0;
3643
3644}
3645
3646static int iw_set_encodeext(struct net_device *dev,
3647 struct iw_request_info *info,
3648 union iwreq_data *wrqu, char *extra)
3649{
3650 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3651 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3652 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3653 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3654
3655 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3656 v_U32_t status = 0;
3657
3658 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3659
3660 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3661
3662 int key_index;
3663 struct iw_point *encoding = &wrqu->encoding;
3664 tCsrRoamSetKey setKey;
3665 v_U32_t roamId= 0xFF;
3666 VOS_STATUS vos_status;
3667
3668 ENTER();
3669
3670 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3671 {
3672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3673 "%s:LOGP in Progress. Ignore!!!",__func__);
3674 return 0;
3675 }
3676
3677 key_index = encoding->flags & IW_ENCODE_INDEX;
3678
3679 if(key_index > 0) {
3680
3681 /*Convert from 1-based to 0-based keying*/
3682 key_index--;
3683 }
3684 if(!ext->key_len) {
3685
3686 /*Set the encrytion type to NONE*/
3687 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3688 return status;
3689 }
3690
3691 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3692 (IW_ENCODE_ALG_WEP == ext->alg))
3693 {
3694 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3695
Agarwal Ashish971c2882013-10-30 20:11:12 +05303696 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3697 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 return -EINVAL;
3699 }
3700 else {
3701 /*Static wep, update the roam profile with the keys */
3702 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3703 key_index < CSR_MAX_NUM_KEY) {
3704 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3705 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3706
3707 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3708 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3709
3710 }
3711 }
3712 return status;
3713 }
3714
3715 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3716
3717 setKey.keyId = key_index;
3718 setKey.keyLength = ext->key_len;
3719
3720 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3721 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3722 }
3723
3724 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3725 /*Key direction for group is RX only*/
3726 setKey.keyDirection = eSIR_RX_ONLY;
3727 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3728 }
3729 else {
3730
3731 setKey.keyDirection = eSIR_TX_RX;
3732 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3733 }
3734
3735 /*For supplicant pae role is zero*/
3736 setKey.paeRole = 0;
3737
3738 switch(ext->alg)
3739 {
3740 case IW_ENCODE_ALG_NONE:
3741 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3742 break;
3743
3744 case IW_ENCODE_ALG_WEP:
3745 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3746 break;
3747
3748 case IW_ENCODE_ALG_TKIP:
3749 {
3750 v_U8_t *pKey = &setKey.Key[0];
3751
3752 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3753
3754 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3755
3756 /*Supplicant sends the 32bytes key in this order
3757
3758 |--------------|----------|----------|
3759 | Tk1 |TX-MIC | RX Mic |
3760 |--------------|----------|----------|
3761 <---16bytes---><--8bytes--><--8bytes-->
3762
3763 */
3764 /*Sme expects the 32 bytes key to be in the below order
3765
3766 |--------------|----------|----------|
3767 | Tk1 |RX-MIC | TX Mic |
3768 |--------------|----------|----------|
3769 <---16bytes---><--8bytes--><--8bytes-->
3770 */
3771 /* Copy the Temporal Key 1 (TK1) */
3772 vos_mem_copy(pKey,ext->key,16);
3773
3774 /*Copy the rx mic first*/
3775 vos_mem_copy(&pKey[16],&ext->key[24],8);
3776
3777 /*Copy the tx mic */
3778 vos_mem_copy(&pKey[24],&ext->key[16],8);
3779
3780 }
3781 break;
3782
3783 case IW_ENCODE_ALG_CCMP:
3784 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3785 break;
3786
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003787#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003788#define IW_ENCODE_ALG_KRK 6
3789 case IW_ENCODE_ALG_KRK:
3790 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3791 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003792#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003793
3794 default:
3795 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3796 break;
3797 }
3798
3799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003800 ("%s:cipher_alg:%d key_len[%d] *pEncryptionType :%d"),__func__,(int)ext->alg,(int)ext->key_len,setKey.encType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003801
3802#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303803 /* The supplicant may attempt to set the PTK once pre-authentication
3804 is done. Save the key in the UMAC and include it in the ADD
3805 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303807 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303809 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3810 "%s: Update PreAuth Key success", __func__);
3811 return 0;
3812 }
3813 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3814 {
3815 hddLog(VOS_TRACE_LEVEL_ERROR,
3816 "%s: Update PreAuth Key failed", __func__);
3817 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 }
3819#endif /* WLAN_FEATURE_VOWIFI_11R */
3820
3821 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3822
3823 vos_status = wlan_hdd_check_ula_done(pAdapter);
3824 if ( vos_status != VOS_STATUS_SUCCESS )
3825 {
3826 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3827 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3828 __LINE__, vos_status );
3829
3830 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3831 }
3832
3833 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3834
3835 if ( halStatus != eHAL_STATUS_SUCCESS )
3836 {
3837 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3838 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3839 __LINE__, halStatus );
3840
3841 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3842 }
3843
3844 return halStatus;
3845}
3846
3847static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3848 union iwreq_data *wrqu, char *extra)
3849{
3850 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3851 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3852
3853 ENTER();
3854
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003855 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3856 {
3857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3858 "%s:LOGP in Progress. Ignore!!!", __func__);
3859 return -EBUSY;
3860 }
3861
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3863 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3864
Arif Hussain6d2a3322013-11-17 19:50:10 -08003865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003866
3867 return -EINVAL;
3868 }
3869
3870 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3871
3872 if((wrqu->retry.flags & IW_RETRY_LONG))
3873 {
3874 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3875 {
c_hpothub8245442013-11-20 23:41:09 +05303876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3877 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 return -EIO;
3879 }
3880 }
3881 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3882 {
3883 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3884 {
c_hpothub8245442013-11-20 23:41:09 +05303885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3886 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 return -EIO;
3888 }
3889 }
3890 }
3891 else
3892 {
3893 return -EOPNOTSUPP;
3894 }
3895
Arif Hussain6d2a3322013-11-17 19:50:10 -08003896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003897
3898 EXIT();
3899
3900 return 0;
3901
3902}
3903
3904static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3905 union iwreq_data *wrqu, char *extra)
3906{
3907 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3908 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3909 v_U32_t retry = 0;
3910
3911 ENTER();
3912
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003913 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3914 {
3915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3916 "%s:LOGP in Progress. Ignore!!!", __func__);
3917 return -EBUSY;
3918 }
3919
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 if((wrqu->retry.flags & IW_RETRY_LONG))
3921 {
3922 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3923
3924 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3925 {
c_hpothub8245442013-11-20 23:41:09 +05303926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3927 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 return -EIO;
3929 }
3930
3931 wrqu->retry.value = retry;
3932 }
3933 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3934 {
3935 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3936
3937 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3938 {
c_hpothub8245442013-11-20 23:41:09 +05303939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3940 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 return -EIO;
3942 }
3943
3944 wrqu->retry.value = retry;
3945 }
3946 else {
3947 return -EOPNOTSUPP;
3948 }
3949
Arif Hussain6d2a3322013-11-17 19:50:10 -08003950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003951
3952 EXIT();
3953
3954 return 0;
3955}
3956
3957static int iw_set_mlme(struct net_device *dev,
3958 struct iw_request_info *info,
3959 union iwreq_data *wrqu,
3960 char *extra)
3961{
3962 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3963 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3964 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3965 eHalStatus status = eHAL_STATUS_SUCCESS;
3966
3967 ENTER();
3968
3969 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3970 {
3971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3972 "%s:LOGP in Progress. Ignore!!!",__func__);
3973 return 0;
3974 }
3975
3976 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3977 switch (mlme->cmd) {
3978 case IW_MLME_DISASSOC:
3979 case IW_MLME_DEAUTH:
3980
3981 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3982 {
3983 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3984
3985 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3986 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3987
3988 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3989 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3990
Jeff Johnson43971f52012-07-17 12:26:56 -07003991 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303992 {
3993 long ret;
3994 ret = wait_for_completion_interruptible_timeout(
3995 &pAdapter->disconnect_comp_var,
3996 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3997 if (ret <= 0)
3998 hddLog(VOS_TRACE_LEVEL_ERROR,
3999 FL("failed wait on disconnect_comp_var %ld"), ret);
4000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08004002 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004003 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07004004
4005 /* Resetting authKeyMgmt */
4006 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
4007
4008 netif_tx_disable(dev);
4009 netif_carrier_off(dev);
4010
4011 }
4012 else
4013 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004014 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 }
4016 break;
4017 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004018 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 return -EINVAL;
4020 }//end of switch
4021
4022 EXIT();
4023
4024 return status;
4025
4026}
4027
4028/* set param sub-ioctls */
4029static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
4030 union iwreq_data *wrqu, char *extra)
4031{
4032 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4033 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4034 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4035 int *value = (int *)extra;
4036 int sub_cmd = value[0];
4037 int set_value = value[1];
4038 int ret = 0; /* success */
4039 int enable_pbm, enable_mp;
4040#ifdef CONFIG_HAS_EARLYSUSPEND
4041 v_U8_t nEnableSuspendOld;
4042#endif
4043 INIT_COMPLETION(pWextState->completion_var);
4044
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004045 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4046 {
4047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4048 "%s:LOGP in Progress. Ignore!!!", __func__);
4049 return -EBUSY;
4050 }
4051
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 switch(sub_cmd)
4053 {
4054 case WE_SET_11D_STATE:
4055 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004056 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004057 memset(&smeConfig, 0x00, sizeof(smeConfig));
4058
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4060
4061 sme_GetConfigParam(hHal,&smeConfig);
4062 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4063
Arif Hussain6d2a3322013-11-17 19:50:10 -08004064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004065
4066 sme_UpdateConfig(hHal,&smeConfig);
4067 }
4068 else {
4069 return -EINVAL;
4070 }
4071 break;
4072 }
4073
4074 case WE_WOWL:
4075 {
4076 switch (set_value)
4077 {
4078 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004079 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 break;
4081 case 0x01:
4082 case 0x02:
4083 case 0x03:
4084 enable_mp = (set_value & 0x01) ? 1 : 0;
4085 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004086 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4088 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4089 break;
4090 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004091 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 ret = -EINVAL;
4093 break;
4094 }
4095
4096 break;
4097 }
4098 case WE_SET_POWER:
4099 {
4100 switch (set_value)
4101 {
4102 case 0: //Full Power
4103 {
4104 struct statsContext context;
4105 eHalStatus status;
4106
4107 init_completion(&context.completion);
4108
4109 context.pAdapter = pAdapter;
4110 context.magic = POWER_CONTEXT_MAGIC;
4111
4112 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4113 iw_power_callback_fn, &context,
4114 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004115 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 {
4117 int lrc = wait_for_completion_interruptible_timeout(
4118 &context.completion,
4119 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004120
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 if (lrc <= 0)
4122 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004123 hddLog(VOS_TRACE_LEVEL_ERROR,
4124 "%s: SME %s while requesting fullpower",
4125 __func__, (0 == lrc) ?
4126 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 }
4128 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004129 /* either we have a response or we timed out. if we timed
4130 out there is a race condition such that the callback
4131 function could be executing at the same time we are. of
4132 primary concern is if the callback function had already
4133 verified the "magic" but had not yet set the completion
4134 variable when a timeout occurred. we serialize these
4135 activities by invalidating the magic while holding a
4136 shared spinlock which will cause us to block if the
4137 callback is currently executing */
4138 spin_lock(&hdd_context_lock);
4139 context.magic = 0;
4140 spin_unlock(&hdd_context_lock);
4141
Arif Hussain6d2a3322013-11-17 19:50:10 -08004142 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 break;
4144 }
4145 case 1: //Enable BMPS
4146 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4147 break;
4148 case 2: //Disable BMPS
4149 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4150 break;
4151 case 3: //Request Bmps
4152 {
4153 struct statsContext context;
4154 eHalStatus status;
4155
4156 init_completion(&context.completion);
4157
4158 context.pAdapter = pAdapter;
4159 context.magic = POWER_CONTEXT_MAGIC;
4160
4161 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4162 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004163 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 {
4165 int lrc = wait_for_completion_interruptible_timeout(
4166 &context.completion,
4167 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 if (lrc <= 0)
4169 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004170 hddLog(VOS_TRACE_LEVEL_ERROR,
4171 "%s: SME %s while requesting BMPS",
4172 __func__, (0 == lrc) ? "timeout" :
4173 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 }
4175 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004176 /* either we have a response or we timed out. if we
4177 timed out there is a race condition such that the
4178 callback function could be executing at the same
4179 time we are. of primary concern is if the callback
4180 function had already verified the "magic" but had
4181 not yet set the completion variable when a timeout
4182 occurred. we serialize these activities by
4183 invalidating the magic while holding a shared
4184 spinlock which will cause us to block if the
4185 callback is currently executing */
4186 spin_lock(&hdd_context_lock);
4187 context.magic = 0;
4188 spin_unlock(&hdd_context_lock);
4189
Arif Hussain6d2a3322013-11-17 19:50:10 -08004190 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 break;
4192 }
4193 case 4: //Enable IMPS
4194 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4195 break;
4196 case 5: //Disable IMPS
4197 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4198 break;
4199 case 6: //Enable Standby
4200 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4201 break;
4202 case 7: //Disable Standby
4203 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4204 break;
4205 case 8: //Request Standby
4206#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004207#endif
4208 break;
4209 case 9: //Start Auto Bmps Timer
4210 sme_StartAutoBmpsTimer(hHal);
4211 break;
4212 case 10://Stop Auto BMPS Timer
4213 sme_StopAutoBmpsTimer(hHal);
4214 break;
4215#ifdef CONFIG_HAS_EARLYSUSPEND
4216 case 11://suspend to standby
4217#ifdef CONFIG_HAS_EARLYSUSPEND
4218 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4219 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4221#endif
4222 break;
4223 case 12://suspend to deep sleep
4224#ifdef CONFIG_HAS_EARLYSUSPEND
4225 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4226 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4228#endif
4229 break;
4230 case 13://resume from suspend
4231#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004232#endif
4233 break;
4234#endif
4235 case 14://reset wlan (power down/power up)
4236 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4237 break;
4238 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004239 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 ret = -EINVAL;
4241 break;
4242 }
4243 break;
4244 }
4245
4246 case WE_SET_MAX_ASSOC:
4247 {
4248 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4249 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4250 {
4251 ret = -EINVAL;
4252 }
4253 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4254 set_value, NULL, eANI_BOOLEAN_FALSE)
4255 != eHAL_STATUS_SUCCESS )
4256 {
c_hpothub8245442013-11-20 23:41:09 +05304257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4258 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 ret = -EIO;
4260 }
4261 break;
4262 }
4263
4264 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4265 {
4266 if( 0 == set_value )
4267 {
4268 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4269 }
4270 else if ( 1 == set_value )
4271 {
4272 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4273 }
4274 else
4275 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004276 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 ret = -EINVAL;
4278 }
4279 break;
4280 }
4281
4282 case WE_SET_DATA_INACTIVITY_TO:
4283 {
4284 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4285 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4286 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4287 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4288 set_value,
4289 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4290 {
4291 hddLog(LOGE,"Failure: Could not pass on "
4292 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004293 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 ret = -EINVAL;
4295 }
4296 break;
4297 }
4298 case WE_SET_MAX_TX_POWER:
4299 {
4300 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4301 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4302
4303 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4304 __func__, set_value);
4305 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4306 eHAL_STATUS_SUCCESS )
4307 {
4308 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4309 __func__);
4310 return -EIO;
4311 }
4312
4313 break;
4314 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004315 case WE_SET_MAX_TX_POWER_2_4:
4316 {
4317 hddLog(VOS_TRACE_LEVEL_INFO,
4318 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4319 __func__, set_value);
4320 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4321 eHAL_STATUS_SUCCESS)
4322 {
4323 hddLog(VOS_TRACE_LEVEL_ERROR,
4324 "%s: Setting maximum tx power failed for 2.4 GHz band",
4325 __func__);
4326 return -EIO;
4327 }
4328
4329 break;
4330 }
4331 case WE_SET_MAX_TX_POWER_5_0:
4332 {
4333 hddLog(VOS_TRACE_LEVEL_INFO,
4334 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4335 __func__, set_value);
4336 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4337 eHAL_STATUS_SUCCESS)
4338 {
4339 hddLog(VOS_TRACE_LEVEL_ERROR,
4340 "%s: Setting maximum tx power failed for 5.0 GHz band",
4341 __func__);
4342 return -EIO;
4343 }
4344
4345 break;
4346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 case WE_SET_HIGHER_DTIM_TRANSITION:
4348 {
4349 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4350 (set_value == eANI_BOOLEAN_TRUE)))
4351 {
4352 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4353 ret = -EINVAL;
4354 }
4355 else
4356 {
4357 if(pAdapter->higherDtimTransition != set_value)
4358 {
4359 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004360 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 }
4362 }
4363
4364 break;
4365 }
4366
4367 case WE_SET_TM_LEVEL:
4368 {
4369 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004370 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4372
4373 break;
4374 }
4375
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304376 case WE_ENABLE_STRICT_FCC_REG:
4377 {
4378 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4379 struct wiphy *wiphy = NULL;
4380 long lrc;
4381 int status;
4382
4383 wiphy = hddCtxt->wiphy;
4384 if(wiphy == NULL)
4385 {
4386 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4387 break;
4388 }
4389 init_completion(&hddCtxt->wiphy_channel_update_event);
4390
4391 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4392
4393 status = regulatory_hint(wiphy, "00");
4394 if(status < 0)
4395 {
4396 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4397 break;
4398 }
4399
4400 /* Wait for completion */
4401 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4402 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4403 if (lrc <= 0)
4404 {
4405 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4406 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4407 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4408 }
4409 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4410
4411 break;
4412 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004413 case WE_SET_DEBUG_LOG:
4414 {
4415 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4416 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4417 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4418 break;
4419 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304420
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 default:
4422 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004423 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 sub_cmd, set_value);
4425 break;
4426 }
4427 }
4428
4429 return ret;
4430}
4431
4432/* set param sub-ioctls */
4433static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4434 union iwreq_data *wrqu, char *extra)
4435{
4436 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05304437 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004439 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4441 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4442#ifdef WLAN_FEATURE_VOWIFI
4443 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4444#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05304445 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07004446
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004447 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4448 {
4449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4450 "%s:LOGP in Progress. Ignore!!!", __func__);
4451 return -EBUSY;
4452 }
4453
Girish Gowli552fc072014-06-14 18:26:16 +05304454 /* helper function to get iwreq_data with compat handling. */
4455 if (hdd_priv_get_data(&s_priv_data, wrqu))
4456 {
4457 return -EINVAL;
4458 }
4459
4460 /* make sure all params are correctly passed to function */
4461 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
4462 {
4463 return -EINVAL;
4464 }
4465
4466 sub_cmd = s_priv_data.flags;
4467
Arif Hussain0273cba2014-01-07 20:58:29 -08004468 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05304469 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
4470 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004471 if (NULL == pBuffer)
4472 {
4473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4474 "mem_alloc_copy_from_user_helper fail");
4475 return -ENOMEM;
4476 }
4477
4478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05304479 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4481 "%s: Received data %s", __func__, pBuffer);
4482
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 switch(sub_cmd)
4484 {
4485 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004487 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 break;
4489 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004491 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 break;
4493#if defined WLAN_FEATURE_VOWIFI
4494 case WE_NEIGHBOR_REPORT_REQUEST:
4495 {
4496 tRrmNeighborReq neighborReq;
4497 tRrmNeighborRspCallbackInfo callbackInfo;
4498
4499 if (pConfig->fRrmEnable)
4500 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05304502 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 if( !neighborReq.no_ssid )
4504 {
Girish Gowli552fc072014-06-14 18:26:16 +05304505 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004506 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004507 }
4508
4509 callbackInfo.neighborRspCallback = NULL;
4510 callbackInfo.neighborRspCallbackContext = NULL;
4511 callbackInfo.timeout = 5000; //5 seconds
4512 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4513 }
4514 else
4515 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004516 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 ret = -EINVAL;
4518 }
4519 }
4520 break;
4521#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 case WE_SET_AP_WPS_IE:
4523 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05304524 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004527 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 if (VOS_STATUS_SUCCESS != vstatus)
4529 {
4530 ret = -EINVAL;
4531 }
4532 break;
4533 default:
4534 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004535 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 ret = -EINVAL;
4537 break;
4538 }
4539 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004540 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 return ret;
4542}
4543
4544/* get param sub-ioctls */
4545static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4546 union iwreq_data *wrqu, char *extra)
4547{
4548 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4549 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4550 int *value = (int *)extra;
4551 int ret = 0; /* success */
4552
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004553 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4554 {
4555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4556 "%s:LOGP in Progress. Ignore!!!", __func__);
4557 return -EBUSY;
4558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004559
4560 switch (value[0])
4561 {
4562 case WE_GET_11D_STATE:
4563 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004564 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304566
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4568
Arif Hussain6d2a3322013-11-17 19:50:10 -08004569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004570
4571 break;
4572 }
4573
4574 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 break;
4577
4578 case WE_PMC_STATE:
4579 {
4580 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 break;
4583 }
4584 case WE_GET_WLAN_DBG:
4585 {
4586 vos_trace_display();
4587 *value = 0;
4588 break;
4589 }
4590 case WE_MODULE_DOWN_IND:
4591 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4594#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4597#endif
4598 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4599
4600 *value = 0;
4601 break;
4602 }
4603 case WE_GET_MAX_ASSOC:
4604 {
4605 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4606 {
c_hpothub8245442013-11-20 23:41:09 +05304607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4608 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 ret = -EIO;
4610 }
4611 break;
4612 }
4613
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 case WE_GET_WDI_DBG:
4615 {
4616 wpalTraceDisplay();
4617 *value = 0;
4618 break;
4619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004620
4621 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4622 {
4623 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4624 break;
4625 }
4626 case WE_GET_CONCURRENCY_MODE:
4627 {
4628 *value = hdd_get_concurrency_mode ( );
4629
Arif Hussain6d2a3322013-11-17 19:50:10 -08004630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 break;
4632 }
4633
4634 default:
4635 {
4636 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4637 break;
4638 }
4639 }
4640
4641 return ret;
4642}
4643
4644/* set param sub-ioctls */
4645int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4646 union iwreq_data *wrqu, char *extra)
4647{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004648 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 int *value = (int *)extra;
4650 int sub_cmd = value[0];
4651 int ret = 0;
4652
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004653 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4654 {
4655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4656 "%s:LOGP in Progress. Ignore!!!", __func__);
4657 return -EBUSY;
4658 }
4659
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 switch(sub_cmd)
4661 {
4662 case WE_SET_WLAN_DBG:
4663 {
4664 vos_trace_setValue( value[1], value[2], value[3]);
4665 break;
4666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 case WE_SET_WDI_DBG:
4668 {
4669 wpalTraceSetLevel( value[1], value[2], value[3]);
4670 break;
4671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 case WE_SET_SAP_CHANNELS:
4673 {
4674 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4675 break;
4676 }
4677
4678 default:
4679 {
Jeff Johnson11e77032014-02-14 13:22:22 -08004680 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 break;
4682 }
4683 }
4684 return ret;
4685}
4686
4687static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4688 union iwreq_data *wrqu, char *extra)
4689{
4690 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4691 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004692#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004693 hdd_wext_state_t *pWextState;
4694#endif
4695
4696 if (pAdapter == NULL)
4697 {
4698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4699 "%s: pAdapter is NULL!", __func__);
4700 return -EINVAL;
4701 }
4702#ifdef WLAN_FEATURE_11W
4703 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004704#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004705
Yue Ma3ede6052013-08-29 00:33:26 -07004706 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4707 {
4708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4709 "%s: HDD Context is NULL!", __func__);
4710
4711 return -EINVAL;
4712 }
4713
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004714 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4715 {
4716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4717 "%s:LOGP in Progress. Ignore!!!", __func__);
4718 return -EBUSY;
4719 }
4720
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 switch(sub_cmd)
4722 {
4723 case WE_WLAN_VERSION:
4724 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004725 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 break;
4727 }
4728
4729 case WE_GET_STATS:
4730 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304731 tHalHandle hHal = NULL;
4732 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4734 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4735 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4736
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304737
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 snprintf(extra, WE_MAX_STR_LEN,
4739 "\nTransmit"
4740 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4741 "\n dropped BK %u, BE %u, VI %u, VO %u"
4742 "\n classified BK %u, BE %u, VI %u, VO %u"
4743 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4744 "\n queued BK %u, BE %u, VI %u, VO %u"
4745 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004746 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 "\n fetched BK %u, BE %u, VI %u, VO %u"
4748 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4749 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004750 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 "\n flushed BK %u, BE %u, VI %u, VO %u"
4752 "\n\nReceive"
4753 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4754 "\n\nResetsStats"
4755 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4756 "\n",
4757 pStats->txXmitCalled,
4758 pStats->txXmitDropped,
4759 pStats->txXmitBackPressured,
4760 pStats->txXmitQueued,
4761
4762 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4763 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4764 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4765 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4766
4767 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4768 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4769 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4770 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4771
4772 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4773 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4774 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4775 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4776
4777 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4778 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4779 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4780 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4781
4782 pStats->txFetched,
4783 pStats->txFetchEmpty,
4784 pStats->txFetchLowResources,
4785 pStats->txFetchDequeueError,
4786
4787 pStats->txFetchDequeued,
4788 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004789 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 pStats->txCompleted,
4791 pStats->txFlushed,
4792
4793 pStats->txFetchedAC[WLANTL_AC_BK],
4794 pStats->txFetchedAC[WLANTL_AC_BE],
4795 pStats->txFetchedAC[WLANTL_AC_VI],
4796 pStats->txFetchedAC[WLANTL_AC_VO],
4797
4798 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4799 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4800 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4801 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4802
4803 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4804 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4805 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4806 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4807
Ravi Joshi41914632013-10-21 23:02:21 -07004808 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4809 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4810 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4811 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4812
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 pStats->txFlushedAC[WLANTL_AC_BK],
4814 pStats->txFlushedAC[WLANTL_AC_BE],
4815 pStats->txFlushedAC[WLANTL_AC_VI],
4816 pStats->txFlushedAC[WLANTL_AC_VO],
4817
4818 pStats->rxChains,
4819 pStats->rxPackets,
4820 pStats->rxDropped,
4821 pStats->rxDelivered,
4822 pStats->rxRefused,
4823
4824 pResetStats->totalLogpResets,
4825 pResetStats->totalCMD53Failures,
4826 pResetStats->totalMutexReadFailures,
4827 pResetStats->totalMIFErrorFailures,
4828 pResetStats->totalFWHearbeatFailures,
4829 pResetStats->totalUnknownExceptions
4830 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304831 wrqu->data.length = strlen(extra);
4832
4833 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
4834
4835 if (hHal)
4836 pMac = PMAC_STRUCT( hHal );
4837
4838 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
4839 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
4840 snprintf(extra+wrqu->data.length, pmmStatsLength,
4841 "\n BMPS sleepcnt %llx, BMPS awakecnt %llx"
4842 "\n BMPS sleepreqfailcnt %llx, BMPS wakeupreqfailcnt %llx"
4843 "\n IMPS sleepcnt %llx, IMPS awakecnt %llx"
4844 "\n IMPS sleeperrcnt %llx, IMPS wakeuperrcnt %llx, IMPS lasterr %llx"
4845 "\n",
4846 pMac->pmm.BmpscntSleep,
4847 pMac->pmm.BmpscntAwake,
4848 pMac->pmm.BmpsSleeReqFailCnt,
4849 pMac->pmm.BmpsWakeupReqFailCnt,
4850 pMac->pmm.ImpsCntSleep,
4851 pMac->pmm.ImpsCntAwake,
4852 pMac->pmm.ImpsSleepErrCnt,
4853 pMac->pmm.ImpsWakeupErrCnt,
4854 pMac->pmm.ImpsLastErr
4855 );
4856 }
4857
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 wrqu->data.length = strlen(extra)+1;
4859 break;
4860 }
4861
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304862/* The case prints the current state of the HDD, SME, CSR, PE, TL
4863 *it can be extended for WDI Global State as well.
4864 *And currently it only checks P2P_CLIENT adapter.
4865 *P2P_DEVICE and P2P_GO have not been added as of now.
4866*/
4867 case WE_GET_STATES:
4868 {
4869 int buf = 0, len = 0;
4870 int adapter_num = 0;
4871 int count = 0, check = 1;
4872
4873 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004874 tHalHandle hHal = NULL;
4875 tpAniSirGlobal pMac = NULL;
4876 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304877
4878 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4879 hdd_adapter_t *useAdapter = NULL;
4880
4881 /* Print wlan0 or p2p0 states based on the adapter_num
4882 *by using the correct adapter
4883 */
4884 while ( adapter_num < 2 )
4885 {
4886 if ( WLAN_ADAPTER == adapter_num )
4887 {
4888 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004889 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304890 "\n\n wlan0 States:-");
4891 len += buf;
4892 }
4893 else if ( P2P_ADAPTER == adapter_num )
4894 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004895 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304896 "\n\n p2p0 States:-");
4897 len += buf;
4898
4899 if( !pHddCtx )
4900 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004901 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304902 "\n pHddCtx is NULL");
4903 len += buf;
4904 break;
4905 }
4906
4907 /*Printing p2p0 states only in the case when the device is
4908 configured as a p2p_client*/
4909 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4910 if ( !useAdapter )
4911 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004912 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304913 "\n Device not configured as P2P_CLIENT.");
4914 len += buf;
4915 break;
4916 }
4917 }
4918
4919 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004920 if (!hHal) {
4921 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4922 "\n pMac is NULL");
4923 len += buf;
4924 break;
4925 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304926 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004927 if (!pMac) {
4928 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4929 "\n pMac is NULL");
4930 len += buf;
4931 break;
4932 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304933 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4934 if( !pHddStaCtx )
4935 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004936 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304937 "\n pHddStaCtx is NULL");
4938 len += buf;
4939 break;
4940 }
4941
4942 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4943
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004944 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304945 "\n HDD Conn State - %s "
4946 "\n \n SME State:"
4947 "\n Neighbour Roam State - %s"
4948 "\n CSR State - %s"
4949 "\n CSR Substate - %s"
4950 "\n \n TL STA %d State: %s",
4951 macTraceGetHDDWlanConnState(
4952 pHddStaCtx->conn_info.connState),
4953 macTraceGetNeighbourRoamState(
4954 pMac->roam.neighborRoamInfo.neighborRoamState),
4955 macTraceGetcsrRoamState(
4956 pMac->roam.curState[useAdapter->sessionId]),
4957 macTraceGetcsrRoamSubState(
4958 pMac->roam.curSubState[useAdapter->sessionId]),
4959 pHddStaCtx->conn_info.staId[0],
4960 macTraceGetTLState(tlState)
4961 );
4962 len += buf;
4963 adapter_num++;
4964 }
4965
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004966 if (pMac) {
4967 /* Printing Lim State starting with global lim states */
4968 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4969 "\n \n LIM STATES:-"
4970 "\n Global Sme State - %s "\
4971 "\n Global mlm State - %s "\
4972 "\n",
4973 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4974 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4975 );
4976 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304977
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004978 /*printing the PE Sme and Mlm states for valid lim sessions*/
4979 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304980 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004981 if ( pMac->lim.gpSession[count].valid )
4982 {
4983 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4984 "\n Lim Valid Session %d:-"
4985 "\n PE Sme State - %s "
4986 "\n PE Mlm State - %s "
4987 "\n",
4988 check,
4989 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4990 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4991 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304992
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004993 len += buf;
4994 check++;
4995 }
4996 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304997 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304998 }
4999
5000 wrqu->data.length = strlen(extra)+1;
5001 break;
5002 }
5003
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 case WE_GET_CFG:
5005 {
5006 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
5007 wrqu->data.length = strlen(extra)+1;
5008 break;
5009 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005010#ifdef WLAN_FEATURE_11AC
5011 case WE_GET_RSSI:
5012 {
5013 v_S7_t s7Rssi = 0;
5014 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
5015 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
5016 wrqu->data.length = strlen(extra)+1;
5017 break;
5018 }
5019#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305020
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005021#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005022 case WE_GET_ROAM_RSSI:
5023 {
5024 v_S7_t s7Rssi = 0;
5025 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
5026 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
5027 wrqu->data.length = strlen(extra)+1;
5028 break;
5029 }
5030#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 case WE_GET_WMM_STATUS:
5032 {
5033 snprintf(extra, WE_MAX_STR_LEN,
5034 "\nDir: 0=up, 1=down, 3=both\n"
5035 "|------------------------|\n"
5036 "|AC | ACM |Admitted| Dir |\n"
5037 "|------------------------|\n"
5038 "|VO | %d | %3s | %d |\n"
5039 "|VI | %d | %3s | %d |\n"
5040 "|BE | %d | %3s | %d |\n"
5041 "|BK | %d | %3s | %d |\n"
5042 "|------------------------|\n",
5043 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
5044 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
5045 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
5046 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
5047 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
5048 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
5049 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
5050 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
5051 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
5052 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
5053 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
5054 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
5055
Jeff Johnsone7245742012-09-05 17:12:55 -07005056
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 wrqu->data.length = strlen(extra)+1;
5058 break;
5059 }
5060 case WE_GET_CHANNEL_LIST:
5061 {
5062 VOS_STATUS status;
5063 v_U8_t i, len;
5064 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05305065 tANI_U8 pBuf[COUNTRY_CODE_LEN];
5066 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
5067 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 tChannelListInfo channel_list;
5069
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005070 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005072 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005074 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 return -EINVAL;
5076 }
5077 buf = extra;
5078
5079 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005080 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
5081 * needed = 5 * number of channels. Check ifsufficient
5082 * buffer is available and then proceed to fill the buffer.
5083 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
5085 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005086 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005087 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005088 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 return -EINVAL;
5090 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005091 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
5092 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05305093 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
5094 {
5095 //Printing Country code in getChannelList
5096 for(i= 0; i < COUNTRY_CODE_LEN; i++)
5097 {
5098 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
5099 "%c ", pBuf[i]);
5100 }
5101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005102 for(i = 0 ; i < channel_list.num_channels; i++)
5103 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005104 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 }
5107 wrqu->data.length = strlen(extra)+1;
5108
5109 break;
5110 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005111#ifdef FEATURE_WLAN_TDLS
5112 case WE_GET_TDLS_PEERS:
5113 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005114 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005115 break;
5116 }
5117#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005118#ifdef WLAN_FEATURE_11W
5119 case WE_GET_11W_INFO:
5120 {
5121 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5122
5123 snprintf(extra, WE_MAX_STR_LEN,
5124 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5125 "\n Number of Unprotected Disassocs %d"
5126 "\n Number of Unprotected Deauths %d",
5127 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5128 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5129 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5130 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5131 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5132
5133 wrqu->data.length = strlen(extra)+1;
5134 break;
5135 }
5136#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305137 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005139 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 break;
5141 }
5142 }
5143
5144 return 0;
5145}
5146
5147/* action sub-ioctls */
5148static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
5149 union iwreq_data *wrqu, char *extra)
5150{
5151 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305152 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005153 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305154 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005155
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005156 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5157 {
5158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5159 "%s:LOGP in Progress. Ignore!!!", __func__);
5160 return -EBUSY;
5161 }
5162
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305163 /* helper function to get iwreq_data with compat handling. */
5164 if (hdd_priv_get_data(&s_priv_data, wrqu))
5165 {
5166 return -EINVAL;
5167 }
5168
5169 sub_cmd = s_priv_data.flags;
5170
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 switch (sub_cmd)
5172 {
5173 case WE_CLEAR_STATS:
5174 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5177 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5178 break;
5179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 case WE_INIT_AP:
5181 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305182 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5183
5184 /* As Soft AP mode might been changed to STA already with
5185 * killing of Hostapd, need to find the adpater by name
5186 * rather than mode */
5187 hdd_adapter_t* pAdapter_to_stop =
5188 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5189 if( pAdapter_to_stop )
5190 {
5191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5192 "Adapter with name softap.0 already "
5193 "exist, ignoring the request.\nRemove the "
5194 "adapter and try again\n");
5195 break;
5196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005197 pr_info("Init AP trigger\n");
5198 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5199 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5200 break;
5201 }
5202 case WE_STOP_AP:
5203 {
5204 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5205 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5206 * this is a dead code and need to find the adpater by name rather than mode */
5207 hdd_adapter_t* pAdapter_to_stop =
5208 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5209 if( pAdapter_to_stop )
5210 {
5211 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5212
5213 pr_info("Stopping AP mode\n");
5214
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305215 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5216 {
5217 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5218 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5219 }
5220
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 /*Make sure that pAdapter cleaned properly*/
5222 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5223 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5224 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5225
5226 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5227 pAdapter_to_stop->macAddressCurrent.bytes);
5228 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5229 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305230
5231 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5232 {
5233 /* put the device back into BMPS */
5234 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 }
5237 else
5238 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005239 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 }
5241
5242 break;
5243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005244#ifdef WLAN_BTAMP_FEATURE
5245 case WE_ENABLE_AMP:
5246 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 WLANBAP_RegisterWithHCI(pAdapter);
5249 break;
5250 }
5251 case WE_DISABLE_AMP:
5252 {
5253 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5254 VOS_STATUS status;
5255
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005257
5258 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5259 status = WLANBAP_StopAmp();
5260 if(VOS_STATUS_SUCCESS != status )
5261 {
5262 pHddCtx->isAmpAllowed = VOS_TRUE;
5263 hddLog(VOS_TRACE_LEVEL_FATAL,
5264 "%s: Failed to stop AMP", __func__);
5265 }
5266 else
5267 {
5268 //a state m/c implementation in PAL is TBD to avoid this delay
5269 msleep(500);
5270 pHddCtx->isAmpAllowed = VOS_FALSE;
5271 WLANBAP_DeregisterFromHCI();
5272 }
5273
5274 break;
5275 }
5276#endif
5277
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005278 case WE_ENABLE_DXE_STALL_DETECT:
5279 {
schang6295e542013-03-12 15:31:23 -07005280 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5281 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005282 break;
5283 }
5284 case WE_DISPLAY_DXE_SNAP_SHOT:
5285 {
schang6295e542013-03-12 15:31:23 -07005286 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5287 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005288 break;
5289 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305290 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5291 {
5292 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5293 hdd_wmm_tx_snapshot(pAdapter);
5294 WLANTL_TLDebugMessage(VOS_TRUE);
5295 break;
5296 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305297
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305298 case WE_SET_REASSOC_TRIGGER:
5299 {
5300 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5301 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5302 v_U32_t roamId = 0;
5303 tCsrRoamModifyProfileFields modProfileFields;
5304 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5305 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5306 return 0;
5307 }
5308
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305309 case WE_STOP_OBSS_SCAN:
5310 {
5311 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5312 2.OBSS scan is stopped by Firmware during the disassociation
5313 3.OBSS stop comamnd is added for debugging purpose*/
5314 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5315 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005316
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305317 if (pAdapter == NULL)
5318 {
5319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5320 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305321 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305322 }
5323 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5324 if (pMac == NULL)
5325 {
5326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5327 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305328 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305329 }
5330 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5331 }
5332 break;
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305333
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 default:
5335 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005336 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 break;
5338 }
5339 }
5340
5341 return ret;
5342}
5343
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305344void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5345{
5346 /*
5347 * Function to display HDD WMM information
5348 * for Tx Queues.
5349 * Prints globala as well as per client depending
5350 * whether the clients are registered or not.
5351 */
5352 int i = 0, j = 0;
5353 for ( i=0; i< NUM_TX_QUEUES; i++)
5354 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305355 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005356 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305357 i, pAdapter->wmm_tx_queue[i].count,
5358 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305359 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305360 }
5361
5362 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5363 {
5364 if(pAdapter->aStaInfo[i].isUsed)
5365 {
5366 hddLog(LOGE, "******STAIndex: %d*********", i);
5367 for ( j=0; j< NUM_TX_QUEUES; j++)
5368 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305369 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005370 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305371 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5372 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5373 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305374 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305375 }
5376 }
5377 }
5378
5379}
Jeff Johnson295189b2012-06-20 16:38:30 -07005380int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5381 union iwreq_data *wrqu, char *extra)
5382{
5383 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5384 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowlid4522fd2014-06-14 17:20:27 +05305385 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 int apps_args[MAX_VAR_ARGS] = {0};
Girish Gowlid4522fd2014-06-14 17:20:27 +05305387 int num_args;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005388 hdd_station_ctx_t *pStaCtx = NULL ;
5389 hdd_ap_ctx_t *pAPCtx = NULL;
5390 int cmd = 0;
5391 int staId = 0;
Girish Gowlid4522fd2014-06-14 17:20:27 +05305392 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005393
Girish Gowlid4522fd2014-06-14 17:20:27 +05305394 /* helper function to get iwreq_data with compat handling. */
5395 if (hdd_priv_get_data(&s_priv_data, wrqu))
5396 {
5397 return -EINVAL;
5398 }
5399
5400 if (NULL == s_priv_data.pointer)
5401 {
5402 return -EINVAL;
5403 }
5404
5405 sub_cmd = s_priv_data.flags;
5406 num_args = s_priv_data.length;
5407
5408 hddLog(LOG1, "%s: Received length %d", __func__, s_priv_data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005409
5410 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5411 {
5412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5413 "%s:LOGP in Progress. Ignore!!!", __func__);
5414 return -EBUSY;
5415 }
5416
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 if (num_args > MAX_VAR_ARGS)
5418 {
5419 num_args = MAX_VAR_ARGS;
5420 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005421
5422 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlid4522fd2014-06-14 17:20:27 +05305423 if (copy_from_user(apps_args, s_priv_data.pointer, (sizeof(int)) * num_args))
Arif Hussain0273cba2014-01-07 20:58:29 -08005424 {
5425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5426 "%s: failed to copy data to user buffer", __func__);
5427 return -EFAULT;
5428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005429
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005430 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5431 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5432 {
5433 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5434 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5435 {
5436 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5437 staId = pStaCtx->conn_info.staId[0];
5438 }
5439 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5440 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5441 {
5442 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5443 staId = pAPCtx->uBCStaId;
5444 }
5445 else
5446 {
5447 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5448 return 0;
5449 }
5450 }
5451
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 switch (sub_cmd)
5453 {
5454 case WE_LOG_DUMP_CMD:
5455 {
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305456 vos_ssr_protect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005458 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 apps_args[3], apps_args[4]);
5460
5461 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5462 apps_args[3], apps_args[4]);
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305463 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005464
5465 }
5466 break;
5467
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 case WE_P2P_NOA_CMD:
5469 {
5470 p2p_app_setP2pPs_t p2pNoA;
5471
5472 p2pNoA.opp_ps = apps_args[0];
5473 p2pNoA.ctWindow = apps_args[1];
5474 p2pNoA.duration = apps_args[2];
5475 p2pNoA.interval = apps_args[3];
5476 p2pNoA.count = apps_args[4];
5477 p2pNoA.single_noa_duration = apps_args[5];
5478 p2pNoA.psSelection = apps_args[6];
5479
5480 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5481 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005482 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5484
5485 hdd_setP2pPs(dev, &p2pNoA);
5486
5487 }
5488 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005489
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305490 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5491 {
5492 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5493 __func__, apps_args[0], apps_args[1]);
5494 vosTraceEnable(apps_args[0], apps_args[1]);
5495 }
5496 break;
5497
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005498 case WE_MTRACE_DUMP_CMD:
5499 {
5500 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5501 "bitmask_of_module %d ",
5502 __func__, apps_args[0], apps_args[1], apps_args[2],
5503 apps_args[3]);
5504 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5505 apps_args[2], apps_args[3]);
5506
5507 }
5508 break;
5509
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005510 case WE_MCC_CONFIG_CREDENTIAL :
5511 {
5512 cmd = 287; //Command should be updated if there is any change
5513 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005514 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005515 {
5516 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5517 }
5518 else
5519 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005520 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005521 return 0;
5522 }
5523 }
5524 break;
5525
5526 case WE_MCC_CONFIG_PARAMS :
5527 {
5528 cmd = 288; //command Should be updated if there is any change
5529 // in the Riva dump command
5530 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5531 }
5532 break;
5533
Chilam NG571c65a2013-01-19 12:27:36 +05305534#ifdef FEATURE_WLAN_TDLS
5535 case WE_TDLS_CONFIG_PARAMS :
5536 {
5537 tdls_config_params_t tdlsParams;
5538
Chilam Ng01120412013-02-19 18:32:21 -08005539 tdlsParams.tdls = apps_args[0];
5540 tdlsParams.tx_period_t = apps_args[1];
5541 tdlsParams.tx_packet_n = apps_args[2];
5542 tdlsParams.discovery_period_t = apps_args[3];
5543 tdlsParams.discovery_tries_n = apps_args[4];
5544 tdlsParams.idle_timeout_t = apps_args[5];
5545 tdlsParams.idle_packet_n = apps_args[6];
5546 tdlsParams.rssi_hysteresis = apps_args[7];
5547 tdlsParams.rssi_trigger_threshold = apps_args[8];
5548 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305549
Chilam Ng01120412013-02-19 18:32:21 -08005550 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305551 }
5552 break;
5553#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 default:
5555 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005556 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5557 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 }
5559 break;
5560 }
5561
5562 return 0;
5563}
5564
5565
5566static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5567 union iwreq_data *wrqu, char *extra)
5568{
5569 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5570 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5571 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5572 int params[HDD_WLAN_WMM_PARAM_COUNT];
5573 sme_QosWmmTspecInfo tSpec;
5574 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05305575 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005576
5577 // make sure the application is sufficiently priviledged
5578 // note that the kernel will do this for "set" ioctls, but since
5579 // this ioctl wants to return status to user space it must be
5580 // defined as a "get" ioctl
5581 if (!capable(CAP_NET_ADMIN))
5582 {
5583 return -EPERM;
5584 }
5585
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005586 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5587 {
5588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5589 "%s:LOGP in Progress. Ignore!!!", __func__);
5590 return -EBUSY;
5591 }
5592
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 // we must be associated in order to add a tspec
5594 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5595 {
5596 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5597 return 0;
5598 }
5599
5600 // since we are defined to be a "get" ioctl, and since the number
5601 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05305602 // will pass down in the iwreq_data, we must copy the "set" params.
5603 // We must handle the compat for iwreq_data in 32U/64K environment.
5604
5605 // helper fucntion to get iwreq_data with compat handling.
5606 if (hdd_priv_get_data(&s_priv_data, wrqu))
5607 {
5608 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5609 return 0;
5610 }
5611
5612 // make sure all params are correctly passed to function
5613 if ((NULL == s_priv_data.pointer) ||
5614 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
5615 {
5616 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5617 return 0;
5618 }
5619
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05305621 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 {
5623 // hmmm, can't get them
5624 return -EIO;
5625 }
5626
5627 // clear the tspec
5628 memset(&tSpec, 0, sizeof(tSpec));
5629
5630 // validate the handle
5631 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5632 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5633 {
5634 // that one is reserved
5635 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5636 return 0;
5637 }
5638
5639 // validate the TID
5640 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5641 {
5642 // out of range
5643 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5644 return 0;
5645 }
5646 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5647
5648 // validate the direction
5649 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5650 {
5651 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5652 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5653 break;
5654
5655 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5656 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5657 break;
5658
5659 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5660 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5661 break;
5662
5663 default:
5664 // unknown
5665 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5666 return 0;
5667 }
5668
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305669 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5670
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 // validate the user priority
5672 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5673 {
5674 // out of range
5675 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5676 return 0;
5677 }
5678 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305679 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5680 {
5681 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5682 return 0;
5683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005684
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5686 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5687 tSpec.ts_info.psb, tSpec.ts_info.up);
5688
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5690 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5691 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5692 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5693 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5694 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5695 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5696 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5697 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5698 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5699 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5700 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5701
5702 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5703
5704 // validate the ts info ack policy
5705 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5706 {
5707 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5708 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5709 break;
5710
5711 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5712 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5713 break;
5714
5715 default:
5716 // unknown
5717 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5718 return 0;
5719 }
5720
5721 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5722 return 0;
5723}
5724
5725
5726static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5727 union iwreq_data *wrqu, char *extra)
5728{
5729 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5730 int *params = (int *)extra;
5731 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5732 v_U32_t handle;
5733
5734 // make sure the application is sufficiently priviledged
5735 // note that the kernel will do this for "set" ioctls, but since
5736 // this ioctl wants to return status to user space it must be
5737 // defined as a "get" ioctl
5738 if (!capable(CAP_NET_ADMIN))
5739 {
5740 return -EPERM;
5741 }
5742
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005743 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5744 {
5745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5746 "%s:LOGP in Progress. Ignore!!!", __func__);
5747 return -EBUSY;
5748 }
5749
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 // although we are defined to be a "get" ioctl, the params we require
5751 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5752 // is no need to copy the params from user space
5753
5754 // validate the handle
5755 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5756 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5757 {
5758 // that one is reserved
5759 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5760 return 0;
5761 }
5762
5763 *pStatus = hdd_wmm_delts(pAdapter, handle);
5764 return 0;
5765}
5766
5767
5768static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5769 union iwreq_data *wrqu, char *extra)
5770{
5771 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5772 int *params = (int *)extra;
5773 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5774 v_U32_t handle;
5775
5776 // although we are defined to be a "get" ioctl, the params we require
5777 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5778 // is no need to copy the params from user space
5779
5780 // validate the handle
5781 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5782 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5783 {
5784 // that one is reserved
5785 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5786 return 0;
5787 }
5788
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005789 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5790 {
5791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5792 "%s:LOGP in Progress. Ignore!!!", __func__);
5793 return -EBUSY;
5794 }
5795
Jeff Johnson295189b2012-06-20 16:38:30 -07005796 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5797 return 0;
5798}
5799
5800
5801#ifdef FEATURE_WLAN_WAPI
5802static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5803 union iwreq_data *wrqu, char *extra)
5804{
5805 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5806 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5807 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5808 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5809
Arif Hussain7adce1b2013-11-11 22:59:34 -08005810 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005811
5812 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005813 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005814 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5815 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005816
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005817 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5818 {
5819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5820 "%s:LOGP in Progress. Ignore!!!", __func__);
5821 return -EBUSY;
5822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005823
5824 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005825 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5827 pRoamProfile->EncryptionType.numEntries = 1;
5828 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5829 pRoamProfile->mcEncryptionType.numEntries = 1;
5830 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5831
5832 pRoamProfile->AuthType.numEntries = 1;
5833 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5834 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5835 }
5836 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005837 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 }
5839 else
5840 return -EINVAL;
5841
5842 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5843
5844 return 0;
5845}
5846
5847static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5848 union iwreq_data *wrqu, char *extra)
5849{
5850 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5851 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5852
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005853 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5854 {
5855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5856 "%s:LOGP in Progress. Ignore!!!", __func__);
5857 return -EBUSY;
5858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5860
5861 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005862 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 return 0;
5864}
5865
5866static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5867 union iwreq_data *wrqu, char *extra)
5868{
5869 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5870// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5871 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5872 int i = 0, j = 0;
5873 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005874 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005875 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005876
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005877 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5878 {
5879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5880 "%s:LOGP in Progress. Ignore!!!", __func__);
5881 return -EBUSY;
5882 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005883
5884 if (NULL == pWapiAssocInfo)
5885 {
5886 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5887 "%s: WDA NULL context", __func__);
5888 VOS_ASSERT(0);
5889 return VOS_STATUS_E_FAILURE;
5890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005891
Arif Hussain6d2a3322013-11-17 19:50:10 -08005892 hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x",__func__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005893 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005895 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005896
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005897 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005899 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005900
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005901 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005902 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 for(i = 0 ; i < 16 ; i++) {
5904 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5905 for(j = 0 ; j < 16 ; j++)
5906 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5907 }
5908
5909 /* We are not using the entire IE as provided by the supplicant.
5910 * This is being calculated by SME. This is the same as in the
5911 * case of WPA. Only the auth mode information needs to be
5912 * extracted here*/
5913 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005914 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5916 }
5917
5918 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005919 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5921 }
5922 return 0;
5923}
5924
5925static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5926 union iwreq_data *wrqu, char *extra)
5927{
5928 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5929 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5930 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5931 tANI_U32 roamId = 0xFF;
5932 tANI_U8 *pKeyPtr = NULL;
5933 v_BOOL_t isConnected = TRUE;
5934 tCsrRoamSetKey setKey;
5935 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5937
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005938 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5939 {
5940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5941 "%s:LOGP in Progress. Ignore!!!", __func__);
5942 return -EBUSY;
5943 }
5944
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005946 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005947 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005948
Arif Hussain6d2a3322013-11-17 19:50:10 -08005949 hddLog(LOG1,":%s: INPUT DATA:\nKey Type:0x%02x Key Direction:0x%02x KEY ID:0x%02x", __func__, pWapiKey->keyType, pWapiKey->keyDirection, pWapiKey->keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 hddLog(LOG1,"Add Index:0x");
5951 for(i =0 ; i < 12 ; i++)
5952 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5953
Arif Hussain6d2a3322013-11-17 19:50:10 -08005954 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5956 for(i =0 ; i < 16 ; i++)
5957 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5958
Arif Hussain6d2a3322013-11-17 19:50:10 -08005959 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5961 for(i =0 ; i < 16 ; i++)
5962 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5963
Arif Hussain6d2a3322013-11-17 19:50:10 -08005964 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 for(i = 0 ; i < 16 ; i++)
5966 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5967
5968 // Clear the setkey memory
5969 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5970 // Store Key ID
5971 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5972 // SET WAPI Encryption
5973 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5974 // Key Directionn both TX and RX
5975 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5976 // the PAE role
5977 setKey.paeRole = 0 ;
5978
5979 switch ( pWapiKey->keyType )
5980 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005981 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 {
5983 isConnected = hdd_connIsConnected(pHddStaCtx);
5984 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5985 break;
5986 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005987 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 {
5989 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5990 break;
5991 }
5992 default:
5993 {
5994 //Any other option is invalid.
5995 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005996 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005997
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005998 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
6000 break; // NEED RETURN FROM HERE ????
6001 }
6002 }
6003
6004 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
6005 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
6006 pKeyPtr = setKey.Key;
6007 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
6008 pKeyPtr += pWapiKey->wpiekLen;
6009 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
6010
6011 // Set the new key with SME.
6012 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6013
6014 if ( isConnected ) {
6015 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
6016 if ( halStatus != eHAL_STATUS_SUCCESS )
6017 {
6018 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6019 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
6020
6021 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6022 }
6023 }
6024#if 0 /// NEED TO CHECK ON THIS
6025 else
6026 {
6027 // Store the keys in the adapter to be moved to the profile & passed to
6028 // SME in the ConnectRequest if we are not yet in connected state.
6029 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
6030 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
6031
6032 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
6033 " Saving key [idx= %d] to apply when moving to connected state ",
6034 setKey.keyId );
6035
6036 }
6037#endif
6038 return halStatus;
6039}
6040
6041static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
6042 union iwreq_data *wrqu, char *extra)
6043{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006044 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006045#ifdef WLAN_DEBUG
6046 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08006047 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006048#endif
6049
6050 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006051 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006052 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006053
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006054 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
6055 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07006056
6057 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006058
6059 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6060 {
6061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6062 "%s:LOGP in Progress. Ignore!!!", __func__);
6063 return -EBUSY;
6064 }
6065
Jeff Johnson295189b2012-06-20 16:38:30 -07006066#ifdef WLAN_DEBUG
6067 for(i =0 ; i < 16 ; i++)
6068 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
6069#endif
6070
6071 return 0;
6072}
6073
6074static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
6075 union iwreq_data *wrqu, char *extra)
6076{
6077 /* Yet to implement this function, 19th April 2010 */
6078 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
6079
6080 return 0;
6081}
6082#endif /* FEATURE_WLAN_WAPI */
6083
6084#ifdef WLAN_FEATURE_VOWIFI_11R
6085//
6086//
6087// Each time the supplicant has the auth_request or reassoc request
6088// IEs ready. This is pushed to the driver. The driver will inturn use
6089// it to send out the auth req and reassoc req for 11r FT Assoc.
6090//
6091static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
6092 union iwreq_data *wrqu, char *extra)
6093{
6094 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6095 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6096 //v_CONTEXT_t pVosContext;
6097
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006098 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6099 {
6100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6101 "%s:LOGP in Progress. Ignore!!!", __func__);
6102 return -EBUSY;
6103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 if (!wrqu->data.length)
6105 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006106 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 return -EINVAL;
6108 }
6109 if (wrqu->data.pointer == NULL)
6110 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006111 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 return -EINVAL;
6113 }
6114
6115 // Added for debug on reception of Re-assoc Req.
6116 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6117 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006118 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006120 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 }
6122
6123#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08006124 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07006125#endif
6126
6127 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08006128 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 wrqu->data.length);
6130
6131 return 0;
6132}
6133#endif
6134
Amar Singhalf3a6e762013-02-19 15:06:50 -08006135static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006136 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08006138{
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006140 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006142 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006143 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006144 tpSirRcvFltMcAddrList mc_addr_list_ptr;
6145 int idx;
6146 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07006147
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006148 if (pHddCtx->isLogpInProgress)
6149 {
6150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6151 "%s:LOGP in Progress. Ignore!!!", __func__);
6152 return -EBUSY;
6153 }
6154
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306155 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
6156 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306157#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07006158
Amar Singhalf3a6e762013-02-19 15:06:50 -08006159 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6160 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006161 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006162 hddLog(VOS_TRACE_LEVEL_ERROR,
6163 "%s: vos_mem_alloc failed", __func__);
6164 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006165 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006166
6167 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
6168
6169 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
6170 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
6171
6172 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
6173 mc_addr_list_ptr->ulMulticastAddrCnt);
6174
6175 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006176 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006177 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
6178 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
6179
6180 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6181 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006182 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006183
Amar Singhalf3a6e762013-02-19 15:06:50 -08006184 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6185 vos_mem_free(mc_addr_list_ptr);
6186 if (eHAL_STATUS_SUCCESS != ret_val)
6187 {
6188 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6189 __func__);
6190 return -EINVAL;
6191 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306192#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306193 }
6194 else
6195 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006196
Amar Singhalf3a6e762013-02-19 15:06:50 -08006197 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6198 "%s: Set MC BC Filter Config request: %d suspend %d",
6199 __func__, pRequest->mcastBcastFilterSetting,
6200 pHddCtx->hdd_wlan_suspended);
6201
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306202 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006203
6204 if (pHddCtx->hdd_wlan_suspended)
6205 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006206 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6207 if (NULL == wlanRxpFilterParam)
6208 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306209 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006210 "%s: vos_mem_alloc failed", __func__);
6211 return -EINVAL;
6212 }
6213
Amar Singhalf3a6e762013-02-19 15:06:50 -08006214 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6215 pRequest->mcastBcastFilterSetting;
6216 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6217
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306218 hdd_conf_hostoffload(pAdapter, TRUE);
6219 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6220 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006221
6222 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6223 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306224 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006225 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6226 wlanRxpFilterParam->setMcstBcstFilter);
6227
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306228 if (eHAL_STATUS_SUCCESS !=
6229 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6230 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006231 {
6232 hddLog(VOS_TRACE_LEVEL_ERROR,
6233 "%s: Failure to execute set HW MC/BC Filter request",
6234 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006235 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006236 return -EINVAL;
6237 }
6238
Amar Singhalf3a6e762013-02-19 15:06:50 -08006239 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006241
6242 return 0;
6243}
6244
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006245static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006246 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 union iwreq_data *wrqu, char *extra)
6248{
6249 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6250 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306251 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006252 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006253
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306254 //Reset the filter to INI value as we have to clear the dynamic filter
6255 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006256
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306257 //Configure FW with new setting
6258 if (pHddCtx->hdd_wlan_suspended)
6259 {
6260 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6261 if (NULL == wlanRxpFilterParam)
6262 {
6263 hddLog(VOS_TRACE_LEVEL_ERROR,
6264 "%s: vos_mem_alloc failed", __func__);
6265 return -EINVAL;
6266 }
6267
6268 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6269 pHddCtx->configuredMcastBcastFilter;
6270 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6271
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306272 hdd_conf_hostoffload(pAdapter, TRUE);
6273 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6274 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306275
6276 if (eHAL_STATUS_SUCCESS !=
6277 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6278 wlanRxpFilterParam))
6279 {
6280 hddLog(VOS_TRACE_LEVEL_ERROR,
6281 "%s: Failure to execute set HW MC/BC Filter request",
6282 __func__);
6283 vos_mem_free(wlanRxpFilterParam);
6284 return -EINVAL;
6285 }
6286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006287 return 0;
6288}
6289
6290static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6291 union iwreq_data *wrqu, char *extra)
6292{
6293 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006294 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 tSirHostOffloadReq offloadRequest;
6296
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006297 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6298 {
6299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6300 "%s:LOGP in Progress. Ignore!!!", __func__);
6301 return -EBUSY;
6302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 /* Debug display of request components. */
6304 switch (pRequest->offloadType)
6305 {
6306 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006307 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 switch (pRequest->enableOrDisable)
6309 {
6310 case WLAN_OFFLOAD_DISABLE:
6311 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6312 break;
6313 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6314 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6315 case WLAN_OFFLOAD_ENABLE:
6316 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6317 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6318 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6319 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6320 }
6321 break;
6322
6323 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006324 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006325 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 switch (pRequest->enableOrDisable)
6327 {
6328 case WLAN_OFFLOAD_DISABLE:
6329 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6330 break;
6331 case WLAN_OFFLOAD_ENABLE:
6332 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6333 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6334 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6335 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6336 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6337 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6338 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6339 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6340 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6341 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6342 }
6343 }
6344
6345 /* Execute offload request. The reason that we can copy the request information
6346 from the ioctl structure to the SME structure is that they are laid out
6347 exactly the same. Otherwise, each piece of information would have to be
6348 copied individually. */
6349 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006350 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6351 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006353 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 __func__);
6355 return -EINVAL;
6356 }
6357
6358 return 0;
6359}
6360
6361static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6362 union iwreq_data *wrqu, char *extra)
6363{
6364 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006365 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 tSirKeepAliveReq keepaliveRequest;
6367
6368 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6369 {
6370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006371 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 return 0;
6373 }
6374
6375 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006376 hddLog(VOS_TRACE_LEVEL_INFO,
6377 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6378 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006379
6380 switch (pRequest->packetType)
6381 {
6382 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006383 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 break;
6385
6386 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6387
Arif Hussain6d2a3322013-11-17 19:50:10 -08006388 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006389 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006390
6391 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6392 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6393 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6394
6395 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6396 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6397 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6398
6399 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6400 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6401 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6402 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6403 break;
6404
6405 }
6406
6407 /* Execute keep alive request. The reason that we can copy the request information
6408 from the ioctl structure to the SME structure is that they are laid out
6409 exactly the same. Otherwise, each piece of information would have to be
6410 copied individually. */
6411 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6412
Arif Hussain6d2a3322013-11-17 19:50:10 -08006413 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006414
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006415 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006416 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006418 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 __func__);
6420 return -EINVAL;
6421 }
6422
6423 return 0;
6424}
6425
6426#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006427int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006428 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006429{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006430 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6431 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 int i=0;
6433
6434 if (pHddCtx->cfg_ini->disablePacketFilter)
6435 {
6436 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006437 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006438 return 0;
6439 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006440 if (pHddCtx->isLogpInProgress)
6441 {
6442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6443 "%s:LOGP in Progress. Ignore!!!", __func__);
6444 return -EBUSY;
6445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 /* Debug display of request components. */
6447 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006448 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006449
6450 switch (pRequest->filterAction)
6451 {
6452 case HDD_RCV_FILTER_SET:
6453 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006454 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006455
6456 packetFilterSetReq.filterId = pRequest->filterId;
6457 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6458 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006459 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 __func__, pRequest->numParams);
6461 return -EINVAL;
6462 }
6463 packetFilterSetReq.numFieldParams = pRequest->numParams;
6464 packetFilterSetReq.coalesceTime = 0;
6465 packetFilterSetReq.filterType = 1;
6466 for (i=0; i < pRequest->numParams; i++)
6467 {
6468 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6469 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6470 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6471 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6472 packetFilterSetReq.paramsData[i].reserved = 0;
6473
Arif Hussain6d2a3322013-11-17 19:50:10 -08006474 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6476 packetFilterSetReq.filterType);
6477
Arif Hussain6d2a3322013-11-17 19:50:10 -08006478 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6480
6481 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6482 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6483 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6484 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6485
Arif Hussain6d2a3322013-11-17 19:50:10 -08006486 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6488 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6489 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6490
Arif Hussain6d2a3322013-11-17 19:50:10 -08006491 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006492 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6493 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6494 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6495 }
6496
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006497 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006499 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 __func__);
6501 return -EINVAL;
6502 }
6503
6504 break;
6505
6506 case HDD_RCV_FILTER_CLEAR:
6507
Arif Hussain6d2a3322013-11-17 19:50:10 -08006508 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006509 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006511 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006513 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 __func__);
6515 return -EINVAL;
6516 }
6517 break;
6518
6519 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006520 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006521 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006522 return -EINVAL;
6523 }
6524 return 0;
6525}
6526
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306527int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6528 tANI_U8 sessionId)
6529{
6530 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6531 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6532
6533 if (NULL == pHddCtx)
6534 {
6535 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6536 return -EINVAL;
6537 }
6538
6539 if (pHddCtx->isLogpInProgress)
6540 {
6541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6542 "%s:LOGP in Progress. Ignore!!!", __func__);
6543 return -EBUSY;
6544 }
6545
6546 if (pHddCtx->cfg_ini->disablePacketFilter)
6547 {
6548 hddLog(VOS_TRACE_LEVEL_ERROR,
6549 "%s: Packet Filtering Disabled. Returning ",
6550 __func__ );
6551 return -EINVAL;
6552 }
6553
6554 switch (filterType)
6555 {
6556 /* For setting IPV6 MC and UC Filter we need to configure
6557 * 2 filters, one for MC and one for UC.
6558 * The Filter ID shouldn't be swapped, which results in making
6559 * UC Filter ineffective.
6560 * We have Hardcode all the values
6561 *
6562 * Reason for a seperate UC filter is because, driver need to
6563 * specify the FW that the specific filter is for unicast
6564 * otherwise FW will not pass the unicast frames by default
6565 * through the filter. This is required to avoid any performance
6566 * hits when no unicast filter is set and only MC/BC are set.
6567 * The way driver informs host is by using the MAC protocol
6568 * layer, CMP flag set to MAX, CMP Data set to 1.
6569 */
6570
6571 case HDD_FILTER_IPV6_MC_UC:
6572 /* Setting IPV6 MC Filter below
6573 */
6574 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6575 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6576 packetFilterSetReq.numFieldParams = 2;
6577 packetFilterSetReq.paramsData[0].protocolLayer =
6578 HDD_FILTER_PROTO_TYPE_MAC;
6579 packetFilterSetReq.paramsData[0].cmpFlag =
6580 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6581 packetFilterSetReq.paramsData[0].dataOffset =
6582 WLAN_HDD_80211_FRM_DA_OFFSET;
6583 packetFilterSetReq.paramsData[0].dataLength = 1;
6584 packetFilterSetReq.paramsData[0].compareData[0] =
6585 HDD_IPV6_MC_CMP_DATA;
6586
6587 packetFilterSetReq.paramsData[1].protocolLayer =
6588 HDD_FILTER_PROTO_TYPE_ARP;
6589 packetFilterSetReq.paramsData[1].cmpFlag =
6590 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6591 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6592 packetFilterSetReq.paramsData[1].dataLength = 2;
6593 packetFilterSetReq.paramsData[1].compareData[0] =
6594 HDD_IPV6_CMP_DATA_0;
6595 packetFilterSetReq.paramsData[1].compareData[1] =
6596 HDD_IPV6_CMP_DATA_1;
6597
6598
6599 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6600 &packetFilterSetReq, sessionId))
6601 {
6602 hddLog(VOS_TRACE_LEVEL_ERROR,
6603 "%s: Failure to execute Set IPv6 Mulicast Filter",
6604 __func__);
6605 return -EINVAL;
6606 }
6607
6608 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6609
6610 /*
6611 * Setting IPV6 UC Filter below
6612 */
6613 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6614 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6615 packetFilterSetReq.numFieldParams = 2;
6616 packetFilterSetReq.paramsData[0].protocolLayer =
6617 HDD_FILTER_PROTO_TYPE_MAC;
6618 packetFilterSetReq.paramsData[0].cmpFlag =
6619 HDD_FILTER_CMP_TYPE_MAX;
6620 packetFilterSetReq.paramsData[0].dataOffset = 0;
6621 packetFilterSetReq.paramsData[0].dataLength = 1;
6622 packetFilterSetReq.paramsData[0].compareData[0] =
6623 HDD_IPV6_UC_CMP_DATA;
6624
6625 packetFilterSetReq.paramsData[1].protocolLayer =
6626 HDD_FILTER_PROTO_TYPE_ARP;
6627 packetFilterSetReq.paramsData[1].cmpFlag =
6628 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6629 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6630 packetFilterSetReq.paramsData[1].dataLength = 2;
6631 packetFilterSetReq.paramsData[1].compareData[0] =
6632 HDD_IPV6_CMP_DATA_0;
6633 packetFilterSetReq.paramsData[1].compareData[1] =
6634 HDD_IPV6_CMP_DATA_1;
6635
6636 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6637 &packetFilterSetReq, sessionId))
6638 {
6639 hddLog(VOS_TRACE_LEVEL_ERROR,
6640 "%s: Failure to execute Set IPv6 Unicast Filter",
6641 __func__);
6642 return -EINVAL;
6643 }
6644
6645 break;
6646
6647 case HDD_FILTER_IPV6_MC:
6648 /*
6649 * IPV6 UC Filter might be already set,
6650 * clear the UC Filter. As the Filter
6651 * IDs are static, we can directly clear it.
6652 */
6653 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6654 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6655 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6656 &packetFilterClrReq, sessionId))
6657 {
6658 hddLog(VOS_TRACE_LEVEL_ERROR,
6659 "%s: Failure to execute Clear IPv6 Unicast Filter",
6660 __func__);
6661 return -EINVAL;
6662 }
6663
6664 /*
6665 * Setting IPV6 MC Filter below
6666 */
6667 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6668 packetFilterSetReq.numFieldParams = 2;
6669 packetFilterSetReq.paramsData[0].protocolLayer =
6670 HDD_FILTER_PROTO_TYPE_MAC;
6671 packetFilterSetReq.paramsData[0].cmpFlag =
6672 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6673 packetFilterSetReq.paramsData[0].dataOffset =
6674 WLAN_HDD_80211_FRM_DA_OFFSET;
6675 packetFilterSetReq.paramsData[0].dataLength = 1;
6676 packetFilterSetReq.paramsData[0].compareData[0] =
6677 HDD_IPV6_MC_CMP_DATA;
6678
6679 packetFilterSetReq.paramsData[1].protocolLayer =
6680 HDD_FILTER_PROTO_TYPE_ARP;
6681 packetFilterSetReq.paramsData[1].cmpFlag =
6682 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6683 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6684 packetFilterSetReq.paramsData[1].dataLength = 2;
6685 packetFilterSetReq.paramsData[1].compareData[0] =
6686 HDD_IPV6_CMP_DATA_0;
6687 packetFilterSetReq.paramsData[1].compareData[1] =
6688 HDD_IPV6_CMP_DATA_1;
6689
6690
6691 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6692 &packetFilterSetReq, sessionId))
6693 {
6694 hddLog(VOS_TRACE_LEVEL_ERROR,
6695 "%s: Failure to execute Set IPv6 Multicast Filter",
6696 __func__);
6697 return -EINVAL;
6698 }
6699 break;
6700
6701 default :
6702 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6703 "%s: Packet Filter Request: Invalid",
6704 __func__);
6705 return -EINVAL;
6706 }
6707 return 0;
6708}
6709
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306710void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006711{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306712 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306713 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006714 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306715 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006716
Yue Ma3ede6052013-08-29 00:33:26 -07006717 if (NULL == pHddCtx)
6718 {
6719 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6720 return;
6721 }
6722
6723 hHal = pHddCtx->hHal;
6724
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306725 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306727 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6728 return;
6729 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306730
6731 /* Check if INI is enabled or not, other wise just return
6732 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306733 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306734 {
6735 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6736 if (NULL == pMulticastAddrs)
6737 {
6738 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6739 return;
6740 }
6741
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 if (set)
6743 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306744 /* Following pre-conditions should be satisfied before wei
6745 * configure the MC address list.
6746 */
6747 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6748 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6749 && pAdapter->mc_addr_list.mc_cnt
6750 && (eConnectionState_Associated ==
6751 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6752 {
6753 pMulticastAddrs->ulMulticastAddrCnt =
6754 pAdapter->mc_addr_list.mc_cnt;
6755 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6756 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006757 memcpy(pMulticastAddrs->multicastAddr[i],
6758 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306759 sizeof(pAdapter->mc_addr_list.addr[i]));
6760 hddLog(VOS_TRACE_LEVEL_INFO,
6761 "%s: %s multicast filter: addr ="
6762 MAC_ADDRESS_STR,
6763 __func__, set ? "setting" : "clearing",
6764 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6765 }
6766 /* Set multicast filter */
6767 sme_8023MulticastList(hHal, pAdapter->sessionId,
6768 pMulticastAddrs);
6769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306771 else
6772 {
6773 /* Need to clear only if it was previously configured
6774 */
6775 if (pAdapter->mc_addr_list.isFilterApplied)
6776 {
6777 pMulticastAddrs->ulMulticastAddrCnt = 0;
6778 sme_8023MulticastList(hHal, pAdapter->sessionId,
6779 pMulticastAddrs);
6780 }
6781
6782 }
6783 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006784 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306786 else
6787 {
6788 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306789 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306790 }
6791 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006792}
6793
6794static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6795 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306796{
Jeff Johnson295189b2012-06-20 16:38:30 -07006797 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006798 tpPacketFilterCfg pRequest = NULL;
6799 int ret;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306800 struct iw_point s_priv_data;
6801
6802 if (hdd_priv_get_data(&s_priv_data, wrqu))
6803 {
6804 return -EINVAL;
6805 }
6806
6807 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6808 {
6809 return -EINVAL;
6810 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006811
Arif Hussain0273cba2014-01-07 20:58:29 -08006812 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306813 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6814 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006815 if (NULL == pRequest)
6816 {
6817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6818 "mem_alloc_copy_from_user_helper fail");
6819 return -ENOMEM;
6820 }
6821
6822 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6823 kfree(pRequest);
6824
6825 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006826}
6827#endif
6828static int iw_get_statistics(struct net_device *dev,
6829 struct iw_request_info *info,
6830 union iwreq_data *wrqu, char *extra)
6831{
6832
6833 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6834 eHalStatus status = eHAL_STATUS_SUCCESS;
6835 hdd_wext_state_t *pWextState;
6836 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6837 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6838 char *p = extra;
6839 int tlen = 0;
6840 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6841
6842 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6843 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6844
6845 ENTER();
6846
6847 if (pHddCtx->isLogpInProgress) {
6848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6849 return -EINVAL;
6850 }
6851
6852 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6853
6854 wrqu->txpower.value = 0;
6855 }
6856 else {
6857 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6858 SME_SUMMARY_STATS |
6859 SME_GLOBAL_CLASSA_STATS |
6860 SME_GLOBAL_CLASSB_STATS |
6861 SME_GLOBAL_CLASSC_STATS |
6862 SME_GLOBAL_CLASSD_STATS |
6863 SME_PER_STA_STATS,
6864 hdd_StatisticsCB, 0, FALSE,
6865 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6866
6867 if (eHAL_STATUS_SUCCESS != status)
6868 {
6869 hddLog(VOS_TRACE_LEVEL_ERROR,
6870 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006871 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 return -EINVAL;
6873 }
6874
6875 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6876
6877 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6878 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6879 {
6880 hddLog(VOS_TRACE_LEVEL_ERROR,
6881 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006882 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 /*Remove the SME statistics list by passing NULL in callback argument*/
6884 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6885 SME_SUMMARY_STATS |
6886 SME_GLOBAL_CLASSA_STATS |
6887 SME_GLOBAL_CLASSB_STATS |
6888 SME_GLOBAL_CLASSC_STATS |
6889 SME_GLOBAL_CLASSD_STATS |
6890 SME_PER_STA_STATS,
6891 NULL, 0, FALSE,
6892 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6893
6894 return -EINVAL;
6895 }
6896 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6897 (tANI_U8) sizeof (pStats->retry_cnt),
6898 (char*) &(pStats->retry_cnt[0]),
6899 tlen);
6900
6901 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6902 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6903 (char*) &(pStats->multiple_retry_cnt[0]),
6904 tlen);
6905
6906 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6907 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6908 (char*) &(pStats->tx_frm_cnt[0]),
6909 tlen);
6910
6911 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6912 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6913 (char*) &(pStats->rx_frm_cnt),
6914 tlen);
6915
6916 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6917 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6918 (char*) &(pStats->frm_dup_cnt),
6919 tlen);
6920
6921 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6922 (tANI_U8) sizeof (pStats->fail_cnt),
6923 (char*) &(pStats->fail_cnt[0]),
6924 tlen);
6925
6926 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6927 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6928 (char*) &(pStats->rts_fail_cnt),
6929 tlen);
6930
6931 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6932 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6933 (char*) &(pStats->ack_fail_cnt),
6934 tlen);
6935
6936 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6937 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6938 (char*) &(pStats->rts_succ_cnt),
6939 tlen);
6940
6941 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6942 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6943 (char*) &(pStats->rx_discard_cnt),
6944 tlen);
6945
6946 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6947 (tANI_U8) sizeof (pStats->rx_error_cnt),
6948 (char*) &(pStats->rx_error_cnt),
6949 tlen);
6950
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006951 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006952 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006953 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 tlen);
6955
6956 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6957 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6958 (char*) &(dStats->rx_byte_cnt),
6959 tlen);
6960
6961 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6962 (tANI_U8) sizeof (dStats->rx_rate),
6963 (char*) &(dStats->rx_rate),
6964 tlen);
6965
6966 /* Transmit rate, in units of 500 kbit/sec */
6967 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6968 (tANI_U8) sizeof (aStats->tx_rate),
6969 (char*) &(aStats->tx_rate),
6970 tlen);
6971
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006972 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6973 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6974 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006975 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006976 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6977 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6978 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006979 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006980 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6981 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6982 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006983 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006984 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6985 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6986 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006987 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006988 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6989 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6990 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006991 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006992 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6993 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6994 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006995 tlen);
6996
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 wrqu->data.length = tlen;
6998
6999 }
7000
7001 EXIT();
7002
7003 return 0;
7004}
7005
7006
7007#ifdef FEATURE_WLAN_SCAN_PNO
7008
7009/*Max Len for PNO notification*/
7010#define MAX_PNO_NOTIFY_LEN 100
7011void found_pref_network_cb (void *callbackContext,
7012 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7013{
7014 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7015 union iwreq_data wrqu;
7016 char buf[MAX_PNO_NOTIFY_LEN+1];
7017
7018 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
7019 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
7020
7021 // create the event
7022 memset(&wrqu, 0, sizeof(wrqu));
7023 memset(buf, 0, sizeof(buf));
7024
7025 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
7026 pPrefNetworkFoundInd->ssId.ssId,
7027 (unsigned int)pPrefNetworkFoundInd->rssi);
7028
7029 wrqu.data.pointer = buf;
7030 wrqu.data.length = strlen(buf);
7031
7032 // send the event
7033
7034 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
7035
7036}
7037
7038
7039/*string based input*/
7040VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
7041 union iwreq_data *wrqu, char *extra, int nOffset)
7042{
7043 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05307044 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07007045 /* pnoRequest is a large struct, so we make it static to avoid stack
7046 overflow. This API is only invoked via ioctl, so it is
7047 serialized by the kernel rtnl_lock and hence does not need to be
7048 reentrant */
7049 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07007050 char *ptr;
7051 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05307052 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7054
7055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7056 "PNO data len %d data %s",
7057 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007058 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007059
7060 if (wrqu->data.length <= nOffset )
7061 {
7062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
7063 return VOS_STATUS_E_FAILURE;
7064 }
7065
7066 pnoRequest.enable = 0;
7067 pnoRequest.ucNetworksCount = 0;
7068 /*-----------------------------------------------------------------------
7069 Input is string based and expected to be like this:
7070
7071 <enabled> <netw_count>
7072 for each network:
7073 <ssid_len> <ssid> <authentication> <encryption>
7074 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
7075 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
7076
7077 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07007078 1 2 4 test 0 0 3 1 6 11 2 40 5 test2 4 4 6 1 2 3 4 5 6 1 0 2 5 2 300 0
Jeff Johnson295189b2012-06-20 16:38:30 -07007079
7080 this translates into:
7081 -----------------------------
7082 enable PNO
7083 look for 2 networks:
7084 test - with authentication type 0 and encryption type 0,
7085 that can be found on 3 channels: 1 6 and 11 ,
7086 SSID bcast type is unknown (directed probe will be sent if AP not found)
7087 and must meet -40dBm RSSI
7088
7089 test2 - with auth and enrytption type 4/4
7090 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
7091 bcast type is non-bcast (directed probe will be sent)
7092 and must not meet any RSSI threshold
7093
Jeff Johnson8301aa12013-03-28 14:27:29 -07007094 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08007096 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007097
Wilson Yang623f6592013-10-08 16:33:37 -07007098 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
7099 {
7100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7101 "PNO enable input is not valid %s",ptr);
7102 return VOS_STATUS_E_FAILURE;
7103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007104
7105 if ( 0 == pnoRequest.enable )
7106 {
7107 /*Disable PNO*/
7108 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05307109 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7110 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007111 pAdapter->sessionId,
7112 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307113 if (eHAL_STATUS_SUCCESS != status)
7114 {
7115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7116 "%s: failed to disable PNO", __func__);
7117 return VOS_STATUS_E_FAILURE;
7118 }
7119 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 return VOS_STATUS_SUCCESS;
7121 }
7122
c_hpothu37f21312014-04-09 21:49:54 +05307123 if (TRUE == pHddCtx->isPnoEnable)
7124 {
7125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7126 FL("already PNO is enabled"));
7127 return -EBUSY;
7128 }
7129 pHddCtx->isPnoEnable = TRUE;
7130
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07007132
7133 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
7134 {
7135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7136 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307137 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007139
7140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7141 "PNO enable %d networks count %d offset %d",
7142 pnoRequest.enable,
7143 pnoRequest.ucNetworksCount,
7144 nOffset);
7145
7146 /* Parameters checking:
7147 ucNetworksCount has to be larger than 0*/
7148 if (( 0 == pnoRequest.ucNetworksCount ) ||
7149 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7150 {
7151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05307152 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 }
7154
7155 ptr += nOffset;
7156
7157 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
7158 {
7159
7160 pnoRequest.aNetworks[i].ssId.length = 0;
7161
Wilson Yang623f6592013-10-08 16:33:37 -07007162 ucParams = sscanf(ptr,"%hhu %n",
7163 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
7164
7165 if (1 != ucParams)
7166 {
7167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7168 "PNO ssid length input is not valid %s",ptr);
7169 return VOS_STATUS_E_FAILURE;
7170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007171
7172 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
7173 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
7174 {
7175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7176 "SSID Len %d is not correct for network %d",
7177 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05307178 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 }
7180
7181 /*Advance to SSID*/
7182 ptr += nOffset;
7183
Jeff Johnson8301aa12013-03-28 14:27:29 -07007184 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08007185 pnoRequest.aNetworks[i].ssId.length);
7186 ptr += pnoRequest.aNetworks[i].ssId.length;
7187
Jeff Johnson02797792013-10-26 19:17:13 -07007188 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08007189 &(pnoRequest.aNetworks[i].authentication),
7190 &(pnoRequest.aNetworks[i].encryption),
7191 &(pnoRequest.aNetworks[i].ucChannelCount),
7192 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007193
Wilson Yang623f6592013-10-08 16:33:37 -07007194 if ( 3 != ucParams )
7195 {
7196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7197 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307198 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007199 }
7200
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007202 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08007203 "auth %d encry %d channel count %d offset %d",
7204 pnoRequest.aNetworks[i].ssId.length,
7205 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
7206 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
7207 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
7208 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
7209 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
7210 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
7211 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
7212 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
7213 pnoRequest.aNetworks[i].authentication,
7214 pnoRequest.aNetworks[i].encryption,
7215 pnoRequest.aNetworks[i].ucChannelCount,
7216 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07007217
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 /*Advance to channel list*/
7219 ptr += nOffset;
7220
Wilson Yang623f6592013-10-08 16:33:37 -07007221 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07007222 {
7223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7224 "Incorrect number of channels");
7225 return VOS_STATUS_E_FAILURE;
7226 }
7227
7228 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
7229 {
7230 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
7231 {
Wilson Yang623f6592013-10-08 16:33:37 -07007232 if (1 != sscanf(ptr,"%hhu %n",
7233 &(pnoRequest.aNetworks[i].aChannels[j]),
7234 &nOffset))
7235 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7236 "PNO network channel input is not valid %s",ptr);
7237 return VOS_STATUS_E_FAILURE;
7238 }
7239 /*Advance to next channel number*/
7240 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 }
7242 }
7243
Jeff Johnson02797792013-10-26 19:17:13 -07007244 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007245 &(pnoRequest.aNetworks[i].bcastNetwType),
7246 &nOffset))
7247 {
7248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7249 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307250 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007252
7253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7254 "PNO bcastNetwType %d offset %d",
7255 pnoRequest.aNetworks[i].bcastNetwType,
7256 nOffset );
7257
7258 /*Advance to rssi Threshold*/
7259 ptr += nOffset;
7260
Wilson Yang623f6592013-10-08 16:33:37 -07007261 if (1 != sscanf(ptr,"%hhu %n",
7262 &(pnoRequest.aNetworks[i].rssiThreshold),
7263 &nOffset))
7264 {
7265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7266 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307267 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007269
7270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7271 "PNO rssi %d offset %d",
7272 pnoRequest.aNetworks[i].rssiThreshold,
7273 nOffset );
7274 /*Advance to next network*/
7275 ptr += nOffset;
7276 }/*For ucNetworkCount*/
7277
7278 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007279 &(pnoRequest.scanTimers.ucScanTimersCount),
7280 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007281
7282 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007283 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 {
7285 ptr += nOffset;
7286
Jeff Johnson8301aa12013-03-28 14:27:29 -07007287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7288 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 pnoRequest.scanTimers.ucScanTimersCount,
7290 nOffset );
7291
7292 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7293 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007295 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05307296 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007297 }
7298
7299 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7300 {
Jeff Johnson02797792013-10-26 19:17:13 -07007301 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7303 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7304 &nOffset);
7305
Wilson Yang623f6592013-10-08 16:33:37 -07007306 if (2 != ucParams)
7307 {
7308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7309 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05307310 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007311 }
7312
Jeff Johnson8301aa12013-03-28 14:27:29 -07007313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7314 "PNO Timer value %d Timer repeat %d offset %d",
7315 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007316 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7317 nOffset );
7318
Jeff Johnson295189b2012-06-20 16:38:30 -07007319 ptr += nOffset;
7320 }
7321
7322 }
7323 else
7324 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7326 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007327 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7328
7329 /*Scan timers defaults to 5 minutes*/
7330 pnoRequest.scanTimers.ucScanTimersCount = 1;
7331 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7332 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7333 }
7334
Wilson Yang623f6592013-10-08 16:33:37 -07007335 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007336
7337 pnoRequest.modePNO = ucMode;
7338 /*for LA we just expose suspend option*/
7339 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7340 {
7341 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7342 }
7343
c_hpothu37f21312014-04-09 21:49:54 +05307344 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 pAdapter->sessionId,
7346 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307347 if (eHAL_STATUS_SUCCESS == status)
7348 {
7349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7350 "%s: PNO enabled", __func__);
7351 return VOS_STATUS_SUCCESS;
7352 }
7353error:
7354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7355 "%s: Failed to enable PNO", __func__);
7356 pHddCtx->isPnoEnable = FALSE;
7357 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007358}/*iw_set_pno*/
7359
7360VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7361 union iwreq_data *wrqu, char *extra, int nOffset)
7362{
7363 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7364 v_U8_t rssiThreshold = 0;
7365 v_U8_t nRead;
7366
Arif Hussain7adce1b2013-11-11 22:59:34 -08007367 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 &rssiThreshold);
7369
7370 if ( 1 != nRead )
7371 {
7372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7373 "Incorrect format");
7374 return VOS_STATUS_E_FAILURE;
7375 }
7376
7377 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7378 return VOS_STATUS_SUCCESS;
7379}
7380
7381
7382static int iw_set_pno_priv(struct net_device *dev,
7383 struct iw_request_info *info,
7384 union iwreq_data *wrqu, char *extra)
7385{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007386 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7387
7388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007389 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007390
7391 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7392 {
7393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7394 "%s:LOGP in Progress. Ignore!!!", __func__);
7395 return -EBUSY;
7396 }
7397 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007398}
7399#endif /*FEATURE_WLAN_SCAN_PNO*/
7400
7401//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05307402int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007403{
7404 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7405 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7406 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal54378cb2014-04-02 16:51:50 +05307407 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307409 eCsrBand connectedBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007410
Atul Mittal54378cb2014-04-02 16:51:50 +05307411 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 {
7413 case WLAN_HDD_UI_BAND_AUTO:
7414 band = eCSR_BAND_ALL;
7415 break;
7416 case WLAN_HDD_UI_BAND_5_GHZ:
7417 band = eCSR_BAND_5G;
7418 break;
7419 case WLAN_HDD_UI_BAND_2_4_GHZ:
7420 band = eCSR_BAND_24;
7421 break;
7422 default:
7423 band = eCSR_BAND_MAX;
7424 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307425 connectedBand =
7426 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07007427
Atul Mittal54378cb2014-04-02 16:51:50 +05307428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007429 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007430
7431 if (band == eCSR_BAND_MAX)
7432 {
7433 /* Received change band request with invalid band value */
7434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05307435 "%s: Invalid band value %u", __func__, ui_band);
7436 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 }
7438
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307439 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7440 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7441 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7442 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007444 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007445 band, pHddCtx->cfg_ini->nBandCapability);
7446 return -EIO;
7447 }
7448
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7450 {
7451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7452 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007453 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007454 return -EIO;
7455 }
7456
7457 if (currBand != band)
7458 {
7459 /* Change band request received.
7460 * Abort pending scan requests, flush the existing scan results,
7461 * and change the band capability
7462 */
7463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7464 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007465 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007466
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307467 /* We need to change the band and flush the scan results here itself
7468 * as we may get timeout for disconnection in which we will return
7469 * with out doing any of these
7470 */
7471 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7472 {
7473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7474 "%s: failed to set the band value to %u ",
7475 __func__, band);
7476 return -EINVAL;
7477 }
7478 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7479 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7480 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7481 sme_FilterScanResults(hHal, pAdapter->sessionId);
7482
7483 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307484 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
7485 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 {
7487 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7488 eHalStatus status = eHAL_STATUS_SUCCESS;
7489 long lrc;
7490
7491 /* STA already connected on current band, So issue disconnect first,
7492 * then change the band*/
7493
7494 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05307495 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
7496 " Set HDD connState to eConnectionState_NotConnected",
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 __func__, csrGetCurrentBand(hHal), band);
7498
7499 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7500 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7501
7502 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7503 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7504
Jeff Johnson43971f52012-07-17 12:26:56 -07007505 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007506 {
7507 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007508 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 __func__, (int)status );
7510 return -EINVAL;
7511 }
7512
7513 lrc = wait_for_completion_interruptible_timeout(
7514 &pAdapter->disconnect_comp_var,
7515 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7516
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307517 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007518
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007519 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007520 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007521
7522 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7523 }
7524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007525 }
7526 return 0;
7527}
7528
Atul Mittal54378cb2014-04-02 16:51:50 +05307529int hdd_setBand_helper(struct net_device *dev, const char *command)
7530{
7531 u8 band;
7532
7533 /*convert the band value from ascii to integer*/
7534 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
7535
7536 return hdd_setBand(dev, band);
7537
7538}
7539
Jeff Johnson295189b2012-06-20 16:38:30 -07007540static int iw_set_band_config(struct net_device *dev,
7541 struct iw_request_info *info,
7542 union iwreq_data *wrqu, char *extra)
7543{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007544 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05307545 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007546
Arif Hussain0273cba2014-01-07 20:58:29 -08007547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007548
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007549 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7550 {
7551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7552 "%s:LOGP in Progress. Ignore!!!", __func__);
7553 return -EBUSY;
7554 }
7555
Atul Mittal54378cb2014-04-02 16:51:50 +05307556 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007557}
7558
7559static int iw_set_power_params_priv(struct net_device *dev,
7560 struct iw_request_info *info,
7561 union iwreq_data *wrqu, char *extra)
7562{
Arif Hussain0273cba2014-01-07 20:58:29 -08007563 int ret;
7564 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7566 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007567 /* ODD number is used for set, copy data using copy_from_user */
7568 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7569 wrqu->data.length);
7570 if (NULL == ptr)
7571 {
7572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7573 "mem_alloc_copy_from_user_helper fail");
7574 return -ENOMEM;
7575 }
7576
7577 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7578 kfree(ptr);
7579 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007580}
7581
7582
7583
7584/*string based input*/
7585VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7586 union iwreq_data *wrqu, char *extra, int nOffset)
7587{
7588 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7589 tSirSetPowerParamsReq powerRequest;
7590 char *ptr;
7591 v_U8_t ucType;
7592 v_U32_t uTotalSize, uValue;
7593 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7594
7595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7596 "Power Params data len %d data %s",
7597 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007598 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007599
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007600 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7601 {
7602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7603 "%s:LOGP in Progress. Ignore!!!", __func__);
7604 return -EBUSY;
7605 }
7606
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 if (wrqu->data.length <= nOffset )
7608 {
7609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7610 return VOS_STATUS_E_FAILURE;
7611 }
7612
7613 uTotalSize = wrqu->data.length - nOffset;
7614
7615 /*-----------------------------------------------------------------------
7616 Input is string based and expected to be like this:
7617
7618 <param_type> <param_value> <param_type> <param_value> ...
7619
7620 e.g:
7621 1 2 2 3 3 0 4 1 5 1
7622
7623 e.g. setting just a few:
7624 1 2 4 1
7625
7626 parameter types:
7627 -----------------------------
7628 1 - Ignore DTIM
7629 2 - Listen Interval
7630 3 - Broadcast Multicas Filter
7631 4 - Beacon Early Termination
7632 5 - Beacon Early Termination Interval
7633 -----------------------------------------------------------------------*/
7634 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7635 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7636 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7637 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7638 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7639
Arif Hussain7adce1b2013-11-11 22:59:34 -08007640 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007641
7642 while ( uTotalSize )
7643 {
Wilson Yang6f971452013-10-08 15:00:00 -07007644 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7645 {
7646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7647 "Invalid input parameter type %s",ptr);
7648 return VOS_STATUS_E_FAILURE;
7649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007650
7651 uTotalSize -= nOffset;
7652
7653 if (!uTotalSize)
7654 {
7655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007656 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007657 ucType, nOffset);
7658 return VOS_STATUS_E_FAILURE;
7659 }
7660
7661 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007662
Jeff Johnson02797792013-10-26 19:17:13 -07007663 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007664 {
7665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7666 "Invalid input parameter value %s",ptr);
7667 return VOS_STATUS_E_FAILURE;
7668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007669
7670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7671 "Power request parameter %d value %d offset %d",
7672 ucType, uValue, nOffset);
7673
7674 switch (ucType)
7675 {
7676 case eSIR_IGNORE_DTIM:
7677 powerRequest.uIgnoreDTIM = uValue;
7678 break;
7679 case eSIR_LISTEN_INTERVAL:
7680 powerRequest.uListenInterval = uValue;
7681 break;
7682 case eSIR_MCAST_BCAST_FILTER:
7683 powerRequest.uBcastMcastFilter = uValue;
7684 break;
7685 case eSIR_ENABLE_BET:
7686 powerRequest.uEnableBET = uValue;
7687 break;
7688 case eSIR_BET_INTERVAL:
7689 powerRequest.uBETInterval = uValue;
7690 break;
7691 default:
7692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007693 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007694 ucType, uValue, nOffset);
7695 return VOS_STATUS_E_FAILURE;
7696 }
7697
7698 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7700 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007701 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007702 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007703 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007704 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007705 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7706 {
7707 uTotalSize = 0;
7708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007709
7710 }/*Go for as long as we have a valid string*/
7711
7712 /* put the device into full power*/
7713 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7714
7715 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007716 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007717
7718 /* put the device back to power save*/
7719 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7720
7721 return VOS_STATUS_SUCCESS;
7722}/*iw_set_power_params*/
7723
7724
7725// Define the Wireless Extensions to the Linux Network Device structure
7726// A number of these routines are NULL (meaning they are not implemented.)
7727
7728static const iw_handler we_handler[] =
7729{
7730 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7731 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7732 (iw_handler) NULL, /* SIOCSIWNWID */
7733 (iw_handler) NULL, /* SIOCGIWNWID */
7734 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7735 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7736 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7737 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7738 (iw_handler) NULL, /* SIOCSIWSENS */
7739 (iw_handler) NULL, /* SIOCGIWSENS */
7740 (iw_handler) NULL, /* SIOCSIWRANGE */
7741 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7742 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7743 (iw_handler) NULL, /* SIOCGIWPRIV */
7744 (iw_handler) NULL, /* SIOCSIWSTATS */
7745 (iw_handler) NULL, /* SIOCGIWSTATS */
7746 iw_handler_set_spy, /* SIOCSIWSPY */
7747 iw_handler_get_spy, /* SIOCGIWSPY */
7748 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7749 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7750 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7751 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7752 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7753 (iw_handler) NULL, /* SIOCGIWAPLIST */
7754 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7755 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7756 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7757 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7758 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7759 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7760 (iw_handler) NULL, /* -- hole -- */
7761 (iw_handler) NULL, /* -- hole -- */
7762 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7763 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7764 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7765 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7766 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7767 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7768 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7769 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7770 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7771 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7772 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7773 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7774 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7775 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7776 (iw_handler) NULL, /* -- hole -- */
7777 (iw_handler) NULL, /* -- hole -- */
7778 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7779 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7780 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7781 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7782 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7783 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7784 (iw_handler) NULL, /* SIOCSIWPMKSA */
7785};
7786
7787static const iw_handler we_private[] = {
7788
7789 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7790 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7791 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7792 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7793 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7794 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7795 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7796 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7797 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7798 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007799#ifdef FEATURE_OEM_DATA_SUPPORT
7800 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7801 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7802#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007803
7804#ifdef FEATURE_WLAN_WAPI
7805 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7806 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7807 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7808 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7809 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7810 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7811#endif /* FEATURE_WLAN_WAPI */
7812#ifdef WLAN_FEATURE_VOWIFI_11R
7813 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7814#endif
7815 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7816 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7817 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7818#ifdef WLAN_FEATURE_PACKET_FILTERING
7819 ,
7820 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7821#endif
7822#ifdef FEATURE_WLAN_SCAN_PNO
7823 ,
7824 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7825#endif
7826 ,
7827 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7828 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7829 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7830 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07007831 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07007832};
7833
7834/*Maximum command length can be only 15 */
7835static const struct iw_priv_args we_private_args[] = {
7836
7837 /* handlers for main ioctl */
7838 { WLAN_PRIV_SET_INT_GET_NONE,
7839 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7840 0,
7841 "" },
7842
7843 /* handlers for sub-ioctl */
7844 { WE_SET_11D_STATE,
7845 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7846 0,
7847 "set11Dstate" },
7848
7849 { WE_WOWL,
7850 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7851 0,
7852 "wowl" },
7853
7854 { WE_SET_POWER,
7855 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7856 0,
7857 "setPower" },
7858
7859 { WE_SET_MAX_ASSOC,
7860 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7861 0,
7862 "setMaxAssoc" },
7863
7864 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7865 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7866 0,
7867 "setAutoChannel" },
7868
7869 { WE_SET_DATA_INACTIVITY_TO,
7870 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7871 0,
7872 "inactivityTO" },
7873
7874 { WE_SET_MAX_TX_POWER,
7875 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7876 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007877 "setMaxTxPower" },
7878
7879 { WE_SET_MAX_TX_POWER_2_4,
7880 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7881 0,
7882 "setTxMaxPower2G" },
7883
7884 { WE_SET_MAX_TX_POWER_5_0,
7885 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7886 0,
7887 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007888
7889 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7890 * as well to keep same syntax as in SAP. Now onwards, STA
7891 * will support both */
7892 { WE_SET_MAX_TX_POWER,
7893 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7894 0,
7895 "setTxMaxPower" },
7896
Jeff Johnson295189b2012-06-20 16:38:30 -07007897 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7898 * 1 = enable and 0 = disable */
7899 {
7900 WE_SET_HIGHER_DTIM_TRANSITION,
7901 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7902 0,
7903 "setHDtimTransn" },
7904
7905 { WE_SET_TM_LEVEL,
7906 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007907 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 "setTmLevel" },
7909
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307910 { WE_ENABLE_STRICT_FCC_REG,
7911 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7912 0,
7913 "setStrictFCCreg" },
7914
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007915 { WE_SET_DEBUG_LOG,
7916 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7917 0, "setDbgLvl" },
7918
Jeff Johnson295189b2012-06-20 16:38:30 -07007919 /* handlers for main ioctl */
7920 { WLAN_PRIV_SET_NONE_GET_INT,
7921 0,
7922 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7923 "" },
7924
7925 /* handlers for sub-ioctl */
7926 { WE_GET_11D_STATE,
7927 0,
7928 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7929 "get11Dstate" },
7930
7931 { WE_IBSS_STATUS,
7932 0,
7933 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7934 "getAdhocStatus" },
7935
7936 { WE_PMC_STATE,
7937 0,
7938 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7939 "pmcState" },
7940
7941 { WE_GET_WLAN_DBG,
7942 0,
7943 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7944 "getwlandbg" },
7945
7946 { WE_MODULE_DOWN_IND,
7947 0,
7948 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7949 "moduleDownInd" },
7950
7951 { WE_GET_MAX_ASSOC,
7952 0,
7953 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7954 "getMaxAssoc" },
7955
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 { WE_GET_WDI_DBG,
7957 0,
7958 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7959 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007960
7961 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7962 0,
7963 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7964 "getAutoChannel" },
7965
7966 { WE_GET_CONCURRENCY_MODE,
7967 0,
7968 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7969 "getconcurrency" },
7970
7971 /* handlers for main ioctl */
7972 { WLAN_PRIV_SET_CHAR_GET_NONE,
7973 IW_PRIV_TYPE_CHAR| 512,
7974 0,
7975 "" },
7976
7977 /* handlers for sub-ioctl */
7978 { WE_WOWL_ADD_PTRN,
7979 IW_PRIV_TYPE_CHAR| 512,
7980 0,
7981 "wowlAddPtrn" },
7982
7983 { WE_WOWL_DEL_PTRN,
7984 IW_PRIV_TYPE_CHAR| 512,
7985 0,
7986 "wowlDelPtrn" },
7987
7988#if defined WLAN_FEATURE_VOWIFI
7989 /* handlers for sub-ioctl */
7990 { WE_NEIGHBOR_REPORT_REQUEST,
7991 IW_PRIV_TYPE_CHAR | 512,
7992 0,
7993 "neighbor" },
7994#endif
7995 { WE_SET_AP_WPS_IE,
7996 IW_PRIV_TYPE_CHAR| 512,
7997 0,
7998 "set_ap_wps_ie" },
7999
8000 { WE_SET_CONFIG,
8001 IW_PRIV_TYPE_CHAR| 512,
8002 0,
8003 "setConfig" },
8004
8005 /* handlers for main ioctl */
8006 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
8007 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8008 0,
8009 "" },
8010
8011 /* handlers for sub-ioctl */
8012 { WE_SET_WLAN_DBG,
8013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8014 0,
8015 "setwlandbg" },
8016
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 { WE_SET_WDI_DBG,
8018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8019 0,
8020 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008021
8022 { WE_SET_SAP_CHANNELS,
8023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8024 0,
8025 "setsapchannels" },
8026
8027 /* handlers for main ioctl */
8028 { WLAN_PRIV_GET_CHAR_SET_NONE,
8029 0,
8030 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8031 "" },
8032
8033 /* handlers for sub-ioctl */
8034 { WE_WLAN_VERSION,
8035 0,
8036 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8037 "version" },
8038 { WE_GET_STATS,
8039 0,
8040 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8041 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308042 { WE_GET_STATES,
8043 0,
8044 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8045 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008046 { WE_GET_CFG,
8047 0,
8048 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8049 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07008050#ifdef WLAN_FEATURE_11AC
8051 { WE_GET_RSSI,
8052 0,
8053 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8054 "getRSSI" },
8055#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008056#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008057 { WE_GET_ROAM_RSSI,
8058 0,
8059 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8060 "getRoamRSSI" },
8061#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008062 { WE_GET_WMM_STATUS,
8063 0,
8064 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8065 "getWmmStatus" },
8066 {
8067 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308068 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8070 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08008071#ifdef FEATURE_WLAN_TDLS
8072 {
8073 WE_GET_TDLS_PEERS,
8074 0,
8075 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8076 "getTdlsPeers" },
8077#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008078#ifdef WLAN_FEATURE_11W
8079 {
8080 WE_GET_11W_INFO,
8081 0,
8082 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8083 "getPMFInfo" },
8084#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 /* handlers for main ioctl */
8086 { WLAN_PRIV_SET_NONE_GET_NONE,
8087 0,
8088 0,
8089 "" },
8090
8091 /* handlers for sub-ioctl */
8092 { WE_CLEAR_STATS,
8093 0,
8094 0,
8095 "clearStats" },
8096 { WE_INIT_AP,
8097 0,
8098 0,
8099 "initAP" },
8100 { WE_STOP_AP,
8101 0,
8102 0,
8103 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308104#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -07008105 { WE_ENABLE_AMP,
8106 0,
8107 0,
8108 "enableAMP" },
8109 { WE_DISABLE_AMP,
8110 0,
8111 0,
8112 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308113#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07008114 { WE_ENABLE_DXE_STALL_DETECT,
8115 0,
8116 0,
8117 "dxeStallDetect" },
8118 { WE_DISPLAY_DXE_SNAP_SHOT,
8119 0,
8120 0,
8121 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308122 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
8123 0,
8124 0,
8125 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07008126 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05308127 WE_SET_REASSOC_TRIGGER,
8128 0,
8129 0,
8130 "reassoc" },
8131 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05308132 WE_STOP_OBSS_SCAN,
8133 0,
8134 0,
8135 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008136
8137 /* handlers for main ioctl */
8138 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
8139 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8140 0,
8141 "" },
8142
8143 /* handlers for sub-ioctl */
8144 { WE_LOG_DUMP_CMD,
8145 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8146 0,
8147 "dump" },
8148
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008149 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308150 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
8151 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8152 0,
8153 "setdumplog" },
8154
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008155 { WE_MTRACE_DUMP_CMD,
8156 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8157 0,
8158 "dumplog" },
8159
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008160 /* handlers for sub ioctl */
8161 {
8162 WE_MCC_CONFIG_CREDENTIAL,
8163 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8164 0,
8165 "setMccCrdnl" },
8166
8167 /* handlers for sub ioctl */
8168 {
8169 WE_MCC_CONFIG_PARAMS,
8170 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8171 0,
8172 "setMccConfig" },
8173
Chilam NG571c65a2013-01-19 12:27:36 +05308174#ifdef FEATURE_WLAN_TDLS
8175 /* handlers for sub ioctl */
8176 {
8177 WE_TDLS_CONFIG_PARAMS,
8178 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8179 0,
8180 "setTdlsConfig" },
8181#endif
8182
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 /* handlers for main ioctl */
8184 { WLAN_PRIV_ADD_TSPEC,
8185 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
8186 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8187 "addTspec" },
8188
8189 /* handlers for main ioctl */
8190 { WLAN_PRIV_DEL_TSPEC,
8191 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8192 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8193 "delTspec" },
8194
8195 /* handlers for main ioctl */
8196 { WLAN_PRIV_GET_TSPEC,
8197 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8199 "getTspec" },
8200
Jeff Johnsone7245742012-09-05 17:12:55 -07008201#ifdef FEATURE_OEM_DATA_SUPPORT
8202 /* handlers for main ioctl - OEM DATA */
8203 {
8204 WLAN_PRIV_SET_OEM_DATA_REQ,
8205 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
8206 0,
8207 "set_oem_data_req" },
8208
8209 /* handlers for main ioctl - OEM DATA */
8210 {
8211 WLAN_PRIV_GET_OEM_DATA_RSP,
8212 0,
8213 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8214 "get_oem_data_rsp" },
8215#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008216
8217#ifdef FEATURE_WLAN_WAPI
8218 /* handlers for main ioctl SET_WAPI_MODE */
8219 { WLAN_PRIV_SET_WAPI_MODE,
8220 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8221 0,
8222 "SET_WAPI_MODE" },
8223
8224 /* handlers for main ioctl GET_WAPI_MODE */
8225 { WLAN_PRIV_GET_WAPI_MODE,
8226 0,
8227 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8228 "GET_WAPI_MODE" },
8229
8230 /* handlers for main ioctl SET_ASSOC_INFO */
8231 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
8232 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
8233 0,
8234 "SET_WAPI_ASSOC" },
8235
8236 /* handlers for main ioctl SET_WAPI_KEY */
8237 { WLAN_PRIV_SET_WAPI_KEY,
8238 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
8239 0,
8240 "SET_WAPI_KEY" },
8241
8242 /* handlers for main ioctl SET_WAPI_BKID */
8243 { WLAN_PRIV_SET_WAPI_BKID,
8244 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8245 0,
8246 "SET_WAPI_BKID" },
8247
8248 /* handlers for main ioctl GET_WAPI_BKID */
8249 { WLAN_PRIV_GET_WAPI_BKID,
8250 0,
8251 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8252 "GET_WAPI_BKID" },
8253#endif /* FEATURE_WLAN_WAPI */
8254
8255 /* handlers for main ioctl - host offload */
8256 {
8257 WLAN_PRIV_SET_HOST_OFFLOAD,
8258 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8259 0,
8260 "setHostOffload" },
8261
8262 {
8263 WLAN_GET_WLAN_STATISTICS,
8264 0,
8265 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8266 "getWlanStats" },
8267
8268 {
8269 WLAN_SET_KEEPALIVE_PARAMS,
8270 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8271 0,
8272 "setKeepAlive" },
8273#ifdef WLAN_FEATURE_PACKET_FILTERING
8274 {
8275 WLAN_SET_PACKET_FILTER_PARAMS,
8276 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8277 0,
8278 "setPktFilter" },
8279#endif
8280#ifdef FEATURE_WLAN_SCAN_PNO
8281 {
8282 WLAN_SET_PNO,
8283 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8284 0,
8285 "setpno" },
8286#endif
8287 {
8288 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05308289 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 0,
8291 "SETBAND" },
8292 /* handlers for dynamic MC BC ioctl */
8293 {
8294 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008295 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 0,
8297 "setMCBCFilter" },
8298 {
8299 WLAN_PRIV_CLEAR_MCBC_FILTER,
8300 0,
8301 0,
8302 "clearMCBCFilter" },
8303 {
8304 WLAN_SET_POWER_PARAMS,
8305 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8306 0,
8307 "setpowerparams" },
8308 {
8309 WLAN_GET_LINK_SPEED,
8310 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308311 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008312};
8313
8314
8315
8316const struct iw_handler_def we_handler_def = {
8317 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8318 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8319 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8320
8321 .standard = (iw_handler *)we_handler,
8322 .private = (iw_handler *)we_private,
8323 .private_args = we_private_args,
8324 .get_wireless_stats = get_wireless_stats,
8325};
8326
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008327int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8328{
8329 v_U32_t cmd = 288; //Command to RIVA
8330 hdd_context_t *pHddCtx = NULL;
8331 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8332 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8333 /*
8334 *configMccParam : specify the bit which needs to be modified
8335 *allowed to update based on wlan_qcom_cfg.ini
8336 * configuration
8337 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8338 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8339 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8340 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8341 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8342 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8343 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8344 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8345 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8346 * Bit 9 : Reserved
8347 */
8348 switch (arg1)
8349 {
8350 //Update MCC SCHEDULE_TIME_SLICE parameter
8351 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8352 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8353 {
8354 if((arg2 >= 5) && (arg2 <= 20))
8355 {
8356 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8357 }
8358 else
8359 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008360 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008361 return 0;
8362 }
8363 }
8364 break;
8365
8366 //Update MCC MAX_NULL_SEND_TIME parameter
8367 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8368 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8369 {
8370 if((arg2 >= 1) && (arg2 <= 10))
8371 {
8372 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8373 }
8374 else
8375 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008376 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008377 return 0;
8378 }
8379 }
8380 break;
8381
8382 //Update MCC TX_EARLY_STOP_TIME parameter
8383 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8384 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8385 {
8386 if((arg2 >= 1) && (arg2 <= 10))
8387 {
8388 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8389 }
8390 else
8391 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008392 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008393 return 0;
8394 }
8395 }
8396 break;
8397
8398 //Update MCC RX_DRAIN_TIME parameter
8399 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8400 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8401 {
8402 if((arg2 >= 1) && (arg2 <= 10))
8403 {
8404 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8405 }
8406 else
8407 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008408 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008409 return 0;
8410 }
8411 }
8412 break;
8413
8414 //Update MCC CHANNEL_SWITCH_TIME parameter
8415 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8416 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8417 {
8418 if((arg2 >= 1) && (arg2 <= 20))
8419 {
8420 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8421 }
8422 else
8423 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008424 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008425 return 0;
8426 }
8427 }
8428 break;
8429
8430 //Update MCC MIN_CHANNEL_TIME parameter
8431 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8432 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8433 {
8434 if((arg2 >= 5) && (arg2 <= 20))
8435 {
8436 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8437 }
8438 else
8439 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008440 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008441 return 0;
8442 }
8443 }
8444 break;
8445
8446 //Update MCC PARK_BEFORE_TBTT parameter
8447 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8448 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8449 {
8450 if((arg2 >= 1) && (arg2 <= 5))
8451 {
8452 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8453 }
8454 else
8455 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008456 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008457 return 0;
8458 }
8459 }
8460 break;
8461
8462 //Update MCC MIN_AFTER_DTIM parameter
8463 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8464 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8465 {
8466 if((arg2 >= 5) && (arg2 <= 15))
8467 {
8468 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8469 }
8470 else
8471 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008472 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008473 return 0;
8474 }
8475 }
8476 break;
8477
8478 //Update MCC TOO_CLOSE_MARGIN parameter
8479 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8480 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8481 {
8482 if((arg2 >= 1) && (arg2 <= 3))
8483 {
8484 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8485 }
8486 else
8487 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008488 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008489 return 0;
8490 }
8491 }
8492 break;
8493
8494 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008495 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008496 __FUNCTION__,arg1);
8497 break;
8498 }
8499 return 0;
8500}
8501
Jeff Johnson295189b2012-06-20 16:38:30 -07008502int hdd_set_wext(hdd_adapter_t *pAdapter)
8503{
8504 hdd_wext_state_t *pwextBuf;
8505 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008506 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008507
8508 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8509
8510 // Now configure the roaming profile links. To SSID and bssid.
8511 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8512 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8513
8514 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8515 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8516
8517 /*Set the numOfChannels to zero to scan all the channels*/
8518 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8519 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8520
8521 /* Default is no encryption */
8522 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8523 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8524
8525 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8526 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8527
8528 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8529
8530 /* Default is no authentication */
8531 pwextBuf->roamProfile.AuthType.numEntries = 1;
8532 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8533
8534 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8535 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8536
8537 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008538 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008539
8540 hdd_clearRoamProfileIe(pAdapter);
8541
8542 return VOS_STATUS_SUCCESS;
8543
8544 }
8545
8546int hdd_register_wext(struct net_device *dev)
8547 {
8548 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8549 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8550 VOS_STATUS status;
8551
8552 ENTER();
8553
8554 // Zero the memory. This zeros the profile structure.
8555 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8556
8557 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8558
8559
8560 status = hdd_set_wext(pAdapter);
8561
8562 if(!VOS_IS_STATUS_SUCCESS(status)) {
8563
Arif Hussain6d2a3322013-11-17 19:50:10 -08008564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 return eHAL_STATUS_FAILURE;
8566 }
8567
8568 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8569 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008571 return eHAL_STATUS_FAILURE;
8572 }
8573
8574 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8575 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 return eHAL_STATUS_FAILURE;
8578 }
8579
8580 // Register as a wireless device
8581 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8582
8583 EXIT();
8584 return 0;
8585}
8586
8587int hdd_UnregisterWext(struct net_device *dev)
8588{
8589#if 0
8590 hdd_wext_state_t *wextBuf;
8591 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8592
8593 ENTER();
8594 // Set up the pointer to the Wireless Extensions state structure
8595 wextBuf = pAdapter->pWextState;
8596
8597 // De-allocate the Wireless Extensions state structure
8598 kfree(wextBuf);
8599
8600 // Clear out the pointer to the Wireless Extensions state structure
8601 pAdapter->pWextState = NULL;
8602
8603 EXIT();
8604#endif
8605 dev->wireless_handlers = NULL;
8606 return 0;
8607}
8608
8609