blob: 7d4b580ebb77ed585b1bb4859e98df2ace8320a4 [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 Koyyalamudia96f5442013-05-10 11:32:06 +0530213#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700214#define WE_SET_REASSOC_TRIGGER 8
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 Puligilla04bb8fd2014-02-03 23:21:47 +05305298 case WE_STOP_OBSS_SCAN:
5299 {
5300 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5301 2.OBSS scan is stopped by Firmware during the disassociation
5302 3.OBSS stop comamnd is added for debugging purpose*/
5303 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5304 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005305
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305306 if (pAdapter == NULL)
5307 {
5308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5309 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305310 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305311 }
5312 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5313 if (pMac == NULL)
5314 {
5315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5316 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305317 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305318 }
5319 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5320 }
5321 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 default:
5323 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005324 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 break;
5326 }
5327 }
5328
5329 return ret;
5330}
5331
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305332void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5333{
5334 /*
5335 * Function to display HDD WMM information
5336 * for Tx Queues.
5337 * Prints globala as well as per client depending
5338 * whether the clients are registered or not.
5339 */
5340 int i = 0, j = 0;
5341 for ( i=0; i< NUM_TX_QUEUES; i++)
5342 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305343 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005344 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305345 i, pAdapter->wmm_tx_queue[i].count,
5346 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305347 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305348 }
5349
5350 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5351 {
5352 if(pAdapter->aStaInfo[i].isUsed)
5353 {
5354 hddLog(LOGE, "******STAIndex: %d*********", i);
5355 for ( j=0; j< NUM_TX_QUEUES; j++)
5356 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305357 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005358 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305359 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5360 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5361 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305362 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305363 }
5364 }
5365 }
5366
5367}
Jeff Johnson295189b2012-06-20 16:38:30 -07005368int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5369 union iwreq_data *wrqu, char *extra)
5370{
5371 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5372 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowlid4522fd2014-06-14 17:20:27 +05305373 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 int apps_args[MAX_VAR_ARGS] = {0};
Girish Gowlid4522fd2014-06-14 17:20:27 +05305375 int num_args;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005376 hdd_station_ctx_t *pStaCtx = NULL ;
5377 hdd_ap_ctx_t *pAPCtx = NULL;
5378 int cmd = 0;
5379 int staId = 0;
Girish Gowlid4522fd2014-06-14 17:20:27 +05305380 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005381
Girish Gowlid4522fd2014-06-14 17:20:27 +05305382 /* helper function to get iwreq_data with compat handling. */
5383 if (hdd_priv_get_data(&s_priv_data, wrqu))
5384 {
5385 return -EINVAL;
5386 }
5387
5388 if (NULL == s_priv_data.pointer)
5389 {
5390 return -EINVAL;
5391 }
5392
5393 sub_cmd = s_priv_data.flags;
5394 num_args = s_priv_data.length;
5395
5396 hddLog(LOG1, "%s: Received length %d", __func__, s_priv_data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005397
5398 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5399 {
5400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5401 "%s:LOGP in Progress. Ignore!!!", __func__);
5402 return -EBUSY;
5403 }
5404
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 if (num_args > MAX_VAR_ARGS)
5406 {
5407 num_args = MAX_VAR_ARGS;
5408 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005409
5410 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlid4522fd2014-06-14 17:20:27 +05305411 if (copy_from_user(apps_args, s_priv_data.pointer, (sizeof(int)) * num_args))
Arif Hussain0273cba2014-01-07 20:58:29 -08005412 {
5413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5414 "%s: failed to copy data to user buffer", __func__);
5415 return -EFAULT;
5416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005417
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005418 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5419 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5420 {
5421 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5422 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5423 {
5424 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5425 staId = pStaCtx->conn_info.staId[0];
5426 }
5427 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5428 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5429 {
5430 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5431 staId = pAPCtx->uBCStaId;
5432 }
5433 else
5434 {
5435 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5436 return 0;
5437 }
5438 }
5439
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 switch (sub_cmd)
5441 {
5442 case WE_LOG_DUMP_CMD:
5443 {
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305444 vos_ssr_protect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005445 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005446 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 apps_args[3], apps_args[4]);
5448
5449 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5450 apps_args[3], apps_args[4]);
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305451 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005452
5453 }
5454 break;
5455
Jeff Johnson295189b2012-06-20 16:38:30 -07005456 case WE_P2P_NOA_CMD:
5457 {
5458 p2p_app_setP2pPs_t p2pNoA;
5459
5460 p2pNoA.opp_ps = apps_args[0];
5461 p2pNoA.ctWindow = apps_args[1];
5462 p2pNoA.duration = apps_args[2];
5463 p2pNoA.interval = apps_args[3];
5464 p2pNoA.count = apps_args[4];
5465 p2pNoA.single_noa_duration = apps_args[5];
5466 p2pNoA.psSelection = apps_args[6];
5467
5468 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5469 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005470 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5472
5473 hdd_setP2pPs(dev, &p2pNoA);
5474
5475 }
5476 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005477
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305478 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5479 {
5480 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5481 __func__, apps_args[0], apps_args[1]);
5482 vosTraceEnable(apps_args[0], apps_args[1]);
5483 }
5484 break;
5485
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005486 case WE_MTRACE_DUMP_CMD:
5487 {
5488 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5489 "bitmask_of_module %d ",
5490 __func__, apps_args[0], apps_args[1], apps_args[2],
5491 apps_args[3]);
5492 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5493 apps_args[2], apps_args[3]);
5494
5495 }
5496 break;
5497
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005498 case WE_MCC_CONFIG_CREDENTIAL :
5499 {
5500 cmd = 287; //Command should be updated if there is any change
5501 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005502 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005503 {
5504 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5505 }
5506 else
5507 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005508 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005509 return 0;
5510 }
5511 }
5512 break;
5513
5514 case WE_MCC_CONFIG_PARAMS :
5515 {
5516 cmd = 288; //command Should be updated if there is any change
5517 // in the Riva dump command
5518 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5519 }
5520 break;
5521
Chilam NG571c65a2013-01-19 12:27:36 +05305522#ifdef FEATURE_WLAN_TDLS
5523 case WE_TDLS_CONFIG_PARAMS :
5524 {
5525 tdls_config_params_t tdlsParams;
5526
Chilam Ng01120412013-02-19 18:32:21 -08005527 tdlsParams.tdls = apps_args[0];
5528 tdlsParams.tx_period_t = apps_args[1];
5529 tdlsParams.tx_packet_n = apps_args[2];
5530 tdlsParams.discovery_period_t = apps_args[3];
5531 tdlsParams.discovery_tries_n = apps_args[4];
5532 tdlsParams.idle_timeout_t = apps_args[5];
5533 tdlsParams.idle_packet_n = apps_args[6];
5534 tdlsParams.rssi_hysteresis = apps_args[7];
5535 tdlsParams.rssi_trigger_threshold = apps_args[8];
5536 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305537
Chilam Ng01120412013-02-19 18:32:21 -08005538 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305539 }
5540 break;
5541#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 default:
5543 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005544 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5545 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 }
5547 break;
5548 }
5549
5550 return 0;
5551}
5552
5553
5554static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5555 union iwreq_data *wrqu, char *extra)
5556{
5557 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5558 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5559 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5560 int params[HDD_WLAN_WMM_PARAM_COUNT];
5561 sme_QosWmmTspecInfo tSpec;
5562 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05305563 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005564
5565 // make sure the application is sufficiently priviledged
5566 // note that the kernel will do this for "set" ioctls, but since
5567 // this ioctl wants to return status to user space it must be
5568 // defined as a "get" ioctl
5569 if (!capable(CAP_NET_ADMIN))
5570 {
5571 return -EPERM;
5572 }
5573
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005574 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5575 {
5576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5577 "%s:LOGP in Progress. Ignore!!!", __func__);
5578 return -EBUSY;
5579 }
5580
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 // we must be associated in order to add a tspec
5582 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5583 {
5584 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5585 return 0;
5586 }
5587
5588 // since we are defined to be a "get" ioctl, and since the number
5589 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05305590 // will pass down in the iwreq_data, we must copy the "set" params.
5591 // We must handle the compat for iwreq_data in 32U/64K environment.
5592
5593 // helper fucntion to get iwreq_data with compat handling.
5594 if (hdd_priv_get_data(&s_priv_data, wrqu))
5595 {
5596 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5597 return 0;
5598 }
5599
5600 // make sure all params are correctly passed to function
5601 if ((NULL == s_priv_data.pointer) ||
5602 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
5603 {
5604 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5605 return 0;
5606 }
5607
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05305609 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 {
5611 // hmmm, can't get them
5612 return -EIO;
5613 }
5614
5615 // clear the tspec
5616 memset(&tSpec, 0, sizeof(tSpec));
5617
5618 // validate the handle
5619 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5620 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5621 {
5622 // that one is reserved
5623 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5624 return 0;
5625 }
5626
5627 // validate the TID
5628 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5629 {
5630 // out of range
5631 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5632 return 0;
5633 }
5634 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5635
5636 // validate the direction
5637 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5638 {
5639 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5640 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5641 break;
5642
5643 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5644 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5645 break;
5646
5647 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5648 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5649 break;
5650
5651 default:
5652 // unknown
5653 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5654 return 0;
5655 }
5656
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305657 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5658
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 // validate the user priority
5660 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5661 {
5662 // out of range
5663 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5664 return 0;
5665 }
5666 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305667 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5668 {
5669 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5670 return 0;
5671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005672
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5674 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5675 tSpec.ts_info.psb, tSpec.ts_info.up);
5676
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5678 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5679 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5680 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5681 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5682 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5683 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5684 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5685 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5686 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5687 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5688 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5689
5690 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5691
5692 // validate the ts info ack policy
5693 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5694 {
5695 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5696 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5697 break;
5698
5699 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5700 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5701 break;
5702
5703 default:
5704 // unknown
5705 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5706 return 0;
5707 }
5708
5709 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5710 return 0;
5711}
5712
5713
5714static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5715 union iwreq_data *wrqu, char *extra)
5716{
5717 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5718 int *params = (int *)extra;
5719 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5720 v_U32_t handle;
5721
5722 // make sure the application is sufficiently priviledged
5723 // note that the kernel will do this for "set" ioctls, but since
5724 // this ioctl wants to return status to user space it must be
5725 // defined as a "get" ioctl
5726 if (!capable(CAP_NET_ADMIN))
5727 {
5728 return -EPERM;
5729 }
5730
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005731 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5732 {
5733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5734 "%s:LOGP in Progress. Ignore!!!", __func__);
5735 return -EBUSY;
5736 }
5737
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 // although we are defined to be a "get" ioctl, the params we require
5739 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5740 // is no need to copy the params from user space
5741
5742 // validate the handle
5743 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5744 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5745 {
5746 // that one is reserved
5747 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5748 return 0;
5749 }
5750
5751 *pStatus = hdd_wmm_delts(pAdapter, handle);
5752 return 0;
5753}
5754
5755
5756static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5757 union iwreq_data *wrqu, char *extra)
5758{
5759 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5760 int *params = (int *)extra;
5761 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5762 v_U32_t handle;
5763
5764 // although we are defined to be a "get" ioctl, the params we require
5765 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5766 // is no need to copy the params from user space
5767
5768 // validate the handle
5769 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5770 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5771 {
5772 // that one is reserved
5773 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5774 return 0;
5775 }
5776
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005777 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5778 {
5779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5780 "%s:LOGP in Progress. Ignore!!!", __func__);
5781 return -EBUSY;
5782 }
5783
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5785 return 0;
5786}
5787
5788
5789#ifdef FEATURE_WLAN_WAPI
5790static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5791 union iwreq_data *wrqu, char *extra)
5792{
5793 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5794 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5795 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5796 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5797
Arif Hussain7adce1b2013-11-11 22:59:34 -08005798 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005799
5800 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005801 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005802 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5803 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005804
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005805 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5806 {
5807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5808 "%s:LOGP in Progress. Ignore!!!", __func__);
5809 return -EBUSY;
5810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005811
5812 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005813 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5815 pRoamProfile->EncryptionType.numEntries = 1;
5816 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5817 pRoamProfile->mcEncryptionType.numEntries = 1;
5818 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5819
5820 pRoamProfile->AuthType.numEntries = 1;
5821 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5822 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5823 }
5824 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005825 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 }
5827 else
5828 return -EINVAL;
5829
5830 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5831
5832 return 0;
5833}
5834
5835static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5836 union iwreq_data *wrqu, char *extra)
5837{
5838 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5839 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5840
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005841 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5842 {
5843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5844 "%s:LOGP in Progress. Ignore!!!", __func__);
5845 return -EBUSY;
5846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5848
5849 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005850 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 return 0;
5852}
5853
5854static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5855 union iwreq_data *wrqu, char *extra)
5856{
5857 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5858// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5859 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5860 int i = 0, j = 0;
5861 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005862 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005863 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005864
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005865 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5866 {
5867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5868 "%s:LOGP in Progress. Ignore!!!", __func__);
5869 return -EBUSY;
5870 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005871
5872 if (NULL == pWapiAssocInfo)
5873 {
5874 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5875 "%s: WDA NULL context", __func__);
5876 VOS_ASSERT(0);
5877 return VOS_STATUS_E_FAILURE;
5878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005879
Arif Hussain6d2a3322013-11-17 19:50:10 -08005880 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 -07005881 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005883 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005884
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005885 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005887 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005888
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005889 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005890 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 for(i = 0 ; i < 16 ; i++) {
5892 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5893 for(j = 0 ; j < 16 ; j++)
5894 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5895 }
5896
5897 /* We are not using the entire IE as provided by the supplicant.
5898 * This is being calculated by SME. This is the same as in the
5899 * case of WPA. Only the auth mode information needs to be
5900 * extracted here*/
5901 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005902 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5904 }
5905
5906 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005907 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5909 }
5910 return 0;
5911}
5912
5913static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5914 union iwreq_data *wrqu, char *extra)
5915{
5916 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5917 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5918 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5919 tANI_U32 roamId = 0xFF;
5920 tANI_U8 *pKeyPtr = NULL;
5921 v_BOOL_t isConnected = TRUE;
5922 tCsrRoamSetKey setKey;
5923 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5925
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005926 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5927 {
5928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5929 "%s:LOGP in Progress. Ignore!!!", __func__);
5930 return -EBUSY;
5931 }
5932
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005934 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005935 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005936
Arif Hussain6d2a3322013-11-17 19:50:10 -08005937 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 -07005938 hddLog(LOG1,"Add Index:0x");
5939 for(i =0 ; i < 12 ; i++)
5940 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5941
Arif Hussain6d2a3322013-11-17 19:50:10 -08005942 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5944 for(i =0 ; i < 16 ; i++)
5945 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5946
Arif Hussain6d2a3322013-11-17 19:50:10 -08005947 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5949 for(i =0 ; i < 16 ; i++)
5950 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5951
Arif Hussain6d2a3322013-11-17 19:50:10 -08005952 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 for(i = 0 ; i < 16 ; i++)
5954 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5955
5956 // Clear the setkey memory
5957 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5958 // Store Key ID
5959 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5960 // SET WAPI Encryption
5961 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5962 // Key Directionn both TX and RX
5963 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5964 // the PAE role
5965 setKey.paeRole = 0 ;
5966
5967 switch ( pWapiKey->keyType )
5968 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005969 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 {
5971 isConnected = hdd_connIsConnected(pHddStaCtx);
5972 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5973 break;
5974 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005975 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 {
5977 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5978 break;
5979 }
5980 default:
5981 {
5982 //Any other option is invalid.
5983 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005984 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005985
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005986 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5988 break; // NEED RETURN FROM HERE ????
5989 }
5990 }
5991
5992 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5993 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5994 pKeyPtr = setKey.Key;
5995 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5996 pKeyPtr += pWapiKey->wpiekLen;
5997 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5998
5999 // Set the new key with SME.
6000 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6001
6002 if ( isConnected ) {
6003 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
6004 if ( halStatus != eHAL_STATUS_SUCCESS )
6005 {
6006 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6007 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
6008
6009 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6010 }
6011 }
6012#if 0 /// NEED TO CHECK ON THIS
6013 else
6014 {
6015 // Store the keys in the adapter to be moved to the profile & passed to
6016 // SME in the ConnectRequest if we are not yet in connected state.
6017 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
6018 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
6019
6020 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
6021 " Saving key [idx= %d] to apply when moving to connected state ",
6022 setKey.keyId );
6023
6024 }
6025#endif
6026 return halStatus;
6027}
6028
6029static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
6030 union iwreq_data *wrqu, char *extra)
6031{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006032 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006033#ifdef WLAN_DEBUG
6034 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08006035 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006036#endif
6037
6038 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006039 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006040 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006041
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006042 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
6043 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07006044
6045 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006046
6047 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6048 {
6049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6050 "%s:LOGP in Progress. Ignore!!!", __func__);
6051 return -EBUSY;
6052 }
6053
Jeff Johnson295189b2012-06-20 16:38:30 -07006054#ifdef WLAN_DEBUG
6055 for(i =0 ; i < 16 ; i++)
6056 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
6057#endif
6058
6059 return 0;
6060}
6061
6062static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
6063 union iwreq_data *wrqu, char *extra)
6064{
6065 /* Yet to implement this function, 19th April 2010 */
6066 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
6067
6068 return 0;
6069}
6070#endif /* FEATURE_WLAN_WAPI */
6071
6072#ifdef WLAN_FEATURE_VOWIFI_11R
6073//
6074//
6075// Each time the supplicant has the auth_request or reassoc request
6076// IEs ready. This is pushed to the driver. The driver will inturn use
6077// it to send out the auth req and reassoc req for 11r FT Assoc.
6078//
6079static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
6080 union iwreq_data *wrqu, char *extra)
6081{
6082 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6083 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6084 //v_CONTEXT_t pVosContext;
6085
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006086 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6087 {
6088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6089 "%s:LOGP in Progress. Ignore!!!", __func__);
6090 return -EBUSY;
6091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 if (!wrqu->data.length)
6093 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006094 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 return -EINVAL;
6096 }
6097 if (wrqu->data.pointer == NULL)
6098 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006099 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 return -EINVAL;
6101 }
6102
6103 // Added for debug on reception of Re-assoc Req.
6104 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6105 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006106 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006108 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 }
6110
6111#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08006112 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07006113#endif
6114
6115 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08006116 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 wrqu->data.length);
6118
6119 return 0;
6120}
6121#endif
6122
Amar Singhalf3a6e762013-02-19 15:06:50 -08006123static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006124 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08006126{
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006128 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006130 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006131 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006132 tpSirRcvFltMcAddrList mc_addr_list_ptr;
6133 int idx;
6134 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07006135
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006136 if (pHddCtx->isLogpInProgress)
6137 {
6138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6139 "%s:LOGP in Progress. Ignore!!!", __func__);
6140 return -EBUSY;
6141 }
6142
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306143 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
6144 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306145#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07006146
Amar Singhalf3a6e762013-02-19 15:06:50 -08006147 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6148 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006149 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006150 hddLog(VOS_TRACE_LEVEL_ERROR,
6151 "%s: vos_mem_alloc failed", __func__);
6152 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006153 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006154
6155 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
6156
6157 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
6158 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
6159
6160 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
6161 mc_addr_list_ptr->ulMulticastAddrCnt);
6162
6163 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006164 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006165 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
6166 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
6167
6168 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6169 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006170 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006171
Amar Singhalf3a6e762013-02-19 15:06:50 -08006172 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6173 vos_mem_free(mc_addr_list_ptr);
6174 if (eHAL_STATUS_SUCCESS != ret_val)
6175 {
6176 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6177 __func__);
6178 return -EINVAL;
6179 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306180#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306181 }
6182 else
6183 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006184
Amar Singhalf3a6e762013-02-19 15:06:50 -08006185 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6186 "%s: Set MC BC Filter Config request: %d suspend %d",
6187 __func__, pRequest->mcastBcastFilterSetting,
6188 pHddCtx->hdd_wlan_suspended);
6189
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306190 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006191
6192 if (pHddCtx->hdd_wlan_suspended)
6193 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006194 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6195 if (NULL == wlanRxpFilterParam)
6196 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306197 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006198 "%s: vos_mem_alloc failed", __func__);
6199 return -EINVAL;
6200 }
6201
Amar Singhalf3a6e762013-02-19 15:06:50 -08006202 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6203 pRequest->mcastBcastFilterSetting;
6204 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6205
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306206 hdd_conf_hostoffload(pAdapter, TRUE);
6207 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6208 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006209
6210 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6211 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306212 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006213 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6214 wlanRxpFilterParam->setMcstBcstFilter);
6215
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306216 if (eHAL_STATUS_SUCCESS !=
6217 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6218 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006219 {
6220 hddLog(VOS_TRACE_LEVEL_ERROR,
6221 "%s: Failure to execute set HW MC/BC Filter request",
6222 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006223 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006224 return -EINVAL;
6225 }
6226
Amar Singhalf3a6e762013-02-19 15:06:50 -08006227 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006229
6230 return 0;
6231}
6232
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006233static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006234 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 union iwreq_data *wrqu, char *extra)
6236{
6237 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6238 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306239 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006240 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006241
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306242 //Reset the filter to INI value as we have to clear the dynamic filter
6243 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006244
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306245 //Configure FW with new setting
6246 if (pHddCtx->hdd_wlan_suspended)
6247 {
6248 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6249 if (NULL == wlanRxpFilterParam)
6250 {
6251 hddLog(VOS_TRACE_LEVEL_ERROR,
6252 "%s: vos_mem_alloc failed", __func__);
6253 return -EINVAL;
6254 }
6255
6256 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6257 pHddCtx->configuredMcastBcastFilter;
6258 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6259
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306260 hdd_conf_hostoffload(pAdapter, TRUE);
6261 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6262 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306263
6264 if (eHAL_STATUS_SUCCESS !=
6265 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6266 wlanRxpFilterParam))
6267 {
6268 hddLog(VOS_TRACE_LEVEL_ERROR,
6269 "%s: Failure to execute set HW MC/BC Filter request",
6270 __func__);
6271 vos_mem_free(wlanRxpFilterParam);
6272 return -EINVAL;
6273 }
6274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 return 0;
6276}
6277
6278static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6279 union iwreq_data *wrqu, char *extra)
6280{
6281 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006282 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006283 tSirHostOffloadReq offloadRequest;
6284
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006285 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6286 {
6287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6288 "%s:LOGP in Progress. Ignore!!!", __func__);
6289 return -EBUSY;
6290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 /* Debug display of request components. */
6292 switch (pRequest->offloadType)
6293 {
6294 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006295 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006296 switch (pRequest->enableOrDisable)
6297 {
6298 case WLAN_OFFLOAD_DISABLE:
6299 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6300 break;
6301 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6302 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6303 case WLAN_OFFLOAD_ENABLE:
6304 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6305 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6306 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6307 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6308 }
6309 break;
6310
6311 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006312 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006313 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 switch (pRequest->enableOrDisable)
6315 {
6316 case WLAN_OFFLOAD_DISABLE:
6317 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6318 break;
6319 case WLAN_OFFLOAD_ENABLE:
6320 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6321 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6322 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6323 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6324 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6325 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6326 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6327 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6328 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6329 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6330 }
6331 }
6332
6333 /* Execute offload request. The reason that we can copy the request information
6334 from the ioctl structure to the SME structure is that they are laid out
6335 exactly the same. Otherwise, each piece of information would have to be
6336 copied individually. */
6337 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006338 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6339 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006341 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 __func__);
6343 return -EINVAL;
6344 }
6345
6346 return 0;
6347}
6348
6349static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6350 union iwreq_data *wrqu, char *extra)
6351{
6352 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006353 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 tSirKeepAliveReq keepaliveRequest;
6355
6356 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6357 {
6358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006359 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 return 0;
6361 }
6362
6363 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006364 hddLog(VOS_TRACE_LEVEL_INFO,
6365 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6366 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006367
6368 switch (pRequest->packetType)
6369 {
6370 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006371 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 break;
6373
6374 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6375
Arif Hussain6d2a3322013-11-17 19:50:10 -08006376 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006377 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006378
6379 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6380 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6381 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6382
6383 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6384 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6385 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6386
6387 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6388 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6389 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6390 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6391 break;
6392
6393 }
6394
6395 /* Execute keep alive request. The reason that we can copy the request information
6396 from the ioctl structure to the SME structure is that they are laid out
6397 exactly the same. Otherwise, each piece of information would have to be
6398 copied individually. */
6399 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6400
Arif Hussain6d2a3322013-11-17 19:50:10 -08006401 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006402
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006403 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006404 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006406 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 __func__);
6408 return -EINVAL;
6409 }
6410
6411 return 0;
6412}
6413
6414#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006415int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006416 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006417{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006418 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6419 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 int i=0;
6421
6422 if (pHddCtx->cfg_ini->disablePacketFilter)
6423 {
6424 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006425 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 return 0;
6427 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006428 if (pHddCtx->isLogpInProgress)
6429 {
6430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6431 "%s:LOGP in Progress. Ignore!!!", __func__);
6432 return -EBUSY;
6433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 /* Debug display of request components. */
6435 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006436 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006437
6438 switch (pRequest->filterAction)
6439 {
6440 case HDD_RCV_FILTER_SET:
6441 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006442 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006443
6444 packetFilterSetReq.filterId = pRequest->filterId;
6445 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6446 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006447 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 __func__, pRequest->numParams);
6449 return -EINVAL;
6450 }
6451 packetFilterSetReq.numFieldParams = pRequest->numParams;
6452 packetFilterSetReq.coalesceTime = 0;
6453 packetFilterSetReq.filterType = 1;
6454 for (i=0; i < pRequest->numParams; i++)
6455 {
6456 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6457 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6458 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6459 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6460 packetFilterSetReq.paramsData[i].reserved = 0;
6461
Arif Hussain6d2a3322013-11-17 19:50:10 -08006462 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6464 packetFilterSetReq.filterType);
6465
Arif Hussain6d2a3322013-11-17 19:50:10 -08006466 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6468
6469 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6470 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6471 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6472 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6473
Arif Hussain6d2a3322013-11-17 19:50:10 -08006474 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6476 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6477 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6478
Arif Hussain6d2a3322013-11-17 19:50:10 -08006479 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6481 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6482 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6483 }
6484
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006485 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006487 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 __func__);
6489 return -EINVAL;
6490 }
6491
6492 break;
6493
6494 case HDD_RCV_FILTER_CLEAR:
6495
Arif Hussain6d2a3322013-11-17 19:50:10 -08006496 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006497 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006499 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006501 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006502 __func__);
6503 return -EINVAL;
6504 }
6505 break;
6506
6507 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006508 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006509 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 return -EINVAL;
6511 }
6512 return 0;
6513}
6514
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306515int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6516 tANI_U8 sessionId)
6517{
6518 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6519 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6520
6521 if (NULL == pHddCtx)
6522 {
6523 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6524 return -EINVAL;
6525 }
6526
6527 if (pHddCtx->isLogpInProgress)
6528 {
6529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6530 "%s:LOGP in Progress. Ignore!!!", __func__);
6531 return -EBUSY;
6532 }
6533
6534 if (pHddCtx->cfg_ini->disablePacketFilter)
6535 {
6536 hddLog(VOS_TRACE_LEVEL_ERROR,
6537 "%s: Packet Filtering Disabled. Returning ",
6538 __func__ );
6539 return -EINVAL;
6540 }
6541
6542 switch (filterType)
6543 {
6544 /* For setting IPV6 MC and UC Filter we need to configure
6545 * 2 filters, one for MC and one for UC.
6546 * The Filter ID shouldn't be swapped, which results in making
6547 * UC Filter ineffective.
6548 * We have Hardcode all the values
6549 *
6550 * Reason for a seperate UC filter is because, driver need to
6551 * specify the FW that the specific filter is for unicast
6552 * otherwise FW will not pass the unicast frames by default
6553 * through the filter. This is required to avoid any performance
6554 * hits when no unicast filter is set and only MC/BC are set.
6555 * The way driver informs host is by using the MAC protocol
6556 * layer, CMP flag set to MAX, CMP Data set to 1.
6557 */
6558
6559 case HDD_FILTER_IPV6_MC_UC:
6560 /* Setting IPV6 MC Filter below
6561 */
6562 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6563 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6564 packetFilterSetReq.numFieldParams = 2;
6565 packetFilterSetReq.paramsData[0].protocolLayer =
6566 HDD_FILTER_PROTO_TYPE_MAC;
6567 packetFilterSetReq.paramsData[0].cmpFlag =
6568 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6569 packetFilterSetReq.paramsData[0].dataOffset =
6570 WLAN_HDD_80211_FRM_DA_OFFSET;
6571 packetFilterSetReq.paramsData[0].dataLength = 1;
6572 packetFilterSetReq.paramsData[0].compareData[0] =
6573 HDD_IPV6_MC_CMP_DATA;
6574
6575 packetFilterSetReq.paramsData[1].protocolLayer =
6576 HDD_FILTER_PROTO_TYPE_ARP;
6577 packetFilterSetReq.paramsData[1].cmpFlag =
6578 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6579 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6580 packetFilterSetReq.paramsData[1].dataLength = 2;
6581 packetFilterSetReq.paramsData[1].compareData[0] =
6582 HDD_IPV6_CMP_DATA_0;
6583 packetFilterSetReq.paramsData[1].compareData[1] =
6584 HDD_IPV6_CMP_DATA_1;
6585
6586
6587 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6588 &packetFilterSetReq, sessionId))
6589 {
6590 hddLog(VOS_TRACE_LEVEL_ERROR,
6591 "%s: Failure to execute Set IPv6 Mulicast Filter",
6592 __func__);
6593 return -EINVAL;
6594 }
6595
6596 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6597
6598 /*
6599 * Setting IPV6 UC Filter below
6600 */
6601 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6602 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6603 packetFilterSetReq.numFieldParams = 2;
6604 packetFilterSetReq.paramsData[0].protocolLayer =
6605 HDD_FILTER_PROTO_TYPE_MAC;
6606 packetFilterSetReq.paramsData[0].cmpFlag =
6607 HDD_FILTER_CMP_TYPE_MAX;
6608 packetFilterSetReq.paramsData[0].dataOffset = 0;
6609 packetFilterSetReq.paramsData[0].dataLength = 1;
6610 packetFilterSetReq.paramsData[0].compareData[0] =
6611 HDD_IPV6_UC_CMP_DATA;
6612
6613 packetFilterSetReq.paramsData[1].protocolLayer =
6614 HDD_FILTER_PROTO_TYPE_ARP;
6615 packetFilterSetReq.paramsData[1].cmpFlag =
6616 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6617 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6618 packetFilterSetReq.paramsData[1].dataLength = 2;
6619 packetFilterSetReq.paramsData[1].compareData[0] =
6620 HDD_IPV6_CMP_DATA_0;
6621 packetFilterSetReq.paramsData[1].compareData[1] =
6622 HDD_IPV6_CMP_DATA_1;
6623
6624 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6625 &packetFilterSetReq, sessionId))
6626 {
6627 hddLog(VOS_TRACE_LEVEL_ERROR,
6628 "%s: Failure to execute Set IPv6 Unicast Filter",
6629 __func__);
6630 return -EINVAL;
6631 }
6632
6633 break;
6634
6635 case HDD_FILTER_IPV6_MC:
6636 /*
6637 * IPV6 UC Filter might be already set,
6638 * clear the UC Filter. As the Filter
6639 * IDs are static, we can directly clear it.
6640 */
6641 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6642 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6643 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6644 &packetFilterClrReq, sessionId))
6645 {
6646 hddLog(VOS_TRACE_LEVEL_ERROR,
6647 "%s: Failure to execute Clear IPv6 Unicast Filter",
6648 __func__);
6649 return -EINVAL;
6650 }
6651
6652 /*
6653 * Setting IPV6 MC Filter below
6654 */
6655 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6656 packetFilterSetReq.numFieldParams = 2;
6657 packetFilterSetReq.paramsData[0].protocolLayer =
6658 HDD_FILTER_PROTO_TYPE_MAC;
6659 packetFilterSetReq.paramsData[0].cmpFlag =
6660 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6661 packetFilterSetReq.paramsData[0].dataOffset =
6662 WLAN_HDD_80211_FRM_DA_OFFSET;
6663 packetFilterSetReq.paramsData[0].dataLength = 1;
6664 packetFilterSetReq.paramsData[0].compareData[0] =
6665 HDD_IPV6_MC_CMP_DATA;
6666
6667 packetFilterSetReq.paramsData[1].protocolLayer =
6668 HDD_FILTER_PROTO_TYPE_ARP;
6669 packetFilterSetReq.paramsData[1].cmpFlag =
6670 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6671 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6672 packetFilterSetReq.paramsData[1].dataLength = 2;
6673 packetFilterSetReq.paramsData[1].compareData[0] =
6674 HDD_IPV6_CMP_DATA_0;
6675 packetFilterSetReq.paramsData[1].compareData[1] =
6676 HDD_IPV6_CMP_DATA_1;
6677
6678
6679 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6680 &packetFilterSetReq, sessionId))
6681 {
6682 hddLog(VOS_TRACE_LEVEL_ERROR,
6683 "%s: Failure to execute Set IPv6 Multicast Filter",
6684 __func__);
6685 return -EINVAL;
6686 }
6687 break;
6688
6689 default :
6690 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6691 "%s: Packet Filter Request: Invalid",
6692 __func__);
6693 return -EINVAL;
6694 }
6695 return 0;
6696}
6697
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306698void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006699{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306700 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306701 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006702 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306703 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006704
Yue Ma3ede6052013-08-29 00:33:26 -07006705 if (NULL == pHddCtx)
6706 {
6707 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6708 return;
6709 }
6710
6711 hHal = pHddCtx->hHal;
6712
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306713 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6716 return;
6717 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306718
6719 /* Check if INI is enabled or not, other wise just return
6720 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306721 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306722 {
6723 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6724 if (NULL == pMulticastAddrs)
6725 {
6726 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6727 return;
6728 }
6729
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 if (set)
6731 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306732 /* Following pre-conditions should be satisfied before wei
6733 * configure the MC address list.
6734 */
6735 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6736 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6737 && pAdapter->mc_addr_list.mc_cnt
6738 && (eConnectionState_Associated ==
6739 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6740 {
6741 pMulticastAddrs->ulMulticastAddrCnt =
6742 pAdapter->mc_addr_list.mc_cnt;
6743 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6744 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006745 memcpy(pMulticastAddrs->multicastAddr[i],
6746 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306747 sizeof(pAdapter->mc_addr_list.addr[i]));
6748 hddLog(VOS_TRACE_LEVEL_INFO,
6749 "%s: %s multicast filter: addr ="
6750 MAC_ADDRESS_STR,
6751 __func__, set ? "setting" : "clearing",
6752 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6753 }
6754 /* Set multicast filter */
6755 sme_8023MulticastList(hHal, pAdapter->sessionId,
6756 pMulticastAddrs);
6757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306759 else
6760 {
6761 /* Need to clear only if it was previously configured
6762 */
6763 if (pAdapter->mc_addr_list.isFilterApplied)
6764 {
6765 pMulticastAddrs->ulMulticastAddrCnt = 0;
6766 sme_8023MulticastList(hHal, pAdapter->sessionId,
6767 pMulticastAddrs);
6768 }
6769
6770 }
6771 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006772 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306774 else
6775 {
6776 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306777 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306778 }
6779 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006780}
6781
6782static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6783 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306784{
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006786 tpPacketFilterCfg pRequest = NULL;
6787 int ret;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306788 struct iw_point s_priv_data;
6789
6790 if (hdd_priv_get_data(&s_priv_data, wrqu))
6791 {
6792 return -EINVAL;
6793 }
6794
6795 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6796 {
6797 return -EINVAL;
6798 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006799
Arif Hussain0273cba2014-01-07 20:58:29 -08006800 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306801 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6802 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006803 if (NULL == pRequest)
6804 {
6805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6806 "mem_alloc_copy_from_user_helper fail");
6807 return -ENOMEM;
6808 }
6809
6810 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6811 kfree(pRequest);
6812
6813 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006814}
6815#endif
6816static int iw_get_statistics(struct net_device *dev,
6817 struct iw_request_info *info,
6818 union iwreq_data *wrqu, char *extra)
6819{
6820
6821 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6822 eHalStatus status = eHAL_STATUS_SUCCESS;
6823 hdd_wext_state_t *pWextState;
6824 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6825 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6826 char *p = extra;
6827 int tlen = 0;
6828 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6829
6830 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6831 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6832
6833 ENTER();
6834
6835 if (pHddCtx->isLogpInProgress) {
6836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6837 return -EINVAL;
6838 }
6839
6840 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6841
6842 wrqu->txpower.value = 0;
6843 }
6844 else {
6845 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6846 SME_SUMMARY_STATS |
6847 SME_GLOBAL_CLASSA_STATS |
6848 SME_GLOBAL_CLASSB_STATS |
6849 SME_GLOBAL_CLASSC_STATS |
6850 SME_GLOBAL_CLASSD_STATS |
6851 SME_PER_STA_STATS,
6852 hdd_StatisticsCB, 0, FALSE,
6853 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6854
6855 if (eHAL_STATUS_SUCCESS != status)
6856 {
6857 hddLog(VOS_TRACE_LEVEL_ERROR,
6858 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006859 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 return -EINVAL;
6861 }
6862
6863 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6864
6865 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6866 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6867 {
6868 hddLog(VOS_TRACE_LEVEL_ERROR,
6869 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006870 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 /*Remove the SME statistics list by passing NULL in callback argument*/
6872 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6873 SME_SUMMARY_STATS |
6874 SME_GLOBAL_CLASSA_STATS |
6875 SME_GLOBAL_CLASSB_STATS |
6876 SME_GLOBAL_CLASSC_STATS |
6877 SME_GLOBAL_CLASSD_STATS |
6878 SME_PER_STA_STATS,
6879 NULL, 0, FALSE,
6880 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6881
6882 return -EINVAL;
6883 }
6884 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6885 (tANI_U8) sizeof (pStats->retry_cnt),
6886 (char*) &(pStats->retry_cnt[0]),
6887 tlen);
6888
6889 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6890 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6891 (char*) &(pStats->multiple_retry_cnt[0]),
6892 tlen);
6893
6894 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6895 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6896 (char*) &(pStats->tx_frm_cnt[0]),
6897 tlen);
6898
6899 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6900 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6901 (char*) &(pStats->rx_frm_cnt),
6902 tlen);
6903
6904 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6905 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6906 (char*) &(pStats->frm_dup_cnt),
6907 tlen);
6908
6909 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6910 (tANI_U8) sizeof (pStats->fail_cnt),
6911 (char*) &(pStats->fail_cnt[0]),
6912 tlen);
6913
6914 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6915 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6916 (char*) &(pStats->rts_fail_cnt),
6917 tlen);
6918
6919 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6920 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6921 (char*) &(pStats->ack_fail_cnt),
6922 tlen);
6923
6924 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6925 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6926 (char*) &(pStats->rts_succ_cnt),
6927 tlen);
6928
6929 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6930 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6931 (char*) &(pStats->rx_discard_cnt),
6932 tlen);
6933
6934 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6935 (tANI_U8) sizeof (pStats->rx_error_cnt),
6936 (char*) &(pStats->rx_error_cnt),
6937 tlen);
6938
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006939 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006940 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006941 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 tlen);
6943
6944 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6945 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6946 (char*) &(dStats->rx_byte_cnt),
6947 tlen);
6948
6949 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6950 (tANI_U8) sizeof (dStats->rx_rate),
6951 (char*) &(dStats->rx_rate),
6952 tlen);
6953
6954 /* Transmit rate, in units of 500 kbit/sec */
6955 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6956 (tANI_U8) sizeof (aStats->tx_rate),
6957 (char*) &(aStats->tx_rate),
6958 tlen);
6959
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006960 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6961 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6962 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006963 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006964 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6965 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6966 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006967 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006968 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6969 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6970 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006971 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006972 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6973 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6974 (char*) &(dStats->tx_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_TX_MC_BYTE_CNT,
6977 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6978 (char*) &(dStats->tx_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_TX_BC_BYTE_CNT,
6981 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6982 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006983 tlen);
6984
Jeff Johnson295189b2012-06-20 16:38:30 -07006985 wrqu->data.length = tlen;
6986
6987 }
6988
6989 EXIT();
6990
6991 return 0;
6992}
6993
6994
6995#ifdef FEATURE_WLAN_SCAN_PNO
6996
6997/*Max Len for PNO notification*/
6998#define MAX_PNO_NOTIFY_LEN 100
6999void found_pref_network_cb (void *callbackContext,
7000 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7001{
7002 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7003 union iwreq_data wrqu;
7004 char buf[MAX_PNO_NOTIFY_LEN+1];
7005
7006 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
7007 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
7008
7009 // create the event
7010 memset(&wrqu, 0, sizeof(wrqu));
7011 memset(buf, 0, sizeof(buf));
7012
7013 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
7014 pPrefNetworkFoundInd->ssId.ssId,
7015 (unsigned int)pPrefNetworkFoundInd->rssi);
7016
7017 wrqu.data.pointer = buf;
7018 wrqu.data.length = strlen(buf);
7019
7020 // send the event
7021
7022 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
7023
7024}
7025
7026
7027/*string based input*/
7028VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
7029 union iwreq_data *wrqu, char *extra, int nOffset)
7030{
7031 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05307032 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07007033 /* pnoRequest is a large struct, so we make it static to avoid stack
7034 overflow. This API is only invoked via ioctl, so it is
7035 serialized by the kernel rtnl_lock and hence does not need to be
7036 reentrant */
7037 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 char *ptr;
7039 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05307040 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7042
7043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7044 "PNO data len %d data %s",
7045 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007046 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007047
7048 if (wrqu->data.length <= nOffset )
7049 {
7050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
7051 return VOS_STATUS_E_FAILURE;
7052 }
7053
7054 pnoRequest.enable = 0;
7055 pnoRequest.ucNetworksCount = 0;
7056 /*-----------------------------------------------------------------------
7057 Input is string based and expected to be like this:
7058
7059 <enabled> <netw_count>
7060 for each network:
7061 <ssid_len> <ssid> <authentication> <encryption>
7062 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
7063 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
7064
7065 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07007066 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 -07007067
7068 this translates into:
7069 -----------------------------
7070 enable PNO
7071 look for 2 networks:
7072 test - with authentication type 0 and encryption type 0,
7073 that can be found on 3 channels: 1 6 and 11 ,
7074 SSID bcast type is unknown (directed probe will be sent if AP not found)
7075 and must meet -40dBm RSSI
7076
7077 test2 - with auth and enrytption type 4/4
7078 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
7079 bcast type is non-bcast (directed probe will be sent)
7080 and must not meet any RSSI threshold
7081
Jeff Johnson8301aa12013-03-28 14:27:29 -07007082 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08007084 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007085
Wilson Yang623f6592013-10-08 16:33:37 -07007086 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
7087 {
7088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7089 "PNO enable input is not valid %s",ptr);
7090 return VOS_STATUS_E_FAILURE;
7091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007092
7093 if ( 0 == pnoRequest.enable )
7094 {
7095 /*Disable PNO*/
7096 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05307097 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7098 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007099 pAdapter->sessionId,
7100 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307101 if (eHAL_STATUS_SUCCESS != status)
7102 {
7103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7104 "%s: failed to disable PNO", __func__);
7105 return VOS_STATUS_E_FAILURE;
7106 }
7107 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007108 return VOS_STATUS_SUCCESS;
7109 }
7110
c_hpothu37f21312014-04-09 21:49:54 +05307111 if (TRUE == pHddCtx->isPnoEnable)
7112 {
7113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7114 FL("already PNO is enabled"));
7115 return -EBUSY;
7116 }
7117 pHddCtx->isPnoEnable = TRUE;
7118
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07007120
7121 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
7122 {
7123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7124 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307125 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007127
7128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7129 "PNO enable %d networks count %d offset %d",
7130 pnoRequest.enable,
7131 pnoRequest.ucNetworksCount,
7132 nOffset);
7133
7134 /* Parameters checking:
7135 ucNetworksCount has to be larger than 0*/
7136 if (( 0 == pnoRequest.ucNetworksCount ) ||
7137 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7138 {
7139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05307140 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 }
7142
7143 ptr += nOffset;
7144
7145 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
7146 {
7147
7148 pnoRequest.aNetworks[i].ssId.length = 0;
7149
Wilson Yang623f6592013-10-08 16:33:37 -07007150 ucParams = sscanf(ptr,"%hhu %n",
7151 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
7152
7153 if (1 != ucParams)
7154 {
7155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7156 "PNO ssid length input is not valid %s",ptr);
7157 return VOS_STATUS_E_FAILURE;
7158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007159
7160 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
7161 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
7162 {
7163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7164 "SSID Len %d is not correct for network %d",
7165 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05307166 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 }
7168
7169 /*Advance to SSID*/
7170 ptr += nOffset;
7171
Jeff Johnson8301aa12013-03-28 14:27:29 -07007172 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08007173 pnoRequest.aNetworks[i].ssId.length);
7174 ptr += pnoRequest.aNetworks[i].ssId.length;
7175
Jeff Johnson02797792013-10-26 19:17:13 -07007176 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08007177 &(pnoRequest.aNetworks[i].authentication),
7178 &(pnoRequest.aNetworks[i].encryption),
7179 &(pnoRequest.aNetworks[i].ucChannelCount),
7180 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007181
Wilson Yang623f6592013-10-08 16:33:37 -07007182 if ( 3 != ucParams )
7183 {
7184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7185 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307186 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007187 }
7188
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007190 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08007191 "auth %d encry %d channel count %d offset %d",
7192 pnoRequest.aNetworks[i].ssId.length,
7193 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
7194 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
7195 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
7196 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
7197 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
7198 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
7199 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
7200 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
7201 pnoRequest.aNetworks[i].authentication,
7202 pnoRequest.aNetworks[i].encryption,
7203 pnoRequest.aNetworks[i].ucChannelCount,
7204 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07007205
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 /*Advance to channel list*/
7207 ptr += nOffset;
7208
Wilson Yang623f6592013-10-08 16:33:37 -07007209 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07007210 {
7211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7212 "Incorrect number of channels");
7213 return VOS_STATUS_E_FAILURE;
7214 }
7215
7216 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
7217 {
7218 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
7219 {
Wilson Yang623f6592013-10-08 16:33:37 -07007220 if (1 != sscanf(ptr,"%hhu %n",
7221 &(pnoRequest.aNetworks[i].aChannels[j]),
7222 &nOffset))
7223 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7224 "PNO network channel input is not valid %s",ptr);
7225 return VOS_STATUS_E_FAILURE;
7226 }
7227 /*Advance to next channel number*/
7228 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 }
7230 }
7231
Jeff Johnson02797792013-10-26 19:17:13 -07007232 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007233 &(pnoRequest.aNetworks[i].bcastNetwType),
7234 &nOffset))
7235 {
7236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7237 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307238 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007240
7241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7242 "PNO bcastNetwType %d offset %d",
7243 pnoRequest.aNetworks[i].bcastNetwType,
7244 nOffset );
7245
7246 /*Advance to rssi Threshold*/
7247 ptr += nOffset;
7248
Wilson Yang623f6592013-10-08 16:33:37 -07007249 if (1 != sscanf(ptr,"%hhu %n",
7250 &(pnoRequest.aNetworks[i].rssiThreshold),
7251 &nOffset))
7252 {
7253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7254 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307255 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007257
7258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7259 "PNO rssi %d offset %d",
7260 pnoRequest.aNetworks[i].rssiThreshold,
7261 nOffset );
7262 /*Advance to next network*/
7263 ptr += nOffset;
7264 }/*For ucNetworkCount*/
7265
7266 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007267 &(pnoRequest.scanTimers.ucScanTimersCount),
7268 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007269
7270 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007271 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 {
7273 ptr += nOffset;
7274
Jeff Johnson8301aa12013-03-28 14:27:29 -07007275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7276 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007277 pnoRequest.scanTimers.ucScanTimersCount,
7278 nOffset );
7279
7280 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7281 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05307284 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007285 }
7286
7287 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7288 {
Jeff Johnson02797792013-10-26 19:17:13 -07007289 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7291 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7292 &nOffset);
7293
Wilson Yang623f6592013-10-08 16:33:37 -07007294 if (2 != ucParams)
7295 {
7296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7297 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05307298 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007299 }
7300
Jeff Johnson8301aa12013-03-28 14:27:29 -07007301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7302 "PNO Timer value %d Timer repeat %d offset %d",
7303 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007304 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7305 nOffset );
7306
Jeff Johnson295189b2012-06-20 16:38:30 -07007307 ptr += nOffset;
7308 }
7309
7310 }
7311 else
7312 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7314 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7316
7317 /*Scan timers defaults to 5 minutes*/
7318 pnoRequest.scanTimers.ucScanTimersCount = 1;
7319 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7320 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7321 }
7322
Wilson Yang623f6592013-10-08 16:33:37 -07007323 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007324
7325 pnoRequest.modePNO = ucMode;
7326 /*for LA we just expose suspend option*/
7327 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7328 {
7329 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7330 }
7331
c_hpothu37f21312014-04-09 21:49:54 +05307332 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007333 pAdapter->sessionId,
7334 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307335 if (eHAL_STATUS_SUCCESS == status)
7336 {
7337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7338 "%s: PNO enabled", __func__);
7339 return VOS_STATUS_SUCCESS;
7340 }
7341error:
7342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7343 "%s: Failed to enable PNO", __func__);
7344 pHddCtx->isPnoEnable = FALSE;
7345 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007346}/*iw_set_pno*/
7347
7348VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7349 union iwreq_data *wrqu, char *extra, int nOffset)
7350{
7351 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7352 v_U8_t rssiThreshold = 0;
7353 v_U8_t nRead;
7354
Arif Hussain7adce1b2013-11-11 22:59:34 -08007355 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 &rssiThreshold);
7357
7358 if ( 1 != nRead )
7359 {
7360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7361 "Incorrect format");
7362 return VOS_STATUS_E_FAILURE;
7363 }
7364
7365 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7366 return VOS_STATUS_SUCCESS;
7367}
7368
7369
7370static int iw_set_pno_priv(struct net_device *dev,
7371 struct iw_request_info *info,
7372 union iwreq_data *wrqu, char *extra)
7373{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007374 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7375
7376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007378
7379 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7380 {
7381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7382 "%s:LOGP in Progress. Ignore!!!", __func__);
7383 return -EBUSY;
7384 }
7385 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007386}
7387#endif /*FEATURE_WLAN_SCAN_PNO*/
7388
7389//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05307390int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007391{
7392 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7393 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7394 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal54378cb2014-04-02 16:51:50 +05307395 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307397 eCsrBand connectedBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007398
Atul Mittal54378cb2014-04-02 16:51:50 +05307399 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 {
7401 case WLAN_HDD_UI_BAND_AUTO:
7402 band = eCSR_BAND_ALL;
7403 break;
7404 case WLAN_HDD_UI_BAND_5_GHZ:
7405 band = eCSR_BAND_5G;
7406 break;
7407 case WLAN_HDD_UI_BAND_2_4_GHZ:
7408 band = eCSR_BAND_24;
7409 break;
7410 default:
7411 band = eCSR_BAND_MAX;
7412 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307413 connectedBand =
7414 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07007415
Atul Mittal54378cb2014-04-02 16:51:50 +05307416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007417 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007418
7419 if (band == eCSR_BAND_MAX)
7420 {
7421 /* Received change band request with invalid band value */
7422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05307423 "%s: Invalid band value %u", __func__, ui_band);
7424 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007425 }
7426
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307427 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7428 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7429 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7430 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007432 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007433 band, pHddCtx->cfg_ini->nBandCapability);
7434 return -EIO;
7435 }
7436
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7438 {
7439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7440 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007441 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007442 return -EIO;
7443 }
7444
7445 if (currBand != band)
7446 {
7447 /* Change band request received.
7448 * Abort pending scan requests, flush the existing scan results,
7449 * and change the band capability
7450 */
7451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7452 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007453 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007454
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307455 /* We need to change the band and flush the scan results here itself
7456 * as we may get timeout for disconnection in which we will return
7457 * with out doing any of these
7458 */
7459 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7460 {
7461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7462 "%s: failed to set the band value to %u ",
7463 __func__, band);
7464 return -EINVAL;
7465 }
7466 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7467 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7468 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7469 sme_FilterScanResults(hHal, pAdapter->sessionId);
7470
7471 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307472 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
7473 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007474 {
7475 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7476 eHalStatus status = eHAL_STATUS_SUCCESS;
7477 long lrc;
7478
7479 /* STA already connected on current band, So issue disconnect first,
7480 * then change the band*/
7481
7482 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05307483 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
7484 " Set HDD connState to eConnectionState_NotConnected",
Jeff Johnson295189b2012-06-20 16:38:30 -07007485 __func__, csrGetCurrentBand(hHal), band);
7486
7487 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7488 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7489
7490 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7491 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7492
Jeff Johnson43971f52012-07-17 12:26:56 -07007493 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 {
7495 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007496 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 __func__, (int)status );
7498 return -EINVAL;
7499 }
7500
7501 lrc = wait_for_completion_interruptible_timeout(
7502 &pAdapter->disconnect_comp_var,
7503 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7504
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307505 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007506
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007507 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007508 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007509
7510 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7511 }
7512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007513 }
7514 return 0;
7515}
7516
Atul Mittal54378cb2014-04-02 16:51:50 +05307517int hdd_setBand_helper(struct net_device *dev, const char *command)
7518{
7519 u8 band;
7520
7521 /*convert the band value from ascii to integer*/
7522 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
7523
7524 return hdd_setBand(dev, band);
7525
7526}
7527
Jeff Johnson295189b2012-06-20 16:38:30 -07007528static int iw_set_band_config(struct net_device *dev,
7529 struct iw_request_info *info,
7530 union iwreq_data *wrqu, char *extra)
7531{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007532 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05307533 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007534
Arif Hussain0273cba2014-01-07 20:58:29 -08007535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007536
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007537 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7538 {
7539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7540 "%s:LOGP in Progress. Ignore!!!", __func__);
7541 return -EBUSY;
7542 }
7543
Atul Mittal54378cb2014-04-02 16:51:50 +05307544 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007545}
7546
7547static int iw_set_power_params_priv(struct net_device *dev,
7548 struct iw_request_info *info,
7549 union iwreq_data *wrqu, char *extra)
7550{
Arif Hussain0273cba2014-01-07 20:58:29 -08007551 int ret;
7552 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7554 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007555 /* ODD number is used for set, copy data using copy_from_user */
7556 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7557 wrqu->data.length);
7558 if (NULL == ptr)
7559 {
7560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7561 "mem_alloc_copy_from_user_helper fail");
7562 return -ENOMEM;
7563 }
7564
7565 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7566 kfree(ptr);
7567 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007568}
7569
7570
7571
7572/*string based input*/
7573VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7574 union iwreq_data *wrqu, char *extra, int nOffset)
7575{
7576 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7577 tSirSetPowerParamsReq powerRequest;
7578 char *ptr;
7579 v_U8_t ucType;
7580 v_U32_t uTotalSize, uValue;
7581 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7582
7583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7584 "Power Params data len %d data %s",
7585 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007586 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007587
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007588 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7589 {
7590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7591 "%s:LOGP in Progress. Ignore!!!", __func__);
7592 return -EBUSY;
7593 }
7594
Jeff Johnson295189b2012-06-20 16:38:30 -07007595 if (wrqu->data.length <= nOffset )
7596 {
7597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7598 return VOS_STATUS_E_FAILURE;
7599 }
7600
7601 uTotalSize = wrqu->data.length - nOffset;
7602
7603 /*-----------------------------------------------------------------------
7604 Input is string based and expected to be like this:
7605
7606 <param_type> <param_value> <param_type> <param_value> ...
7607
7608 e.g:
7609 1 2 2 3 3 0 4 1 5 1
7610
7611 e.g. setting just a few:
7612 1 2 4 1
7613
7614 parameter types:
7615 -----------------------------
7616 1 - Ignore DTIM
7617 2 - Listen Interval
7618 3 - Broadcast Multicas Filter
7619 4 - Beacon Early Termination
7620 5 - Beacon Early Termination Interval
7621 -----------------------------------------------------------------------*/
7622 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7623 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7624 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7625 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7626 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7627
Arif Hussain7adce1b2013-11-11 22:59:34 -08007628 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007629
7630 while ( uTotalSize )
7631 {
Wilson Yang6f971452013-10-08 15:00:00 -07007632 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7633 {
7634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7635 "Invalid input parameter type %s",ptr);
7636 return VOS_STATUS_E_FAILURE;
7637 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007638
7639 uTotalSize -= nOffset;
7640
7641 if (!uTotalSize)
7642 {
7643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007644 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 ucType, nOffset);
7646 return VOS_STATUS_E_FAILURE;
7647 }
7648
7649 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007650
Jeff Johnson02797792013-10-26 19:17:13 -07007651 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007652 {
7653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7654 "Invalid input parameter value %s",ptr);
7655 return VOS_STATUS_E_FAILURE;
7656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007657
7658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7659 "Power request parameter %d value %d offset %d",
7660 ucType, uValue, nOffset);
7661
7662 switch (ucType)
7663 {
7664 case eSIR_IGNORE_DTIM:
7665 powerRequest.uIgnoreDTIM = uValue;
7666 break;
7667 case eSIR_LISTEN_INTERVAL:
7668 powerRequest.uListenInterval = uValue;
7669 break;
7670 case eSIR_MCAST_BCAST_FILTER:
7671 powerRequest.uBcastMcastFilter = uValue;
7672 break;
7673 case eSIR_ENABLE_BET:
7674 powerRequest.uEnableBET = uValue;
7675 break;
7676 case eSIR_BET_INTERVAL:
7677 powerRequest.uBETInterval = uValue;
7678 break;
7679 default:
7680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007681 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 ucType, uValue, nOffset);
7683 return VOS_STATUS_E_FAILURE;
7684 }
7685
7686 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7688 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007689 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007691 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007692 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007693 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7694 {
7695 uTotalSize = 0;
7696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007697
7698 }/*Go for as long as we have a valid string*/
7699
7700 /* put the device into full power*/
7701 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7702
7703 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007704 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007705
7706 /* put the device back to power save*/
7707 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7708
7709 return VOS_STATUS_SUCCESS;
7710}/*iw_set_power_params*/
7711
7712
7713// Define the Wireless Extensions to the Linux Network Device structure
7714// A number of these routines are NULL (meaning they are not implemented.)
7715
7716static const iw_handler we_handler[] =
7717{
7718 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7719 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7720 (iw_handler) NULL, /* SIOCSIWNWID */
7721 (iw_handler) NULL, /* SIOCGIWNWID */
7722 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7723 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7724 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7725 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7726 (iw_handler) NULL, /* SIOCSIWSENS */
7727 (iw_handler) NULL, /* SIOCGIWSENS */
7728 (iw_handler) NULL, /* SIOCSIWRANGE */
7729 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7730 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7731 (iw_handler) NULL, /* SIOCGIWPRIV */
7732 (iw_handler) NULL, /* SIOCSIWSTATS */
7733 (iw_handler) NULL, /* SIOCGIWSTATS */
7734 iw_handler_set_spy, /* SIOCSIWSPY */
7735 iw_handler_get_spy, /* SIOCGIWSPY */
7736 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7737 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7738 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7739 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7740 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7741 (iw_handler) NULL, /* SIOCGIWAPLIST */
7742 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7743 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7744 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7745 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7746 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7747 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7748 (iw_handler) NULL, /* -- hole -- */
7749 (iw_handler) NULL, /* -- hole -- */
7750 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7751 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7752 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7753 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7754 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7755 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7756 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7757 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7758 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7759 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7760 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7761 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7762 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7763 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7764 (iw_handler) NULL, /* -- hole -- */
7765 (iw_handler) NULL, /* -- hole -- */
7766 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7767 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7768 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7769 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7770 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7771 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7772 (iw_handler) NULL, /* SIOCSIWPMKSA */
7773};
7774
7775static const iw_handler we_private[] = {
7776
7777 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7778 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7779 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7780 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7781 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7782 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7783 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7784 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7785 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7786 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007787#ifdef FEATURE_OEM_DATA_SUPPORT
7788 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7789 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7790#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007791
7792#ifdef FEATURE_WLAN_WAPI
7793 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7794 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7795 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7796 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7797 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7798 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7799#endif /* FEATURE_WLAN_WAPI */
7800#ifdef WLAN_FEATURE_VOWIFI_11R
7801 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7802#endif
7803 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7804 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7805 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7806#ifdef WLAN_FEATURE_PACKET_FILTERING
7807 ,
7808 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7809#endif
7810#ifdef FEATURE_WLAN_SCAN_PNO
7811 ,
7812 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7813#endif
7814 ,
7815 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7816 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7817 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7818 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07007819 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07007820};
7821
7822/*Maximum command length can be only 15 */
7823static const struct iw_priv_args we_private_args[] = {
7824
7825 /* handlers for main ioctl */
7826 { WLAN_PRIV_SET_INT_GET_NONE,
7827 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7828 0,
7829 "" },
7830
7831 /* handlers for sub-ioctl */
7832 { WE_SET_11D_STATE,
7833 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7834 0,
7835 "set11Dstate" },
7836
7837 { WE_WOWL,
7838 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7839 0,
7840 "wowl" },
7841
7842 { WE_SET_POWER,
7843 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7844 0,
7845 "setPower" },
7846
7847 { WE_SET_MAX_ASSOC,
7848 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7849 0,
7850 "setMaxAssoc" },
7851
7852 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7853 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7854 0,
7855 "setAutoChannel" },
7856
7857 { WE_SET_DATA_INACTIVITY_TO,
7858 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7859 0,
7860 "inactivityTO" },
7861
7862 { WE_SET_MAX_TX_POWER,
7863 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7864 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007865 "setMaxTxPower" },
7866
7867 { WE_SET_MAX_TX_POWER_2_4,
7868 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7869 0,
7870 "setTxMaxPower2G" },
7871
7872 { WE_SET_MAX_TX_POWER_5_0,
7873 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7874 0,
7875 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007876
7877 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7878 * as well to keep same syntax as in SAP. Now onwards, STA
7879 * will support both */
7880 { WE_SET_MAX_TX_POWER,
7881 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7882 0,
7883 "setTxMaxPower" },
7884
Jeff Johnson295189b2012-06-20 16:38:30 -07007885 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7886 * 1 = enable and 0 = disable */
7887 {
7888 WE_SET_HIGHER_DTIM_TRANSITION,
7889 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7890 0,
7891 "setHDtimTransn" },
7892
7893 { WE_SET_TM_LEVEL,
7894 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007895 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 "setTmLevel" },
7897
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307898 { WE_ENABLE_STRICT_FCC_REG,
7899 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7900 0,
7901 "setStrictFCCreg" },
7902
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007903 { WE_SET_DEBUG_LOG,
7904 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7905 0, "setDbgLvl" },
7906
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 /* handlers for main ioctl */
7908 { WLAN_PRIV_SET_NONE_GET_INT,
7909 0,
7910 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7911 "" },
7912
7913 /* handlers for sub-ioctl */
7914 { WE_GET_11D_STATE,
7915 0,
7916 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7917 "get11Dstate" },
7918
7919 { WE_IBSS_STATUS,
7920 0,
7921 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7922 "getAdhocStatus" },
7923
7924 { WE_PMC_STATE,
7925 0,
7926 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7927 "pmcState" },
7928
7929 { WE_GET_WLAN_DBG,
7930 0,
7931 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7932 "getwlandbg" },
7933
7934 { WE_MODULE_DOWN_IND,
7935 0,
7936 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7937 "moduleDownInd" },
7938
7939 { WE_GET_MAX_ASSOC,
7940 0,
7941 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7942 "getMaxAssoc" },
7943
Jeff Johnson295189b2012-06-20 16:38:30 -07007944 { WE_GET_WDI_DBG,
7945 0,
7946 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7947 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007948
7949 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7950 0,
7951 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7952 "getAutoChannel" },
7953
7954 { WE_GET_CONCURRENCY_MODE,
7955 0,
7956 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7957 "getconcurrency" },
7958
7959 /* handlers for main ioctl */
7960 { WLAN_PRIV_SET_CHAR_GET_NONE,
7961 IW_PRIV_TYPE_CHAR| 512,
7962 0,
7963 "" },
7964
7965 /* handlers for sub-ioctl */
7966 { WE_WOWL_ADD_PTRN,
7967 IW_PRIV_TYPE_CHAR| 512,
7968 0,
7969 "wowlAddPtrn" },
7970
7971 { WE_WOWL_DEL_PTRN,
7972 IW_PRIV_TYPE_CHAR| 512,
7973 0,
7974 "wowlDelPtrn" },
7975
7976#if defined WLAN_FEATURE_VOWIFI
7977 /* handlers for sub-ioctl */
7978 { WE_NEIGHBOR_REPORT_REQUEST,
7979 IW_PRIV_TYPE_CHAR | 512,
7980 0,
7981 "neighbor" },
7982#endif
7983 { WE_SET_AP_WPS_IE,
7984 IW_PRIV_TYPE_CHAR| 512,
7985 0,
7986 "set_ap_wps_ie" },
7987
7988 { WE_SET_CONFIG,
7989 IW_PRIV_TYPE_CHAR| 512,
7990 0,
7991 "setConfig" },
7992
7993 /* handlers for main ioctl */
7994 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7995 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7996 0,
7997 "" },
7998
7999 /* handlers for sub-ioctl */
8000 { WE_SET_WLAN_DBG,
8001 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8002 0,
8003 "setwlandbg" },
8004
Jeff Johnson295189b2012-06-20 16:38:30 -07008005 { WE_SET_WDI_DBG,
8006 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8007 0,
8008 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008009
8010 { WE_SET_SAP_CHANNELS,
8011 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8012 0,
8013 "setsapchannels" },
8014
8015 /* handlers for main ioctl */
8016 { WLAN_PRIV_GET_CHAR_SET_NONE,
8017 0,
8018 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8019 "" },
8020
8021 /* handlers for sub-ioctl */
8022 { WE_WLAN_VERSION,
8023 0,
8024 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8025 "version" },
8026 { WE_GET_STATS,
8027 0,
8028 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8029 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308030 { WE_GET_STATES,
8031 0,
8032 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8033 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008034 { WE_GET_CFG,
8035 0,
8036 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8037 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07008038#ifdef WLAN_FEATURE_11AC
8039 { WE_GET_RSSI,
8040 0,
8041 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8042 "getRSSI" },
8043#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008044#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008045 { WE_GET_ROAM_RSSI,
8046 0,
8047 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8048 "getRoamRSSI" },
8049#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 { WE_GET_WMM_STATUS,
8051 0,
8052 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8053 "getWmmStatus" },
8054 {
8055 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308056 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07008057 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8058 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08008059#ifdef FEATURE_WLAN_TDLS
8060 {
8061 WE_GET_TDLS_PEERS,
8062 0,
8063 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8064 "getTdlsPeers" },
8065#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008066#ifdef WLAN_FEATURE_11W
8067 {
8068 WE_GET_11W_INFO,
8069 0,
8070 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8071 "getPMFInfo" },
8072#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 /* handlers for main ioctl */
8074 { WLAN_PRIV_SET_NONE_GET_NONE,
8075 0,
8076 0,
8077 "" },
8078
8079 /* handlers for sub-ioctl */
8080 { WE_CLEAR_STATS,
8081 0,
8082 0,
8083 "clearStats" },
8084 { WE_INIT_AP,
8085 0,
8086 0,
8087 "initAP" },
8088 { WE_STOP_AP,
8089 0,
8090 0,
8091 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308092#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 { WE_ENABLE_AMP,
8094 0,
8095 0,
8096 "enableAMP" },
8097 { WE_DISABLE_AMP,
8098 0,
8099 0,
8100 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308101#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07008102 { WE_ENABLE_DXE_STALL_DETECT,
8103 0,
8104 0,
8105 "dxeStallDetect" },
8106 { WE_DISPLAY_DXE_SNAP_SHOT,
8107 0,
8108 0,
8109 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308110 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
8111 0,
8112 0,
8113 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07008114 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05308115 WE_STOP_OBSS_SCAN,
8116 0,
8117 0,
8118 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008119
8120 /* handlers for main ioctl */
8121 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
8122 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8123 0,
8124 "" },
8125
8126 /* handlers for sub-ioctl */
8127 { WE_LOG_DUMP_CMD,
8128 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8129 0,
8130 "dump" },
8131
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008132 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308133 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
8134 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8135 0,
8136 "setdumplog" },
8137
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008138 { WE_MTRACE_DUMP_CMD,
8139 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8140 0,
8141 "dumplog" },
8142
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008143 /* handlers for sub ioctl */
8144 {
8145 WE_MCC_CONFIG_CREDENTIAL,
8146 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8147 0,
8148 "setMccCrdnl" },
8149
8150 /* handlers for sub ioctl */
8151 {
8152 WE_MCC_CONFIG_PARAMS,
8153 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8154 0,
8155 "setMccConfig" },
8156
Chilam NG571c65a2013-01-19 12:27:36 +05308157#ifdef FEATURE_WLAN_TDLS
8158 /* handlers for sub ioctl */
8159 {
8160 WE_TDLS_CONFIG_PARAMS,
8161 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8162 0,
8163 "setTdlsConfig" },
8164#endif
8165
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 /* handlers for main ioctl */
8167 { WLAN_PRIV_ADD_TSPEC,
8168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
8169 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8170 "addTspec" },
8171
8172 /* handlers for main ioctl */
8173 { WLAN_PRIV_DEL_TSPEC,
8174 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8176 "delTspec" },
8177
8178 /* handlers for main ioctl */
8179 { WLAN_PRIV_GET_TSPEC,
8180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8181 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8182 "getTspec" },
8183
Jeff Johnsone7245742012-09-05 17:12:55 -07008184#ifdef FEATURE_OEM_DATA_SUPPORT
8185 /* handlers for main ioctl - OEM DATA */
8186 {
8187 WLAN_PRIV_SET_OEM_DATA_REQ,
8188 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
8189 0,
8190 "set_oem_data_req" },
8191
8192 /* handlers for main ioctl - OEM DATA */
8193 {
8194 WLAN_PRIV_GET_OEM_DATA_RSP,
8195 0,
8196 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8197 "get_oem_data_rsp" },
8198#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008199
8200#ifdef FEATURE_WLAN_WAPI
8201 /* handlers for main ioctl SET_WAPI_MODE */
8202 { WLAN_PRIV_SET_WAPI_MODE,
8203 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8204 0,
8205 "SET_WAPI_MODE" },
8206
8207 /* handlers for main ioctl GET_WAPI_MODE */
8208 { WLAN_PRIV_GET_WAPI_MODE,
8209 0,
8210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8211 "GET_WAPI_MODE" },
8212
8213 /* handlers for main ioctl SET_ASSOC_INFO */
8214 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
8215 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
8216 0,
8217 "SET_WAPI_ASSOC" },
8218
8219 /* handlers for main ioctl SET_WAPI_KEY */
8220 { WLAN_PRIV_SET_WAPI_KEY,
8221 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
8222 0,
8223 "SET_WAPI_KEY" },
8224
8225 /* handlers for main ioctl SET_WAPI_BKID */
8226 { WLAN_PRIV_SET_WAPI_BKID,
8227 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8228 0,
8229 "SET_WAPI_BKID" },
8230
8231 /* handlers for main ioctl GET_WAPI_BKID */
8232 { WLAN_PRIV_GET_WAPI_BKID,
8233 0,
8234 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8235 "GET_WAPI_BKID" },
8236#endif /* FEATURE_WLAN_WAPI */
8237
8238 /* handlers for main ioctl - host offload */
8239 {
8240 WLAN_PRIV_SET_HOST_OFFLOAD,
8241 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8242 0,
8243 "setHostOffload" },
8244
8245 {
8246 WLAN_GET_WLAN_STATISTICS,
8247 0,
8248 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8249 "getWlanStats" },
8250
8251 {
8252 WLAN_SET_KEEPALIVE_PARAMS,
8253 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8254 0,
8255 "setKeepAlive" },
8256#ifdef WLAN_FEATURE_PACKET_FILTERING
8257 {
8258 WLAN_SET_PACKET_FILTER_PARAMS,
8259 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8260 0,
8261 "setPktFilter" },
8262#endif
8263#ifdef FEATURE_WLAN_SCAN_PNO
8264 {
8265 WLAN_SET_PNO,
8266 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8267 0,
8268 "setpno" },
8269#endif
8270 {
8271 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05308272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 0,
8274 "SETBAND" },
8275 /* handlers for dynamic MC BC ioctl */
8276 {
8277 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008278 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 0,
8280 "setMCBCFilter" },
8281 {
8282 WLAN_PRIV_CLEAR_MCBC_FILTER,
8283 0,
8284 0,
8285 "clearMCBCFilter" },
8286 {
8287 WLAN_SET_POWER_PARAMS,
8288 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8289 0,
8290 "setpowerparams" },
8291 {
8292 WLAN_GET_LINK_SPEED,
8293 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308294 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008295};
8296
8297
8298
8299const struct iw_handler_def we_handler_def = {
8300 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8301 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8302 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8303
8304 .standard = (iw_handler *)we_handler,
8305 .private = (iw_handler *)we_private,
8306 .private_args = we_private_args,
8307 .get_wireless_stats = get_wireless_stats,
8308};
8309
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008310int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8311{
8312 v_U32_t cmd = 288; //Command to RIVA
8313 hdd_context_t *pHddCtx = NULL;
8314 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8315 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8316 /*
8317 *configMccParam : specify the bit which needs to be modified
8318 *allowed to update based on wlan_qcom_cfg.ini
8319 * configuration
8320 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8321 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8322 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8323 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8324 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8325 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8326 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8327 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8328 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8329 * Bit 9 : Reserved
8330 */
8331 switch (arg1)
8332 {
8333 //Update MCC SCHEDULE_TIME_SLICE parameter
8334 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8335 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8336 {
8337 if((arg2 >= 5) && (arg2 <= 20))
8338 {
8339 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8340 }
8341 else
8342 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008343 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008344 return 0;
8345 }
8346 }
8347 break;
8348
8349 //Update MCC MAX_NULL_SEND_TIME parameter
8350 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8351 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8352 {
8353 if((arg2 >= 1) && (arg2 <= 10))
8354 {
8355 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8356 }
8357 else
8358 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008359 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008360 return 0;
8361 }
8362 }
8363 break;
8364
8365 //Update MCC TX_EARLY_STOP_TIME parameter
8366 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8367 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8368 {
8369 if((arg2 >= 1) && (arg2 <= 10))
8370 {
8371 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8372 }
8373 else
8374 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008375 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008376 return 0;
8377 }
8378 }
8379 break;
8380
8381 //Update MCC RX_DRAIN_TIME parameter
8382 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8383 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8384 {
8385 if((arg2 >= 1) && (arg2 <= 10))
8386 {
8387 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8388 }
8389 else
8390 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008391 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008392 return 0;
8393 }
8394 }
8395 break;
8396
8397 //Update MCC CHANNEL_SWITCH_TIME parameter
8398 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8399 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8400 {
8401 if((arg2 >= 1) && (arg2 <= 20))
8402 {
8403 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8404 }
8405 else
8406 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008407 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008408 return 0;
8409 }
8410 }
8411 break;
8412
8413 //Update MCC MIN_CHANNEL_TIME parameter
8414 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8415 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8416 {
8417 if((arg2 >= 5) && (arg2 <= 20))
8418 {
8419 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8420 }
8421 else
8422 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008423 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008424 return 0;
8425 }
8426 }
8427 break;
8428
8429 //Update MCC PARK_BEFORE_TBTT parameter
8430 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8431 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8432 {
8433 if((arg2 >= 1) && (arg2 <= 5))
8434 {
8435 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8436 }
8437 else
8438 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008439 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008440 return 0;
8441 }
8442 }
8443 break;
8444
8445 //Update MCC MIN_AFTER_DTIM parameter
8446 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8447 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8448 {
8449 if((arg2 >= 5) && (arg2 <= 15))
8450 {
8451 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8452 }
8453 else
8454 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008455 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008456 return 0;
8457 }
8458 }
8459 break;
8460
8461 //Update MCC TOO_CLOSE_MARGIN parameter
8462 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8463 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8464 {
8465 if((arg2 >= 1) && (arg2 <= 3))
8466 {
8467 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8468 }
8469 else
8470 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008471 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008472 return 0;
8473 }
8474 }
8475 break;
8476
8477 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008478 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008479 __FUNCTION__,arg1);
8480 break;
8481 }
8482 return 0;
8483}
8484
Jeff Johnson295189b2012-06-20 16:38:30 -07008485int hdd_set_wext(hdd_adapter_t *pAdapter)
8486{
8487 hdd_wext_state_t *pwextBuf;
8488 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008489 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008490
8491 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8492
8493 // Now configure the roaming profile links. To SSID and bssid.
8494 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8495 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8496
8497 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8498 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8499
8500 /*Set the numOfChannels to zero to scan all the channels*/
8501 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8502 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8503
8504 /* Default is no encryption */
8505 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8506 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8507
8508 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8509 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8510
8511 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8512
8513 /* Default is no authentication */
8514 pwextBuf->roamProfile.AuthType.numEntries = 1;
8515 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8516
8517 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8518 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8519
8520 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008521 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008522
8523 hdd_clearRoamProfileIe(pAdapter);
8524
8525 return VOS_STATUS_SUCCESS;
8526
8527 }
8528
8529int hdd_register_wext(struct net_device *dev)
8530 {
8531 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8532 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8533 VOS_STATUS status;
8534
8535 ENTER();
8536
8537 // Zero the memory. This zeros the profile structure.
8538 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8539
8540 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8541
8542
8543 status = hdd_set_wext(pAdapter);
8544
8545 if(!VOS_IS_STATUS_SUCCESS(status)) {
8546
Arif Hussain6d2a3322013-11-17 19:50:10 -08008547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008548 return eHAL_STATUS_FAILURE;
8549 }
8550
8551 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8552 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008554 return eHAL_STATUS_FAILURE;
8555 }
8556
8557 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8558 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 return eHAL_STATUS_FAILURE;
8561 }
8562
8563 // Register as a wireless device
8564 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8565
8566 EXIT();
8567 return 0;
8568}
8569
8570int hdd_UnregisterWext(struct net_device *dev)
8571{
8572#if 0
8573 hdd_wext_state_t *wextBuf;
8574 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8575
8576 ENTER();
8577 // Set up the pointer to the Wireless Extensions state structure
8578 wextBuf = pAdapter->pWextState;
8579
8580 // De-allocate the Wireless Extensions state structure
8581 kfree(wextBuf);
8582
8583 // Clear out the pointer to the Wireless Extensions state structure
8584 pAdapter->pWextState = NULL;
8585
8586 EXIT();
8587#endif
8588 dev->wireless_handlers = NULL;
8589 return 0;
8590}
8591
8592