blob: e1012bf56f476e76d7249ad78c1ea18e11ce9687 [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
Jeff Johnson295189b2012-06-20 16:38:30 -070053 This file defines all of the types that are utilized by the CCP module
54 of the "Portable" HDD. This file also includes the underlying Linux
55 Wireless Extensions Data types referred to by CCP.
56
57 ======================================================================== */
58
59#include <linux/version.h>
60#include <linux/module.h>
61#include <linux/kernel.h>
62#include <linux/init.h>
63#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053064#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include <wlan_hdd_includes.h>
66#include <wlan_btc_svc.h>
67#include <wlan_nlink_common.h>
68#ifdef WLAN_BTAMP_FEATURE
69#include <bap_hdd_main.h>
70#endif
71#include <vos_api.h>
72#include <net/arp.h>
73#include "ccmApi.h"
74#include "sirParams.h"
75#include "csrApi.h"
76#include "csrInsideApi.h"
77#if defined WLAN_FEATURE_VOWIFI
78#include "smeRrmInternal.h"
79#endif
80#include <aniGlobal.h>
81#include "dot11f.h"
82#include <wlan_hdd_wowl.h>
83#include <wlan_hdd_cfg.h>
84#include <wlan_hdd_wmm.h>
85#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053087#ifdef FEATURE_WLAN_TDLS
88#include "wlan_hdd_tdls.h"
89#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070090
91#ifdef CONFIG_HAS_EARLYSUSPEND
92#include <linux/earlysuspend.h>
93#endif
94#include "wlan_hdd_power.h"
95#include "qwlan_version.h"
96#include <vos_power.h>
97#include "wlan_hdd_host_offload.h"
98#include "wlan_hdd_keep_alive.h"
99#ifdef WLAN_FEATURE_PACKET_FILTERING
100#include "wlan_hdd_packet_filtering.h"
101#endif
102
Jeff Johnson295189b2012-06-20 16:38:30 -0700103#include <linux/wireless.h>
104#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530106#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#include "wlan_hdd_misc.h"
109#include "bap_hdd_misc.h"
110
111#include "wlan_hdd_dev_pwr.h"
112#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530113#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700114#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700115
116#ifdef CONFIG_HAS_EARLYSUSPEND
117extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
118extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
119#endif
120
Jeff Johnsone7245742012-09-05 17:12:55 -0700121#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800122#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700123#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700124
125#define HDD_FINISH_ULA_TIME_OUT 800
126
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700127
Jeff Johnson295189b2012-06-20 16:38:30 -0700128extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
129int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
130
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700131static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700132module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
133
Jeff Johnson295189b2012-06-20 16:38:30 -0700134/* To Validate Channel against the Frequency and Vice-Versa */
135static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
136 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
137 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
138 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
139 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
140 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
141 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
142 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
143 {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} };
144
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800145#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700146
147/* Private ioctls and their sub-ioctls */
148#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
149#define WE_SET_11D_STATE 1
150#define WE_WOWL 2
151#define WE_SET_POWER 3
152#define WE_SET_MAX_ASSOC 4
153#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
154#define WE_SET_DATA_INACTIVITY_TO 6
155#define WE_SET_MAX_TX_POWER 7
156#define WE_SET_HIGHER_DTIM_TRANSITION 8
157#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530158#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700159#define WE_SET_MAX_TX_POWER_2_4 11
160#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800161/* Private IOCTL for debug connection issues */
162#define WE_SET_DEBUG_LOG 13
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 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004298 case WE_SET_DEBUG_LOG:
4299 {
4300 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4301 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4302 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4303 break;
4304 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304305
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 default:
4307 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004308 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 sub_cmd, set_value);
4310 break;
4311 }
4312 }
4313
4314 return ret;
4315}
4316
4317/* set param sub-ioctls */
4318static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4319 union iwreq_data *wrqu, char *extra)
4320{
4321 VOS_STATUS vstatus;
4322 int sub_cmd = wrqu->data.flags;
4323 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004324 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4326 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4327#ifdef WLAN_FEATURE_VOWIFI
4328 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4329#endif /* WLAN_FEATURE_VOWIFI */
4330
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004331 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4332 {
4333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4334 "%s:LOGP in Progress. Ignore!!!", __func__);
4335 return -EBUSY;
4336 }
4337
Arif Hussain0273cba2014-01-07 20:58:29 -08004338 /* ODD number is used for set, copy data using copy_from_user */
4339 pBuffer = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4340 wrqu->data.length);
4341 if (NULL == pBuffer)
4342 {
4343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4344 "mem_alloc_copy_from_user_helper fail");
4345 return -ENOMEM;
4346 }
4347
4348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4349 "%s: Received length %d", __func__, wrqu->data.length);
4350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4351 "%s: Received data %s", __func__, pBuffer);
4352
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 switch(sub_cmd)
4354 {
4355 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004357 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 break;
4359 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004361 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 break;
4363#if defined WLAN_FEATURE_VOWIFI
4364 case WE_NEIGHBOR_REPORT_REQUEST:
4365 {
4366 tRrmNeighborReq neighborReq;
4367 tRrmNeighborRspCallbackInfo callbackInfo;
4368
4369 if (pConfig->fRrmEnable)
4370 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4373 if( !neighborReq.no_ssid )
4374 {
4375 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004376 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 }
4378
4379 callbackInfo.neighborRspCallback = NULL;
4380 callbackInfo.neighborRspCallbackContext = NULL;
4381 callbackInfo.timeout = 5000; //5 seconds
4382 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4383 }
4384 else
4385 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004386 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 ret = -EINVAL;
4388 }
4389 }
4390 break;
4391#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 case WE_SET_AP_WPS_IE:
4393 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain0273cba2014-01-07 20:58:29 -08004394 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004397 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 if (VOS_STATUS_SUCCESS != vstatus)
4399 {
4400 ret = -EINVAL;
4401 }
4402 break;
4403 default:
4404 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004405 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 ret = -EINVAL;
4407 break;
4408 }
4409 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004410 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 return ret;
4412}
4413
4414/* get param sub-ioctls */
4415static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4416 union iwreq_data *wrqu, char *extra)
4417{
4418 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4419 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4420 int *value = (int *)extra;
4421 int ret = 0; /* success */
4422
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004423 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4424 {
4425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4426 "%s:LOGP in Progress. Ignore!!!", __func__);
4427 return -EBUSY;
4428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004429
4430 switch (value[0])
4431 {
4432 case WE_GET_11D_STATE:
4433 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004434 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304436
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4438
Arif Hussain6d2a3322013-11-17 19:50:10 -08004439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004440
4441 break;
4442 }
4443
4444 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 break;
4447
4448 case WE_PMC_STATE:
4449 {
4450 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 break;
4453 }
4454 case WE_GET_WLAN_DBG:
4455 {
4456 vos_trace_display();
4457 *value = 0;
4458 break;
4459 }
4460 case WE_MODULE_DOWN_IND:
4461 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4464#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4467#endif
4468 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4469
4470 *value = 0;
4471 break;
4472 }
4473 case WE_GET_MAX_ASSOC:
4474 {
4475 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4476 {
4477 ret = -EIO;
4478 }
4479 break;
4480 }
4481
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 case WE_GET_WDI_DBG:
4483 {
4484 wpalTraceDisplay();
4485 *value = 0;
4486 break;
4487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004488
4489 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4490 {
4491 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4492 break;
4493 }
4494 case WE_GET_CONCURRENCY_MODE:
4495 {
4496 *value = hdd_get_concurrency_mode ( );
4497
Arif Hussain6d2a3322013-11-17 19:50:10 -08004498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 break;
4500 }
4501
4502 default:
4503 {
4504 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4505 break;
4506 }
4507 }
4508
4509 return ret;
4510}
4511
4512/* set param sub-ioctls */
4513int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4514 union iwreq_data *wrqu, char *extra)
4515{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004516 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 int *value = (int *)extra;
4518 int sub_cmd = value[0];
4519 int ret = 0;
4520
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004521 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4522 {
4523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4524 "%s:LOGP in Progress. Ignore!!!", __func__);
4525 return -EBUSY;
4526 }
4527
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 switch(sub_cmd)
4529 {
4530 case WE_SET_WLAN_DBG:
4531 {
4532 vos_trace_setValue( value[1], value[2], value[3]);
4533 break;
4534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 case WE_SET_WDI_DBG:
4536 {
4537 wpalTraceSetLevel( value[1], value[2], value[3]);
4538 break;
4539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 case WE_SET_SAP_CHANNELS:
4541 {
4542 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4543 break;
4544 }
4545
4546 default:
4547 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004548 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 break;
4550 }
4551 }
4552 return ret;
4553}
4554
4555static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4556 union iwreq_data *wrqu, char *extra)
4557{
4558 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4559 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004560#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004561 hdd_wext_state_t *pWextState;
4562#endif
4563
4564 if (pAdapter == NULL)
4565 {
4566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4567 "%s: pAdapter is NULL!", __func__);
4568 return -EINVAL;
4569 }
4570#ifdef WLAN_FEATURE_11W
4571 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004572#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004573
Yue Ma3ede6052013-08-29 00:33:26 -07004574 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4575 {
4576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4577 "%s: HDD Context is NULL!", __func__);
4578
4579 return -EINVAL;
4580 }
4581
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004582 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4583 {
4584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4585 "%s:LOGP in Progress. Ignore!!!", __func__);
4586 return -EBUSY;
4587 }
4588
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 switch(sub_cmd)
4590 {
4591 case WE_WLAN_VERSION:
4592 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004593 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 break;
4595 }
4596
4597 case WE_GET_STATS:
4598 {
4599 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4600 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4601 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4602
4603 snprintf(extra, WE_MAX_STR_LEN,
4604 "\nTransmit"
4605 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4606 "\n dropped BK %u, BE %u, VI %u, VO %u"
4607 "\n classified BK %u, BE %u, VI %u, VO %u"
4608 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4609 "\n queued BK %u, BE %u, VI %u, VO %u"
4610 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004611 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 "\n fetched BK %u, BE %u, VI %u, VO %u"
4613 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4614 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004615 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 "\n flushed BK %u, BE %u, VI %u, VO %u"
4617 "\n\nReceive"
4618 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4619 "\n\nResetsStats"
4620 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4621 "\n",
4622 pStats->txXmitCalled,
4623 pStats->txXmitDropped,
4624 pStats->txXmitBackPressured,
4625 pStats->txXmitQueued,
4626
4627 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4628 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4629 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4630 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4631
4632 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4633 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4634 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4635 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4636
4637 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4638 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4639 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4640 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4641
4642 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4643 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4644 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4645 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4646
4647 pStats->txFetched,
4648 pStats->txFetchEmpty,
4649 pStats->txFetchLowResources,
4650 pStats->txFetchDequeueError,
4651
4652 pStats->txFetchDequeued,
4653 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004654 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 pStats->txCompleted,
4656 pStats->txFlushed,
4657
4658 pStats->txFetchedAC[WLANTL_AC_BK],
4659 pStats->txFetchedAC[WLANTL_AC_BE],
4660 pStats->txFetchedAC[WLANTL_AC_VI],
4661 pStats->txFetchedAC[WLANTL_AC_VO],
4662
4663 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4664 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4665 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4666 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4667
4668 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4669 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4670 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4671 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4672
Ravi Joshi41914632013-10-21 23:02:21 -07004673 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4674 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4675 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4676 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4677
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 pStats->txFlushedAC[WLANTL_AC_BK],
4679 pStats->txFlushedAC[WLANTL_AC_BE],
4680 pStats->txFlushedAC[WLANTL_AC_VI],
4681 pStats->txFlushedAC[WLANTL_AC_VO],
4682
4683 pStats->rxChains,
4684 pStats->rxPackets,
4685 pStats->rxDropped,
4686 pStats->rxDelivered,
4687 pStats->rxRefused,
4688
4689 pResetStats->totalLogpResets,
4690 pResetStats->totalCMD53Failures,
4691 pResetStats->totalMutexReadFailures,
4692 pResetStats->totalMIFErrorFailures,
4693 pResetStats->totalFWHearbeatFailures,
4694 pResetStats->totalUnknownExceptions
4695 );
4696 wrqu->data.length = strlen(extra)+1;
4697 break;
4698 }
4699
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304700/* The case prints the current state of the HDD, SME, CSR, PE, TL
4701 *it can be extended for WDI Global State as well.
4702 *And currently it only checks P2P_CLIENT adapter.
4703 *P2P_DEVICE and P2P_GO have not been added as of now.
4704*/
4705 case WE_GET_STATES:
4706 {
4707 int buf = 0, len = 0;
4708 int adapter_num = 0;
4709 int count = 0, check = 1;
4710
4711 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004712 tHalHandle hHal = NULL;
4713 tpAniSirGlobal pMac = NULL;
4714 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304715
4716 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4717 hdd_adapter_t *useAdapter = NULL;
4718
4719 /* Print wlan0 or p2p0 states based on the adapter_num
4720 *by using the correct adapter
4721 */
4722 while ( adapter_num < 2 )
4723 {
4724 if ( WLAN_ADAPTER == adapter_num )
4725 {
4726 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004727 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304728 "\n\n wlan0 States:-");
4729 len += buf;
4730 }
4731 else if ( P2P_ADAPTER == adapter_num )
4732 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004733 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304734 "\n\n p2p0 States:-");
4735 len += buf;
4736
4737 if( !pHddCtx )
4738 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004739 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304740 "\n pHddCtx is NULL");
4741 len += buf;
4742 break;
4743 }
4744
4745 /*Printing p2p0 states only in the case when the device is
4746 configured as a p2p_client*/
4747 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4748 if ( !useAdapter )
4749 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004750 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304751 "\n Device not configured as P2P_CLIENT.");
4752 len += buf;
4753 break;
4754 }
4755 }
4756
4757 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004758 if (!hHal) {
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 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004765 if (!pMac) {
4766 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4767 "\n pMac is NULL");
4768 len += buf;
4769 break;
4770 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304771 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4772 if( !pHddStaCtx )
4773 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004774 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304775 "\n pHddStaCtx is NULL");
4776 len += buf;
4777 break;
4778 }
4779
4780 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4781
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004782 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304783 "\n HDD Conn State - %s "
4784 "\n \n SME State:"
4785 "\n Neighbour Roam State - %s"
4786 "\n CSR State - %s"
4787 "\n CSR Substate - %s"
4788 "\n \n TL STA %d State: %s",
4789 macTraceGetHDDWlanConnState(
4790 pHddStaCtx->conn_info.connState),
4791 macTraceGetNeighbourRoamState(
4792 pMac->roam.neighborRoamInfo.neighborRoamState),
4793 macTraceGetcsrRoamState(
4794 pMac->roam.curState[useAdapter->sessionId]),
4795 macTraceGetcsrRoamSubState(
4796 pMac->roam.curSubState[useAdapter->sessionId]),
4797 pHddStaCtx->conn_info.staId[0],
4798 macTraceGetTLState(tlState)
4799 );
4800 len += buf;
4801 adapter_num++;
4802 }
4803
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004804 if (pMac) {
4805 /* Printing Lim State starting with global lim states */
4806 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4807 "\n \n LIM STATES:-"
4808 "\n Global Sme State - %s "\
4809 "\n Global mlm State - %s "\
4810 "\n",
4811 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4812 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4813 );
4814 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304815
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004816 /*printing the PE Sme and Mlm states for valid lim sessions*/
4817 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304818 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004819 if ( pMac->lim.gpSession[count].valid )
4820 {
4821 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4822 "\n Lim Valid Session %d:-"
4823 "\n PE Sme State - %s "
4824 "\n PE Mlm State - %s "
4825 "\n",
4826 check,
4827 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4828 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4829 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304830
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004831 len += buf;
4832 check++;
4833 }
4834 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304835 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304836 }
4837
4838 wrqu->data.length = strlen(extra)+1;
4839 break;
4840 }
4841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 case WE_GET_CFG:
4843 {
4844 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4845 wrqu->data.length = strlen(extra)+1;
4846 break;
4847 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004848#ifdef WLAN_FEATURE_11AC
4849 case WE_GET_RSSI:
4850 {
4851 v_S7_t s7Rssi = 0;
4852 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4853 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4854 wrqu->data.length = strlen(extra)+1;
4855 break;
4856 }
4857#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304858
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004859#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4860 case WE_GET_ROAM_RSSI:
4861 {
4862 v_S7_t s7Rssi = 0;
4863 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4864 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4865 wrqu->data.length = strlen(extra)+1;
4866 break;
4867 }
4868#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 case WE_GET_WMM_STATUS:
4870 {
4871 snprintf(extra, WE_MAX_STR_LEN,
4872 "\nDir: 0=up, 1=down, 3=both\n"
4873 "|------------------------|\n"
4874 "|AC | ACM |Admitted| Dir |\n"
4875 "|------------------------|\n"
4876 "|VO | %d | %3s | %d |\n"
4877 "|VI | %d | %3s | %d |\n"
4878 "|BE | %d | %3s | %d |\n"
4879 "|BK | %d | %3s | %d |\n"
4880 "|------------------------|\n",
4881 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4882 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4883 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4884 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4885 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4886 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4887 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4888 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4889 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4890 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4891 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4892 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4893
Jeff Johnsone7245742012-09-05 17:12:55 -07004894
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 wrqu->data.length = strlen(extra)+1;
4896 break;
4897 }
4898 case WE_GET_CHANNEL_LIST:
4899 {
4900 VOS_STATUS status;
4901 v_U8_t i, len;
4902 char* buf ;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004903
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 tChannelListInfo channel_list;
4905
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004906 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004908 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004910 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 return -EINVAL;
4912 }
4913 buf = extra;
4914
4915 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004916 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4917 * needed = 5 * number of channels. Check ifsufficient
4918 * buffer is available and then proceed to fill the buffer.
4919 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4921 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004922 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004923 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004924 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 return -EINVAL;
4926 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004927 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
4928 channel_list.num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 for(i = 0 ; i < channel_list.num_channels; i++)
4930 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004931 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 }
4934 wrqu->data.length = strlen(extra)+1;
4935
4936 break;
4937 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004938#ifdef FEATURE_WLAN_TDLS
4939 case WE_GET_TDLS_PEERS:
4940 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08004941 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004942 break;
4943 }
4944#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004945#ifdef WLAN_FEATURE_11W
4946 case WE_GET_11W_INFO:
4947 {
4948 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4949
4950 snprintf(extra, WE_MAX_STR_LEN,
4951 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4952 "\n Number of Unprotected Disassocs %d"
4953 "\n Number of Unprotected Deauths %d",
4954 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4955 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4956 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4957 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
4958 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
4959
4960 wrqu->data.length = strlen(extra)+1;
4961 break;
4962 }
4963#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304964 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004966 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 break;
4968 }
4969 }
4970
4971 return 0;
4972}
4973
4974/* action sub-ioctls */
4975static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4976 union iwreq_data *wrqu, char *extra)
4977{
4978 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4979 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004980 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004981
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004982 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4983 {
4984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4985 "%s:LOGP in Progress. Ignore!!!", __func__);
4986 return -EBUSY;
4987 }
4988
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 switch (sub_cmd)
4990 {
4991 case WE_CLEAR_STATS:
4992 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
4995 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
4996 break;
4997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 case WE_INIT_AP:
4999 {
5000 pr_info("Init AP trigger\n");
5001 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5002 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5003 break;
5004 }
5005 case WE_STOP_AP:
5006 {
5007 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5008 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5009 * this is a dead code and need to find the adpater by name rather than mode */
5010 hdd_adapter_t* pAdapter_to_stop =
5011 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5012 if( pAdapter_to_stop )
5013 {
5014 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5015
5016 pr_info("Stopping AP mode\n");
5017
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305018 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5019 {
5020 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5021 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5022 }
5023
Jeff Johnson295189b2012-06-20 16:38:30 -07005024 /*Make sure that pAdapter cleaned properly*/
5025 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5026 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5027 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5028
5029 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5030 pAdapter_to_stop->macAddressCurrent.bytes);
5031 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5032 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305033
5034 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5035 {
5036 /* put the device back into BMPS */
5037 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 }
5040 else
5041 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005042 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 }
5044
5045 break;
5046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005047#ifdef WLAN_BTAMP_FEATURE
5048 case WE_ENABLE_AMP:
5049 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 WLANBAP_RegisterWithHCI(pAdapter);
5052 break;
5053 }
5054 case WE_DISABLE_AMP:
5055 {
5056 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5057 VOS_STATUS status;
5058
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005060
5061 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5062 status = WLANBAP_StopAmp();
5063 if(VOS_STATUS_SUCCESS != status )
5064 {
5065 pHddCtx->isAmpAllowed = VOS_TRUE;
5066 hddLog(VOS_TRACE_LEVEL_FATAL,
5067 "%s: Failed to stop AMP", __func__);
5068 }
5069 else
5070 {
5071 //a state m/c implementation in PAL is TBD to avoid this delay
5072 msleep(500);
5073 pHddCtx->isAmpAllowed = VOS_FALSE;
5074 WLANBAP_DeregisterFromHCI();
5075 }
5076
5077 break;
5078 }
5079#endif
5080
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005081 case WE_ENABLE_DXE_STALL_DETECT:
5082 {
schang6295e542013-03-12 15:31:23 -07005083 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5084 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005085 break;
5086 }
5087 case WE_DISPLAY_DXE_SNAP_SHOT:
5088 {
schang6295e542013-03-12 15:31:23 -07005089 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5090 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005091 break;
5092 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305093 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5094 {
5095 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5096 hdd_wmm_tx_snapshot(pAdapter);
5097 WLANTL_TLDebugMessage(VOS_TRUE);
5098 break;
5099 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07005100 case WE_SET_REASSOC_TRIGGER:
5101 {
5102 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5103 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5104 v_U32_t roamId = 0;
5105 tCsrRoamModifyProfileFields modProfileFields;
5106 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5107 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5108 return 0;
5109 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305110
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005111
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 default:
5113 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005114 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 break;
5116 }
5117 }
5118
5119 return ret;
5120}
5121
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305122void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5123{
5124 /*
5125 * Function to display HDD WMM information
5126 * for Tx Queues.
5127 * Prints globala as well as per client depending
5128 * whether the clients are registered or not.
5129 */
5130 int i = 0, j = 0;
5131 for ( i=0; i< NUM_TX_QUEUES; i++)
5132 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305133 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005134 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305135 i, pAdapter->wmm_tx_queue[i].count,
5136 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305137 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305138 }
5139
5140 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5141 {
5142 if(pAdapter->aStaInfo[i].isUsed)
5143 {
5144 hddLog(LOGE, "******STAIndex: %d*********", i);
5145 for ( j=0; j< NUM_TX_QUEUES; j++)
5146 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305147 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005148 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305149 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5150 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5151 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305152 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305153 }
5154 }
5155 }
5156
5157}
Jeff Johnson295189b2012-06-20 16:38:30 -07005158int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5159 union iwreq_data *wrqu, char *extra)
5160{
5161 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5162 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5163 int sub_cmd = wrqu->data.flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 int apps_args[MAX_VAR_ARGS] = {0};
5165 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005166 hdd_station_ctx_t *pStaCtx = NULL ;
5167 hdd_ap_ctx_t *pAPCtx = NULL;
5168 int cmd = 0;
5169 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005170
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005171 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005172
5173 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5174 {
5175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5176 "%s:LOGP in Progress. Ignore!!!", __func__);
5177 return -EBUSY;
5178 }
5179
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 if (num_args > MAX_VAR_ARGS)
5181 {
5182 num_args = MAX_VAR_ARGS;
5183 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005184
5185 /* ODD number is used for set, copy data using copy_from_user */
5186 if (copy_from_user(apps_args, wrqu->data.pointer, (sizeof(int)) * num_args))
5187 {
5188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5189 "%s: failed to copy data to user buffer", __func__);
5190 return -EFAULT;
5191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005192
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005193 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5194 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5195 {
5196 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5197 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5198 {
5199 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5200 staId = pStaCtx->conn_info.staId[0];
5201 }
5202 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5203 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5204 {
5205 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5206 staId = pAPCtx->uBCStaId;
5207 }
5208 else
5209 {
5210 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5211 return 0;
5212 }
5213 }
5214
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 switch (sub_cmd)
5216 {
5217 case WE_LOG_DUMP_CMD:
5218 {
5219 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005220 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 apps_args[3], apps_args[4]);
5222
5223 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5224 apps_args[3], apps_args[4]);
5225
5226 }
5227 break;
5228
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 case WE_P2P_NOA_CMD:
5230 {
5231 p2p_app_setP2pPs_t p2pNoA;
5232
5233 p2pNoA.opp_ps = apps_args[0];
5234 p2pNoA.ctWindow = apps_args[1];
5235 p2pNoA.duration = apps_args[2];
5236 p2pNoA.interval = apps_args[3];
5237 p2pNoA.count = apps_args[4];
5238 p2pNoA.single_noa_duration = apps_args[5];
5239 p2pNoA.psSelection = apps_args[6];
5240
5241 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5242 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005243 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5245
5246 hdd_setP2pPs(dev, &p2pNoA);
5247
5248 }
5249 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005250
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305251 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5252 {
5253 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5254 __func__, apps_args[0], apps_args[1]);
5255 vosTraceEnable(apps_args[0], apps_args[1]);
5256 }
5257 break;
5258
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005259 case WE_MTRACE_DUMP_CMD:
5260 {
5261 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5262 "bitmask_of_module %d ",
5263 __func__, apps_args[0], apps_args[1], apps_args[2],
5264 apps_args[3]);
5265 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5266 apps_args[2], apps_args[3]);
5267
5268 }
5269 break;
5270
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005271 case WE_MCC_CONFIG_CREDENTIAL :
5272 {
5273 cmd = 287; //Command should be updated if there is any change
5274 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005275 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005276 {
5277 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5278 }
5279 else
5280 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005281 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005282 return 0;
5283 }
5284 }
5285 break;
5286
5287 case WE_MCC_CONFIG_PARAMS :
5288 {
5289 cmd = 288; //command Should be updated if there is any change
5290 // in the Riva dump command
5291 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5292 }
5293 break;
5294
Chilam NG571c65a2013-01-19 12:27:36 +05305295#ifdef FEATURE_WLAN_TDLS
5296 case WE_TDLS_CONFIG_PARAMS :
5297 {
5298 tdls_config_params_t tdlsParams;
5299
Chilam Ng01120412013-02-19 18:32:21 -08005300 tdlsParams.tdls = apps_args[0];
5301 tdlsParams.tx_period_t = apps_args[1];
5302 tdlsParams.tx_packet_n = apps_args[2];
5303 tdlsParams.discovery_period_t = apps_args[3];
5304 tdlsParams.discovery_tries_n = apps_args[4];
5305 tdlsParams.idle_timeout_t = apps_args[5];
5306 tdlsParams.idle_packet_n = apps_args[6];
5307 tdlsParams.rssi_hysteresis = apps_args[7];
5308 tdlsParams.rssi_trigger_threshold = apps_args[8];
5309 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305310
Chilam Ng01120412013-02-19 18:32:21 -08005311 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305312 }
5313 break;
5314#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 default:
5316 {
5317 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
5318 }
5319 break;
5320 }
5321
5322 return 0;
5323}
5324
5325
5326static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5327 union iwreq_data *wrqu, char *extra)
5328{
5329 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5330 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5331 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5332 int params[HDD_WLAN_WMM_PARAM_COUNT];
5333 sme_QosWmmTspecInfo tSpec;
5334 v_U32_t handle;
5335
5336 // make sure the application is sufficiently priviledged
5337 // note that the kernel will do this for "set" ioctls, but since
5338 // this ioctl wants to return status to user space it must be
5339 // defined as a "get" ioctl
5340 if (!capable(CAP_NET_ADMIN))
5341 {
5342 return -EPERM;
5343 }
5344
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005345 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5346 {
5347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5348 "%s:LOGP in Progress. Ignore!!!", __func__);
5349 return -EBUSY;
5350 }
5351
Jeff Johnson295189b2012-06-20 16:38:30 -07005352 // we must be associated in order to add a tspec
5353 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5354 {
5355 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5356 return 0;
5357 }
5358
5359 // since we are defined to be a "get" ioctl, and since the number
5360 // of params exceeds the number of params that wireless extensions
5361 // will pass down in the iwreq_data, we must copy the "set" params
5362 // from user space ourselves
5363 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5364 {
5365 // hmmm, can't get them
5366 return -EIO;
5367 }
5368
5369 // clear the tspec
5370 memset(&tSpec, 0, sizeof(tSpec));
5371
5372 // validate the handle
5373 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5374 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5375 {
5376 // that one is reserved
5377 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5378 return 0;
5379 }
5380
5381 // validate the TID
5382 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5383 {
5384 // out of range
5385 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5386 return 0;
5387 }
5388 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5389
5390 // validate the direction
5391 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5392 {
5393 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5394 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5395 break;
5396
5397 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5398 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5399 break;
5400
5401 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5402 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5403 break;
5404
5405 default:
5406 // unknown
5407 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5408 return 0;
5409 }
5410
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305411 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5412
Jeff Johnson295189b2012-06-20 16:38:30 -07005413 // validate the user priority
5414 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5415 {
5416 // out of range
5417 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5418 return 0;
5419 }
5420 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305421 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5422 {
5423 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5424 return 0;
5425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005426
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5428 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5429 tSpec.ts_info.psb, tSpec.ts_info.up);
5430
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5432 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5433 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5434 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5435 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5436 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5437 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5438 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5439 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5440 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5441 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5442 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5443
5444 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5445
5446 // validate the ts info ack policy
5447 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5448 {
5449 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5450 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5451 break;
5452
5453 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5454 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5455 break;
5456
5457 default:
5458 // unknown
5459 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5460 return 0;
5461 }
5462
5463 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5464 return 0;
5465}
5466
5467
5468static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5469 union iwreq_data *wrqu, char *extra)
5470{
5471 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5472 int *params = (int *)extra;
5473 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5474 v_U32_t handle;
5475
5476 // make sure the application is sufficiently priviledged
5477 // note that the kernel will do this for "set" ioctls, but since
5478 // this ioctl wants to return status to user space it must be
5479 // defined as a "get" ioctl
5480 if (!capable(CAP_NET_ADMIN))
5481 {
5482 return -EPERM;
5483 }
5484
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005485 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5486 {
5487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5488 "%s:LOGP in Progress. Ignore!!!", __func__);
5489 return -EBUSY;
5490 }
5491
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 // although we are defined to be a "get" ioctl, the params we require
5493 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5494 // is no need to copy the params from user space
5495
5496 // validate the handle
5497 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5498 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5499 {
5500 // that one is reserved
5501 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5502 return 0;
5503 }
5504
5505 *pStatus = hdd_wmm_delts(pAdapter, handle);
5506 return 0;
5507}
5508
5509
5510static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5511 union iwreq_data *wrqu, char *extra)
5512{
5513 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5514 int *params = (int *)extra;
5515 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5516 v_U32_t handle;
5517
5518 // although we are defined to be a "get" ioctl, the params we require
5519 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5520 // is no need to copy the params from user space
5521
5522 // validate the handle
5523 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5524 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5525 {
5526 // that one is reserved
5527 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5528 return 0;
5529 }
5530
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005531 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5532 {
5533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5534 "%s:LOGP in Progress. Ignore!!!", __func__);
5535 return -EBUSY;
5536 }
5537
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5539 return 0;
5540}
5541
5542
5543#ifdef FEATURE_WLAN_WAPI
5544static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5545 union iwreq_data *wrqu, char *extra)
5546{
5547 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5548 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5549 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5550 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5551
Arif Hussain7adce1b2013-11-11 22:59:34 -08005552 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005553
5554 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005555 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005556 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5557 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005558
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005559 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5560 {
5561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5562 "%s:LOGP in Progress. Ignore!!!", __func__);
5563 return -EBUSY;
5564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005565
5566 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005567 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5569 pRoamProfile->EncryptionType.numEntries = 1;
5570 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5571 pRoamProfile->mcEncryptionType.numEntries = 1;
5572 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5573
5574 pRoamProfile->AuthType.numEntries = 1;
5575 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5576 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5577 }
5578 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005579 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 }
5581 else
5582 return -EINVAL;
5583
5584 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5585
5586 return 0;
5587}
5588
5589static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5590 union iwreq_data *wrqu, char *extra)
5591{
5592 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5593 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5594
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005595 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5596 {
5597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5598 "%s:LOGP in Progress. Ignore!!!", __func__);
5599 return -EBUSY;
5600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5602
5603 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005604 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005605 printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode);
5606 return 0;
5607}
5608
5609static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5610 union iwreq_data *wrqu, char *extra)
5611{
5612 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5613// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5614 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5615 int i = 0, j = 0;
5616 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005617 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005618 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005619
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005620 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5621 {
5622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5623 "%s:LOGP in Progress. Ignore!!!", __func__);
5624 return -EBUSY;
5625 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005626
5627 if (NULL == pWapiAssocInfo)
5628 {
5629 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5630 "%s: WDA NULL context", __func__);
5631 VOS_ASSERT(0);
5632 return VOS_STATUS_E_FAILURE;
5633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005634
Arif Hussain6d2a3322013-11-17 19:50:10 -08005635 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 -07005636 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005638 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005639
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005640 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005642 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005643
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005644 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005645 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 for(i = 0 ; i < 16 ; i++) {
5647 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5648 for(j = 0 ; j < 16 ; j++)
5649 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5650 }
5651
5652 /* We are not using the entire IE as provided by the supplicant.
5653 * This is being calculated by SME. This is the same as in the
5654 * case of WPA. Only the auth mode information needs to be
5655 * extracted here*/
5656 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005657 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5659 }
5660
5661 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005662 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5664 }
5665 return 0;
5666}
5667
5668static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5669 union iwreq_data *wrqu, char *extra)
5670{
5671 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5672 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5673 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5674 tANI_U32 roamId = 0xFF;
5675 tANI_U8 *pKeyPtr = NULL;
5676 v_BOOL_t isConnected = TRUE;
5677 tCsrRoamSetKey setKey;
5678 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5680
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005681 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5682 {
5683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5684 "%s:LOGP in Progress. Ignore!!!", __func__);
5685 return -EBUSY;
5686 }
5687
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005689 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005690 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005691
Arif Hussain6d2a3322013-11-17 19:50:10 -08005692 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 -07005693 hddLog(LOG1,"Add Index:0x");
5694 for(i =0 ; i < 12 ; i++)
5695 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5696
Arif Hussain6d2a3322013-11-17 19:50:10 -08005697 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5699 for(i =0 ; i < 16 ; i++)
5700 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5701
Arif Hussain6d2a3322013-11-17 19:50:10 -08005702 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5704 for(i =0 ; i < 16 ; i++)
5705 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5706
Arif Hussain6d2a3322013-11-17 19:50:10 -08005707 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 for(i = 0 ; i < 16 ; i++)
5709 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5710
5711 // Clear the setkey memory
5712 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5713 // Store Key ID
5714 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5715 // SET WAPI Encryption
5716 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5717 // Key Directionn both TX and RX
5718 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5719 // the PAE role
5720 setKey.paeRole = 0 ;
5721
5722 switch ( pWapiKey->keyType )
5723 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005724 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 {
5726 isConnected = hdd_connIsConnected(pHddStaCtx);
5727 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5728 break;
5729 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005730 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 {
5732 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5733 break;
5734 }
5735 default:
5736 {
5737 //Any other option is invalid.
5738 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005739 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005740
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005741 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5743 break; // NEED RETURN FROM HERE ????
5744 }
5745 }
5746
5747 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5748 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5749 pKeyPtr = setKey.Key;
5750 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5751 pKeyPtr += pWapiKey->wpiekLen;
5752 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5753
5754 // Set the new key with SME.
5755 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5756
5757 if ( isConnected ) {
5758 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5759 if ( halStatus != eHAL_STATUS_SUCCESS )
5760 {
5761 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5762 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5763
5764 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5765 }
5766 }
5767#if 0 /// NEED TO CHECK ON THIS
5768 else
5769 {
5770 // Store the keys in the adapter to be moved to the profile & passed to
5771 // SME in the ConnectRequest if we are not yet in connected state.
5772 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5773 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5774
5775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5776 " Saving key [idx= %d] to apply when moving to connected state ",
5777 setKey.keyId );
5778
5779 }
5780#endif
5781 return halStatus;
5782}
5783
5784static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5785 union iwreq_data *wrqu, char *extra)
5786{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005787 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005788#ifdef WLAN_DEBUG
5789 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005790 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005791#endif
5792
5793 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005794 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005795 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005796
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005797 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5798 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005799
5800 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005801
5802 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5803 {
5804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5805 "%s:LOGP in Progress. Ignore!!!", __func__);
5806 return -EBUSY;
5807 }
5808
Jeff Johnson295189b2012-06-20 16:38:30 -07005809#ifdef WLAN_DEBUG
5810 for(i =0 ; i < 16 ; i++)
5811 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5812#endif
5813
5814 return 0;
5815}
5816
5817static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5818 union iwreq_data *wrqu, char *extra)
5819{
5820 /* Yet to implement this function, 19th April 2010 */
5821 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5822
5823 return 0;
5824}
5825#endif /* FEATURE_WLAN_WAPI */
5826
5827#ifdef WLAN_FEATURE_VOWIFI_11R
5828//
5829//
5830// Each time the supplicant has the auth_request or reassoc request
5831// IEs ready. This is pushed to the driver. The driver will inturn use
5832// it to send out the auth req and reassoc req for 11r FT Assoc.
5833//
5834static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5835 union iwreq_data *wrqu, char *extra)
5836{
5837 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5838 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5839 //v_CONTEXT_t pVosContext;
5840
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005841 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5842 {
5843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5844 "%s:LOGP in Progress. Ignore!!!", __func__);
5845 return -EBUSY;
5846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 if (!wrqu->data.length)
5848 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005849 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 return -EINVAL;
5851 }
5852 if (wrqu->data.pointer == NULL)
5853 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005854 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 return -EINVAL;
5856 }
5857
5858 // Added for debug on reception of Re-assoc Req.
5859 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5860 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005861 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005863 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 }
5865
5866#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005867 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005868#endif
5869
5870 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005871 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 wrqu->data.length);
5873
5874 return 0;
5875}
5876#endif
5877
Amar Singhalf3a6e762013-02-19 15:06:50 -08005878static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005879 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005881{
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005883 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005885 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005886 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005887 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5888 int idx;
5889 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005890
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005891 if (pHddCtx->isLogpInProgress)
5892 {
5893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5894 "%s:LOGP in Progress. Ignore!!!", __func__);
5895 return -EBUSY;
5896 }
5897
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305898 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5899 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305900#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005901
Amar Singhalf3a6e762013-02-19 15:06:50 -08005902 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5903 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005904 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005905 hddLog(VOS_TRACE_LEVEL_ERROR,
5906 "%s: vos_mem_alloc failed", __func__);
5907 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005908 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005909
5910 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5911
5912 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5913 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5914
5915 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5916 mc_addr_list_ptr->ulMulticastAddrCnt);
5917
5918 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005919 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005920 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5921 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5922
5923 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5924 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005925 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005926
Amar Singhalf3a6e762013-02-19 15:06:50 -08005927 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5928 vos_mem_free(mc_addr_list_ptr);
5929 if (eHAL_STATUS_SUCCESS != ret_val)
5930 {
5931 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5932 __func__);
5933 return -EINVAL;
5934 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305935#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305936 }
5937 else
5938 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005939
Amar Singhalf3a6e762013-02-19 15:06:50 -08005940 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5941 "%s: Set MC BC Filter Config request: %d suspend %d",
5942 __func__, pRequest->mcastBcastFilterSetting,
5943 pHddCtx->hdd_wlan_suspended);
5944
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305945 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005946
5947 if (pHddCtx->hdd_wlan_suspended)
5948 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005949 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5950 if (NULL == wlanRxpFilterParam)
5951 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305952 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005953 "%s: vos_mem_alloc failed", __func__);
5954 return -EINVAL;
5955 }
5956
Amar Singhalf3a6e762013-02-19 15:06:50 -08005957 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5958 pRequest->mcastBcastFilterSetting;
5959 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5960
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305961 hdd_conf_hostoffload(pAdapter, TRUE);
5962 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5963 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005964
5965 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5966 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305967 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08005968 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5969 wlanRxpFilterParam->setMcstBcstFilter);
5970
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305971 if (eHAL_STATUS_SUCCESS !=
5972 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5973 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08005974 {
5975 hddLog(VOS_TRACE_LEVEL_ERROR,
5976 "%s: Failure to execute set HW MC/BC Filter request",
5977 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005978 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005979 return -EINVAL;
5980 }
5981
Amar Singhalf3a6e762013-02-19 15:06:50 -08005982 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005984
5985 return 0;
5986}
5987
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005988static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005989 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 union iwreq_data *wrqu, char *extra)
5991{
5992 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5993 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305994 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005995 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005996
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305997 //Reset the filter to INI value as we have to clear the dynamic filter
5998 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07005999
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306000 //Configure FW with new setting
6001 if (pHddCtx->hdd_wlan_suspended)
6002 {
6003 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6004 if (NULL == wlanRxpFilterParam)
6005 {
6006 hddLog(VOS_TRACE_LEVEL_ERROR,
6007 "%s: vos_mem_alloc failed", __func__);
6008 return -EINVAL;
6009 }
6010
6011 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6012 pHddCtx->configuredMcastBcastFilter;
6013 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6014
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306015 hdd_conf_hostoffload(pAdapter, TRUE);
6016 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6017 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306018
6019 if (eHAL_STATUS_SUCCESS !=
6020 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6021 wlanRxpFilterParam))
6022 {
6023 hddLog(VOS_TRACE_LEVEL_ERROR,
6024 "%s: Failure to execute set HW MC/BC Filter request",
6025 __func__);
6026 vos_mem_free(wlanRxpFilterParam);
6027 return -EINVAL;
6028 }
6029 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 return 0;
6031}
6032
6033static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6034 union iwreq_data *wrqu, char *extra)
6035{
6036 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006037 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 tSirHostOffloadReq offloadRequest;
6039
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006040 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6041 {
6042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6043 "%s:LOGP in Progress. Ignore!!!", __func__);
6044 return -EBUSY;
6045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 /* Debug display of request components. */
6047 switch (pRequest->offloadType)
6048 {
6049 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006050 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 switch (pRequest->enableOrDisable)
6052 {
6053 case WLAN_OFFLOAD_DISABLE:
6054 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6055 break;
6056 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6057 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6058 case WLAN_OFFLOAD_ENABLE:
6059 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6060 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6061 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6062 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6063 }
6064 break;
6065
6066 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006067 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006068 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 switch (pRequest->enableOrDisable)
6070 {
6071 case WLAN_OFFLOAD_DISABLE:
6072 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6073 break;
6074 case WLAN_OFFLOAD_ENABLE:
6075 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6076 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6077 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6078 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6079 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6080 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6081 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6082 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6083 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6084 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6085 }
6086 }
6087
6088 /* Execute offload request. The reason that we can copy the request information
6089 from the ioctl structure to the SME structure is that they are laid out
6090 exactly the same. Otherwise, each piece of information would have to be
6091 copied individually. */
6092 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006093 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6094 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006096 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 __func__);
6098 return -EINVAL;
6099 }
6100
6101 return 0;
6102}
6103
6104static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6105 union iwreq_data *wrqu, char *extra)
6106{
6107 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006108 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 tSirKeepAliveReq keepaliveRequest;
6110
6111 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6112 {
6113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006114 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 return 0;
6116 }
6117
6118 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006119 hddLog(VOS_TRACE_LEVEL_INFO,
6120 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6121 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006122
6123 switch (pRequest->packetType)
6124 {
6125 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006126 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 break;
6128
6129 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6130
Arif Hussain6d2a3322013-11-17 19:50:10 -08006131 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006132 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006133
6134 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6135 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6136 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6137
6138 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6139 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6140 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6141
6142 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6143 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6144 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6145 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6146 break;
6147
6148 }
6149
6150 /* Execute keep alive request. The reason that we can copy the request information
6151 from the ioctl structure to the SME structure is that they are laid out
6152 exactly the same. Otherwise, each piece of information would have to be
6153 copied individually. */
6154 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6155
Arif Hussain6d2a3322013-11-17 19:50:10 -08006156 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006157
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006158 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006159 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006161 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 __func__);
6163 return -EINVAL;
6164 }
6165
6166 return 0;
6167}
6168
6169#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006170int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006171 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006172{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006173 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6174 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 int i=0;
6176
6177 if (pHddCtx->cfg_ini->disablePacketFilter)
6178 {
6179 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006180 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 return 0;
6182 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006183 if (pHddCtx->isLogpInProgress)
6184 {
6185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6186 "%s:LOGP in Progress. Ignore!!!", __func__);
6187 return -EBUSY;
6188 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 /* Debug display of request components. */
6190 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006191 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006192
6193 switch (pRequest->filterAction)
6194 {
6195 case HDD_RCV_FILTER_SET:
6196 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006197 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006198
6199 packetFilterSetReq.filterId = pRequest->filterId;
6200 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6201 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006202 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 __func__, pRequest->numParams);
6204 return -EINVAL;
6205 }
6206 packetFilterSetReq.numFieldParams = pRequest->numParams;
6207 packetFilterSetReq.coalesceTime = 0;
6208 packetFilterSetReq.filterType = 1;
6209 for (i=0; i < pRequest->numParams; i++)
6210 {
6211 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6212 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6213 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6214 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6215 packetFilterSetReq.paramsData[i].reserved = 0;
6216
Arif Hussain6d2a3322013-11-17 19:50:10 -08006217 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6219 packetFilterSetReq.filterType);
6220
Arif Hussain6d2a3322013-11-17 19:50:10 -08006221 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6223
6224 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6225 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6226 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6227 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6228
Arif Hussain6d2a3322013-11-17 19:50:10 -08006229 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6231 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6232 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6233
Arif Hussain6d2a3322013-11-17 19:50:10 -08006234 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6236 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6237 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6238 }
6239
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006240 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006242 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 __func__);
6244 return -EINVAL;
6245 }
6246
6247 break;
6248
6249 case HDD_RCV_FILTER_CLEAR:
6250
Arif Hussain6d2a3322013-11-17 19:50:10 -08006251 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006252 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006254 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006256 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 __func__);
6258 return -EINVAL;
6259 }
6260 break;
6261
6262 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006263 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006264 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 return -EINVAL;
6266 }
6267 return 0;
6268}
6269
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306270int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6271 tANI_U8 sessionId)
6272{
6273 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6274 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6275
6276 if (NULL == pHddCtx)
6277 {
6278 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6279 return -EINVAL;
6280 }
6281
6282 if (pHddCtx->isLogpInProgress)
6283 {
6284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6285 "%s:LOGP in Progress. Ignore!!!", __func__);
6286 return -EBUSY;
6287 }
6288
6289 if (pHddCtx->cfg_ini->disablePacketFilter)
6290 {
6291 hddLog(VOS_TRACE_LEVEL_ERROR,
6292 "%s: Packet Filtering Disabled. Returning ",
6293 __func__ );
6294 return -EINVAL;
6295 }
6296
6297 switch (filterType)
6298 {
6299 /* For setting IPV6 MC and UC Filter we need to configure
6300 * 2 filters, one for MC and one for UC.
6301 * The Filter ID shouldn't be swapped, which results in making
6302 * UC Filter ineffective.
6303 * We have Hardcode all the values
6304 *
6305 * Reason for a seperate UC filter is because, driver need to
6306 * specify the FW that the specific filter is for unicast
6307 * otherwise FW will not pass the unicast frames by default
6308 * through the filter. This is required to avoid any performance
6309 * hits when no unicast filter is set and only MC/BC are set.
6310 * The way driver informs host is by using the MAC protocol
6311 * layer, CMP flag set to MAX, CMP Data set to 1.
6312 */
6313
6314 case HDD_FILTER_IPV6_MC_UC:
6315 /* Setting IPV6 MC Filter below
6316 */
6317 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6318 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6319 packetFilterSetReq.numFieldParams = 2;
6320 packetFilterSetReq.paramsData[0].protocolLayer =
6321 HDD_FILTER_PROTO_TYPE_MAC;
6322 packetFilterSetReq.paramsData[0].cmpFlag =
6323 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6324 packetFilterSetReq.paramsData[0].dataOffset =
6325 WLAN_HDD_80211_FRM_DA_OFFSET;
6326 packetFilterSetReq.paramsData[0].dataLength = 1;
6327 packetFilterSetReq.paramsData[0].compareData[0] =
6328 HDD_IPV6_MC_CMP_DATA;
6329
6330 packetFilterSetReq.paramsData[1].protocolLayer =
6331 HDD_FILTER_PROTO_TYPE_ARP;
6332 packetFilterSetReq.paramsData[1].cmpFlag =
6333 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6334 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6335 packetFilterSetReq.paramsData[1].dataLength = 2;
6336 packetFilterSetReq.paramsData[1].compareData[0] =
6337 HDD_IPV6_CMP_DATA_0;
6338 packetFilterSetReq.paramsData[1].compareData[1] =
6339 HDD_IPV6_CMP_DATA_1;
6340
6341
6342 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6343 &packetFilterSetReq, sessionId))
6344 {
6345 hddLog(VOS_TRACE_LEVEL_ERROR,
6346 "%s: Failure to execute Set IPv6 Mulicast Filter",
6347 __func__);
6348 return -EINVAL;
6349 }
6350
6351 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6352
6353 /*
6354 * Setting IPV6 UC Filter below
6355 */
6356 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6357 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6358 packetFilterSetReq.numFieldParams = 2;
6359 packetFilterSetReq.paramsData[0].protocolLayer =
6360 HDD_FILTER_PROTO_TYPE_MAC;
6361 packetFilterSetReq.paramsData[0].cmpFlag =
6362 HDD_FILTER_CMP_TYPE_MAX;
6363 packetFilterSetReq.paramsData[0].dataOffset = 0;
6364 packetFilterSetReq.paramsData[0].dataLength = 1;
6365 packetFilterSetReq.paramsData[0].compareData[0] =
6366 HDD_IPV6_UC_CMP_DATA;
6367
6368 packetFilterSetReq.paramsData[1].protocolLayer =
6369 HDD_FILTER_PROTO_TYPE_ARP;
6370 packetFilterSetReq.paramsData[1].cmpFlag =
6371 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6372 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6373 packetFilterSetReq.paramsData[1].dataLength = 2;
6374 packetFilterSetReq.paramsData[1].compareData[0] =
6375 HDD_IPV6_CMP_DATA_0;
6376 packetFilterSetReq.paramsData[1].compareData[1] =
6377 HDD_IPV6_CMP_DATA_1;
6378
6379 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6380 &packetFilterSetReq, sessionId))
6381 {
6382 hddLog(VOS_TRACE_LEVEL_ERROR,
6383 "%s: Failure to execute Set IPv6 Unicast Filter",
6384 __func__);
6385 return -EINVAL;
6386 }
6387
6388 break;
6389
6390 case HDD_FILTER_IPV6_MC:
6391 /*
6392 * IPV6 UC Filter might be already set,
6393 * clear the UC Filter. As the Filter
6394 * IDs are static, we can directly clear it.
6395 */
6396 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6397 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6398 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6399 &packetFilterClrReq, sessionId))
6400 {
6401 hddLog(VOS_TRACE_LEVEL_ERROR,
6402 "%s: Failure to execute Clear IPv6 Unicast Filter",
6403 __func__);
6404 return -EINVAL;
6405 }
6406
6407 /*
6408 * Setting IPV6 MC Filter below
6409 */
6410 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6411 packetFilterSetReq.numFieldParams = 2;
6412 packetFilterSetReq.paramsData[0].protocolLayer =
6413 HDD_FILTER_PROTO_TYPE_MAC;
6414 packetFilterSetReq.paramsData[0].cmpFlag =
6415 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6416 packetFilterSetReq.paramsData[0].dataOffset =
6417 WLAN_HDD_80211_FRM_DA_OFFSET;
6418 packetFilterSetReq.paramsData[0].dataLength = 1;
6419 packetFilterSetReq.paramsData[0].compareData[0] =
6420 HDD_IPV6_MC_CMP_DATA;
6421
6422 packetFilterSetReq.paramsData[1].protocolLayer =
6423 HDD_FILTER_PROTO_TYPE_ARP;
6424 packetFilterSetReq.paramsData[1].cmpFlag =
6425 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6426 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6427 packetFilterSetReq.paramsData[1].dataLength = 2;
6428 packetFilterSetReq.paramsData[1].compareData[0] =
6429 HDD_IPV6_CMP_DATA_0;
6430 packetFilterSetReq.paramsData[1].compareData[1] =
6431 HDD_IPV6_CMP_DATA_1;
6432
6433
6434 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6435 &packetFilterSetReq, sessionId))
6436 {
6437 hddLog(VOS_TRACE_LEVEL_ERROR,
6438 "%s: Failure to execute Set IPv6 Multicast Filter",
6439 __func__);
6440 return -EINVAL;
6441 }
6442 break;
6443
6444 default :
6445 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6446 "%s: Packet Filter Request: Invalid",
6447 __func__);
6448 return -EINVAL;
6449 }
6450 return 0;
6451}
6452
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306453void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006454{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306455 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306456 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006457 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306458 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006459
Yue Ma3ede6052013-08-29 00:33:26 -07006460 if (NULL == pHddCtx)
6461 {
6462 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6463 return;
6464 }
6465
6466 hHal = pHddCtx->hHal;
6467
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306468 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006469 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306470 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6471 return;
6472 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306473
6474 /* Check if INI is enabled or not, other wise just return
6475 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306476 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306477 {
6478 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6479 if (NULL == pMulticastAddrs)
6480 {
6481 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6482 return;
6483 }
6484
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 if (set)
6486 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306487 /* Following pre-conditions should be satisfied before wei
6488 * configure the MC address list.
6489 */
6490 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6491 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6492 && pAdapter->mc_addr_list.mc_cnt
6493 && (eConnectionState_Associated ==
6494 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6495 {
6496 pMulticastAddrs->ulMulticastAddrCnt =
6497 pAdapter->mc_addr_list.mc_cnt;
6498 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6499 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006500 memcpy(pMulticastAddrs->multicastAddr[i],
6501 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306502 sizeof(pAdapter->mc_addr_list.addr[i]));
6503 hddLog(VOS_TRACE_LEVEL_INFO,
6504 "%s: %s multicast filter: addr ="
6505 MAC_ADDRESS_STR,
6506 __func__, set ? "setting" : "clearing",
6507 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6508 }
6509 /* Set multicast filter */
6510 sme_8023MulticastList(hHal, pAdapter->sessionId,
6511 pMulticastAddrs);
6512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306514 else
6515 {
6516 /* Need to clear only if it was previously configured
6517 */
6518 if (pAdapter->mc_addr_list.isFilterApplied)
6519 {
6520 pMulticastAddrs->ulMulticastAddrCnt = 0;
6521 sme_8023MulticastList(hHal, pAdapter->sessionId,
6522 pMulticastAddrs);
6523 }
6524
6525 }
6526 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006527 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306529 else
6530 {
6531 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306532 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306533 }
6534 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006535}
6536
6537static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6538 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306539{
Jeff Johnson295189b2012-06-20 16:38:30 -07006540 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006541 tpPacketFilterCfg pRequest = NULL;
6542 int ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006543
Arif Hussain0273cba2014-01-07 20:58:29 -08006544 /* ODD number is used for set, copy data using copy_from_user */
6545 pRequest = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
6546 wrqu->data.length);
6547 if (NULL == pRequest)
6548 {
6549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6550 "mem_alloc_copy_from_user_helper fail");
6551 return -ENOMEM;
6552 }
6553
6554 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6555 kfree(pRequest);
6556
6557 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006558}
6559#endif
6560static int iw_get_statistics(struct net_device *dev,
6561 struct iw_request_info *info,
6562 union iwreq_data *wrqu, char *extra)
6563{
6564
6565 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6566 eHalStatus status = eHAL_STATUS_SUCCESS;
6567 hdd_wext_state_t *pWextState;
6568 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6569 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6570 char *p = extra;
6571 int tlen = 0;
6572 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6573
6574 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6575 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6576
6577 ENTER();
6578
6579 if (pHddCtx->isLogpInProgress) {
6580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6581 return -EINVAL;
6582 }
6583
6584 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6585
6586 wrqu->txpower.value = 0;
6587 }
6588 else {
6589 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6590 SME_SUMMARY_STATS |
6591 SME_GLOBAL_CLASSA_STATS |
6592 SME_GLOBAL_CLASSB_STATS |
6593 SME_GLOBAL_CLASSC_STATS |
6594 SME_GLOBAL_CLASSD_STATS |
6595 SME_PER_STA_STATS,
6596 hdd_StatisticsCB, 0, FALSE,
6597 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6598
6599 if (eHAL_STATUS_SUCCESS != status)
6600 {
6601 hddLog(VOS_TRACE_LEVEL_ERROR,
6602 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006603 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006604 return -EINVAL;
6605 }
6606
6607 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6608
6609 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6610 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6611 {
6612 hddLog(VOS_TRACE_LEVEL_ERROR,
6613 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006614 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 /*Remove the SME statistics list by passing NULL in callback argument*/
6616 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6617 SME_SUMMARY_STATS |
6618 SME_GLOBAL_CLASSA_STATS |
6619 SME_GLOBAL_CLASSB_STATS |
6620 SME_GLOBAL_CLASSC_STATS |
6621 SME_GLOBAL_CLASSD_STATS |
6622 SME_PER_STA_STATS,
6623 NULL, 0, FALSE,
6624 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6625
6626 return -EINVAL;
6627 }
6628 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6629 (tANI_U8) sizeof (pStats->retry_cnt),
6630 (char*) &(pStats->retry_cnt[0]),
6631 tlen);
6632
6633 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6634 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6635 (char*) &(pStats->multiple_retry_cnt[0]),
6636 tlen);
6637
6638 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6639 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6640 (char*) &(pStats->tx_frm_cnt[0]),
6641 tlen);
6642
6643 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6644 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6645 (char*) &(pStats->rx_frm_cnt),
6646 tlen);
6647
6648 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6649 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6650 (char*) &(pStats->frm_dup_cnt),
6651 tlen);
6652
6653 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6654 (tANI_U8) sizeof (pStats->fail_cnt),
6655 (char*) &(pStats->fail_cnt[0]),
6656 tlen);
6657
6658 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6659 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6660 (char*) &(pStats->rts_fail_cnt),
6661 tlen);
6662
6663 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6664 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6665 (char*) &(pStats->ack_fail_cnt),
6666 tlen);
6667
6668 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6669 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6670 (char*) &(pStats->rts_succ_cnt),
6671 tlen);
6672
6673 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6674 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6675 (char*) &(pStats->rx_discard_cnt),
6676 tlen);
6677
6678 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6679 (tANI_U8) sizeof (pStats->rx_error_cnt),
6680 (char*) &(pStats->rx_error_cnt),
6681 tlen);
6682
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006683 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006684 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006685 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006686 tlen);
6687
6688 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6689 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6690 (char*) &(dStats->rx_byte_cnt),
6691 tlen);
6692
6693 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6694 (tANI_U8) sizeof (dStats->rx_rate),
6695 (char*) &(dStats->rx_rate),
6696 tlen);
6697
6698 /* Transmit rate, in units of 500 kbit/sec */
6699 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6700 (tANI_U8) sizeof (aStats->tx_rate),
6701 (char*) &(aStats->tx_rate),
6702 tlen);
6703
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006704 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6705 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6706 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006707 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006708 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6709 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6710 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006711 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006712 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6713 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6714 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006715 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006716 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6717 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6718 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006719 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006720 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6721 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6722 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006723 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006724 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6725 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6726 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006727 tlen);
6728
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 wrqu->data.length = tlen;
6730
6731 }
6732
6733 EXIT();
6734
6735 return 0;
6736}
6737
6738
6739#ifdef FEATURE_WLAN_SCAN_PNO
6740
6741/*Max Len for PNO notification*/
6742#define MAX_PNO_NOTIFY_LEN 100
6743void found_pref_network_cb (void *callbackContext,
6744 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6745{
6746 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6747 union iwreq_data wrqu;
6748 char buf[MAX_PNO_NOTIFY_LEN+1];
6749
6750 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6751 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6752
6753 // create the event
6754 memset(&wrqu, 0, sizeof(wrqu));
6755 memset(buf, 0, sizeof(buf));
6756
6757 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6758 pPrefNetworkFoundInd->ssId.ssId,
6759 (unsigned int)pPrefNetworkFoundInd->rssi);
6760
6761 wrqu.data.pointer = buf;
6762 wrqu.data.length = strlen(buf);
6763
6764 // send the event
6765
6766 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6767
6768}
6769
6770
6771/*string based input*/
6772VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6773 union iwreq_data *wrqu, char *extra, int nOffset)
6774{
6775 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006776 /* pnoRequest is a large struct, so we make it static to avoid stack
6777 overflow. This API is only invoked via ioctl, so it is
6778 serialized by the kernel rtnl_lock and hence does not need to be
6779 reentrant */
6780 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006781 char *ptr;
6782 v_U8_t i,j, ucParams, ucMode;
6783 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6784
6785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6786 "PNO data len %d data %s",
6787 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006788 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006789
6790 if (wrqu->data.length <= nOffset )
6791 {
6792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6793 return VOS_STATUS_E_FAILURE;
6794 }
6795
6796 pnoRequest.enable = 0;
6797 pnoRequest.ucNetworksCount = 0;
6798 /*-----------------------------------------------------------------------
6799 Input is string based and expected to be like this:
6800
6801 <enabled> <netw_count>
6802 for each network:
6803 <ssid_len> <ssid> <authentication> <encryption>
6804 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6805 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6806
6807 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006808 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 -07006809
6810 this translates into:
6811 -----------------------------
6812 enable PNO
6813 look for 2 networks:
6814 test - with authentication type 0 and encryption type 0,
6815 that can be found on 3 channels: 1 6 and 11 ,
6816 SSID bcast type is unknown (directed probe will be sent if AP not found)
6817 and must meet -40dBm RSSI
6818
6819 test2 - with auth and enrytption type 4/4
6820 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6821 bcast type is non-bcast (directed probe will be sent)
6822 and must not meet any RSSI threshold
6823
Jeff Johnson8301aa12013-03-28 14:27:29 -07006824 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006826 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006827
Wilson Yang623f6592013-10-08 16:33:37 -07006828 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6829 {
6830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6831 "PNO enable input is not valid %s",ptr);
6832 return VOS_STATUS_E_FAILURE;
6833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006834
6835 if ( 0 == pnoRequest.enable )
6836 {
6837 /*Disable PNO*/
6838 memset(&pnoRequest, 0, sizeof(pnoRequest));
6839 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6840 pAdapter->sessionId,
6841 found_pref_network_cb, pAdapter);
6842 return VOS_STATUS_SUCCESS;
6843 }
6844
6845 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006846
6847 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6848 {
6849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6850 "PNO count input not valid %s",ptr);
6851 return VOS_STATUS_E_FAILURE;
6852
6853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006854
6855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6856 "PNO enable %d networks count %d offset %d",
6857 pnoRequest.enable,
6858 pnoRequest.ucNetworksCount,
6859 nOffset);
6860
6861 /* Parameters checking:
6862 ucNetworksCount has to be larger than 0*/
6863 if (( 0 == pnoRequest.ucNetworksCount ) ||
6864 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6865 {
6866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6867 return VOS_STATUS_E_FAILURE;
6868 }
6869
6870 ptr += nOffset;
6871
6872 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6873 {
6874
6875 pnoRequest.aNetworks[i].ssId.length = 0;
6876
Wilson Yang623f6592013-10-08 16:33:37 -07006877 ucParams = sscanf(ptr,"%hhu %n",
6878 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6879
6880 if (1 != ucParams)
6881 {
6882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6883 "PNO ssid length input is not valid %s",ptr);
6884 return VOS_STATUS_E_FAILURE;
6885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006886
6887 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6888 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6889 {
6890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6891 "SSID Len %d is not correct for network %d",
6892 pnoRequest.aNetworks[i].ssId.length, i);
6893 return VOS_STATUS_E_FAILURE;
6894 }
6895
6896 /*Advance to SSID*/
6897 ptr += nOffset;
6898
Jeff Johnson8301aa12013-03-28 14:27:29 -07006899 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006900 pnoRequest.aNetworks[i].ssId.length);
6901 ptr += pnoRequest.aNetworks[i].ssId.length;
6902
Jeff Johnson02797792013-10-26 19:17:13 -07006903 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006904 &(pnoRequest.aNetworks[i].authentication),
6905 &(pnoRequest.aNetworks[i].encryption),
6906 &(pnoRequest.aNetworks[i].ucChannelCount),
6907 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006908
Wilson Yang623f6592013-10-08 16:33:37 -07006909 if ( 3 != ucParams )
6910 {
6911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6912 "Incorrect cmd %s",ptr);
6913 return VOS_STATUS_E_FAILURE;
6914 }
6915
Jeff Johnson295189b2012-06-20 16:38:30 -07006916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006917 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006918 "auth %d encry %d channel count %d offset %d",
6919 pnoRequest.aNetworks[i].ssId.length,
6920 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6921 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6922 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6923 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6924 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6925 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6926 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6927 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6928 pnoRequest.aNetworks[i].authentication,
6929 pnoRequest.aNetworks[i].encryption,
6930 pnoRequest.aNetworks[i].ucChannelCount,
6931 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006932
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 /*Advance to channel list*/
6934 ptr += nOffset;
6935
Wilson Yang623f6592013-10-08 16:33:37 -07006936 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 {
6938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6939 "Incorrect number of channels");
6940 return VOS_STATUS_E_FAILURE;
6941 }
6942
6943 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6944 {
6945 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6946 {
Wilson Yang623f6592013-10-08 16:33:37 -07006947 if (1 != sscanf(ptr,"%hhu %n",
6948 &(pnoRequest.aNetworks[i].aChannels[j]),
6949 &nOffset))
6950 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6951 "PNO network channel input is not valid %s",ptr);
6952 return VOS_STATUS_E_FAILURE;
6953 }
6954 /*Advance to next channel number*/
6955 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006956 }
6957 }
6958
Jeff Johnson02797792013-10-26 19:17:13 -07006959 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006960 &(pnoRequest.aNetworks[i].bcastNetwType),
6961 &nOffset))
6962 {
6963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6964 "PNO broadcast network type input is not valid %s",ptr);
6965 return VOS_STATUS_E_FAILURE;
6966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006967
6968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6969 "PNO bcastNetwType %d offset %d",
6970 pnoRequest.aNetworks[i].bcastNetwType,
6971 nOffset );
6972
6973 /*Advance to rssi Threshold*/
6974 ptr += nOffset;
6975
Wilson Yang623f6592013-10-08 16:33:37 -07006976 if (1 != sscanf(ptr,"%hhu %n",
6977 &(pnoRequest.aNetworks[i].rssiThreshold),
6978 &nOffset))
6979 {
6980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6981 "PNO rssi threshold input is not valid %s",ptr);
6982 return VOS_STATUS_E_FAILURE;
6983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006984
6985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6986 "PNO rssi %d offset %d",
6987 pnoRequest.aNetworks[i].rssiThreshold,
6988 nOffset );
6989 /*Advance to next network*/
6990 ptr += nOffset;
6991 }/*For ucNetworkCount*/
6992
6993 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006994 &(pnoRequest.scanTimers.ucScanTimersCount),
6995 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006996
6997 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07006998 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006999 {
7000 ptr += nOffset;
7001
Jeff Johnson8301aa12013-03-28 14:27:29 -07007002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7003 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 pnoRequest.scanTimers.ucScanTimersCount,
7005 nOffset );
7006
7007 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7008 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 "Incorrect cmd - too many scan timers");
7011 return VOS_STATUS_E_FAILURE;
7012 }
7013
7014 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7015 {
Jeff Johnson02797792013-10-26 19:17:13 -07007016 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007017 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7018 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7019 &nOffset);
7020
Wilson Yang623f6592013-10-08 16:33:37 -07007021 if (2 != ucParams)
7022 {
7023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7024 "Incorrect cmd - diff params then expected %d", ucParams);
7025 return VOS_STATUS_E_FAILURE;
7026 }
7027
Jeff Johnson8301aa12013-03-28 14:27:29 -07007028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7029 "PNO Timer value %d Timer repeat %d offset %d",
7030 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7032 nOffset );
7033
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 ptr += nOffset;
7035 }
7036
7037 }
7038 else
7039 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7041 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007042 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7043
7044 /*Scan timers defaults to 5 minutes*/
7045 pnoRequest.scanTimers.ucScanTimersCount = 1;
7046 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7047 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7048 }
7049
Wilson Yang623f6592013-10-08 16:33:37 -07007050 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007051
7052 pnoRequest.modePNO = ucMode;
7053 /*for LA we just expose suspend option*/
7054 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7055 {
7056 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7057 }
7058
7059 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
7060 pAdapter->sessionId,
7061 found_pref_network_cb, pAdapter);
7062
7063 return VOS_STATUS_SUCCESS;
7064}/*iw_set_pno*/
7065
7066VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7067 union iwreq_data *wrqu, char *extra, int nOffset)
7068{
7069 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7070 v_U8_t rssiThreshold = 0;
7071 v_U8_t nRead;
7072
Arif Hussain7adce1b2013-11-11 22:59:34 -08007073 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007074 &rssiThreshold);
7075
7076 if ( 1 != nRead )
7077 {
7078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7079 "Incorrect format");
7080 return VOS_STATUS_E_FAILURE;
7081 }
7082
7083 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7084 return VOS_STATUS_SUCCESS;
7085}
7086
7087
7088static int iw_set_pno_priv(struct net_device *dev,
7089 struct iw_request_info *info,
7090 union iwreq_data *wrqu, char *extra)
7091{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007092 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7093
7094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007096
7097 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7098 {
7099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7100 "%s:LOGP in Progress. Ignore!!!", __func__);
7101 return -EBUSY;
7102 }
7103 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007104}
7105#endif /*FEATURE_WLAN_SCAN_PNO*/
7106
7107//Common function to SetBand
7108int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
7109{
7110 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7111 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7112 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7113 tANI_U8 band = 0;
7114 eCsrBand currBand = eCSR_BAND_MAX;
7115
7116 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
7117
7118 switch(band)
7119 {
7120 case WLAN_HDD_UI_BAND_AUTO:
7121 band = eCSR_BAND_ALL;
7122 break;
7123 case WLAN_HDD_UI_BAND_5_GHZ:
7124 band = eCSR_BAND_5G;
7125 break;
7126 case WLAN_HDD_UI_BAND_2_4_GHZ:
7127 band = eCSR_BAND_24;
7128 break;
7129 default:
7130 band = eCSR_BAND_MAX;
7131 }
7132
7133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007134 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007135
7136 if (band == eCSR_BAND_MAX)
7137 {
7138 /* Received change band request with invalid band value */
7139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007140 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 return -EIO;
7142 }
7143
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307144 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7145 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7146 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7147 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007149 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007150 band, pHddCtx->cfg_ini->nBandCapability);
7151 return -EIO;
7152 }
7153
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7155 {
7156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7157 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007158 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 return -EIO;
7160 }
7161
7162 if (currBand != band)
7163 {
7164 /* Change band request received.
7165 * Abort pending scan requests, flush the existing scan results,
7166 * and change the band capability
7167 */
7168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7169 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007170 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007171
7172 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
7173 {
7174 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7175 eHalStatus status = eHAL_STATUS_SUCCESS;
7176 long lrc;
7177
7178 /* STA already connected on current band, So issue disconnect first,
7179 * then change the band*/
7180
7181 hddLog(VOS_TRACE_LEVEL_INFO,
7182 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
7183 __func__, csrGetCurrentBand(hHal), band);
7184
7185 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7186 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7187
7188 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7189 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7190
Jeff Johnson43971f52012-07-17 12:26:56 -07007191 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 {
7193 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007194 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007195 __func__, (int)status );
7196 return -EINVAL;
7197 }
7198
7199 lrc = wait_for_completion_interruptible_timeout(
7200 &pAdapter->disconnect_comp_var,
7201 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7202
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307203 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007204
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007205 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007206 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007207
7208 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7209 }
7210 }
7211
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307212 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307214 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 {
7216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7217 "%s: failed to set the band value to %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007218 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 return -EINVAL;
7220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007222 }
7223 return 0;
7224}
7225
7226static int iw_set_band_config(struct net_device *dev,
7227 struct iw_request_info *info,
7228 union iwreq_data *wrqu, char *extra)
7229{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007230 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08007231 tANI_U8 *ptr = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 int ret = 0;
7233
Arif Hussain0273cba2014-01-07 20:58:29 -08007234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007235
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007236 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7237 {
7238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7239 "%s:LOGP in Progress. Ignore!!!", __func__);
7240 return -EBUSY;
7241 }
7242
Arif Hussain0273cba2014-01-07 20:58:29 -08007243 /* ODD number is used for set, copy data using copy_from_user */
7244 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7245 wrqu->data.length);
7246 if (NULL == ptr)
7247 {
7248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7249 "mem_alloc_copy_from_user_helper fail");
7250 return -ENOMEM;
7251 }
7252
Jeff Johnson295189b2012-06-20 16:38:30 -07007253 if (memcmp(ptr, "SETBAND ", 8) == 0)
7254 {
7255 /* Change band request received */
7256 ret = hdd_setBand_helper(dev, ptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07007257 }
Arif Hussain0273cba2014-01-07 20:58:29 -08007258 kfree(ptr);
7259
7260 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007261}
7262
7263static int iw_set_power_params_priv(struct net_device *dev,
7264 struct iw_request_info *info,
7265 union iwreq_data *wrqu, char *extra)
7266{
Arif Hussain0273cba2014-01-07 20:58:29 -08007267 int ret;
7268 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7270 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007271 /* ODD number is used for set, copy data using copy_from_user */
7272 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7273 wrqu->data.length);
7274 if (NULL == ptr)
7275 {
7276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7277 "mem_alloc_copy_from_user_helper fail");
7278 return -ENOMEM;
7279 }
7280
7281 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7282 kfree(ptr);
7283 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007284}
7285
7286
7287
7288/*string based input*/
7289VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7290 union iwreq_data *wrqu, char *extra, int nOffset)
7291{
7292 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7293 tSirSetPowerParamsReq powerRequest;
7294 char *ptr;
7295 v_U8_t ucType;
7296 v_U32_t uTotalSize, uValue;
7297 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7298
7299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7300 "Power Params data len %d data %s",
7301 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007302 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007303
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007304 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7305 {
7306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7307 "%s:LOGP in Progress. Ignore!!!", __func__);
7308 return -EBUSY;
7309 }
7310
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 if (wrqu->data.length <= nOffset )
7312 {
7313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7314 return VOS_STATUS_E_FAILURE;
7315 }
7316
7317 uTotalSize = wrqu->data.length - nOffset;
7318
7319 /*-----------------------------------------------------------------------
7320 Input is string based and expected to be like this:
7321
7322 <param_type> <param_value> <param_type> <param_value> ...
7323
7324 e.g:
7325 1 2 2 3 3 0 4 1 5 1
7326
7327 e.g. setting just a few:
7328 1 2 4 1
7329
7330 parameter types:
7331 -----------------------------
7332 1 - Ignore DTIM
7333 2 - Listen Interval
7334 3 - Broadcast Multicas Filter
7335 4 - Beacon Early Termination
7336 5 - Beacon Early Termination Interval
7337 -----------------------------------------------------------------------*/
7338 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7339 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7340 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7341 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7342 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7343
Arif Hussain7adce1b2013-11-11 22:59:34 -08007344 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007345
7346 while ( uTotalSize )
7347 {
Wilson Yang6f971452013-10-08 15:00:00 -07007348 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7349 {
7350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7351 "Invalid input parameter type %s",ptr);
7352 return VOS_STATUS_E_FAILURE;
7353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007354
7355 uTotalSize -= nOffset;
7356
7357 if (!uTotalSize)
7358 {
7359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007360 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 ucType, nOffset);
7362 return VOS_STATUS_E_FAILURE;
7363 }
7364
7365 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007366
Jeff Johnson02797792013-10-26 19:17:13 -07007367 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007368 {
7369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7370 "Invalid input parameter value %s",ptr);
7371 return VOS_STATUS_E_FAILURE;
7372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007373
7374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7375 "Power request parameter %d value %d offset %d",
7376 ucType, uValue, nOffset);
7377
7378 switch (ucType)
7379 {
7380 case eSIR_IGNORE_DTIM:
7381 powerRequest.uIgnoreDTIM = uValue;
7382 break;
7383 case eSIR_LISTEN_INTERVAL:
7384 powerRequest.uListenInterval = uValue;
7385 break;
7386 case eSIR_MCAST_BCAST_FILTER:
7387 powerRequest.uBcastMcastFilter = uValue;
7388 break;
7389 case eSIR_ENABLE_BET:
7390 powerRequest.uEnableBET = uValue;
7391 break;
7392 case eSIR_BET_INTERVAL:
7393 powerRequest.uBETInterval = uValue;
7394 break;
7395 default:
7396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007397 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007398 ucType, uValue, nOffset);
7399 return VOS_STATUS_E_FAILURE;
7400 }
7401
7402 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7404 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007405 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007407 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007408 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007409 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7410 {
7411 uTotalSize = 0;
7412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007413
7414 }/*Go for as long as we have a valid string*/
7415
7416 /* put the device into full power*/
7417 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7418
7419 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007420 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007421
7422 /* put the device back to power save*/
7423 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7424
7425 return VOS_STATUS_SUCCESS;
7426}/*iw_set_power_params*/
7427
7428
7429// Define the Wireless Extensions to the Linux Network Device structure
7430// A number of these routines are NULL (meaning they are not implemented.)
7431
7432static const iw_handler we_handler[] =
7433{
7434 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7435 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7436 (iw_handler) NULL, /* SIOCSIWNWID */
7437 (iw_handler) NULL, /* SIOCGIWNWID */
7438 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7439 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7440 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7441 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7442 (iw_handler) NULL, /* SIOCSIWSENS */
7443 (iw_handler) NULL, /* SIOCGIWSENS */
7444 (iw_handler) NULL, /* SIOCSIWRANGE */
7445 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7446 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7447 (iw_handler) NULL, /* SIOCGIWPRIV */
7448 (iw_handler) NULL, /* SIOCSIWSTATS */
7449 (iw_handler) NULL, /* SIOCGIWSTATS */
7450 iw_handler_set_spy, /* SIOCSIWSPY */
7451 iw_handler_get_spy, /* SIOCGIWSPY */
7452 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7453 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7454 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7455 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7456 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7457 (iw_handler) NULL, /* SIOCGIWAPLIST */
7458 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7459 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7460 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7461 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7462 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7463 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7464 (iw_handler) NULL, /* -- hole -- */
7465 (iw_handler) NULL, /* -- hole -- */
7466 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7467 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7468 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7469 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7470 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7471 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7472 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7473 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7474 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7475 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7476 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7477 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7478 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7479 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7480 (iw_handler) NULL, /* -- hole -- */
7481 (iw_handler) NULL, /* -- hole -- */
7482 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7483 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7484 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7485 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7486 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7487 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7488 (iw_handler) NULL, /* SIOCSIWPMKSA */
7489};
7490
7491static const iw_handler we_private[] = {
7492
7493 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7494 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7495 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7496 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7497 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7498 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7499 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7500 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7501 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7502 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007503#ifdef FEATURE_OEM_DATA_SUPPORT
7504 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7505 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7506#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007507
7508#ifdef FEATURE_WLAN_WAPI
7509 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7510 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7511 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7512 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7513 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7514 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7515#endif /* FEATURE_WLAN_WAPI */
7516#ifdef WLAN_FEATURE_VOWIFI_11R
7517 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7518#endif
7519 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7520 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7521 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7522#ifdef WLAN_FEATURE_PACKET_FILTERING
7523 ,
7524 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7525#endif
7526#ifdef FEATURE_WLAN_SCAN_PNO
7527 ,
7528 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7529#endif
7530 ,
7531 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7532 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7533 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7534 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007535 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07007536};
7537
7538/*Maximum command length can be only 15 */
7539static const struct iw_priv_args we_private_args[] = {
7540
7541 /* handlers for main ioctl */
7542 { WLAN_PRIV_SET_INT_GET_NONE,
7543 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7544 0,
7545 "" },
7546
7547 /* handlers for sub-ioctl */
7548 { WE_SET_11D_STATE,
7549 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7550 0,
7551 "set11Dstate" },
7552
7553 { WE_WOWL,
7554 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7555 0,
7556 "wowl" },
7557
7558 { WE_SET_POWER,
7559 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7560 0,
7561 "setPower" },
7562
7563 { WE_SET_MAX_ASSOC,
7564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7565 0,
7566 "setMaxAssoc" },
7567
7568 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7569 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7570 0,
7571 "setAutoChannel" },
7572
7573 { WE_SET_DATA_INACTIVITY_TO,
7574 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7575 0,
7576 "inactivityTO" },
7577
7578 { WE_SET_MAX_TX_POWER,
7579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7580 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007581 "setMaxTxPower" },
7582
7583 { WE_SET_MAX_TX_POWER_2_4,
7584 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7585 0,
7586 "setTxMaxPower2G" },
7587
7588 { WE_SET_MAX_TX_POWER_5_0,
7589 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7590 0,
7591 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007592
7593 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7594 * as well to keep same syntax as in SAP. Now onwards, STA
7595 * will support both */
7596 { WE_SET_MAX_TX_POWER,
7597 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7598 0,
7599 "setTxMaxPower" },
7600
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7602 * 1 = enable and 0 = disable */
7603 {
7604 WE_SET_HIGHER_DTIM_TRANSITION,
7605 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7606 0,
7607 "setHDtimTransn" },
7608
7609 { WE_SET_TM_LEVEL,
7610 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007611 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 "setTmLevel" },
7613
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307614 { WE_ENABLE_STRICT_FCC_REG,
7615 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7616 0,
7617 "setStrictFCCreg" },
7618
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007619 { WE_SET_DEBUG_LOG,
7620 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7621 0, "setDbgLvl" },
7622
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 /* handlers for main ioctl */
7624 { WLAN_PRIV_SET_NONE_GET_INT,
7625 0,
7626 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7627 "" },
7628
7629 /* handlers for sub-ioctl */
7630 { WE_GET_11D_STATE,
7631 0,
7632 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7633 "get11Dstate" },
7634
7635 { WE_IBSS_STATUS,
7636 0,
7637 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7638 "getAdhocStatus" },
7639
7640 { WE_PMC_STATE,
7641 0,
7642 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7643 "pmcState" },
7644
7645 { WE_GET_WLAN_DBG,
7646 0,
7647 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7648 "getwlandbg" },
7649
7650 { WE_MODULE_DOWN_IND,
7651 0,
7652 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7653 "moduleDownInd" },
7654
7655 { WE_GET_MAX_ASSOC,
7656 0,
7657 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7658 "getMaxAssoc" },
7659
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 { WE_GET_WDI_DBG,
7661 0,
7662 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7663 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007664
7665 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7666 0,
7667 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7668 "getAutoChannel" },
7669
7670 { WE_GET_CONCURRENCY_MODE,
7671 0,
7672 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7673 "getconcurrency" },
7674
7675 /* handlers for main ioctl */
7676 { WLAN_PRIV_SET_CHAR_GET_NONE,
7677 IW_PRIV_TYPE_CHAR| 512,
7678 0,
7679 "" },
7680
7681 /* handlers for sub-ioctl */
7682 { WE_WOWL_ADD_PTRN,
7683 IW_PRIV_TYPE_CHAR| 512,
7684 0,
7685 "wowlAddPtrn" },
7686
7687 { WE_WOWL_DEL_PTRN,
7688 IW_PRIV_TYPE_CHAR| 512,
7689 0,
7690 "wowlDelPtrn" },
7691
7692#if defined WLAN_FEATURE_VOWIFI
7693 /* handlers for sub-ioctl */
7694 { WE_NEIGHBOR_REPORT_REQUEST,
7695 IW_PRIV_TYPE_CHAR | 512,
7696 0,
7697 "neighbor" },
7698#endif
7699 { WE_SET_AP_WPS_IE,
7700 IW_PRIV_TYPE_CHAR| 512,
7701 0,
7702 "set_ap_wps_ie" },
7703
7704 { WE_SET_CONFIG,
7705 IW_PRIV_TYPE_CHAR| 512,
7706 0,
7707 "setConfig" },
7708
7709 /* handlers for main ioctl */
7710 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7711 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7712 0,
7713 "" },
7714
7715 /* handlers for sub-ioctl */
7716 { WE_SET_WLAN_DBG,
7717 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7718 0,
7719 "setwlandbg" },
7720
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 { WE_SET_WDI_DBG,
7722 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7723 0,
7724 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007725
7726 { WE_SET_SAP_CHANNELS,
7727 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7728 0,
7729 "setsapchannels" },
7730
7731 /* handlers for main ioctl */
7732 { WLAN_PRIV_GET_CHAR_SET_NONE,
7733 0,
7734 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7735 "" },
7736
7737 /* handlers for sub-ioctl */
7738 { WE_WLAN_VERSION,
7739 0,
7740 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7741 "version" },
7742 { WE_GET_STATS,
7743 0,
7744 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7745 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307746 { WE_GET_STATES,
7747 0,
7748 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7749 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007750 { WE_GET_CFG,
7751 0,
7752 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7753 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007754#ifdef WLAN_FEATURE_11AC
7755 { WE_GET_RSSI,
7756 0,
7757 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7758 "getRSSI" },
7759#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007760#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
7761 { WE_GET_ROAM_RSSI,
7762 0,
7763 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7764 "getRoamRSSI" },
7765#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007766 { WE_GET_WMM_STATUS,
7767 0,
7768 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7769 "getWmmStatus" },
7770 {
7771 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307772 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007773 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7774 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007775#ifdef FEATURE_WLAN_TDLS
7776 {
7777 WE_GET_TDLS_PEERS,
7778 0,
7779 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7780 "getTdlsPeers" },
7781#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007782#ifdef WLAN_FEATURE_11W
7783 {
7784 WE_GET_11W_INFO,
7785 0,
7786 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7787 "getPMFInfo" },
7788#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007789 /* handlers for main ioctl */
7790 { WLAN_PRIV_SET_NONE_GET_NONE,
7791 0,
7792 0,
7793 "" },
7794
7795 /* handlers for sub-ioctl */
7796 { WE_CLEAR_STATS,
7797 0,
7798 0,
7799 "clearStats" },
7800 { WE_INIT_AP,
7801 0,
7802 0,
7803 "initAP" },
7804 { WE_STOP_AP,
7805 0,
7806 0,
7807 "exitAP" },
7808 { WE_ENABLE_AMP,
7809 0,
7810 0,
7811 "enableAMP" },
7812 { WE_DISABLE_AMP,
7813 0,
7814 0,
7815 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007816 { WE_ENABLE_DXE_STALL_DETECT,
7817 0,
7818 0,
7819 "dxeStallDetect" },
7820 { WE_DISPLAY_DXE_SNAP_SHOT,
7821 0,
7822 0,
7823 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307824 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7825 0,
7826 0,
7827 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007828 {
7829 WE_SET_REASSOC_TRIGGER,
7830 0,
7831 0,
7832 "reassoc" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007833
7834 /* handlers for main ioctl */
7835 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7836 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7837 0,
7838 "" },
7839
7840 /* handlers for sub-ioctl */
7841 { WE_LOG_DUMP_CMD,
7842 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7843 0,
7844 "dump" },
7845
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007846 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307847 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
7848 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7849 0,
7850 "setdumplog" },
7851
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007852 { WE_MTRACE_DUMP_CMD,
7853 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7854 0,
7855 "dumplog" },
7856
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007857 /* handlers for sub ioctl */
7858 {
7859 WE_MCC_CONFIG_CREDENTIAL,
7860 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7861 0,
7862 "setMccCrdnl" },
7863
7864 /* handlers for sub ioctl */
7865 {
7866 WE_MCC_CONFIG_PARAMS,
7867 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7868 0,
7869 "setMccConfig" },
7870
Chilam NG571c65a2013-01-19 12:27:36 +05307871#ifdef FEATURE_WLAN_TDLS
7872 /* handlers for sub ioctl */
7873 {
7874 WE_TDLS_CONFIG_PARAMS,
7875 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7876 0,
7877 "setTdlsConfig" },
7878#endif
7879
Jeff Johnson295189b2012-06-20 16:38:30 -07007880 /* handlers for main ioctl */
7881 { WLAN_PRIV_ADD_TSPEC,
7882 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7883 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7884 "addTspec" },
7885
7886 /* handlers for main ioctl */
7887 { WLAN_PRIV_DEL_TSPEC,
7888 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7889 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7890 "delTspec" },
7891
7892 /* handlers for main ioctl */
7893 { WLAN_PRIV_GET_TSPEC,
7894 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7895 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7896 "getTspec" },
7897
Jeff Johnsone7245742012-09-05 17:12:55 -07007898#ifdef FEATURE_OEM_DATA_SUPPORT
7899 /* handlers for main ioctl - OEM DATA */
7900 {
7901 WLAN_PRIV_SET_OEM_DATA_REQ,
7902 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7903 0,
7904 "set_oem_data_req" },
7905
7906 /* handlers for main ioctl - OEM DATA */
7907 {
7908 WLAN_PRIV_GET_OEM_DATA_RSP,
7909 0,
7910 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
7911 "get_oem_data_rsp" },
7912#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007913
7914#ifdef FEATURE_WLAN_WAPI
7915 /* handlers for main ioctl SET_WAPI_MODE */
7916 { WLAN_PRIV_SET_WAPI_MODE,
7917 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7918 0,
7919 "SET_WAPI_MODE" },
7920
7921 /* handlers for main ioctl GET_WAPI_MODE */
7922 { WLAN_PRIV_GET_WAPI_MODE,
7923 0,
7924 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7925 "GET_WAPI_MODE" },
7926
7927 /* handlers for main ioctl SET_ASSOC_INFO */
7928 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
7929 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
7930 0,
7931 "SET_WAPI_ASSOC" },
7932
7933 /* handlers for main ioctl SET_WAPI_KEY */
7934 { WLAN_PRIV_SET_WAPI_KEY,
7935 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
7936 0,
7937 "SET_WAPI_KEY" },
7938
7939 /* handlers for main ioctl SET_WAPI_BKID */
7940 { WLAN_PRIV_SET_WAPI_BKID,
7941 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7942 0,
7943 "SET_WAPI_BKID" },
7944
7945 /* handlers for main ioctl GET_WAPI_BKID */
7946 { WLAN_PRIV_GET_WAPI_BKID,
7947 0,
7948 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7949 "GET_WAPI_BKID" },
7950#endif /* FEATURE_WLAN_WAPI */
7951
7952 /* handlers for main ioctl - host offload */
7953 {
7954 WLAN_PRIV_SET_HOST_OFFLOAD,
7955 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
7956 0,
7957 "setHostOffload" },
7958
7959 {
7960 WLAN_GET_WLAN_STATISTICS,
7961 0,
7962 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
7963 "getWlanStats" },
7964
7965 {
7966 WLAN_SET_KEEPALIVE_PARAMS,
7967 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
7968 0,
7969 "setKeepAlive" },
7970#ifdef WLAN_FEATURE_PACKET_FILTERING
7971 {
7972 WLAN_SET_PACKET_FILTER_PARAMS,
7973 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
7974 0,
7975 "setPktFilter" },
7976#endif
7977#ifdef FEATURE_WLAN_SCAN_PNO
7978 {
7979 WLAN_SET_PNO,
7980 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7981 0,
7982 "setpno" },
7983#endif
7984 {
7985 WLAN_SET_BAND_CONFIG,
7986 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7987 0,
7988 "SETBAND" },
7989 /* handlers for dynamic MC BC ioctl */
7990 {
7991 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007992 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 0,
7994 "setMCBCFilter" },
7995 {
7996 WLAN_PRIV_CLEAR_MCBC_FILTER,
7997 0,
7998 0,
7999 "clearMCBCFilter" },
8000 {
8001 WLAN_SET_POWER_PARAMS,
8002 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8003 0,
8004 "setpowerparams" },
8005 {
8006 WLAN_GET_LINK_SPEED,
8007 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308008 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008009};
8010
8011
8012
8013const struct iw_handler_def we_handler_def = {
8014 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8015 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8016 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8017
8018 .standard = (iw_handler *)we_handler,
8019 .private = (iw_handler *)we_private,
8020 .private_args = we_private_args,
8021 .get_wireless_stats = get_wireless_stats,
8022};
8023
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008024int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8025{
8026 v_U32_t cmd = 288; //Command to RIVA
8027 hdd_context_t *pHddCtx = NULL;
8028 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8029 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8030 /*
8031 *configMccParam : specify the bit which needs to be modified
8032 *allowed to update based on wlan_qcom_cfg.ini
8033 * configuration
8034 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8035 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8036 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8037 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8038 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8039 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8040 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8041 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8042 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8043 * Bit 9 : Reserved
8044 */
8045 switch (arg1)
8046 {
8047 //Update MCC SCHEDULE_TIME_SLICE parameter
8048 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8049 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8050 {
8051 if((arg2 >= 5) && (arg2 <= 20))
8052 {
8053 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8054 }
8055 else
8056 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008057 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008058 return 0;
8059 }
8060 }
8061 break;
8062
8063 //Update MCC MAX_NULL_SEND_TIME parameter
8064 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8065 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8066 {
8067 if((arg2 >= 1) && (arg2 <= 10))
8068 {
8069 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8070 }
8071 else
8072 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008073 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008074 return 0;
8075 }
8076 }
8077 break;
8078
8079 //Update MCC TX_EARLY_STOP_TIME parameter
8080 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8081 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8082 {
8083 if((arg2 >= 1) && (arg2 <= 10))
8084 {
8085 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8086 }
8087 else
8088 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008089 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008090 return 0;
8091 }
8092 }
8093 break;
8094
8095 //Update MCC RX_DRAIN_TIME parameter
8096 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8097 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8098 {
8099 if((arg2 >= 1) && (arg2 <= 10))
8100 {
8101 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8102 }
8103 else
8104 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008105 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008106 return 0;
8107 }
8108 }
8109 break;
8110
8111 //Update MCC CHANNEL_SWITCH_TIME parameter
8112 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8113 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8114 {
8115 if((arg2 >= 1) && (arg2 <= 20))
8116 {
8117 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8118 }
8119 else
8120 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008121 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008122 return 0;
8123 }
8124 }
8125 break;
8126
8127 //Update MCC MIN_CHANNEL_TIME parameter
8128 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8129 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8130 {
8131 if((arg2 >= 5) && (arg2 <= 20))
8132 {
8133 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8134 }
8135 else
8136 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008137 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008138 return 0;
8139 }
8140 }
8141 break;
8142
8143 //Update MCC PARK_BEFORE_TBTT parameter
8144 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8145 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8146 {
8147 if((arg2 >= 1) && (arg2 <= 5))
8148 {
8149 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8150 }
8151 else
8152 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008153 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008154 return 0;
8155 }
8156 }
8157 break;
8158
8159 //Update MCC MIN_AFTER_DTIM parameter
8160 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8161 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8162 {
8163 if((arg2 >= 5) && (arg2 <= 15))
8164 {
8165 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8166 }
8167 else
8168 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008169 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008170 return 0;
8171 }
8172 }
8173 break;
8174
8175 //Update MCC TOO_CLOSE_MARGIN parameter
8176 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8177 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8178 {
8179 if((arg2 >= 1) && (arg2 <= 3))
8180 {
8181 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8182 }
8183 else
8184 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008185 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008186 return 0;
8187 }
8188 }
8189 break;
8190
8191 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008192 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008193 __FUNCTION__,arg1);
8194 break;
8195 }
8196 return 0;
8197}
8198
Jeff Johnson295189b2012-06-20 16:38:30 -07008199int hdd_set_wext(hdd_adapter_t *pAdapter)
8200{
8201 hdd_wext_state_t *pwextBuf;
8202 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008203 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008204
8205 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8206
8207 // Now configure the roaming profile links. To SSID and bssid.
8208 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8209 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8210
8211 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8212 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8213
8214 /*Set the numOfChannels to zero to scan all the channels*/
8215 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8216 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8217
8218 /* Default is no encryption */
8219 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8220 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8221
8222 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8223 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8224
8225 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8226
8227 /* Default is no authentication */
8228 pwextBuf->roamProfile.AuthType.numEntries = 1;
8229 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8230
8231 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8232 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8233
8234 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008235 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008236
8237 hdd_clearRoamProfileIe(pAdapter);
8238
8239 return VOS_STATUS_SUCCESS;
8240
8241 }
8242
8243int hdd_register_wext(struct net_device *dev)
8244 {
8245 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8246 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8247 VOS_STATUS status;
8248
8249 ENTER();
8250
8251 // Zero the memory. This zeros the profile structure.
8252 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8253
8254 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8255
8256
8257 status = hdd_set_wext(pAdapter);
8258
8259 if(!VOS_IS_STATUS_SUCCESS(status)) {
8260
Arif Hussain6d2a3322013-11-17 19:50:10 -08008261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008262 return eHAL_STATUS_FAILURE;
8263 }
8264
8265 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8266 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 return eHAL_STATUS_FAILURE;
8269 }
8270
8271 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8272 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008274 return eHAL_STATUS_FAILURE;
8275 }
8276
8277 // Register as a wireless device
8278 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8279
8280 EXIT();
8281 return 0;
8282}
8283
8284int hdd_UnregisterWext(struct net_device *dev)
8285{
8286#if 0
8287 hdd_wext_state_t *wextBuf;
8288 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8289
8290 ENTER();
8291 // Set up the pointer to the Wireless Extensions state structure
8292 wextBuf = pAdapter->pWextState;
8293
8294 // De-allocate the Wireless Extensions state structure
8295 kfree(wextBuf);
8296
8297 // Clear out the pointer to the Wireless Extensions state structure
8298 pAdapter->pWextState = NULL;
8299
8300 EXIT();
8301#endif
8302 dev->wireless_handlers = NULL;
8303 return 0;
8304}
8305
8306