blob: 91a97b0f8bef8074430ca5f38c6783d35421d49b [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Arif Hussain0273cba2014-01-07 20:58:29 -08002 * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/** ------------------------------------------------------------------------ *
43 ------------------------------------------------------------------------ *
44
45
46 \file wlan_hdd_wext.c
47
48 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
49 interfaces.
50
51 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
52
53 Copyright (C) 2007 Airgo Networks, Incorporated
54
55 This file defines all of the types that are utilized by the CCP module
56 of the "Portable" HDD. This file also includes the underlying Linux
57 Wireless Extensions Data types referred to by CCP.
58
59 ======================================================================== */
60
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053066#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include <wlan_hdd_includes.h>
68#include <wlan_btc_svc.h>
69#include <wlan_nlink_common.h>
70#ifdef WLAN_BTAMP_FEATURE
71#include <bap_hdd_main.h>
72#endif
73#include <vos_api.h>
74#include <net/arp.h>
75#include "ccmApi.h"
76#include "sirParams.h"
77#include "csrApi.h"
78#include "csrInsideApi.h"
79#if defined WLAN_FEATURE_VOWIFI
80#include "smeRrmInternal.h"
81#endif
82#include <aniGlobal.h>
83#include "dot11f.h"
84#include <wlan_hdd_wowl.h>
85#include <wlan_hdd_cfg.h>
86#include <wlan_hdd_wmm.h>
87#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070088#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053089#ifdef FEATURE_WLAN_TDLS
90#include "wlan_hdd_tdls.h"
91#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070092
93#ifdef CONFIG_HAS_EARLYSUSPEND
94#include <linux/earlysuspend.h>
95#endif
96#include "wlan_hdd_power.h"
97#include "qwlan_version.h"
98#include <vos_power.h>
99#include "wlan_hdd_host_offload.h"
100#include "wlan_hdd_keep_alive.h"
101#ifdef WLAN_FEATURE_PACKET_FILTERING
102#include "wlan_hdd_packet_filtering.h"
103#endif
104
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#include <linux/wireless.h>
106#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -0700107#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530108#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
110#include "wlan_hdd_misc.h"
111#include "bap_hdd_misc.h"
112
113#include "wlan_hdd_dev_pwr.h"
114#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530115#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700116#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118#ifdef CONFIG_HAS_EARLYSUSPEND
119extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
120extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
121#endif
122
Jeff Johnsone7245742012-09-05 17:12:55 -0700123#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800124#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700125#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700126
127#define HDD_FINISH_ULA_TIME_OUT 800
128
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700129
Jeff Johnson295189b2012-06-20 16:38:30 -0700130extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
131int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
132
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700133static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700134module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
135
Jeff Johnson295189b2012-06-20 16:38:30 -0700136/* To Validate Channel against the Frequency and Vice-Versa */
137static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
138 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
139 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
140 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
141 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
142 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
143 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
144 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
145 {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} };
146
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800147#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700148
149/* Private ioctls and their sub-ioctls */
150#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
151#define WE_SET_11D_STATE 1
152#define WE_WOWL 2
153#define WE_SET_POWER 3
154#define WE_SET_MAX_ASSOC 4
155#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
156#define WE_SET_DATA_INACTIVITY_TO 6
157#define WE_SET_MAX_TX_POWER 7
158#define WE_SET_HIGHER_DTIM_TRANSITION 8
159#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530160#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700161#define WE_SET_MAX_TX_POWER_2_4 11
162#define WE_SET_MAX_TX_POWER_5_0 12
Jeff Johnson295189b2012-06-20 16:38:30 -0700163
164/* Private ioctls and their sub-ioctls */
165#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
166#define WE_GET_11D_STATE 1
167#define WE_IBSS_STATUS 2
168#define WE_PMC_STATE 3
169#define WE_GET_WLAN_DBG 4
170#define WE_MODULE_DOWN_IND 5
171#define WE_GET_MAX_ASSOC 6
172#define WE_GET_WDI_DBG 7
173#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
174#define WE_GET_CONCURRENCY_MODE 9
175/* Private ioctls and their sub-ioctls */
176#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
177
178/* Private ioctls and their sub-ioctls */
179#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
180#define WE_WOWL_ADD_PTRN 1
181#define WE_WOWL_DEL_PTRN 2
182#if defined WLAN_FEATURE_VOWIFI
183#define WE_NEIGHBOR_REPORT_REQUEST 3
184#endif
185#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
186#define WE_SET_CONFIG 5
187
188/* Private ioctls and their sub-ioctls */
189#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
190#define WE_SET_WLAN_DBG 1
191#define WE_SET_WDI_DBG 2
192#define WE_SET_SAP_CHANNELS 3
193
194/* Private ioctls and their sub-ioctls */
195#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
196#define WE_WLAN_VERSION 1
197#define WE_GET_STATS 2
198#define WE_GET_CFG 3
199#define WE_GET_WMM_STATUS 4
200#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700201#ifdef WLAN_FEATURE_11AC
202#define WE_GET_RSSI 6
203#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800204#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800205#ifdef FEATURE_WLAN_TDLS
206#define WE_GET_TDLS_PEERS 8
207#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700208#ifdef WLAN_FEATURE_11W
209#define WE_GET_11W_INFO 9
210#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530211#define WE_GET_STATES 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700212
213/* Private ioctls and their sub-ioctls */
214#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
215#define WE_CLEAR_STATS 1
216#define WE_INIT_AP 2
217#define WE_STOP_AP 3
218#define WE_ENABLE_AMP 4
219#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700220#define WE_ENABLE_DXE_STALL_DETECT 6
221#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530222#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700223#define WE_SET_REASSOC_TRIGGER 8
Jeff Johnson295189b2012-06-20 16:38:30 -0700224
225/* Private ioctls and their sub-ioctls */
226#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
227#define WE_LOG_DUMP_CMD 1
228
Jeff Johnson295189b2012-06-20 16:38:30 -0700229#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800230//IOCTL to configure MCC params
231#define WE_MCC_CONFIG_CREDENTIAL 3
232#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
Chilam NG571c65a2013-01-19 12:27:36 +0530234#ifdef FEATURE_WLAN_TDLS
235#define WE_TDLS_CONFIG_PARAMS 5
236#endif
237
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700238#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530239#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700240
Chilam Ng01120412013-02-19 18:32:21 -0800241#ifdef FEATURE_WLAN_TDLS
242#undef MAX_VAR_ARGS
243#define MAX_VAR_ARGS 10
244#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700245#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800246#endif
247
Jeff Johnson295189b2012-06-20 16:38:30 -0700248
249/* Private ioctls (with no sub-ioctls) */
250/* note that they must be odd so that they have "get" semantics */
251#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
252#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
253#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
254
255#ifdef FEATURE_WLAN_WAPI
256/* Private ioctls EVEN NO: SET, ODD NO:GET */
257#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
258#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
259#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
260#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
261#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
262#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
263#define WAPI_PSK_AKM_SUITE 0x02721400
264#define WAPI_CERT_AKM_SUITE 0x01721400
265#endif
266
Jeff Johnsone7245742012-09-05 17:12:55 -0700267#ifdef FEATURE_OEM_DATA_SUPPORT
268/* Private ioctls for setting the measurement configuration */
269#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
270#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
271#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700272
273#ifdef WLAN_FEATURE_VOWIFI_11R
274#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
275#endif
276
277/* Private ioctl for setting the host offload feature */
278#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
279
280/* Private ioctl to get the statistics */
281#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
282
283/* Private ioctl to set the Keep Alive Params */
284#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
285#ifdef WLAN_FEATURE_PACKET_FILTERING
286/* Private ioctl to set the Packet Filtering Params */
287#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
288#endif
289
290#ifdef FEATURE_WLAN_SCAN_PNO
291/* Private ioctl to get the statistics */
292#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
293#endif
294
295#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
296
297#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
298#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700299/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700300
Jeff Johnson295189b2012-06-20 16:38:30 -0700301#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
302#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
303
304#define WLAN_STATS_INVALID 0
305#define WLAN_STATS_RETRY_CNT 1
306#define WLAN_STATS_MUL_RETRY_CNT 2
307#define WLAN_STATS_TX_FRM_CNT 3
308#define WLAN_STATS_RX_FRM_CNT 4
309#define WLAN_STATS_FRM_DUP_CNT 5
310#define WLAN_STATS_FAIL_CNT 6
311#define WLAN_STATS_RTS_FAIL_CNT 7
312#define WLAN_STATS_ACK_FAIL_CNT 8
313#define WLAN_STATS_RTS_SUC_CNT 9
314#define WLAN_STATS_RX_DISCARD_CNT 10
315#define WLAN_STATS_RX_ERROR_CNT 11
316#define WLAN_STATS_TX_BYTE_CNT 12
317
318#define WLAN_STATS_RX_BYTE_CNT 13
319#define WLAN_STATS_RX_RATE 14
320#define WLAN_STATS_TX_RATE 15
321
Jeff Johnsone7245742012-09-05 17:12:55 -0700322#define WLAN_STATS_RX_UC_BYTE_CNT 16
323#define WLAN_STATS_RX_MC_BYTE_CNT 17
324#define WLAN_STATS_RX_BC_BYTE_CNT 18
325#define WLAN_STATS_TX_UC_BYTE_CNT 19
326#define WLAN_STATS_TX_MC_BYTE_CNT 20
327#define WLAN_STATS_TX_BC_BYTE_CNT 21
328
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800329#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
330 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
331 { \
332 *__p++ = __type; \
333 *__p++ = __size; \
334 memcpy(__p, __val, __size); \
335 __p += __size; \
336 __tlen += __size + 2; \
337 } \
338 else \
339 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800340 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800341 } \
342 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700343
344#define VERSION_VALUE_MAX_LEN 32
345
346#define TX_PER_TRACKING_DEFAULT_RATIO 5
347#define TX_PER_TRACKING_MAX_RATIO 10
348#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
349
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530350#define WLAN_ADAPTER 0
351#define P2P_ADAPTER 1
352
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800353/*MCC Configuration parameters */
354enum {
355 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
356 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
357 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
358 MCC_RX_DRAIN_TIME_CFG_PARAM,
359 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
360 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
361 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
362 MCC_MIN_AFTER_DTIM_CFG_PARAM,
363 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
364};
365
366int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
367 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
368
Jeff Johnson295189b2012-06-20 16:38:30 -0700369#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800370int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700371 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700372#endif
373
Jeff Johnson295189b2012-06-20 16:38:30 -0700374/**---------------------------------------------------------------------------
375
Arif Hussain0273cba2014-01-07 20:58:29 -0800376 \brief mem_alloc_copy_from_user_helper -
377
378 Helper function to allocate buffer and copy user data.
379
380 \param - wrqu - Pointer to IOCTL Data.
381 len - size
382
383 \return - On Success pointer to buffer, On failure NULL
384
385 --------------------------------------------------------------------------*/
386static void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
387{
388 u8 *ptr = NULL;
389
390 /* in order to protect the code, an extra byte is post appended to the buffer
391 * and the null termination is added. However, when allocating (len+1) byte
392 * of memory, we need to make sure that there is no uint overflow when doing
393 * addition. In theory check len < UINT_MAX protects the uint overflow. For
394 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
395 * guess, now, it is assumed that the private command buffer size is no
396 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
397 */
398 if (len > MAX_USER_COMMAND_SIZE)
399 {
400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
401 "Invalid length");
402 return NULL;
403 }
404
405 ptr = kmalloc(len + 1, GFP_KERNEL);
406 if (NULL == ptr)
407 {
408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
409 "unable to allocate memory");
410 return NULL;
411 }
412
413 if (copy_from_user(ptr, wrqu_data, len))
414 {
415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
416 "%s: failed to copy data to user buffer", __func__);
417 kfree(ptr);
418 return NULL;
419 }
420 ptr[len] = '\0';
421 return ptr;
422}
423
424/**---------------------------------------------------------------------------
425
Jeff Johnson295189b2012-06-20 16:38:30 -0700426 \brief hdd_wlan_get_version() -
427
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800428 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700429
430 \param - pAdapter Pointer to the adapter.
431 wrqu - Pointer to IOCTL REQUEST Data.
432 extra - Pointer to char
433
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800434 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700435
436 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800437void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
438 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700439{
440 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800441 tSirVersionString wcnss_SW_version;
442 tSirVersionString wcnss_HW_version;
443 char *pSWversion;
444 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700446
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800447 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
448 sizeof(wcnss_SW_version));
449 if (VOS_IS_STATUS_SUCCESS(status))
450 {
451 pSWversion = wcnss_SW_version;
452 }
453 else
454 {
455 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 }
457
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800458 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
459 sizeof(wcnss_HW_version));
460 if (VOS_IS_STATUS_SUCCESS(status))
461 {
462 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700463 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800464 else
465 {
466 pHWversion = "Unknown";
467 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700468
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700469 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800470 "Host SW:%s, FW:%s, HW:%s",
471 QWLAN_VERSIONSTR,
472 pSWversion,
473 pHWversion);
474
475 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700476}
477
Jeff Johnson295189b2012-06-20 16:38:30 -0700478int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
479{
480 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
481 v_U32_t threshold = 0,status = 0;
482
483 ENTER();
484
Agarwal Ashish971c2882013-10-30 20:11:12 +0530485 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
486 {
487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 "%s:LOGP in Progress. Ignore!!!",__func__);
489 return status;
490 }
491
492 if ( eHAL_STATUS_SUCCESS !=
493 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
494 {
495 return -EIO;
496 }
497 wrqu->rts.value = threshold;
498
499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800500 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700501
502 EXIT();
503
504 return 0;
505}
506
507int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
508{
509 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
510 v_U32_t threshold = 0,status = 0;
511
512 ENTER();
513
Agarwal Ashish971c2882013-10-30 20:11:12 +0530514 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
515 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
517 "%s:LOGP in Progress. Ignore!!!",__func__);
518 return status;
519 }
520
521 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
522 != eHAL_STATUS_SUCCESS )
523 {
524 return -EIO;
525 }
526 wrqu->frag.value = threshold;
527
528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800529 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700530
531 EXIT();
532
533 return 0;
534}
535
536int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
537{
Jeff Johnsone7245742012-09-05 17:12:55 -0700538 int i;
539 if (channel > 0)
540 {
541 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
542 {
543 if (channel == freq_chan_map[i].chan)
544 {
545 *pfreq = freq_chan_map[i].freq;
546 return 1;
547 }
548 }
549 }
550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800551 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700552 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700553}
554
555static v_BOOL_t
556hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
557{
558 v_BOOL_t rsnType = VOS_FALSE;
559 // is the authType supported?
560 switch (authType)
561 {
562 case eCSR_AUTH_TYPE_NONE: //never used
563 rsnType = eANI_BOOLEAN_FALSE;
564 break;
565 // MAC layer authentication types
566 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
567 rsnType = eANI_BOOLEAN_FALSE;
568 break;
569 case eCSR_AUTH_TYPE_SHARED_KEY:
570 rsnType = eANI_BOOLEAN_FALSE;
571 break;
572 case eCSR_AUTH_TYPE_AUTOSWITCH:
573 rsnType = eANI_BOOLEAN_FALSE;
574 break;
575
576 // Upper layer authentication types
577 case eCSR_AUTH_TYPE_WPA:
578 rsnType = eANI_BOOLEAN_TRUE;
579 break;
580 case eCSR_AUTH_TYPE_WPA_PSK:
581 rsnType = eANI_BOOLEAN_TRUE;
582 break;
583 case eCSR_AUTH_TYPE_WPA_NONE:
584 rsnType = eANI_BOOLEAN_TRUE;
585 break;
586#ifdef WLAN_FEATURE_VOWIFI_11R
587 case eCSR_AUTH_TYPE_FT_RSN:
588#endif
589 case eCSR_AUTH_TYPE_RSN:
590 rsnType = eANI_BOOLEAN_TRUE;
591 break;
592#ifdef WLAN_FEATURE_VOWIFI_11R
593 case eCSR_AUTH_TYPE_FT_RSN_PSK:
594#endif
595 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700596#ifdef WLAN_FEATURE_11W
597 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
598#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 rsnType = eANI_BOOLEAN_TRUE;
600 break;
601 //case eCSR_AUTH_TYPE_FAILED:
602 case eCSR_AUTH_TYPE_UNKNOWN:
603 rsnType = eANI_BOOLEAN_FALSE;
604 break;
605 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800606 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
607 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 rsnType = eANI_BOOLEAN_FALSE;
609 break;
610 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800611 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700612 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 return rsnType;
614}
615
616static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
617{
618 struct statsContext *pStatsContext;
619 hdd_adapter_t *pAdapter;
620
621 if (ioctl_debug)
622 {
623 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700624 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 }
626
627 if (NULL == pContext)
628 {
629 hddLog(VOS_TRACE_LEVEL_ERROR,
630 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700631 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 return;
633 }
634
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 pStatsContext = pContext;
636 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800637
638 /* there is a race condition that exists between this callback
639 function and the caller since the caller could time out either
640 before or while this code is executing. we use a spinlock to
641 serialize these actions */
642 spin_lock(&hdd_context_lock);
643
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
645 {
646 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800647 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700648 hddLog(VOS_TRACE_LEVEL_WARN,
649 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700650 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 if (ioctl_debug)
652 {
653 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700654 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700655 }
656 return;
657 }
658
Jeff Johnson72a40512013-12-19 10:14:15 -0800659 /* context is valid so caller is still waiting */
660
661 /* paranoia: invalidate the magic */
662 pStatsContext->magic = 0;
663
664 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 pAdapter->rssi = rssi;
666
Jeff Johnson72a40512013-12-19 10:14:15 -0800667 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800669
670 /* serialization is complete */
671 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700672}
673
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530674static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
675{
676 struct statsContext *pStatsContext;
677 hdd_adapter_t *pAdapter;
678
679 if (ioctl_debug)
680 {
681 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
682 __func__, (int)snr, (int)staId, pContext);
683 }
684
685 if (NULL == pContext)
686 {
687 hddLog(VOS_TRACE_LEVEL_ERROR,
688 "%s: Bad param, pContext [%p]",
689 __func__, pContext);
690 return;
691 }
692
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530693 pStatsContext = pContext;
694 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800695
696 /* there is a race condition that exists between this callback
697 function and the caller since the caller could time out either
698 before or while this code is executing. we use a spinlock to
699 serialize these actions */
700 spin_lock(&hdd_context_lock);
701
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530702 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
703 {
704 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800705 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530706 hddLog(VOS_TRACE_LEVEL_WARN,
707 "%s: Invalid context, pAdapter [%p] magic [%08x]",
708 __func__, pAdapter, pStatsContext->magic);
709 if (ioctl_debug)
710 {
711 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
712 __func__, pAdapter, pStatsContext->magic);
713 }
714 return;
715 }
716
Jeff Johnson72a40512013-12-19 10:14:15 -0800717 /* context is valid so caller is still waiting */
718
719 /* paranoia: invalidate the magic */
720 pStatsContext->magic = 0;
721
722 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530723 pAdapter->snr = snr;
724
Jeff Johnson72a40512013-12-19 10:14:15 -0800725 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530726 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800727
728 /* serialization is complete */
729 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530730}
731
Jeff Johnson295189b2012-06-20 16:38:30 -0700732VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
733{
734 struct statsContext context;
735 hdd_context_t *pHddCtx;
736 hdd_station_ctx_t *pHddStaCtx;
737 eHalStatus hstatus;
738 long lrc;
739
740 if (NULL == pAdapter)
741 {
742 hddLog(VOS_TRACE_LEVEL_WARN,
743 "%s: Invalid context, pAdapter", __func__);
744 return VOS_STATUS_E_FAULT;
745 }
746 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
747 {
748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
749 /* return a cached value */
750 *rssi_value = pAdapter->rssi;
751 return VOS_STATUS_SUCCESS;
752 }
753
754 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
755 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
756
757 init_completion(&context.completion);
758 context.pAdapter = pAdapter;
759 context.magic = RSSI_CONTEXT_MAGIC;
760
761 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
762 pHddStaCtx->conn_info.staId[ 0 ],
763 pHddStaCtx->conn_info.bssId,
764 &context, pHddCtx->pvosContext);
765 if (eHAL_STATUS_SUCCESS != hstatus)
766 {
767 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700768 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 /* we'll returned a cached value below */
770 }
771 else
772 {
773 /* request was sent -- wait for the response */
774 lrc = wait_for_completion_interruptible_timeout(&context.completion,
775 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 if (lrc <= 0)
777 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800778 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700779 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 /* we'll now returned a cached value below */
781 }
782 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800783
784 /* either we never sent a request, we sent a request and received a
785 response or we sent a request and timed out. if we never sent a
786 request or if we sent a request and got a response, we want to
787 clear the magic out of paranoia. if we timed out there is a
788 race condition such that the callback function could be
789 executing at the same time we are. of primary concern is if the
790 callback function had already verified the "magic" but had not
791 yet set the completion variable when a timeout occurred. we
792 serialize these activities by invalidating the magic while
793 holding a shared spinlock which will cause us to block if the
794 callback is currently executing */
795 spin_lock(&hdd_context_lock);
796 context.magic = 0;
797 spin_unlock(&hdd_context_lock);
798
Jeff Johnson295189b2012-06-20 16:38:30 -0700799 *rssi_value = pAdapter->rssi;
800
801 return VOS_STATUS_SUCCESS;
802}
803
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530804VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
805{
806 struct statsContext context;
807 hdd_context_t *pHddCtx;
808 hdd_station_ctx_t *pHddStaCtx;
809 eHalStatus hstatus;
810 long lrc;
811 int valid;
812
813 if (NULL == pAdapter)
814 {
815 hddLog(VOS_TRACE_LEVEL_ERROR,
816 "%s: Invalid context, pAdapter", __func__);
817 return VOS_STATUS_E_FAULT;
818 }
819
820 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
821
822 valid = wlan_hdd_validate_context(pHddCtx);
823 if (0 != valid)
824 {
825 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
826 return VOS_STATUS_E_FAULT;
827 }
828
829 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
830 if (NULL == pHddStaCtx)
831 {
832 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
833 return VOS_STATUS_E_FAULT;
834 }
835
836 init_completion(&context.completion);
837 context.pAdapter = pAdapter;
838 context.magic = SNR_CONTEXT_MAGIC;
839
840 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
841 pHddStaCtx->conn_info.staId[ 0 ],
842 pHddStaCtx->conn_info.bssId,
843 &context);
844 if (eHAL_STATUS_SUCCESS != hstatus)
845 {
846 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
847 __func__);
848 /* we'll returned a cached value below */
849 }
850 else
851 {
852 /* request was sent -- wait for the response */
853 lrc = wait_for_completion_interruptible_timeout(&context.completion,
854 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530855 if (lrc <= 0)
856 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800857 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530858 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530859 /* we'll now returned a cached value below */
860 }
861 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800862
863 /* either we never sent a request, we sent a request and received a
864 response or we sent a request and timed out. if we never sent a
865 request or if we sent a request and got a response, we want to
866 clear the magic out of paranoia. if we timed out there is a
867 race condition such that the callback function could be
868 executing at the same time we are. of primary concern is if the
869 callback function had already verified the "magic" but had not
870 yet set the completion variable when a timeout occurred. we
871 serialize these activities by invalidating the magic while
872 holding a shared spinlock which will cause us to block if the
873 callback is currently executing */
874 spin_lock(&hdd_context_lock);
875 context.magic = 0;
876 spin_unlock(&hdd_context_lock);
877
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530878 *snr = pAdapter->snr;
879
880 return VOS_STATUS_SUCCESS;
881}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800882#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
883
884static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
885{
886 struct statsContext *pStatsContext;
887 hdd_adapter_t *pAdapter;
888 if (ioctl_debug)
889 {
890 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
891 __func__, (int)rssi, (int)staId, pContext);
892 }
893
894 if (NULL == pContext)
895 {
896 hddLog(VOS_TRACE_LEVEL_ERROR,
897 "%s: Bad param, pContext [%p]",
898 __func__, pContext);
899 return;
900 }
901
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800902 pStatsContext = pContext;
903 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800904
905 /* there is a race condition that exists between this callback
906 function and the caller since the caller could time out either
907 before or while this code is executing. we use a spinlock to
908 serialize these actions */
909 spin_lock(&hdd_context_lock);
910
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800911 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
912 {
913 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800914 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800915 hddLog(VOS_TRACE_LEVEL_WARN,
916 "%s: Invalid context, pAdapter [%p] magic [%08x]",
917 __func__, pAdapter, pStatsContext->magic);
918 if (ioctl_debug)
919 {
920 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
921 __func__, pAdapter, pStatsContext->magic);
922 }
923 return;
924 }
925
Jeff Johnson72a40512013-12-19 10:14:15 -0800926 /* context is valid so caller is still waiting */
927
928 /* paranoia: invalidate the magic */
929 pStatsContext->magic = 0;
930
931 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800932 pAdapter->rssi = rssi;
933
Jeff Johnson72a40512013-12-19 10:14:15 -0800934 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800935 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800936
937 /* serialization is complete */
938 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800939}
940
941
942
943VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
944{
945 struct statsContext context;
946 hdd_context_t *pHddCtx = NULL;
947 hdd_station_ctx_t *pHddStaCtx = NULL;
948 eHalStatus hstatus;
949 long lrc;
950
951 if (NULL == pAdapter)
952 {
953 hddLog(VOS_TRACE_LEVEL_WARN,
954 "%s: Invalid context, pAdapter", __func__);
955 return VOS_STATUS_E_FAULT;
956 }
957 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
958 {
959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
960 /* return a cached value */
961 *rssi_value = pAdapter->rssi;
962 return VOS_STATUS_SUCCESS;
963 }
964
965 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
966 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
967
968 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
969 {
970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
971 /* return a cached value */
972 *rssi_value = 0;
973 return VOS_STATUS_SUCCESS;
974 }
975 init_completion(&context.completion);
976 context.pAdapter = pAdapter;
977 context.magic = RSSI_CONTEXT_MAGIC;
978
979 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
980 pHddStaCtx->conn_info.staId[ 0 ],
981 pHddStaCtx->conn_info.bssId,
982 &context, pHddCtx->pvosContext);
983 if (eHAL_STATUS_SUCCESS != hstatus)
984 {
985 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
986 __func__);
987 /* we'll returned a cached value below */
988 }
989 else
990 {
991 /* request was sent -- wait for the response */
992 lrc = wait_for_completion_interruptible_timeout(&context.completion,
993 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800994 if (lrc <= 0)
995 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800996 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800997 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800998 /* we'll now returned a cached value below */
999 }
1000 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001001
1002 /* either we never sent a request, we sent a request and received a
1003 response or we sent a request and timed out. if we never sent a
1004 request or if we sent a request and got a response, we want to
1005 clear the magic out of paranoia. if we timed out there is a
1006 race condition such that the callback function could be
1007 executing at the same time we are. of primary concern is if the
1008 callback function had already verified the "magic" but had not
1009 yet set the completion variable when a timeout occurred. we
1010 serialize these activities by invalidating the magic while
1011 holding a shared spinlock which will cause us to block if the
1012 callback is currently executing */
1013 spin_lock(&hdd_context_lock);
1014 context.magic = 0;
1015 spin_unlock(&hdd_context_lock);
1016
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001017 *rssi_value = pAdapter->rssi;
1018
1019 return VOS_STATUS_SUCCESS;
1020}
1021#endif
1022
1023
Jeff Johnson295189b2012-06-20 16:38:30 -07001024void hdd_StatisticsCB( void *pStats, void *pContext )
1025{
1026 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1027 hdd_stats_t *pStatsCache = NULL;
1028 hdd_wext_state_t *pWextState;
1029 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1030
1031 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1032 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1033 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1034 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1035 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1036 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1037
1038 if (pAdapter!= NULL)
1039 pStatsCache = &pAdapter->hdd_stats;
1040
1041
1042 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1043 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1044 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1045 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1046 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1047 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1048
1049 if (pStatsCache!=NULL)
1050 {
1051 // and copy the stats into the cache we keep in the adapter instance structure
1052 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1053 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1054 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1055 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1056 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1057 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1058 }
1059
1060 if(pAdapter)
1061 {
1062 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1063 if(pWextState)
1064 {
1065 vos_status = vos_event_set(&pWextState->vosevent);
1066 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1067 {
1068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001069 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 return;
1071 }
1072 }
1073 }
1074}
1075
1076void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1077{
1078 v_CONTEXT_t pVosContext;
1079 hdd_context_t *pHddCtx;
1080 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1081#if 0
1082 hdd_wext_state_t *pWextState;
1083 v_U32_t roamId;
1084#endif
1085
1086 ENTER();
1087
1088 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1089
1090 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1091 if (NULL == pHddCtx)
1092 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001093 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 return;
1095 }
1096#if 0
1097 pWextState = pAdapter->pWextState;
1098#endif
1099
1100 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1101 {
1102 //TODO Verify is this is really used. If yes need to fix it.
1103 hdd_reconnect_all_adapters( pHddCtx );
1104#if 0
1105 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1106 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1107 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1108
1109 if(VOS_STATUS_SUCCESS == vosStatus)
1110 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1111 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1112
1113 sme_RoamConnect(halHandle,
1114 pAdapter->sessionId, &(pWextState->roamProfile),
1115 &roamId);
1116#endif
1117 }
1118
1119 EXIT();
1120
1121}
1122
1123void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1124{
1125 int i = 0;
1126 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1127
1128 /* clear WPA/RSN/WSC IE information in the profile */
1129 pWextState->roamProfile.nWPAReqIELength = 0;
1130 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1131 pWextState->roamProfile.nRSNReqIELength = 0;
1132 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1133
Chet Lanctot186b5732013-03-18 10:26:30 -07001134#ifdef FEATURE_WLAN_WAPI
1135 pWextState->roamProfile.nWAPIReqIELength = 0;
1136 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1137#endif
1138
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301141 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1143 pWextState->roamProfile.nAddIEAssocLength = 0;
1144
1145 pWextState->roamProfile.EncryptionType.numEntries = 1;
1146 pWextState->roamProfile.EncryptionType.encryptionType[0]
1147 = eCSR_ENCRYPT_TYPE_NONE;
1148
1149 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1150 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1151 = eCSR_ENCRYPT_TYPE_NONE;
1152
1153 pWextState->roamProfile.AuthType.numEntries = 1;
1154 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1155
Chet Lanctot186b5732013-03-18 10:26:30 -07001156#ifdef WLAN_FEATURE_11W
1157 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1158 pWextState->roamProfile.MFPRequired = 0;
1159 pWextState->roamProfile.MFPCapable = 0;
1160#endif
1161
Jeff Johnson295189b2012-06-20 16:38:30 -07001162 pWextState->authKeyMgmt = 0;
1163
1164 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1165 {
1166 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1167 {
1168 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1169 }
1170 }
1171#ifdef FEATURE_WLAN_WAPI
1172 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1173 pAdapter->wapi_info.nWapiMode = 0;
1174#endif
1175
1176 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1177
1178}
1179
1180void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1181{
1182 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001183
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001184 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1185 {
1186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1187 "%s: Invalid pAdapter magic", __func__);
1188 }
1189 else
1190 {
1191 complete(&pAdapter->ula_complete);
1192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001193}
1194
1195VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1196{
1197 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001199 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001200
1201 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1202 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001203 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001204
1205 /*To avoid race condition between the set key and the last EAPOL
1206 packet, notify TL to finish upper layer authentication incase if the
1207 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001208 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001209
1210 if ( vos_status != VOS_STATUS_SUCCESS )
1211 {
1212 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1213 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1214 __LINE__, vos_status );
1215 return vos_status;
1216
1217 }
1218
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001219 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001221 if (0 == rc)
1222 {
1223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1224 "%s: Timeout waiting for ULA to complete", __func__);
1225 /* we'll still fall through and return success since the
1226 * connection may still get established but is just taking
1227 * too long for us to wait */
1228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 }
1230 return VOS_STATUS_SUCCESS;
1231}
1232
1233v_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)
1234{
1235
1236 int left = ie_len;
1237 v_U8_t *ptr = ie;
1238 v_U8_t elem_id,elem_len;
1239 v_U8_t eid = 0xDD;
1240
1241 if ( NULL == ie || 0 == ie_len )
1242 return NULL;
1243
1244 while(left >= 2)
1245 {
1246 elem_id = ptr[0];
1247 elem_len = ptr[1];
1248 left -= 2;
1249 if(elem_len > left)
1250 {
1251 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001252 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 eid,elem_len,left);
1254 return NULL;
1255 }
1256 if (elem_id == eid)
1257 {
1258 if(memcmp( &ptr[2], oui, oui_size)==0)
1259 return ptr;
1260 }
1261
1262 left -= elem_len;
1263 ptr += (elem_len + 2);
1264 }
1265 return NULL;
1266}
1267
1268static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1269 union iwreq_data *wrqu, char *extra)
1270{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001271 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 /* Do nothing for now */
1273 return 0;
1274}
1275
1276static int iw_get_name(struct net_device *dev,
1277 struct iw_request_info *info,
1278 char *wrqu, char *extra)
1279{
1280
1281 ENTER();
1282 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1283 EXIT();
1284 return 0;
1285}
1286
1287static int iw_set_mode(struct net_device *dev,
1288 struct iw_request_info *info,
1289 union iwreq_data *wrqu, char *extra)
1290{
1291 hdd_wext_state_t *pWextState;
1292 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1293 tCsrRoamProfile *pRoamProfile;
1294 eCsrRoamBssType LastBSSType;
1295 eMib_dot11DesiredBssType connectedBssType;
1296 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001298
1299 ENTER();
1300
1301 if (NULL == pAdapter)
1302 {
1303 hddLog(VOS_TRACE_LEVEL_WARN,
1304 "%s: Invalid context, pAdapter", __func__);
1305 return 0;
1306 }
1307
1308 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1310 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 return 0;
1312 }
1313
1314 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1315 if (pWextState == NULL)
1316 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301317 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 return -EINVAL;
1319 }
1320
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 pRoamProfile = &pWextState->roamProfile;
1323 LastBSSType = pRoamProfile->BSSType;
1324
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301325 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001326
1327 switch (wrqu->mode)
1328 {
1329 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301330 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1332 // Set the phymode correctly for IBSS.
1333 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1334 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001335 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 break;
1338 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301339 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 break;
1343 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301344 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1346 break;
1347 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301348 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 return -EOPNOTSUPP;
1350 }
1351
1352 if ( LastBSSType != pRoamProfile->BSSType )
1353 {
1354 //the BSS mode changed
1355 // We need to issue disconnect if connected or in IBSS disconnect state
1356 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1357 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1358 {
1359 VOS_STATUS vosStatus;
1360 // need to issue a disconnect to CSR.
1361 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1362 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1363 pAdapter->sessionId,
1364 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1365 if(VOS_STATUS_SUCCESS == vosStatus)
1366 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1367 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1368 }
1369 }
1370
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 EXIT();
1372 return 0;
1373}
1374
1375
1376static int iw_get_mode(struct net_device *dev,
1377 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301378 union iwreq_data *wrqu,
1379 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001380{
1381
1382 hdd_wext_state_t *pWextState;
1383 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1384
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301385 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001386
1387 if (NULL == pAdapter)
1388 {
1389 hddLog(VOS_TRACE_LEVEL_WARN,
1390 "%s: Invalid context, pAdapter", __func__);
1391 return 0;
1392 }
1393
1394 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1396 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001397 return 0;
1398 }
1399
1400 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1401 if (pWextState == NULL)
1402 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301403 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 return -EINVAL;
1405 }
1406
1407 switch (pWextState->roamProfile.BSSType)
1408 {
1409 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001410 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301411 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 break;
1413 case eCSR_BSS_TYPE_IBSS:
1414 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001415 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301416 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 break;
1418 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001419 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301420 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 break;
1422 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001423 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 break;
1425 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301426
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 return 0;
1428}
1429
1430static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1431 union iwreq_data *wrqu, char *extra)
1432{
1433 v_U32_t numChans = 0;
1434 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1435 v_U32_t indx = 0;
1436 v_U32_t status = 0;
1437
1438 hdd_wext_state_t *pWextState;
1439 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1440 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1441 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1442 tCsrRoamProfile * pRoamProfile;
1443 ENTER();
1444
1445 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1447 return status;
1448 }
1449
1450 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1451
1452 pRoamProfile = &pWextState->roamProfile;
1453
Arif Hussain6d2a3322013-11-17 19:50:10 -08001454 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001455
1456 /* Link is up then return cant set channel*/
1457 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1458 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1459 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001460 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 return -EOPNOTSUPP;
1462 }
1463
1464 /* Settings by Frequency as input */
1465 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1466 (wrqu->freq.m <= (tANI_U32)5.825e8))
1467 {
1468 tANI_U32 freq = wrqu->freq.m / 100000;
1469
1470 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1471 indx++;
1472 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1473 {
1474 return -EINVAL;
1475 }
1476 wrqu->freq.e = 0;
1477 wrqu->freq.m = freq_chan_map[indx].chan;
1478
1479 }
1480
1481 if (wrqu->freq.e == 0)
1482 {
1483 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1484 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1485 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001486 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001487 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1489 return -EINVAL;
1490 }
1491
1492 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1493
1494 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1495 validChan, &numChans) != eHAL_STATUS_SUCCESS){
1496 return -EIO;
1497 }
1498
1499 for (indx = 0; indx < numChans; indx++) {
1500 if (wrqu->freq.m == validChan[indx]){
1501 break;
1502 }
1503 }
1504 }
1505 else{
1506
1507 return -EINVAL;
1508 }
1509
1510 if(indx >= numChans)
1511 {
1512 return -EINVAL;
1513 }
1514
1515 /* Set the Operational Channel */
1516 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1517 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1518 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1519
Arif Hussain6d2a3322013-11-17 19:50:10 -08001520 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001521
1522 EXIT();
1523
1524 return status;
1525}
1526
1527static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1528 struct iw_freq *fwrq, char *extra)
1529{
Jeff Johnsone7245742012-09-05 17:12:55 -07001530 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1532 tHalHandle hHal;
1533 hdd_wext_state_t *pWextState;
1534 tCsrRoamProfile * pRoamProfile;
1535 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1536
1537 ENTER();
1538
1539 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1541 return status;
1542 }
1543
1544 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1545 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1546
1547 pRoamProfile = &pWextState->roamProfile;
1548
1549 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1550 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001551 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 {
1553 return -EIO;
1554 }
1555 else
1556 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001557 status = hdd_wlan_get_freq(channel, &freq);
1558 if( TRUE == status )
1559 {
1560 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1561 * iwlist & iwconfig command shows frequency into proper
1562 * format (2.412 GHz instead of 246.2 MHz)*/
1563 fwrq->m = freq;
1564 fwrq->e = MHZ;
1565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 }
1567 }
1568 else
1569 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001570 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1571 * iwlist & iwconfig command shows frequency into proper
1572 * format (2.412 GHz instead of 246.2 MHz)*/
1573 fwrq->m = 0;
1574 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001576 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001577}
1578
1579static int iw_get_tx_power(struct net_device *dev,
1580 struct iw_request_info *info,
1581 union iwreq_data *wrqu, char *extra)
1582{
1583
1584 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1585 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1586 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1587
1588 if (pHddCtx->isLogpInProgress)
1589 {
1590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1591 "%s:LOGP in Progress. Ignore!!!",__func__);
1592 return -EBUSY;
1593 }
1594
1595 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1596 {
1597 wrqu->txpower.value = 0;
1598 return 0;
1599 }
1600 wlan_hdd_get_classAstats(pAdapter);
1601 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1602
1603 return 0;
1604}
1605
1606static int iw_set_tx_power(struct net_device *dev,
1607 struct iw_request_info *info,
1608 union iwreq_data *wrqu, char *extra)
1609{
1610 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1611 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1612
1613 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1614 {
1615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1616 return 0;
1617 }
1618
1619 ENTER();
1620
1621 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1622 {
1623 return -EIO;
1624 }
1625
1626 EXIT();
1627
1628 return 0;
1629}
1630
1631static int iw_get_bitrate(struct net_device *dev,
1632 struct iw_request_info *info,
1633 union iwreq_data *wrqu, char *extra)
1634{
1635 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1636 eHalStatus status = eHAL_STATUS_SUCCESS;
1637 hdd_wext_state_t *pWextState;
1638 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1639 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1640
1641 ENTER();
1642
1643 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1645 return status;
1646 }
1647
1648 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1649 wrqu->bitrate.value = 0;
1650 }
1651 else {
1652 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1653 SME_SUMMARY_STATS |
1654 SME_GLOBAL_CLASSA_STATS |
1655 SME_GLOBAL_CLASSB_STATS |
1656 SME_GLOBAL_CLASSC_STATS |
1657 SME_GLOBAL_CLASSD_STATS |
1658 SME_PER_STA_STATS,
1659 hdd_StatisticsCB, 0, FALSE,
1660 pHddStaCtx->conn_info.staId[0], pAdapter );
1661
1662 if(eHAL_STATUS_SUCCESS != status)
1663 {
1664 hddLog(VOS_TRACE_LEVEL_ERROR,
1665 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001666 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001667 return status;
1668 }
1669
1670 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1671
1672 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1673
1674 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1675 {
1676 hddLog(VOS_TRACE_LEVEL_ERROR,
1677 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001678 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 return VOS_STATUS_E_FAILURE;
1680 }
1681
1682 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1683 }
1684
1685 EXIT();
1686
1687 return vos_status;
1688}
1689/* ccm call back function */
1690
1691static int iw_set_bitrate(struct net_device *dev,
1692 struct iw_request_info *info,
1693 union iwreq_data *wrqu,
1694 char *extra)
1695{
1696 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1697 hdd_wext_state_t *pWextState;
1698 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1699 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1700 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1701 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1702 v_U32_t i, rate;
1703 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1704
1705 ENTER();
1706
1707 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1709 return 0;
1710 }
1711
1712 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1713
1714 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1715 {
1716 return -ENXIO ;
1717 }
1718
1719 rate = wrqu->bitrate.value;
1720
1721 if (rate == -1)
1722 {
1723 rate = WNI_CFG_FIXED_RATE_AUTO;
1724 valid_rate = TRUE;
1725 }
1726 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1727 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1728 {
1729 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1730 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1731 {
1732 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1733 WNI_CFG_SUPPORTED_RATES_11A,
1734 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1735 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1736 WNI_CFG_SUPPORTED_RATES_11B,
1737 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1738 {
1739 for (i = 0; i < (b_len + a_len); ++i)
1740 {
1741 /* supported rates returned is double the actual rate so we divide it by 2 */
1742 if ((supp_rates[i]&0x7F)/2 == rate)
1743 {
1744 valid_rate = TRUE;
1745 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1746 break;
1747 }
1748 }
1749 }
1750 }
1751 }
1752 if (valid_rate != TRUE)
1753 {
1754 return -EINVAL;
1755 }
1756 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1757 WNI_CFG_FIXED_RATE, rate,
1758 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1759 {
1760 return -EIO;
1761 }
1762 return 0;
1763}
1764
1765
1766static int iw_set_genie(struct net_device *dev,
1767 struct iw_request_info *info,
1768 union iwreq_data *wrqu,
1769 char *extra)
1770{
1771 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1772 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001773 u_int8_t *genie = NULL;
1774 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 v_U16_t remLen;
1776
1777 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001778
1779 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1781 "%s:LOGP in Progress. Ignore!!!", __func__);
1782 return 0;
1783 }
1784
1785 if (!wrqu->data.length) {
1786 hdd_clearRoamProfileIe(pAdapter);
1787 EXIT();
1788 return 0;
1789 }
1790
1791 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1792 wrqu->data.length);
1793 if (NULL == base_genie)
1794 {
1795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1796 "mem_alloc_copy_from_user_helper fail");
1797 return -ENOMEM;
1798 }
1799
1800 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001801
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 remLen = wrqu->data.length;
1803
Arif Hussain6d2a3322013-11-17 19:50:10 -08001804 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001805
1806 /* clear any previous genIE before this call */
1807 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1808
1809 while (remLen >= 2)
1810 {
1811 v_U16_t eLen = 0;
1812 v_U8_t elementId;
1813 elementId = *genie++;
1814 eLen = *genie++;
1815 remLen -= 2;
1816
Arif Hussain6d2a3322013-11-17 19:50:10 -08001817 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 __func__, elementId, eLen);
1819
1820 switch ( elementId )
1821 {
1822 case IE_EID_VENDOR:
1823 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001824 {
1825 kfree(base_genie);
1826 return -EINVAL;
1827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001828
1829 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1830 {
1831 v_U16_t curGenIELen = pWextState->genIE.length;
1832 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1833 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1834
1835 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1836 {
1837 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001838 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001840 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 return -ENOMEM;
1842 }
1843 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1844 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1845 pWextState->genIE.length += eLen + 2;
1846 }
1847 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1848 {
1849 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1850 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1851 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1852 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1853 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1854 }
1855 else /* any vendorId except WPA IE should be accumulated to genIE */
1856 {
1857 v_U16_t curGenIELen = pWextState->genIE.length;
1858 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1859 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1860
1861 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1862 {
1863 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001864 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001866 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 return -ENOMEM;
1868 }
1869 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1870 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1871 pWextState->genIE.length += eLen + 2;
1872 }
1873 break;
1874 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001875 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1877 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1878 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1879 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1880 break;
1881
1882 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001883 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001884 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 return 0;
1886 }
1887 genie += eLen;
1888 remLen -= eLen;
1889 }
1890 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001891 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 return 0;
1893}
1894
1895static int iw_get_genie(struct net_device *dev,
1896 struct iw_request_info *info,
1897 union iwreq_data *wrqu,
1898 char *extra)
1899{
1900 hdd_wext_state_t *pWextState;
1901 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1902 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1903 eHalStatus status;
1904 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1905 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1906
1907 ENTER();
1908
1909 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1911 return 0;
1912 }
1913
1914
Arif Hussain6d2a3322013-11-17 19:50:10 -08001915 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001916
1917 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1918
1919 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1920 {
1921 return -ENXIO;
1922 }
1923
1924 // Return something ONLY if we are associated with an RSN or WPA network
1925 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1926 pWextState->roamProfile.negotiatedAuthType))
1927 {
1928 return -ENXIO;
1929 }
1930
1931 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1932 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1933 pAdapter->sessionId,
1934 &length,
1935 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001936 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1937 if (wrqu->data.length < length)
1938 {
1939 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1940 return -EFAULT;
1941 }
1942 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, wrqu->data.length);
1943 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001944
Arif Hussain6d2a3322013-11-17 19:50:10 -08001945 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001946
1947 EXIT();
1948
1949 return 0;
1950}
1951
1952static int iw_get_encode(struct net_device *dev,
1953 struct iw_request_info *info,
1954 struct iw_point *dwrq, char *extra)
1955{
1956 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1957 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1958 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1959 int keyId;
1960 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1961 int i;
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 keyId = pRoamProfile->Keys.defaultIndex;
1971
1972 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1973 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001974 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001975 return -EINVAL;
1976 }
1977
1978 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1979 {
1980 dwrq->flags |= IW_ENCODE_ENABLED;
1981 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1982 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1983
1984 dwrq->flags |= (keyId + 1);
1985
1986 }
1987 else
1988 {
1989 dwrq->flags |= IW_ENCODE_DISABLED;
1990 }
1991
1992 for(i=0; i < MAX_WEP_KEYS; i++)
1993 {
1994 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
1995 {
1996 continue;
1997 }
1998 else
1999 {
2000 break;
2001 }
2002 }
2003
2004 if(MAX_WEP_KEYS == i)
2005 {
2006 dwrq->flags |= IW_ENCODE_NOKEY;
2007 }
2008
2009 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2010
2011 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2012 {
2013 dwrq->flags |= IW_ENCODE_OPEN;
2014 }
2015 else
2016 {
2017 dwrq->flags |= IW_ENCODE_RESTRICTED;
2018 }
2019 EXIT();
2020 return 0;
2021}
2022
2023#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2024#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2025
2026
2027/*
2028 * This function sends a single 'key' to LIM at all time.
2029 */
2030
2031static int iw_get_rts_threshold(struct net_device *dev,
2032 struct iw_request_info *info,
2033 union iwreq_data *wrqu, char *extra)
2034{
2035 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2036 v_U32_t status = 0;
2037
2038 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2039
2040 return status;
2041}
2042
2043static int iw_set_rts_threshold(struct net_device *dev,
2044 struct iw_request_info *info,
2045 union iwreq_data *wrqu, char *extra)
2046{
2047 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2048 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2049
2050 ENTER();
2051
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002052 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2053 {
2054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2055 "%s:LOGP in Progress. Ignore!!!", __func__);
2056 return -EAGAIN;
2057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2059 {
2060 return -EINVAL;
2061 }
2062
2063 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2064 {
2065 return -EIO;
2066 }
2067
2068 EXIT();
2069
2070 return 0;
2071}
2072
2073static int iw_get_frag_threshold(struct net_device *dev,
2074 struct iw_request_info *info,
2075 union iwreq_data *wrqu, char *extra)
2076{
2077 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2078 v_U32_t status = 0;
2079
2080 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2081
2082 return status;
2083}
2084
2085static int iw_set_frag_threshold(struct net_device *dev,
2086 struct iw_request_info *info,
2087 union iwreq_data *wrqu, char *extra)
2088{
2089 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2090 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2091
2092 ENTER();
2093
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002094 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2095 {
2096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2097 "%s:LOGP in Progress. Ignore!!!", __func__);
2098 return -EBUSY;
2099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2101 {
2102 return -EINVAL;
2103 }
2104
2105 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2106 {
2107 return -EIO;
2108 }
2109
2110 EXIT();
2111
2112 return 0;
2113}
2114
2115static int iw_get_power_mode(struct net_device *dev,
2116 struct iw_request_info *info,
2117 union iwreq_data *wrqu, char *extra)
2118{
2119 ENTER();
2120 return -EOPNOTSUPP;
2121}
2122
2123static int iw_set_power_mode(struct net_device *dev,
2124 struct iw_request_info *info,
2125 union iwreq_data *wrqu, char *extra)
2126{
2127 ENTER();
2128 return -EOPNOTSUPP;
2129}
2130
2131static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2132 union iwreq_data *wrqu, char *extra)
2133{
2134 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2135 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2136 struct iw_range *range = (struct iw_range *) extra;
2137
2138 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2139
2140 v_U32_t num_channels = sizeof(channels);
2141 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2142 v_U32_t a_len;
2143 v_U32_t b_len;
2144 v_U32_t active_phy_mode = 0;
2145 v_U8_t index = 0, i;
2146
2147 ENTER();
2148
2149 wrqu->data.length = sizeof(struct iw_range);
2150 memset(range, 0, sizeof(struct iw_range));
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
2159 /*Get the phy mode*/
2160 if (ccmCfgGetInt(hHal,
2161 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2162 {
2163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002164 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002165
2166 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2167 {
2168 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002169 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 if (ccmCfgGetStr(hHal,
2171 WNI_CFG_SUPPORTED_RATES_11A,
2172 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2173 {
2174 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2175 {
2176 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2177 }
2178 for (i = 0; i < a_len; i++)
2179 {
2180 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2181 }
2182 range->num_bitrates = a_len;
2183 }
2184 else
2185 {
2186 return -EIO;
2187 }
2188 }
2189 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2190 {
2191 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002192 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 if (ccmCfgGetStr(hHal,
2194 WNI_CFG_SUPPORTED_RATES_11B,
2195 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2196 {
2197 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2198 {
2199 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2200 }
2201 for (i = 0; i < b_len; i++)
2202 {
2203 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2204 }
2205 range->num_bitrates = b_len;
2206 }
2207 else
2208 {
2209 return -EIO;
2210 }
2211 }
2212 }
2213
2214 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2215 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2216 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2217
2218 range->encoding_size[0] = 5;
2219 range->encoding_size[1] = 13;
2220 range->num_encoding_sizes = 2;
2221 range->max_encoding_tokens = MAX_WEP_KEYS;
2222
2223 // we support through Wireless Extensions 22
2224 range->we_version_compiled = WIRELESS_EXT;
2225 range->we_version_source = 22;
2226
2227 /*Supported Channels and Frequencies*/
2228 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2229 {
2230 return -EIO;
2231 }
2232 if (num_channels > IW_MAX_FREQUENCIES)
2233 {
2234 num_channels = IW_MAX_FREQUENCIES;
2235 }
2236
2237 range->num_channels = num_channels;
2238 range->num_frequency = num_channels;
2239
2240 for (index=0; index < num_channels; index++)
2241 {
2242 v_U32_t frq_indx = 0;
2243
2244 range->freq[index].i = channels[index];
2245 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2246 {
2247 if(channels[index] == freq_chan_map[frq_indx].chan)
2248 {
2249 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2250 range->freq[index].e = 1;
2251 break;
2252 }
2253 frq_indx++;
2254 }
2255 }
2256
2257 /* Event capability (kernel + driver) */
2258 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2259 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2260 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2261 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2262
2263 /*Encryption capability*/
2264 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2265 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2266
2267 /* Txpower capability */
2268 range->txpower_capa = IW_TXPOW_MWATT;
2269
2270 /*Scanning capability*/
2271 #if WIRELESS_EXT >= 22
2272 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2273 #endif
2274
2275 EXIT();
2276 return 0;
2277}
2278
2279/* Callback function registered with PMC to know status of PMC request */
2280static void iw_power_callback_fn (void *pContext, eHalStatus status)
2281{
2282 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002283
2284 if (NULL == pContext)
2285 {
2286 hddLog(VOS_TRACE_LEVEL_ERROR,
2287 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002288 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 return;
2290 }
2291
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002293
Jeff Johnson72a40512013-12-19 10:14:15 -08002294 /* there is a race condition that exists between this callback
2295 function and the caller since the caller could time out either
2296 before or while this code is executing. we use a spinlock to
2297 serialize these actions */
2298 spin_lock(&hdd_context_lock);
2299
2300 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002301 {
2302 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002303 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002305 "%s: Invalid context, magic [%08x]",
2306 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002307
2308 if (ioctl_debug)
2309 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002310 pr_info("%s: Invalid context, magic [%08x]\n",
2311 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 }
2313 return;
2314 }
2315
Jeff Johnson72a40512013-12-19 10:14:15 -08002316 /* context is valid so caller is still waiting */
2317
2318 /* paranoia: invalidate the magic */
2319 pStatsContext->magic = 0;
2320
2321 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002323
2324 /* serialization is complete */
2325 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002326}
2327
2328/* Callback function for tx per hit */
2329void hdd_tx_per_hit_cb (void *pCallbackContext)
2330{
2331 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2332 unsigned char tx_fail[16];
2333 union iwreq_data wrqu;
2334
2335 if (NULL == pAdapter)
2336 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002337 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 return;
2339 }
2340 memset(&wrqu, 0, sizeof(wrqu));
2341 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2342 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2343}
2344
2345void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2346{
2347 struct statsContext *pStatsContext;
2348 tCsrGlobalClassAStatsInfo *pClassAStats;
2349 hdd_adapter_t *pAdapter;
2350
2351 if (ioctl_debug)
2352 {
2353 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002354 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 }
2356
2357 if ((NULL == pStats) || (NULL == pContext))
2358 {
2359 hddLog(VOS_TRACE_LEVEL_ERROR,
2360 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002361 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 return;
2363 }
2364
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 pClassAStats = pStats;
2366 pStatsContext = pContext;
2367 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002368
2369 /* there is a race condition that exists between this callback
2370 function and the caller since the caller could time out either
2371 before or while this code is executing. we use a spinlock to
2372 serialize these actions */
2373 spin_lock(&hdd_context_lock);
2374
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2376 {
2377 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002378 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 hddLog(VOS_TRACE_LEVEL_WARN,
2380 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002381 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 if (ioctl_debug)
2383 {
2384 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002385 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 }
2387 return;
2388 }
2389
Jeff Johnson72a40512013-12-19 10:14:15 -08002390 /* context is valid so caller is still waiting */
2391
2392 /* paranoia: invalidate the magic */
2393 pStatsContext->magic = 0;
2394
2395 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2397
Jeff Johnson72a40512013-12-19 10:14:15 -08002398 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002400
2401 /* serialization is complete */
2402 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002403}
2404
2405VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2406{
2407 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2408 eHalStatus hstatus;
2409 long lrc;
2410 struct statsContext context;
2411
2412 if (NULL == pAdapter)
2413 {
2414 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2415 return VOS_STATUS_E_FAULT;
2416 }
2417 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2418 {
2419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2420 return VOS_STATUS_SUCCESS;
2421 }
2422
2423 /* we are connected
2424 prepare our callback context */
2425 init_completion(&context.completion);
2426 context.pAdapter = pAdapter;
2427 context.magic = STATS_CONTEXT_MAGIC;
2428 /* query only for Class A statistics (which include link speed) */
2429 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2430 eCSR_HDD,
2431 SME_GLOBAL_CLASSA_STATS,
2432 hdd_GetClassA_statisticsCB,
2433 0, // not periodic
2434 FALSE, //non-cached results
2435 pHddStaCtx->conn_info.staId[0],
2436 &context);
2437 if (eHAL_STATUS_SUCCESS != hstatus)
2438 {
2439 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002440 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002441 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 /* we'll returned a cached value below */
2443 }
2444 else
2445 {
2446 /* request was sent -- wait for the response */
2447 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2448 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 if (lrc <= 0)
2450 {
2451 hddLog(VOS_TRACE_LEVEL_ERROR,
2452 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002453 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 }
2455 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002456
2457 /* either we never sent a request, we sent a request and received a
2458 response or we sent a request and timed out. if we never sent a
2459 request or if we sent a request and got a response, we want to
2460 clear the magic out of paranoia. if we timed out there is a
2461 race condition such that the callback function could be
2462 executing at the same time we are. of primary concern is if the
2463 callback function had already verified the "magic" but had not
2464 yet set the completion variable when a timeout occurred. we
2465 serialize these activities by invalidating the magic while
2466 holding a shared spinlock which will cause us to block if the
2467 callback is currently executing */
2468 spin_lock(&hdd_context_lock);
2469 context.magic = 0;
2470 spin_unlock(&hdd_context_lock);
2471
2472 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 return VOS_STATUS_SUCCESS;
2474}
2475
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002476static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2477{
2478 struct statsContext *pStatsContext;
2479 tCsrSummaryStatsInfo *pSummaryStats;
2480 tCsrGlobalClassAStatsInfo *pClassAStats;
2481 hdd_adapter_t *pAdapter;
2482
2483 if (ioctl_debug)
2484 {
2485 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002486 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002487 }
2488
2489 if ((NULL == pStats) || (NULL == pContext))
2490 {
2491 hddLog(VOS_TRACE_LEVEL_ERROR,
2492 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002493 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002494 return;
2495 }
2496
Jeff Johnson72a40512013-12-19 10:14:15 -08002497 /* there is a race condition that exists between this callback
2498 function and the caller since the caller could time out either
2499 before or while this code is executing. we use a spinlock to
2500 serialize these actions */
2501 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002502
2503 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2504 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2505 pStatsContext = pContext;
2506 pAdapter = pStatsContext->pAdapter;
2507 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2508 {
2509 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002510 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002511 hddLog(VOS_TRACE_LEVEL_WARN,
2512 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002513 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002514 if (ioctl_debug)
2515 {
2516 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002517 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002518 }
2519 return;
2520 }
2521
Jeff Johnson72a40512013-12-19 10:14:15 -08002522 /* context is valid so caller is still waiting */
2523
2524 /* paranoia: invalidate the magic */
2525 pStatsContext->magic = 0;
2526
2527 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002528 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2529 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2530
Jeff Johnson72a40512013-12-19 10:14:15 -08002531 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002532 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002533
2534 /* serialization is complete */
2535 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002536}
2537
2538VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2539{
2540 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2541 eHalStatus hstatus;
2542 long lrc;
2543 struct statsContext context;
2544
2545 if (NULL == pAdapter)
2546 {
2547 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2548 return VOS_STATUS_SUCCESS;
2549 }
2550
2551 /* we are connected
2552 prepare our callback context */
2553 init_completion(&context.completion);
2554 context.pAdapter = pAdapter;
2555 context.magic = STATS_CONTEXT_MAGIC;
2556
2557 /* query only for Summary & Class A statistics */
2558 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2559 eCSR_HDD,
2560 SME_SUMMARY_STATS |
2561 SME_GLOBAL_CLASSA_STATS,
2562 hdd_get_station_statisticsCB,
2563 0, // not periodic
2564 FALSE, //non-cached results
2565 pHddStaCtx->conn_info.staId[0],
2566 &context);
2567 if (eHAL_STATUS_SUCCESS != hstatus)
2568 {
2569 hddLog(VOS_TRACE_LEVEL_ERROR,
2570 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002571 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002572 /* we'll return with cached values */
2573 }
2574 else
2575 {
2576 /* request was sent -- wait for the response */
2577 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2578 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002579
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002580 if (lrc <= 0)
2581 {
2582 hddLog(VOS_TRACE_LEVEL_ERROR,
2583 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002584 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002585 }
2586 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002587
2588 /* either we never sent a request, we sent a request and received a
2589 response or we sent a request and timed out. if we never sent a
2590 request or if we sent a request and got a response, we want to
2591 clear the magic out of paranoia. if we timed out there is a
2592 race condition such that the callback function could be
2593 executing at the same time we are. of primary concern is if the
2594 callback function had already verified the "magic" but had not
2595 yet set the completion variable when a timeout occurred. we
2596 serialize these activities by invalidating the magic while
2597 holding a shared spinlock which will cause us to block if the
2598 callback is currently executing */
2599 spin_lock(&hdd_context_lock);
2600 context.magic = 0;
2601 spin_unlock(&hdd_context_lock);
2602
2603 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002604 return VOS_STATUS_SUCCESS;
2605}
2606
2607
Jeff Johnson295189b2012-06-20 16:38:30 -07002608/*
2609 * Support for the LINKSPEED private command
2610 * Per the WiFi framework the response must be of the form
2611 * "LinkSpeed xx"
2612 */
2613static int iw_get_linkspeed(struct net_device *dev,
2614 struct iw_request_info *info,
2615 union iwreq_data *wrqu, char *extra)
2616{
2617 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302618 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302620 int len = sizeof(v_U32_t) + 1;
2621 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302623 VOS_STATUS status;
2624 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002625
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302626 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2627
2628 valid = wlan_hdd_validate_context(pHddCtx);
2629
2630 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002631 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302632 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2633 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002634 }
2635
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2637 {
2638 /* we are not connected so we don't have a classAstats */
2639 link_speed = 0;
2640 }
2641 else
2642 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302643 status = wlan_hdd_get_classAstats(pAdapter);
2644
2645 if (!VOS_IS_STATUS_SUCCESS(status ))
2646 {
2647 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2648 return -EINVAL;
2649 }
2650
2651 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2652 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2653 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2654 &link_speed);
2655
2656 link_speed = link_speed / 10;
2657
2658 if (0 == link_speed)
2659 {
2660 /* The linkspeed returned by HAL is in units of 500kbps.
2661 * converting it to mbps.
2662 * This is required to support legacy firmware which does
2663 * not return link capacity.
2664 */
2665 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2666 }
2667
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 }
2669
2670 wrqu->data.length = len;
2671 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002672 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 if ((rc < 0) || (rc >= len))
2674 {
2675 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302676 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 return -EIO;
2678 }
2679
2680 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002681 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002682}
2683
2684
2685/*
2686 * Support for the RSSI & RSSI-APPROX private commands
2687 * Per the WiFi framework the response must be of the form
2688 * "<ssid> rssi <xx>"
2689 * unless we are not associated, in which case the response is
2690 * "OK"
2691 */
2692static int iw_get_rssi(struct net_device *dev,
2693 struct iw_request_info *info,
2694 union iwreq_data *wrqu, char *extra)
2695{
2696 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002697 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 int len = wrqu->data.length;
2699 v_S7_t s7Rssi = 0;
2700 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2701 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2702 VOS_STATUS vosStatus;
2703 int rc;
2704
2705 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2706 (0 == ssidlen) || (ssidlen >= len))
2707 {
2708 /* we are not connected or our SSID is too long
2709 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002710 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 }
2712 else
2713 {
2714 /* we are connected with a valid SSID
2715 so we can write the SSID into the return buffer
2716 (note that it is not NUL-terminated) */
2717 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2718
2719 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2720
2721 if (VOS_STATUS_SUCCESS == vosStatus)
2722 {
2723 /* append the rssi to the ssid in the format required by
2724 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002725 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 }
2727 else
2728 {
2729 rc = -1;
2730 }
2731 }
2732
2733 /* verify that we wrote a valid response */
2734 if ((rc < 0) || (rc >= len))
2735 {
2736 // encoding or length error?
2737 hddLog(VOS_TRACE_LEVEL_ERROR,
2738 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002739 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 return -EIO;
2741 }
2742
2743 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002744 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002745}
2746
2747/*
2748 * Support for SoftAP channel range private command
2749 */
2750static int iw_softap_set_channel_range( struct net_device *dev,
2751 int startChannel,
2752 int endChannel,
2753 int band)
2754{
Jeff Johnson43971f52012-07-17 12:26:56 -07002755 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 int ret = 0;
2757 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2758 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002759 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2760
Jeff Johnson295189b2012-06-20 16:38:30 -07002761
2762 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2763 if (VOS_STATUS_SUCCESS != status)
2764 {
2765 ret = -EINVAL;
2766 }
Yathish9f22e662012-12-10 14:21:35 -08002767 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 return ret;
2769}
2770
2771VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2772{
2773 struct statsContext context;
2774 eHalStatus status;
2775 hdd_context_t *pHddCtx;
2776
2777 if (NULL == pAdapter)
2778 {
2779 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2780 return VOS_STATUS_E_FAULT;
2781 }
2782
2783 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2784 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2785 init_completion(&context.completion);
2786
2787 context.pAdapter = pAdapter;
2788 context.magic = POWER_CONTEXT_MAGIC;
2789
2790 if (DRIVER_POWER_MODE_ACTIVE == mode)
2791 {
2792 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2793 "Full Power", __func__);
2794 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2795 iw_power_callback_fn, &context,
2796 eSME_FULL_PWR_NEEDED_BY_HDD);
2797 // Enter Full power command received from GUI this means we are disconnected
2798 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2799 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2800 if (eHAL_STATUS_PMC_PENDING == status)
2801 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002802 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 int lrc = wait_for_completion_interruptible_timeout(
2804 &context.completion,
2805 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002806
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 if (lrc <= 0)
2808 {
2809 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002810 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 }
2812 }
2813 }
2814 else if (DRIVER_POWER_MODE_AUTO == mode)
2815 {
2816 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2817 {
2818 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2819 __func__);
2820 // Enter BMPS command received from GUI this means DHCP is completed
2821 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2822 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2823 FALSE);
2824 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2825 iw_power_callback_fn, &context);
2826 if (eHAL_STATUS_PMC_PENDING == status)
2827 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002828 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 int lrc = wait_for_completion_interruptible_timeout(
2830 &context.completion,
2831 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 if (lrc <= 0)
2833 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002834 hddLog(VOS_TRACE_LEVEL_ERROR,
2835 "%s: SME %s while requesting BMPS",
2836 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 }
2838 }
2839 }
2840 else
2841 {
2842 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2843 "enabled in the cfg");
2844 }
2845 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002846
2847 /* either we never sent a request, we sent a request and received a
2848 response or we sent a request and timed out. if we never sent a
2849 request or if we sent a request and got a response, we want to
2850 clear the magic out of paranoia. if we timed out there is a
2851 race condition such that the callback function could be
2852 executing at the same time we are. of primary concern is if the
2853 callback function had already verified the "magic" but had not
2854 yet set the completion variable when a timeout occurred. we
2855 serialize these activities by invalidating the magic while
2856 holding a shared spinlock which will cause us to block if the
2857 callback is currently executing */
2858 spin_lock(&hdd_context_lock);
2859 context.magic = 0;
2860 spin_unlock(&hdd_context_lock);
2861
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 return VOS_STATUS_SUCCESS;
2863}
2864
2865VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2866 hdd_adapter_t *pAdapter)
2867{
2868 VOS_STATUS vos_Status;
2869
2870 if ((NULL == pAdapter) || (NULL == pHddCtx))
2871 {
2872 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2873 return VOS_STATUS_E_FAULT;
2874 }
2875
2876 /**Exit from Deep sleep or standby if we get the driver
2877 START cmd from android GUI
2878 */
2879 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2880 {
2881 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2882 "from Stand by",__func__);
2883 vos_Status = hdd_exit_standby(pHddCtx);
2884 }
2885 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2886 {
2887 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2888 "from deep sleep",__func__);
2889 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2890 }
2891 else
2892 {
2893 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2894 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2895 vos_Status = VOS_STATUS_SUCCESS;
2896 }
2897
2898 return vos_Status;
2899}
2900
2901VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2902{
2903 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2904
2905 if (NULL == pHddCtx)
2906 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302907 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 return VOS_STATUS_E_FAULT;
2909 }
2910
2911 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2912 {
2913 //Execute standby procedure.
2914 //Executing standby procedure will cause the STA to
2915 //disassociate first and then the chip will be put into standby.
2916 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2917 vos_Status = hdd_enter_standby(pHddCtx);
2918 }
2919 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2920 pHddCtx->cfg_ini->nEnableDriverStop)
2921 {
2922 //Execute deep sleep procedure
2923 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002924 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 //Deep sleep not supported
2926 vos_Status = hdd_enter_standby(pHddCtx);
2927 }
2928 else
2929 {
2930 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2931 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2932 vos_Status = VOS_STATUS_SUCCESS;
2933 }
2934
2935 return vos_Status;
2936}
2937
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002938
2939void* wlan_hdd_change_country_code_callback(void *pAdapter)
2940{
2941
2942 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002943 complete(&call_back_pAdapter->change_country_code);
2944
2945 return NULL;
2946}
2947
Jeff Johnson295189b2012-06-20 16:38:30 -07002948static int iw_set_priv(struct net_device *dev,
2949 struct iw_request_info *info,
2950 union iwreq_data *wrqu, char *extra)
2951{
2952 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08002953 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 int cmd_len = wrqu->data.length;
2955 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08002956 int rc = 0;
2957 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2958
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2960
2961 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08002962 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2963 wrqu->data.length);
2964 if (NULL == cmd)
2965 {
2966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2967 "mem_alloc_copy_from_user_helper fail");
2968 return -ENOMEM;
2969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002970
2971 if (ioctl_debug)
2972 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002973 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 }
2975
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002976 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2977 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002978
2979 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08002980 if (ioctl_debug)
2981 {
2982 pr_info("%s: RESTART in progress\n", __func__);
2983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002984
Arif Hussain24bfa702014-01-22 13:51:30 -08002985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08002987 kfree(cmd);
2988 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 }
2990
Arif Hussain24bfa702014-01-22 13:51:30 -08002991 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 {
Arif Hussain24bfa702014-01-22 13:51:30 -08002993 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
2994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2995 "%s: Error in iw_set_scan!", __func__);
2996 rc = -EINVAL;
2997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 }
2999 else if( strcasecmp(cmd, "start") == 0 ) {
3000
Arif Hussain6d2a3322013-11-17 19:50:10 -08003001 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003003
Arif Hussain24bfa702014-01-22 13:51:30 -08003004 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3005 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 {
3007 union iwreq_data wrqu;
3008 char buf[10];
3009
3010 memset(&wrqu, 0, sizeof(wrqu));
3011 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3012 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3013 }
3014 else
3015 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003016 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3017 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 }
3019 goto done;
3020 }
3021 else if( strcasecmp(cmd, "stop") == 0 )
3022 {
3023 union iwreq_data wrqu;
3024 char buf[10];
3025
Arif Hussain6d2a3322013-11-17 19:50:10 -08003026 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003027
3028 wlan_hdd_enter_lowpower(pHddCtx);
3029 memset(&wrqu, 0, sizeof(wrqu));
3030 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3031 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 goto done;
3033 }
3034 else if (strcasecmp(cmd, "macaddr") == 0)
3035 {
3036 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3037 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3038 }
3039 else if (strcasecmp(cmd, "scan-active") == 0)
3040 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003041 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 ret = snprintf(cmd, cmd_len, "OK");
3043 }
3044 else if (strcasecmp(cmd, "scan-passive") == 0)
3045 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003046 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 ret = snprintf(cmd, cmd_len, "OK");
3048 }
3049 else if( strcasecmp(cmd, "scan-mode") == 0 )
3050 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003051 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 }
3053 else if( strcasecmp(cmd, "linkspeed") == 0 )
3054 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003055 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 }
3057 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3058 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003059 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003060 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003061
3062 country_code = cmd + 8;
3063
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003064 init_completion(&pAdapter->change_country_code);
3065
Arif Hussain24bfa702014-01-22 13:51:30 -08003066 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003067 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 country_code,
3069 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303070 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303071 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303072 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003073
3074 /* Wait for completion */
3075 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3076 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3077
3078 if (lrc <= 0)
3079 {
3080 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003081 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003082 }
3083
Arif Hussain24bfa702014-01-22 13:51:30 -08003084 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003086 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003087 "%s: SME Change Country code fail", __func__);
3088 kfree(cmd);
3089 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 }
3091 }
3092 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3093 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003094 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 }
3096 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3097 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003098 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003099
Wilson Yang1be3e652013-10-09 15:18:31 -07003100 if (9 < cmd_len)
3101 {
3102 ptr = (char*)(cmd + 9);
3103
3104 }else{
3105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3106 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003107 kfree(cmd);
3108 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003109 }
3110
3111 if (1 != sscanf(ptr,"%d",&mode))
3112 {
3113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3114 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003115 kfree(cmd);
3116 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003117 }
3118
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 wlan_hdd_enter_bmps(pAdapter, mode);
3120 /*TODO:Set the power mode*/
3121 }
3122 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3123 v_U32_t pmc_state;
3124 v_U16_t value;
3125
3126 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3127 if(pmc_state == BMPS) {
3128 value = DRIVER_POWER_MODE_AUTO;
3129 }
3130 else {
3131 value = DRIVER_POWER_MODE_ACTIVE;
3132 }
3133 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3134 }
3135 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003136 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 /*TODO: set the btcoexmode*/
3138 }
3139 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3140
Arif Hussain6d2a3322013-11-17 19:50:10 -08003141 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 /*TODO: Return the btcoex status*/
3143 }
3144 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3145
Arif Hussain6d2a3322013-11-17 19:50:10 -08003146 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003147
3148 /*TODO: Enable Rx data Filter*/
3149 }
3150 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3151
Arif Hussain6d2a3322013-11-17 19:50:10 -08003152 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003153
3154 /*TODO: Disable Rx data Filter*/
3155 }
3156 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3157
Arif Hussain6d2a3322013-11-17 19:50:10 -08003158 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 /*TODO: rxfilter-statistics*/
3160 }
3161 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3162
Arif Hussain6d2a3322013-11-17 19:50:10 -08003163 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 /*TODO: rxfilter-add*/
3165 }
3166 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3167
Arif Hussain6d2a3322013-11-17 19:50:10 -08003168 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 /*TODO: rxfilter-remove*/
3170 }
3171#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003172 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3173 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3174 /*TODO: support pnosetup*/
3175 }
3176 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3177 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3178 /*TODO: support pnoforce*/
3179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3181
Arif Hussain6d2a3322013-11-17 19:50:10 -08003182 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003183 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3184 kfree(cmd);
3185 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 }
3187 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003188 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003189 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3190 kfree(cmd);
3191 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 }
3193#endif /*FEATURE_WLAN_SCAN_PNO*/
3194 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003195 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003196 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3197 kfree(cmd);
3198 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003199 }
3200 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3201 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003202 char *ptr;
3203
3204 if (18 < cmd_len)
3205 {
3206 ptr = (char*)(cmd + 18);
3207 }else{
3208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3209 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003210 kfree(cmd);
3211 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003212 }
3213
Jeff Johnson02797792013-10-26 19:17:13 -07003214 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003215 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3216 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3217 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3218 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3219 {
3220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3221 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003222 kfree(cmd);
3223 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003225
3226 // parameters checking
3227 // period has to be larger than 0
3228 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3229 {
3230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003231 kfree(cmd);
3232 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 }
3234
3235 // use default value 5 is the input is not reasonable. in unit of 10%
3236 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3237 {
3238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3239 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3240 }
3241
3242 // default is 5
3243 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3244 {
3245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3246 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3247 }
3248
Arif Hussain24bfa702014-01-22 13:51:30 -08003249 if (eHAL_STATUS_SUCCESS !=
3250 sme_SetTxPerTracking(pHddCtx->hHal,
3251 hdd_tx_per_hit_cb,
3252 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003254 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 }
3256 }
3257 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003258 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3259 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 }
3261done:
3262 /* many of the commands write information back into the command
3263 string using snprintf(). check the return value here in one
3264 place */
3265 if ((ret < 0) || (ret >= cmd_len))
3266 {
3267 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003268 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003270 else if (ret > 0)
3271 {
3272 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3273 {
3274 hddLog(VOS_TRACE_LEVEL_ERROR,
3275 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003276 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003277 return -EFAULT;
3278 }
3279 wrqu->data.length = ret;
3280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003281
3282 if (ioctl_debug)
3283 {
3284 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003285 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003287 kfree(cmd);
3288 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003289}
3290
3291static int iw_set_nick(struct net_device *dev,
3292 struct iw_request_info *info,
3293 union iwreq_data *wrqu, char *extra)
3294{
3295 ENTER();
3296 return 0;
3297}
3298
3299static int iw_get_nick(struct net_device *dev,
3300 struct iw_request_info *info,
3301 union iwreq_data *wrqu, char *extra)
3302{
3303 ENTER();
3304 return 0;
3305}
3306
3307static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3308{
3309 ENTER();
3310 return NULL;
3311}
3312
3313static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3314 union iwreq_data *wrqu,char *extra)
3315
3316{
3317 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3318 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3319 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3320 struct iw_point *encoderq = &(wrqu->encoding);
3321 v_U32_t keyId;
3322 v_U8_t key_length;
3323 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3324 v_BOOL_t fKeyPresent = 0;
3325 int i;
3326 eHalStatus status = eHAL_STATUS_SUCCESS;
3327
3328
3329 ENTER();
3330
3331 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3332 {
3333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3334 "%s:LOGP in Progress. Ignore!!!",__func__);
3335 return 0;
3336 }
3337
3338
3339 keyId = encoderq->flags & IW_ENCODE_INDEX;
3340
3341 if(keyId)
3342 {
3343 if(keyId > MAX_WEP_KEYS)
3344 {
3345 return -EINVAL;
3346 }
3347
3348 fKeyPresent = 1;
3349 keyId--;
3350 }
3351 else
3352 {
3353 fKeyPresent = 0;
3354 }
3355
3356
3357 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3358 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 if(!fKeyPresent) {
3361
3362 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3363
3364 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3365 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3366 }
3367 }
3368 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3369 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3370 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3371 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3372
3373 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3374 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3375
3376 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3377 {
3378 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3379 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003380 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3382 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3383 }
3384
3385 return status;
3386
3387 }
3388
3389 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3390 {
3391 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3392
3393 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3394
3395 }
3396
3397
3398 if(wrqu->data.length > 0)
3399 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003400 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003401
3402 key_length = wrqu->data.length;
3403
3404 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3405
3406 if(5 == key_length)
3407 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003408 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003409
3410 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3411 {
3412 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3413 }
3414 else
3415 {
3416 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3417 }
3418 }
3419 else if(13 == key_length)
3420 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003421 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003422
3423 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3424 {
3425 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3426 }
3427 else
3428 {
3429 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3430 }
3431 }
3432 else
3433 {
3434 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003435 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 return -EINVAL;
3437 }
3438
3439 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3440 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3441 pWextState->roamProfile.EncryptionType.numEntries = 1;
3442 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3443 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3444 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3445
3446 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3447 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3448 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3449 {
3450
3451 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3452
3453 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3454 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3455
3456 return status;
3457 }
3458 }
3459
3460 return 0;
3461}
3462
3463static int iw_get_encodeext(struct net_device *dev,
3464 struct iw_request_info *info,
3465 struct iw_point *dwrq,
3466 char *extra)
3467{
3468 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3469 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3470 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3471 int keyId;
3472 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3473 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3474 int i;
3475
3476 ENTER();
3477
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003478 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3479 {
3480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3481 "%s:LOGP in Progress. Ignore!!!", __func__);
3482 return -EBUSY;
3483 }
3484
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 keyId = pRoamProfile->Keys.defaultIndex;
3486
3487 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3488 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003489 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 return -EINVAL;
3491 }
3492
3493 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3494 {
3495 dwrq->flags |= IW_ENCODE_ENABLED;
3496 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303497 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3498 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 }
3500 else
3501 {
3502 dwrq->flags |= IW_ENCODE_DISABLED;
3503 }
3504
3505 for(i=0; i < MAX_WEP_KEYS; i++)
3506 {
3507 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3508 {
3509 continue;
3510 }
3511 else
3512 {
3513 break;
3514 }
3515 }
3516
3517 if(MAX_WEP_KEYS == i)
3518 {
3519 dwrq->flags |= IW_ENCODE_NOKEY;
3520 }
3521 else
3522 {
3523 dwrq->flags |= IW_ENCODE_ENABLED;
3524 }
3525
3526 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3527
3528 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3529 {
3530 dwrq->flags |= IW_ENCODE_DISABLED;
3531 }
3532
3533 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3534
3535 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3536 {
3537 dwrq->flags |= IW_ENCODE_OPEN;
3538 }
3539 else
3540 {
3541 dwrq->flags |= IW_ENCODE_RESTRICTED;
3542 }
3543 EXIT();
3544 return 0;
3545
3546}
3547
3548static int iw_set_encodeext(struct net_device *dev,
3549 struct iw_request_info *info,
3550 union iwreq_data *wrqu, char *extra)
3551{
3552 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3553 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3554 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3555 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3556
3557 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3558 v_U32_t status = 0;
3559
3560 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3561
3562 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3563
3564 int key_index;
3565 struct iw_point *encoding = &wrqu->encoding;
3566 tCsrRoamSetKey setKey;
3567 v_U32_t roamId= 0xFF;
3568 VOS_STATUS vos_status;
3569
3570 ENTER();
3571
3572 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3573 {
3574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3575 "%s:LOGP in Progress. Ignore!!!",__func__);
3576 return 0;
3577 }
3578
3579 key_index = encoding->flags & IW_ENCODE_INDEX;
3580
3581 if(key_index > 0) {
3582
3583 /*Convert from 1-based to 0-based keying*/
3584 key_index--;
3585 }
3586 if(!ext->key_len) {
3587
3588 /*Set the encrytion type to NONE*/
3589 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3590 return status;
3591 }
3592
3593 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3594 (IW_ENCODE_ALG_WEP == ext->alg))
3595 {
3596 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3597
Agarwal Ashish971c2882013-10-30 20:11:12 +05303598 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3599 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 return -EINVAL;
3601 }
3602 else {
3603 /*Static wep, update the roam profile with the keys */
3604 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3605 key_index < CSR_MAX_NUM_KEY) {
3606 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3607 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3608
3609 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3610 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3611
3612 }
3613 }
3614 return status;
3615 }
3616
3617 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3618
3619 setKey.keyId = key_index;
3620 setKey.keyLength = ext->key_len;
3621
3622 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3623 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3624 }
3625
3626 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3627 /*Key direction for group is RX only*/
3628 setKey.keyDirection = eSIR_RX_ONLY;
3629 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3630 }
3631 else {
3632
3633 setKey.keyDirection = eSIR_TX_RX;
3634 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3635 }
3636
3637 /*For supplicant pae role is zero*/
3638 setKey.paeRole = 0;
3639
3640 switch(ext->alg)
3641 {
3642 case IW_ENCODE_ALG_NONE:
3643 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3644 break;
3645
3646 case IW_ENCODE_ALG_WEP:
3647 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3648 break;
3649
3650 case IW_ENCODE_ALG_TKIP:
3651 {
3652 v_U8_t *pKey = &setKey.Key[0];
3653
3654 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3655
3656 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3657
3658 /*Supplicant sends the 32bytes key in this order
3659
3660 |--------------|----------|----------|
3661 | Tk1 |TX-MIC | RX Mic |
3662 |--------------|----------|----------|
3663 <---16bytes---><--8bytes--><--8bytes-->
3664
3665 */
3666 /*Sme expects the 32 bytes key to be in the below order
3667
3668 |--------------|----------|----------|
3669 | Tk1 |RX-MIC | TX Mic |
3670 |--------------|----------|----------|
3671 <---16bytes---><--8bytes--><--8bytes-->
3672 */
3673 /* Copy the Temporal Key 1 (TK1) */
3674 vos_mem_copy(pKey,ext->key,16);
3675
3676 /*Copy the rx mic first*/
3677 vos_mem_copy(&pKey[16],&ext->key[24],8);
3678
3679 /*Copy the tx mic */
3680 vos_mem_copy(&pKey[24],&ext->key[16],8);
3681
3682 }
3683 break;
3684
3685 case IW_ENCODE_ALG_CCMP:
3686 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3687 break;
3688
3689#ifdef FEATURE_WLAN_CCX
3690#define IW_ENCODE_ALG_KRK 6
3691 case IW_ENCODE_ALG_KRK:
3692 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3693 break;
3694#endif /* FEATURE_WLAN_CCX */
3695
3696 default:
3697 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3698 break;
3699 }
3700
3701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003702 ("%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 -07003703
3704#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303705 /* The supplicant may attempt to set the PTK once pre-authentication
3706 is done. Save the key in the UMAC and include it in the ADD
3707 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303709 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303711 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3712 "%s: Update PreAuth Key success", __func__);
3713 return 0;
3714 }
3715 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3716 {
3717 hddLog(VOS_TRACE_LEVEL_ERROR,
3718 "%s: Update PreAuth Key failed", __func__);
3719 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 }
3721#endif /* WLAN_FEATURE_VOWIFI_11R */
3722
3723 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3724
3725 vos_status = wlan_hdd_check_ula_done(pAdapter);
3726 if ( vos_status != VOS_STATUS_SUCCESS )
3727 {
3728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3729 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3730 __LINE__, vos_status );
3731
3732 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3733 }
3734
3735 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3736
3737 if ( halStatus != eHAL_STATUS_SUCCESS )
3738 {
3739 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3740 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3741 __LINE__, halStatus );
3742
3743 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3744 }
3745
3746 return halStatus;
3747}
3748
3749static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3750 union iwreq_data *wrqu, char *extra)
3751{
3752 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3753 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3754
3755 ENTER();
3756
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003757 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3758 {
3759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3760 "%s:LOGP in Progress. Ignore!!!", __func__);
3761 return -EBUSY;
3762 }
3763
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3765 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3766
Arif Hussain6d2a3322013-11-17 19:50:10 -08003767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003768
3769 return -EINVAL;
3770 }
3771
3772 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3773
3774 if((wrqu->retry.flags & IW_RETRY_LONG))
3775 {
3776 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3777 {
3778 return -EIO;
3779 }
3780 }
3781 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3782 {
3783 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3784 {
3785 return -EIO;
3786 }
3787 }
3788 }
3789 else
3790 {
3791 return -EOPNOTSUPP;
3792 }
3793
Arif Hussain6d2a3322013-11-17 19:50:10 -08003794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003795
3796 EXIT();
3797
3798 return 0;
3799
3800}
3801
3802static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3803 union iwreq_data *wrqu, char *extra)
3804{
3805 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3806 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3807 v_U32_t retry = 0;
3808
3809 ENTER();
3810
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003811 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3812 {
3813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3814 "%s:LOGP in Progress. Ignore!!!", __func__);
3815 return -EBUSY;
3816 }
3817
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 if((wrqu->retry.flags & IW_RETRY_LONG))
3819 {
3820 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3821
3822 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3823 {
3824 return -EIO;
3825 }
3826
3827 wrqu->retry.value = retry;
3828 }
3829 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3830 {
3831 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3832
3833 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3834 {
3835 return -EIO;
3836 }
3837
3838 wrqu->retry.value = retry;
3839 }
3840 else {
3841 return -EOPNOTSUPP;
3842 }
3843
Arif Hussain6d2a3322013-11-17 19:50:10 -08003844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003845
3846 EXIT();
3847
3848 return 0;
3849}
3850
3851static int iw_set_mlme(struct net_device *dev,
3852 struct iw_request_info *info,
3853 union iwreq_data *wrqu,
3854 char *extra)
3855{
3856 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3857 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3858 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3859 eHalStatus status = eHAL_STATUS_SUCCESS;
3860
3861 ENTER();
3862
3863 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3864 {
3865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3866 "%s:LOGP in Progress. Ignore!!!",__func__);
3867 return 0;
3868 }
3869
3870 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3871 switch (mlme->cmd) {
3872 case IW_MLME_DISASSOC:
3873 case IW_MLME_DEAUTH:
3874
3875 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3876 {
3877 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3878
3879 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3880 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3881
3882 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3883 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3884
Jeff Johnson43971f52012-07-17 12:26:56 -07003885 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3887 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3888 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08003889 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003890 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003891
3892 /* Resetting authKeyMgmt */
3893 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3894
3895 netif_tx_disable(dev);
3896 netif_carrier_off(dev);
3897
3898 }
3899 else
3900 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003901 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 -07003902 }
3903 break;
3904 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003905 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 return -EINVAL;
3907 }//end of switch
3908
3909 EXIT();
3910
3911 return status;
3912
3913}
3914
3915/* set param sub-ioctls */
3916static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3917 union iwreq_data *wrqu, char *extra)
3918{
3919 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3920 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3921 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3922 int *value = (int *)extra;
3923 int sub_cmd = value[0];
3924 int set_value = value[1];
3925 int ret = 0; /* success */
3926 int enable_pbm, enable_mp;
3927#ifdef CONFIG_HAS_EARLYSUSPEND
3928 v_U8_t nEnableSuspendOld;
3929#endif
3930 INIT_COMPLETION(pWextState->completion_var);
3931
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003932 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3933 {
3934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3935 "%s:LOGP in Progress. Ignore!!!", __func__);
3936 return -EBUSY;
3937 }
3938
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 switch(sub_cmd)
3940 {
3941 case WE_SET_11D_STATE:
3942 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003943 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07003944 memset(&smeConfig, 0x00, sizeof(smeConfig));
3945
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3947
3948 sme_GetConfigParam(hHal,&smeConfig);
3949 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3950
Arif Hussain6d2a3322013-11-17 19:50:10 -08003951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07003952
3953 sme_UpdateConfig(hHal,&smeConfig);
3954 }
3955 else {
3956 return -EINVAL;
3957 }
3958 break;
3959 }
3960
3961 case WE_WOWL:
3962 {
3963 switch (set_value)
3964 {
3965 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003966 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 break;
3968 case 0x01:
3969 case 0x02:
3970 case 0x03:
3971 enable_mp = (set_value & 0x01) ? 1 : 0;
3972 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003973 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
3975 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
3976 break;
3977 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003978 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 ret = -EINVAL;
3980 break;
3981 }
3982
3983 break;
3984 }
3985 case WE_SET_POWER:
3986 {
3987 switch (set_value)
3988 {
3989 case 0: //Full Power
3990 {
3991 struct statsContext context;
3992 eHalStatus status;
3993
3994 init_completion(&context.completion);
3995
3996 context.pAdapter = pAdapter;
3997 context.magic = POWER_CONTEXT_MAGIC;
3998
3999 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4000 iw_power_callback_fn, &context,
4001 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004002 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 {
4004 int lrc = wait_for_completion_interruptible_timeout(
4005 &context.completion,
4006 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004007
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 if (lrc <= 0)
4009 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004010 hddLog(VOS_TRACE_LEVEL_ERROR,
4011 "%s: SME %s while requesting fullpower",
4012 __func__, (0 == lrc) ?
4013 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 }
4015 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004016 /* either we have a response or we timed out. if we timed
4017 out there is a race condition such that the callback
4018 function could be executing at the same time we are. of
4019 primary concern is if the callback function had already
4020 verified the "magic" but had not yet set the completion
4021 variable when a timeout occurred. we serialize these
4022 activities by invalidating the magic while holding a
4023 shared spinlock which will cause us to block if the
4024 callback is currently executing */
4025 spin_lock(&hdd_context_lock);
4026 context.magic = 0;
4027 spin_unlock(&hdd_context_lock);
4028
Arif Hussain6d2a3322013-11-17 19:50:10 -08004029 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 break;
4031 }
4032 case 1: //Enable BMPS
4033 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4034 break;
4035 case 2: //Disable BMPS
4036 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4037 break;
4038 case 3: //Request Bmps
4039 {
4040 struct statsContext context;
4041 eHalStatus status;
4042
4043 init_completion(&context.completion);
4044
4045 context.pAdapter = pAdapter;
4046 context.magic = POWER_CONTEXT_MAGIC;
4047
4048 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4049 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004050 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 {
4052 int lrc = wait_for_completion_interruptible_timeout(
4053 &context.completion,
4054 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 if (lrc <= 0)
4056 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004057 hddLog(VOS_TRACE_LEVEL_ERROR,
4058 "%s: SME %s while requesting BMPS",
4059 __func__, (0 == lrc) ? "timeout" :
4060 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 }
4062 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004063 /* either we have a response or we timed out. if we
4064 timed out there is a race condition such that the
4065 callback function could be executing at the same
4066 time we are. of primary concern is if the callback
4067 function had already verified the "magic" but had
4068 not yet set the completion variable when a timeout
4069 occurred. we serialize these activities by
4070 invalidating the magic while holding a shared
4071 spinlock which will cause us to block if the
4072 callback is currently executing */
4073 spin_lock(&hdd_context_lock);
4074 context.magic = 0;
4075 spin_unlock(&hdd_context_lock);
4076
Arif Hussain6d2a3322013-11-17 19:50:10 -08004077 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 break;
4079 }
4080 case 4: //Enable IMPS
4081 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4082 break;
4083 case 5: //Disable IMPS
4084 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4085 break;
4086 case 6: //Enable Standby
4087 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4088 break;
4089 case 7: //Disable Standby
4090 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4091 break;
4092 case 8: //Request Standby
4093#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004094#endif
4095 break;
4096 case 9: //Start Auto Bmps Timer
4097 sme_StartAutoBmpsTimer(hHal);
4098 break;
4099 case 10://Stop Auto BMPS Timer
4100 sme_StopAutoBmpsTimer(hHal);
4101 break;
4102#ifdef CONFIG_HAS_EARLYSUSPEND
4103 case 11://suspend to standby
4104#ifdef CONFIG_HAS_EARLYSUSPEND
4105 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4106 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4108#endif
4109 break;
4110 case 12://suspend to deep sleep
4111#ifdef CONFIG_HAS_EARLYSUSPEND
4112 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4113 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4115#endif
4116 break;
4117 case 13://resume from suspend
4118#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004119#endif
4120 break;
4121#endif
4122 case 14://reset wlan (power down/power up)
4123 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4124 break;
4125 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004126 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 ret = -EINVAL;
4128 break;
4129 }
4130 break;
4131 }
4132
4133 case WE_SET_MAX_ASSOC:
4134 {
4135 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4136 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4137 {
4138 ret = -EINVAL;
4139 }
4140 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4141 set_value, NULL, eANI_BOOLEAN_FALSE)
4142 != eHAL_STATUS_SUCCESS )
4143 {
4144 ret = -EIO;
4145 }
4146 break;
4147 }
4148
4149 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4150 {
4151 if( 0 == set_value )
4152 {
4153 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4154 }
4155 else if ( 1 == set_value )
4156 {
4157 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4158 }
4159 else
4160 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004161 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 ret = -EINVAL;
4163 }
4164 break;
4165 }
4166
4167 case WE_SET_DATA_INACTIVITY_TO:
4168 {
4169 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4170 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4171 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4172 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4173 set_value,
4174 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4175 {
4176 hddLog(LOGE,"Failure: Could not pass on "
4177 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004178 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 ret = -EINVAL;
4180 }
4181 break;
4182 }
4183 case WE_SET_MAX_TX_POWER:
4184 {
4185 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4186 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4187
4188 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4189 __func__, set_value);
4190 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4191 eHAL_STATUS_SUCCESS )
4192 {
4193 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4194 __func__);
4195 return -EIO;
4196 }
4197
4198 break;
4199 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004200 case WE_SET_MAX_TX_POWER_2_4:
4201 {
4202 hddLog(VOS_TRACE_LEVEL_INFO,
4203 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4204 __func__, set_value);
4205 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4206 eHAL_STATUS_SUCCESS)
4207 {
4208 hddLog(VOS_TRACE_LEVEL_ERROR,
4209 "%s: Setting maximum tx power failed for 2.4 GHz band",
4210 __func__);
4211 return -EIO;
4212 }
4213
4214 break;
4215 }
4216 case WE_SET_MAX_TX_POWER_5_0:
4217 {
4218 hddLog(VOS_TRACE_LEVEL_INFO,
4219 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4220 __func__, set_value);
4221 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4222 eHAL_STATUS_SUCCESS)
4223 {
4224 hddLog(VOS_TRACE_LEVEL_ERROR,
4225 "%s: Setting maximum tx power failed for 5.0 GHz band",
4226 __func__);
4227 return -EIO;
4228 }
4229
4230 break;
4231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 case WE_SET_HIGHER_DTIM_TRANSITION:
4233 {
4234 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4235 (set_value == eANI_BOOLEAN_TRUE)))
4236 {
4237 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4238 ret = -EINVAL;
4239 }
4240 else
4241 {
4242 if(pAdapter->higherDtimTransition != set_value)
4243 {
4244 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004245 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 }
4247 }
4248
4249 break;
4250 }
4251
4252 case WE_SET_TM_LEVEL:
4253 {
4254 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004255 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4257
4258 break;
4259 }
4260
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304261 case WE_ENABLE_STRICT_FCC_REG:
4262 {
4263 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4264 struct wiphy *wiphy = NULL;
4265 long lrc;
4266 int status;
4267
4268 wiphy = hddCtxt->wiphy;
4269 if(wiphy == NULL)
4270 {
4271 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4272 break;
4273 }
4274 init_completion(&hddCtxt->wiphy_channel_update_event);
4275
4276 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4277
4278 status = regulatory_hint(wiphy, "00");
4279 if(status < 0)
4280 {
4281 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4282 break;
4283 }
4284
4285 /* Wait for completion */
4286 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4287 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4288 if (lrc <= 0)
4289 {
4290 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4291 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4292 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4293 }
4294 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4295
4296 break;
4297 }
4298
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 default:
4300 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004301 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 sub_cmd, set_value);
4303 break;
4304 }
4305 }
4306
4307 return ret;
4308}
4309
4310/* set param sub-ioctls */
4311static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4312 union iwreq_data *wrqu, char *extra)
4313{
4314 VOS_STATUS vstatus;
4315 int sub_cmd = wrqu->data.flags;
4316 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004317 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4319 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4320#ifdef WLAN_FEATURE_VOWIFI
4321 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4322#endif /* WLAN_FEATURE_VOWIFI */
4323
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004324 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4325 {
4326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4327 "%s:LOGP in Progress. Ignore!!!", __func__);
4328 return -EBUSY;
4329 }
4330
Arif Hussain0273cba2014-01-07 20:58:29 -08004331 /* ODD number is used for set, copy data using copy_from_user */
4332 pBuffer = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4333 wrqu->data.length);
4334 if (NULL == pBuffer)
4335 {
4336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4337 "mem_alloc_copy_from_user_helper fail");
4338 return -ENOMEM;
4339 }
4340
4341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4342 "%s: Received length %d", __func__, wrqu->data.length);
4343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4344 "%s: Received data %s", __func__, pBuffer);
4345
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 switch(sub_cmd)
4347 {
4348 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004350 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 break;
4352 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004354 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004355 break;
4356#if defined WLAN_FEATURE_VOWIFI
4357 case WE_NEIGHBOR_REPORT_REQUEST:
4358 {
4359 tRrmNeighborReq neighborReq;
4360 tRrmNeighborRspCallbackInfo callbackInfo;
4361
4362 if (pConfig->fRrmEnable)
4363 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004365 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4366 if( !neighborReq.no_ssid )
4367 {
4368 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004369 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 }
4371
4372 callbackInfo.neighborRspCallback = NULL;
4373 callbackInfo.neighborRspCallbackContext = NULL;
4374 callbackInfo.timeout = 5000; //5 seconds
4375 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4376 }
4377 else
4378 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004379 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 ret = -EINVAL;
4381 }
4382 }
4383 break;
4384#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 case WE_SET_AP_WPS_IE:
4386 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain0273cba2014-01-07 20:58:29 -08004387 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004390 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 if (VOS_STATUS_SUCCESS != vstatus)
4392 {
4393 ret = -EINVAL;
4394 }
4395 break;
4396 default:
4397 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004398 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 ret = -EINVAL;
4400 break;
4401 }
4402 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004403 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 return ret;
4405}
4406
4407/* get param sub-ioctls */
4408static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4409 union iwreq_data *wrqu, char *extra)
4410{
4411 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4412 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4413 int *value = (int *)extra;
4414 int ret = 0; /* success */
4415
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004416 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4417 {
4418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4419 "%s:LOGP in Progress. Ignore!!!", __func__);
4420 return -EBUSY;
4421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004422
4423 switch (value[0])
4424 {
4425 case WE_GET_11D_STATE:
4426 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004427 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304429
Jeff Johnson295189b2012-06-20 16:38:30 -07004430 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4431
Arif Hussain6d2a3322013-11-17 19:50:10 -08004432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004433
4434 break;
4435 }
4436
4437 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 break;
4440
4441 case WE_PMC_STATE:
4442 {
4443 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 break;
4446 }
4447 case WE_GET_WLAN_DBG:
4448 {
4449 vos_trace_display();
4450 *value = 0;
4451 break;
4452 }
4453 case WE_MODULE_DOWN_IND:
4454 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4457#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4460#endif
4461 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4462
4463 *value = 0;
4464 break;
4465 }
4466 case WE_GET_MAX_ASSOC:
4467 {
4468 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4469 {
4470 ret = -EIO;
4471 }
4472 break;
4473 }
4474
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 case WE_GET_WDI_DBG:
4476 {
4477 wpalTraceDisplay();
4478 *value = 0;
4479 break;
4480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004481
4482 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4483 {
4484 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4485 break;
4486 }
4487 case WE_GET_CONCURRENCY_MODE:
4488 {
4489 *value = hdd_get_concurrency_mode ( );
4490
Arif Hussain6d2a3322013-11-17 19:50:10 -08004491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 break;
4493 }
4494
4495 default:
4496 {
4497 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4498 break;
4499 }
4500 }
4501
4502 return ret;
4503}
4504
4505/* set param sub-ioctls */
4506int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4507 union iwreq_data *wrqu, char *extra)
4508{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004509 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 int *value = (int *)extra;
4511 int sub_cmd = value[0];
4512 int ret = 0;
4513
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004514 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4515 {
4516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4517 "%s:LOGP in Progress. Ignore!!!", __func__);
4518 return -EBUSY;
4519 }
4520
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 switch(sub_cmd)
4522 {
4523 case WE_SET_WLAN_DBG:
4524 {
4525 vos_trace_setValue( value[1], value[2], value[3]);
4526 break;
4527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 case WE_SET_WDI_DBG:
4529 {
4530 wpalTraceSetLevel( value[1], value[2], value[3]);
4531 break;
4532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 case WE_SET_SAP_CHANNELS:
4534 {
4535 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4536 break;
4537 }
4538
4539 default:
4540 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004541 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 break;
4543 }
4544 }
4545 return ret;
4546}
4547
4548static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4549 union iwreq_data *wrqu, char *extra)
4550{
4551 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4552 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004553#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004554 hdd_wext_state_t *pWextState;
4555#endif
4556
4557 if (pAdapter == NULL)
4558 {
4559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4560 "%s: pAdapter is NULL!", __func__);
4561 return -EINVAL;
4562 }
4563#ifdef WLAN_FEATURE_11W
4564 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004565#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004566
Yue Ma3ede6052013-08-29 00:33:26 -07004567 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4568 {
4569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4570 "%s: HDD Context is NULL!", __func__);
4571
4572 return -EINVAL;
4573 }
4574
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004575 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4576 {
4577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4578 "%s:LOGP in Progress. Ignore!!!", __func__);
4579 return -EBUSY;
4580 }
4581
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 switch(sub_cmd)
4583 {
4584 case WE_WLAN_VERSION:
4585 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004586 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 break;
4588 }
4589
4590 case WE_GET_STATS:
4591 {
4592 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4593 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4594 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4595
4596 snprintf(extra, WE_MAX_STR_LEN,
4597 "\nTransmit"
4598 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4599 "\n dropped BK %u, BE %u, VI %u, VO %u"
4600 "\n classified BK %u, BE %u, VI %u, VO %u"
4601 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4602 "\n queued BK %u, BE %u, VI %u, VO %u"
4603 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004604 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 "\n fetched BK %u, BE %u, VI %u, VO %u"
4606 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4607 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004608 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 "\n flushed BK %u, BE %u, VI %u, VO %u"
4610 "\n\nReceive"
4611 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4612 "\n\nResetsStats"
4613 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4614 "\n",
4615 pStats->txXmitCalled,
4616 pStats->txXmitDropped,
4617 pStats->txXmitBackPressured,
4618 pStats->txXmitQueued,
4619
4620 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4621 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4622 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4623 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4624
4625 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4626 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4627 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4628 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4629
4630 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4631 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4632 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4633 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4634
4635 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4636 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4637 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4638 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4639
4640 pStats->txFetched,
4641 pStats->txFetchEmpty,
4642 pStats->txFetchLowResources,
4643 pStats->txFetchDequeueError,
4644
4645 pStats->txFetchDequeued,
4646 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004647 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 pStats->txCompleted,
4649 pStats->txFlushed,
4650
4651 pStats->txFetchedAC[WLANTL_AC_BK],
4652 pStats->txFetchedAC[WLANTL_AC_BE],
4653 pStats->txFetchedAC[WLANTL_AC_VI],
4654 pStats->txFetchedAC[WLANTL_AC_VO],
4655
4656 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4657 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4658 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4659 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4660
4661 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4662 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4663 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4664 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4665
Ravi Joshi41914632013-10-21 23:02:21 -07004666 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4667 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4668 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4669 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4670
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 pStats->txFlushedAC[WLANTL_AC_BK],
4672 pStats->txFlushedAC[WLANTL_AC_BE],
4673 pStats->txFlushedAC[WLANTL_AC_VI],
4674 pStats->txFlushedAC[WLANTL_AC_VO],
4675
4676 pStats->rxChains,
4677 pStats->rxPackets,
4678 pStats->rxDropped,
4679 pStats->rxDelivered,
4680 pStats->rxRefused,
4681
4682 pResetStats->totalLogpResets,
4683 pResetStats->totalCMD53Failures,
4684 pResetStats->totalMutexReadFailures,
4685 pResetStats->totalMIFErrorFailures,
4686 pResetStats->totalFWHearbeatFailures,
4687 pResetStats->totalUnknownExceptions
4688 );
4689 wrqu->data.length = strlen(extra)+1;
4690 break;
4691 }
4692
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304693/* The case prints the current state of the HDD, SME, CSR, PE, TL
4694 *it can be extended for WDI Global State as well.
4695 *And currently it only checks P2P_CLIENT adapter.
4696 *P2P_DEVICE and P2P_GO have not been added as of now.
4697*/
4698 case WE_GET_STATES:
4699 {
4700 int buf = 0, len = 0;
4701 int adapter_num = 0;
4702 int count = 0, check = 1;
4703
4704 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004705 tHalHandle hHal = NULL;
4706 tpAniSirGlobal pMac = NULL;
4707 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304708
4709 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4710 hdd_adapter_t *useAdapter = NULL;
4711
4712 /* Print wlan0 or p2p0 states based on the adapter_num
4713 *by using the correct adapter
4714 */
4715 while ( adapter_num < 2 )
4716 {
4717 if ( WLAN_ADAPTER == adapter_num )
4718 {
4719 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004720 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304721 "\n\n wlan0 States:-");
4722 len += buf;
4723 }
4724 else if ( P2P_ADAPTER == adapter_num )
4725 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004726 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304727 "\n\n p2p0 States:-");
4728 len += buf;
4729
4730 if( !pHddCtx )
4731 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004732 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304733 "\n pHddCtx is NULL");
4734 len += buf;
4735 break;
4736 }
4737
4738 /*Printing p2p0 states only in the case when the device is
4739 configured as a p2p_client*/
4740 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4741 if ( !useAdapter )
4742 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004743 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304744 "\n Device not configured as P2P_CLIENT.");
4745 len += buf;
4746 break;
4747 }
4748 }
4749
4750 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004751 if (!hHal) {
4752 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4753 "\n pMac is NULL");
4754 len += buf;
4755 break;
4756 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304757 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004758 if (!pMac) {
4759 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4760 "\n pMac is NULL");
4761 len += buf;
4762 break;
4763 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304764 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4765 if( !pHddStaCtx )
4766 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004767 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304768 "\n pHddStaCtx is NULL");
4769 len += buf;
4770 break;
4771 }
4772
4773 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4774
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004775 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304776 "\n HDD Conn State - %s "
4777 "\n \n SME State:"
4778 "\n Neighbour Roam State - %s"
4779 "\n CSR State - %s"
4780 "\n CSR Substate - %s"
4781 "\n \n TL STA %d State: %s",
4782 macTraceGetHDDWlanConnState(
4783 pHddStaCtx->conn_info.connState),
4784 macTraceGetNeighbourRoamState(
4785 pMac->roam.neighborRoamInfo.neighborRoamState),
4786 macTraceGetcsrRoamState(
4787 pMac->roam.curState[useAdapter->sessionId]),
4788 macTraceGetcsrRoamSubState(
4789 pMac->roam.curSubState[useAdapter->sessionId]),
4790 pHddStaCtx->conn_info.staId[0],
4791 macTraceGetTLState(tlState)
4792 );
4793 len += buf;
4794 adapter_num++;
4795 }
4796
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004797 if (pMac) {
4798 /* Printing Lim State starting with global lim states */
4799 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4800 "\n \n LIM STATES:-"
4801 "\n Global Sme State - %s "\
4802 "\n Global mlm State - %s "\
4803 "\n",
4804 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4805 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4806 );
4807 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304808
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004809 /*printing the PE Sme and Mlm states for valid lim sessions*/
4810 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304811 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004812 if ( pMac->lim.gpSession[count].valid )
4813 {
4814 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4815 "\n Lim Valid Session %d:-"
4816 "\n PE Sme State - %s "
4817 "\n PE Mlm State - %s "
4818 "\n",
4819 check,
4820 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4821 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4822 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304823
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004824 len += buf;
4825 check++;
4826 }
4827 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304828 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304829 }
4830
4831 wrqu->data.length = strlen(extra)+1;
4832 break;
4833 }
4834
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 case WE_GET_CFG:
4836 {
4837 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4838 wrqu->data.length = strlen(extra)+1;
4839 break;
4840 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004841#ifdef WLAN_FEATURE_11AC
4842 case WE_GET_RSSI:
4843 {
4844 v_S7_t s7Rssi = 0;
4845 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4846 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4847 wrqu->data.length = strlen(extra)+1;
4848 break;
4849 }
4850#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304851
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004852#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4853 case WE_GET_ROAM_RSSI:
4854 {
4855 v_S7_t s7Rssi = 0;
4856 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4857 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4858 wrqu->data.length = strlen(extra)+1;
4859 break;
4860 }
4861#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 case WE_GET_WMM_STATUS:
4863 {
4864 snprintf(extra, WE_MAX_STR_LEN,
4865 "\nDir: 0=up, 1=down, 3=both\n"
4866 "|------------------------|\n"
4867 "|AC | ACM |Admitted| Dir |\n"
4868 "|------------------------|\n"
4869 "|VO | %d | %3s | %d |\n"
4870 "|VI | %d | %3s | %d |\n"
4871 "|BE | %d | %3s | %d |\n"
4872 "|BK | %d | %3s | %d |\n"
4873 "|------------------------|\n",
4874 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4875 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4876 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4877 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4878 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4879 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4880 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4881 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4882 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4883 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4884 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4885 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4886
Jeff Johnsone7245742012-09-05 17:12:55 -07004887
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 wrqu->data.length = strlen(extra)+1;
4889 break;
4890 }
4891 case WE_GET_CHANNEL_LIST:
4892 {
4893 VOS_STATUS status;
4894 v_U8_t i, len;
4895 char* buf ;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004896
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 tChannelListInfo channel_list;
4898
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004899 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004901 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004903 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 return -EINVAL;
4905 }
4906 buf = extra;
4907
4908 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004909 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4910 * needed = 5 * number of channels. Check ifsufficient
4911 * buffer is available and then proceed to fill the buffer.
4912 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4914 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004915 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004916 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004917 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004918 return -EINVAL;
4919 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004920 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
4921 channel_list.num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 for(i = 0 ; i < channel_list.num_channels; i++)
4923 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004924 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 }
4927 wrqu->data.length = strlen(extra)+1;
4928
4929 break;
4930 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004931#ifdef FEATURE_WLAN_TDLS
4932 case WE_GET_TDLS_PEERS:
4933 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08004934 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004935 break;
4936 }
4937#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004938#ifdef WLAN_FEATURE_11W
4939 case WE_GET_11W_INFO:
4940 {
4941 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4942
4943 snprintf(extra, WE_MAX_STR_LEN,
4944 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4945 "\n Number of Unprotected Disassocs %d"
4946 "\n Number of Unprotected Deauths %d",
4947 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4948 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4949 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4950 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
4951 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
4952
4953 wrqu->data.length = strlen(extra)+1;
4954 break;
4955 }
4956#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304957 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004958 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004959 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 break;
4961 }
4962 }
4963
4964 return 0;
4965}
4966
4967/* action sub-ioctls */
4968static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4969 union iwreq_data *wrqu, char *extra)
4970{
4971 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4972 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004973 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004974
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004975 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4976 {
4977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4978 "%s:LOGP in Progress. Ignore!!!", __func__);
4979 return -EBUSY;
4980 }
4981
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 switch (sub_cmd)
4983 {
4984 case WE_CLEAR_STATS:
4985 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
4988 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
4989 break;
4990 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 case WE_INIT_AP:
4992 {
4993 pr_info("Init AP trigger\n");
4994 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
4995 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
4996 break;
4997 }
4998 case WE_STOP_AP:
4999 {
5000 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5001 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5002 * this is a dead code and need to find the adpater by name rather than mode */
5003 hdd_adapter_t* pAdapter_to_stop =
5004 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5005 if( pAdapter_to_stop )
5006 {
5007 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5008
5009 pr_info("Stopping AP mode\n");
5010
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305011 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5012 {
5013 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5014 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5015 }
5016
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 /*Make sure that pAdapter cleaned properly*/
5018 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5019 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5020 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5021
5022 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5023 pAdapter_to_stop->macAddressCurrent.bytes);
5024 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5025 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305026
5027 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5028 {
5029 /* put the device back into BMPS */
5030 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 }
5033 else
5034 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005035 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 }
5037
5038 break;
5039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005040#ifdef WLAN_BTAMP_FEATURE
5041 case WE_ENABLE_AMP:
5042 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 WLANBAP_RegisterWithHCI(pAdapter);
5045 break;
5046 }
5047 case WE_DISABLE_AMP:
5048 {
5049 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5050 VOS_STATUS status;
5051
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005053
5054 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5055 status = WLANBAP_StopAmp();
5056 if(VOS_STATUS_SUCCESS != status )
5057 {
5058 pHddCtx->isAmpAllowed = VOS_TRUE;
5059 hddLog(VOS_TRACE_LEVEL_FATAL,
5060 "%s: Failed to stop AMP", __func__);
5061 }
5062 else
5063 {
5064 //a state m/c implementation in PAL is TBD to avoid this delay
5065 msleep(500);
5066 pHddCtx->isAmpAllowed = VOS_FALSE;
5067 WLANBAP_DeregisterFromHCI();
5068 }
5069
5070 break;
5071 }
5072#endif
5073
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005074 case WE_ENABLE_DXE_STALL_DETECT:
5075 {
schang6295e542013-03-12 15:31:23 -07005076 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5077 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005078 break;
5079 }
5080 case WE_DISPLAY_DXE_SNAP_SHOT:
5081 {
schang6295e542013-03-12 15:31:23 -07005082 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5083 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005084 break;
5085 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305086 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5087 {
5088 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5089 hdd_wmm_tx_snapshot(pAdapter);
5090 WLANTL_TLDebugMessage(VOS_TRUE);
5091 break;
5092 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07005093 case WE_SET_REASSOC_TRIGGER:
5094 {
5095 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5096 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5097 v_U32_t roamId = 0;
5098 tCsrRoamModifyProfileFields modProfileFields;
5099 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5100 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5101 return 0;
5102 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305103
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005104
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 default:
5106 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005107 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 break;
5109 }
5110 }
5111
5112 return ret;
5113}
5114
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305115void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5116{
5117 /*
5118 * Function to display HDD WMM information
5119 * for Tx Queues.
5120 * Prints globala as well as per client depending
5121 * whether the clients are registered or not.
5122 */
5123 int i = 0, j = 0;
5124 for ( i=0; i< NUM_TX_QUEUES; i++)
5125 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305126 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005127 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305128 i, pAdapter->wmm_tx_queue[i].count,
5129 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305130 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305131 }
5132
5133 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5134 {
5135 if(pAdapter->aStaInfo[i].isUsed)
5136 {
5137 hddLog(LOGE, "******STAIndex: %d*********", i);
5138 for ( j=0; j< NUM_TX_QUEUES; j++)
5139 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305140 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005141 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305142 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5143 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5144 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305145 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305146 }
5147 }
5148 }
5149
5150}
Jeff Johnson295189b2012-06-20 16:38:30 -07005151int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5152 union iwreq_data *wrqu, char *extra)
5153{
5154 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5155 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5156 int sub_cmd = wrqu->data.flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 int apps_args[MAX_VAR_ARGS] = {0};
5158 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005159 hdd_station_ctx_t *pStaCtx = NULL ;
5160 hdd_ap_ctx_t *pAPCtx = NULL;
5161 int cmd = 0;
5162 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005163
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005164 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005165
5166 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5167 {
5168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5169 "%s:LOGP in Progress. Ignore!!!", __func__);
5170 return -EBUSY;
5171 }
5172
Jeff Johnson295189b2012-06-20 16:38:30 -07005173 if (num_args > MAX_VAR_ARGS)
5174 {
5175 num_args = MAX_VAR_ARGS;
5176 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005177
5178 /* ODD number is used for set, copy data using copy_from_user */
5179 if (copy_from_user(apps_args, wrqu->data.pointer, (sizeof(int)) * num_args))
5180 {
5181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5182 "%s: failed to copy data to user buffer", __func__);
5183 return -EFAULT;
5184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005185
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005186 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5187 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5188 {
5189 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5190 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5191 {
5192 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5193 staId = pStaCtx->conn_info.staId[0];
5194 }
5195 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5196 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5197 {
5198 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5199 staId = pAPCtx->uBCStaId;
5200 }
5201 else
5202 {
5203 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5204 return 0;
5205 }
5206 }
5207
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 switch (sub_cmd)
5209 {
5210 case WE_LOG_DUMP_CMD:
5211 {
5212 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005213 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005214 apps_args[3], apps_args[4]);
5215
5216 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5217 apps_args[3], apps_args[4]);
5218
5219 }
5220 break;
5221
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 case WE_P2P_NOA_CMD:
5223 {
5224 p2p_app_setP2pPs_t p2pNoA;
5225
5226 p2pNoA.opp_ps = apps_args[0];
5227 p2pNoA.ctWindow = apps_args[1];
5228 p2pNoA.duration = apps_args[2];
5229 p2pNoA.interval = apps_args[3];
5230 p2pNoA.count = apps_args[4];
5231 p2pNoA.single_noa_duration = apps_args[5];
5232 p2pNoA.psSelection = apps_args[6];
5233
5234 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5235 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005236 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5238
5239 hdd_setP2pPs(dev, &p2pNoA);
5240
5241 }
5242 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005243
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305244 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5245 {
5246 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5247 __func__, apps_args[0], apps_args[1]);
5248 vosTraceEnable(apps_args[0], apps_args[1]);
5249 }
5250 break;
5251
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005252 case WE_MTRACE_DUMP_CMD:
5253 {
5254 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5255 "bitmask_of_module %d ",
5256 __func__, apps_args[0], apps_args[1], apps_args[2],
5257 apps_args[3]);
5258 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5259 apps_args[2], apps_args[3]);
5260
5261 }
5262 break;
5263
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005264 case WE_MCC_CONFIG_CREDENTIAL :
5265 {
5266 cmd = 287; //Command should be updated if there is any change
5267 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005268 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005269 {
5270 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5271 }
5272 else
5273 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005274 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005275 return 0;
5276 }
5277 }
5278 break;
5279
5280 case WE_MCC_CONFIG_PARAMS :
5281 {
5282 cmd = 288; //command Should be updated if there is any change
5283 // in the Riva dump command
5284 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5285 }
5286 break;
5287
Chilam NG571c65a2013-01-19 12:27:36 +05305288#ifdef FEATURE_WLAN_TDLS
5289 case WE_TDLS_CONFIG_PARAMS :
5290 {
5291 tdls_config_params_t tdlsParams;
5292
Chilam Ng01120412013-02-19 18:32:21 -08005293 tdlsParams.tdls = apps_args[0];
5294 tdlsParams.tx_period_t = apps_args[1];
5295 tdlsParams.tx_packet_n = apps_args[2];
5296 tdlsParams.discovery_period_t = apps_args[3];
5297 tdlsParams.discovery_tries_n = apps_args[4];
5298 tdlsParams.idle_timeout_t = apps_args[5];
5299 tdlsParams.idle_packet_n = apps_args[6];
5300 tdlsParams.rssi_hysteresis = apps_args[7];
5301 tdlsParams.rssi_trigger_threshold = apps_args[8];
5302 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305303
Chilam Ng01120412013-02-19 18:32:21 -08005304 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305305 }
5306 break;
5307#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 default:
5309 {
5310 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
5311 }
5312 break;
5313 }
5314
5315 return 0;
5316}
5317
5318
5319static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5320 union iwreq_data *wrqu, char *extra)
5321{
5322 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5323 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5324 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5325 int params[HDD_WLAN_WMM_PARAM_COUNT];
5326 sme_QosWmmTspecInfo tSpec;
5327 v_U32_t handle;
5328
5329 // make sure the application is sufficiently priviledged
5330 // note that the kernel will do this for "set" ioctls, but since
5331 // this ioctl wants to return status to user space it must be
5332 // defined as a "get" ioctl
5333 if (!capable(CAP_NET_ADMIN))
5334 {
5335 return -EPERM;
5336 }
5337
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005338 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5339 {
5340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5341 "%s:LOGP in Progress. Ignore!!!", __func__);
5342 return -EBUSY;
5343 }
5344
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 // we must be associated in order to add a tspec
5346 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5347 {
5348 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5349 return 0;
5350 }
5351
5352 // since we are defined to be a "get" ioctl, and since the number
5353 // of params exceeds the number of params that wireless extensions
5354 // will pass down in the iwreq_data, we must copy the "set" params
5355 // from user space ourselves
5356 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5357 {
5358 // hmmm, can't get them
5359 return -EIO;
5360 }
5361
5362 // clear the tspec
5363 memset(&tSpec, 0, sizeof(tSpec));
5364
5365 // validate the handle
5366 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5367 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5368 {
5369 // that one is reserved
5370 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5371 return 0;
5372 }
5373
5374 // validate the TID
5375 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5376 {
5377 // out of range
5378 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5379 return 0;
5380 }
5381 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5382
5383 // validate the direction
5384 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5385 {
5386 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5387 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5388 break;
5389
5390 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5391 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5392 break;
5393
5394 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5395 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5396 break;
5397
5398 default:
5399 // unknown
5400 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5401 return 0;
5402 }
5403
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305404 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5405
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 // validate the user priority
5407 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5408 {
5409 // out of range
5410 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5411 return 0;
5412 }
5413 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305414 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5415 {
5416 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5417 return 0;
5418 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005419
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5421 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5422 tSpec.ts_info.psb, tSpec.ts_info.up);
5423
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5425 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5426 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5427 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5428 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5429 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5430 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5431 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5432 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5433 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5434 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5435 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5436
5437 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5438
5439 // validate the ts info ack policy
5440 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5441 {
5442 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5443 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5444 break;
5445
5446 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5447 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5448 break;
5449
5450 default:
5451 // unknown
5452 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5453 return 0;
5454 }
5455
5456 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5457 return 0;
5458}
5459
5460
5461static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5462 union iwreq_data *wrqu, char *extra)
5463{
5464 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5465 int *params = (int *)extra;
5466 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5467 v_U32_t handle;
5468
5469 // make sure the application is sufficiently priviledged
5470 // note that the kernel will do this for "set" ioctls, but since
5471 // this ioctl wants to return status to user space it must be
5472 // defined as a "get" ioctl
5473 if (!capable(CAP_NET_ADMIN))
5474 {
5475 return -EPERM;
5476 }
5477
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005478 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5479 {
5480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5481 "%s:LOGP in Progress. Ignore!!!", __func__);
5482 return -EBUSY;
5483 }
5484
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 // although we are defined to be a "get" ioctl, the params we require
5486 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5487 // is no need to copy the params from user space
5488
5489 // validate the handle
5490 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5491 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5492 {
5493 // that one is reserved
5494 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5495 return 0;
5496 }
5497
5498 *pStatus = hdd_wmm_delts(pAdapter, handle);
5499 return 0;
5500}
5501
5502
5503static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5504 union iwreq_data *wrqu, char *extra)
5505{
5506 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5507 int *params = (int *)extra;
5508 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5509 v_U32_t handle;
5510
5511 // although we are defined to be a "get" ioctl, the params we require
5512 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5513 // is no need to copy the params from user space
5514
5515 // validate the handle
5516 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5517 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5518 {
5519 // that one is reserved
5520 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5521 return 0;
5522 }
5523
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005524 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5525 {
5526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5527 "%s:LOGP in Progress. Ignore!!!", __func__);
5528 return -EBUSY;
5529 }
5530
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5532 return 0;
5533}
5534
5535
5536#ifdef FEATURE_WLAN_WAPI
5537static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5538 union iwreq_data *wrqu, char *extra)
5539{
5540 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5541 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5542 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5543 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5544
Arif Hussain7adce1b2013-11-11 22:59:34 -08005545 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005546
5547 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005548 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005549 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5550 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005551
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005552 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5553 {
5554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5555 "%s:LOGP in Progress. Ignore!!!", __func__);
5556 return -EBUSY;
5557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005558
5559 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005560 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5562 pRoamProfile->EncryptionType.numEntries = 1;
5563 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5564 pRoamProfile->mcEncryptionType.numEntries = 1;
5565 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5566
5567 pRoamProfile->AuthType.numEntries = 1;
5568 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5569 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5570 }
5571 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005572 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 }
5574 else
5575 return -EINVAL;
5576
5577 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5578
5579 return 0;
5580}
5581
5582static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5583 union iwreq_data *wrqu, char *extra)
5584{
5585 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5586 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5587
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005588 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5589 {
5590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5591 "%s:LOGP in Progress. Ignore!!!", __func__);
5592 return -EBUSY;
5593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5595
5596 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005597 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode);
5599 return 0;
5600}
5601
5602static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5603 union iwreq_data *wrqu, char *extra)
5604{
5605 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5606// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5607 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5608 int i = 0, j = 0;
5609 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005610 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005611 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005612
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005613 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5614 {
5615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5616 "%s:LOGP in Progress. Ignore!!!", __func__);
5617 return -EBUSY;
5618 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005619
5620 if (NULL == pWapiAssocInfo)
5621 {
5622 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5623 "%s: WDA NULL context", __func__);
5624 VOS_ASSERT(0);
5625 return VOS_STATUS_E_FAILURE;
5626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005627
Arif Hussain6d2a3322013-11-17 19:50:10 -08005628 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 -07005629 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005631 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005632
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005633 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005635 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005636
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005637 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005638 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 for(i = 0 ; i < 16 ; i++) {
5640 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5641 for(j = 0 ; j < 16 ; j++)
5642 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5643 }
5644
5645 /* We are not using the entire IE as provided by the supplicant.
5646 * This is being calculated by SME. This is the same as in the
5647 * case of WPA. Only the auth mode information needs to be
5648 * extracted here*/
5649 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005650 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5652 }
5653
5654 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005655 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5657 }
5658 return 0;
5659}
5660
5661static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5662 union iwreq_data *wrqu, char *extra)
5663{
5664 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5665 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5666 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5667 tANI_U32 roamId = 0xFF;
5668 tANI_U8 *pKeyPtr = NULL;
5669 v_BOOL_t isConnected = TRUE;
5670 tCsrRoamSetKey setKey;
5671 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5673
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005674 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5675 {
5676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5677 "%s:LOGP in Progress. Ignore!!!", __func__);
5678 return -EBUSY;
5679 }
5680
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005682 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005683 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005684
Arif Hussain6d2a3322013-11-17 19:50:10 -08005685 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 -07005686 hddLog(LOG1,"Add Index:0x");
5687 for(i =0 ; i < 12 ; i++)
5688 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5689
Arif Hussain6d2a3322013-11-17 19:50:10 -08005690 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5692 for(i =0 ; i < 16 ; i++)
5693 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5694
Arif Hussain6d2a3322013-11-17 19:50:10 -08005695 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5697 for(i =0 ; i < 16 ; i++)
5698 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5699
Arif Hussain6d2a3322013-11-17 19:50:10 -08005700 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 for(i = 0 ; i < 16 ; i++)
5702 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5703
5704 // Clear the setkey memory
5705 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5706 // Store Key ID
5707 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5708 // SET WAPI Encryption
5709 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5710 // Key Directionn both TX and RX
5711 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5712 // the PAE role
5713 setKey.paeRole = 0 ;
5714
5715 switch ( pWapiKey->keyType )
5716 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005717 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 {
5719 isConnected = hdd_connIsConnected(pHddStaCtx);
5720 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5721 break;
5722 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005723 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 {
5725 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5726 break;
5727 }
5728 default:
5729 {
5730 //Any other option is invalid.
5731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005732 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005733
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005734 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5736 break; // NEED RETURN FROM HERE ????
5737 }
5738 }
5739
5740 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5741 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5742 pKeyPtr = setKey.Key;
5743 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5744 pKeyPtr += pWapiKey->wpiekLen;
5745 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5746
5747 // Set the new key with SME.
5748 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5749
5750 if ( isConnected ) {
5751 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5752 if ( halStatus != eHAL_STATUS_SUCCESS )
5753 {
5754 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5755 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5756
5757 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5758 }
5759 }
5760#if 0 /// NEED TO CHECK ON THIS
5761 else
5762 {
5763 // Store the keys in the adapter to be moved to the profile & passed to
5764 // SME in the ConnectRequest if we are not yet in connected state.
5765 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5766 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5767
5768 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5769 " Saving key [idx= %d] to apply when moving to connected state ",
5770 setKey.keyId );
5771
5772 }
5773#endif
5774 return halStatus;
5775}
5776
5777static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5778 union iwreq_data *wrqu, char *extra)
5779{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005780 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005781#ifdef WLAN_DEBUG
5782 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005783 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005784#endif
5785
5786 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005787 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005788 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005789
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005790 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5791 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005792
5793 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005794
5795 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5796 {
5797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5798 "%s:LOGP in Progress. Ignore!!!", __func__);
5799 return -EBUSY;
5800 }
5801
Jeff Johnson295189b2012-06-20 16:38:30 -07005802#ifdef WLAN_DEBUG
5803 for(i =0 ; i < 16 ; i++)
5804 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5805#endif
5806
5807 return 0;
5808}
5809
5810static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5811 union iwreq_data *wrqu, char *extra)
5812{
5813 /* Yet to implement this function, 19th April 2010 */
5814 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5815
5816 return 0;
5817}
5818#endif /* FEATURE_WLAN_WAPI */
5819
5820#ifdef WLAN_FEATURE_VOWIFI_11R
5821//
5822//
5823// Each time the supplicant has the auth_request or reassoc request
5824// IEs ready. This is pushed to the driver. The driver will inturn use
5825// it to send out the auth req and reassoc req for 11r FT Assoc.
5826//
5827static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5828 union iwreq_data *wrqu, char *extra)
5829{
5830 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5831 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5832 //v_CONTEXT_t pVosContext;
5833
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005834 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5835 {
5836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5837 "%s:LOGP in Progress. Ignore!!!", __func__);
5838 return -EBUSY;
5839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 if (!wrqu->data.length)
5841 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005842 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 return -EINVAL;
5844 }
5845 if (wrqu->data.pointer == NULL)
5846 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005847 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 return -EINVAL;
5849 }
5850
5851 // Added for debug on reception of Re-assoc Req.
5852 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5853 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005854 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005856 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 }
5858
5859#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005860 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005861#endif
5862
5863 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005864 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 wrqu->data.length);
5866
5867 return 0;
5868}
5869#endif
5870
Amar Singhalf3a6e762013-02-19 15:06:50 -08005871static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005872 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005874{
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005876 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005878 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005879 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005880 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5881 int idx;
5882 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005883
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005884 if (pHddCtx->isLogpInProgress)
5885 {
5886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5887 "%s:LOGP in Progress. Ignore!!!", __func__);
5888 return -EBUSY;
5889 }
5890
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305891 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5892 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305893#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005894
Amar Singhalf3a6e762013-02-19 15:06:50 -08005895 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5896 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005897 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005898 hddLog(VOS_TRACE_LEVEL_ERROR,
5899 "%s: vos_mem_alloc failed", __func__);
5900 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005901 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005902
5903 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5904
5905 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5906 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5907
5908 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5909 mc_addr_list_ptr->ulMulticastAddrCnt);
5910
5911 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005912 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005913 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5914 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5915
5916 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5917 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005918 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005919
Amar Singhalf3a6e762013-02-19 15:06:50 -08005920 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5921 vos_mem_free(mc_addr_list_ptr);
5922 if (eHAL_STATUS_SUCCESS != ret_val)
5923 {
5924 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5925 __func__);
5926 return -EINVAL;
5927 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305928#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305929 }
5930 else
5931 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005932
Amar Singhalf3a6e762013-02-19 15:06:50 -08005933 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5934 "%s: Set MC BC Filter Config request: %d suspend %d",
5935 __func__, pRequest->mcastBcastFilterSetting,
5936 pHddCtx->hdd_wlan_suspended);
5937
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305938 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005939
5940 if (pHddCtx->hdd_wlan_suspended)
5941 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005942 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5943 if (NULL == wlanRxpFilterParam)
5944 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305945 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005946 "%s: vos_mem_alloc failed", __func__);
5947 return -EINVAL;
5948 }
5949
Amar Singhalf3a6e762013-02-19 15:06:50 -08005950 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5951 pRequest->mcastBcastFilterSetting;
5952 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5953
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305954 hdd_conf_hostoffload(pAdapter, TRUE);
5955 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5956 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005957
5958 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5959 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305960 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08005961 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5962 wlanRxpFilterParam->setMcstBcstFilter);
5963
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305964 if (eHAL_STATUS_SUCCESS !=
5965 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5966 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08005967 {
5968 hddLog(VOS_TRACE_LEVEL_ERROR,
5969 "%s: Failure to execute set HW MC/BC Filter request",
5970 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005971 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005972 return -EINVAL;
5973 }
5974
Amar Singhalf3a6e762013-02-19 15:06:50 -08005975 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005977
5978 return 0;
5979}
5980
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005981static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005982 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 union iwreq_data *wrqu, char *extra)
5984{
5985 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5986 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305987 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005988 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005989
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305990 //Reset the filter to INI value as we have to clear the dynamic filter
5991 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07005992
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305993 //Configure FW with new setting
5994 if (pHddCtx->hdd_wlan_suspended)
5995 {
5996 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5997 if (NULL == wlanRxpFilterParam)
5998 {
5999 hddLog(VOS_TRACE_LEVEL_ERROR,
6000 "%s: vos_mem_alloc failed", __func__);
6001 return -EINVAL;
6002 }
6003
6004 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6005 pHddCtx->configuredMcastBcastFilter;
6006 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6007
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306008 hdd_conf_hostoffload(pAdapter, TRUE);
6009 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6010 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306011
6012 if (eHAL_STATUS_SUCCESS !=
6013 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6014 wlanRxpFilterParam))
6015 {
6016 hddLog(VOS_TRACE_LEVEL_ERROR,
6017 "%s: Failure to execute set HW MC/BC Filter request",
6018 __func__);
6019 vos_mem_free(wlanRxpFilterParam);
6020 return -EINVAL;
6021 }
6022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 return 0;
6024}
6025
6026static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6027 union iwreq_data *wrqu, char *extra)
6028{
6029 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006030 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 tSirHostOffloadReq offloadRequest;
6032
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006033 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6034 {
6035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6036 "%s:LOGP in Progress. Ignore!!!", __func__);
6037 return -EBUSY;
6038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 /* Debug display of request components. */
6040 switch (pRequest->offloadType)
6041 {
6042 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006043 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 switch (pRequest->enableOrDisable)
6045 {
6046 case WLAN_OFFLOAD_DISABLE:
6047 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6048 break;
6049 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6050 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6051 case WLAN_OFFLOAD_ENABLE:
6052 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6053 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6054 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6055 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6056 }
6057 break;
6058
6059 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006060 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006061 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 switch (pRequest->enableOrDisable)
6063 {
6064 case WLAN_OFFLOAD_DISABLE:
6065 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6066 break;
6067 case WLAN_OFFLOAD_ENABLE:
6068 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6069 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6070 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6071 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6072 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6073 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6074 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6075 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6076 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6077 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6078 }
6079 }
6080
6081 /* Execute offload request. The reason that we can copy the request information
6082 from the ioctl structure to the SME structure is that they are laid out
6083 exactly the same. Otherwise, each piece of information would have to be
6084 copied individually. */
6085 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006086 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6087 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006089 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006090 __func__);
6091 return -EINVAL;
6092 }
6093
6094 return 0;
6095}
6096
6097static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6098 union iwreq_data *wrqu, char *extra)
6099{
6100 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006101 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 tSirKeepAliveReq keepaliveRequest;
6103
6104 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6105 {
6106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006107 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 return 0;
6109 }
6110
6111 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006112 hddLog(VOS_TRACE_LEVEL_INFO,
6113 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6114 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006115
6116 switch (pRequest->packetType)
6117 {
6118 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006119 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 break;
6121
6122 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6123
Arif Hussain6d2a3322013-11-17 19:50:10 -08006124 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006125 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006126
6127 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6128 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6129 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6130
6131 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6132 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6133 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6134
6135 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6136 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6137 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6138 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6139 break;
6140
6141 }
6142
6143 /* Execute keep alive request. The reason that we can copy the request information
6144 from the ioctl structure to the SME structure is that they are laid out
6145 exactly the same. Otherwise, each piece of information would have to be
6146 copied individually. */
6147 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6148
Arif Hussain6d2a3322013-11-17 19:50:10 -08006149 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006150
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006151 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006152 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006154 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 __func__);
6156 return -EINVAL;
6157 }
6158
6159 return 0;
6160}
6161
6162#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006163int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006164 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006165{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006166 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6167 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 int i=0;
6169
6170 if (pHddCtx->cfg_ini->disablePacketFilter)
6171 {
6172 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006173 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 return 0;
6175 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006176 if (pHddCtx->isLogpInProgress)
6177 {
6178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6179 "%s:LOGP in Progress. Ignore!!!", __func__);
6180 return -EBUSY;
6181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 /* Debug display of request components. */
6183 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006184 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006185
6186 switch (pRequest->filterAction)
6187 {
6188 case HDD_RCV_FILTER_SET:
6189 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006190 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006191
6192 packetFilterSetReq.filterId = pRequest->filterId;
6193 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6194 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006195 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 __func__, pRequest->numParams);
6197 return -EINVAL;
6198 }
6199 packetFilterSetReq.numFieldParams = pRequest->numParams;
6200 packetFilterSetReq.coalesceTime = 0;
6201 packetFilterSetReq.filterType = 1;
6202 for (i=0; i < pRequest->numParams; i++)
6203 {
6204 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6205 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6206 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6207 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6208 packetFilterSetReq.paramsData[i].reserved = 0;
6209
Arif Hussain6d2a3322013-11-17 19:50:10 -08006210 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6212 packetFilterSetReq.filterType);
6213
Arif Hussain6d2a3322013-11-17 19:50:10 -08006214 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6216
6217 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6218 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6219 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6220 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6221
Arif Hussain6d2a3322013-11-17 19:50:10 -08006222 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6224 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6225 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6226
Arif Hussain6d2a3322013-11-17 19:50:10 -08006227 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6229 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6230 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6231 }
6232
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006233 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006235 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 __func__);
6237 return -EINVAL;
6238 }
6239
6240 break;
6241
6242 case HDD_RCV_FILTER_CLEAR:
6243
Arif Hussain6d2a3322013-11-17 19:50:10 -08006244 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006245 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006247 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006248 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006249 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 __func__);
6251 return -EINVAL;
6252 }
6253 break;
6254
6255 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006256 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006257 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 return -EINVAL;
6259 }
6260 return 0;
6261}
6262
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306263int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6264 tANI_U8 sessionId)
6265{
6266 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6267 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6268
6269 if (NULL == pHddCtx)
6270 {
6271 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6272 return -EINVAL;
6273 }
6274
6275 if (pHddCtx->isLogpInProgress)
6276 {
6277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6278 "%s:LOGP in Progress. Ignore!!!", __func__);
6279 return -EBUSY;
6280 }
6281
6282 if (pHddCtx->cfg_ini->disablePacketFilter)
6283 {
6284 hddLog(VOS_TRACE_LEVEL_ERROR,
6285 "%s: Packet Filtering Disabled. Returning ",
6286 __func__ );
6287 return -EINVAL;
6288 }
6289
6290 switch (filterType)
6291 {
6292 /* For setting IPV6 MC and UC Filter we need to configure
6293 * 2 filters, one for MC and one for UC.
6294 * The Filter ID shouldn't be swapped, which results in making
6295 * UC Filter ineffective.
6296 * We have Hardcode all the values
6297 *
6298 * Reason for a seperate UC filter is because, driver need to
6299 * specify the FW that the specific filter is for unicast
6300 * otherwise FW will not pass the unicast frames by default
6301 * through the filter. This is required to avoid any performance
6302 * hits when no unicast filter is set and only MC/BC are set.
6303 * The way driver informs host is by using the MAC protocol
6304 * layer, CMP flag set to MAX, CMP Data set to 1.
6305 */
6306
6307 case HDD_FILTER_IPV6_MC_UC:
6308 /* Setting IPV6 MC Filter below
6309 */
6310 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6311 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6312 packetFilterSetReq.numFieldParams = 2;
6313 packetFilterSetReq.paramsData[0].protocolLayer =
6314 HDD_FILTER_PROTO_TYPE_MAC;
6315 packetFilterSetReq.paramsData[0].cmpFlag =
6316 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6317 packetFilterSetReq.paramsData[0].dataOffset =
6318 WLAN_HDD_80211_FRM_DA_OFFSET;
6319 packetFilterSetReq.paramsData[0].dataLength = 1;
6320 packetFilterSetReq.paramsData[0].compareData[0] =
6321 HDD_IPV6_MC_CMP_DATA;
6322
6323 packetFilterSetReq.paramsData[1].protocolLayer =
6324 HDD_FILTER_PROTO_TYPE_ARP;
6325 packetFilterSetReq.paramsData[1].cmpFlag =
6326 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6327 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6328 packetFilterSetReq.paramsData[1].dataLength = 2;
6329 packetFilterSetReq.paramsData[1].compareData[0] =
6330 HDD_IPV6_CMP_DATA_0;
6331 packetFilterSetReq.paramsData[1].compareData[1] =
6332 HDD_IPV6_CMP_DATA_1;
6333
6334
6335 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6336 &packetFilterSetReq, sessionId))
6337 {
6338 hddLog(VOS_TRACE_LEVEL_ERROR,
6339 "%s: Failure to execute Set IPv6 Mulicast Filter",
6340 __func__);
6341 return -EINVAL;
6342 }
6343
6344 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6345
6346 /*
6347 * Setting IPV6 UC Filter below
6348 */
6349 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6350 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6351 packetFilterSetReq.numFieldParams = 2;
6352 packetFilterSetReq.paramsData[0].protocolLayer =
6353 HDD_FILTER_PROTO_TYPE_MAC;
6354 packetFilterSetReq.paramsData[0].cmpFlag =
6355 HDD_FILTER_CMP_TYPE_MAX;
6356 packetFilterSetReq.paramsData[0].dataOffset = 0;
6357 packetFilterSetReq.paramsData[0].dataLength = 1;
6358 packetFilterSetReq.paramsData[0].compareData[0] =
6359 HDD_IPV6_UC_CMP_DATA;
6360
6361 packetFilterSetReq.paramsData[1].protocolLayer =
6362 HDD_FILTER_PROTO_TYPE_ARP;
6363 packetFilterSetReq.paramsData[1].cmpFlag =
6364 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6365 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6366 packetFilterSetReq.paramsData[1].dataLength = 2;
6367 packetFilterSetReq.paramsData[1].compareData[0] =
6368 HDD_IPV6_CMP_DATA_0;
6369 packetFilterSetReq.paramsData[1].compareData[1] =
6370 HDD_IPV6_CMP_DATA_1;
6371
6372 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6373 &packetFilterSetReq, sessionId))
6374 {
6375 hddLog(VOS_TRACE_LEVEL_ERROR,
6376 "%s: Failure to execute Set IPv6 Unicast Filter",
6377 __func__);
6378 return -EINVAL;
6379 }
6380
6381 break;
6382
6383 case HDD_FILTER_IPV6_MC:
6384 /*
6385 * IPV6 UC Filter might be already set,
6386 * clear the UC Filter. As the Filter
6387 * IDs are static, we can directly clear it.
6388 */
6389 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6390 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6391 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6392 &packetFilterClrReq, sessionId))
6393 {
6394 hddLog(VOS_TRACE_LEVEL_ERROR,
6395 "%s: Failure to execute Clear IPv6 Unicast Filter",
6396 __func__);
6397 return -EINVAL;
6398 }
6399
6400 /*
6401 * Setting IPV6 MC Filter below
6402 */
6403 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6404 packetFilterSetReq.numFieldParams = 2;
6405 packetFilterSetReq.paramsData[0].protocolLayer =
6406 HDD_FILTER_PROTO_TYPE_MAC;
6407 packetFilterSetReq.paramsData[0].cmpFlag =
6408 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6409 packetFilterSetReq.paramsData[0].dataOffset =
6410 WLAN_HDD_80211_FRM_DA_OFFSET;
6411 packetFilterSetReq.paramsData[0].dataLength = 1;
6412 packetFilterSetReq.paramsData[0].compareData[0] =
6413 HDD_IPV6_MC_CMP_DATA;
6414
6415 packetFilterSetReq.paramsData[1].protocolLayer =
6416 HDD_FILTER_PROTO_TYPE_ARP;
6417 packetFilterSetReq.paramsData[1].cmpFlag =
6418 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6419 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6420 packetFilterSetReq.paramsData[1].dataLength = 2;
6421 packetFilterSetReq.paramsData[1].compareData[0] =
6422 HDD_IPV6_CMP_DATA_0;
6423 packetFilterSetReq.paramsData[1].compareData[1] =
6424 HDD_IPV6_CMP_DATA_1;
6425
6426
6427 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6428 &packetFilterSetReq, sessionId))
6429 {
6430 hddLog(VOS_TRACE_LEVEL_ERROR,
6431 "%s: Failure to execute Set IPv6 Multicast Filter",
6432 __func__);
6433 return -EINVAL;
6434 }
6435 break;
6436
6437 default :
6438 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6439 "%s: Packet Filter Request: Invalid",
6440 __func__);
6441 return -EINVAL;
6442 }
6443 return 0;
6444}
6445
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306446void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006447{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306448 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306449 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006450 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306451 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006452
Yue Ma3ede6052013-08-29 00:33:26 -07006453 if (NULL == pHddCtx)
6454 {
6455 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6456 return;
6457 }
6458
6459 hHal = pHddCtx->hHal;
6460
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306461 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006462 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306463 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6464 return;
6465 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306466
6467 /* Check if INI is enabled or not, other wise just return
6468 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306469 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306470 {
6471 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6472 if (NULL == pMulticastAddrs)
6473 {
6474 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6475 return;
6476 }
6477
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 if (set)
6479 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306480 /* Following pre-conditions should be satisfied before wei
6481 * configure the MC address list.
6482 */
6483 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6484 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6485 && pAdapter->mc_addr_list.mc_cnt
6486 && (eConnectionState_Associated ==
6487 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6488 {
6489 pMulticastAddrs->ulMulticastAddrCnt =
6490 pAdapter->mc_addr_list.mc_cnt;
6491 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6492 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006493 memcpy(pMulticastAddrs->multicastAddr[i],
6494 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306495 sizeof(pAdapter->mc_addr_list.addr[i]));
6496 hddLog(VOS_TRACE_LEVEL_INFO,
6497 "%s: %s multicast filter: addr ="
6498 MAC_ADDRESS_STR,
6499 __func__, set ? "setting" : "clearing",
6500 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6501 }
6502 /* Set multicast filter */
6503 sme_8023MulticastList(hHal, pAdapter->sessionId,
6504 pMulticastAddrs);
6505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306507 else
6508 {
6509 /* Need to clear only if it was previously configured
6510 */
6511 if (pAdapter->mc_addr_list.isFilterApplied)
6512 {
6513 pMulticastAddrs->ulMulticastAddrCnt = 0;
6514 sme_8023MulticastList(hHal, pAdapter->sessionId,
6515 pMulticastAddrs);
6516 }
6517
6518 }
6519 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006520 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306522 else
6523 {
6524 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306525 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306526 }
6527 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006528}
6529
6530static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6531 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306532{
Jeff Johnson295189b2012-06-20 16:38:30 -07006533 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006534 tpPacketFilterCfg pRequest = NULL;
6535 int ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006536
Arif Hussain0273cba2014-01-07 20:58:29 -08006537 /* ODD number is used for set, copy data using copy_from_user */
6538 pRequest = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
6539 wrqu->data.length);
6540 if (NULL == pRequest)
6541 {
6542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6543 "mem_alloc_copy_from_user_helper fail");
6544 return -ENOMEM;
6545 }
6546
6547 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6548 kfree(pRequest);
6549
6550 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006551}
6552#endif
6553static int iw_get_statistics(struct net_device *dev,
6554 struct iw_request_info *info,
6555 union iwreq_data *wrqu, char *extra)
6556{
6557
6558 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6559 eHalStatus status = eHAL_STATUS_SUCCESS;
6560 hdd_wext_state_t *pWextState;
6561 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6562 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6563 char *p = extra;
6564 int tlen = 0;
6565 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6566
6567 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6568 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6569
6570 ENTER();
6571
6572 if (pHddCtx->isLogpInProgress) {
6573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6574 return -EINVAL;
6575 }
6576
6577 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6578
6579 wrqu->txpower.value = 0;
6580 }
6581 else {
6582 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6583 SME_SUMMARY_STATS |
6584 SME_GLOBAL_CLASSA_STATS |
6585 SME_GLOBAL_CLASSB_STATS |
6586 SME_GLOBAL_CLASSC_STATS |
6587 SME_GLOBAL_CLASSD_STATS |
6588 SME_PER_STA_STATS,
6589 hdd_StatisticsCB, 0, FALSE,
6590 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6591
6592 if (eHAL_STATUS_SUCCESS != status)
6593 {
6594 hddLog(VOS_TRACE_LEVEL_ERROR,
6595 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006596 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 return -EINVAL;
6598 }
6599
6600 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6601
6602 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6603 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6604 {
6605 hddLog(VOS_TRACE_LEVEL_ERROR,
6606 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006607 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 /*Remove the SME statistics list by passing NULL in callback argument*/
6609 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6610 SME_SUMMARY_STATS |
6611 SME_GLOBAL_CLASSA_STATS |
6612 SME_GLOBAL_CLASSB_STATS |
6613 SME_GLOBAL_CLASSC_STATS |
6614 SME_GLOBAL_CLASSD_STATS |
6615 SME_PER_STA_STATS,
6616 NULL, 0, FALSE,
6617 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6618
6619 return -EINVAL;
6620 }
6621 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6622 (tANI_U8) sizeof (pStats->retry_cnt),
6623 (char*) &(pStats->retry_cnt[0]),
6624 tlen);
6625
6626 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6627 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6628 (char*) &(pStats->multiple_retry_cnt[0]),
6629 tlen);
6630
6631 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6632 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6633 (char*) &(pStats->tx_frm_cnt[0]),
6634 tlen);
6635
6636 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6637 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6638 (char*) &(pStats->rx_frm_cnt),
6639 tlen);
6640
6641 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6642 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6643 (char*) &(pStats->frm_dup_cnt),
6644 tlen);
6645
6646 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6647 (tANI_U8) sizeof (pStats->fail_cnt),
6648 (char*) &(pStats->fail_cnt[0]),
6649 tlen);
6650
6651 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6652 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6653 (char*) &(pStats->rts_fail_cnt),
6654 tlen);
6655
6656 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6657 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6658 (char*) &(pStats->ack_fail_cnt),
6659 tlen);
6660
6661 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6662 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6663 (char*) &(pStats->rts_succ_cnt),
6664 tlen);
6665
6666 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6667 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6668 (char*) &(pStats->rx_discard_cnt),
6669 tlen);
6670
6671 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6672 (tANI_U8) sizeof (pStats->rx_error_cnt),
6673 (char*) &(pStats->rx_error_cnt),
6674 tlen);
6675
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006676 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006677 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006678 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 tlen);
6680
6681 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6682 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6683 (char*) &(dStats->rx_byte_cnt),
6684 tlen);
6685
6686 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6687 (tANI_U8) sizeof (dStats->rx_rate),
6688 (char*) &(dStats->rx_rate),
6689 tlen);
6690
6691 /* Transmit rate, in units of 500 kbit/sec */
6692 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6693 (tANI_U8) sizeof (aStats->tx_rate),
6694 (char*) &(aStats->tx_rate),
6695 tlen);
6696
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006697 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6698 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6699 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006700 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006701 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6702 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6703 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006704 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006705 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6706 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6707 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006708 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006709 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6710 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6711 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006712 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006713 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6714 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6715 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006716 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006717 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6718 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6719 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006720 tlen);
6721
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 wrqu->data.length = tlen;
6723
6724 }
6725
6726 EXIT();
6727
6728 return 0;
6729}
6730
6731
6732#ifdef FEATURE_WLAN_SCAN_PNO
6733
6734/*Max Len for PNO notification*/
6735#define MAX_PNO_NOTIFY_LEN 100
6736void found_pref_network_cb (void *callbackContext,
6737 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6738{
6739 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6740 union iwreq_data wrqu;
6741 char buf[MAX_PNO_NOTIFY_LEN+1];
6742
6743 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6744 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6745
6746 // create the event
6747 memset(&wrqu, 0, sizeof(wrqu));
6748 memset(buf, 0, sizeof(buf));
6749
6750 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6751 pPrefNetworkFoundInd->ssId.ssId,
6752 (unsigned int)pPrefNetworkFoundInd->rssi);
6753
6754 wrqu.data.pointer = buf;
6755 wrqu.data.length = strlen(buf);
6756
6757 // send the event
6758
6759 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6760
6761}
6762
6763
6764/*string based input*/
6765VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6766 union iwreq_data *wrqu, char *extra, int nOffset)
6767{
6768 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006769 /* pnoRequest is a large struct, so we make it static to avoid stack
6770 overflow. This API is only invoked via ioctl, so it is
6771 serialized by the kernel rtnl_lock and hence does not need to be
6772 reentrant */
6773 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006774 char *ptr;
6775 v_U8_t i,j, ucParams, ucMode;
6776 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6777
6778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6779 "PNO data len %d data %s",
6780 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006781 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006782
6783 if (wrqu->data.length <= nOffset )
6784 {
6785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6786 return VOS_STATUS_E_FAILURE;
6787 }
6788
6789 pnoRequest.enable = 0;
6790 pnoRequest.ucNetworksCount = 0;
6791 /*-----------------------------------------------------------------------
6792 Input is string based and expected to be like this:
6793
6794 <enabled> <netw_count>
6795 for each network:
6796 <ssid_len> <ssid> <authentication> <encryption>
6797 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6798 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6799
6800 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006801 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 -07006802
6803 this translates into:
6804 -----------------------------
6805 enable PNO
6806 look for 2 networks:
6807 test - with authentication type 0 and encryption type 0,
6808 that can be found on 3 channels: 1 6 and 11 ,
6809 SSID bcast type is unknown (directed probe will be sent if AP not found)
6810 and must meet -40dBm RSSI
6811
6812 test2 - with auth and enrytption type 4/4
6813 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6814 bcast type is non-bcast (directed probe will be sent)
6815 and must not meet any RSSI threshold
6816
Jeff Johnson8301aa12013-03-28 14:27:29 -07006817 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006818 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006819 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006820
Wilson Yang623f6592013-10-08 16:33:37 -07006821 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6822 {
6823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6824 "PNO enable input is not valid %s",ptr);
6825 return VOS_STATUS_E_FAILURE;
6826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006827
6828 if ( 0 == pnoRequest.enable )
6829 {
6830 /*Disable PNO*/
6831 memset(&pnoRequest, 0, sizeof(pnoRequest));
6832 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6833 pAdapter->sessionId,
6834 found_pref_network_cb, pAdapter);
6835 return VOS_STATUS_SUCCESS;
6836 }
6837
6838 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006839
6840 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6841 {
6842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6843 "PNO count input not valid %s",ptr);
6844 return VOS_STATUS_E_FAILURE;
6845
6846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006847
6848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6849 "PNO enable %d networks count %d offset %d",
6850 pnoRequest.enable,
6851 pnoRequest.ucNetworksCount,
6852 nOffset);
6853
6854 /* Parameters checking:
6855 ucNetworksCount has to be larger than 0*/
6856 if (( 0 == pnoRequest.ucNetworksCount ) ||
6857 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6858 {
6859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6860 return VOS_STATUS_E_FAILURE;
6861 }
6862
6863 ptr += nOffset;
6864
6865 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6866 {
6867
6868 pnoRequest.aNetworks[i].ssId.length = 0;
6869
Wilson Yang623f6592013-10-08 16:33:37 -07006870 ucParams = sscanf(ptr,"%hhu %n",
6871 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6872
6873 if (1 != ucParams)
6874 {
6875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6876 "PNO ssid length input is not valid %s",ptr);
6877 return VOS_STATUS_E_FAILURE;
6878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006879
6880 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6881 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6882 {
6883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6884 "SSID Len %d is not correct for network %d",
6885 pnoRequest.aNetworks[i].ssId.length, i);
6886 return VOS_STATUS_E_FAILURE;
6887 }
6888
6889 /*Advance to SSID*/
6890 ptr += nOffset;
6891
Jeff Johnson8301aa12013-03-28 14:27:29 -07006892 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006893 pnoRequest.aNetworks[i].ssId.length);
6894 ptr += pnoRequest.aNetworks[i].ssId.length;
6895
Jeff Johnson02797792013-10-26 19:17:13 -07006896 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006897 &(pnoRequest.aNetworks[i].authentication),
6898 &(pnoRequest.aNetworks[i].encryption),
6899 &(pnoRequest.aNetworks[i].ucChannelCount),
6900 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006901
Wilson Yang623f6592013-10-08 16:33:37 -07006902 if ( 3 != ucParams )
6903 {
6904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6905 "Incorrect cmd %s",ptr);
6906 return VOS_STATUS_E_FAILURE;
6907 }
6908
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006910 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006911 "auth %d encry %d channel count %d offset %d",
6912 pnoRequest.aNetworks[i].ssId.length,
6913 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6914 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6915 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6916 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6917 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6918 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6919 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6920 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6921 pnoRequest.aNetworks[i].authentication,
6922 pnoRequest.aNetworks[i].encryption,
6923 pnoRequest.aNetworks[i].ucChannelCount,
6924 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006925
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 /*Advance to channel list*/
6927 ptr += nOffset;
6928
Wilson Yang623f6592013-10-08 16:33:37 -07006929 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 {
6931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6932 "Incorrect number of channels");
6933 return VOS_STATUS_E_FAILURE;
6934 }
6935
6936 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6937 {
6938 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6939 {
Wilson Yang623f6592013-10-08 16:33:37 -07006940 if (1 != sscanf(ptr,"%hhu %n",
6941 &(pnoRequest.aNetworks[i].aChannels[j]),
6942 &nOffset))
6943 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6944 "PNO network channel input is not valid %s",ptr);
6945 return VOS_STATUS_E_FAILURE;
6946 }
6947 /*Advance to next channel number*/
6948 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006949 }
6950 }
6951
Jeff Johnson02797792013-10-26 19:17:13 -07006952 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006953 &(pnoRequest.aNetworks[i].bcastNetwType),
6954 &nOffset))
6955 {
6956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6957 "PNO broadcast network type input is not valid %s",ptr);
6958 return VOS_STATUS_E_FAILURE;
6959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006960
6961 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6962 "PNO bcastNetwType %d offset %d",
6963 pnoRequest.aNetworks[i].bcastNetwType,
6964 nOffset );
6965
6966 /*Advance to rssi Threshold*/
6967 ptr += nOffset;
6968
Wilson Yang623f6592013-10-08 16:33:37 -07006969 if (1 != sscanf(ptr,"%hhu %n",
6970 &(pnoRequest.aNetworks[i].rssiThreshold),
6971 &nOffset))
6972 {
6973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6974 "PNO rssi threshold input is not valid %s",ptr);
6975 return VOS_STATUS_E_FAILURE;
6976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006977
6978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6979 "PNO rssi %d offset %d",
6980 pnoRequest.aNetworks[i].rssiThreshold,
6981 nOffset );
6982 /*Advance to next network*/
6983 ptr += nOffset;
6984 }/*For ucNetworkCount*/
6985
6986 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006987 &(pnoRequest.scanTimers.ucScanTimersCount),
6988 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006989
6990 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07006991 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006992 {
6993 ptr += nOffset;
6994
Jeff Johnson8301aa12013-03-28 14:27:29 -07006995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6996 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 pnoRequest.scanTimers.ucScanTimersCount,
6998 nOffset );
6999
7000 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7001 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 "Incorrect cmd - too many scan timers");
7004 return VOS_STATUS_E_FAILURE;
7005 }
7006
7007 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7008 {
Jeff Johnson02797792013-10-26 19:17:13 -07007009 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7011 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7012 &nOffset);
7013
Wilson Yang623f6592013-10-08 16:33:37 -07007014 if (2 != ucParams)
7015 {
7016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7017 "Incorrect cmd - diff params then expected %d", ucParams);
7018 return VOS_STATUS_E_FAILURE;
7019 }
7020
Jeff Johnson8301aa12013-03-28 14:27:29 -07007021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7022 "PNO Timer value %d Timer repeat %d offset %d",
7023 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7025 nOffset );
7026
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 ptr += nOffset;
7028 }
7029
7030 }
7031 else
7032 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7034 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007035 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7036
7037 /*Scan timers defaults to 5 minutes*/
7038 pnoRequest.scanTimers.ucScanTimersCount = 1;
7039 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7040 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7041 }
7042
Wilson Yang623f6592013-10-08 16:33:37 -07007043 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007044
7045 pnoRequest.modePNO = ucMode;
7046 /*for LA we just expose suspend option*/
7047 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7048 {
7049 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7050 }
7051
7052 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
7053 pAdapter->sessionId,
7054 found_pref_network_cb, pAdapter);
7055
7056 return VOS_STATUS_SUCCESS;
7057}/*iw_set_pno*/
7058
7059VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7060 union iwreq_data *wrqu, char *extra, int nOffset)
7061{
7062 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7063 v_U8_t rssiThreshold = 0;
7064 v_U8_t nRead;
7065
Arif Hussain7adce1b2013-11-11 22:59:34 -08007066 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007067 &rssiThreshold);
7068
7069 if ( 1 != nRead )
7070 {
7071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7072 "Incorrect format");
7073 return VOS_STATUS_E_FAILURE;
7074 }
7075
7076 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7077 return VOS_STATUS_SUCCESS;
7078}
7079
7080
7081static int iw_set_pno_priv(struct net_device *dev,
7082 struct iw_request_info *info,
7083 union iwreq_data *wrqu, char *extra)
7084{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007085 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7086
7087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007088 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007089
7090 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7091 {
7092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7093 "%s:LOGP in Progress. Ignore!!!", __func__);
7094 return -EBUSY;
7095 }
7096 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007097}
7098#endif /*FEATURE_WLAN_SCAN_PNO*/
7099
7100//Common function to SetBand
7101int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
7102{
7103 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7104 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7105 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7106 tANI_U8 band = 0;
7107 eCsrBand currBand = eCSR_BAND_MAX;
7108
7109 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
7110
7111 switch(band)
7112 {
7113 case WLAN_HDD_UI_BAND_AUTO:
7114 band = eCSR_BAND_ALL;
7115 break;
7116 case WLAN_HDD_UI_BAND_5_GHZ:
7117 band = eCSR_BAND_5G;
7118 break;
7119 case WLAN_HDD_UI_BAND_2_4_GHZ:
7120 band = eCSR_BAND_24;
7121 break;
7122 default:
7123 band = eCSR_BAND_MAX;
7124 }
7125
7126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007127 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007128
7129 if (band == eCSR_BAND_MAX)
7130 {
7131 /* Received change band request with invalid band value */
7132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007133 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 return -EIO;
7135 }
7136
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307137 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7138 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7139 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7140 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007142 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007143 band, pHddCtx->cfg_ini->nBandCapability);
7144 return -EIO;
7145 }
7146
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7148 {
7149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7150 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007151 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007152 return -EIO;
7153 }
7154
7155 if (currBand != band)
7156 {
7157 /* Change band request received.
7158 * Abort pending scan requests, flush the existing scan results,
7159 * and change the band capability
7160 */
7161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7162 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007163 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007164
7165 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
7166 {
7167 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7168 eHalStatus status = eHAL_STATUS_SUCCESS;
7169 long lrc;
7170
7171 /* STA already connected on current band, So issue disconnect first,
7172 * then change the band*/
7173
7174 hddLog(VOS_TRACE_LEVEL_INFO,
7175 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
7176 __func__, csrGetCurrentBand(hHal), band);
7177
7178 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7179 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7180
7181 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7182 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7183
Jeff Johnson43971f52012-07-17 12:26:56 -07007184 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 {
7186 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007187 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 __func__, (int)status );
7189 return -EINVAL;
7190 }
7191
7192 lrc = wait_for_completion_interruptible_timeout(
7193 &pAdapter->disconnect_comp_var,
7194 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7195
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307196 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007197
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007198 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007199 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007200
7201 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7202 }
7203 }
7204
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307205 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307207 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 {
7209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7210 "%s: failed to set the band value to %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007211 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 return -EINVAL;
7213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007214 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 }
7216 return 0;
7217}
7218
7219static int iw_set_band_config(struct net_device *dev,
7220 struct iw_request_info *info,
7221 union iwreq_data *wrqu, char *extra)
7222{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08007224 tANI_U8 *ptr = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007225 int ret = 0;
7226
Arif Hussain0273cba2014-01-07 20:58:29 -08007227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007228
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007229 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7230 {
7231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7232 "%s:LOGP in Progress. Ignore!!!", __func__);
7233 return -EBUSY;
7234 }
7235
Arif Hussain0273cba2014-01-07 20:58:29 -08007236 /* ODD number is used for set, copy data using copy_from_user */
7237 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7238 wrqu->data.length);
7239 if (NULL == ptr)
7240 {
7241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7242 "mem_alloc_copy_from_user_helper fail");
7243 return -ENOMEM;
7244 }
7245
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 if (memcmp(ptr, "SETBAND ", 8) == 0)
7247 {
7248 /* Change band request received */
7249 ret = hdd_setBand_helper(dev, ptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 }
Arif Hussain0273cba2014-01-07 20:58:29 -08007251 kfree(ptr);
7252
7253 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007254}
7255
7256static int iw_set_power_params_priv(struct net_device *dev,
7257 struct iw_request_info *info,
7258 union iwreq_data *wrqu, char *extra)
7259{
Arif Hussain0273cba2014-01-07 20:58:29 -08007260 int ret;
7261 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7263 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007264 /* ODD number is used for set, copy data using copy_from_user */
7265 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7266 wrqu->data.length);
7267 if (NULL == ptr)
7268 {
7269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7270 "mem_alloc_copy_from_user_helper fail");
7271 return -ENOMEM;
7272 }
7273
7274 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7275 kfree(ptr);
7276 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007277}
7278
7279
7280
7281/*string based input*/
7282VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7283 union iwreq_data *wrqu, char *extra, int nOffset)
7284{
7285 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7286 tSirSetPowerParamsReq powerRequest;
7287 char *ptr;
7288 v_U8_t ucType;
7289 v_U32_t uTotalSize, uValue;
7290 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7291
7292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7293 "Power Params data len %d data %s",
7294 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007295 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007296
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007297 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7298 {
7299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7300 "%s:LOGP in Progress. Ignore!!!", __func__);
7301 return -EBUSY;
7302 }
7303
Jeff Johnson295189b2012-06-20 16:38:30 -07007304 if (wrqu->data.length <= nOffset )
7305 {
7306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7307 return VOS_STATUS_E_FAILURE;
7308 }
7309
7310 uTotalSize = wrqu->data.length - nOffset;
7311
7312 /*-----------------------------------------------------------------------
7313 Input is string based and expected to be like this:
7314
7315 <param_type> <param_value> <param_type> <param_value> ...
7316
7317 e.g:
7318 1 2 2 3 3 0 4 1 5 1
7319
7320 e.g. setting just a few:
7321 1 2 4 1
7322
7323 parameter types:
7324 -----------------------------
7325 1 - Ignore DTIM
7326 2 - Listen Interval
7327 3 - Broadcast Multicas Filter
7328 4 - Beacon Early Termination
7329 5 - Beacon Early Termination Interval
7330 -----------------------------------------------------------------------*/
7331 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7332 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7333 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7334 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7335 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7336
Arif Hussain7adce1b2013-11-11 22:59:34 -08007337 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007338
7339 while ( uTotalSize )
7340 {
Wilson Yang6f971452013-10-08 15:00:00 -07007341 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7342 {
7343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7344 "Invalid input parameter type %s",ptr);
7345 return VOS_STATUS_E_FAILURE;
7346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007347
7348 uTotalSize -= nOffset;
7349
7350 if (!uTotalSize)
7351 {
7352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007353 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007354 ucType, nOffset);
7355 return VOS_STATUS_E_FAILURE;
7356 }
7357
7358 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007359
Jeff Johnson02797792013-10-26 19:17:13 -07007360 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007361 {
7362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7363 "Invalid input parameter value %s",ptr);
7364 return VOS_STATUS_E_FAILURE;
7365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007366
7367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7368 "Power request parameter %d value %d offset %d",
7369 ucType, uValue, nOffset);
7370
7371 switch (ucType)
7372 {
7373 case eSIR_IGNORE_DTIM:
7374 powerRequest.uIgnoreDTIM = uValue;
7375 break;
7376 case eSIR_LISTEN_INTERVAL:
7377 powerRequest.uListenInterval = uValue;
7378 break;
7379 case eSIR_MCAST_BCAST_FILTER:
7380 powerRequest.uBcastMcastFilter = uValue;
7381 break;
7382 case eSIR_ENABLE_BET:
7383 powerRequest.uEnableBET = uValue;
7384 break;
7385 case eSIR_BET_INTERVAL:
7386 powerRequest.uBETInterval = uValue;
7387 break;
7388 default:
7389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007390 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007391 ucType, uValue, nOffset);
7392 return VOS_STATUS_E_FAILURE;
7393 }
7394
7395 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7397 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007398 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007400 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007401 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007402 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7403 {
7404 uTotalSize = 0;
7405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007406
7407 }/*Go for as long as we have a valid string*/
7408
7409 /* put the device into full power*/
7410 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7411
7412 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007413 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007414
7415 /* put the device back to power save*/
7416 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7417
7418 return VOS_STATUS_SUCCESS;
7419}/*iw_set_power_params*/
7420
7421
7422// Define the Wireless Extensions to the Linux Network Device structure
7423// A number of these routines are NULL (meaning they are not implemented.)
7424
7425static const iw_handler we_handler[] =
7426{
7427 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7428 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7429 (iw_handler) NULL, /* SIOCSIWNWID */
7430 (iw_handler) NULL, /* SIOCGIWNWID */
7431 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7432 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7433 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7434 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7435 (iw_handler) NULL, /* SIOCSIWSENS */
7436 (iw_handler) NULL, /* SIOCGIWSENS */
7437 (iw_handler) NULL, /* SIOCSIWRANGE */
7438 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7439 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7440 (iw_handler) NULL, /* SIOCGIWPRIV */
7441 (iw_handler) NULL, /* SIOCSIWSTATS */
7442 (iw_handler) NULL, /* SIOCGIWSTATS */
7443 iw_handler_set_spy, /* SIOCSIWSPY */
7444 iw_handler_get_spy, /* SIOCGIWSPY */
7445 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7446 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7447 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7448 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7449 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7450 (iw_handler) NULL, /* SIOCGIWAPLIST */
7451 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7452 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7453 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7454 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7455 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7456 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7457 (iw_handler) NULL, /* -- hole -- */
7458 (iw_handler) NULL, /* -- hole -- */
7459 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7460 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7461 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7462 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7463 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7464 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7465 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7466 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7467 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7468 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7469 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7470 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7471 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7472 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7473 (iw_handler) NULL, /* -- hole -- */
7474 (iw_handler) NULL, /* -- hole -- */
7475 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7476 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7477 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7478 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7479 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7480 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7481 (iw_handler) NULL, /* SIOCSIWPMKSA */
7482};
7483
7484static const iw_handler we_private[] = {
7485
7486 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7487 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7488 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7489 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7490 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7491 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7492 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7493 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7494 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7495 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007496#ifdef FEATURE_OEM_DATA_SUPPORT
7497 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7498 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7499#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007500
7501#ifdef FEATURE_WLAN_WAPI
7502 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7503 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7504 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7505 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7506 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7507 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7508#endif /* FEATURE_WLAN_WAPI */
7509#ifdef WLAN_FEATURE_VOWIFI_11R
7510 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7511#endif
7512 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7513 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7514 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7515#ifdef WLAN_FEATURE_PACKET_FILTERING
7516 ,
7517 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7518#endif
7519#ifdef FEATURE_WLAN_SCAN_PNO
7520 ,
7521 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7522#endif
7523 ,
7524 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7525 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7526 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7527 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007528 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07007529};
7530
7531/*Maximum command length can be only 15 */
7532static const struct iw_priv_args we_private_args[] = {
7533
7534 /* handlers for main ioctl */
7535 { WLAN_PRIV_SET_INT_GET_NONE,
7536 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7537 0,
7538 "" },
7539
7540 /* handlers for sub-ioctl */
7541 { WE_SET_11D_STATE,
7542 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7543 0,
7544 "set11Dstate" },
7545
7546 { WE_WOWL,
7547 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7548 0,
7549 "wowl" },
7550
7551 { WE_SET_POWER,
7552 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7553 0,
7554 "setPower" },
7555
7556 { WE_SET_MAX_ASSOC,
7557 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7558 0,
7559 "setMaxAssoc" },
7560
7561 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7562 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7563 0,
7564 "setAutoChannel" },
7565
7566 { WE_SET_DATA_INACTIVITY_TO,
7567 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7568 0,
7569 "inactivityTO" },
7570
7571 { WE_SET_MAX_TX_POWER,
7572 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7573 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007574 "setMaxTxPower" },
7575
7576 { WE_SET_MAX_TX_POWER_2_4,
7577 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7578 0,
7579 "setTxMaxPower2G" },
7580
7581 { WE_SET_MAX_TX_POWER_5_0,
7582 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7583 0,
7584 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007585
7586 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7587 * as well to keep same syntax as in SAP. Now onwards, STA
7588 * will support both */
7589 { WE_SET_MAX_TX_POWER,
7590 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7591 0,
7592 "setTxMaxPower" },
7593
Jeff Johnson295189b2012-06-20 16:38:30 -07007594 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7595 * 1 = enable and 0 = disable */
7596 {
7597 WE_SET_HIGHER_DTIM_TRANSITION,
7598 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7599 0,
7600 "setHDtimTransn" },
7601
7602 { WE_SET_TM_LEVEL,
7603 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007604 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007605 "setTmLevel" },
7606
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307607 { WE_ENABLE_STRICT_FCC_REG,
7608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7609 0,
7610 "setStrictFCCreg" },
7611
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 /* handlers for main ioctl */
7613 { WLAN_PRIV_SET_NONE_GET_INT,
7614 0,
7615 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7616 "" },
7617
7618 /* handlers for sub-ioctl */
7619 { WE_GET_11D_STATE,
7620 0,
7621 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7622 "get11Dstate" },
7623
7624 { WE_IBSS_STATUS,
7625 0,
7626 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7627 "getAdhocStatus" },
7628
7629 { WE_PMC_STATE,
7630 0,
7631 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7632 "pmcState" },
7633
7634 { WE_GET_WLAN_DBG,
7635 0,
7636 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7637 "getwlandbg" },
7638
7639 { WE_MODULE_DOWN_IND,
7640 0,
7641 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7642 "moduleDownInd" },
7643
7644 { WE_GET_MAX_ASSOC,
7645 0,
7646 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7647 "getMaxAssoc" },
7648
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 { WE_GET_WDI_DBG,
7650 0,
7651 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7652 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007653
7654 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7655 0,
7656 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7657 "getAutoChannel" },
7658
7659 { WE_GET_CONCURRENCY_MODE,
7660 0,
7661 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7662 "getconcurrency" },
7663
7664 /* handlers for main ioctl */
7665 { WLAN_PRIV_SET_CHAR_GET_NONE,
7666 IW_PRIV_TYPE_CHAR| 512,
7667 0,
7668 "" },
7669
7670 /* handlers for sub-ioctl */
7671 { WE_WOWL_ADD_PTRN,
7672 IW_PRIV_TYPE_CHAR| 512,
7673 0,
7674 "wowlAddPtrn" },
7675
7676 { WE_WOWL_DEL_PTRN,
7677 IW_PRIV_TYPE_CHAR| 512,
7678 0,
7679 "wowlDelPtrn" },
7680
7681#if defined WLAN_FEATURE_VOWIFI
7682 /* handlers for sub-ioctl */
7683 { WE_NEIGHBOR_REPORT_REQUEST,
7684 IW_PRIV_TYPE_CHAR | 512,
7685 0,
7686 "neighbor" },
7687#endif
7688 { WE_SET_AP_WPS_IE,
7689 IW_PRIV_TYPE_CHAR| 512,
7690 0,
7691 "set_ap_wps_ie" },
7692
7693 { WE_SET_CONFIG,
7694 IW_PRIV_TYPE_CHAR| 512,
7695 0,
7696 "setConfig" },
7697
7698 /* handlers for main ioctl */
7699 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7700 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7701 0,
7702 "" },
7703
7704 /* handlers for sub-ioctl */
7705 { WE_SET_WLAN_DBG,
7706 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7707 0,
7708 "setwlandbg" },
7709
Jeff Johnson295189b2012-06-20 16:38:30 -07007710 { WE_SET_WDI_DBG,
7711 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7712 0,
7713 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007714
7715 { WE_SET_SAP_CHANNELS,
7716 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7717 0,
7718 "setsapchannels" },
7719
7720 /* handlers for main ioctl */
7721 { WLAN_PRIV_GET_CHAR_SET_NONE,
7722 0,
7723 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7724 "" },
7725
7726 /* handlers for sub-ioctl */
7727 { WE_WLAN_VERSION,
7728 0,
7729 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7730 "version" },
7731 { WE_GET_STATS,
7732 0,
7733 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7734 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307735 { WE_GET_STATES,
7736 0,
7737 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7738 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007739 { WE_GET_CFG,
7740 0,
7741 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7742 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007743#ifdef WLAN_FEATURE_11AC
7744 { WE_GET_RSSI,
7745 0,
7746 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7747 "getRSSI" },
7748#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007749#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
7750 { WE_GET_ROAM_RSSI,
7751 0,
7752 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7753 "getRoamRSSI" },
7754#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007755 { WE_GET_WMM_STATUS,
7756 0,
7757 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7758 "getWmmStatus" },
7759 {
7760 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307761 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007762 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7763 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007764#ifdef FEATURE_WLAN_TDLS
7765 {
7766 WE_GET_TDLS_PEERS,
7767 0,
7768 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7769 "getTdlsPeers" },
7770#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007771#ifdef WLAN_FEATURE_11W
7772 {
7773 WE_GET_11W_INFO,
7774 0,
7775 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7776 "getPMFInfo" },
7777#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007778 /* handlers for main ioctl */
7779 { WLAN_PRIV_SET_NONE_GET_NONE,
7780 0,
7781 0,
7782 "" },
7783
7784 /* handlers for sub-ioctl */
7785 { WE_CLEAR_STATS,
7786 0,
7787 0,
7788 "clearStats" },
7789 { WE_INIT_AP,
7790 0,
7791 0,
7792 "initAP" },
7793 { WE_STOP_AP,
7794 0,
7795 0,
7796 "exitAP" },
7797 { WE_ENABLE_AMP,
7798 0,
7799 0,
7800 "enableAMP" },
7801 { WE_DISABLE_AMP,
7802 0,
7803 0,
7804 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007805 { WE_ENABLE_DXE_STALL_DETECT,
7806 0,
7807 0,
7808 "dxeStallDetect" },
7809 { WE_DISPLAY_DXE_SNAP_SHOT,
7810 0,
7811 0,
7812 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307813 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7814 0,
7815 0,
7816 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007817 {
7818 WE_SET_REASSOC_TRIGGER,
7819 0,
7820 0,
7821 "reassoc" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007822
7823 /* handlers for main ioctl */
7824 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7825 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7826 0,
7827 "" },
7828
7829 /* handlers for sub-ioctl */
7830 { WE_LOG_DUMP_CMD,
7831 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7832 0,
7833 "dump" },
7834
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007835 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307836 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
7837 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7838 0,
7839 "setdumplog" },
7840
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007841 { WE_MTRACE_DUMP_CMD,
7842 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7843 0,
7844 "dumplog" },
7845
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007846 /* handlers for sub ioctl */
7847 {
7848 WE_MCC_CONFIG_CREDENTIAL,
7849 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7850 0,
7851 "setMccCrdnl" },
7852
7853 /* handlers for sub ioctl */
7854 {
7855 WE_MCC_CONFIG_PARAMS,
7856 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7857 0,
7858 "setMccConfig" },
7859
Chilam NG571c65a2013-01-19 12:27:36 +05307860#ifdef FEATURE_WLAN_TDLS
7861 /* handlers for sub ioctl */
7862 {
7863 WE_TDLS_CONFIG_PARAMS,
7864 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7865 0,
7866 "setTdlsConfig" },
7867#endif
7868
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 /* handlers for main ioctl */
7870 { WLAN_PRIV_ADD_TSPEC,
7871 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7872 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7873 "addTspec" },
7874
7875 /* handlers for main ioctl */
7876 { WLAN_PRIV_DEL_TSPEC,
7877 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7878 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7879 "delTspec" },
7880
7881 /* handlers for main ioctl */
7882 { WLAN_PRIV_GET_TSPEC,
7883 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7884 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7885 "getTspec" },
7886
Jeff Johnsone7245742012-09-05 17:12:55 -07007887#ifdef FEATURE_OEM_DATA_SUPPORT
7888 /* handlers for main ioctl - OEM DATA */
7889 {
7890 WLAN_PRIV_SET_OEM_DATA_REQ,
7891 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7892 0,
7893 "set_oem_data_req" },
7894
7895 /* handlers for main ioctl - OEM DATA */
7896 {
7897 WLAN_PRIV_GET_OEM_DATA_RSP,
7898 0,
7899 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
7900 "get_oem_data_rsp" },
7901#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007902
7903#ifdef FEATURE_WLAN_WAPI
7904 /* handlers for main ioctl SET_WAPI_MODE */
7905 { WLAN_PRIV_SET_WAPI_MODE,
7906 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7907 0,
7908 "SET_WAPI_MODE" },
7909
7910 /* handlers for main ioctl GET_WAPI_MODE */
7911 { WLAN_PRIV_GET_WAPI_MODE,
7912 0,
7913 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7914 "GET_WAPI_MODE" },
7915
7916 /* handlers for main ioctl SET_ASSOC_INFO */
7917 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
7918 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
7919 0,
7920 "SET_WAPI_ASSOC" },
7921
7922 /* handlers for main ioctl SET_WAPI_KEY */
7923 { WLAN_PRIV_SET_WAPI_KEY,
7924 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
7925 0,
7926 "SET_WAPI_KEY" },
7927
7928 /* handlers for main ioctl SET_WAPI_BKID */
7929 { WLAN_PRIV_SET_WAPI_BKID,
7930 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7931 0,
7932 "SET_WAPI_BKID" },
7933
7934 /* handlers for main ioctl GET_WAPI_BKID */
7935 { WLAN_PRIV_GET_WAPI_BKID,
7936 0,
7937 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7938 "GET_WAPI_BKID" },
7939#endif /* FEATURE_WLAN_WAPI */
7940
7941 /* handlers for main ioctl - host offload */
7942 {
7943 WLAN_PRIV_SET_HOST_OFFLOAD,
7944 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
7945 0,
7946 "setHostOffload" },
7947
7948 {
7949 WLAN_GET_WLAN_STATISTICS,
7950 0,
7951 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
7952 "getWlanStats" },
7953
7954 {
7955 WLAN_SET_KEEPALIVE_PARAMS,
7956 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
7957 0,
7958 "setKeepAlive" },
7959#ifdef WLAN_FEATURE_PACKET_FILTERING
7960 {
7961 WLAN_SET_PACKET_FILTER_PARAMS,
7962 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
7963 0,
7964 "setPktFilter" },
7965#endif
7966#ifdef FEATURE_WLAN_SCAN_PNO
7967 {
7968 WLAN_SET_PNO,
7969 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7970 0,
7971 "setpno" },
7972#endif
7973 {
7974 WLAN_SET_BAND_CONFIG,
7975 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7976 0,
7977 "SETBAND" },
7978 /* handlers for dynamic MC BC ioctl */
7979 {
7980 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007981 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07007982 0,
7983 "setMCBCFilter" },
7984 {
7985 WLAN_PRIV_CLEAR_MCBC_FILTER,
7986 0,
7987 0,
7988 "clearMCBCFilter" },
7989 {
7990 WLAN_SET_POWER_PARAMS,
7991 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7992 0,
7993 "setpowerparams" },
7994 {
7995 WLAN_GET_LINK_SPEED,
7996 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05307997 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007998};
7999
8000
8001
8002const struct iw_handler_def we_handler_def = {
8003 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8004 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8005 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8006
8007 .standard = (iw_handler *)we_handler,
8008 .private = (iw_handler *)we_private,
8009 .private_args = we_private_args,
8010 .get_wireless_stats = get_wireless_stats,
8011};
8012
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008013int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8014{
8015 v_U32_t cmd = 288; //Command to RIVA
8016 hdd_context_t *pHddCtx = NULL;
8017 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8018 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8019 /*
8020 *configMccParam : specify the bit which needs to be modified
8021 *allowed to update based on wlan_qcom_cfg.ini
8022 * configuration
8023 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8024 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8025 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8026 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8027 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8028 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8029 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8030 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8031 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8032 * Bit 9 : Reserved
8033 */
8034 switch (arg1)
8035 {
8036 //Update MCC SCHEDULE_TIME_SLICE parameter
8037 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8038 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8039 {
8040 if((arg2 >= 5) && (arg2 <= 20))
8041 {
8042 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8043 }
8044 else
8045 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008046 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008047 return 0;
8048 }
8049 }
8050 break;
8051
8052 //Update MCC MAX_NULL_SEND_TIME parameter
8053 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8054 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8055 {
8056 if((arg2 >= 1) && (arg2 <= 10))
8057 {
8058 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8059 }
8060 else
8061 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008062 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008063 return 0;
8064 }
8065 }
8066 break;
8067
8068 //Update MCC TX_EARLY_STOP_TIME parameter
8069 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8070 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8071 {
8072 if((arg2 >= 1) && (arg2 <= 10))
8073 {
8074 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8075 }
8076 else
8077 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008078 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008079 return 0;
8080 }
8081 }
8082 break;
8083
8084 //Update MCC RX_DRAIN_TIME parameter
8085 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8086 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8087 {
8088 if((arg2 >= 1) && (arg2 <= 10))
8089 {
8090 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8091 }
8092 else
8093 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008094 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008095 return 0;
8096 }
8097 }
8098 break;
8099
8100 //Update MCC CHANNEL_SWITCH_TIME parameter
8101 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8102 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8103 {
8104 if((arg2 >= 1) && (arg2 <= 20))
8105 {
8106 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8107 }
8108 else
8109 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008110 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008111 return 0;
8112 }
8113 }
8114 break;
8115
8116 //Update MCC MIN_CHANNEL_TIME parameter
8117 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8118 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8119 {
8120 if((arg2 >= 5) && (arg2 <= 20))
8121 {
8122 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8123 }
8124 else
8125 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008126 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008127 return 0;
8128 }
8129 }
8130 break;
8131
8132 //Update MCC PARK_BEFORE_TBTT parameter
8133 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8134 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8135 {
8136 if((arg2 >= 1) && (arg2 <= 5))
8137 {
8138 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8139 }
8140 else
8141 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008142 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008143 return 0;
8144 }
8145 }
8146 break;
8147
8148 //Update MCC MIN_AFTER_DTIM parameter
8149 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8150 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8151 {
8152 if((arg2 >= 5) && (arg2 <= 15))
8153 {
8154 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8155 }
8156 else
8157 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008158 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008159 return 0;
8160 }
8161 }
8162 break;
8163
8164 //Update MCC TOO_CLOSE_MARGIN parameter
8165 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8166 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8167 {
8168 if((arg2 >= 1) && (arg2 <= 3))
8169 {
8170 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8171 }
8172 else
8173 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008174 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008175 return 0;
8176 }
8177 }
8178 break;
8179
8180 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008181 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008182 __FUNCTION__,arg1);
8183 break;
8184 }
8185 return 0;
8186}
8187
Jeff Johnson295189b2012-06-20 16:38:30 -07008188int hdd_set_wext(hdd_adapter_t *pAdapter)
8189{
8190 hdd_wext_state_t *pwextBuf;
8191 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008192 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008193
8194 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8195
8196 // Now configure the roaming profile links. To SSID and bssid.
8197 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8198 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8199
8200 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8201 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8202
8203 /*Set the numOfChannels to zero to scan all the channels*/
8204 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8205 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8206
8207 /* Default is no encryption */
8208 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8209 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8210
8211 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8212 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8213
8214 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8215
8216 /* Default is no authentication */
8217 pwextBuf->roamProfile.AuthType.numEntries = 1;
8218 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8219
8220 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8221 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8222
8223 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008224 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008225
8226 hdd_clearRoamProfileIe(pAdapter);
8227
8228 return VOS_STATUS_SUCCESS;
8229
8230 }
8231
8232int hdd_register_wext(struct net_device *dev)
8233 {
8234 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8235 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8236 VOS_STATUS status;
8237
8238 ENTER();
8239
8240 // Zero the memory. This zeros the profile structure.
8241 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8242
8243 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8244
8245
8246 status = hdd_set_wext(pAdapter);
8247
8248 if(!VOS_IS_STATUS_SUCCESS(status)) {
8249
Arif Hussain6d2a3322013-11-17 19:50:10 -08008250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008251 return eHAL_STATUS_FAILURE;
8252 }
8253
8254 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8255 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 return eHAL_STATUS_FAILURE;
8258 }
8259
8260 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8261 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 return eHAL_STATUS_FAILURE;
8264 }
8265
8266 // Register as a wireless device
8267 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8268
8269 EXIT();
8270 return 0;
8271}
8272
8273int hdd_UnregisterWext(struct net_device *dev)
8274{
8275#if 0
8276 hdd_wext_state_t *wextBuf;
8277 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8278
8279 ENTER();
8280 // Set up the pointer to the Wireless Extensions state structure
8281 wextBuf = pAdapter->pWextState;
8282
8283 // De-allocate the Wireless Extensions state structure
8284 kfree(wextBuf);
8285
8286 // Clear out the pointer to the Wireless Extensions state structure
8287 pAdapter->pWextState = NULL;
8288
8289 EXIT();
8290#endif
8291 dev->wireless_handlers = NULL;
8292 return 0;
8293}
8294
8295